diff --git a/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs b/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs index 21a492062ca..e04c417cb7e 100644 --- a/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs +++ b/packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs @@ -383,61 +383,4 @@ test.describe('Hashtags', () => { `, ); }); - - test('Can handle hashtags following multiple invalid hashtags', async ({ - page, - }) => { - await focusEditor(page); - await page.keyboard.type('#hello'); - - await page.keyboard.press('Space'); - - await page.keyboard.type('#world'); - await page.keyboard.type('#invalid'); - await page.keyboard.type('#invalid'); - await page.keyboard.type('#invalid'); - - await page.keyboard.press('Space'); - - await page.keyboard.type('#valid'); - - await page.keyboard.press('Space'); - - await page.keyboard.type('#valid'); - await page.keyboard.type('#invalid'); - - await page.keyboard.press('Space'); - await page.keyboard.type('#valid'); - - await waitForSelector(page, '.PlaygroundEditorTheme__hashtag'); - - await assertHTML( - page, - html` -

- - #hello - - - - #world - - #invalid#invalid#invalid - - #valid - - - - #valid - - #invalid - - #valid - -

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