Skip to content

Commit

Permalink
fix: List item shortcuts throwing errors (#1236)
Browse files Browse the repository at this point in the history
* Fixed list item shortcuts throwing errors

* Added keyboard shortcut e2e tests

* Small fix
  • Loading branch information
matthewlipski authored Nov 14, 2024
1 parent 9ef0cbe commit 5653454
Show file tree
Hide file tree
Showing 23 changed files with 935 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
return true;
}

return this.options.editor.commands.command(
return this.editor.commands.command(
updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
type: "bulletListItem",
props: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
return {
Enter: () => handleEnter(this.options.editor),
"Mod-Shift-9": () => {
const blockInfo = getBlockInfoFromSelection(this.options.editor.state);
const blockInfo = getBlockInfoFromSelection(this.editor.state);
if (
!blockInfo.isBlockContainer ||
blockInfo.blockContent.node.type.spec.content !== "inline*"
Expand Down
12 changes: 6 additions & 6 deletions tests/src/component/copypaste-internal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test("Alert Copy/Paste Internal", async ({ browserName, mount, page }) => {
);
await button.first().click();

await copyPasteAll(page, "mac");
await copyPasteAll(page);
await page.waitForTimeout(50);

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

await copyPasteAll(page, "mac");
await copyPasteAll(page);
await page.waitForTimeout(50);

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

await copyPasteAll(page, "mac");
await copyPasteAll(page);
await page.waitForTimeout(50);

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

await copyPasteAll(page, "mac");
await copyPasteAll(page);
await page.waitForTimeout(50);

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

await copyPasteAll(page, "mac");
await copyPasteAll(page);
await page.waitForTimeout(50);

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

await copyPasteAll(page, "mac");
await copyPasteAll(page);
await page.waitForTimeout(50);

const expectedToC =
Expand Down
42 changes: 42 additions & 0 deletions tests/src/end-to-end/keyboardhandlers/keyboardhandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,46 @@ test.describe("Check Keyboard Handlers' Behaviour", () => {

await compareDocToSnapshot(page, "backspacePreservesNestedBlocks.json");
});
test("Check heading 1 shortcut", async ({ page }) => {
await focusOnEditor(page);
await page.keyboard.type("Paragraph");
await page.keyboard.press("ControlOrMeta+Alt+1");

await compareDocToSnapshot(page, "heading1Shortcut.json");
});
test("Check heading 2 shortcut", async ({ page }) => {
await focusOnEditor(page);
await page.keyboard.type("Paragraph");
await page.keyboard.press("ControlOrMeta+Alt+2");

await compareDocToSnapshot(page, "heading2Shortcut.json");
});
test("Check heading 3 shortcut", async ({ page }) => {
await focusOnEditor(page);
await page.keyboard.type("Paragraph");
await page.keyboard.press("ControlOrMeta+Alt+3");

await compareDocToSnapshot(page, "heading3Shortcut.json");
});
test("Check numbered list item shortcut", async ({ page }) => {
await focusOnEditor(page);
await page.keyboard.type("Paragraph");
await page.keyboard.press("ControlOrMeta+Shift+7");

await compareDocToSnapshot(page, "numberedListItemShortcut.json");
});
test("Check bullet list item shortcut", async ({ page }) => {
await focusOnEditor(page);
await page.keyboard.type("Paragraph");
await page.keyboard.press("ControlOrMeta+Shift+8");

await compareDocToSnapshot(page, "bulletListItemShortcut.json");
});
test("Check checked list item shortcut", async ({ page }) => {
await focusOnEditor(page);
await page.keyboard.type("Paragraph");
await page.keyboard.press("ControlOrMeta+Shift+9");

await compareDocToSnapshot(page, "checkedListItemShortcut.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",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "bulletListItem",
"attrs": {
"textAlignment": "left"
},
"content": [
{
"type": "text",
"text": "Paragraph"
}
]
}
]
},
{
"type": "blockContainer",
"attrs": {
"id": "1",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "paragraph",
"attrs": {
"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",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "bulletListItem",
"attrs": {
"textAlignment": "left"
},
"content": [
{
"type": "text",
"text": "Paragraph"
}
]
}
]
},
{
"type": "blockContainer",
"attrs": {
"id": "1",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "paragraph",
"attrs": {
"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",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "bulletListItem",
"attrs": {
"textAlignment": "left"
},
"content": [
{
"type": "text",
"text": "Paragraph"
}
]
}
]
},
{
"type": "blockContainer",
"attrs": {
"id": "1",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "paragraph",
"attrs": {
"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",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "checkListItem",
"attrs": {
"textAlignment": "left",
"checked": false
},
"content": [
{
"type": "text",
"text": "Paragraph"
}
]
}
]
},
{
"type": "blockContainer",
"attrs": {
"id": "1",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "paragraph",
"attrs": {
"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",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "checkListItem",
"attrs": {
"textAlignment": "left",
"checked": false
},
"content": [
{
"type": "text",
"text": "Paragraph"
}
]
}
]
},
{
"type": "blockContainer",
"attrs": {
"id": "1",
"textColor": "default",
"backgroundColor": "default"
},
"content": [
{
"type": "paragraph",
"attrs": {
"textAlignment": "left"
}
}
]
}
]
}
]
}
Loading

0 comments on commit 5653454

Please sign in to comment.