From bddd362390b244b1f50544136c4a0752e6b7ac11 Mon Sep 17 00:00:00 2001 From: Sahejkm <163521239+Sahejkm@users.noreply.github.com> Date: Wed, 8 May 2024 21:03:03 +0800 Subject: [PATCH] Revert #6053 first till proper fix is shipped in #6056 (#6058) --- .../__tests__/e2e/Hashtags.spec.mjs | 57 ------------------- .../src/registerLexicalTextEntity.ts | 7 +++ 2 files changed, 7 insertions(+), 57 deletions(-) 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) {