@blocknote/xl-multi-column 0.19.0 → 0.19.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.js +243 -228
- package/dist/blocknote-xl-multi-column.js.map +1 -1
- package/dist/blocknote-xl-multi-column.umd.cjs +18 -18
- package/dist/blocknote-xl-multi-column.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +4 -4
- package/src/extensions/ColumnResize/ColumnResizeExtension.ts +5 -3
- package/src/extensions/DropCursor/MultiColumnDropCursorPlugin.ts +34 -12
- package/src/test/commands/__snapshots__/removeBlocks.test.ts.snap +226 -0
- package/src/test/commands/__snapshots__/replaceBlocks.test.ts.snap +175 -0
- package/src/test/commands/removeBlocks.test.ts +19 -0
- package/src/test/commands/replaceBlocks.test.ts +40 -0
- package/types/src/test/commands/removeBlocks.test.d.ts +1 -0
- package/types/src/test/commands/replaceBlocks.test.d.ts +1 -0
- package/types/src/test/setupTestEnv.d.ts +0 -12
package/dist/webpack-stats.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"builtAt":
|
|
1
|
+
{"builtAt":1731699614292,"assets":[{"name":"blocknote-xl-multi-column.umd.cjs","size":68962},{"name":"blocknote-xl-multi-column.umd.cjs.map","size":3631606}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-multi-column.umd.cjs"],"names":["index"]}],"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":8234,"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":11957,"chunks":["a1ee98a"]},{"name":"./commonjsHelpers.js","size":140,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/jsx-runtime.js?commonjs-module","size":31,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react-jsx-runtime.production.min.js?commonjs-exports","size":40,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/index.js?commonjs-module","size":26,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react.production.min.js?commonjs-exports","size":30,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react.production.min.js","size":7647,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react.development.js?commonjs-module","size":38,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react.development.js","size":92443,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/index.js","size":299,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react-jsx-runtime.production.min.js","size":1192,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react-jsx-runtime.development.js?commonjs-exports","size":37,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/cjs/react-jsx-runtime.development.js","size":43835,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/jsx-runtime.js","size":225,"chunks":["a1ee98a"]},{"name":"../../node_modules/react/index.js?commonjs-es-import","size":100,"chunks":["a1ee98a"]},{"name":"../../node_modules/react-icons/lib/iconContext.mjs","size":217,"chunks":["a1ee98a"]},{"name":"../../node_modules/react-icons/lib/iconBase.mjs","size":3929,"chunks":["a1ee98a"]},{"name":"../../node_modules/react-icons/tb/index.mjs","size":732,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx","size":2087,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://github.com/TypeCellOS/BlockNote",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "AGPL-3.0 OR PROPRIETARY",
|
|
6
|
-
"version": "0.19.
|
|
6
|
+
"version": "0.19.1",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
9
|
"types",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"clean": "rimraf dist && rimraf types"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@blocknote/core": "^0.19.
|
|
49
|
-
"@blocknote/react": "^0.19.
|
|
48
|
+
"@blocknote/core": "^0.19.1",
|
|
49
|
+
"@blocknote/react": "^0.19.1",
|
|
50
50
|
"@tiptap/core": "^2.7.1",
|
|
51
51
|
"prosemirror-model": "^1.23.0",
|
|
52
52
|
"prosemirror-state": "^1.4.3",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"access": "public",
|
|
77
77
|
"registry": "https://registry.npmjs.org/"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "8ba7d2ce11c674a6f5ed4cc5f81ad20f165ef46d"
|
|
80
80
|
}
|
|
@@ -296,9 +296,11 @@ class ColumnResizePluginView implements PluginView {
|
|
|
296
296
|
this.editor.sideMenu.unfreezeMenu();
|
|
297
297
|
};
|
|
298
298
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
destroy() {
|
|
300
|
+
this.view.dom.removeEventListener("mousedown", this.mouseDownHandler);
|
|
301
|
+
document.body.removeEventListener("mousemove", this.mouseMoveHandler);
|
|
302
|
+
document.body.removeEventListener("mouseup", this.mouseUpHandler);
|
|
303
|
+
}
|
|
302
304
|
}
|
|
303
305
|
|
|
304
306
|
const createColumnResizePlugin = (editor: BlockNoteEditor<any, any, any>) =>
|
|
@@ -2,7 +2,7 @@ import type { BlockNoteEditor } from "@blocknote/core";
|
|
|
2
2
|
import {
|
|
3
3
|
UniqueID,
|
|
4
4
|
getBlockInfo,
|
|
5
|
-
|
|
5
|
+
getNearestBlockPos,
|
|
6
6
|
nodeToBlock,
|
|
7
7
|
} from "@blocknote/core";
|
|
8
8
|
import { EditorState, Plugin } from "prosemirror-state";
|
|
@@ -130,17 +130,24 @@ export function multiColumnDropCursor(
|
|
|
130
130
|
(b) => b.id === blockInfo.bnBlock.node.attrs.id
|
|
131
131
|
);
|
|
132
132
|
|
|
133
|
-
const newChildren = columnList.children
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
const newChildren = columnList.children
|
|
134
|
+
// If the dragged block is in one of the columns, remove it.
|
|
135
|
+
.map((column) => ({
|
|
136
|
+
...column,
|
|
137
|
+
children: column.children.filter(
|
|
138
|
+
(block) => block.id !== draggedBlock.id
|
|
139
|
+
),
|
|
140
|
+
}))
|
|
141
|
+
// Remove empty columns (can happen when dragged block is removed).
|
|
142
|
+
.filter((column) => column.children.length > 0)
|
|
143
|
+
// Insert the dragged block in the correct position.
|
|
144
|
+
.toSpliced(position === "left" ? index : index + 1, 0, {
|
|
137
145
|
type: "column",
|
|
138
146
|
children: [draggedBlock],
|
|
139
147
|
props: {},
|
|
140
148
|
content: undefined,
|
|
141
149
|
id: UniqueID.options.generateID(),
|
|
142
|
-
}
|
|
143
|
-
);
|
|
150
|
+
});
|
|
144
151
|
|
|
145
152
|
editor.removeBlocks([draggedBlock]);
|
|
146
153
|
|
|
@@ -201,14 +208,25 @@ class DropCursorView {
|
|
|
201
208
|
const handler = (e: Event) => {
|
|
202
209
|
(this as any)[name](e);
|
|
203
210
|
};
|
|
204
|
-
editorView.dom.addEventListener(
|
|
211
|
+
editorView.dom.addEventListener(
|
|
212
|
+
name,
|
|
213
|
+
handler,
|
|
214
|
+
// drop event captured in bubbling phase to make sure
|
|
215
|
+
// "cursorPos" is set to undefined before the "handleDrop" handler is called
|
|
216
|
+
// (otherwise an error could be thrown, see https://github.com/TypeCellOS/BlockNote/pull/1240)
|
|
217
|
+
name === "drop" ? true : undefined
|
|
218
|
+
);
|
|
205
219
|
return { name, handler };
|
|
206
220
|
});
|
|
207
221
|
}
|
|
208
222
|
|
|
209
223
|
destroy() {
|
|
210
224
|
this.handlers.forEach(({ name, handler }) =>
|
|
211
|
-
this.editorView.dom.removeEventListener(
|
|
225
|
+
this.editorView.dom.removeEventListener(
|
|
226
|
+
name,
|
|
227
|
+
handler,
|
|
228
|
+
name === "drop" ? true : undefined
|
|
229
|
+
)
|
|
212
230
|
);
|
|
213
231
|
}
|
|
214
232
|
|
|
@@ -267,6 +285,10 @@ class DropCursorView {
|
|
|
267
285
|
) {
|
|
268
286
|
const block = this.editorView.nodeDOM(this.cursorPos.pos);
|
|
269
287
|
|
|
288
|
+
if (!block) {
|
|
289
|
+
throw new Error("nodeDOM returned null in updateOverlay");
|
|
290
|
+
}
|
|
291
|
+
|
|
270
292
|
const blockRect = (block as HTMLElement).getBoundingClientRect();
|
|
271
293
|
const halfWidth = (this.width / 2) * scaleY;
|
|
272
294
|
const left =
|
|
@@ -434,7 +456,7 @@ class DropCursorView {
|
|
|
434
456
|
target = point;
|
|
435
457
|
}
|
|
436
458
|
}
|
|
437
|
-
|
|
459
|
+
|
|
438
460
|
this.setCursor({ pos: target, position });
|
|
439
461
|
this.scheduleRemoval(5000);
|
|
440
462
|
}
|
|
@@ -445,7 +467,7 @@ class DropCursorView {
|
|
|
445
467
|
}
|
|
446
468
|
|
|
447
469
|
drop() {
|
|
448
|
-
this.
|
|
470
|
+
this.setCursor(undefined);
|
|
449
471
|
}
|
|
450
472
|
|
|
451
473
|
dragleave(event: DragEvent) {
|
|
@@ -465,7 +487,7 @@ function getTargetPosInfo(
|
|
|
465
487
|
state: EditorState,
|
|
466
488
|
eventPos: { pos: number; inside: number }
|
|
467
489
|
) {
|
|
468
|
-
const blockPos =
|
|
490
|
+
const blockPos = getNearestBlockPos(state.doc, eventPos.pos);
|
|
469
491
|
|
|
470
492
|
// if we're at a block that's in a column, we want to compare the mouse position to the column, not the block inside it
|
|
471
493
|
// why? because we want to insert a new column in the columnList, instead of a new columnList inside of the column
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Test removeBlocks > Remove all blocks in column 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"children": [
|
|
7
|
+
{
|
|
8
|
+
"children": [],
|
|
9
|
+
"content": [
|
|
10
|
+
{
|
|
11
|
+
"styles": {},
|
|
12
|
+
"text": "Nested Paragraph 0",
|
|
13
|
+
"type": "text",
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
"id": "nested-paragraph-0",
|
|
17
|
+
"props": {
|
|
18
|
+
"backgroundColor": "default",
|
|
19
|
+
"textAlignment": "left",
|
|
20
|
+
"textColor": "default",
|
|
21
|
+
},
|
|
22
|
+
"type": "paragraph",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
"content": [
|
|
26
|
+
{
|
|
27
|
+
"styles": {},
|
|
28
|
+
"text": "Paragraph 0",
|
|
29
|
+
"type": "text",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
"id": "paragraph-0",
|
|
33
|
+
"props": {
|
|
34
|
+
"backgroundColor": "default",
|
|
35
|
+
"textAlignment": "left",
|
|
36
|
+
"textColor": "default",
|
|
37
|
+
},
|
|
38
|
+
"type": "paragraph",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"children": [
|
|
42
|
+
{
|
|
43
|
+
"children": [
|
|
44
|
+
{
|
|
45
|
+
"children": [],
|
|
46
|
+
"content": [],
|
|
47
|
+
"id": "0",
|
|
48
|
+
"props": {
|
|
49
|
+
"backgroundColor": "default",
|
|
50
|
+
"textAlignment": "left",
|
|
51
|
+
"textColor": "default",
|
|
52
|
+
},
|
|
53
|
+
"type": "paragraph",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
"content": undefined,
|
|
57
|
+
"id": "column-0",
|
|
58
|
+
"props": {
|
|
59
|
+
"width": 1,
|
|
60
|
+
},
|
|
61
|
+
"type": "column",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"children": [
|
|
65
|
+
{
|
|
66
|
+
"children": [],
|
|
67
|
+
"content": [
|
|
68
|
+
{
|
|
69
|
+
"styles": {},
|
|
70
|
+
"text": "Column Paragraph 2",
|
|
71
|
+
"type": "text",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
"id": "column-paragraph-2",
|
|
75
|
+
"props": {
|
|
76
|
+
"backgroundColor": "default",
|
|
77
|
+
"textAlignment": "left",
|
|
78
|
+
"textColor": "default",
|
|
79
|
+
},
|
|
80
|
+
"type": "paragraph",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"children": [],
|
|
84
|
+
"content": [
|
|
85
|
+
{
|
|
86
|
+
"styles": {},
|
|
87
|
+
"text": "Column Paragraph 3",
|
|
88
|
+
"type": "text",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
"id": "column-paragraph-3",
|
|
92
|
+
"props": {
|
|
93
|
+
"backgroundColor": "default",
|
|
94
|
+
"textAlignment": "left",
|
|
95
|
+
"textColor": "default",
|
|
96
|
+
},
|
|
97
|
+
"type": "paragraph",
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
"content": undefined,
|
|
101
|
+
"id": "column-1",
|
|
102
|
+
"props": {
|
|
103
|
+
"width": 1,
|
|
104
|
+
},
|
|
105
|
+
"type": "column",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
"content": undefined,
|
|
109
|
+
"id": "column-list-0",
|
|
110
|
+
"props": {},
|
|
111
|
+
"type": "columnList",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"children": [],
|
|
115
|
+
"content": [],
|
|
116
|
+
"id": "trailing-paragraph",
|
|
117
|
+
"props": {
|
|
118
|
+
"backgroundColor": "default",
|
|
119
|
+
"textAlignment": "left",
|
|
120
|
+
"textColor": "default",
|
|
121
|
+
},
|
|
122
|
+
"type": "paragraph",
|
|
123
|
+
},
|
|
124
|
+
]
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
exports[`Test removeBlocks > Remove all columns in columnList 1`] = `
|
|
128
|
+
[
|
|
129
|
+
{
|
|
130
|
+
"children": [
|
|
131
|
+
{
|
|
132
|
+
"children": [],
|
|
133
|
+
"content": [
|
|
134
|
+
{
|
|
135
|
+
"styles": {},
|
|
136
|
+
"text": "Nested Paragraph 0",
|
|
137
|
+
"type": "text",
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
"id": "nested-paragraph-0",
|
|
141
|
+
"props": {
|
|
142
|
+
"backgroundColor": "default",
|
|
143
|
+
"textAlignment": "left",
|
|
144
|
+
"textColor": "default",
|
|
145
|
+
},
|
|
146
|
+
"type": "paragraph",
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
"content": [
|
|
150
|
+
{
|
|
151
|
+
"styles": {},
|
|
152
|
+
"text": "Paragraph 0",
|
|
153
|
+
"type": "text",
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
"id": "paragraph-0",
|
|
157
|
+
"props": {
|
|
158
|
+
"backgroundColor": "default",
|
|
159
|
+
"textAlignment": "left",
|
|
160
|
+
"textColor": "default",
|
|
161
|
+
},
|
|
162
|
+
"type": "paragraph",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"children": [
|
|
166
|
+
{
|
|
167
|
+
"children": [
|
|
168
|
+
{
|
|
169
|
+
"children": [],
|
|
170
|
+
"content": [],
|
|
171
|
+
"id": "1",
|
|
172
|
+
"props": {
|
|
173
|
+
"backgroundColor": "default",
|
|
174
|
+
"textAlignment": "left",
|
|
175
|
+
"textColor": "default",
|
|
176
|
+
},
|
|
177
|
+
"type": "paragraph",
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
"content": undefined,
|
|
181
|
+
"id": "0",
|
|
182
|
+
"props": {
|
|
183
|
+
"width": 1,
|
|
184
|
+
},
|
|
185
|
+
"type": "column",
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"children": [
|
|
189
|
+
{
|
|
190
|
+
"children": [],
|
|
191
|
+
"content": [],
|
|
192
|
+
"id": "3",
|
|
193
|
+
"props": {
|
|
194
|
+
"backgroundColor": "default",
|
|
195
|
+
"textAlignment": "left",
|
|
196
|
+
"textColor": "default",
|
|
197
|
+
},
|
|
198
|
+
"type": "paragraph",
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
"content": undefined,
|
|
202
|
+
"id": "2",
|
|
203
|
+
"props": {
|
|
204
|
+
"width": 1,
|
|
205
|
+
},
|
|
206
|
+
"type": "column",
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
"content": undefined,
|
|
210
|
+
"id": "column-list-0",
|
|
211
|
+
"props": {},
|
|
212
|
+
"type": "columnList",
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"children": [],
|
|
216
|
+
"content": [],
|
|
217
|
+
"id": "trailing-paragraph",
|
|
218
|
+
"props": {
|
|
219
|
+
"backgroundColor": "default",
|
|
220
|
+
"textAlignment": "left",
|
|
221
|
+
"textColor": "default",
|
|
222
|
+
},
|
|
223
|
+
"type": "paragraph",
|
|
224
|
+
},
|
|
225
|
+
]
|
|
226
|
+
`;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Test replaceBlocks > Replace paragraph with column list above column list empty column list 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"children": [
|
|
7
|
+
{
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"children": [],
|
|
11
|
+
"content": [
|
|
12
|
+
{
|
|
13
|
+
"styles": {},
|
|
14
|
+
"text": "Inserted Column Paragraph",
|
|
15
|
+
"type": "text",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
"id": "2",
|
|
19
|
+
"props": {
|
|
20
|
+
"backgroundColor": "default",
|
|
21
|
+
"textAlignment": "left",
|
|
22
|
+
"textColor": "default",
|
|
23
|
+
},
|
|
24
|
+
"type": "paragraph",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
"content": undefined,
|
|
28
|
+
"id": "1",
|
|
29
|
+
"props": {
|
|
30
|
+
"width": 1,
|
|
31
|
+
},
|
|
32
|
+
"type": "column",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"children": [
|
|
36
|
+
{
|
|
37
|
+
"children": [],
|
|
38
|
+
"content": [
|
|
39
|
+
{
|
|
40
|
+
"styles": {},
|
|
41
|
+
"text": "Inserted Column Paragraph",
|
|
42
|
+
"type": "text",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
"id": "4",
|
|
46
|
+
"props": {
|
|
47
|
+
"backgroundColor": "default",
|
|
48
|
+
"textAlignment": "left",
|
|
49
|
+
"textColor": "default",
|
|
50
|
+
},
|
|
51
|
+
"type": "paragraph",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
"content": undefined,
|
|
55
|
+
"id": "3",
|
|
56
|
+
"props": {
|
|
57
|
+
"width": 1,
|
|
58
|
+
},
|
|
59
|
+
"type": "column",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
"content": undefined,
|
|
63
|
+
"id": "0",
|
|
64
|
+
"props": {},
|
|
65
|
+
"type": "columnList",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"children": [
|
|
69
|
+
{
|
|
70
|
+
"children": [
|
|
71
|
+
{
|
|
72
|
+
"children": [],
|
|
73
|
+
"content": [
|
|
74
|
+
{
|
|
75
|
+
"styles": {},
|
|
76
|
+
"text": "Column Paragraph 0",
|
|
77
|
+
"type": "text",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
"id": "column-paragraph-0",
|
|
81
|
+
"props": {
|
|
82
|
+
"backgroundColor": "default",
|
|
83
|
+
"textAlignment": "left",
|
|
84
|
+
"textColor": "default",
|
|
85
|
+
},
|
|
86
|
+
"type": "paragraph",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"children": [],
|
|
90
|
+
"content": [
|
|
91
|
+
{
|
|
92
|
+
"styles": {},
|
|
93
|
+
"text": "Column Paragraph 1",
|
|
94
|
+
"type": "text",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
"id": "column-paragraph-1",
|
|
98
|
+
"props": {
|
|
99
|
+
"backgroundColor": "default",
|
|
100
|
+
"textAlignment": "left",
|
|
101
|
+
"textColor": "default",
|
|
102
|
+
},
|
|
103
|
+
"type": "paragraph",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
"content": undefined,
|
|
107
|
+
"id": "column-0",
|
|
108
|
+
"props": {
|
|
109
|
+
"width": 1,
|
|
110
|
+
},
|
|
111
|
+
"type": "column",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"children": [
|
|
115
|
+
{
|
|
116
|
+
"children": [],
|
|
117
|
+
"content": [
|
|
118
|
+
{
|
|
119
|
+
"styles": {},
|
|
120
|
+
"text": "Column Paragraph 2",
|
|
121
|
+
"type": "text",
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
"id": "column-paragraph-2",
|
|
125
|
+
"props": {
|
|
126
|
+
"backgroundColor": "default",
|
|
127
|
+
"textAlignment": "left",
|
|
128
|
+
"textColor": "default",
|
|
129
|
+
},
|
|
130
|
+
"type": "paragraph",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"children": [],
|
|
134
|
+
"content": [
|
|
135
|
+
{
|
|
136
|
+
"styles": {},
|
|
137
|
+
"text": "Column Paragraph 3",
|
|
138
|
+
"type": "text",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
"id": "column-paragraph-3",
|
|
142
|
+
"props": {
|
|
143
|
+
"backgroundColor": "default",
|
|
144
|
+
"textAlignment": "left",
|
|
145
|
+
"textColor": "default",
|
|
146
|
+
},
|
|
147
|
+
"type": "paragraph",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
"content": undefined,
|
|
151
|
+
"id": "column-1",
|
|
152
|
+
"props": {
|
|
153
|
+
"width": 1,
|
|
154
|
+
},
|
|
155
|
+
"type": "column",
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
"content": undefined,
|
|
159
|
+
"id": "column-list-0",
|
|
160
|
+
"props": {},
|
|
161
|
+
"type": "columnList",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"children": [],
|
|
165
|
+
"content": [],
|
|
166
|
+
"id": "trailing-paragraph",
|
|
167
|
+
"props": {
|
|
168
|
+
"backgroundColor": "default",
|
|
169
|
+
"textAlignment": "left",
|
|
170
|
+
"textColor": "default",
|
|
171
|
+
},
|
|
172
|
+
"type": "paragraph",
|
|
173
|
+
},
|
|
174
|
+
]
|
|
175
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { setupTestEnv } from "../setupTestEnv.js";
|
|
4
|
+
|
|
5
|
+
const getEditor = setupTestEnv();
|
|
6
|
+
|
|
7
|
+
describe("Test removeBlocks", () => {
|
|
8
|
+
it("Remove all blocks in column", () => {
|
|
9
|
+
getEditor().removeBlocks(["column-paragraph-0", "column-paragraph-1"]);
|
|
10
|
+
|
|
11
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("Remove all columns in columnList", () => {
|
|
15
|
+
getEditor().removeBlocks(["column-0", "column-1"]);
|
|
16
|
+
|
|
17
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { setupTestEnv } from "../setupTestEnv.js";
|
|
4
|
+
|
|
5
|
+
const getEditor = setupTestEnv();
|
|
6
|
+
|
|
7
|
+
describe("Test replaceBlocks", () => {
|
|
8
|
+
it("Replace paragraph with column list above column list empty column list", () => {
|
|
9
|
+
getEditor().replaceBlocks(
|
|
10
|
+
["paragraph-0"],
|
|
11
|
+
[
|
|
12
|
+
{
|
|
13
|
+
type: "columnList",
|
|
14
|
+
children: [
|
|
15
|
+
{
|
|
16
|
+
type: "column",
|
|
17
|
+
children: [
|
|
18
|
+
{
|
|
19
|
+
type: "paragraph",
|
|
20
|
+
content: "Inserted Column Paragraph",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "column",
|
|
26
|
+
children: [
|
|
27
|
+
{
|
|
28
|
+
type: "paragraph",
|
|
29
|
+
content: "Inserted Column Paragraph",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -211,9 +211,6 @@ export declare const testEditorSchema: BlockNoteSchema<import("@blocknote/core")
|
|
|
211
211
|
type: "table";
|
|
212
212
|
content: "table";
|
|
213
213
|
propSchema: {
|
|
214
|
-
backgroundColor: {
|
|
215
|
-
default: "default";
|
|
216
|
-
};
|
|
217
214
|
textColor: {
|
|
218
215
|
default: "default";
|
|
219
216
|
};
|
|
@@ -223,9 +220,6 @@ export declare const testEditorSchema: BlockNoteSchema<import("@blocknote/core")
|
|
|
223
220
|
type: "table";
|
|
224
221
|
content: "table";
|
|
225
222
|
propSchema: {
|
|
226
|
-
backgroundColor: {
|
|
227
|
-
default: "default";
|
|
228
|
-
};
|
|
229
223
|
textColor: {
|
|
230
224
|
default: "default";
|
|
231
225
|
};
|
|
@@ -731,9 +725,6 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("@blocknote
|
|
|
731
725
|
type: "table";
|
|
732
726
|
content: "table";
|
|
733
727
|
propSchema: {
|
|
734
|
-
backgroundColor: {
|
|
735
|
-
default: "default";
|
|
736
|
-
};
|
|
737
728
|
textColor: {
|
|
738
729
|
default: "default";
|
|
739
730
|
};
|
|
@@ -743,9 +734,6 @@ export declare function setupTestEnv(): () => BlockNoteEditor<import("@blocknote
|
|
|
743
734
|
type: "table";
|
|
744
735
|
content: "table";
|
|
745
736
|
propSchema: {
|
|
746
|
-
backgroundColor: {
|
|
747
|
-
default: "default";
|
|
748
|
-
};
|
|
749
737
|
textColor: {
|
|
750
738
|
default: "default";
|
|
751
739
|
};
|