From 424f71dc190fb715915fae4a66c87e1d9fa35cc4 Mon Sep 17 00:00:00 2001 From: supernova <217093914+tmpluto@users.noreply.github.com> Date: Sun, 4 Jan 2026 09:15:42 +0400 Subject: [PATCH 1/3] fix: when you convert a block into checkListItem via inputRule, it should transfer its content into checkListItem content --- packages/core/src/blocks/ListItem/CheckListItem/block.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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: [], + } }; }, }, From f9a348beb02d3eafb190b69056b0789549200223 Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Wed, 7 Jan 2026 14:13:55 +0100 Subject: [PATCH 2/3] test: add tests for checklist keyboard handling --- .../keyboardhandlers/keyboardhandlers.test.ts | 26 ++++++++++ ...dPreservesContent-json-chromium-linux.json | 49 +++++++++++++++++++ ...edPreservesContent-json-firefox-linux.json | 49 +++++++++++++++++++ ...ePreservesContent-json-chromium-linux.json | 49 +++++++++++++++++++ ...lePreservesContent-json-firefox-linux.json | 49 +++++++++++++++++++ 5 files changed, 222 insertions(+) create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-chromium-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-firefox-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-chromium-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-firefox-linux.json diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts index d098665efc..6a74d21c9e 100644 --- a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts @@ -171,4 +171,30 @@ 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", + ); + }); }); 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/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 From 871577990244456a47aa06d5940306ec36700e4c Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Wed, 7 Jan 2026 14:18:07 +0100 Subject: [PATCH 3/3] test: add tests for other list item input rules --- .../keyboardhandlers/keyboardhandlers.test.ts | 26 ++++++++++ ...ePreservesContent-json-chromium-linux.json | 48 ++++++++++++++++++ ...lePreservesContent-json-firefox-linux.json | 48 ++++++++++++++++++ ...ulePreservesContent-json-webkit-linux.json | 48 ++++++++++++++++++ ...kedPreservesContent-json-webkit-linux.json | 49 +++++++++++++++++++ ...ulePreservesContent-json-webkit-linux.json | 49 +++++++++++++++++++ ...ePreservesContent-json-chromium-linux.json | 48 ++++++++++++++++++ ...lePreservesContent-json-firefox-linux.json | 48 ++++++++++++++++++ ...ulePreservesContent-json-webkit-linux.json | 48 ++++++++++++++++++ 9 files changed, 412 insertions(+) create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-chromium-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-firefox-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/bulletListItemInputRulePreservesContent-json-webkit-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRuleCheckedPreservesContent-json-webkit-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/checkListItemInputRulePreservesContent-json-webkit-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-chromium-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-firefox-linux.json create mode 100644 tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/numberedListItemInputRulePreservesContent-json-webkit-linux.json diff --git a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts index 6a74d21c9e..199223e3ad 100644 --- a/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts +++ b/tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts @@ -197,4 +197,30 @@ test.describe("Check Keyboard Handlers' Behaviour", () => { "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-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-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