Skip to content

Commit

Permalink
Revert "fix(@lexical/text): for handling hashtag following multiple i…
Browse files Browse the repository at this point in the history
…nvalid matches (#6053)"

This reverts commit 89a9701.
  • Loading branch information
Sahejkm committed May 8, 2024
1 parent 7e3a79c commit c91834d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 57 deletions.
57 changes: 0 additions & 57 deletions packages/lexical-playground/__tests__/e2e/Hashtags.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span class="PlaygroundEditorTheme__hashtag" data-lexical-text="true">
#hello
</span>
<span data-lexical-text="true"></span>
<span class="PlaygroundEditorTheme__hashtag" data-lexical-text="true">
#world
</span>
<span data-lexical-text="true">#invalid#invalid#invalid</span>
<span class="PlaygroundEditorTheme__hashtag" data-lexical-text="true">
#valid
</span>
<span data-lexical-text="true"></span>
<span class="PlaygroundEditorTheme__hashtag" data-lexical-text="true">
#valid
</span>
<span data-lexical-text="true">#invalid</span>
<span class="PlaygroundEditorTheme__hashtag" data-lexical-text="true">
#valid
</span>
</p>
`,
);
});
});
7 changes: 7 additions & 0 deletions packages/lexical-text/src/registerLexicalTextEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function registerLexicalTextEntity<T extends TextNode>(
}
}

// eslint-disable-next-line no-constant-condition
let prevMatchLengthToSkip = 0;
// eslint-disable-next-line no-constant-condition
while (true) {
Expand Down Expand Up @@ -127,6 +128,12 @@ export function registerLexicalTextEntity<T extends TextNode>(
return;
}
}
} else {
const nextMatch = getMatch(nextText);

if (nextMatch !== null && nextMatch.start === 0) {
return;
}
}

if (match === null) {
Expand Down

0 comments on commit c91834d

Please sign in to comment.