From 7c63b173f9f404d0b159c34328643da83e03a485 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Fri, 9 Dec 2022 18:28:53 +0100 Subject: [PATCH 1/6] Fixed block splitting bug --- .../core/src/extensions/Blocks/nodes/Block.ts | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/packages/core/src/extensions/Blocks/nodes/Block.ts b/packages/core/src/extensions/Blocks/nodes/Block.ts index aee2aa93f4..35a9889a4d 100644 --- a/packages/core/src/extensions/Blocks/nodes/Block.ts +++ b/packages/core/src/extensions/Blocks/nodes/Block.ts @@ -243,21 +243,37 @@ export const Block = Node.create({ return false; } - const { contentNode, contentType, startPos, endPos, depth } = - blockInfo; + const { + node, + contentNode, + contentType, + numChildBlocks, + startPos, + endPos, + depth, + } = blockInfo; const newBlockInsertionPos = endPos + 1; // Creates new block first, otherwise positions get changed due to the original block's content changing. - // Only text content is transferred to the new block. - const secondBlockContent = state.doc.textBetween(posInBlock, endPos); + // Only text content and nested blocks are transferred to the new block. + const secondBlockTextContent = state.doc.textBetween( + posInBlock, + startPos + 1 + contentNode.nodeSize + ); const newBlock = state.schema.nodes["block"].createAndFill()!; const newBlockContentPos = newBlockInsertionPos + 2; if (dispatch) { state.tr.insert(newBlockInsertionPos, newBlock); - state.tr.insertText(secondBlockContent, newBlockContentPos); + + if (numChildBlocks > 0) { + const secondBlockNestedBlocks = node.lastChild!; + state.tr.insert(newBlockContentPos, secondBlockNestedBlocks); + } + + state.tr.insertText(secondBlockTextContent, newBlockContentPos); if (keepType) { state.tr.setBlockType( @@ -269,14 +285,18 @@ export const Block = Node.create({ } } - // Updates content of original block. - const firstBlockContent = state.doc.content.cut(startPos, posInBlock); + // Updates content of original block. We don't need to worry about any nested blocks here since they're + // always transferred to the new block. + const originalBlockTextContent = state.doc.content.cut( + startPos, + posInBlock + ); if (dispatch) { state.tr.replace( startPos, endPos, - new Slice(firstBlockContent, depth, depth) + new Slice(originalBlockTextContent, depth, depth) ); } From 69515f0ac332e17fa8cffde7a29d5250121b5e99 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Fri, 9 Dec 2022 19:35:51 +0100 Subject: [PATCH 2/6] Rewrite to use `Slice` instead of `textContent` for block content --- .../core/src/extensions/Blocks/nodes/Block.ts | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/packages/core/src/extensions/Blocks/nodes/Block.ts b/packages/core/src/extensions/Blocks/nodes/Block.ts index 35a9889a4d..fca90d6dcc 100644 --- a/packages/core/src/extensions/Blocks/nodes/Block.ts +++ b/packages/core/src/extensions/Blocks/nodes/Block.ts @@ -1,5 +1,5 @@ import { mergeAttributes, Node } from "@tiptap/core"; -import { Slice } from "prosemirror-model"; +import { Fragment, Slice } from "prosemirror-model"; import { TextSelection } from "prosemirror-state"; import BlockAttributes from "../BlockAttributes"; import { getBlockInfoFromPos } from "../helpers/getBlockInfoFromPos"; @@ -243,38 +243,38 @@ export const Block = Node.create({ return false; } - const { - node, - contentNode, - contentType, - numChildBlocks, - startPos, - endPos, - depth, - } = blockInfo; + const { contentNode, contentType, startPos, endPos, depth } = + blockInfo; - const newBlockInsertionPos = endPos + 1; - - // Creates new block first, otherwise positions get changed due to the original block's content changing. - // Only text content and nested blocks are transferred to the new block. - const secondBlockTextContent = state.doc.textBetween( - posInBlock, - startPos + 1 + contentNode.nodeSize - ); + const originalBlockContent = state.doc.cut(startPos + 1, posInBlock); + const newBlockContent = state.doc.cut(posInBlock, endPos - 1); const newBlock = state.schema.nodes["block"].createAndFill()!; + + const newBlockInsertionPos = endPos + 1; const newBlockContentPos = newBlockInsertionPos + 2; if (dispatch) { + // Creates a new block. Since the schema requires it to have a content node, a textContent node is created + // automatically, spanning newBlockContentPos to newBlockContentPos + 1. state.tr.insert(newBlockInsertionPos, newBlock); - if (numChildBlocks > 0) { - const secondBlockNestedBlocks = node.lastChild!; - state.tr.insert(newBlockContentPos, secondBlockNestedBlocks); - } - - state.tr.insertText(secondBlockTextContent, newBlockContentPos); + // Replaces the content of the newly created block's content node. Doesn't replace the whole content node so + // its type doesn't change. + state.tr.replace( + newBlockContentPos, + newBlockContentPos + 1, + newBlockContent.content.size > 0 + ? new Slice( + Fragment.from(newBlockContent), + depth + 2, + depth + 2 + ) + : undefined + ); + // Changes the type of the content node. The range doesn't matter as long as both from and to positions are + // within the content node. if (keepType) { state.tr.setBlockType( newBlockContentPos, @@ -283,20 +283,24 @@ export const Block = Node.create({ contentNode.attrs ); } - } - // Updates content of original block. We don't need to worry about any nested blocks here since they're - // always transferred to the new block. - const originalBlockTextContent = state.doc.content.cut( - startPos, - posInBlock - ); + // Sets the selection to the start of the new block's content node. + state.tr.setSelection( + new TextSelection(state.doc.resolve(newBlockContentPos)) + ); - if (dispatch) { + // Replaces the content of the original block's content node. Doesn't replace the whole content node so its + // type doesn't change. state.tr.replace( - startPos, - endPos, - new Slice(originalBlockTextContent, depth, depth) + startPos + 1, + endPos - 1, + originalBlockContent.content.size > 0 + ? new Slice( + Fragment.from(originalBlockContent), + depth + 2, + depth + 2 + ) + : undefined ); } From bf7927fae01baff800b49a532969ba7ef0d5cd87 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Wed, 8 Feb 2023 16:15:35 +0100 Subject: [PATCH 3/6] Minor changes --- packages/core/src/extensions/Blocks/nodes/BlockContainer.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/extensions/Blocks/nodes/BlockContainer.ts b/packages/core/src/extensions/Blocks/nodes/BlockContainer.ts index b70e6fab14..ad28144ef4 100644 --- a/packages/core/src/extensions/Blocks/nodes/BlockContainer.ts +++ b/packages/core/src/extensions/Blocks/nodes/BlockContainer.ts @@ -236,13 +236,14 @@ export const BlockContainer = Node.create({ const originalBlockContent = state.doc.cut(startPos + 1, posInBlock); const newBlockContent = state.doc.cut(posInBlock, endPos - 1); - const newBlock = state.schema.nodes["blockContainer"].createAndFill()!; + const newBlock = + state.schema.nodes["blockContainer"].createAndFill()!; const newBlockInsertionPos = endPos + 1; const newBlockContentPos = newBlockInsertionPos + 2; if (dispatch) { - // Creates a new block. Since the schema requires it to have a content node, a textContent node is created + // Creates a new block. Since the schema requires it to have a content node, a paragraph node is created // automatically, spanning newBlockContentPos to newBlockContentPos + 1. state.tr.insert(newBlockInsertionPos, newBlock); From f129619aa1b4d0b2136a5e7ca4ab995fbd09b92b Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Wed, 8 Feb 2023 16:48:42 +0100 Subject: [PATCH 4/6] Added related keyboard handler tests --- .../keyboardhandlers/keyboardhandlers.test.ts | 34 +++++ ...terPreservesMarks-json-chromium-linux.json | 59 +++++++++ ...nterPreservesMarks-json-firefox-linux.json | 81 ++++++++++++ ...enterPreservesMarks-json-webkit-linux.json | 81 ++++++++++++ ...ervesNestedBlocks-json-chromium-linux.json | 122 ++++++++++++++++++ ...servesNestedBlocks-json-firefox-linux.json | 122 ++++++++++++++++++ ...eservesNestedBlocks-json-webkit-linux.json | 122 ++++++++++++++++++ tests/utils/const.ts | 1 + 8 files changed, 622 insertions(+) create mode 100644 tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json create mode 100644 tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-firefox-linux.json create mode 100644 tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-webkit-linux.json create mode 100644 tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-chromium-linux.json create mode 100644 tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-firefox-linux.json create mode 100644 tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-webkit-linux.json diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts index 36c24edc4f..c08194e842 100644 --- a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts @@ -1,6 +1,7 @@ import { test } from "../../setup/setupScript"; import { BASE_URL, + ITALIC_BUTTON_SELECTOR, H_ONE_BLOCK_SELECTOR, H_TWO_BLOCK_SELECTOR, } from "../../utils/const"; @@ -34,4 +35,37 @@ test.describe("Check Keyboard Handlers' Behaviour", () => { await compareDocToSnapshot(page, "enterSelectionNotEmpty.json"); }); + test("Check Enter preserves marks", async ({ page }) => { + await focusOnEditor(page); + await insertHeading(page, 1); + + const element = await page.locator(H_ONE_BLOCK_SELECTOR); + let boundingBox = await element.boundingBox(); + let { x, y, height } = boundingBox; + + await page.mouse.click(x + 35, y + height / 2, { clickCount: 2 }); + await page.locator(ITALIC_BUTTON_SELECTOR).click(); + await page.waitForTimeout(450); + await page.mouse.click(x + 35, y + height / 2); + await page.keyboard.press("Enter"); + + await compareDocToSnapshot(page, "enterPreservesMarks.json"); + }); + test("Check Enter preserves nested blocks", async ({ page }) => { + await focusOnEditor(page); + await insertHeading(page, 1); + await page.keyboard.press("Tab"); + await insertHeading(page, 2); + await page.keyboard.press("Tab"); + await insertHeading(page, 3); + + const element = await page.locator(H_ONE_BLOCK_SELECTOR); + let boundingBox = await element.boundingBox(); + let { x, y, height } = boundingBox; + + await page.mouse.click(x + 35, y + height / 2); + await page.keyboard.press("Enter"); + + await compareDocToSnapshot(page, "enterPreservesNestedBlocks.json"); + }); }); diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json new file mode 100644 index 0000000000..0eefd8b774 --- /dev/null +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json @@ -0,0 +1,59 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 0, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "1" + } + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 2, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + } + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 1, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-firefox-linux.json b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-firefox-linux.json new file mode 100644 index 0000000000..fa64e4b10e --- /dev/null +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-firefox-linux.json @@ -0,0 +1,81 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 0, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "1" + }, + "content": [ + { + "type": "text", + "marks": [ + { + "type": "italic" + } + ], + "text": "H" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 2, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "marks": [ + { + "type": "italic" + } + ], + "text": "eading" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 1, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-webkit-linux.json b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-webkit-linux.json new file mode 100644 index 0000000000..fa64e4b10e --- /dev/null +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-webkit-linux.json @@ -0,0 +1,81 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 0, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "1" + }, + "content": [ + { + "type": "text", + "marks": [ + { + "type": "italic" + } + ], + "text": "H" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 2, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "marks": [ + { + "type": "italic" + } + ], + "text": "eading" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 1, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-chromium-linux.json b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-chromium-linux.json new file mode 100644 index 0000000000..3b74616256 --- /dev/null +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-chromium-linux.json @@ -0,0 +1,122 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 0, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "1" + }, + "content": [ + { + "type": "text", + "text": "H" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 4, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "eading" + } + ] + }, + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 1, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "2" + }, + "content": [ + { + "type": "text", + "text": "Heading" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 2, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "3" + }, + "content": [ + { + "type": "text", + "text": "Heading" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 3, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-firefox-linux.json b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-firefox-linux.json new file mode 100644 index 0000000000..3b74616256 --- /dev/null +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-firefox-linux.json @@ -0,0 +1,122 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 0, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "1" + }, + "content": [ + { + "type": "text", + "text": "H" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 4, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "eading" + } + ] + }, + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 1, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "2" + }, + "content": [ + { + "type": "text", + "text": "Heading" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 2, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "3" + }, + "content": [ + { + "type": "text", + "text": "Heading" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 3, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-webkit-linux.json b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-webkit-linux.json new file mode 100644 index 0000000000..3b74616256 --- /dev/null +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesNestedBlocks-json-webkit-linux.json @@ -0,0 +1,122 @@ +{ + "type": "doc", + "content": [ + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 0, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "1" + }, + "content": [ + { + "type": "text", + "text": "H" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 4, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + }, + "content": [ + { + "type": "text", + "text": "eading" + } + ] + }, + { + "type": "blockGroup", + "content": [ + { + "type": "blockContainer", + "attrs": { + "id": 1, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "2" + }, + "content": [ + { + "type": "text", + "text": "Heading" + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 2, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "heading", + "attrs": { + "textAlignment": "left", + "level": "3" + }, + "content": [ + { + "type": "text", + "text": "Heading" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "blockContainer", + "attrs": { + "id": 3, + "textColor": "default", + "backgroundColor": "default" + }, + "content": [ + { + "type": "paragraph", + "attrs": { + "textAlignment": "left" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/utils/const.ts b/tests/utils/const.ts index 804868ab25..3f8e7c09e7 100644 --- a/tests/utils/const.ts +++ b/tests/utils/const.ts @@ -20,6 +20,7 @@ export const DRAG_HANDLE_ADD_SELECTOR = `[data-test="dragHandleAdd"]`; export const DRAG_HANDLE_MENU_SELECTOR = `.mantine-DragHandleMenu-root`; export const SLASH_MENU_SELECTOR = `.mantine-SlashMenu-root`; +export const ITALIC_BUTTON_SELECTOR = `[data-test="italic"]`; export const COLORS_BUTTON_SELECTOR = `[data-test="colors"]`; export const TEXT_COLOR_SELECTOR = (color: string) => `[data-test="text-color-${color}"]`; From 6fcc4e39a5d827f71ab0bb28eb12975de92368a5 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Wed, 8 Feb 2023 16:59:04 +0100 Subject: [PATCH 5/6] Updated Chromium snapshot --- ...terPreservesMarks-json-chromium-linux.json | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json index 0eefd8b774..fa64e4b10e 100644 --- a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts-snapshots/enterPreservesMarks-json-chromium-linux.json @@ -17,7 +17,18 @@ "attrs": { "textAlignment": "left", "level": "1" - } + }, + "content": [ + { + "type": "text", + "marks": [ + { + "type": "italic" + } + ], + "text": "H" + } + ] } ] }, @@ -33,7 +44,18 @@ "type": "paragraph", "attrs": { "textAlignment": "left" - } + }, + "content": [ + { + "type": "text", + "marks": [ + { + "type": "italic" + } + ], + "text": "eading" + } + ] } ] }, From 1e4da992a876e7d8b2aea18fbe68459e9ef84d40 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Wed, 8 Feb 2023 17:02:18 +0100 Subject: [PATCH 6/6] Increased test timeout --- tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts index c08194e842..39be3d5f62 100644 --- a/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts +++ b/tests/end-to-end/keyboardhandlers/keyboardhandlers.test.ts @@ -45,10 +45,12 @@ test.describe("Check Keyboard Handlers' Behaviour", () => { await page.mouse.click(x + 35, y + height / 2, { clickCount: 2 }); await page.locator(ITALIC_BUTTON_SELECTOR).click(); - await page.waitForTimeout(450); + await page.waitForTimeout(600); await page.mouse.click(x + 35, y + height / 2); await page.keyboard.press("Enter"); + await page.pause(); + await compareDocToSnapshot(page, "enterPreservesMarks.json"); }); test("Check Enter preserves nested blocks", async ({ page }) => {