@blocknote/core 0.50.0 → 0.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +4 -4
- package/dist/{blocks-UU7EM-QM.js → blocks-D0lMxErU.js} +397 -368
- package/dist/blocks-D0lMxErU.js.map +1 -0
- package/dist/blocks-KyMOxPT3.cjs +11 -0
- package/dist/blocks-KyMOxPT3.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/extensions-Cutrafjg.cjs +52 -0
- package/dist/extensions-Cutrafjg.cjs.map +1 -0
- package/dist/{extensions-CkLT--Nc.js → extensions-D2mx2C9y.js} +622 -353
- package/dist/extensions-D2mx2C9y.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +1 -1
- package/dist/locales.js.map +1 -1
- package/dist/src-D5R5YzV7.cjs +21 -0
- package/dist/src-D5R5YzV7.cjs.map +1 -0
- package/dist/{src-SVFpMAWE.js → src-Dvmif2FY.js} +1070 -564
- package/dist/src-Dvmif2FY.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +8 -8
- package/package.json +1 -13
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +7 -7
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +5 -5
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +2550 -291
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +83 -2
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +103 -42
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -143
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +6 -6
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +22 -22
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +12 -8
- package/src/api/blockManipulation/setupTestEnv.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +2 -6
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +7 -2
- package/src/api/clipboard/toClipboard/copyExtension.ts +12 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +12 -4
- package/src/api/exporters/markdown/htmlToMarkdown.ts +813 -0
- package/src/api/exporters/markdown/markdownExporter.ts +2 -21
- package/src/api/nodeConversions/blockToNode.ts +3 -2
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +122 -107
- package/src/api/parsers/html/util/nestedLists.test.ts +1 -12
- package/src/api/parsers/markdown/markdownToHtml.ts +1194 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +2 -101
- package/src/blocks/Audio/block.ts +1 -4
- package/src/blocks/Code/block.test.ts +258 -0
- package/src/blocks/File/block.ts +1 -4
- package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +7 -2
- package/src/blocks/Image/block.ts +9 -6
- package/src/blocks/ListItem/BulletListItem/block.ts +7 -4
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +3 -4
- package/src/blocks/Video/block.ts +4 -5
- package/src/blocks/Video/parseVideoElement.ts +2 -1
- package/src/editor/Block.css +8 -0
- package/src/editor/BlockNoteEditor.test.ts +10 -4
- package/src/editor/BlockNoteEditor.ts +30 -13
- package/src/editor/managers/BlockManager.ts +10 -6
- package/src/editor/managers/ExtensionManager/index.ts +80 -25
- package/src/editor/performance.test.ts +2 -2
- package/src/editor/transformPasted.test.ts +295 -0
- package/src/editor/transformPasted.ts +77 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +1 -12
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +0 -11
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
- package/src/extensions/SideMenu/dragging.ts +7 -10
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +21 -0
- package/src/extensions/TrailingNode/TrailingNode.ts +124 -65
- package/src/i18n/locales/fr.ts +1 -1
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +13 -2
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +1 -1
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +1 -0
- package/types/src/api/exporters/markdown/htmlToMarkdown.d.ts +11 -0
- package/types/src/api/parsers/markdown/markdownToHtml.d.ts +5 -0
- package/types/src/blocks/Code/block.test.d.ts +1 -0
- package/types/src/blocks/Video/block.d.ts +2 -0
- package/types/src/blocks/Video/parseVideoElement.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +20 -6
- package/types/src/editor/managers/BlockManager.d.ts +8 -4
- package/types/src/editor/transformPasted.test.d.ts +1 -0
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +8 -3
- package/dist/blocks-BFnTypT-.cjs +0 -11
- package/dist/blocks-BFnTypT-.cjs.map +0 -1
- package/dist/blocks-UU7EM-QM.js.map +0 -1
- package/dist/extensions-CYsFi5Is.cjs +0 -2
- package/dist/extensions-CYsFi5Is.cjs.map +0 -1
- package/dist/extensions-CkLT--Nc.js.map +0 -1
- package/dist/src-DsJ6yzs9.cjs +0 -5
- package/dist/src-DsJ6yzs9.cjs.map +0 -1
- package/dist/src-SVFpMAWE.js.map +0 -1
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +0 -42
- package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +0 -19
- package/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.ts +0 -39
- package/types/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.d.ts +0 -7
- package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +0 -2
- package/types/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.d.ts +0 -6
|
@@ -2,7 +2,10 @@ import { NodeSelection, TextSelection } from "prosemirror-state";
|
|
|
2
2
|
import { CellSelection } from "prosemirror-tables";
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getBlockInfoFromTransaction,
|
|
7
|
+
getNearestBlockPos,
|
|
8
|
+
} from "../../../getBlockInfoFromPos.js";
|
|
6
9
|
import { setupTestEnv } from "../../setupTestEnv.js";
|
|
7
10
|
import {
|
|
8
11
|
moveBlocksDown,
|
|
@@ -204,6 +207,45 @@ describe("Test moveBlocksUp", () => {
|
|
|
204
207
|
|
|
205
208
|
expect(getEditor().document).toMatchSnapshot();
|
|
206
209
|
});
|
|
210
|
+
|
|
211
|
+
it("Explicit block argument moves the given block", () => {
|
|
212
|
+
getEditor().setTextCursorPosition("paragraph-0");
|
|
213
|
+
|
|
214
|
+
moveBlocksUp(getEditor(), "paragraph-2");
|
|
215
|
+
|
|
216
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("Explicit block argument does not change the selection", () => {
|
|
220
|
+
getEditor().setTextCursorPosition("paragraph-1");
|
|
221
|
+
makeSelectionSpanContent("text");
|
|
222
|
+
|
|
223
|
+
moveBlocksUp(getEditor(), "paragraph-2");
|
|
224
|
+
|
|
225
|
+
const { anchor, head } = getEditor().transact((tr) => tr.selection);
|
|
226
|
+
const anchorBlockId = getEditor().transact(
|
|
227
|
+
(tr) => getNearestBlockPos(tr.doc, anchor).node.attrs.id,
|
|
228
|
+
);
|
|
229
|
+
const headBlockId = getEditor().transact(
|
|
230
|
+
(tr) => getNearestBlockPos(tr.doc, head).node.attrs.id,
|
|
231
|
+
);
|
|
232
|
+
expect(anchorBlockId).toBe("paragraph-1");
|
|
233
|
+
expect(headBlockId).toBe("paragraph-1");
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("Explicit block argument with first block is a no-op", () => {
|
|
237
|
+
const documentBefore = getEditor().document;
|
|
238
|
+
|
|
239
|
+
moveBlocksUp(getEditor(), "paragraph-0");
|
|
240
|
+
|
|
241
|
+
expect(getEditor().document).toEqual(documentBefore);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it("Explicit block argument with nested block", () => {
|
|
245
|
+
moveBlocksUp(getEditor(), "nested-paragraph-1");
|
|
246
|
+
|
|
247
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
248
|
+
});
|
|
207
249
|
});
|
|
208
250
|
|
|
209
251
|
describe("Test moveBlocksDown", () => {
|
|
@@ -232,7 +274,7 @@ describe("Test moveBlocksDown", () => {
|
|
|
232
274
|
});
|
|
233
275
|
|
|
234
276
|
it("Last block", () => {
|
|
235
|
-
getEditor().setTextCursorPosition("
|
|
277
|
+
getEditor().setTextCursorPosition("paragraph-9");
|
|
236
278
|
|
|
237
279
|
moveBlocksDown(getEditor());
|
|
238
280
|
|
|
@@ -286,4 +328,43 @@ describe("Test moveBlocksDown", () => {
|
|
|
286
328
|
|
|
287
329
|
expect(getEditor().document).toMatchSnapshot();
|
|
288
330
|
});
|
|
331
|
+
|
|
332
|
+
it("Explicit block argument moves the given block", () => {
|
|
333
|
+
getEditor().setTextCursorPosition("paragraph-9");
|
|
334
|
+
|
|
335
|
+
moveBlocksDown(getEditor(), "paragraph-0");
|
|
336
|
+
|
|
337
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it("Explicit block argument does not change the selection", () => {
|
|
341
|
+
getEditor().setTextCursorPosition("paragraph-1");
|
|
342
|
+
makeSelectionSpanContent("text");
|
|
343
|
+
|
|
344
|
+
moveBlocksDown(getEditor(), "paragraph-0");
|
|
345
|
+
|
|
346
|
+
const { anchor, head } = getEditor().transact((tr) => tr.selection);
|
|
347
|
+
const anchorBlockId = getEditor().transact(
|
|
348
|
+
(tr) => getNearestBlockPos(tr.doc, anchor).node.attrs.id,
|
|
349
|
+
);
|
|
350
|
+
const headBlockId = getEditor().transact(
|
|
351
|
+
(tr) => getNearestBlockPos(tr.doc, head).node.attrs.id,
|
|
352
|
+
);
|
|
353
|
+
expect(anchorBlockId).toBe("paragraph-1");
|
|
354
|
+
expect(headBlockId).toBe("paragraph-1");
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it("Explicit block argument with last block is a no-op", () => {
|
|
358
|
+
const documentBefore = getEditor().document;
|
|
359
|
+
|
|
360
|
+
moveBlocksDown(getEditor(), "trailing-paragraph");
|
|
361
|
+
|
|
362
|
+
expect(getEditor().document).toEqual(documentBefore);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it("Explicit block argument with nested block", () => {
|
|
366
|
+
moveBlocksDown(getEditor(), "nested-paragraph-0");
|
|
367
|
+
|
|
368
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
369
|
+
});
|
|
289
370
|
});
|
|
@@ -123,29 +123,50 @@ function updateBlockSelectionFromData(
|
|
|
123
123
|
tr.setSelection(selection);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
* done here instead of in `getSelection` as we still need to remove the entire
|
|
129
|
-
* `columnList` node but only insert the `blockContainer` nodes inside it.
|
|
130
|
-
* @param blocks The blocks to flatten.
|
|
131
|
-
*/
|
|
126
|
+
// Replaces top-level `column` blocks with their children, as a `column` is not
|
|
127
|
+
// a valid block outside a `columnList`. Other blocks are returned as-is.
|
|
132
128
|
function flattenColumns(
|
|
133
129
|
blocks: Block<any, any, any>[],
|
|
134
130
|
): Block<any, any, any>[] {
|
|
135
|
-
return blocks
|
|
136
|
-
.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
131
|
+
return blocks.flatMap((block) =>
|
|
132
|
+
block.type === "column" ? block.children : [block],
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Removes the given blocks from the editor, then inserts them before/after a
|
|
138
|
+
* reference block.
|
|
139
|
+
* @param editor The BlockNote editor instance to move the blocks in.
|
|
140
|
+
* @param blocks The blocks to move.
|
|
141
|
+
* @param referenceBlock The reference block to insert the blocks before/after.
|
|
142
|
+
* @param placement Whether to insert the blocks before or after the reference
|
|
143
|
+
* block.
|
|
144
|
+
*/
|
|
145
|
+
export function moveBlocks(
|
|
146
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
147
|
+
blocks: Block<any, any, any>[],
|
|
148
|
+
referenceBlock: BlockIdentifier,
|
|
149
|
+
placement: "before" | "after",
|
|
150
|
+
) {
|
|
151
|
+
editor.transact(() => {
|
|
152
|
+
// A `columnList` reference can be dissolved by `fixColumnList` when its
|
|
153
|
+
// `column`s are removed, leaving its ID invalid for re-insertion. Anchor
|
|
154
|
+
// to an adjacent block instead, which is unaffected by the removal.
|
|
155
|
+
const refBlock = editor.getBlock(referenceBlock);
|
|
156
|
+
if (refBlock?.type === "columnList") {
|
|
157
|
+
const adjacent =
|
|
158
|
+
placement === "after"
|
|
159
|
+
? editor.getNextBlock(refBlock)
|
|
160
|
+
: editor.getPrevBlock(refBlock);
|
|
161
|
+
if (adjacent) {
|
|
162
|
+
referenceBlock = adjacent;
|
|
163
|
+
placement = placement === "after" ? "before" : "after";
|
|
141
164
|
}
|
|
165
|
+
}
|
|
142
166
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
147
|
-
})
|
|
148
|
-
.flat();
|
|
167
|
+
editor.removeBlocks(blocks);
|
|
168
|
+
editor.insertBlocks(flattenColumns(blocks), referenceBlock, placement);
|
|
169
|
+
});
|
|
149
170
|
}
|
|
150
171
|
|
|
151
172
|
/**
|
|
@@ -170,8 +191,7 @@ export function moveSelectedBlocksAndSelection(
|
|
|
170
191
|
];
|
|
171
192
|
const selectionData = getBlockSelectionData(editor);
|
|
172
193
|
|
|
173
|
-
editor
|
|
174
|
-
editor.insertBlocks(flattenColumns(blocks), referenceBlock, placement);
|
|
194
|
+
moveBlocks(editor, blocks, referenceBlock, placement);
|
|
175
195
|
|
|
176
196
|
updateBlockSelectionFromData(tr, selectionData);
|
|
177
197
|
});
|
|
@@ -289,50 +309,91 @@ function getMoveDownPlacement(
|
|
|
289
309
|
return { referenceBlock, placement };
|
|
290
310
|
}
|
|
291
311
|
|
|
292
|
-
export function moveBlocksUp(
|
|
312
|
+
export function moveBlocksUp(
|
|
313
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
314
|
+
blockIdentifier?: BlockIdentifier,
|
|
315
|
+
) {
|
|
293
316
|
editor.transact(() => {
|
|
294
|
-
|
|
295
|
-
|
|
317
|
+
let sourceBlock: Block<any, any, any> | undefined;
|
|
318
|
+
if (blockIdentifier) {
|
|
319
|
+
sourceBlock = editor.getBlock(blockIdentifier);
|
|
320
|
+
if (!sourceBlock) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
const selection = editor.getSelection();
|
|
325
|
+
sourceBlock =
|
|
326
|
+
selection?.blocks[0] || editor.getTextCursorPosition().block;
|
|
327
|
+
}
|
|
296
328
|
|
|
297
329
|
const moveUpPlacement = getMoveUpPlacement(
|
|
298
330
|
editor,
|
|
299
|
-
editor.getPrevBlock(
|
|
300
|
-
editor.getParentBlock(
|
|
331
|
+
editor.getPrevBlock(sourceBlock),
|
|
332
|
+
editor.getParentBlock(sourceBlock),
|
|
301
333
|
);
|
|
302
334
|
|
|
303
335
|
if (!moveUpPlacement) {
|
|
304
336
|
return;
|
|
305
337
|
}
|
|
306
338
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
339
|
+
if (blockIdentifier) {
|
|
340
|
+
moveBlocks(
|
|
341
|
+
editor,
|
|
342
|
+
[sourceBlock],
|
|
343
|
+
moveUpPlacement.referenceBlock,
|
|
344
|
+
moveUpPlacement.placement,
|
|
345
|
+
);
|
|
346
|
+
} else {
|
|
347
|
+
moveSelectedBlocksAndSelection(
|
|
348
|
+
editor,
|
|
349
|
+
moveUpPlacement.referenceBlock,
|
|
350
|
+
moveUpPlacement.placement,
|
|
351
|
+
);
|
|
352
|
+
}
|
|
312
353
|
});
|
|
313
354
|
}
|
|
314
355
|
|
|
315
|
-
export function moveBlocksDown(
|
|
356
|
+
export function moveBlocksDown(
|
|
357
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
358
|
+
blockIdentifier?: BlockIdentifier,
|
|
359
|
+
) {
|
|
316
360
|
editor.transact(() => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
361
|
+
let sourceBlock: Block<any, any, any> | undefined;
|
|
362
|
+
if (blockIdentifier) {
|
|
363
|
+
sourceBlock = editor.getBlock(blockIdentifier);
|
|
364
|
+
if (!sourceBlock) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
const selection = editor.getSelection();
|
|
369
|
+
sourceBlock =
|
|
370
|
+
selection?.blocks[selection?.blocks.length - 1] ||
|
|
371
|
+
editor.getTextCursorPosition().block;
|
|
372
|
+
}
|
|
321
373
|
|
|
322
374
|
const moveDownPlacement = getMoveDownPlacement(
|
|
323
375
|
editor,
|
|
324
|
-
editor.getNextBlock(
|
|
325
|
-
editor.getParentBlock(
|
|
376
|
+
editor.getNextBlock(sourceBlock),
|
|
377
|
+
editor.getParentBlock(sourceBlock),
|
|
326
378
|
);
|
|
327
379
|
|
|
328
380
|
if (!moveDownPlacement) {
|
|
329
381
|
return;
|
|
330
382
|
}
|
|
331
383
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
384
|
+
if (blockIdentifier) {
|
|
385
|
+
moveBlocks(
|
|
386
|
+
editor,
|
|
387
|
+
[sourceBlock],
|
|
388
|
+
moveDownPlacement.referenceBlock,
|
|
389
|
+
moveDownPlacement.placement,
|
|
390
|
+
);
|
|
391
|
+
} else {
|
|
392
|
+
moveSelectedBlocksAndSelection(
|
|
393
|
+
editor,
|
|
394
|
+
moveDownPlacement.referenceBlock,
|
|
395
|
+
moveDownPlacement.placement,
|
|
396
|
+
);
|
|
397
|
+
}
|
|
337
398
|
});
|
|
338
399
|
}
|
|
@@ -71,17 +71,6 @@ exports[`unnestBlock / liftListItem > BLO-835: unnest block with siblings after
|
|
|
71
71
|
},
|
|
72
72
|
"type": "paragraph",
|
|
73
73
|
},
|
|
74
|
-
{
|
|
75
|
-
"children": [],
|
|
76
|
-
"content": [],
|
|
77
|
-
"id": "0",
|
|
78
|
-
"props": {
|
|
79
|
-
"backgroundColor": "default",
|
|
80
|
-
"textAlignment": "left",
|
|
81
|
-
"textColor": "default",
|
|
82
|
-
},
|
|
83
|
-
"type": "paragraph",
|
|
84
|
-
},
|
|
85
74
|
]
|
|
86
75
|
`;
|
|
87
76
|
|
|
@@ -139,17 +128,6 @@ exports[`unnestBlock / liftListItem > BLO-835: unnest block with siblings after
|
|
|
139
128
|
},
|
|
140
129
|
"type": "paragraph",
|
|
141
130
|
},
|
|
142
|
-
{
|
|
143
|
-
"children": [],
|
|
144
|
-
"content": [],
|
|
145
|
-
"id": "0",
|
|
146
|
-
"props": {
|
|
147
|
-
"backgroundColor": "default",
|
|
148
|
-
"textAlignment": "left",
|
|
149
|
-
"textColor": "default",
|
|
150
|
-
},
|
|
151
|
-
"type": "paragraph",
|
|
152
|
-
},
|
|
153
131
|
]
|
|
154
132
|
`;
|
|
155
133
|
|
|
@@ -241,17 +219,6 @@ exports[`unnestBlock / liftListItem > BLO-835: unnest block with siblings after
|
|
|
241
219
|
},
|
|
242
220
|
"type": "paragraph",
|
|
243
221
|
},
|
|
244
|
-
{
|
|
245
|
-
"children": [],
|
|
246
|
-
"content": [],
|
|
247
|
-
"id": "0",
|
|
248
|
-
"props": {
|
|
249
|
-
"backgroundColor": "default",
|
|
250
|
-
"textAlignment": "left",
|
|
251
|
-
"textColor": "default",
|
|
252
|
-
},
|
|
253
|
-
"type": "paragraph",
|
|
254
|
-
},
|
|
255
222
|
]
|
|
256
223
|
`;
|
|
257
224
|
|
|
@@ -326,17 +293,6 @@ exports[`unnestBlock / liftListItem > BLO-844/847: unnest with complex nesting a
|
|
|
326
293
|
},
|
|
327
294
|
"type": "paragraph",
|
|
328
295
|
},
|
|
329
|
-
{
|
|
330
|
-
"children": [],
|
|
331
|
-
"content": [],
|
|
332
|
-
"id": "0",
|
|
333
|
-
"props": {
|
|
334
|
-
"backgroundColor": "default",
|
|
335
|
-
"textAlignment": "left",
|
|
336
|
-
"textColor": "default",
|
|
337
|
-
},
|
|
338
|
-
"type": "paragraph",
|
|
339
|
-
},
|
|
340
296
|
]
|
|
341
297
|
`;
|
|
342
298
|
|
|
@@ -376,17 +332,6 @@ exports[`unnestBlock / liftListItem > BLO-844/847: unnest with complex nesting a
|
|
|
376
332
|
},
|
|
377
333
|
"type": "paragraph",
|
|
378
334
|
},
|
|
379
|
-
{
|
|
380
|
-
"children": [],
|
|
381
|
-
"content": [],
|
|
382
|
-
"id": "0",
|
|
383
|
-
"props": {
|
|
384
|
-
"backgroundColor": "default",
|
|
385
|
-
"textAlignment": "left",
|
|
386
|
-
"textColor": "default",
|
|
387
|
-
},
|
|
388
|
-
"type": "paragraph",
|
|
389
|
-
},
|
|
390
335
|
]
|
|
391
336
|
`;
|
|
392
337
|
|
|
@@ -514,17 +459,6 @@ exports[`unnestBlock / liftListItem > BLO-899: Shift-Tab on second-level nested
|
|
|
514
459
|
},
|
|
515
460
|
"type": "paragraph",
|
|
516
461
|
},
|
|
517
|
-
{
|
|
518
|
-
"children": [],
|
|
519
|
-
"content": [],
|
|
520
|
-
"id": "0",
|
|
521
|
-
"props": {
|
|
522
|
-
"backgroundColor": "default",
|
|
523
|
-
"textAlignment": "left",
|
|
524
|
-
"textColor": "default",
|
|
525
|
-
},
|
|
526
|
-
"type": "paragraph",
|
|
527
|
-
},
|
|
528
462
|
]
|
|
529
463
|
`;
|
|
530
464
|
|
|
@@ -600,17 +534,6 @@ exports[`unnestBlock / liftListItem > BLO-899: Shift-Tab on second-level nested
|
|
|
600
534
|
},
|
|
601
535
|
"type": "paragraph",
|
|
602
536
|
},
|
|
603
|
-
{
|
|
604
|
-
"children": [],
|
|
605
|
-
"content": [],
|
|
606
|
-
"id": "0",
|
|
607
|
-
"props": {
|
|
608
|
-
"backgroundColor": "default",
|
|
609
|
-
"textAlignment": "left",
|
|
610
|
-
"textColor": "default",
|
|
611
|
-
},
|
|
612
|
-
"type": "paragraph",
|
|
613
|
-
},
|
|
614
537
|
]
|
|
615
538
|
`;
|
|
616
539
|
|
|
@@ -703,17 +626,6 @@ exports[`unnestBlock / liftListItem > BLO-953: unnest block with multi-level nes
|
|
|
703
626
|
},
|
|
704
627
|
"type": "paragraph",
|
|
705
628
|
},
|
|
706
|
-
{
|
|
707
|
-
"children": [],
|
|
708
|
-
"content": [],
|
|
709
|
-
"id": "0",
|
|
710
|
-
"props": {
|
|
711
|
-
"backgroundColor": "default",
|
|
712
|
-
"textAlignment": "left",
|
|
713
|
-
"textColor": "default",
|
|
714
|
-
},
|
|
715
|
-
"type": "paragraph",
|
|
716
|
-
},
|
|
717
629
|
]
|
|
718
630
|
`;
|
|
719
631
|
|
|
@@ -789,17 +701,6 @@ exports[`unnestBlock / liftListItem > BLO-953: unnest block with multi-level nes
|
|
|
789
701
|
},
|
|
790
702
|
"type": "paragraph",
|
|
791
703
|
},
|
|
792
|
-
{
|
|
793
|
-
"children": [],
|
|
794
|
-
"content": [],
|
|
795
|
-
"id": "0",
|
|
796
|
-
"props": {
|
|
797
|
-
"backgroundColor": "default",
|
|
798
|
-
"textAlignment": "left",
|
|
799
|
-
"textColor": "default",
|
|
800
|
-
},
|
|
801
|
-
"type": "paragraph",
|
|
802
|
-
},
|
|
803
704
|
]
|
|
804
705
|
`;
|
|
805
706
|
|
|
@@ -891,17 +792,6 @@ exports[`unnestBlock / liftListItem > Edge cases > should handle unnesting block
|
|
|
891
792
|
},
|
|
892
793
|
"type": "paragraph",
|
|
893
794
|
},
|
|
894
|
-
{
|
|
895
|
-
"children": [],
|
|
896
|
-
"content": [],
|
|
897
|
-
"id": "0",
|
|
898
|
-
"props": {
|
|
899
|
-
"backgroundColor": "default",
|
|
900
|
-
"textAlignment": "left",
|
|
901
|
-
"textColor": "default",
|
|
902
|
-
},
|
|
903
|
-
"type": "paragraph",
|
|
904
|
-
},
|
|
905
795
|
]
|
|
906
796
|
`;
|
|
907
797
|
|
|
@@ -961,17 +851,6 @@ exports[`unnestBlock / liftListItem > Edge cases > should handle unnesting with
|
|
|
961
851
|
},
|
|
962
852
|
"type": "heading",
|
|
963
853
|
},
|
|
964
|
-
{
|
|
965
|
-
"children": [],
|
|
966
|
-
"content": [],
|
|
967
|
-
"id": "0",
|
|
968
|
-
"props": {
|
|
969
|
-
"backgroundColor": "default",
|
|
970
|
-
"textAlignment": "left",
|
|
971
|
-
"textColor": "default",
|
|
972
|
-
},
|
|
973
|
-
"type": "paragraph",
|
|
974
|
-
},
|
|
975
854
|
]
|
|
976
855
|
`;
|
|
977
856
|
|
|
@@ -1012,17 +891,6 @@ exports[`unnestBlock / liftListItem > nestBlock > should nest a block under its
|
|
|
1012
891
|
},
|
|
1013
892
|
"type": "paragraph",
|
|
1014
893
|
},
|
|
1015
|
-
{
|
|
1016
|
-
"children": [],
|
|
1017
|
-
"content": [],
|
|
1018
|
-
"id": "0",
|
|
1019
|
-
"props": {
|
|
1020
|
-
"backgroundColor": "default",
|
|
1021
|
-
"textAlignment": "left",
|
|
1022
|
-
"textColor": "default",
|
|
1023
|
-
},
|
|
1024
|
-
"type": "paragraph",
|
|
1025
|
-
},
|
|
1026
894
|
]
|
|
1027
895
|
`;
|
|
1028
896
|
|
|
@@ -1080,16 +948,5 @@ exports[`unnestBlock / liftListItem > nestBlock > should nest into a sibling tha
|
|
|
1080
948
|
},
|
|
1081
949
|
"type": "paragraph",
|
|
1082
950
|
},
|
|
1083
|
-
{
|
|
1084
|
-
"children": [],
|
|
1085
|
-
"content": [],
|
|
1086
|
-
"id": "0",
|
|
1087
|
-
"props": {
|
|
1088
|
-
"backgroundColor": "default",
|
|
1089
|
-
"textAlignment": "left",
|
|
1090
|
-
"textColor": "default",
|
|
1091
|
-
},
|
|
1092
|
-
"type": "paragraph",
|
|
1093
|
-
},
|
|
1094
951
|
]
|
|
1095
952
|
`;
|
package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap
CHANGED
|
@@ -470,7 +470,7 @@ exports[`Test replaceBlocks > Remove multiple consecutive blocks 1`] = `
|
|
|
470
470
|
{
|
|
471
471
|
"children": [],
|
|
472
472
|
"content": [],
|
|
473
|
-
"id": "
|
|
473
|
+
"id": "paragraph-9",
|
|
474
474
|
"props": {
|
|
475
475
|
"backgroundColor": "default",
|
|
476
476
|
"textAlignment": "left",
|
|
@@ -767,7 +767,7 @@ exports[`Test replaceBlocks > Remove multiple non-consecutive blocks 1`] = `
|
|
|
767
767
|
{
|
|
768
768
|
"children": [],
|
|
769
769
|
"content": [],
|
|
770
|
-
"id": "
|
|
770
|
+
"id": "paragraph-9",
|
|
771
771
|
"props": {
|
|
772
772
|
"backgroundColor": "default",
|
|
773
773
|
"textAlignment": "left",
|
|
@@ -1318,7 +1318,7 @@ exports[`Test replaceBlocks > Remove single block 1`] = `
|
|
|
1318
1318
|
{
|
|
1319
1319
|
"children": [],
|
|
1320
1320
|
"content": [],
|
|
1321
|
-
"id": "
|
|
1321
|
+
"id": "paragraph-9",
|
|
1322
1322
|
"props": {
|
|
1323
1323
|
"backgroundColor": "default",
|
|
1324
1324
|
"textAlignment": "left",
|
|
@@ -1850,7 +1850,7 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with multiple
|
|
|
1850
1850
|
{
|
|
1851
1851
|
"children": [],
|
|
1852
1852
|
"content": [],
|
|
1853
|
-
"id": "
|
|
1853
|
+
"id": "paragraph-9",
|
|
1854
1854
|
"props": {
|
|
1855
1855
|
"backgroundColor": "default",
|
|
1856
1856
|
"textAlignment": "left",
|
|
@@ -2342,7 +2342,7 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single ba
|
|
|
2342
2342
|
{
|
|
2343
2343
|
"children": [],
|
|
2344
2344
|
"content": [],
|
|
2345
|
-
"id": "
|
|
2345
|
+
"id": "paragraph-9",
|
|
2346
2346
|
"props": {
|
|
2347
2347
|
"backgroundColor": "default",
|
|
2348
2348
|
"textAlignment": "left",
|
|
@@ -2892,7 +2892,7 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single co
|
|
|
2892
2892
|
{
|
|
2893
2893
|
"children": [],
|
|
2894
2894
|
"content": [],
|
|
2895
|
-
"id": "
|
|
2895
|
+
"id": "paragraph-9",
|
|
2896
2896
|
"props": {
|
|
2897
2897
|
"backgroundColor": "default",
|
|
2898
2898
|
"textAlignment": "left",
|
|
@@ -3240,7 +3240,7 @@ exports[`Test replaceBlocks > Replace multiple non-consecutive blocks with multi
|
|
|
3240
3240
|
{
|
|
3241
3241
|
"children": [],
|
|
3242
3242
|
"content": [],
|
|
3243
|
-
"id": "
|
|
3243
|
+
"id": "paragraph-9",
|
|
3244
3244
|
"props": {
|
|
3245
3245
|
"backgroundColor": "default",
|
|
3246
3246
|
"textAlignment": "left",
|
|
@@ -3548,7 +3548,7 @@ exports[`Test replaceBlocks > Replace multiple non-consecutive blocks with singl
|
|
|
3548
3548
|
{
|
|
3549
3549
|
"children": [],
|
|
3550
3550
|
"content": [],
|
|
3551
|
-
"id": "
|
|
3551
|
+
"id": "paragraph-9",
|
|
3552
3552
|
"props": {
|
|
3553
3553
|
"backgroundColor": "default",
|
|
3554
3554
|
"textAlignment": "left",
|
|
@@ -3914,7 +3914,7 @@ exports[`Test replaceBlocks > Replace multiple non-consecutive blocks with singl
|
|
|
3914
3914
|
{
|
|
3915
3915
|
"children": [],
|
|
3916
3916
|
"content": [],
|
|
3917
|
-
"id": "
|
|
3917
|
+
"id": "paragraph-9",
|
|
3918
3918
|
"props": {
|
|
3919
3919
|
"backgroundColor": "default",
|
|
3920
3920
|
"textAlignment": "left",
|
|
@@ -4516,7 +4516,7 @@ exports[`Test replaceBlocks > Replace single block with multiple 1`] = `
|
|
|
4516
4516
|
{
|
|
4517
4517
|
"children": [],
|
|
4518
4518
|
"content": [],
|
|
4519
|
-
"id": "
|
|
4519
|
+
"id": "paragraph-9",
|
|
4520
4520
|
"props": {
|
|
4521
4521
|
"backgroundColor": "default",
|
|
4522
4522
|
"textAlignment": "left",
|
|
@@ -5078,7 +5078,7 @@ exports[`Test replaceBlocks > Replace single block with single basic 1`] = `
|
|
|
5078
5078
|
{
|
|
5079
5079
|
"children": [],
|
|
5080
5080
|
"content": [],
|
|
5081
|
-
"id": "
|
|
5081
|
+
"id": "paragraph-9",
|
|
5082
5082
|
"props": {
|
|
5083
5083
|
"backgroundColor": "default",
|
|
5084
5084
|
"textAlignment": "left",
|
|
@@ -5698,7 +5698,7 @@ exports[`Test replaceBlocks > Replace single block with single complex 1`] = `
|
|
|
5698
5698
|
{
|
|
5699
5699
|
"children": [],
|
|
5700
5700
|
"content": [],
|
|
5701
|
-
"id": "
|
|
5701
|
+
"id": "paragraph-9",
|
|
5702
5702
|
"props": {
|
|
5703
5703
|
"backgroundColor": "default",
|
|
5704
5704
|
"textAlignment": "left",
|
|
@@ -27,9 +27,11 @@ export function removeAndInsertBlocks<
|
|
|
27
27
|
const pmSchema = getPmSchema(tr);
|
|
28
28
|
// Converts the `PartialBlock`s to ProseMirror nodes to insert them into the
|
|
29
29
|
// document.
|
|
30
|
-
const nodesToInsert: Node[] = blocksToInsert.map((block) =>
|
|
31
|
-
blockToNode(block, pmSchema)
|
|
32
|
-
|
|
30
|
+
const nodesToInsert: Node[] = blocksToInsert.map((block) => {
|
|
31
|
+
const node = blockToNode(block, pmSchema);
|
|
32
|
+
node.check(); // `blockToNode` is lenient; validate before mutating the doc
|
|
33
|
+
return node;
|
|
34
|
+
});
|
|
33
35
|
|
|
34
36
|
const idsOfBlocksToRemove = new Set<string>(
|
|
35
37
|
blocksToRemove.map((block) =>
|