1 | If you want to publish a custom set you need to create a NodeBB plugin with peer dependency `nodebb-plugin-emoji-extended`.
|
2 |
|
3 | The recommended way of registering the set (and logging an error when peer emoji-extended is missing):
|
4 |
|
5 | var winston = require("winston");
|
6 | var setsCtrl = null;
|
7 |
|
8 | try {
|
9 | setsCtrl = require("nodebb-plugin-emoji-extended/lib/sets/controller");
|
10 | } catch (e) {
|
11 | winston.error("[emoji] nodebb-plugin-emoji-extended is not installed. nodebb-plugin-my-plugin depends on it.");
|
12 | }
|
13 |
|
14 | if (setsCtrl != null) { setsCtrl.register(require("./path/to/set/module"), "my-set"); }
|
15 |
|
16 | Where the set module may provide the following properties:
|
17 |
|
18 | * `[(Object|String)[]] url` - Definition of path for templates within auto-completion (explanation below).
|
19 | * `[String] name` - The name of the set. Shown within ACP.
|
20 | * `[String] preview` - URL to a preview image of the set. Used within ACP.
|
21 | * `[{id: RegExp[]|RegExp}] mapping.separationLeading` - RegExp(s) to replace with emoji (with leading word-boundary required for match).
|
22 | * `[{id: RegExp[]|RegExp}] mapping.separationWrapped` - RegExp(s) to replace with emoji (with leading and trailing word-boundary required for match).
|
23 | * `[String] license` - License details to be shown within emoji modal legal information tab.
|
24 | * `[String] moduleId` - The ID of your plugin (NPM package name). Shown within ACP.
|
25 | * `[String, HTML] description` - The description of the set. Shown within ACP.
|
26 | * `[String, HTML] attribution` - Attribution to be shown within emoji modal legal information tab.
|
27 | * `[String, CSS] mainStyles` - Styles to use within frontend.
|
28 | * `[String, CSS] emailStyles` - Styles to use within emails.
|
29 | * `[Boolean] prepared` - If false, an update is required before activation.
|
30 |
|
31 | * `[Emoji[]] use(options)` - Called when set should get activated.
|
32 | * `[Emoji[]] update()` - Called to update the image files (if not set, the set is treated static).
|
33 | * `[String] parse(text)` - Called to parse a plain text and replace emoji occurrences with HTML.
|
34 | * `[void] purge()` - Called to remove image files (only recommended if reversible via `update`).
|
35 |
|
36 | The attributes `name`, `use` and `parse` must be set when needed (e.g. `parse` is not needed before `use` is resolved).
|
37 | The functions `use`, `update` and `purge` may also return a `Promise` to resolve asynchronously.
|
38 | The properties `url`, `preview`, `mapping`, `description`, `attribution`, `mainStyles`, `emailStyles` and `prepared` may as well be function returning the required value.
|
39 |
|
40 | The array items of `url` get concatenated to resolve the URL for an image at client-side (needed for auto-completion).
|
41 | Objects within the `url` array must provide a `[String] key` property (e.g. `id` or `file`) which gets resolved to that attribute of the `Emoji` (only properties as described below get resolved).
|
42 | If it provides `[Boolean] encode` set to `true`, the property gets URI-encoded.
|
43 | If property `key` cannot be resolved and a `[String] fallback` is specified, this gets used instead.
|
44 |
|
45 | An `Emoji` object is required to provide at least `[String] id`.
|
46 | It may also provide the following attributes:
|
47 |
|
48 | * `[String] category` - The category of the emoji (within emoji modal, default: `"others"`).
|
49 | * `[String] file` - The filename of the emoji (if it differs from the id).
|
50 | * `[String] classes` - Extra class names for the emoji.
|
51 |
|
52 |
|
53 | Some *official* sets for further help:
|
54 | * [nodebb-plugin-emoji-one](https://github.com/NodeBB-Community/nodebb-plugin-emoji-one) - Example of image files being kept up-to-date with online zip archive, featuring `Emoji.file` usage.
|
55 | * [nodebb-plugin-emoji-static](https://github.com/NodeBB-Community/nodebb-plugin-emoji-static) - User defined images.
|
56 | * [nodebb-plugin-emoji-cubicopp](https://github.com/NodeBB-Community/nodebb-plugin-emoji-cubicopp) - Example of static image files.
|
57 | * [nodebb-plugin-emoji-apple](https://github.com/NodeBB-Community/nodebb-plugin-emoji-apple) - Example of image files being kept up-to-date with a GitHub repository.
|