UNPKG

3.28 kBMarkdownView Raw
1# Emoji for NodeBB
2
3![Compatibility](https://packages.nodebb.org/api/v1/plugins/nodebb-plugin-emoji/compatibility.png)
4[![Downloads](https://img.shields.io/npm/dm/nodebb-plugin-emoji.svg)](https://www.npmjs.com/package/nodebb-plugin-emoji)
5[![Dependency Status](https://david-dm.org/NodeBB-Community/nodebb-plugin-emoji.svg)](https://david-dm.org/NodeBB/nodebb-plugin-emoji)
6
7Adds extensible emoji functionality to NodeBB
8
9 - Multiple sets of emoji available for use
10 - Intelligent auto-completion while composing posts and chat messages
11 - Ability to convert common emoticons like `:)` to emoji
12 - Convenient dialog to view and insert all available emoji
13 - First-party support for custom emoji (available in the ACP)
14
15## Installation
16
17For best results, install `nodebb-plugin-emoji` and emoji packs through the NodeBB Admin Panel.
18
19### Emoji packs
20
21The following emoji packs are known to be compatible with `nodebb-plugin-emoji`
22
23 - [nodebb-plugin-emoji-android](https://github.com/nodebb-community/nodebb-plugin-emoji-android)
24 - [nodebb-plugin-emoji-one](https://github.com/NodeBB-Community/nodebb-plugin-emoji-one)
25 - [nodebb-plugin-emoji-apple](https://github.com/NodeBB-Community/nodebb-plugin-emoji-apple)
26 - [nodebb-plugin-emoji-cubicopp](https://github.com/NodeBB-Community/nodebb-plugin-emoji-cubicopp)
27 - [nodebb-plugin-emoji-vital](https://github.com/NodeBB-Community/nodebb-plugin-emoji-vital)
28 - [nodebb-plugin-emoji-fontawesome](https://github.com/NodeBB-Community/nodebb-plugin-emoji-fontawesome)
29
30To add custom emoji, visit the **Emoji** ACP page and click on the pencil button in the bottom left.
31
32#### Hook: `filter:emoji.packs`
33
34In version two of the emoji plugin, a completely new API is now used to create emoji sets. Now, an emoji set defines its emojis via a hook that is emoitted by the emoji plugin when a build of emoji assets is run.
35
36To use this, you must listen for the hook by adding it to `plugin.json` like so:
37```json
38{
39 "library": "emoji.js",
40 "hooks": [
41 { "hook": "filter:emoji.packs", "method": "defineEmoji" }
42 ]
43}
44```
45
46And then providing the `defineEmoji` function in your library file (`emoji.js` here):
47```js
48exports.defineEmoji = function (data, callback) {
49 data.packs.push({
50 name: 'My Emoji Pack',
51 id: 'my-emoji',
52 attribution: '',
53 path: __dirname,
54 license: '',
55 mode: 'images',
56 images: {
57 directory: 'emoji',
58 },
59 dictionary: {
60 custom: {
61 aliases: ['personalized'],
62 image: 'custom.png',
63 character: '',
64 },
65 },
66 });
67
68 callback(null, data);
69};
70```
71
72In the above case, we define the emoji pack "My Emoji Pack" and one emoji: `custom` which has an alias of `personalized`, with an image named `custom.png` in the `emoji` directory. For full documentation, I suggest going [to the interface definitions for `Emoji` and `EmojiDefinition`](lib/types.d.ts).
73
74On an emoji build, initiated either on first install of the plugin or through the plugin ACP page, the emoji plugin will fire that hook and gather all emoji packs, then process them to produce metadata files it uses on the client side.
75
76### Manual installation
77
78If `nodebb-plugin-emoji` is not available through the ACP, you can install it manually with NPM
79
80 npm install nodebb-plugin-emoji