emoji-box

Overview

emoji-box

特别说明:

  • 基于 Vue3 编写,Vue2 不适用。
  • 本项目中的表情(圆脸、其他、手势、动物)基于微软开源表情制作,可商用。
  • 如涉及其他表情用于不正当的行为,后果由使用者承担责任,与本项目无关。

安装

npm

npm i emoji-box

yarn

yarn add emoji-box

引入

Vue3

// 引入安装包和样式
import { createApp } from 'vue'
import App from './App.vue'
import Emoji from 'emoji-box'
import 'emoji-box/dist/style.css'

const app = createApp(App)
app.use(Emoji)
// 自定义图片 cdn 地址
// app.use(Emoji, { cdn: '' })

Nuxt3 在 plugins 下新建 emoji.ts 文件

import { defineNuxtPlugin } from '#app'
import Emoji from 'emoji-box'
import 'emoji-box/dist/style.css'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(Emoji)
  // 自定义图片 cdn 地址
  // nuxtApp.vueApp.use(Emoji, { cdn: '' })
})

自定义图片 cdn 地址说明(可选)

示例

<template>
  <div class="app">
    <header>
      <h1>emoji-box</h1>
      <span>
        <a href="https://www.npmjs.com/package/emoji-box" target="_blank">使用文档</a>
        &nbsp;&nbsp;
        <a href="https://github.com/newbill/emoji-box" target="_blank">仓库地址</a>
      </span>
    </header>
    <Emoji v-model="state.value" @add="addEmoji($event)" @delete="deleteEmoji()" />
    <div class="test">
      <div class="flex-box">
        <div class="box">{{ state.value }}</div>
        <button @click="send()" class="btn">渲染</button>
        <div class="box">
          <div v-for="(msg, index) of state.msgs" :key="index" v-html="msg"></div>
        </div>
      </div>
    </div>
    <footer>
      <div>&copy;&nbsp;{{ new Date().getFullYear() }}&nbsp;emoji-box</div>
      <div>
        <span>由&nbsp;<a href="https://d.sv" target="_blank">DAI</a>&nbsp;设计</span>
        <span class="heart">&nbsp;❤&nbsp;</span>
        <span>由&nbsp;<a href="https://vercel.com" target="_blank">Vercel</a>&nbsp;驱动</span>
      </div>
      <div>一切用于不正当的行为,后果由使用者承担责任,与本项目无关</div>
    </footer>
  </div>
</template>

<script setup>
import { reactive, getCurrentInstance } from 'vue'
const internalInstance = getCurrentInstance()
const global = internalInstance?.appContext.config.globalProperties

const state = reactive({
  value: '',
  msgs: [],
})

const send = () => {
  state.msgs.push(global.$string2emoji(state.value))
  state.value = ''
}

const addEmoji = (val) => {
  state.value += val
}

const deleteEmoji = () => {
  if (state.value) {
    state.value = global.$deleteEmoji(state.value)
  }
}
</script>

<style scoped>
a {
  text-decoration: none;
  color: #666;
}
a:hover {
  color: green;
}
.app {
  max-width: 870px;
  margin: auto;
}
header,
footer {
  text-align: center;
  margin-top: 50px;
}
header {
  margin-bottom: 50px;
}
.test {
  margin: 50px 0;
}
.flex-box {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
}
.btn {
  width: 10%;
  display: inline-block;
  cursor: pointer;
}
.box {
  flex-grow: 1;
  text-align: left;
  max-width: 45%;
  height: 200px;
  border: 1px green solid;
  border-radius: 3px;
  display: inline-block;
  overflow: auto;
}
.heart {
  color: red;
}
</style>

参数说明

必要参数

  • v-model: 关联插入表情的内容字段
  • addEmoji($event): 点击表情触发的方法,返回参数是该表情的文本形式
  • deleteEmoji(): 点击删除按钮触发的方法

