Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/core/src/blocks/ListItem/CheckListItem/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ export const createCheckListItemBlockSpec = createBlockSpec(
type: "checkListItem",
props: {
checked: false,
},
content: [],
}
};
},
},
Expand Down
52 changes: 52 additions & 0 deletions tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
});
});
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
]
}
]
}
Loading
Loading