Skip to content

Commit

Permalink
Merge branch 'main' into table_cut
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum authored Aug 21, 2024
2 parents ec3901a + 24cf9e3 commit 9157bc0
Show file tree
Hide file tree
Showing 9 changed files with 613 additions and 617 deletions.
10 changes: 1 addition & 9 deletions packages/lexical-overflow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,7 @@ export class OverflowNode extends ElementNode {
return parent.insertNewAfter(selection, restoreSelection);
}

canBeEmpty(): false {
return false;
}

isInline(): true {
return true;
}

excludeFromCopy(): true {
excludeFromCopy(): boolean {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,183 +108,182 @@ test.describe('Lists CopyAndPaste', () => {
});
});

test('Copy and paste of partial list items into the list', async ({
page,
isPlainText,
isCollab,
browserName,
}) => {
test.skip(isPlainText);

await focusEditor(page);

// Add three list items
await page.keyboard.type('- one');
await page.keyboard.press('Enter');
await page.keyboard.type('two');
await page.keyboard.press('Enter');
await page.keyboard.type('three');

await page.keyboard.press('Enter');
await page.keyboard.press('Enter');

// Add a paragraph
await page.keyboard.type('Some text.');

await assertHTML(
page,
html`
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">one</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="2">
<span data-lexical-text="true">two</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="3">
<span data-lexical-text="true">three</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 10,
anchorPath: [1, 0, 0],
focusOffset: 10,
focusPath: [1, 0, 0],
});

await page.keyboard.down('Shift');
await moveToLineBeginning(page);
await moveLeft(page, 3);
await page.keyboard.up('Shift');

await assertSelection(page, {
anchorOffset: 10,
anchorPath: [1, 0, 0],
focusOffset: 3,
focusPath: [0, 2, 0, 0],
});

// Copy the partial list item and paragraph
const clipboard = await copyToClipboard(page);

// Select all and remove content
await page.keyboard.press('ArrowUp');
await page.keyboard.press('ArrowUp');
if (!IS_WINDOWS && browserName === 'firefox') {
test(
'Copy and paste of partial list items into the list',
{tag: '@flaky'},
async ({page, isPlainText, isCollab, browserName}) => {
test.skip(isPlainText);

await focusEditor(page);

// Add three list items
await page.keyboard.type('- one');
await page.keyboard.press('Enter');
await page.keyboard.type('two');
await page.keyboard.press('Enter');
await page.keyboard.type('three');

await page.keyboard.press('Enter');
await page.keyboard.press('Enter');

// Add a paragraph
await page.keyboard.type('Some text.');

await assertHTML(
page,
html`
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">one</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="2">
<span data-lexical-text="true">two</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="3">
<span data-lexical-text="true">three</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 10,
anchorPath: [1, 0, 0],
focusOffset: 10,
focusPath: [1, 0, 0],
});

await page.keyboard.down('Shift');
await moveToLineBeginning(page);
await moveLeft(page, 3);
await page.keyboard.up('Shift');

await assertSelection(page, {
anchorOffset: 10,
anchorPath: [1, 0, 0],
focusOffset: 3,
focusPath: [0, 2, 0, 0],
});

// Copy the partial list item and paragraph
const clipboard = await copyToClipboard(page);

// Select all and remove content
await page.keyboard.press('ArrowUp');
}
await moveToLineEnd(page);

await page.keyboard.down('Enter');

await assertHTML(
page,
html`
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">one</span>
</li>
<li class="PlaygroundEditorTheme__listItem" value="2">
<br />
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="3">
<span data-lexical-text="true">two</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="4">
<span data-lexical-text="true">three</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 0,
anchorPath: [0, 1],
focusOffset: 0,
focusPath: [0, 1],
});

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">one</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="2">
<span data-lexical-text="true">ee</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">two</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="2">
<span data-lexical-text="true">three</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 10,
anchorPath: [1, 0, 0],
focusOffset: 10,
focusPath: [1, 0, 0],
});
});
await page.keyboard.press('ArrowUp');
if (!IS_WINDOWS && browserName === 'firefox') {
await page.keyboard.press('ArrowUp');
}
await moveToLineEnd(page);

await page.keyboard.down('Enter');

await assertHTML(
page,
html`
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">one</span>
</li>
<li class="PlaygroundEditorTheme__listItem" value="2">
<br />
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="3">
<span data-lexical-text="true">two</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="4">
<span data-lexical-text="true">three</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 0,
anchorPath: [0, 1],
focusOffset: 0,
focusPath: [0, 1],
});

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">one</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="2">
<span data-lexical-text="true">ee</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
<ul class="PlaygroundEditorTheme__ul">
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="1">
<span data-lexical-text="true">two</span>
</li>
<li
class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr"
dir="ltr"
value="2">
<span data-lexical-text="true">three</span>
</li>
</ul>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Some text.</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 10,
anchorPath: [1, 0, 0],
focusOffset: 10,
focusPath: [1, 0, 0],
});
},
);

test('Copy list items and paste back into list', async ({
page,
Expand Down
Loading

0 comments on commit 9157bc0

Please sign in to comment.