Skip to content

Commit

Permalink
Merge branch 'main' into revert-49580d4
Browse files Browse the repository at this point in the history
  • Loading branch information
potatowagon authored Dec 12, 2024
2 parents 4d29ab8 + 6243c4b commit 252d932
Show file tree
Hide file tree
Showing 15 changed files with 1,030 additions and 463 deletions.
2 changes: 1 addition & 1 deletion packages/lexical-list/src/LexicalListItemNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class ListItemNode extends ElementNode {
}

canMergeWith(node: LexicalNode): boolean {
return $isParagraphNode(node) || $isListItemNode(node);
return $isListItemNode(node) || $isParagraphNode(node);
}

extractWithChild(child: LexicalNode, selection: BaseSelection): boolean {
Expand Down
14 changes: 6 additions & 8 deletions packages/lexical-list/src/formatList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
$getSelection,
$isElementNode,
$isLeafNode,
$isParagraphNode,
$isRangeSelection,
$isRootOrShadowRoot,
ElementNode,
Expand Down Expand Up @@ -498,6 +497,8 @@ export function $handleListInsertParagraph(): boolean {

if ($isRootOrShadowRoot(grandparent)) {
replacementNode = $createParagraphNode();
replacementNode.setTextStyle(selection.style);
replacementNode.setTextFormat(selection.format);
topListNode.insertAfter(replacementNode);
} else if ($isListItemNode(grandparent)) {
replacementNode = $createListItemNode();
Expand All @@ -511,17 +512,14 @@ export function $handleListInsertParagraph(): boolean {

if (nextSiblings.length > 0) {
const newList = $createListNode(parent.getListType());
if ($isParagraphNode(replacementNode)) {
replacementNode.insertAfter(newList);
} else {
if ($isListItemNode(replacementNode)) {
const newListItem = $createListItemNode();
newListItem.append(newList);
replacementNode.insertAfter(newListItem);
} else {
replacementNode.insertAfter(newList);
}
nextSiblings.forEach((sibling) => {
sibling.remove();
newList.append(sibling);
});
newList.append(...nextSiblings);
}

// Don't leave hanging nested empty lists
Expand Down
60 changes: 44 additions & 16 deletions packages/lexical-playground/__tests__/e2e/CodeBlock.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ test.describe('CodeBlock', () => {
;
</span>
<br />
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenFunction"
data-lexical-text="true">
Expand All @@ -393,7 +395,9 @@ test.describe('CodeBlock', () => {
;
</span>
<br />
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenPunctuation"
data-lexical-text="true">
Expand Down Expand Up @@ -453,7 +457,9 @@ test.describe('CodeBlock', () => {
{
</span>
<br />
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenFunction"
data-lexical-text="true">
Expand Down Expand Up @@ -501,8 +507,12 @@ test.describe('CodeBlock', () => {
data-gutter="123"
data-highlight-language="javascript"
data-language="javascript">
<span data-lexical-text="true"></span>
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenAttr"
data-lexical-text="true">
Expand All @@ -527,9 +537,15 @@ test.describe('CodeBlock', () => {
{
</span>
<br />
<span data-lexical-text="true"></span>
<span data-lexical-text="true"></span>
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenFunction"
data-lexical-text="true">
Expand All @@ -551,8 +567,12 @@ test.describe('CodeBlock', () => {
;
</span>
<br />
<span data-lexical-text="true"></span>
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenPunctuation"
data-lexical-text="true">
Expand All @@ -575,7 +595,9 @@ test.describe('CodeBlock', () => {
data-gutter="123"
data-highlight-language="javascript"
data-language="javascript">
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenAttr"
data-lexical-text="true">
Expand All @@ -600,8 +622,12 @@ test.describe('CodeBlock', () => {
{
</span>
<br />
<span data-lexical-text="true"></span>
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenFunction"
data-lexical-text="true">
Expand All @@ -623,7 +649,9 @@ test.describe('CodeBlock', () => {
;
</span>
<br />
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenPunctuation"
data-lexical-text="true">
Expand Down Expand Up @@ -913,10 +941,10 @@ test.describe('CodeBlock', () => {
data-gutter="12"
data-language="javascript"
data-highlight-language="javascript">
<span data-lexical-text="true"></span>
<span class="PlaygroundEditorTheme__tabNode" data-lexical-text="true"></span>
<span data-lexical-text="true">a b</span>
<br />
<span data-lexical-text="true"></span>
<span class="PlaygroundEditorTheme__tabNode" data-lexical-text="true"></span>
<span data-lexical-text="true">c d</span>
</code>
`,
Expand Down
19 changes: 19 additions & 0 deletions packages/lexical-playground/__tests__/e2e/List.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
pasteFromClipboard,
repeat,
selectFromAlignDropdown,
selectFromColorPicker,
selectFromFormatDropdown,
test,
waitForSelector,
Expand Down Expand Up @@ -159,6 +160,24 @@ test.describe.parallel('Nested List', () => {
);
});

test('Should retain selection style when exiting list', async ({page}) => {
await focusEditor(page);
await toggleBulletList(page);

await selectFromColorPicker(page);
await toggleBold(page);

Check failure on line 168 in packages/lexical-playground/__tests__/e2e/List.spec.mjs

View workflow job for this annotation

GitHub Actions / core-tests / integrity (20.11.0)

'toggleBold' is not defined
await page.keyboard.type('Hello');
//Double-enter to exit list
await page.keyboard.press('Enter');
await page.keyboard.press('Enter');
await page.keyboard.type('World');

await assertHTML(
page,
'<ul class="PlaygroundEditorTheme__ul"><li value="1" class="PlaygroundEditorTheme__listItem PlaygroundEditorTheme__ltr" dir="ltr"><strong class="PlaygroundEditorTheme__textBold" style="color: rgb(208, 2, 27)" data-lexical-text="true">Hello</strong></li></ul><p class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr" dir="ltr"><strong class="PlaygroundEditorTheme__textBold" style="color: rgb(208, 2, 27)" data-lexical-text="true">World</strong></p>',
);
});

test(`Can indent/outdent mutliple list nodes in a list with multiple levels of indentation`, async ({
page,
}) => {
Expand Down
8 changes: 6 additions & 2 deletions packages/lexical-playground/__tests__/e2e/Tab.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ test.describe('Tab', () => {
dir="ltr"
style="padding-inline-start: calc(40px)">
<span data-lexical-text="true">すし</span>
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span data-lexical-text="true">すし</span>
</p>
`,
Expand All @@ -106,7 +108,9 @@ test.describe('Tab', () => {
data-gutter="1"
data-highlight-language="javascript"
data-language="javascript">
<span data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tabNode"
data-lexical-text="true"></span>
<span
class="PlaygroundEditorTheme__tokenAttr"
data-lexical-text="true">
Expand Down
Loading

0 comments on commit 252d932

Please sign in to comment.