Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove capital letter mentions #4991

Merged
merged 6 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test.describe('Clear All Formatting', () => {

await clearEditor(page);

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');

await waitForSelector(page, '#typeahead-menu ul li');
await assertHTML(
Expand All @@ -142,7 +142,7 @@ test.describe('Clear All Formatting', () => {
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Luke</span>
<span data-lexical-text="true">@Luke</span>
</p>
`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ test.describe('Composition', () => {
await focusEditor(page);
await enableCompositionKeyEvents(page);

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await waitForSelector(page, '#typeahead-menu ul li');
await page.keyboard.press('Enter');

Expand Down Expand Up @@ -491,7 +491,7 @@ test.describe('Composition', () => {
await focusEditor(page);
await enableCompositionKeyEvents(page);

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await waitForSelector(page, '#typeahead-menu ul li');
await page.keyboard.press('Enter');

Expand Down Expand Up @@ -558,7 +558,7 @@ test.describe('Composition', () => {
await focusEditor(page);
await enableCompositionKeyEvents(page);

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await waitForSelector(page, '#typeahead-menu ul li');
await page.keyboard.press('Enter');

Expand Down
123 changes: 81 additions & 42 deletions packages/lexical-playground/__tests__/e2e/Mentions.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@ test.describe('Mentions', () => {

test(`Can enter the Luke Skywalker mention`, async ({page}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await assertSelection(page, {
anchorOffset: 4,
anchorOffset: 5,
anchorPath: [0, 0, 0],
focusOffset: 4,
focusOffset: 5,
focusPath: [0, 0, 0],
});

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Luke</span>
<span data-lexical-text="true">@Luke</span>
</p>
`,
);
Expand Down Expand Up @@ -99,22 +103,26 @@ test.describe('Mentions', () => {
page,
}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await assertSelection(page, {
anchorOffset: 4,
anchorOffset: 5,
anchorPath: [0, 0, 0],
focusOffset: 4,
focusOffset: 5,
focusPath: [0, 0, 0],
});

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Luke</span>
<span data-lexical-text="true">@Luke</span>
</p>
`,
);
Expand Down Expand Up @@ -190,22 +198,26 @@ test.describe('Mentions', () => {
page,
}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await assertSelection(page, {
anchorOffset: 4,
anchorOffset: 5,
anchorPath: [0, 0, 0],
focusOffset: 4,
focusOffset: 5,
focusPath: [0, 0, 0],
});

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Luke</span>
<span data-lexical-text="true">@Luke</span>
</p>
`,
);
Expand Down Expand Up @@ -262,22 +274,26 @@ test.describe('Mentions', () => {
page,
}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await assertSelection(page, {
anchorOffset: 4,
anchorOffset: 5,
anchorPath: [0, 0, 0],
focusOffset: 4,
focusOffset: 5,
focusPath: [0, 0, 0],
});

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Luke</span>
<span data-lexical-text="true">@Luke</span>
</p>
`,
);
Expand Down Expand Up @@ -334,22 +350,26 @@ test.describe('Mentions', () => {
page,
}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await assertSelection(page, {
anchorOffset: 4,
anchorOffset: 5,
anchorPath: [0, 0, 0],
focusOffset: 4,
focusOffset: 5,
focusPath: [0, 0, 0],
});

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Luke</span>
<span data-lexical-text="true">@Luke</span>
</p>
`,
);
Expand Down Expand Up @@ -435,16 +455,20 @@ test.describe('Mentions', () => {
focusPath: [0, 0, 0],
});

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');

await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);

await waitForSelector(page, '#typeahead-menu ul li');
await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">abc Luke def</span>
<span data-lexical-text="true">abc @Luke def</span>
</p>
`,
);
Expand Down Expand Up @@ -505,42 +529,54 @@ test.describe('Mentions', () => {
browserName,
}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await assertSelection(page, {
anchorOffset: 4,
anchorOffset: 5,
anchorPath: [0, 0, 0],
focusOffset: 4,
focusOffset: 5,
focusPath: [0, 0, 0],
});

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);
await page.keyboard.press('Enter');

await waitForSelector(page, '.mention');

await page.keyboard.type(' ');

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);
await page.keyboard.press('Enter');

await waitForSelector(page, '.mention:nth-child(1)');

await page.keyboard.type(' ');

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);
await page.keyboard.press('Enter');

await waitForSelector(page, '.mention:nth-child(3)');

await page.keyboard.type(' ');

await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);
await page.keyboard.press('Enter');

await waitForSelector(page, '.mention:nth-child(5)');
Expand Down Expand Up @@ -814,15 +850,18 @@ test.describe('Mentions', () => {
page,
}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await page.keyboard.type('@Luke');
await assertSelection(page, {
anchorOffset: 4,
anchorOffset: 5,
anchorPath: [0, 0, 0],
focusOffset: 4,
focusOffset: 5,
focusPath: [0, 0, 0],
});

await waitForSelector(page, '#typeahead-menu ul li');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);
await page.keyboard.press('Enter');

await waitForSelector(page, '.mention');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ test.describe('Regression test #379', () => {
page,
}) => {
await focusEditor(page);
await page.keyboard.type('Luke');
await waitForSelector(page, '#typeahead-menu ul li');
await page.keyboard.type('@Luke');
await waitForSelector(
page,
'#typeahead-menu ul li:has-text("Luke Skywalker")',
);
await page.keyboard.press('Enter');
await assertHTML(
page,
Expand Down
15 changes: 13 additions & 2 deletions packages/lexical-playground/src/plugins/CommentPlugin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ function CommentInputBox({
correctedLeft = 10;
}
boxElem.style.left = `${correctedLeft}px`;
boxElem.style.top = `${bottom + 20 + (window.pageYOffset || document.documentElement.scrollTop)}px`;
boxElem.style.top = `${
bottom +
20 +
(window.pageYOffset || document.documentElement.scrollTop)
}px`;
const selectionRectsLength = selectionRects.length;
const {container} = selectionState;
const elements: Array<HTMLSpanElement> = selectionState.elements;
Expand All @@ -265,7 +269,14 @@ function CommentInputBox({
container.appendChild(elem);
}
const color = '255, 212, 0';
const style = `position:absolute;top:${selectionRect.top + (window.pageYOffset || document.documentElement.scrollTop)}px;left:${selectionRect.left}px;height:${selectionRect.height}px;width:${selectionRect.width}px;background-color:rgba(${color}, 0.3);pointer-events:none;z-index:5;`;
const style = `position:absolute;top:${
selectionRect.top +
(window.pageYOffset || document.documentElement.scrollTop)
}px;left:${selectionRect.left}px;height:${
selectionRect.height
}px;width:${
selectionRect.width
}px;background-color:rgba(${color}, 0.3);pointer-events:none;z-index:5;`;
elem.style.cssText = style;
}
for (let i = elementsLength - 1; i >= selectionRectsLength; i--) {
Expand Down