From 086beeb97d6f6959c8a3c434dee4014df737e9b5 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Thu, 7 May 2026 19:40:16 +0200 Subject: [PATCH 1/4] Added decoration to `TrailingNodeExtension` to hide trailing block when editor is read-only --- packages/core/src/editor/editor.css | 5 +++ .../extensions/TrailingNode/TrailingNode.ts | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/packages/core/src/editor/editor.css b/packages/core/src/editor/editor.css index a1a3dda7b0..7e65e448f0 100644 --- a/packages/core/src/editor/editor.css +++ b/packages/core/src/editor/editor.css @@ -195,3 +195,8 @@ For the ShowSelectionPlugin background-color: highlight; padding: 2px 0; } + +/* Hide trailing block when editor is not editable. */ +.bn-editor[contenteditable="false"] .bn-trailing-block { + display: none; +} diff --git a/packages/core/src/extensions/TrailingNode/TrailingNode.ts b/packages/core/src/extensions/TrailingNode/TrailingNode.ts index 523c5fef4a..e71e591439 100644 --- a/packages/core/src/extensions/TrailingNode/TrailingNode.ts +++ b/packages/core/src/extensions/TrailingNode/TrailingNode.ts @@ -1,4 +1,5 @@ import { Plugin, PluginKey } from "prosemirror-state"; +import { Decoration, DecorationSet } from "prosemirror-view"; import { createExtension } from "../../editor/BlockNoteExtension.js"; // based on https://github.com/ueberdosis/tiptap/blob/40a9404c94c7fef7900610c195536384781ae101/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts @@ -19,6 +20,41 @@ export const TrailingNodeExtension = createExtension(() => { prosemirrorPlugins: [ new Plugin({ key: plugin, + props: { + decorations: (state) => { + const { doc } = state; + + const lastBlockGroup = doc.lastChild; + if (!lastBlockGroup || lastBlockGroup.type.name !== "blockGroup") { + return; + } + + const lastBlockContainer = lastBlockGroup.lastChild; + if ( + !lastBlockContainer || + lastBlockContainer.type.name !== "blockContainer" + ) { + return; + } + + const lastBlockContent = lastBlockContainer.firstChild; + if ( + !lastBlockContent || + lastBlockContent.type.spec.content !== "inline*" || + lastBlockContent.content.size > 0 + ) { + return; + } + + const from = doc.content.size - 1 - lastBlockContainer.nodeSize; + + return DecorationSet.create(doc, [ + Decoration.node(from, from + lastBlockContainer.nodeSize, { + class: "bn-trailing-block", + }), + ]); + }, + }, appendTransaction: (_, __, state) => { const { doc, tr, schema } = state; const shouldInsertNodeAtEnd = plugin.getState(state); From e31e5ce6aba466de3fb6987349a62cef05e862b0 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Thu, 7 May 2026 20:08:20 +0200 Subject: [PATCH 2/4] Added optional argument to `moveBlocksUp/Down` to select block to move + tests --- .../__snapshots__/moveBlocks.test.ts.snap | 2798 +++++++++++++++-- .../commands/moveBlocks/moveBlocks.test.ts | 83 +- .../commands/moveBlocks/moveBlocks.ts | 109 +- packages/core/src/editor/BlockNoteEditor.ts | 16 +- .../core/src/editor/managers/BlockManager.ts | 16 +- 5 files changed, 2721 insertions(+), 301 deletions(-) diff --git a/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap b/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap index 902463bbc1..fa0248730a 100644 --- a/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +++ b/packages/core/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap @@ -568,8 +568,25 @@ exports[`Test moveBlocksDown > Basic 1`] = ` ] `; -exports[`Test moveBlocksDown > Into children 1`] = ` +exports[`Test moveBlocksDown > Explicit block argument moves the given block 1`] = ` [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, { "children": [], "content": [ @@ -589,23 +606,6 @@ exports[`Test moveBlocksDown > Into children 1`] = ` }, { "children": [ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph 1", - "type": "text", - }, - ], - "id": "paragraph-1", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, { "children": [ { @@ -1136,7 +1136,7 @@ exports[`Test moveBlocksDown > Into children 1`] = ` ] `; -exports[`Test moveBlocksDown > Last block 1`] = ` +exports[`Test moveBlocksDown > Explicit block argument with nested block 1`] = ` [ { "children": [], @@ -1172,36 +1172,35 @@ exports[`Test moveBlocksDown > Last block 1`] = ` }, "type": "paragraph", }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with children", + "type": "text", + }, + ], + "id": "paragraph-with-children", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, { "children": [ { - "children": [ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Double Nested Paragraph 0", - "type": "text", - }, - ], - "id": "double-nested-paragraph-0", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - ], + "children": [], "content": [ { "styles": {}, - "text": "Nested Paragraph 0", + "text": "Double Nested Paragraph 0", "type": "text", }, ], - "id": "nested-paragraph-0", + "id": "double-nested-paragraph-0", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -1213,11 +1212,11 @@ exports[`Test moveBlocksDown > Last block 1`] = ` "content": [ { "styles": {}, - "text": "Paragraph with children", + "text": "Nested Paragraph 0", "type": "text", }, ], - "id": "paragraph-with-children", + "id": "nested-paragraph-0", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -1704,7 +1703,7 @@ exports[`Test moveBlocksDown > Last block 1`] = ` ] `; -exports[`Test moveBlocksDown > Multiple blocks 1`] = ` +exports[`Test moveBlocksDown > Into children 1`] = ` [ { "children": [], @@ -1724,41 +1723,24 @@ exports[`Test moveBlocksDown > Multiple blocks 1`] = ` "type": "paragraph", }, { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph with props", - "type": "text", - }, - ], - "id": "paragraph-with-props", - "props": { - "backgroundColor": "default", - "textAlignment": "center", - "textColor": "red", - }, - "type": "paragraph", - }, - { - "children": [], - "content": [ + "children": [ { - "styles": {}, - "text": "Paragraph 1", - "type": "text", + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", }, - ], - "id": "paragraph-1", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - { - "children": [ { "children": [ { @@ -1827,6 +1809,23 @@ exports[`Test moveBlocksDown > Multiple blocks 1`] = ` }, "type": "paragraph", }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with props", + "type": "text", + }, + ], + "id": "paragraph-with-props", + "props": { + "backgroundColor": "default", + "textAlignment": "center", + "textColor": "red", + }, + "type": "paragraph", + }, { "children": [], "content": [ @@ -2272,7 +2271,7 @@ exports[`Test moveBlocksDown > Multiple blocks 1`] = ` ] `; -exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`] = ` +exports[`Test moveBlocksDown > Last block 1`] = ` [ { "children": [], @@ -2291,23 +2290,6 @@ exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`] }, "type": "paragraph", }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph 2", - "type": "text", - }, - ], - "id": "paragraph-2", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, { "children": [], "content": [ @@ -2378,6 +2360,23 @@ exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`] }, "type": "paragraph", }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 2", + "type": "text", + }, + ], + "id": "paragraph-2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, { "children": [], "content": [ @@ -2840,7 +2839,7 @@ exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`] ] `; -exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = ` +exports[`Test moveBlocksDown > Multiple blocks 1`] = ` [ { "children": [], @@ -2864,15 +2863,15 @@ exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = ` "content": [ { "styles": {}, - "text": "Paragraph 2", + "text": "Paragraph with props", "type": "text", }, ], - "id": "paragraph-2", + "id": "paragraph-with-props", "props": { "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", + "textAlignment": "center", + "textColor": "red", }, "type": "paragraph", }, @@ -2951,15 +2950,15 @@ exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = ` "content": [ { "styles": {}, - "text": "Paragraph with props", + "text": "Paragraph 2", "type": "text", }, ], - "id": "paragraph-with-props", + "id": "paragraph-2", "props": { "backgroundColor": "default", - "textAlignment": "center", - "textColor": "red", + "textAlignment": "left", + "textColor": "default", }, "type": "paragraph", }, @@ -3408,7 +3407,7 @@ exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = ` ] `; -exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested block 1`] = ` +exports[`Test moveBlocksDown > Multiple blocks ending in block with children 1`] = ` [ { "children": [], @@ -3432,11 +3431,11 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo "content": [ { "styles": {}, - "text": "Paragraph 1", + "text": "Paragraph 2", "type": "text", }, ], - "id": "paragraph-1", + "id": "paragraph-2", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -3449,22 +3448,11 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo "content": [ { "styles": {}, - "text": "Paragraph with children", + "text": "Paragraph 1", "type": "text", }, ], - "id": "paragraph-with-children", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - { - "children": [], - "content": [], - "id": "trailing-paragraph", + "id": "paragraph-1", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -3475,15 +3463,33 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo { "children": [ { - "children": [], + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 0", + "type": "text", + }, + ], + "id": "double-nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], "content": [ { "styles": {}, - "text": "Double Nested Paragraph 0", + "text": "Nested Paragraph 0", "type": "text", }, ], - "id": "double-nested-paragraph-0", + "id": "nested-paragraph-0", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -3495,11 +3501,11 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo "content": [ { "styles": {}, - "text": "Nested Paragraph 0", + "text": "Paragraph with children", "type": "text", }, ], - "id": "nested-paragraph-0", + "id": "paragraph-with-children", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -3512,28 +3518,11 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo "content": [ { "styles": {}, - "text": "Paragraph 2", + "text": "Paragraph with props", "type": "text", }, ], - "id": "paragraph-2", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph with props", - "type": "text", - }, - ], - "id": "paragraph-with-props", + "id": "paragraph-with-props", "props": { "backgroundColor": "default", "textAlignment": "center", @@ -3975,7 +3964,7 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo { "children": [], "content": [], - "id": "0", + "id": "trailing-paragraph", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -3986,7 +3975,7 @@ exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested blo ] `; -exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1`] = ` +exports[`Test moveBlocksDown > Multiple blocks ending in nested block 1`] = ` [ { "children": [], @@ -4010,11 +3999,11 @@ exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1 "content": [ { "styles": {}, - "text": "Paragraph 1", + "text": "Paragraph 2", "type": "text", }, ], - "id": "paragraph-1", + "id": "paragraph-2", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -4027,15 +4016,15 @@ exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1 "content": [ { "styles": {}, - "text": "Paragraph with props", + "text": "Paragraph 1", "type": "text", }, ], - "id": "paragraph-with-props", + "id": "paragraph-1", "props": { "backgroundColor": "default", - "textAlignment": "center", - "textColor": "red", + "textAlignment": "left", + "textColor": "default", }, "type": "paragraph", }, @@ -4097,15 +4086,15 @@ exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1 "content": [ { "styles": {}, - "text": "Paragraph 2", + "text": "Paragraph with props", "type": "text", }, ], - "id": "paragraph-2", + "id": "paragraph-with-props", "props": { "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", + "textAlignment": "center", + "textColor": "red", }, "type": "paragraph", }, @@ -4554,7 +4543,7 @@ exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1 ] `; -exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = ` +exports[`Test moveBlocksDown > Multiple blocks starting and ending in nested block 1`] = ` [ { "children": [], @@ -4609,18 +4598,12 @@ exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = ` }, { "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph with props", - "type": "text", - }, - ], - "id": "paragraph-with-props", + "content": [], + "id": "trailing-paragraph", "props": { "backgroundColor": "default", - "textAlignment": "center", - "textColor": "red", + "textAlignment": "left", + "textColor": "default", }, "type": "paragraph", }, @@ -4676,6 +4659,23 @@ exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = ` }, "type": "paragraph", }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with props", + "type": "text", + }, + ], + "id": "paragraph-with-props", + "props": { + "backgroundColor": "default", + "textAlignment": "center", + "textColor": "red", + }, + "type": "paragraph", + }, { "children": [], "content": [ @@ -5110,7 +5110,7 @@ exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = ` { "children": [], "content": [], - "id": "trailing-paragraph", + "id": "0", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -5121,7 +5121,7 @@ exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = ` ] `; -exports[`Test moveBlocksDown > Out of children 1`] = ` +exports[`Test moveBlocksDown > Multiple blocks starting in block with children 1`] = ` [ { "children": [], @@ -5157,6 +5157,23 @@ exports[`Test moveBlocksDown > Out of children 1`] = ` }, "type": "paragraph", }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with props", + "type": "text", + }, + ], + "id": "paragraph-with-props", + "props": { + "backgroundColor": "default", + "textAlignment": "center", + "textColor": "red", + }, + "type": "paragraph", + }, { "children": [ { @@ -5227,23 +5244,6 @@ exports[`Test moveBlocksDown > Out of children 1`] = ` }, "type": "paragraph", }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph with props", - "type": "text", - }, - ], - "id": "paragraph-with-props", - "props": { - "backgroundColor": "default", - "textAlignment": "center", - "textColor": "red", - }, - "type": "paragraph", - }, { "children": [], "content": [ @@ -5607,7 +5607,43 @@ exports[`Test moveBlocksDown > Out of children 1`] = ` "type": "paragraph", }, { - "children": [], + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 1", + "type": "text", + }, + ], + "id": "double-nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 1", + "type": "text", + }, + ], + "id": "nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], "content": [ { "styles": { @@ -5640,33 +5676,31 @@ exports[`Test moveBlocksDown > Out of children 1`] = ` "type": "heading", }, { - "children": [ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Double Nested Paragraph 1", - "type": "text", - }, - ], - "id": "double-nested-paragraph-1", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - ], + "children": [], + "content": [], + "id": "trailing-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] +`; + +exports[`Test moveBlocksDown > Multiple blocks starting in nested block 1`] = ` +[ + { + "children": [], "content": [ { "styles": {}, - "text": "Nested Paragraph 1", + "text": "Paragraph 0", "type": "text", }, ], - "id": "nested-paragraph-1", + "id": "paragraph-0", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -5676,8 +5710,14 @@ exports[`Test moveBlocksDown > Out of children 1`] = ` }, { "children": [], - "content": [], - "id": "trailing-paragraph", + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "paragraph-1", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -5685,21 +5725,16 @@ exports[`Test moveBlocksDown > Out of children 1`] = ` }, "type": "paragraph", }, -] -`; - -exports[`Test moveBlocksUp > Basic 1`] = ` -[ { "children": [], "content": [ { "styles": {}, - "text": "Paragraph 1", + "text": "Paragraph with children", "type": "text", }, ], - "id": "paragraph-1", + "id": "paragraph-with-children", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -5712,48 +5747,30 @@ exports[`Test moveBlocksUp > Basic 1`] = ` "content": [ { "styles": {}, - "text": "Paragraph 0", + "text": "Paragraph with props", "type": "text", }, ], - "id": "paragraph-0", + "id": "paragraph-with-props", "props": { "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", + "textAlignment": "center", + "textColor": "red", }, "type": "paragraph", }, { "children": [ { - "children": [ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Double Nested Paragraph 0", - "type": "text", - }, - ], - "id": "double-nested-paragraph-0", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - ], + "children": [], "content": [ { "styles": {}, - "text": "Nested Paragraph 0", + "text": "Double Nested Paragraph 0", "type": "text", }, ], - "id": "nested-paragraph-0", + "id": "double-nested-paragraph-0", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -5765,11 +5782,11 @@ exports[`Test moveBlocksUp > Basic 1`] = ` "content": [ { "styles": {}, - "text": "Paragraph with children", + "text": "Nested Paragraph 0", "type": "text", }, ], - "id": "paragraph-with-children", + "id": "nested-paragraph-0", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -5799,32 +5816,15 @@ exports[`Test moveBlocksUp > Basic 1`] = ` "content": [ { "styles": {}, - "text": "Paragraph with props", + "text": "Paragraph 3", "type": "text", }, ], - "id": "paragraph-with-props", + "id": "paragraph-3", "props": { "backgroundColor": "default", - "textAlignment": "center", - "textColor": "red", - }, - "type": "paragraph", - }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph 3", - "type": "text", - }, - ], - "id": "paragraph-3", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", + "textAlignment": "left", + "textColor": "default", }, "type": "paragraph", }, @@ -6256,6 +6256,2276 @@ exports[`Test moveBlocksUp > Basic 1`] = ` ] `; +exports[`Test moveBlocksDown > Out of children 1`] = ` +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 0", + "type": "text", + }, + ], + "id": "paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 0", + "type": "text", + }, + ], + "id": "double-nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 0", + "type": "text", + }, + ], + "id": "nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Paragraph with children", + "type": "text", + }, + ], + "id": "paragraph-with-children", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 2", + "type": "text", + }, + ], + "id": "paragraph-2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with props", + "type": "text", + }, + ], + "id": "paragraph-with-props", + "props": { + "backgroundColor": "default", + "textAlignment": "center", + "textColor": "red", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 3", + "type": "text", + }, + ], + "id": "paragraph-3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Paragraph", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "paragraph-with-styled-content", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 4", + "type": "text", + }, + ], + "id": "paragraph-4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "heading-0", + "props": { + "backgroundColor": "default", + "isToggleable": false, + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 5", + "type": "text", + }, + ], + "id": "paragraph-5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": undefined, + "id": "image-0", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "showPreview": true, + "textAlignment": "left", + "url": "https://via.placeholder.com/150", + }, + "type": "image", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 6", + "type": "text", + }, + ], + "id": "paragraph-6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + undefined, + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 1", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 2", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 3", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 4", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 5", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 6", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 7", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 8", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 9", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", + }, + "id": "table-0", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 7", + "type": "text", + }, + ], + "id": "paragraph-7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [], + "id": "empty-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 8", + "type": "text", + }, + ], + "id": "paragraph-8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "heading-with-everything", + "props": { + "backgroundColor": "red", + "isToggleable": false, + "level": 2, + "textAlignment": "center", + "textColor": "red", + }, + "type": "heading", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 1", + "type": "text", + }, + ], + "id": "double-nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 1", + "type": "text", + }, + ], + "id": "nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [], + "id": "trailing-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] +`; + +exports[`Test moveBlocksUp > Basic 1`] = ` +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 0", + "type": "text", + }, + ], + "id": "paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 0", + "type": "text", + }, + ], + "id": "double-nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 0", + "type": "text", + }, + ], + "id": "nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Paragraph with children", + "type": "text", + }, + ], + "id": "paragraph-with-children", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 2", + "type": "text", + }, + ], + "id": "paragraph-2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with props", + "type": "text", + }, + ], + "id": "paragraph-with-props", + "props": { + "backgroundColor": "default", + "textAlignment": "center", + "textColor": "red", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 3", + "type": "text", + }, + ], + "id": "paragraph-3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Paragraph", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "paragraph-with-styled-content", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 4", + "type": "text", + }, + ], + "id": "paragraph-4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "heading-0", + "props": { + "backgroundColor": "default", + "isToggleable": false, + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 5", + "type": "text", + }, + ], + "id": "paragraph-5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": undefined, + "id": "image-0", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "showPreview": true, + "textAlignment": "left", + "url": "https://via.placeholder.com/150", + }, + "type": "image", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 6", + "type": "text", + }, + ], + "id": "paragraph-6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + undefined, + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 1", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 2", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 3", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 4", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 5", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 6", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 7", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 8", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 9", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", + }, + "id": "table-0", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 7", + "type": "text", + }, + ], + "id": "paragraph-7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [], + "id": "empty-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 8", + "type": "text", + }, + ], + "id": "paragraph-8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 1", + "type": "text", + }, + ], + "id": "double-nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 1", + "type": "text", + }, + ], + "id": "nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "heading-with-everything", + "props": { + "backgroundColor": "red", + "isToggleable": false, + "level": 2, + "textAlignment": "center", + "textColor": "red", + }, + "type": "heading", + }, + { + "children": [], + "content": [], + "id": "trailing-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] +`; + +exports[`Test moveBlocksUp > Explicit block argument moves the given block 1`] = ` +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 0", + "type": "text", + }, + ], + "id": "paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 0", + "type": "text", + }, + ], + "id": "double-nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 0", + "type": "text", + }, + ], + "id": "nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 2", + "type": "text", + }, + ], + "id": "paragraph-2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Paragraph with children", + "type": "text", + }, + ], + "id": "paragraph-with-children", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with props", + "type": "text", + }, + ], + "id": "paragraph-with-props", + "props": { + "backgroundColor": "default", + "textAlignment": "center", + "textColor": "red", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 3", + "type": "text", + }, + ], + "id": "paragraph-3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Paragraph", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "paragraph-with-styled-content", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 4", + "type": "text", + }, + ], + "id": "paragraph-4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "heading-0", + "props": { + "backgroundColor": "default", + "isToggleable": false, + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 5", + "type": "text", + }, + ], + "id": "paragraph-5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": undefined, + "id": "image-0", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "showPreview": true, + "textAlignment": "left", + "url": "https://via.placeholder.com/150", + }, + "type": "image", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 6", + "type": "text", + }, + ], + "id": "paragraph-6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + undefined, + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 1", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 2", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 3", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 4", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 5", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 6", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 7", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 8", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 9", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", + }, + "id": "table-0", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 7", + "type": "text", + }, + ], + "id": "paragraph-7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [], + "id": "empty-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 8", + "type": "text", + }, + ], + "id": "paragraph-8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 1", + "type": "text", + }, + ], + "id": "double-nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 1", + "type": "text", + }, + ], + "id": "nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "heading-with-everything", + "props": { + "backgroundColor": "red", + "isToggleable": false, + "level": 2, + "textAlignment": "center", + "textColor": "red", + }, + "type": "heading", + }, + { + "children": [], + "content": [], + "id": "trailing-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] +`; + +exports[`Test moveBlocksUp > Explicit block argument with nested block 1`] = ` +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 0", + "type": "text", + }, + ], + "id": "paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 0", + "type": "text", + }, + ], + "id": "double-nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 0", + "type": "text", + }, + ], + "id": "nested-paragraph-0", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Paragraph with children", + "type": "text", + }, + ], + "id": "paragraph-with-children", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 2", + "type": "text", + }, + ], + "id": "paragraph-2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph with props", + "type": "text", + }, + ], + "id": "paragraph-with-props", + "props": { + "backgroundColor": "default", + "textAlignment": "center", + "textColor": "red", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 3", + "type": "text", + }, + ], + "id": "paragraph-3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Paragraph", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "paragraph-with-styled-content", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 4", + "type": "text", + }, + ], + "id": "paragraph-4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "heading-0", + "props": { + "backgroundColor": "default", + "isToggleable": false, + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 5", + "type": "text", + }, + ], + "id": "paragraph-5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": undefined, + "id": "image-0", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "showPreview": true, + "textAlignment": "left", + "url": "https://via.placeholder.com/150", + }, + "type": "image", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 6", + "type": "text", + }, + ], + "id": "paragraph-6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + undefined, + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 1", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 2", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 3", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 4", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 5", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 6", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 7", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 8", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 9", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", + }, + "id": "table-0", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 7", + "type": "text", + }, + ], + "id": "paragraph-7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [], + "id": "empty-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 8", + "type": "text", + }, + ], + "id": "paragraph-8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Double Nested Paragraph 1", + "type": "text", + }, + ], + "id": "double-nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 1", + "type": "text", + }, + ], + "id": "nested-paragraph-1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading", + "type": "text", + }, + { + "styles": {}, + "text": " with styled ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "content", + "type": "text", + }, + ], + "id": "heading-with-everything", + "props": { + "backgroundColor": "red", + "isToggleable": false, + "level": 2, + "textAlignment": "center", + "textColor": "red", + }, + "type": "heading", + }, + { + "children": [], + "content": [], + "id": "trailing-paragraph", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] +`; + exports[`Test moveBlocksUp > First block 1`] = ` [ { diff --git a/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts b/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts index 8c637d5985..387fc5d7a7 100644 --- a/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +++ b/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts @@ -2,7 +2,10 @@ import { NodeSelection, TextSelection } from "prosemirror-state"; import { CellSelection } from "prosemirror-tables"; import { describe, expect, it } from "vitest"; -import { getBlockInfoFromTransaction } from "../../../getBlockInfoFromPos.js"; +import { + getBlockInfoFromTransaction, + getNearestBlockPos, +} from "../../../getBlockInfoFromPos.js"; import { setupTestEnv } from "../../setupTestEnv.js"; import { moveBlocksDown, @@ -204,6 +207,45 @@ describe("Test moveBlocksUp", () => { expect(getEditor().document).toMatchSnapshot(); }); + + it("Explicit block argument moves the given block", () => { + getEditor().setTextCursorPosition("paragraph-0"); + + moveBlocksUp(getEditor(), "paragraph-2"); + + expect(getEditor().document).toMatchSnapshot(); + }); + + it("Explicit block argument does not change the selection", () => { + getEditor().setTextCursorPosition("paragraph-1"); + makeSelectionSpanContent("text"); + + moveBlocksUp(getEditor(), "paragraph-2"); + + const { anchor, head } = getEditor().transact((tr) => tr.selection); + const anchorBlockId = getEditor().transact( + (tr) => getNearestBlockPos(tr.doc, anchor).node.attrs.id, + ); + const headBlockId = getEditor().transact( + (tr) => getNearestBlockPos(tr.doc, head).node.attrs.id, + ); + expect(anchorBlockId).toBe("paragraph-1"); + expect(headBlockId).toBe("paragraph-1"); + }); + + it("Explicit block argument with first block is a no-op", () => { + const documentBefore = getEditor().document; + + moveBlocksUp(getEditor(), "paragraph-0"); + + expect(getEditor().document).toEqual(documentBefore); + }); + + it("Explicit block argument with nested block", () => { + moveBlocksUp(getEditor(), "nested-paragraph-1"); + + expect(getEditor().document).toMatchSnapshot(); + }); }); describe("Test moveBlocksDown", () => { @@ -286,4 +328,43 @@ describe("Test moveBlocksDown", () => { expect(getEditor().document).toMatchSnapshot(); }); + + it("Explicit block argument moves the given block", () => { + getEditor().setTextCursorPosition("trailing-paragraph"); + + moveBlocksDown(getEditor(), "paragraph-0"); + + expect(getEditor().document).toMatchSnapshot(); + }); + + it("Explicit block argument does not change the selection", () => { + getEditor().setTextCursorPosition("paragraph-1"); + makeSelectionSpanContent("text"); + + moveBlocksDown(getEditor(), "paragraph-0"); + + const { anchor, head } = getEditor().transact((tr) => tr.selection); + const anchorBlockId = getEditor().transact( + (tr) => getNearestBlockPos(tr.doc, anchor).node.attrs.id, + ); + const headBlockId = getEditor().transact( + (tr) => getNearestBlockPos(tr.doc, head).node.attrs.id, + ); + expect(anchorBlockId).toBe("paragraph-1"); + expect(headBlockId).toBe("paragraph-1"); + }); + + it("Explicit block argument with last block is a no-op", () => { + const documentBefore = getEditor().document; + + moveBlocksDown(getEditor(), "trailing-paragraph"); + + expect(getEditor().document).toEqual(documentBefore); + }); + + it("Explicit block argument with nested block", () => { + moveBlocksDown(getEditor(), "nested-paragraph-0"); + + expect(getEditor().document).toMatchSnapshot(); + }); }); diff --git a/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts b/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts index 8d4591123e..8709e2bf89 100644 --- a/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +++ b/packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts @@ -148,6 +148,27 @@ function flattenColumns( .flat(); } +/** + * Removes the given blocks from the editor, then inserts them before/after a + * reference block. + * @param editor The BlockNote editor instance to move the blocks in. + * @param blocks The blocks to move. + * @param referenceBlock The reference block to insert the blocks before/after. + * @param placement Whether to insert the blocks before or after the reference + * block. + */ +export function moveBlocks( + editor: BlockNoteEditor, + blocks: Block[], + referenceBlock: BlockIdentifier, + placement: "before" | "after", +) { + editor.transact(() => { + editor.removeBlocks(blocks); + editor.insertBlocks(flattenColumns(blocks), referenceBlock, placement); + }); +} + /** * Removes the selected blocks from the editor, then inserts them before/after a * reference block. Also updates the selection to match the original selection @@ -170,8 +191,7 @@ export function moveSelectedBlocksAndSelection( ]; const selectionData = getBlockSelectionData(editor); - editor.removeBlocks(blocks); - editor.insertBlocks(flattenColumns(blocks), referenceBlock, placement); + moveBlocks(editor, blocks, referenceBlock, placement); updateBlockSelectionFromData(tr, selectionData); }); @@ -289,50 +309,91 @@ function getMoveDownPlacement( return { referenceBlock, placement }; } -export function moveBlocksUp(editor: BlockNoteEditor) { +export function moveBlocksUp( + editor: BlockNoteEditor, + blockIdentifier?: BlockIdentifier, +) { editor.transact(() => { - const selection = editor.getSelection(); - const block = selection?.blocks[0] || editor.getTextCursorPosition().block; + let sourceBlock: Block | undefined; + if (blockIdentifier) { + sourceBlock = editor.getBlock(blockIdentifier); + if (!sourceBlock) { + return; + } + } else { + const selection = editor.getSelection(); + sourceBlock = + selection?.blocks[0] || editor.getTextCursorPosition().block; + } const moveUpPlacement = getMoveUpPlacement( editor, - editor.getPrevBlock(block), - editor.getParentBlock(block), + editor.getPrevBlock(sourceBlock), + editor.getParentBlock(sourceBlock), ); if (!moveUpPlacement) { return; } - moveSelectedBlocksAndSelection( - editor, - moveUpPlacement.referenceBlock, - moveUpPlacement.placement, - ); + if (blockIdentifier) { + moveBlocks( + editor, + [sourceBlock], + moveUpPlacement.referenceBlock, + moveUpPlacement.placement, + ); + } else { + moveSelectedBlocksAndSelection( + editor, + moveUpPlacement.referenceBlock, + moveUpPlacement.placement, + ); + } }); } -export function moveBlocksDown(editor: BlockNoteEditor) { +export function moveBlocksDown( + editor: BlockNoteEditor, + blockIdentifier?: BlockIdentifier, +) { editor.transact(() => { - const selection = editor.getSelection(); - const block = - selection?.blocks[selection?.blocks.length - 1] || - editor.getTextCursorPosition().block; + let sourceBlock: Block | undefined; + if (blockIdentifier) { + sourceBlock = editor.getBlock(blockIdentifier); + if (!sourceBlock) { + return; + } + } else { + const selection = editor.getSelection(); + sourceBlock = + selection?.blocks[selection?.blocks.length - 1] || + editor.getTextCursorPosition().block; + } const moveDownPlacement = getMoveDownPlacement( editor, - editor.getNextBlock(block), - editor.getParentBlock(block), + editor.getNextBlock(sourceBlock), + editor.getParentBlock(sourceBlock), ); if (!moveDownPlacement) { return; } - moveSelectedBlocksAndSelection( - editor, - moveDownPlacement.referenceBlock, - moveDownPlacement.placement, - ); + if (blockIdentifier) { + moveBlocks( + editor, + [sourceBlock], + moveDownPlacement.referenceBlock, + moveDownPlacement.placement, + ); + } else { + moveSelectedBlocksAndSelection( + editor, + moveDownPlacement.referenceBlock, + moveDownPlacement.placement, + ); + } }); } diff --git a/packages/core/src/editor/BlockNoteEditor.ts b/packages/core/src/editor/BlockNoteEditor.ts index ca6e0b4817..5d8bae1313 100644 --- a/packages/core/src/editor/BlockNoteEditor.ts +++ b/packages/core/src/editor/BlockNoteEditor.ts @@ -1240,19 +1240,23 @@ export class BlockNoteEditor< /** * Moves the selected blocks up. If the previous block has children, moves * them to the end of its children. If there is no previous block, but the - * current blocks share a common parent, moves them out of & before it. + * current blocks share a common parent, moves them out of & before it. If a + * `blockIdentifier` is provided, that block is moved instead of the + * selection, and the selection is left unchanged. */ - public moveBlocksUp() { - return this._blockManager.moveBlocksUp(); + public moveBlocksUp(blockIdentifier?: BlockIdentifier) { + return this._blockManager.moveBlocksUp(blockIdentifier); } /** * Moves the selected blocks down. If the next block has children, moves * them to the start of its children. If there is no next block, but the - * current blocks share a common parent, moves them out of & after it. + * current blocks share a common parent, moves them out of & after it. If a + * `blockIdentifier` is provided, that block is moved instead of the + * selection, and the selection is left unchanged. */ - public moveBlocksDown() { - return this._blockManager.moveBlocksDown(); + public moveBlocksDown(blockIdentifier?: BlockIdentifier) { + return this._blockManager.moveBlocksDown(blockIdentifier); } /** diff --git a/packages/core/src/editor/managers/BlockManager.ts b/packages/core/src/editor/managers/BlockManager.ts index 2ea90ae984..ea9d9a5680 100644 --- a/packages/core/src/editor/managers/BlockManager.ts +++ b/packages/core/src/editor/managers/BlockManager.ts @@ -234,18 +234,22 @@ export class BlockManager< /** * Moves the selected blocks up. If the previous block has children, moves * them to the end of its children. If there is no previous block, but the - * current blocks share a common parent, moves them out of & before it. + * current blocks share a common parent, moves them out of & before it. If a + * `blockIdentifier` is provided, that block is moved instead of the + * selection, and the selection is left unchanged. */ - public moveBlocksUp() { - return moveBlocksUp(this.editor); + public moveBlocksUp(blockIdentifier?: BlockIdentifier) { + return moveBlocksUp(this.editor, blockIdentifier); } /** * Moves the selected blocks down. If the next block has children, moves * them to the start of its children. If there is no next block, but the - * current blocks share a common parent, moves them out of & after it. + * current blocks share a common parent, moves them out of & after it. If a + * `blockIdentifier` is provided, that block is moved instead of the + * selection, and the selection is left unchanged. */ - public moveBlocksDown() { - return moveBlocksDown(this.editor); + public moveBlocksDown(blockIdentifier?: BlockIdentifier) { + return moveBlocksDown(this.editor, blockIdentifier); } } From d818562d9b0d14e7acf262ce431d0c56f9efa9d8 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Thu, 7 May 2026 20:14:45 +0200 Subject: [PATCH 3/4] Updated docs --- .../docs/reference/editor/manipulating-content.mdx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/content/docs/reference/editor/manipulating-content.mdx b/docs/content/docs/reference/editor/manipulating-content.mdx index 6c2df88dc7..1a9c97c222 100644 --- a/docs/content/docs/reference/editor/manipulating-content.mdx +++ b/docs/content/docs/reference/editor/manipulating-content.mdx @@ -252,11 +252,13 @@ editor.replaceBlocks( #### Reordering Blocks ```typescript -moveBlocksUp(): void -moveBlocksDown(): void +moveBlocksUp(blockIdentifier?: BlockIdentifier): void +moveBlocksDown(blockIdentifier?: BlockIdentifier): void ``` -Moves the currently selected blocks up or down in the document. +Moves the currently selected blocks up or down in the document. If a +`blockIdentifier` is provided, that block is moved instead of the selection, +and the selection is left unchanged. ```typescript // Move selected blocks up @@ -264,6 +266,12 @@ editor.moveBlocksUp(); // Move selected blocks down editor.moveBlocksDown(); + +// Move a specific block up, without changing the selection +editor.moveBlocksUp("block-123"); + +// Move a specific block down, without changing the selection +editor.moveBlocksDown("block-123"); ``` ### Nesting Blocks From 0caea13358fdd256e9c5e09ec3e93f205dd9feaa Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Thu, 7 May 2026 20:15:19 +0200 Subject: [PATCH 4/4] Revert "Added decoration to `TrailingNodeExtension` to hide trailing block when editor is read-only" This reverts commit 086beeb97d6f6959c8a3c434dee4014df737e9b5. --- packages/core/src/editor/editor.css | 5 --- .../extensions/TrailingNode/TrailingNode.ts | 36 ------------------- 2 files changed, 41 deletions(-) diff --git a/packages/core/src/editor/editor.css b/packages/core/src/editor/editor.css index 7e65e448f0..a1a3dda7b0 100644 --- a/packages/core/src/editor/editor.css +++ b/packages/core/src/editor/editor.css @@ -195,8 +195,3 @@ For the ShowSelectionPlugin background-color: highlight; padding: 2px 0; } - -/* Hide trailing block when editor is not editable. */ -.bn-editor[contenteditable="false"] .bn-trailing-block { - display: none; -} diff --git a/packages/core/src/extensions/TrailingNode/TrailingNode.ts b/packages/core/src/extensions/TrailingNode/TrailingNode.ts index e71e591439..523c5fef4a 100644 --- a/packages/core/src/extensions/TrailingNode/TrailingNode.ts +++ b/packages/core/src/extensions/TrailingNode/TrailingNode.ts @@ -1,5 +1,4 @@ import { Plugin, PluginKey } from "prosemirror-state"; -import { Decoration, DecorationSet } from "prosemirror-view"; import { createExtension } from "../../editor/BlockNoteExtension.js"; // based on https://github.com/ueberdosis/tiptap/blob/40a9404c94c7fef7900610c195536384781ae101/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts @@ -20,41 +19,6 @@ export const TrailingNodeExtension = createExtension(() => { prosemirrorPlugins: [ new Plugin({ key: plugin, - props: { - decorations: (state) => { - const { doc } = state; - - const lastBlockGroup = doc.lastChild; - if (!lastBlockGroup || lastBlockGroup.type.name !== "blockGroup") { - return; - } - - const lastBlockContainer = lastBlockGroup.lastChild; - if ( - !lastBlockContainer || - lastBlockContainer.type.name !== "blockContainer" - ) { - return; - } - - const lastBlockContent = lastBlockContainer.firstChild; - if ( - !lastBlockContent || - lastBlockContent.type.spec.content !== "inline*" || - lastBlockContent.content.size > 0 - ) { - return; - } - - const from = doc.content.size - 1 - lastBlockContainer.nodeSize; - - return DecorationSet.create(doc, [ - Decoration.node(from, from + lastBlockContainer.nodeSize, { - class: "bn-trailing-block", - }), - ]); - }, - }, appendTransaction: (_, __, state) => { const { doc, tr, schema } = state; const shouldInsertNodeAtEnd = plugin.getState(state);