mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-emoji.git
synced 2025-10-04 01:20:58 +08:00
add button into chat composer
This commit is contained in:
parent
c370602036
commit
63088872d5
3 changed files with 35 additions and 1 deletions
19
lib/index.ts
19
lib/index.ts
|
@ -69,6 +69,25 @@ export async function addStylesheet<Payload extends {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function filterMessagingLoadRoom<Payload extends {
|
||||||
|
room: {
|
||||||
|
composerActions: {
|
||||||
|
action: string;
|
||||||
|
class: string;
|
||||||
|
icon: string;
|
||||||
|
title: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
}>(data: Payload): Promise<Payload> {
|
||||||
|
data.room.composerActions.push({
|
||||||
|
action: 'emoji',
|
||||||
|
class: 'd-none d-md-flex',
|
||||||
|
icon: 'fa-smile',
|
||||||
|
title: '[[emoji:composer.title]]',
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
export async function configGet(config: any): Promise<any> {
|
export async function configGet(config: any): Promise<any> {
|
||||||
const customFirst = await settings.getOne('customFirst');
|
const customFirst = await settings.getOne('customFirst');
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
{ "hook": "filter:email.prepare", "method": "parse.email" },
|
{ "hook": "filter:email.prepare", "method": "parse.email" },
|
||||||
{ "hook": "filter:middleware.renderHeader", "method": "parse.header" },
|
{ "hook": "filter:middleware.renderHeader", "method": "parse.header" },
|
||||||
{ "hook": "filter:meta.getLinkTags", "method": "addStylesheet" },
|
{ "hook": "filter:meta.getLinkTags", "method": "addStylesheet" },
|
||||||
{ "hook": "filter:config.get", "method": "configGet" }
|
{ "hook": "filter:config.get", "method": "configGet" },
|
||||||
|
{ "hook": "filter:messaging.loadRoom", "method": "filterMessagingLoadRoom" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,18 @@ require(['emoji'], function (emoji) {
|
||||||
emoji.init();
|
emoji.init();
|
||||||
data.strategies.push(emoji.strategy);
|
data.strategies.push(emoji.strategy);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(window).on('action:chat.loaded', (ev, container) => {
|
||||||
|
const containerEl = $(container);
|
||||||
|
const textarea = containerEl.find('[component="chat/input"]')[0];
|
||||||
|
const addEmojiBtn = $(container).find('[data-action="emoji"]');
|
||||||
|
|
||||||
|
addEmojiBtn.on('click', (ev) => {
|
||||||
|
require([
|
||||||
|
'emoji-dialog'
|
||||||
|
], function (emojiDialog) {
|
||||||
|
emojiDialog.toggleForInsert(textarea, 0, 0, ev);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue