diff --git a/packages/lexical-text/src/registerLexicalTextEntity.ts b/packages/lexical-text/src/registerLexicalTextEntity.ts index fb081d69878..b29ae7d2d9f 100644 --- a/packages/lexical-text/src/registerLexicalTextEntity.ts +++ b/packages/lexical-text/src/registerLexicalTextEntity.ts @@ -61,7 +61,7 @@ export function registerLexicalTextEntity( return; } - const prevSibling = node.getPreviousSibling(); + let prevSibling = node.getPreviousSibling(); let text = node.getTextContent(); let currentNode = node; let match; @@ -100,7 +100,6 @@ export function registerLexicalTextEntity( } } - // eslint-disable-next-line no-constant-condition let prevMatchLengthToSkip = 0; // eslint-disable-next-line no-constant-condition while (true) { @@ -128,12 +127,6 @@ export function registerLexicalTextEntity( return; } } - } else { - const nextMatch = getMatch(nextText); - - if (nextMatch !== null && nextMatch.start === 0) { - return; - } } if (match === null) { @@ -165,6 +158,8 @@ export function registerLexicalTextEntity( if (currentNode == null) { return; } + prevMatchLengthToSkip = 0; + prevSibling = replacementNode; } };