Skip to content

Commit 2063eb8

Browse files
committed
Fix not rendered autocomplete emojis
Currently we have some emojis that are autocompleted but won't show up in the resulting document. This patch adds all emojis that are pushed to Codemirror and applies them to the markdown rendering process, so they become usable. Signed-off-by: Sheogorath <[email protected]>
1 parent c7478c1 commit 2063eb8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

public/js/extra.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,20 @@ const pdfPlugin = new Plugin(
11451145
}
11461146
)
11471147

1148+
const emojijsPlugin = new Plugin(
1149+
// regexp to match emoji shortcodes :something:
1150+
/:([\d\D]*):/,
1151+
1152+
(match, utils) => {
1153+
const emoji = match[1] ? match[1].toLowerCase() : undefined
1154+
if (window.emojify.emojiNames.includes(emoji)) {
1155+
const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`)
1156+
return div[0].outerHTML
1157+
}
1158+
return match[0]
1159+
}
1160+
)
1161+
11481162
// yaml meta, from https://github.com/eugeneware/remarkable-meta
11491163
function get (state, line) {
11501164
const pos = state.bMarks[line]
@@ -1189,6 +1203,7 @@ function metaPlugin (md) {
11891203
}
11901204

11911205
md.use(metaPlugin)
1206+
md.use(emojijsPlugin)
11921207
md.use(youtubePlugin)
11931208
md.use(vimeoPlugin)
11941209
md.use(gistPlugin)

0 commit comments

Comments
 (0)