implement unicode emoji replacements
This commit is contained in:
@@ -171,13 +171,17 @@ function getEmojiTokenByTranslation(content, pos, state) {
|
||||
}
|
||||
}
|
||||
|
||||
function applyEmoji(content, state) {
|
||||
function applyEmoji(content, state, emojiUnicodeReplacer) {
|
||||
let i;
|
||||
let result = null;
|
||||
let contentToken = null;
|
||||
|
||||
let start = 0;
|
||||
|
||||
if (emojiUnicodeReplacer) {
|
||||
content = emojiUnicodeReplacer(content);
|
||||
}
|
||||
|
||||
let endToken = content.length;
|
||||
|
||||
for (i=0; i<content.length-1; i++) {
|
||||
@@ -236,6 +240,8 @@ export function setup(helper) {
|
||||
});
|
||||
|
||||
helper.registerPlugin((md)=>{
|
||||
md.core.ruler.push('emoji', state => textReplace(state, applyEmoji));
|
||||
md.core.ruler.push('emoji', state => textReplace(
|
||||
state, (c,s)=>applyEmoji(c,s,md.options.discourse.emojiUnicodeReplacer))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ export function buildOptions(state) {
|
||||
userId,
|
||||
getCurrentUser,
|
||||
currentUser,
|
||||
lookupAvatarByPostNumber
|
||||
lookupAvatarByPostNumber,
|
||||
emojiUnicodeReplacer
|
||||
} = state;
|
||||
|
||||
if (!siteSettings.enable_experimental_markdown_it) {
|
||||
@@ -53,6 +54,7 @@ export function buildOptions(state) {
|
||||
currentUser,
|
||||
lookupAvatarByPostNumber,
|
||||
mentionLookup: state.mentionLookup,
|
||||
emojiUnicodeReplacer,
|
||||
allowedHrefSchemes: siteSettings.allowed_href_schemes ? siteSettings.allowed_href_schemes.split('|') : null,
|
||||
markdownIt: siteSettings.enable_experimental_markdown_it
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user