|
@@ -75,8 +75,30 @@ converse.plugins.add('converse-emoji', {
|
|
|
async initialize () {
|
|
|
if (!converse.emojis.initialized) {
|
|
|
converse.emojis.initialized = true;
|
|
|
+
|
|
|
const module = await import(/*webpackChunkName: "emojis" */ './emoji.json');
|
|
|
- const json = (converse.emojis.json = module.default);
|
|
|
+ /**
|
|
|
+ * *Hook* which allows plugins to modify emojis definition.
|
|
|
+ *
|
|
|
+ * Note: This hook is only fired one time, when ConverseJS initiliazed.
|
|
|
+ *
|
|
|
+ * @event _converse#loadEmojis
|
|
|
+ * @param json
|
|
|
+ * See src/headless/emojis.json for more information about the content of this parameter.
|
|
|
+ * @example
|
|
|
+ * api.listen.on('loadEmojis', (json) => {
|
|
|
+ * json.custom??= {};
|
|
|
+ * json.custom[":my_emoji"] = {
|
|
|
+ * "sn":":my_emoji:","url":"https://example.com/my_emoji.png","c":"custom"
|
|
|
+ * };
|
|
|
+ * delete json.custom[":converse:"];
|
|
|
+ * return json;
|
|
|
+ * });
|
|
|
+ */
|
|
|
+ const json = await api.hook('loadEmojis', module.default);
|
|
|
+ converse.emojis.json = json;
|
|
|
+
|
|
|
+
|
|
|
converse.emojis.by_sn = Object.keys(json).reduce(
|
|
|
(result, cat) => Object.assign(result, json[cat]),
|
|
|
{}
|