mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(app): make a backslash before an emoji node keep it literal (#2010)
This commit is contained in:
1 parent
5ec02c3089
commit
6d289e31c7
1 file changed
+19
-7
@@ -139,6 +139,16 @@ function $reconcileParagraph(paragraph: ParagraphNode, parserFlags?: number): vo
|
||||
}
|
||||
}
|
||||
|
||||
function $isEscapedAtOffset(source: string, offset: number): boolean {
|
||||
let backslashes = 0;
|
||||
let cursor = offset - 1;
|
||||
while (cursor >= 0 && source[cursor] === '\\') {
|
||||
backslashes += 1;
|
||||
cursor -= 1;
|
||||
}
|
||||
return backslashes % 2 === 1;
|
||||
}
|
||||
|
||||
function $reconcileLine(
|
||||
line: Array<LexicalNode>,
|
||||
parserFlags?: number,
|
||||
@@ -153,13 +163,15 @@ function $reconcileLine(
|
||||
const nodeText = $nodeWireText(node);
|
||||
const nodeEnd = sourceOffset + nodeText.length;
|
||||
if ($isComposerMentionNode(node) || $isComposerCustomEmojiNode(node) || $isComposerStandardEmojiNode(node)) {
|
||||
const literal = spans.some(
|
||||
(span) =>
|
||||
span.role === 'content' &&
|
||||
(span.format & MarkdownHl.code) !== 0 &&
|
||||
span.start <= sourceOffset &&
|
||||
span.end >= nodeEnd,
|
||||
);
|
||||
const literal =
|
||||
$isEscapedAtOffset(source, sourceOffset) ||
|
||||
spans.some(
|
||||
(span) =>
|
||||
span.role === 'content' &&
|
||||
(span.format & MarkdownHl.code) !== 0 &&
|
||||
span.start <= sourceOffset &&
|
||||
span.end >= nodeEnd,
|
||||
);
|
||||
if (node.isLiteral() !== literal) {
|
||||
node.setLiteral(literal);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user