可选参数

  • id: 表情面板的唯一标识,可省略,字符串类型,默认为emoji-box
  • buttton: 是否显示删除按钮,可省略,布尔类型,默认为true
  • height: 面板高度,可省略,字符串类型,默认为160px
  • hidden: 选择要隐藏的表情面板,可省略,字符串数组类型,默认为空即都显示,hidden=['XX']则表示隐藏XX表情面板
  • active: 默认选中的表情面板,可省略,字符串类型,默认为圆脸

全局方法

// 解析显示表情
this.value = this.$string2emoji(this.value)
// 逐个删除已有表情
this.value = this.$deleteEmoji(this.value)

在线体验

demo

联系

如有侵权造成影响,请留言联系邮箱删除。

You might also like...

A Chromium extension that enables users to use customizable :emoji: on Facebook/Facebook Messenger.

:emoji: for Messenger A Chromium extension that enables users to use customizable :emoji: on Facebook/Facebook Messenger. Install Download the extensi

Aug 31, 2022

Vanilla javascript emoji picker

Vanilla javascript emoji picker

FG Emoji Picker - Emoji picker created with vanilla javascript This is the simplest to use emoji picker built with vanilla javascript. Benefits: It is

Dec 16, 2022

A button to POST an emoji to an endpoint.

open-heart A button for the Open Heart Protocol. 🚧 Highly experimental. Tag a version to avoid unexpected changes. Usage !-- Include `OpenHeartEle

Nov 3, 2022

A web app to post emoji implemented in connect-go and connect-web.

A web app to post emoji implemented in connect-go and connect-web.

emotter Emotter is an app to post and share single emoji. This is an example app of connect. Example https://emotter.syumai.com API: Cloud Run Web cli

Oct 30, 2022

Selectize is the hybrid of a textbox and select box. It's jQuery based and it has autocomplete and native-feeling keyboard navigation; useful for tagging, contact lists, etc.

selectize.js → Selectize is looking for new members on the maintenance team! Selectize is an extensible jQuery-based custom select UI control. It's

Dec 31, 2022

A vanilla JS customisable select box/text input plugin ⚡️

Choices.js I'm looking for active maintainers for this project as I no longer have the time to support it. Please get in touch if you're interested 👍

Jan 7, 2023

Selectize is the hybrid of a textbox and select box. It's jQuery based and it has autocomplete and native-feeling keyboard navigation; useful for tagging, contact lists, etc.

selectize.js → Selectize is looking for new members on the maintenance team! Selectize is an extensible jQuery-based custom select UI control. It's

Dec 31, 2022

A behavior for Internet Explorer allowing it to recognize and render various CSS3 box decoration properties

============================ ====== PIE ====== ==========

Dec 26, 2022

A library for prototyping realtime hand detection (bounding box), directly in the browser.

A library for prototyping realtime hand detection (bounding box), directly in the browser.

Handtrack.js View a live demo in your browser here. Handtrack.js is a library for prototyping realtime hand detection (bounding box), directly in the

Jan 3, 2023

PowerModeInput can make your text input box more compelling

PowerModeInput can make your text input box more compelling

PowerModeInput PowerModeInput can make your text input box more compelling This project can make your input box lively. One day I saw a vscode plugin

Dec 2, 2022

Prefetch and sync state to client with one line of code, out-of-the-box

vue3-SSR-starter Prefetch and sync state to client with one line of code, out-of-the-box Features vue3 SSR vue-router we don't need vuex anymore one l

Aug 28, 2022

Chart.js Box Plots and Violin Plot Charts

Chart.js Box Plots and Violin Plot Charts

Chart.js Box and Violin Plot Chart.js module for charting box and violin plots. This is a maintained fork of @datavisyn/chartjs-chart-box-and-violin-p

Dec 14, 2022

Free & Open Source Version of Kneaver Thinking Box

kneaver-open Free & Open Source Version of Kneaver Thinking Box This is a very initial submission. barely more than a boilerplate. There is no warrant

Jan 17, 2022

This simple project aims to connect to an API to fetch score data and display it on a LeaderBoard box, as well as provide the tool to submit a new score.

      This simple project aims to connect to an API to fetch score data and display it on a LeaderBoard box, as well as provide the tool to submit a new score.

Leader Board: Hit the API! This simple project aims to connect to an API to fetch score data and display it on a LeaderBoard box, as well as provide t

Apr 6, 2022

This box comes with everything you need to start using smart contracts from a react app

Truffle React Hooks TypeScript Template This box comes with everything you need to start using smart contracts from a react app. This is as barebones

Mar 11, 2022

👩🏻‍💻 Developer Ready: A comprehensive template. Works out of the box for most Node.js projects.

👩🏻‍💻 Developer Ready: A comprehensive template. Works out of the box for most Node.js projects.

node-typescript-boilerplate 👩🏻‍💻 Developer Ready: A comprehensive template. Works out of the box for most Node.js projects. 🏃🏽 Instant Value: All

Dec 15, 2022

FortuneSheet is an online spreedsheet component library that provides out-of-the-box features just like Excel

FortuneSheet FortuneSheet is an online spreedsheet component library that provides out-of-the-box features just like Excel English | 简体中文 Purpose The

Jan 3, 2023

Used for creating a out-of-the-box template without additional configuration.

ou Used for creating a out-of-the-box template without additional configuration. Templates Vue3 Lite Template Used for some simple web app Vue3 + Vite

Jul 17, 2022
Collection of CSS box-shadows for every taste contains more than 100 simple, beautiful and airy shadows.

Vue Box-shadows Collection of CSS box-shadows for every taste contains more than 100 simple, beautiful and airy shadows. Add beautiful shadow effects

Andrej Sharapov 29 Nov 14, 2022
Easily add emoji support to your website! Replace keywords with emoji's :yum:

Emoji-Parser.js ?? A emoji parser to easily add emoji support to your website Show your support! Features: Use's the same style GitHub does! TON's of

Marketing Pipeline 13 Sep 9, 2022
emoji-box

emoji-box 特别说明: 基于 Vue3 编写,Vue2 不适用。 本项目中的表情(圆脸、其他、手势、动物)基于微软开源表情制作,可商用。 如涉及其他表情用于不正当的行为,后果由使用者承担责任,与本项目无关。 安装 npm npm i emoji-box yarn yarn add emoj

null 1 Dec 27, 2022
Custom alert box using javaScript and css. This plugin will provide the functionality to customize the default JavaScript alert box.

customAlertBoxPlugin Custom Alert Box Plugin Using JavaScript and CSS Author: Suraj Aswal Must Include CSS Code/Default Custom Alert Box Class: /* mus

Suraj Aswal 17 Sep 10, 2022
Vanilla JavaScript emoji picker component

Vanilla JavaScript emoji picker ?? Screenshot Demo and Documentation https://emoji-button.js.org Features ?? Vanilla JS, use with any framework ?? Use

Joe Attardi 1.1k Dec 31, 2022
Geniemoji - The Emoji Genie 🧞‍♂️

Geniemoji ??‍♂️ The Emoji Genie What is Geniemoji? Geniemoji is an app that makes using emojis on desktop simpler than ever It works on operating syst

Virej Dasani 64 Dec 25, 2022
An wide ranged emoji picker extension for firefox based browsers.

Fire-Picker A wide ranged emoji picker extension for firefox based browsers made with pure js. This is still in a prototype phase. Changes will be mad

null 2 Jan 10, 2022
An wide ranged emoji picker extension for firefox based browsers.

Fire-Picker A wide ranged emoji picker extension for firefox based browsers made with pure js. This is still in a prototype phase. Changes will be mad

Furha Lepton 2 Jan 10, 2022
Provides intellisense, search and preview of emoji

Features Suggest emoji names after typing : or / (can be changed) Browse emojis by category Fuzzy search emojis Intellisense emojiIntellSense.language

Xiaoqian Zhang 5 Oct 15, 2022
Emojion - Create and share images combined emoji and text

?? Emojion Emojion is a web application to create and share images combined an emoji and text. Your contribution is welcome! Concepts Simple Since the

ajfAfg 4 Oct 14, 2022