npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-emotor

v1.2.0

Published

带emoji表情功能的输入框组件

Downloads

16

Readme

react-emotor

带emoji表情输入功能的react编辑框组件

versionlicensesizedownload

示例图片

安装

npm install react-emotor
yarn add react-emotor

基本用法

输入框组件使用方法

输入框组件相对于普通的输入框添加了emoji表情输入功能,点击emoji表情后组件会将该emoji图片插入到输入框中并调用onChange函数向用户提供经过Unicode转码后的字符串,用户只需存储该字符串即可。

import React, { useRef } from 'react'
import { ReactEmojiEditor } from 'react-emotor'

const App = () => {
  // 创建ref用于接收编辑框组件的节点对象,
  const emotor = useRef();

  // 组件内容改变回调函数
  function contentOnChange(content) {
    console.log(content);
  }

  // 清空组件内容
  function myClean() {
    console.log("clean");
    emotor.current.clean();
  }

  // 组件获取焦点
  function myFocus() {
    console.log("onFocus");
    emotor.current.onFocus();
  }

  return (
    <div>
      <ReactEmojiEditor
        ref={emotor}
        className='myClassName'
        id="myEmotor"
        defaultValue='this is default value 😀😀😀'
        onChange={content => contentOnChange(content)}
      />
      <button onClick={myClean}>清空</button>
      <button onClick={myFocus}>聚焦</button>
    </div>
  )
}

export default App

输出框使用方法

输出框组件主要功能是将传入字符串中emoji表情转换成对应的表情图片并输出。

import React from 'react'
import { ReactEmojiShow } from 'react-emotor';

const App = () => {

  const content = '这是一段带😄😄😄emoji表情的文字';

  return (
    <ReactEmojiShow
      content={content}
    />
  )
}

export default App

注意事项

由于项目中emoji表情采用Unicode编码格式存储,因此使用组件前需要确保数据库编码格式为utf-8mb4

API

ReactEmojiEditor

| 参数 | 说明 | 类型 | 默认值 | | ------------ | ---------------------------- | ----------------- | ------------ | | width | 组件宽度 | string | 100% | | placeholder | 编辑框默认内容 | string | '' | | className | 组件类名 | string | '' | | id | 组件输入框id(同页面多次引入组件时需要指定不同的id) | string | 'emotor' | | defaultValue | 组件默认显示的内容 | string | '' | | onChange | 内容改变时调用此函数 | function(content) | function(){} |

关于作者

作者: 举个锤子

联系邮箱:[email protected]

Gitee: https://gitee.com/jia_hongxing

博客网址:https://www.jhxblog.cn

鸣谢

该项目外观样式参考了emojionearea项目,感谢作者编写并开源优秀的JavaScript代码

感谢周哥在项目开发过程中对作者的解答与指导

更新日志

v1.2.0版本,2022-05-19

  1. 修改:修改表情图片地址,使用无损压缩后的图片,提高加载速度
  2. 修改:修复无法正常插入表情的问题
  3. 新功能:新增获取焦点接口,提供组件获取焦点功能
  4. 新功能:新增清空组件内容接口,提供清空组件内容功能
  5. 新功能:新增组件默认值参数,创建组件时可传入默认显示的内容
  6. 新功能:新增id参数,用户可在页面中引入多个ReactEmojiEditor组件

v1.1.0版本,2022-03-29

  1. 修改:修改表情图片地址,使用阿里云oss存储

v1.0.5版本,2021-09-25

  1. 修改:删除项目中正则表达式的断言写法,兼容Safari浏览器

v1.0.3版本,2021-09-03

  1. 修改:修复图片显示问题
  2. 修改:修复选择框被遮挡问题

v1.0.0版本,2021-09-02

  1. 新功能:emoji表情输入
  2. 新功能:Unicode编码格式数据解析并输出
  3. 修改:更改编辑框默认显示数据