Gathering detailed insights and metrics for react-emotor
Gathering detailed insights and metrics for react-emotor
npm install react-emotor
Typescript
Module System
Node Version
NPM Version
73.4
Supply Chain
99
Quality
75.6
Maintenance
100
Vulnerability
100
License
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
2,180
Last Day
1
Last Week
6
Last Month
35
Last Year
625
Minified
Minified + Gzipped
Latest Version
1.2.0
Package Id
react-emotor@1.2.0
Unpacked Size
195.34 kB
Size
45.29 kB
File Count
14
NPM Version
6.14.10
Node Version
14.15.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-66.7%
6
Compared to previous week
Last month
-58.3%
35
Compared to previous month
Last year
50.2%
625
Compared to previous year
带emoji表情输入功能的react编辑框组件
1npm install react-emotor
1yarn add react-emotor
输入框组件相对于普通的输入框添加了emoji表情输入功能,点击emoji表情后组件会将该emoji图片插入到输入框中并调用onChange函数向用户提供经过Unicode转码后的字符串,用户只需存储该字符串即可。
1import React, { useRef } from 'react' 2import { ReactEmojiEditor } from 'react-emotor' 3 4const App = () => { 5 // 创建ref用于接收编辑框组件的节点对象, 6 const emotor = useRef(); 7 8 // 组件内容改变回调函数 9 function contentOnChange(content) { 10 console.log(content); 11 } 12 13 // 清空组件内容 14 function myClean() { 15 console.log("clean"); 16 emotor.current.clean(); 17 } 18 19 // 组件获取焦点 20 function myFocus() { 21 console.log("onFocus"); 22 emotor.current.onFocus(); 23 } 24 25 return ( 26 <div> 27 <ReactEmojiEditor 28 ref={emotor} 29 className='myClassName' 30 id="myEmotor" 31 defaultValue='this is default value 😀😀😀' 32 onChange={content => contentOnChange(content)} 33 /> 34 <button onClick={myClean}>清空</button> 35 <button onClick={myFocus}>聚焦</button> 36 </div> 37 ) 38} 39 40export default App
输出框组件主要功能是将传入字符串中emoji表情转换成对应的表情图片并输出。
1import React from 'react' 2import { ReactEmojiShow } from 'react-emotor'; 3 4const App = () => { 5 6 const content = '这是一段带😄😄😄emoji表情的文字'; 7 8 return ( 9 <ReactEmojiShow 10 content={content} 11 /> 12 ) 13} 14 15export default App
由于项目中emoji表情采用Unicode编码格式存储,因此使用组件前需要确保数据库编码格式为utf-8mb4。
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
width | 组件宽度 | string | 100% |
placeholder | 编辑框默认内容 | string | '' |
className | 组件类名 | string | '' |
id | 组件输入框id(同页面多次引入组件时需要指定不同的id) | string | 'emotor' |
defaultValue | 组件默认显示的内容 | string | '' |
onChange | 内容改变时调用此函数 | function(content) | function(){} |
作者: 举个锤子
联系邮箱:jhx2433@163.com
Gitee: https://gitee.com/jia_hongxing
该项目外观样式参考了emojionearea项目,感谢作者编写并开源优秀的JavaScript代码
感谢周哥在项目开发过程中对作者的解答与指导
No vulnerabilities found.
No security vulnerabilities found.