Skip to content

Commit 5653454

Browse files
fix: List item shortcuts throwing errors (#1236)
* Fixed list item shortcuts throwing errors * Added keyboard shortcut e2e tests * Small fix
1 parent 9ef0cbe commit 5653454

23 files changed

+935
-18
lines changed

packages/core/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
6565
return true;
6666
}
6767

68-
return this.options.editor.commands.command(
68+
return this.editor.commands.command(
6969
updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
7070
type: "bulletListItem",
7171
props: {},

packages/core/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
109109
return {
110110
Enter: () => handleEnter(this.options.editor),
111111
"Mod-Shift-9": () => {
112-
const blockInfo = getBlockInfoFromSelection(this.options.editor.state);
112+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
113113
if (
114114
!blockInfo.isBlockContainer ||
115115
blockInfo.blockContent.node.type.spec.content !== "inline*"

tests/src/component/copypaste-internal.spec.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test("Alert Copy/Paste Internal", async ({ browserName, mount, page }) => {
3232
);
3333
await button.first().click();
3434

35-
await copyPasteAll(page, "mac");
35+
await copyPasteAll(page);
3636
await page.waitForTimeout(50);
3737

3838
await compareDocToSnapshot(page, "alert-internal");
@@ -52,7 +52,7 @@ test("Button Copy/Paste Internal", async ({ browserName, mount, page }) => {
5252
await page.keyboard.press("ArrowDown");
5353
await page.keyboard.type("Paragraph 2");
5454

55-
await copyPasteAll(page, "mac");
55+
await copyPasteAll(page);
5656
await page.waitForTimeout(50);
5757

5858
const button = await page.locator("button");
@@ -76,7 +76,7 @@ test("Embed Copy/Paste Internal", async ({ browserName, mount, page }) => {
7676
await page.keyboard.press("ArrowDown");
7777
await page.keyboard.type("Paragraph 2");
7878

79-
await copyPasteAll(page, "mac");
79+
await copyPasteAll(page);
8080
await page.waitForTimeout(50);
8181

8282
await compareDocToSnapshot(page, "embed-internal");
@@ -98,7 +98,7 @@ test("Image Copy/Paste Internal", async ({ browserName, mount, page }) => {
9898
await page.keyboard.press("ArrowDown");
9999
await page.keyboard.type("Paragraph 2");
100100

101-
await copyPasteAll(page, "mac");
101+
await copyPasteAll(page);
102102
await page.waitForTimeout(50);
103103

104104
await compareDocToSnapshot(page, "image-internal");
@@ -118,7 +118,7 @@ test("Separator Copy/Paste Internal", async ({ browserName, mount, page }) => {
118118
await page.keyboard.press("ArrowDown");
119119
await page.keyboard.type("Paragraph 2");
120120

121-
await copyPasteAll(page, "mac");
121+
await copyPasteAll(page);
122122
await page.waitForTimeout(50);
123123

124124
await compareDocToSnapshot(page, "separator-internal");
@@ -144,7 +144,7 @@ test("Table of Contents Copy/Paste Internal", async ({
144144
await executeSlashCommand(page, "h2");
145145
await page.keyboard.type("Heading 2");
146146

147-
await copyPasteAll(page, "mac");
147+
await copyPasteAll(page);
148148
await page.waitForTimeout(50);
149149

150150
const expectedToC =

tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,46 @@ test.describe("Check Keyboard Handlers' Behaviour", () => {
131131

132132
await compareDocToSnapshot(page, "backspacePreservesNestedBlocks.json");
133133
});
134+
test("Check heading 1 shortcut", async ({ page }) => {
135+
await focusOnEditor(page);
136+
await page.keyboard.type("Paragraph");
137+
await page.keyboard.press("ControlOrMeta+Alt+1");
138+
139+
await compareDocToSnapshot(page, "heading1Shortcut.json");
140+
});
141+
test("Check heading 2 shortcut", async ({ page }) => {
142+
await focusOnEditor(page);
143+
await page.keyboard.type("Paragraph");
144+
await page.keyboard.press("ControlOrMeta+Alt+2");
145+
146+
await compareDocToSnapshot(page, "heading2Shortcut.json");
147+
});
148+
test("Check heading 3 shortcut", async ({ page }) => {
149+
await focusOnEditor(page);
150+
await page.keyboard.type("Paragraph");
151+
await page.keyboard.press("ControlOrMeta+Alt+3");
152+
153+
await compareDocToSnapshot(page, "heading3Shortcut.json");
154+
});
155+
test("Check numbered list item shortcut", async ({ page }) => {
156+
await focusOnEditor(page);
157+
await page.keyboard.type("Paragraph");
158+
await page.keyboard.press("ControlOrMeta+Shift+7");
159+
160+
await compareDocToSnapshot(page, "numberedListItemShortcut.json");
161+
});
162+
test("Check bullet list item shortcut", async ({ page }) => {
163+
await focusOnEditor(page);
164+
await page.keyboard.type("Paragraph");
165+
await page.keyboard.press("ControlOrMeta+Shift+8");
166+
167+
await compareDocToSnapshot(page, "bulletListItemShortcut.json");
168+
});
169+
test("Check checked list item shortcut", async ({ page }) => {
170+
await focusOnEditor(page);
171+
await page.keyboard.type("Paragraph");
172+
await page.keyboard.press("ControlOrMeta+Shift+9");
173+
174+
await compareDocToSnapshot(page, "checkedListItemShortcut.json");
175+
});
134176
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"type": "doc",
3+
"content": [
4+
{
5+
"type": "blockGroup",
6+
"content": [
7+
{
8+
"type": "blockContainer",
9+
"attrs": {
10+
"id": "0",
11+
"textColor": "default",
12+
"backgroundColor": "default"
13+
},
14+
"content": [
15+
{
16+
"type": "bulletListItem",
17+
"attrs": {
18+
"textAlignment": "left"
19+
},
20+
"content": [
21+
{
22+
"type": "text",
23+
"text": "Paragraph"
24+
}
25+
]
26+
}
27+
]
28+
},
29+
{
30+
"type": "blockContainer",
31+
"attrs": {
32+
"id": "1",
33+
"textColor": "default",
34+
"backgroundColor": "default"
35+
},
36+
"content": [
37+
{
38+
"type": "paragraph",
39+
"attrs": {
40+
"textAlignment": "left"
41+
}
42+
}
43+
]
44+
}
45+
]
46+
}
47+
]
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"type": "doc",
3+
"content": [
4+
{
5+
"type": "blockGroup",
6+
"content": [
7+
{
8+
"type": "blockContainer",
9+
"attrs": {
10+
"id": "0",
11+
"textColor": "default",
12+
"backgroundColor": "default"
13+
},
14+
"content": [
15+
{
16+
"type": "bulletListItem",
17+
"attrs": {
18+
"textAlignment": "left"
19+
},
20+
"content": [
21+
{
22+
"type": "text",
23+
"text": "Paragraph"
24+
}
25+
]
26+
}
27+
]
28+
},
29+
{
30+
"type": "blockContainer",
31+
"attrs": {
32+
"id": "1",
33+
"textColor": "default",
34+
"backgroundColor": "default"
35+
},
36+
"content": [
37+
{
38+
"type": "paragraph",
39+
"attrs": {
40+
"textAlignment": "left"
41+
}
42+
}
43+
]
44+
}
45+
]
46+
}
47+
]
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"type": "doc",
3+
"content": [
4+
{
5+
"type": "blockGroup",
6+
"content": [
7+
{
8+
"type": "blockContainer",
9+
"attrs": {
10+
"id": "0",
11+
"textColor": "default",
12+
"backgroundColor": "default"
13+
},
14+
"content": [
15+
{
16+
"type": "bulletListItem",
17+
"attrs": {
18+
"textAlignment": "left"
19+
},
20+
"content": [
21+
{
22+
"type": "text",
23+
"text": "Paragraph"
24+
}
25+
]
26+
}
27+
]
28+
},
29+
{
30+
"type": "blockContainer",
31+
"attrs": {
32+
"id": "1",
33+
"textColor": "default",
34+
"backgroundColor": "default"
35+
},
36+
"content": [
37+
{
38+
"type": "paragraph",
39+
"attrs": {
40+
"textAlignment": "left"
41+
}
42+
}
43+
]
44+
}
45+
]
46+
}
47+
]
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"type": "doc",
3+
"content": [
4+
{
5+
"type": "blockGroup",
6+
"content": [
7+
{
8+
"type": "blockContainer",
9+
"attrs": {
10+
"id": "0",
11+
"textColor": "default",
12+
"backgroundColor": "default"
13+
},
14+
"content": [
15+
{
16+
"type": "checkListItem",
17+
"attrs": {
18+
"textAlignment": "left",
19+
"checked": false
20+
},
21+
"content": [
22+
{
23+
"type": "text",
24+
"text": "Paragraph"
25+
}
26+
]
27+
}
28+
]
29+
},
30+
{
31+
"type": "blockContainer",
32+
"attrs": {
33+
"id": "1",
34+
"textColor": "default",
35+
"backgroundColor": "default"
36+
},
37+
"content": [
38+
{
39+
"type": "paragraph",
40+
"attrs": {
41+
"textAlignment": "left"
42+
}
43+
}
44+
]
45+
}
46+
]
47+
}
48+
]
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"type": "doc",
3+
"content": [
4+
{
5+
"type": "blockGroup",
6+
"content": [
7+
{
8+
"type": "blockContainer",
9+
"attrs": {
10+
"id": "0",
11+
"textColor": "default",
12+
"backgroundColor": "default"
13+
},
14+
"content": [
15+
{
16+
"type": "checkListItem",
17+
"attrs": {
18+
"textAlignment": "left",
19+
"checked": false
20+
},
21+
"content": [
22+
{
23+
"type": "text",
24+
"text": "Paragraph"
25+
}
26+
]
27+
}
28+
]
29+
},
30+
{
31+
"type": "blockContainer",
32+
"attrs": {
33+
"id": "1",
34+
"textColor": "default",
35+
"backgroundColor": "default"
36+
},
37+
"content": [
38+
{
39+
"type": "paragraph",
40+
"attrs": {
41+
"textAlignment": "left"
42+
}
43+
}
44+
]
45+
}
46+
]
47+
}
48+
]
49+
}

0 commit comments

Comments
 (0)