mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: allow site operators to disable emoji shortcuts
This commit is contained in:
parent
7ba06de0d6
commit
3492a91056
4 changed files with 27 additions and 3 deletions
|
@ -170,7 +170,7 @@ function getEmojiTokenByTranslation(content, pos, state) {
|
|||
}
|
||||
}
|
||||
|
||||
function applyEmoji(content, state, emojiUnicodeReplacer) {
|
||||
function applyEmoji(content, state, emojiUnicodeReplacer, enableShortcuts) {
|
||||
let i;
|
||||
let result = null;
|
||||
let contentToken = null;
|
||||
|
@ -195,7 +195,7 @@ function applyEmoji(content, state, emojiUnicodeReplacer) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!token) {
|
||||
if (enableShortcuts && !token) {
|
||||
// handle aliases (note: we can't do this in inline cause ; is not a split point)
|
||||
//
|
||||
let info = getEmojiTokenByTranslation(content, i, state);
|
||||
|
@ -231,13 +231,19 @@ function applyEmoji(content, state, emojiUnicodeReplacer) {
|
|||
export function setup(helper) {
|
||||
helper.registerOptions((opts, siteSettings, state)=>{
|
||||
opts.features.emoji = !!siteSettings.enable_emoji;
|
||||
opts.features.emojiShortcuts = !!siteSettings.enable_emoji_shortcuts;
|
||||
opts.emojiSet = siteSettings.emoji_set || "";
|
||||
opts.customEmoji = state.customEmoji;
|
||||
});
|
||||
|
||||
helper.registerPlugin((md)=>{
|
||||
md.core.ruler.push('emoji', state => md.options.discourse.helpers.textReplace(
|
||||
state, (c,s)=>applyEmoji(c,s,md.options.discourse.emojiUnicodeReplacer))
|
||||
state, (c,s)=>applyEmoji(
|
||||
c,
|
||||
s,
|
||||
md.options.discourse.emojiUnicodeReplacer,
|
||||
md.options.discourse.features.emojiShortcuts
|
||||
))
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue