Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
@@ -0,0 +1,22 @@
// test is located in test/extract-mentions
export function extractMentions(nodes) {
const mentions = [];
collectMentions(nodes, mentions);
return mentions;
}
function collectMentions(nodes, mentions) {
for(let i = 0; i < nodes.length; i++){
const node = nodes[i];
if (node.type === "mention" && !isWrappedUserEmojiMention(nodes, i)) {
mentions.push(node.props);
}
if ("children" in node && Array.isArray(node.children)) {
collectMentions(node.children, mentions);
}
}
}
function isWrappedUserEmojiMention(nodes, index) {
const previous = nodes[index - 1];
const next = nodes[index + 1];
return previous?.type === "text" && next?.type === "text" && previous.props.text.endsWith(":") && next.props.text.startsWith(":");
}