diff --git a/src/components/status-content.tsx b/src/components/status-content.tsx index 265c53323..4924d6509 100644 --- a/src/components/status-content.tsx +++ b/src/components/status-content.tsx @@ -92,17 +92,25 @@ const StatusContent: React.FC = ({ } if (domNode instanceof DOMText) { - const parts = domNode.data.split(' ').map((part) => { - const match = part.match(/^:(\w+):$/); - if (!match) return part; + const parts: Array = []; - const [, shortcode] = match; - const customEmoji = customEmojis.find((e) => e.shortcode === shortcode); + const textNodes = domNode.data.split(/:\w+:/); + const shortcodes = [...domNode.data.matchAll(/:(\w+):/g)]; - if (!customEmoji) return part; + for (let i = 0; i < textNodes.length; i++) { + parts.push(textNodes[i]); - return {part}; - }); + if (shortcodes[i]) { + const [text, shortcode] = shortcodes[i]; + const customEmoji = customEmojis.find((e) => e.shortcode === shortcode); + + if (customEmoji) { + parts.push({shortcode}); + } else { + parts.push(text); + } + } + } return <>{parts}; }