diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 43784082..d0b67080 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -363,7 +363,7 @@ export class MarkdownTextArea extends Component< if (value === null) { const emoji = customEmojisLookup.get(e.id)?.custom_emoji; if (emoji) { - value = `![${emoji.alt_text}](${emoji.image_url} "${emoji.shortcode}")`; + value = `![${emoji.alt_text}](${emoji.image_url} "emoji ${emoji.shortcode}")`; } } i.setState({ diff --git a/src/shared/markdown.ts b/src/shared/markdown.ts index 8927c325..97568b51 100644 --- a/src/shared/markdown.ts +++ b/src/shared/markdown.ts @@ -195,11 +195,22 @@ export function setupMarkdown() { ) { //Provide custom renderer for our emojis to allow us to add a css class and force size dimensions on them. const item = tokens[idx] as any; - const title = item.attrs.length >= 3 ? item.attrs[2][1] : ""; + let title = item.attrs.length >= 3 ? item.attrs[2][1] : ""; + const splitTitle = title.split(/ (.*)/, 2); + const isEmoji = splitTitle[0] === "emoji"; + if (isEmoji) { + title = splitTitle[1]; + } const customEmoji = customEmojisLookup.get(title); - const isCustomEmoji = customEmoji !== undefined; - if (!isCustomEmoji) { - return defaultRenderer?.(tokens, idx, options, env, self) ?? ""; + const isLocalEmoji = customEmoji !== undefined; + if (!isLocalEmoji) { + const imgElement = + defaultRenderer?.(tokens, idx, options, env, self) ?? ""; + if (imgElement) { + return `${imgElement}`; + } else return ""; } return ` {