Add comments for emoji wrapping

This commit is contained in:
ohmwraith
2026-04-26 19:44:06 +03:00
parent b6eca7e471
commit c2cf614142
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -630,7 +630,7 @@ class MarkDown {
mention.classList.add("mentionMD");
mention.contentEditable = "false";
mention.textContent = everyone ? "@everyone" : "@here";
setTextWithWrappedEmoji(mention, mention.textContent || "");
appendcurrent();
span.appendChild(mention);
mention.setAttribute("real", everyone ? `@everyone` : "@here");
+3 -2
View File
@@ -31,16 +31,17 @@ let instances:
}[]
| null = null;
await setTheme();
// Matches keycaps, flags, standard, skin-toned, and ZWJ emoji sequences.
const emojiGraphemeRegex = /^(?:[0-9#*]\uFE0F?\u20E3|\p{Regional_Indicator}{2}|\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?[\u{1F3FB}-\u{1F3FF}]?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?[\u{1F3FB}-\u{1F3FF}]?)*?)$/u;
export function setTextWithWrappedEmoji(target: HTMLElement, name: string) {
target.textContent = "";
// Fallback for browsers without grapheme segmentation support.
if (!("Segmenter" in Intl)) {
target.textContent = name;
return;
}
const segmenter = new Intl.Segmenter("und", {granularity: "grapheme"});
// Buffer plain text between emoji to keep fewer DOM nodes.
let textBuffer = "";
const flushTextBuffer = () => {
if (!textBuffer) return;