diff --git a/packages/core/src/blocks/ListItem/CheckListItem/block.ts b/packages/core/src/blocks/ListItem/CheckListItem/block.ts index dd38189894..024295a542 100644 --- a/packages/core/src/blocks/ListItem/CheckListItem/block.ts +++ b/packages/core/src/blocks/ListItem/CheckListItem/block.ts @@ -154,8 +154,7 @@ export const createCheckListItemBlockSpec = createBlockSpec( type: "checkListItem", props: { checked: false, - }, - content: [], + } }; }, }, diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts index d098665efc..199223e3ad 100644 --- a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts @@ -171,4 +171,56 @@ test.describe("Check Keyboard Handlers' Behaviour", () => { await compareDocToSnapshot(page, "checkedListItemShortcut.json"); }); + test("Check checkListItem inputRule preserves content", async ({ page }) => { + await focusOnEditor(page); + // Type [ ] followed by space at the start to trigger inputRule, then add content + // The inputRule should convert the paragraph to a checkListItem and preserve the content we type after + await page.keyboard.type("[ ] My task"); + await page.waitForTimeout(500); + + await compareDocToSnapshot( + page, + "checkListItemInputRulePreservesContent.json", + ); + }); + test("Check checkListItem inputRule with checked preserves content", async ({ + page, + }) => { + await focusOnEditor(page); + // Type [x] followed by space at the start to trigger inputRule with checked=true, then add content + // This should convert the paragraph to a checkListItem with checked=true and preserve the content + await page.keyboard.type("[x] Completed task"); + await page.waitForTimeout(150); + + await compareDocToSnapshot( + page, + "checkListItemInputRuleCheckedPreservesContent.json", + ); + }); + test("Check bulletListItem inputRule preserves content", async ({ page }) => { + await focusOnEditor(page); + // Type - followed by space at the start to trigger inputRule, then add content + // The inputRule should convert the paragraph to a bulletListItem and preserve the content + await page.keyboard.type("- My task"); + await page.waitForTimeout(500); + + await compareDocToSnapshot( + page, + "bulletListItemInputRulePreservesContent.json", + ); + }); + test("Check numberedListItem inputRule preserves content", async ({ + page, + }) => { + await focusOnEditor(page); + // Type 1. followed by space at the start to trigger inputRule, then add content + // The inputRule should convert the paragraph to a numberedListItem and preserve the content + await page.keyboard.type("1. My task"); + await page.waitForTimeout(500); + + await compareDocToSnapshot( + page, + "numberedListItemInputRulePreservesContent.json", + ); + }); }); diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-chromium-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-chromium-linux.json new file mode 100644 index 0000000000..028eb20baf --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-chromium-linux.json @@ -0,0 +1,48 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "bulletListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-firefox-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-firefox-linux.json new file mode 100644 index 0000000000..028eb20baf --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-firefox-linux.json @@ -0,0 +1,48 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "bulletListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-webkit-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-webkit-linux.json new file mode 100644 index 0000000000..028eb20baf --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-webkit-linux.json @@ -0,0 +1,48 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "bulletListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-chromium-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-chromium-linux.json new file mode 100644 index 0000000000..c77bbd3eec --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-chromium-linux.json @@ -0,0 +1,49 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "checkListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left", + "checked": true + }, + "content": [ + { + "type": "text", + "text": "Completed task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-firefox-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-firefox-linux.json new file mode 100644 index 0000000000..c77bbd3eec --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-firefox-linux.json @@ -0,0 +1,49 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "checkListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left", + "checked": true + }, + "content": [ + { + "type": "text", + "text": "Completed task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-webkit-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-webkit-linux.json new file mode 100644 index 0000000000..c77bbd3eec --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-webkit-linux.json @@ -0,0 +1,49 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "checkListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left", + "checked": true + }, + "content": [ + { + "type": "text", + "text": "Completed task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-chromium-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-chromium-linux.json new file mode 100644 index 0000000000..d03cdba817 --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-chromium-linux.json @@ -0,0 +1,49 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "checkListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left", + "checked": false + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-firefox-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-firefox-linux.json new file mode 100644 index 0000000000..d03cdba817 --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-firefox-linux.json @@ -0,0 +1,49 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "checkListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left", + "checked": false + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-webkit-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-webkit-linux.json new file mode 100644 index 0000000000..d03cdba817 --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-webkit-linux.json @@ -0,0 +1,49 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "checkListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left", + "checked": false + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-chromium-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-chromium-linux.json new file mode 100644 index 0000000000..0893e74778 --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-chromium-linux.json @@ -0,0 +1,48 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "numberedListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-firefox-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-firefox-linux.json new file mode 100644 index 0000000000..0893e74778 --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-firefox-linux.json @@ -0,0 +1,48 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "numberedListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-webkit-linux.json b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-webkit-linux.json new file mode 100644 index 0000000000..0893e74778 --- /dev/null +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-webkit-linux.json @@ -0,0 +1,48 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": "0" + }, + "content": [ + { + "type": "numberedListItem", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "My task" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": "2" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file