@blocknote/xl-multi-column 0.29.1 → 0.30.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-xl-multi-column.cjs.map +1 -1
- package/dist/blocknote-xl-multi-column.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +7 -7
- package/src/blocks/Columns/index.ts +1 -1
- package/src/blocks/schema.ts +2 -2
- package/src/extensions/ColumnResize/ColumnResizeExtension.ts +17 -17
- package/src/extensions/DropCursor/MultiColumnDropCursorPlugin.ts +18 -15
- package/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx +4 -4
- package/src/i18n/dictionary.ts +1 -1
- package/src/test/commands/insertBlocks.test.ts +9 -9
- package/src/test/commands/replaceBlocks.test.ts +1 -1
- package/src/test/conversions/formatConversionTestUtil.ts +17 -17
- package/src/test/conversions/htmlConversion.test.ts +3 -3
- package/src/test/conversions/nodeConversion.test.ts +2 -2
- package/types/src/test/setupTestEnv.d.ts +16 -8
package/dist/webpack-stats.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"builtAt":
|
|
1
|
+
{"builtAt":1747749779136,"assets":[{"name":"blocknote-xl-multi-column.cjs","size":20482},{"name":"blocknote-xl-multi-column.cjs.map","size":3791875}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-multi-column.cjs"],"names":["blocknote-xl-multi-column"]}],"modules":[{"name":"./src/i18n/locales/ar.ts","size":364,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/de.ts","size":400,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/en.ts","size":378,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/es.ts","size":392,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/fr.ts","size":398,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/hr.ts","size":396,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/is.ts","size":376,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ja.ts","size":284,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ko.ts","size":288,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/nl.ts","size":390,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pl.ts","size":394,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pt.ts","size":388,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ru.ts","size":370,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/vi.ts","size":340,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/zh.ts","size":274,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/i18n/dictionary.ts","size":189,"chunks":["a1ee98a"]},{"name":"./src/extensions/ColumnResize/ColumnResizeExtension.ts","size":8309,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/Column.ts","size":2567,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/ColumnList.ts","size":1120,"chunks":["a1ee98a"]},{"name":"./src/blocks/Columns/index.ts","size":210,"chunks":["a1ee98a"]},{"name":"./src/blocks/schema.ts","size":425,"chunks":["a1ee98a"]},{"name":"./src/extensions/DropCursor/MultiColumnDropCursorPlugin.ts","size":11715,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@18.3.1/node_modules/react-icons/lib/iconContext.mjs","size":251,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@18.3.1/node_modules/react-icons/lib/iconBase.mjs","size":4003,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@18.3.1/node_modules/react-icons/tb/index.mjs","size":708,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx","size":2073,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"directory": "packages/xl-multi-column"
|
|
10
10
|
},
|
|
11
11
|
"license": "AGPL-3.0 OR PROPRIETARY",
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.30.1",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
15
|
"types",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@blocknote/core": "0.
|
|
46
|
-
"@blocknote/react": "0.
|
|
45
|
+
"@blocknote/core": "0.30.1",
|
|
46
|
+
"@blocknote/react": "0.30.1",
|
|
47
47
|
"@tiptap/core": "^2.7.1",
|
|
48
|
-
"prosemirror-model": "^1.
|
|
48
|
+
"prosemirror-model": "^1.25.1",
|
|
49
49
|
"prosemirror-state": "^1.4.3",
|
|
50
50
|
"prosemirror-tables": "^1.3.7",
|
|
51
51
|
"prosemirror-transform": "^1.9.0",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"eslint": "^8.10.0",
|
|
60
60
|
"jsdom": "^21.1.0",
|
|
61
61
|
"prettier": "^2.7.1",
|
|
62
|
+
"react": "^18.3.1",
|
|
63
|
+
"react-dom": "^18.3.1",
|
|
62
64
|
"rimraf": "^5.0.5",
|
|
63
65
|
"rollup-plugin-webpack-stats": "^0.2.2",
|
|
64
66
|
"typescript": "^5.3.3",
|
|
65
67
|
"vite": "^5.3.4",
|
|
66
68
|
"vite-plugin-eslint": "^1.8.1",
|
|
67
|
-
"vitest": "^2.0.3"
|
|
68
|
-
"react": "^18.3.1",
|
|
69
|
-
"react-dom": "^18.3.1"
|
|
69
|
+
"vitest": "^2.0.3"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "^18.0 || ^19.0 || >= 19.0.0-rc",
|
package/src/blocks/schema.ts
CHANGED
|
@@ -19,9 +19,9 @@ export const multiColumnSchema = BlockNoteSchema.create({
|
|
|
19
19
|
export const withMultiColumn = <
|
|
20
20
|
B extends BlockSchema,
|
|
21
21
|
I extends InlineContentSchema,
|
|
22
|
-
S extends StyleSchema
|
|
22
|
+
S extends StyleSchema,
|
|
23
23
|
>(
|
|
24
|
-
schema: BlockNoteSchema<B, I, S
|
|
24
|
+
schema: BlockNoteSchema<B, I, S>,
|
|
25
25
|
) => {
|
|
26
26
|
return BlockNoteSchema.create({
|
|
27
27
|
blockSpecs: {
|
|
@@ -54,7 +54,7 @@ class ColumnResizePluginView implements PluginView {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
getColumnHoverOrDefaultState = (
|
|
57
|
-
event: MouseEvent
|
|
57
|
+
event: MouseEvent,
|
|
58
58
|
): ColumnDefaultState | ColumnHoverState => {
|
|
59
59
|
if (!this.editor.isEditable) {
|
|
60
60
|
return { type: "default" };
|
|
@@ -68,7 +68,7 @@ class ColumnResizePluginView implements PluginView {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const columnElement = target.closest(
|
|
71
|
-
".bn-block-column"
|
|
71
|
+
".bn-block-column",
|
|
72
72
|
) as HTMLElement | null;
|
|
73
73
|
|
|
74
74
|
// Do nothing if a column element does not exist in the event target's
|
|
@@ -85,8 +85,8 @@ class ColumnResizePluginView implements PluginView {
|
|
|
85
85
|
startPos < columnElementDOMRect.left + this.RESIZE_MARGIN_WIDTH_PX
|
|
86
86
|
? "left"
|
|
87
87
|
: startPos > columnElementDOMRect.right - this.RESIZE_MARGIN_WIDTH_PX
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
? "right"
|
|
89
|
+
: "none";
|
|
90
90
|
|
|
91
91
|
// The column element before or after the one hovered by the cursor,
|
|
92
92
|
// depending on which side the cursor is on.
|
|
@@ -94,8 +94,8 @@ class ColumnResizePluginView implements PluginView {
|
|
|
94
94
|
cursorElementSide === "left"
|
|
95
95
|
? columnElement.previousElementSibling
|
|
96
96
|
: cursorElementSide === "right"
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
? columnElement.nextElementSibling
|
|
98
|
+
: undefined;
|
|
99
99
|
|
|
100
100
|
// Do nothing if the cursor is not within the resize margin or if there
|
|
101
101
|
// is no column before or after the one hovered by the cursor, depending
|
|
@@ -121,7 +121,7 @@ class ColumnResizePluginView implements PluginView {
|
|
|
121
121
|
|
|
122
122
|
const rightColumnNodeAndPos = getNodeById(
|
|
123
123
|
rightColumnId,
|
|
124
|
-
this.view.state.doc
|
|
124
|
+
this.view.state.doc,
|
|
125
125
|
);
|
|
126
126
|
|
|
127
127
|
if (
|
|
@@ -186,7 +186,7 @@ class ColumnResizePluginView implements PluginView {
|
|
|
186
186
|
};
|
|
187
187
|
|
|
188
188
|
this.view.dispatch(
|
|
189
|
-
this.view.state.tr.setMeta(columnResizePluginKey, newState)
|
|
189
|
+
this.view.state.tr.setMeta(columnResizePluginKey, newState),
|
|
190
190
|
);
|
|
191
191
|
|
|
192
192
|
this.editor.sideMenu.freezeMenu();
|
|
@@ -228,7 +228,7 @@ class ColumnResizePluginView implements PluginView {
|
|
|
228
228
|
|
|
229
229
|
// Update the plugin state.
|
|
230
230
|
this.view.dispatch(
|
|
231
|
-
this.view.state.tr.setMeta(columnResizePluginKey, newState)
|
|
231
|
+
this.view.state.tr.setMeta(columnResizePluginKey, newState),
|
|
232
232
|
);
|
|
233
233
|
|
|
234
234
|
return;
|
|
@@ -269,14 +269,14 @@ class ColumnResizePluginView implements PluginView {
|
|
|
269
269
|
.setNodeAttribute(
|
|
270
270
|
pluginState.leftColumn.posBeforeNode,
|
|
271
271
|
"width",
|
|
272
|
-
newLeftColumnWidth
|
|
272
|
+
newLeftColumnWidth,
|
|
273
273
|
)
|
|
274
274
|
.setNodeAttribute(
|
|
275
275
|
pluginState.rightColumn.posBeforeNode,
|
|
276
276
|
"width",
|
|
277
|
-
newRightColumnWidth
|
|
277
|
+
newRightColumnWidth,
|
|
278
278
|
)
|
|
279
|
-
.setMeta("addToHistory", false)
|
|
279
|
+
.setMeta("addToHistory", false),
|
|
280
280
|
);
|
|
281
281
|
};
|
|
282
282
|
|
|
@@ -294,7 +294,7 @@ class ColumnResizePluginView implements PluginView {
|
|
|
294
294
|
// Revert plugin state to default or hover, depending on where the mouse
|
|
295
295
|
// cursor is.
|
|
296
296
|
this.view.dispatch(
|
|
297
|
-
this.view.state.tr.setMeta(columnResizePluginKey, newState)
|
|
297
|
+
this.view.state.tr.setMeta(columnResizePluginKey, newState),
|
|
298
298
|
);
|
|
299
299
|
|
|
300
300
|
this.editor.sideMenu.unfreezeMenu();
|
|
@@ -326,7 +326,7 @@ const createColumnResizePlugin = (editor: BlockNoteEditor<any, any, any>) =>
|
|
|
326
326
|
pluginState.leftColumn.node.nodeSize,
|
|
327
327
|
{
|
|
328
328
|
style: "box-shadow: 4px 0 0 #ccc; cursor: col-resize",
|
|
329
|
-
}
|
|
329
|
+
},
|
|
330
330
|
),
|
|
331
331
|
Decoration.node(
|
|
332
332
|
pluginState.rightColumn.posBeforeNode,
|
|
@@ -334,13 +334,13 @@ const createColumnResizePlugin = (editor: BlockNoteEditor<any, any, any>) =>
|
|
|
334
334
|
pluginState.rightColumn.node.nodeSize,
|
|
335
335
|
{
|
|
336
336
|
style: "cursor: col-resize",
|
|
337
|
-
}
|
|
337
|
+
},
|
|
338
338
|
),
|
|
339
339
|
]);
|
|
340
340
|
},
|
|
341
341
|
},
|
|
342
342
|
state: {
|
|
343
|
-
init: () => ({ type: "default" } as ColumnState
|
|
343
|
+
init: () => ({ type: "default" }) as ColumnState,
|
|
344
344
|
apply: (tr, oldPluginState) => {
|
|
345
345
|
const newPluginState = tr.getMeta(columnResizePluginKey) as
|
|
346
346
|
| ColumnState
|
|
@@ -353,7 +353,7 @@ const createColumnResizePlugin = (editor: BlockNoteEditor<any, any, any>) =>
|
|
|
353
353
|
});
|
|
354
354
|
|
|
355
355
|
export const createColumnResizeExtension = (
|
|
356
|
-
editor: BlockNoteEditor<any, any, any
|
|
356
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
357
357
|
) =>
|
|
358
358
|
Extension.create({
|
|
359
359
|
name: "columnResize",
|
|
@@ -37,7 +37,7 @@ interface DropCursorOptions {
|
|
|
37
37
|
export function multiColumnDropCursor(
|
|
38
38
|
options: DropCursorOptions & {
|
|
39
39
|
editor: BlockNoteEditor<any, any, any>;
|
|
40
|
-
}
|
|
40
|
+
},
|
|
41
41
|
): Plugin {
|
|
42
42
|
const editor = options.editor;
|
|
43
43
|
return new Plugin({
|
|
@@ -80,7 +80,7 @@ export function multiColumnDropCursor(
|
|
|
80
80
|
|
|
81
81
|
const draggedBlock = nodeToBlock(
|
|
82
82
|
slice.content.child(0),
|
|
83
|
-
editor.pmSchema
|
|
83
|
+
editor.pmSchema,
|
|
84
84
|
// TODO: cache?
|
|
85
85
|
);
|
|
86
86
|
|
|
@@ -93,7 +93,7 @@ export function multiColumnDropCursor(
|
|
|
93
93
|
|
|
94
94
|
const columnList = nodeToBlock<any, any, any>(
|
|
95
95
|
parentBlock,
|
|
96
|
-
editor.pmSchema
|
|
96
|
+
editor.pmSchema,
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
// In a `columnList`, we expect that the average width of each column
|
|
@@ -123,7 +123,7 @@ export function multiColumnDropCursor(
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
const index = columnList.children.findIndex(
|
|
126
|
-
(b) => b.id === blockInfo.bnBlock.node.attrs.id
|
|
126
|
+
(b) => b.id === blockInfo.bnBlock.node.attrs.id,
|
|
127
127
|
);
|
|
128
128
|
|
|
129
129
|
const newChildren = columnList.children
|
|
@@ -131,7 +131,7 @@ export function multiColumnDropCursor(
|
|
|
131
131
|
.map((column) => ({
|
|
132
132
|
...column,
|
|
133
133
|
children: column.children.filter(
|
|
134
|
-
(block) => block.id !== draggedBlock.id
|
|
134
|
+
(block) => block.id !== draggedBlock.id,
|
|
135
135
|
),
|
|
136
136
|
}))
|
|
137
137
|
// Remove empty columns (can happen when dragged block is removed).
|
|
@@ -175,7 +175,7 @@ export function multiColumnDropCursor(
|
|
|
175
175
|
};
|
|
176
176
|
}),
|
|
177
177
|
},
|
|
178
|
-
]
|
|
178
|
+
],
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -196,7 +196,10 @@ class DropCursorView {
|
|
|
196
196
|
timeout: ReturnType<typeof setTimeout> | undefined = undefined;
|
|
197
197
|
handlers: { name: string; handler: (event: Event) => void }[];
|
|
198
198
|
|
|
199
|
-
constructor(
|
|
199
|
+
constructor(
|
|
200
|
+
readonly editorView: EditorView,
|
|
201
|
+
options: DropCursorOptions,
|
|
202
|
+
) {
|
|
200
203
|
this.width = options.width ?? 1;
|
|
201
204
|
this.color = options.color === false ? undefined : options.color || "black";
|
|
202
205
|
this.class = options.class;
|
|
@@ -211,7 +214,7 @@ class DropCursorView {
|
|
|
211
214
|
// drop event captured in bubbling phase to make sure
|
|
212
215
|
// "cursorPos" is set to undefined before the "handleDrop" handler is called
|
|
213
216
|
// (otherwise an error could be thrown, see https://github.com/TypeCellOS/BlockNote/pull/1240)
|
|
214
|
-
name === "drop" ? true : undefined
|
|
217
|
+
name === "drop" ? true : undefined,
|
|
215
218
|
);
|
|
216
219
|
return { name, handler };
|
|
217
220
|
});
|
|
@@ -222,8 +225,8 @@ class DropCursorView {
|
|
|
222
225
|
this.editorView.dom.removeEventListener(
|
|
223
226
|
name,
|
|
224
227
|
handler,
|
|
225
|
-
name === "drop" ? true : undefined
|
|
226
|
-
)
|
|
228
|
+
name === "drop" ? true : undefined,
|
|
229
|
+
),
|
|
227
230
|
);
|
|
228
231
|
}
|
|
229
232
|
|
|
@@ -241,7 +244,7 @@ class DropCursorView {
|
|
|
241
244
|
setCursor(
|
|
242
245
|
cursorPos:
|
|
243
246
|
| { pos: number; position: "left" | "right" | "regular" }
|
|
244
|
-
| undefined
|
|
247
|
+
| undefined,
|
|
245
248
|
) {
|
|
246
249
|
if (
|
|
247
250
|
cursorPos === this.cursorPos ||
|
|
@@ -303,7 +306,7 @@ class DropCursorView {
|
|
|
303
306
|
} else {
|
|
304
307
|
// regular logic
|
|
305
308
|
const node = this.editorView.nodeDOM(
|
|
306
|
-
this.cursorPos.pos - (before ? before.nodeSize : 0)
|
|
309
|
+
this.cursorPos.pos - (before ? before.nodeSize : 0),
|
|
307
310
|
);
|
|
308
311
|
if (node) {
|
|
309
312
|
const nodeRect = (node as HTMLElement).getBoundingClientRect();
|
|
@@ -362,7 +365,7 @@ class DropCursorView {
|
|
|
362
365
|
this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
|
|
363
366
|
this.element.classList.toggle(
|
|
364
367
|
"prosemirror-dropcursor-vertical",
|
|
365
|
-
this.cursorPos.position !== "regular"
|
|
368
|
+
this.cursorPos.position !== "regular",
|
|
366
369
|
);
|
|
367
370
|
this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
|
|
368
371
|
let parentLeft, parentTop;
|
|
@@ -446,7 +449,7 @@ class DropCursorView {
|
|
|
446
449
|
const point = dropPoint(
|
|
447
450
|
this.editorView.state.doc,
|
|
448
451
|
target,
|
|
449
|
-
this.editorView.dragging.slice
|
|
452
|
+
this.editorView.dragging.slice,
|
|
450
453
|
);
|
|
451
454
|
|
|
452
455
|
if (point != null) {
|
|
@@ -482,7 +485,7 @@ class DropCursorView {
|
|
|
482
485
|
*/
|
|
483
486
|
function getTargetPosInfo(
|
|
484
487
|
state: EditorState,
|
|
485
|
-
eventPos: { pos: number; inside: number }
|
|
488
|
+
eventPos: { pos: number; inside: number },
|
|
486
489
|
) {
|
|
487
490
|
const blockPos = getNearestBlockPos(state.doc, eventPos.pos);
|
|
488
491
|
|
|
@@ -13,9 +13,9 @@ import { getMultiColumnDictionary } from "../../i18n/dictionary.js";
|
|
|
13
13
|
|
|
14
14
|
export function checkMultiColumnBlocksInSchema<
|
|
15
15
|
I extends InlineContentSchema,
|
|
16
|
-
S extends StyleSchema
|
|
16
|
+
S extends StyleSchema,
|
|
17
17
|
>(
|
|
18
|
-
editor: BlockNoteEditor<any, I, S
|
|
18
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
19
19
|
): editor is BlockNoteEditor<typeof multiColumnSchema.blockSchema, I, S> {
|
|
20
20
|
return (
|
|
21
21
|
"column" in editor.schema.blockSchema &&
|
|
@@ -30,7 +30,7 @@ export function checkMultiColumnBlocksInSchema<
|
|
|
30
30
|
export function getMultiColumnSlashMenuItems<
|
|
31
31
|
BSchema extends BlockSchema,
|
|
32
32
|
I extends InlineContentSchema,
|
|
33
|
-
S extends StyleSchema
|
|
33
|
+
S extends StyleSchema,
|
|
34
34
|
>(editor: BlockNoteEditor<BSchema, I, S>) {
|
|
35
35
|
const items: Omit<DefaultReactSuggestionItem, "key">[] = [];
|
|
36
36
|
|
|
@@ -97,7 +97,7 @@ export function getMultiColumnSlashMenuItems<
|
|
|
97
97
|
],
|
|
98
98
|
});
|
|
99
99
|
},
|
|
100
|
-
}
|
|
100
|
+
},
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
|
package/src/i18n/dictionary.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { BlockNoteEditor } from "@blocknote/core";
|
|
|
16
16
|
// }
|
|
17
17
|
|
|
18
18
|
export function getMultiColumnDictionary(
|
|
19
|
-
editor: BlockNoteEditor<any, any, any
|
|
19
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
20
20
|
) {
|
|
21
21
|
if (!(editor.dictionary as any).multi_column) {
|
|
22
22
|
throw new Error("Multi-column dictionary not found");
|
|
@@ -11,7 +11,7 @@ describe("Test insertBlocks", () => {
|
|
|
11
11
|
getEditor().insertBlocks(
|
|
12
12
|
[{ type: "columnList" }],
|
|
13
13
|
"paragraph-0",
|
|
14
|
-
"after"
|
|
14
|
+
"after",
|
|
15
15
|
);
|
|
16
16
|
}).toThrow();
|
|
17
17
|
});
|
|
@@ -31,7 +31,7 @@ describe("Test insertBlocks", () => {
|
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
33
|
"paragraph-0",
|
|
34
|
-
"after"
|
|
34
|
+
"after",
|
|
35
35
|
);
|
|
36
36
|
}).toThrow();
|
|
37
37
|
});
|
|
@@ -57,7 +57,7 @@ describe("Test insertBlocks", () => {
|
|
|
57
57
|
},
|
|
58
58
|
],
|
|
59
59
|
"paragraph-0",
|
|
60
|
-
"after"
|
|
60
|
+
"after",
|
|
61
61
|
);
|
|
62
62
|
}).toThrow();
|
|
63
63
|
});
|
|
@@ -90,7 +90,7 @@ describe("Test insertBlocks", () => {
|
|
|
90
90
|
},
|
|
91
91
|
],
|
|
92
92
|
"paragraph-0",
|
|
93
|
-
"after"
|
|
93
|
+
"after",
|
|
94
94
|
);
|
|
95
95
|
|
|
96
96
|
expect(getEditor().document).toMatchSnapshot();
|
|
@@ -110,7 +110,7 @@ describe("Test insertBlocks", () => {
|
|
|
110
110
|
},
|
|
111
111
|
],
|
|
112
112
|
"column-0",
|
|
113
|
-
"before"
|
|
113
|
+
"before",
|
|
114
114
|
);
|
|
115
115
|
|
|
116
116
|
expect(getEditor().document).toMatchSnapshot();
|
|
@@ -144,7 +144,7 @@ describe("Test insertBlocks", () => {
|
|
|
144
144
|
},
|
|
145
145
|
],
|
|
146
146
|
"nested-paragraph-0",
|
|
147
|
-
"after"
|
|
147
|
+
"after",
|
|
148
148
|
);
|
|
149
149
|
|
|
150
150
|
expect(getEditor().document).toMatchSnapshot();
|
|
@@ -167,7 +167,7 @@ describe("Test insertBlocks", () => {
|
|
|
167
167
|
},
|
|
168
168
|
],
|
|
169
169
|
"nested-paragraph-0",
|
|
170
|
-
"after"
|
|
170
|
+
"after",
|
|
171
171
|
);
|
|
172
172
|
}).toThrow();
|
|
173
173
|
});
|
|
@@ -184,7 +184,7 @@ describe("Test insertBlocks", () => {
|
|
|
184
184
|
},
|
|
185
185
|
],
|
|
186
186
|
"column-0",
|
|
187
|
-
"after"
|
|
187
|
+
"after",
|
|
188
188
|
);
|
|
189
189
|
}).toThrow();
|
|
190
190
|
});
|
|
@@ -198,7 +198,7 @@ describe("Test insertBlocks", () => {
|
|
|
198
198
|
},
|
|
199
199
|
],
|
|
200
200
|
"column-paragraph-0",
|
|
201
|
-
"after"
|
|
201
|
+
"after",
|
|
202
202
|
);
|
|
203
203
|
|
|
204
204
|
expect(getEditor().document).toMatchSnapshot();
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@blocknote/core";
|
|
18
18
|
|
|
19
19
|
function textShorthandToStyledText(
|
|
20
|
-
content: string | StyledText<any>[] = ""
|
|
20
|
+
content: string | StyledText<any>[] = "",
|
|
21
21
|
): StyledText<any>[] {
|
|
22
22
|
if (typeof content === "string") {
|
|
23
23
|
return [
|
|
@@ -36,7 +36,7 @@ function partialContentToInlineContent(
|
|
|
36
36
|
| PartialInlineContent<any, any>
|
|
37
37
|
| PartialTableCell<any, any>
|
|
38
38
|
| TableContent<any>
|
|
39
|
-
| undefined
|
|
39
|
+
| undefined,
|
|
40
40
|
):
|
|
41
41
|
| InlineContent<any, any>[]
|
|
42
42
|
| TableContent<any>
|
|
@@ -76,7 +76,7 @@ function partialContentToInlineContent(
|
|
|
76
76
|
rows: content.rows.map((row) => ({
|
|
77
77
|
...row,
|
|
78
78
|
cells: row.cells.map(
|
|
79
|
-
(cell) => partialContentToInlineContent(cell) as any
|
|
79
|
+
(cell) => partialContentToInlineContent(cell) as any,
|
|
80
80
|
),
|
|
81
81
|
})),
|
|
82
82
|
};
|
|
@@ -100,23 +100,23 @@ function partialContentToInlineContent(
|
|
|
100
100
|
export function partialBlocksToBlocksForTesting<
|
|
101
101
|
BSchema extends BlockSchema,
|
|
102
102
|
I extends InlineContentSchema,
|
|
103
|
-
S extends StyleSchema
|
|
103
|
+
S extends StyleSchema,
|
|
104
104
|
>(
|
|
105
105
|
schema: BlockNoteSchema<BSchema, I, S>,
|
|
106
|
-
partialBlocks: Array<PartialBlock<NoInfer<BSchema>, NoInfer<I>, NoInfer<S
|
|
106
|
+
partialBlocks: Array<PartialBlock<NoInfer<BSchema>, NoInfer<I>, NoInfer<S>>>,
|
|
107
107
|
): Array<Block<BSchema, I, S>> {
|
|
108
108
|
return partialBlocks.map((partialBlock) =>
|
|
109
|
-
partialBlockToBlockForTesting(schema.blockSchema, partialBlock)
|
|
109
|
+
partialBlockToBlockForTesting(schema.blockSchema, partialBlock),
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export function partialBlockToBlockForTesting<
|
|
114
114
|
BSchema extends BlockSchema,
|
|
115
115
|
I extends InlineContentSchema,
|
|
116
|
-
S extends StyleSchema
|
|
116
|
+
S extends StyleSchema,
|
|
117
117
|
>(
|
|
118
118
|
schema: BSchema,
|
|
119
|
-
partialBlock: PartialBlock<BSchema, I, S
|
|
119
|
+
partialBlock: PartialBlock<BSchema, I, S>,
|
|
120
120
|
): Block<BSchema, I, S> {
|
|
121
121
|
const contentType: "inline" | "table" | "none" =
|
|
122
122
|
schema[partialBlock.type!].content;
|
|
@@ -129,14 +129,14 @@ export function partialBlockToBlockForTesting<
|
|
|
129
129
|
contentType === "inline"
|
|
130
130
|
? []
|
|
131
131
|
: contentType === "table"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
? {
|
|
133
|
+
type: "tableContent",
|
|
134
|
+
columnWidths: undefined,
|
|
135
|
+
headerRows: undefined,
|
|
136
|
+
headerCols: undefined,
|
|
137
|
+
rows: [],
|
|
138
|
+
}
|
|
139
|
+
: (undefined as any),
|
|
140
140
|
children: [] as any,
|
|
141
141
|
...partialBlock,
|
|
142
142
|
};
|
|
@@ -149,7 +149,7 @@ export function partialBlockToBlockForTesting<
|
|
|
149
149
|
) {
|
|
150
150
|
(withDefaults.props as any)[propKey] = propValue.default;
|
|
151
151
|
}
|
|
152
|
-
}
|
|
152
|
+
},
|
|
153
153
|
);
|
|
154
154
|
|
|
155
155
|
if (contentType === "inline") {
|
|
@@ -21,12 +21,12 @@ import { multiColumnSchemaTestCases } from "./testCases.js";
|
|
|
21
21
|
async function convertToHTMLAndCompareSnapshots<
|
|
22
22
|
B extends BlockSchema,
|
|
23
23
|
I extends InlineContentSchema,
|
|
24
|
-
S extends StyleSchema
|
|
24
|
+
S extends StyleSchema,
|
|
25
25
|
>(
|
|
26
26
|
editor: BlockNoteEditor<B, I, S>,
|
|
27
27
|
blocks: PartialBlock<B, I, S>[],
|
|
28
28
|
snapshotDirectory: string,
|
|
29
|
-
snapshotName: string
|
|
29
|
+
snapshotName: string,
|
|
30
30
|
) {
|
|
31
31
|
addIdsToBlocks(blocks);
|
|
32
32
|
const serializer = createInternalHTMLSerializer(editor.pmSchema, editor);
|
|
@@ -93,7 +93,7 @@ describe("Test multi-column HTML conversion", () => {
|
|
|
93
93
|
editor,
|
|
94
94
|
document.blocks,
|
|
95
95
|
nameSplit[0],
|
|
96
|
-
nameSplit[1]
|
|
96
|
+
nameSplit[1],
|
|
97
97
|
);
|
|
98
98
|
});
|
|
99
99
|
}
|
|
@@ -22,7 +22,7 @@ function addIdsToBlock(block: PartialBlock<any, any, any>) {
|
|
|
22
22
|
|
|
23
23
|
function validateConversion(
|
|
24
24
|
block: PartialBlock<any, any, any>,
|
|
25
|
-
editor: BlockNoteEditor<any, any, any
|
|
25
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
26
26
|
) {
|
|
27
27
|
addIdsToBlock(block);
|
|
28
28
|
const node = blockToNode(block, editor.pmSchema);
|
|
@@ -33,7 +33,7 @@ function validateConversion(
|
|
|
33
33
|
|
|
34
34
|
const fullOriginalBlock = partialBlockToBlockForTesting(
|
|
35
35
|
editor.schema.blockSchema,
|
|
36
|
-
block
|
|
36
|
+
block,
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
expect(outputBlock).toStrictEqual(fullOriginalBlock);
|
|
@@ -330,7 +330,8 @@ export declare const testEditorSchema: BlockNoteSchema<import("@blocknote/core")
|
|
|
330
330
|
default: true;
|
|
331
331
|
};
|
|
332
332
|
previewWidth: {
|
|
333
|
-
default:
|
|
333
|
+
default: undefined;
|
|
334
|
+
type: "number";
|
|
334
335
|
};
|
|
335
336
|
};
|
|
336
337
|
content: "none";
|
|
@@ -360,7 +361,8 @@ export declare const testEditorSchema: BlockNoteSchema<import("@blocknote/core")
|
|
|
360
361
|
default: true;
|
|
361
362
|
};
|
|
362
363
|
previewWidth: {
|
|
363
|
-
default:
|
|
364
|
+
default: undefined;
|
|
365
|
+
type: "number";
|
|
364
366
|
};
|
|
365
367
|
};
|
|
366
368
|
content: "none";
|
|
@@ -392,7 +394,8 @@ export declare const testEditorSchema: BlockNoteSchema<import("@blocknote/core")
|
|
|
392
394
|
default: true;
|
|
393
395
|
};
|
|
394
396
|
previewWidth: {
|
|
395
|
-
default:
|
|
397
|
+
default: undefined;
|
|
398
|
+
type: "number";
|
|
396
399
|
};
|
|
397
400
|
};
|
|
398
401
|
content: "none";
|
|
@@ -422,7 +425,8 @@ export declare const testEditorSchema: BlockNoteSchema<import("@blocknote/core")
|
|
|
422
425
|
default: true;
|
|
423
426
|
};
|
|
424
427
|
previewWidth: {
|
|
425
|
-
default:
|
|
428
|
+
default: undefined;
|
|
429
|
+
type: "number";
|
|
426
430
|
};
|
|
427
431
|
};
|
|
428
432
|
content: "none";
|
|
@@ -884,7 +888,8 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("@blocknote
|
|
|
884
888
|
default: true;
|
|
885
889
|
};
|
|
886
890
|
previewWidth: {
|
|
887
|
-
default:
|
|
891
|
+
default: undefined;
|
|
892
|
+
type: "number";
|
|
888
893
|
};
|
|
889
894
|
};
|
|
890
895
|
content: "none";
|
|
@@ -914,7 +919,8 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("@blocknote
|
|
|
914
919
|
default: true;
|
|
915
920
|
};
|
|
916
921
|
previewWidth: {
|
|
917
|
-
default:
|
|
922
|
+
default: undefined;
|
|
923
|
+
type: "number";
|
|
918
924
|
};
|
|
919
925
|
};
|
|
920
926
|
content: "none";
|
|
@@ -946,7 +952,8 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("@blocknote
|
|
|
946
952
|
default: true;
|
|
947
953
|
};
|
|
948
954
|
previewWidth: {
|
|
949
|
-
default:
|
|
955
|
+
default: undefined;
|
|
956
|
+
type: "number";
|
|
950
957
|
};
|
|
951
958
|
};
|
|
952
959
|
content: "none";
|
|
@@ -976,7 +983,8 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("@blocknote
|
|
|
976
983
|
default: true;
|
|
977
984
|
};
|
|
978
985
|
previewWidth: {
|
|
979
|
-
default:
|
|
986
|
+
default: undefined;
|
|
987
|
+
type: "number";
|
|
980
988
|
};
|
|
981
989
|
};
|
|
982
990
|
content: "none";
|