2022-02-14 17:31:30 +00:00
|
|
|
export function emojify(text) {
|
|
|
|
let last = 0;
|
|
|
|
let nodes = [];
|
|
|
|
text.replace(/:([^\s:]+):/g, (match, name, index) => {
|
|
|
|
if(last <= index) nodes.push(document.createTextNode(text.slice(last, index)))
|
|
|
|
nodes.push(Object.assign(new Image(), {src: `/emojis/${name}.png`, className: "emoji", alt: name}))
|
|
|
|
last = index + match.length
|
|
|
|
})
|
|
|
|
if(last < text.length) nodes.push(document.createTextNode(text.slice(last)))
|
|
|
|
return nodes
|
2022-02-14 20:58:59 +00:00
|
|
|
}
|
|
|
|
export const emojis = Promise.resolve(["blobcat", "blobhaj"])
|