@blocknote/xl-multi-column 0.47.2 → 0.48.0
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 +2 -2
- package/dist/blocknote-xl-multi-column.cjs.map +1 -1
- package/dist/blocknote-xl-multi-column.js +650 -842
- package/dist/blocknote-xl-multi-column.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +6 -6
- package/src/test/commands/__snapshots__/backspace.test.ts.snap +696 -0
- package/src/test/commands/backspace.test.ts +202 -0
- package/types/src/test/commands/backspace.test.d.ts +1 -0
|
@@ -1,848 +1,656 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
e.getBlock(i.id) && e.removeBlocks([i]), e.updateBlock(a, {
|
|
348
|
-
children: b
|
|
349
|
-
});
|
|
350
|
-
} else {
|
|
351
|
-
const r = y(s.bnBlock.node, e.pmSchema);
|
|
352
|
-
if (r.id === i.id)
|
|
353
|
-
return !0;
|
|
354
|
-
const a = l.position === "left" ? [i, r] : [r, i];
|
|
355
|
-
e.getBlock(i.id) && e.removeBlocks([i]), e.replaceBlocks(
|
|
356
|
-
[r],
|
|
357
|
-
[
|
|
358
|
-
{
|
|
359
|
-
type: "columnList",
|
|
360
|
-
children: a.map((c) => ({
|
|
361
|
-
type: "column",
|
|
362
|
-
children: [c]
|
|
363
|
-
}))
|
|
364
|
-
}
|
|
365
|
-
]
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
return !0;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
const he = X(
|
|
374
|
-
({ editor: e }) => ({
|
|
375
|
-
key: "multiColumnDropHandler",
|
|
376
|
-
prosemirrorPlugins: [me(e)]
|
|
377
|
-
})
|
|
378
|
-
), f = new V("ColumnResizePlugin");
|
|
379
|
-
class pe {
|
|
380
|
-
constructor(t, o) {
|
|
381
|
-
m(this, "editor");
|
|
382
|
-
m(this, "view");
|
|
383
|
-
m(this, "RESIZE_MARGIN_WIDTH_PX", 20);
|
|
384
|
-
m(this, "COLUMN_MIN_WIDTH_PERCENT", 0.5);
|
|
385
|
-
m(this, "getColumnHoverOrDefaultState", (t) => {
|
|
386
|
-
if (!this.editor.isEditable)
|
|
387
|
-
return { type: "default" };
|
|
388
|
-
const o = t.target;
|
|
389
|
-
if (!this.view.dom.contains(o))
|
|
390
|
-
return { type: "default" };
|
|
391
|
-
const n = o.closest(
|
|
392
|
-
".bn-block-column"
|
|
393
|
-
);
|
|
394
|
-
if (!n)
|
|
395
|
-
return { type: "default" };
|
|
396
|
-
const u = t.clientX, l = n.getBoundingClientRect(), s = u < l.left + this.RESIZE_MARGIN_WIDTH_PX ? "left" : u > l.right - this.RESIZE_MARGIN_WIDTH_PX ? "right" : "none", i = s === "left" ? n.previousElementSibling : s === "right" ? n.nextElementSibling : void 0;
|
|
397
|
-
if (!i)
|
|
398
|
-
return { type: "default" };
|
|
399
|
-
const r = s === "left" ? i : n, a = s === "left" ? n : i, c = r.getAttribute("data-id"), h = a.getAttribute("data-id"), p = k(c, this.view.state.doc), b = k(
|
|
400
|
-
h,
|
|
401
|
-
this.view.state.doc
|
|
402
|
-
);
|
|
403
|
-
if (!p || !b || !p.posBeforeNode)
|
|
404
|
-
throw new Error("Column not found");
|
|
405
|
-
return {
|
|
406
|
-
type: "hover",
|
|
407
|
-
leftColumn: {
|
|
408
|
-
element: r,
|
|
409
|
-
id: c,
|
|
410
|
-
...p
|
|
411
|
-
},
|
|
412
|
-
rightColumn: {
|
|
413
|
-
element: a,
|
|
414
|
-
id: h,
|
|
415
|
-
...b
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
});
|
|
419
|
-
// When the user mouses down near the boundary between two columns, we
|
|
420
|
-
// want to set the plugin state to resize, so the columns can be resized
|
|
421
|
-
// by moving the mouse.
|
|
422
|
-
m(this, "mouseDownHandler", (t) => {
|
|
423
|
-
var r;
|
|
424
|
-
let o = this.getColumnHoverOrDefaultState(t);
|
|
425
|
-
if (o.type === "default")
|
|
426
|
-
return;
|
|
427
|
-
t.preventDefault();
|
|
428
|
-
const n = t.clientX, u = o.leftColumn.element.getBoundingClientRect().width, l = o.rightColumn.element.getBoundingClientRect().width, s = o.leftColumn.node.attrs.width, i = o.rightColumn.node.attrs.width;
|
|
429
|
-
o = {
|
|
430
|
-
type: "resize",
|
|
431
|
-
startPos: n,
|
|
432
|
-
leftColumn: {
|
|
433
|
-
...o.leftColumn,
|
|
434
|
-
widthPx: u,
|
|
435
|
-
widthPercent: s
|
|
436
|
-
},
|
|
437
|
-
rightColumn: {
|
|
438
|
-
...o.rightColumn,
|
|
439
|
-
widthPx: l,
|
|
440
|
-
widthPercent: i
|
|
441
|
-
}
|
|
442
|
-
}, this.view.dispatch(
|
|
443
|
-
this.view.state.tr.setMeta(f, o)
|
|
444
|
-
), (r = this.editor.getExtension(_)) == null || r.freezeMenu();
|
|
445
|
-
});
|
|
446
|
-
// If the plugin isn't in a resize state, we want to update it to either a
|
|
447
|
-
// hover state if the mouse is near the boundary between two columns, or
|
|
448
|
-
// default otherwise. If the plugin is in a resize state, we want to
|
|
449
|
-
// update the column widths based on the horizontal mouse movement.
|
|
450
|
-
m(this, "mouseMoveHandler", (t) => {
|
|
451
|
-
var r, a;
|
|
452
|
-
const o = f.getState(this.view.state);
|
|
453
|
-
if (!o)
|
|
454
|
-
return;
|
|
455
|
-
if (o.type !== "resize") {
|
|
456
|
-
const c = this.getColumnHoverOrDefaultState(t), h = o.type === "default" && c.type === "default", p = o.type !== "default" && c.type !== "default" && o.leftColumn.id === c.leftColumn.id && o.rightColumn.id === c.rightColumn.id;
|
|
457
|
-
if (h || p || c.type === "hover" && ((a = (r = this.editor.getExtension(_)) == null ? void 0 : r.store.state) != null && a.show))
|
|
458
|
-
return;
|
|
459
|
-
this.view.dispatch(
|
|
460
|
-
this.view.state.tr.setMeta(f, c)
|
|
461
|
-
);
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
const u = (t.clientX - o.startPos) * o.leftColumn.widthPercent, l = (o.leftColumn.widthPx + u) / o.leftColumn.widthPx - 1;
|
|
465
|
-
let s = o.leftColumn.widthPercent + l, i = o.rightColumn.widthPercent - l;
|
|
466
|
-
s < this.COLUMN_MIN_WIDTH_PERCENT ? (i -= this.COLUMN_MIN_WIDTH_PERCENT - s, s = this.COLUMN_MIN_WIDTH_PERCENT) : i < this.COLUMN_MIN_WIDTH_PERCENT && (s -= this.COLUMN_MIN_WIDTH_PERCENT - i, i = this.COLUMN_MIN_WIDTH_PERCENT), this.view.dispatch(
|
|
467
|
-
this.view.state.tr.setNodeAttribute(
|
|
468
|
-
o.leftColumn.posBeforeNode,
|
|
469
|
-
"width",
|
|
470
|
-
s
|
|
471
|
-
).setNodeAttribute(
|
|
472
|
-
o.rightColumn.posBeforeNode,
|
|
473
|
-
"width",
|
|
474
|
-
i
|
|
475
|
-
).setMeta("addToHistory", !1)
|
|
476
|
-
);
|
|
477
|
-
});
|
|
478
|
-
// If the plugin is in a resize state, we want to revert it to a default
|
|
479
|
-
// or hover, depending on where the mouse cursor is, when the user
|
|
480
|
-
// releases the mouse button.
|
|
481
|
-
m(this, "mouseUpHandler", (t) => {
|
|
482
|
-
var u;
|
|
483
|
-
const o = f.getState(this.view.state);
|
|
484
|
-
if (!o || o.type !== "resize")
|
|
485
|
-
return;
|
|
486
|
-
const n = this.getColumnHoverOrDefaultState(t);
|
|
487
|
-
this.view.dispatch(
|
|
488
|
-
this.view.state.tr.setMeta(f, n)
|
|
489
|
-
), (u = this.editor.getExtension(_)) == null || u.unfreezeMenu();
|
|
490
|
-
});
|
|
491
|
-
this.editor = t, this.view = o, this.view.dom.addEventListener("mousedown", this.mouseDownHandler), document.body.addEventListener("mousemove", this.mouseMoveHandler), document.body.addEventListener("mouseup", this.mouseUpHandler);
|
|
492
|
-
}
|
|
493
|
-
destroy() {
|
|
494
|
-
this.view.dom.removeEventListener("mousedown", this.mouseDownHandler), document.body.removeEventListener("mousemove", this.mouseMoveHandler), document.body.removeEventListener("mouseup", this.mouseUpHandler);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
const fe = (e) => new I({
|
|
498
|
-
key: f,
|
|
499
|
-
props: {
|
|
500
|
-
// This adds a border between the columns when the user is
|
|
501
|
-
// resizing them or when the cursor is near their boundary.
|
|
502
|
-
decorations: (t) => {
|
|
503
|
-
const o = f.getState(t);
|
|
504
|
-
return !o || o.type === "default" ? E.empty : E.create(t.doc, [
|
|
505
|
-
x.node(
|
|
506
|
-
o.leftColumn.posBeforeNode,
|
|
507
|
-
o.leftColumn.posBeforeNode + o.leftColumn.node.nodeSize,
|
|
508
|
-
{
|
|
509
|
-
style: "box-shadow: 4px 0 0 #ccc; cursor: col-resize"
|
|
510
|
-
}
|
|
511
|
-
),
|
|
512
|
-
x.node(
|
|
513
|
-
o.rightColumn.posBeforeNode,
|
|
514
|
-
o.rightColumn.posBeforeNode + o.rightColumn.node.nodeSize,
|
|
515
|
-
{
|
|
516
|
-
style: "cursor: col-resize"
|
|
517
|
-
}
|
|
518
|
-
)
|
|
519
|
-
]);
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
state: {
|
|
523
|
-
init: () => ({ type: "default" }),
|
|
524
|
-
apply: (t, o) => {
|
|
525
|
-
const n = t.getMeta(f);
|
|
526
|
-
return n === void 0 ? o : n;
|
|
527
|
-
}
|
|
528
|
-
},
|
|
529
|
-
view: (t) => new pe(e, t)
|
|
530
|
-
}), ge = (e) => Y.create({
|
|
531
|
-
name: "columnResize",
|
|
532
|
-
addProseMirrorPlugins() {
|
|
533
|
-
return [fe(e)];
|
|
534
|
-
}
|
|
535
|
-
}), be = L.create({
|
|
536
|
-
name: "column",
|
|
537
|
-
group: "bnBlock childContainer",
|
|
538
|
-
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
539
|
-
content: "blockContainer+",
|
|
540
|
-
priority: 40,
|
|
541
|
-
defining: !0,
|
|
542
|
-
marks: "deletion insertion modification",
|
|
543
|
-
addAttributes() {
|
|
544
|
-
return {
|
|
545
|
-
width: {
|
|
546
|
-
// Why does each column have a default width of 1, i.e. 100%? Because
|
|
547
|
-
// when creating a new column, we want to make sure that existing
|
|
548
|
-
// column widths are preserved, while the new one also has a sensible
|
|
549
|
-
// width. If we'd set it so all column widths must add up to 100%
|
|
550
|
-
// instead, then each time a new column is created, we'd have to assign
|
|
551
|
-
// it a width depending on the total number of columns and also adjust
|
|
552
|
-
// the widths of the other columns. The same can be said for using px
|
|
553
|
-
// instead of percent widths and making them add to the editor width. So
|
|
554
|
-
// using this method is both simpler and computationally cheaper. This
|
|
555
|
-
// is possible because we can set the `flex-grow` property to the width
|
|
556
|
-
// value, which handles all the resizing for us, instead of manually
|
|
557
|
-
// having to set the `width` property of each column.
|
|
558
|
-
default: 1,
|
|
559
|
-
parseHTML: (e) => {
|
|
560
|
-
const t = e.getAttribute("data-width");
|
|
561
|
-
if (t === null)
|
|
562
|
-
return null;
|
|
563
|
-
const o = parseFloat(t);
|
|
564
|
-
return isFinite(o) ? o : null;
|
|
565
|
-
},
|
|
566
|
-
renderHTML: (e) => ({
|
|
567
|
-
"data-width": e.width.toString(),
|
|
568
|
-
style: `flex-grow: ${e.width};`
|
|
569
|
-
})
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
},
|
|
573
|
-
parseHTML() {
|
|
574
|
-
return [
|
|
575
|
-
{
|
|
576
|
-
tag: "div",
|
|
577
|
-
getAttrs: (e) => typeof e == "string" ? !1 : e.getAttribute("data-node-type") === this.name ? {} : !1
|
|
578
|
-
}
|
|
579
|
-
];
|
|
580
|
-
},
|
|
581
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
582
|
-
const t = document.createElement("div");
|
|
583
|
-
t.className = "bn-block-column", t.setAttribute("data-node-type", this.name);
|
|
584
|
-
for (const [o, n] of Object.entries(e))
|
|
585
|
-
t.setAttribute(o, n);
|
|
586
|
-
return {
|
|
587
|
-
dom: t,
|
|
588
|
-
contentDOM: t
|
|
589
|
-
};
|
|
590
|
-
},
|
|
591
|
-
addExtensions() {
|
|
592
|
-
return [ge(this.options.editor)];
|
|
593
|
-
}
|
|
594
|
-
}), we = L.create({
|
|
595
|
-
name: "columnList",
|
|
596
|
-
group: "childContainer bnBlock blockGroupChild",
|
|
597
|
-
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
598
|
-
content: "column column+",
|
|
599
|
-
// min two columns
|
|
600
|
-
priority: 40,
|
|
601
|
-
// should be below blockContainer
|
|
602
|
-
defining: !0,
|
|
603
|
-
marks: "deletion insertion modification",
|
|
604
|
-
parseHTML() {
|
|
605
|
-
return [
|
|
606
|
-
{
|
|
607
|
-
tag: "div",
|
|
608
|
-
getAttrs: (e) => typeof e == "string" ? !1 : e.getAttribute("data-node-type") === this.name ? {} : !1
|
|
609
|
-
}
|
|
610
|
-
];
|
|
611
|
-
},
|
|
612
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
613
|
-
const t = document.createElement("div");
|
|
614
|
-
t.className = "bn-block-column-list", t.setAttribute("data-node-type", this.name);
|
|
615
|
-
for (const [o, n] of Object.entries(e))
|
|
616
|
-
t.setAttribute(o, n);
|
|
617
|
-
return t.style.display = "flex", {
|
|
618
|
-
dom: t,
|
|
619
|
-
contentDOM: t
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
}), H = M(
|
|
623
|
-
{
|
|
624
|
-
node: be,
|
|
625
|
-
type: "column",
|
|
626
|
-
content: "none"
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
width: {
|
|
630
|
-
default: 1
|
|
631
|
-
}
|
|
632
|
-
},
|
|
633
|
-
[he()]
|
|
634
|
-
), z = M(
|
|
635
|
-
{
|
|
636
|
-
node: we,
|
|
637
|
-
type: "columnList",
|
|
638
|
-
content: "none"
|
|
639
|
-
},
|
|
640
|
-
{}
|
|
641
|
-
), D = q.create({
|
|
642
|
-
blockSpecs: {
|
|
643
|
-
column: H,
|
|
644
|
-
columnList: z
|
|
645
|
-
}
|
|
646
|
-
}), Re = (e) => e.extend({
|
|
647
|
-
blockSpecs: {
|
|
648
|
-
column: H,
|
|
649
|
-
columnList: z
|
|
650
|
-
}
|
|
1
|
+
import { BlockNoteSchema as e, UniqueID as t, createBlockSpecFromTiptapNode as n, createExtension as r, getBlockInfo as i, getNearestBlockPos as a, getNodeById as o, nodeToBlock as s } from "@blocknote/core";
|
|
2
|
+
import { Plugin as c, PluginKey as l } from "prosemirror-state";
|
|
3
|
+
import { Extension as u, Node as d } from "@tiptap/core";
|
|
4
|
+
import { SideMenuExtension as f, insertOrUpdateBlockForSlashMenu as p } from "@blocknote/core/extensions";
|
|
5
|
+
import { Decoration as m, DecorationSet as h } from "prosemirror-view";
|
|
6
|
+
import { TbColumns2 as g, TbColumns3 as _ } from "react-icons/tb";
|
|
7
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
8
|
+
//#region \0rolldown/runtime.js
|
|
9
|
+
var y = Object.defineProperty, b = (e, t) => {
|
|
10
|
+
let n = {};
|
|
11
|
+
for (var r in e) y(n, r, {
|
|
12
|
+
get: e[r],
|
|
13
|
+
enumerable: !0
|
|
14
|
+
});
|
|
15
|
+
return t || y(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
|
+
}, x = { slash_menu: {
|
|
17
|
+
two_columns: {
|
|
18
|
+
title: "عمودان",
|
|
19
|
+
subtext: "عمودان جنبًا إلى جنب",
|
|
20
|
+
aliases: [
|
|
21
|
+
"أعمدة",
|
|
22
|
+
"صف",
|
|
23
|
+
"تقسيم"
|
|
24
|
+
],
|
|
25
|
+
group: "الكتل الأساسية"
|
|
26
|
+
},
|
|
27
|
+
three_columns: {
|
|
28
|
+
title: "ثلاثة أعمدة",
|
|
29
|
+
subtext: "ثلاثة أعمدة جنبًا إلى جنب",
|
|
30
|
+
aliases: [
|
|
31
|
+
"أعمدة",
|
|
32
|
+
"صف",
|
|
33
|
+
"تقسيم"
|
|
34
|
+
],
|
|
35
|
+
group: "الكتل الأساسية"
|
|
36
|
+
}
|
|
37
|
+
} }, S = { slash_menu: {
|
|
38
|
+
two_columns: {
|
|
39
|
+
title: "Zwei Spalten",
|
|
40
|
+
subtext: "Zwei Spalten nebeneinander",
|
|
41
|
+
aliases: [
|
|
42
|
+
"Spalten",
|
|
43
|
+
"Reihe",
|
|
44
|
+
"teilen"
|
|
45
|
+
],
|
|
46
|
+
group: "Grundlegende Blöcke"
|
|
47
|
+
},
|
|
48
|
+
three_columns: {
|
|
49
|
+
title: "Drei Spalten",
|
|
50
|
+
subtext: "Drei Spalten nebeneinander",
|
|
51
|
+
aliases: [
|
|
52
|
+
"Spalten",
|
|
53
|
+
"Reihe",
|
|
54
|
+
"teilen"
|
|
55
|
+
],
|
|
56
|
+
group: "Grundlegende Blöcke"
|
|
57
|
+
}
|
|
58
|
+
} }, C = { slash_menu: {
|
|
59
|
+
two_columns: {
|
|
60
|
+
title: "Two Columns",
|
|
61
|
+
subtext: "Two columns side by side",
|
|
62
|
+
aliases: [
|
|
63
|
+
"columns",
|
|
64
|
+
"row",
|
|
65
|
+
"split"
|
|
66
|
+
],
|
|
67
|
+
group: "Basic blocks"
|
|
68
|
+
},
|
|
69
|
+
three_columns: {
|
|
70
|
+
title: "Three Columns",
|
|
71
|
+
subtext: "Three columns side by side",
|
|
72
|
+
aliases: [
|
|
73
|
+
"columns",
|
|
74
|
+
"row",
|
|
75
|
+
"split"
|
|
76
|
+
],
|
|
77
|
+
group: "Basic blocks"
|
|
78
|
+
}
|
|
79
|
+
} }, w = { slash_menu: {
|
|
80
|
+
two_columns: {
|
|
81
|
+
title: "Dos Columnas",
|
|
82
|
+
subtext: "Dos columnas lado a lado",
|
|
83
|
+
aliases: [
|
|
84
|
+
"columnas",
|
|
85
|
+
"fila",
|
|
86
|
+
"dividir"
|
|
87
|
+
],
|
|
88
|
+
group: "Bloques básicos"
|
|
89
|
+
},
|
|
90
|
+
three_columns: {
|
|
91
|
+
title: "Tres Columnas",
|
|
92
|
+
subtext: "Tres columnas lado a lado",
|
|
93
|
+
aliases: [
|
|
94
|
+
"columnas",
|
|
95
|
+
"fila",
|
|
96
|
+
"dividir"
|
|
97
|
+
],
|
|
98
|
+
group: "Bloques básicos"
|
|
99
|
+
}
|
|
100
|
+
} }, T = { slash_menu: {
|
|
101
|
+
two_columns: {
|
|
102
|
+
title: "Deux Colonnes",
|
|
103
|
+
subtext: "Deux colonnes côte à côte",
|
|
104
|
+
aliases: [
|
|
105
|
+
"colonnes",
|
|
106
|
+
"rangée",
|
|
107
|
+
"partager"
|
|
108
|
+
],
|
|
109
|
+
group: "Blocs de base"
|
|
110
|
+
},
|
|
111
|
+
three_columns: {
|
|
112
|
+
title: "Trois Colonnes",
|
|
113
|
+
subtext: "Trois colonnes côte à côte",
|
|
114
|
+
aliases: [
|
|
115
|
+
"colonnes",
|
|
116
|
+
"rangée",
|
|
117
|
+
"partager"
|
|
118
|
+
],
|
|
119
|
+
group: "Blocs de base"
|
|
120
|
+
}
|
|
121
|
+
} }, E = { slash_menu: {
|
|
122
|
+
two_columns: {
|
|
123
|
+
title: "Dva Stupca",
|
|
124
|
+
subtext: "Dva stupca jedan pored drugog",
|
|
125
|
+
aliases: [
|
|
126
|
+
"stupci",
|
|
127
|
+
"redak",
|
|
128
|
+
"podijeli"
|
|
129
|
+
],
|
|
130
|
+
group: "Osnovni blokovi"
|
|
131
|
+
},
|
|
132
|
+
three_columns: {
|
|
133
|
+
title: "Tri Stupca",
|
|
134
|
+
subtext: "Tri stupca jedan pored drugog",
|
|
135
|
+
aliases: [
|
|
136
|
+
"stupci",
|
|
137
|
+
"redak",
|
|
138
|
+
"podijeli"
|
|
139
|
+
],
|
|
140
|
+
group: "Osnovni blokovi"
|
|
141
|
+
}
|
|
142
|
+
} }, D = { slash_menu: {
|
|
143
|
+
two_columns: {
|
|
144
|
+
title: "Tvær Dálkar",
|
|
145
|
+
subtext: "Tvær dálkar hlið við hlið",
|
|
146
|
+
aliases: [
|
|
147
|
+
"dálkar",
|
|
148
|
+
"röð",
|
|
149
|
+
"skipta"
|
|
150
|
+
],
|
|
151
|
+
group: "Grunnblokkar"
|
|
152
|
+
},
|
|
153
|
+
three_columns: {
|
|
154
|
+
title: "Þrír Dálkar",
|
|
155
|
+
subtext: "Þrír dálkar hlið við hlið",
|
|
156
|
+
aliases: [
|
|
157
|
+
"dálkar",
|
|
158
|
+
"röð",
|
|
159
|
+
"skipta"
|
|
160
|
+
],
|
|
161
|
+
group: "Grunnblokkar"
|
|
162
|
+
}
|
|
163
|
+
} }, O = { slash_menu: {
|
|
164
|
+
two_columns: {
|
|
165
|
+
title: "二列",
|
|
166
|
+
subtext: "二列並んで",
|
|
167
|
+
aliases: [
|
|
168
|
+
"列",
|
|
169
|
+
"行",
|
|
170
|
+
"分割"
|
|
171
|
+
],
|
|
172
|
+
group: "基本ブロック"
|
|
173
|
+
},
|
|
174
|
+
three_columns: {
|
|
175
|
+
title: "三列",
|
|
176
|
+
subtext: "三列並んで",
|
|
177
|
+
aliases: [
|
|
178
|
+
"列",
|
|
179
|
+
"行",
|
|
180
|
+
"分割"
|
|
181
|
+
],
|
|
182
|
+
group: "基本ブロック"
|
|
183
|
+
}
|
|
184
|
+
} }, k = { slash_menu: {
|
|
185
|
+
two_columns: {
|
|
186
|
+
title: "두 열",
|
|
187
|
+
subtext: "두 열 나란히",
|
|
188
|
+
aliases: [
|
|
189
|
+
"열",
|
|
190
|
+
"행",
|
|
191
|
+
"분할"
|
|
192
|
+
],
|
|
193
|
+
group: "기본 블록"
|
|
194
|
+
},
|
|
195
|
+
three_columns: {
|
|
196
|
+
title: "세 열",
|
|
197
|
+
subtext: "세 열 나란히",
|
|
198
|
+
aliases: [
|
|
199
|
+
"열",
|
|
200
|
+
"행",
|
|
201
|
+
"분할"
|
|
202
|
+
],
|
|
203
|
+
group: "기본 블록"
|
|
204
|
+
}
|
|
205
|
+
} }, A = { slash_menu: {
|
|
206
|
+
two_columns: {
|
|
207
|
+
title: "Twee Kolommen",
|
|
208
|
+
subtext: "Twee kolommen naast elkaar",
|
|
209
|
+
aliases: [
|
|
210
|
+
"kolommen",
|
|
211
|
+
"rij",
|
|
212
|
+
"verdelen"
|
|
213
|
+
],
|
|
214
|
+
group: "Basisblokken"
|
|
215
|
+
},
|
|
216
|
+
three_columns: {
|
|
217
|
+
title: "Drie Kolommen",
|
|
218
|
+
subtext: "Drie kolommen naast elkaar",
|
|
219
|
+
aliases: [
|
|
220
|
+
"kolommen",
|
|
221
|
+
"rij",
|
|
222
|
+
"verdelen"
|
|
223
|
+
],
|
|
224
|
+
group: "Basisblokken"
|
|
225
|
+
}
|
|
226
|
+
} }, j = { slash_menu: {
|
|
227
|
+
two_columns: {
|
|
228
|
+
title: "Dwie Kolumny",
|
|
229
|
+
subtext: "Dwie kolumny obok siebie",
|
|
230
|
+
aliases: [
|
|
231
|
+
"kolumny",
|
|
232
|
+
"rząd",
|
|
233
|
+
"podzielić"
|
|
234
|
+
],
|
|
235
|
+
group: "Podstawowe bloki"
|
|
236
|
+
},
|
|
237
|
+
three_columns: {
|
|
238
|
+
title: "Trzy Kolumny",
|
|
239
|
+
subtext: "Trzy kolumny obok siebie",
|
|
240
|
+
aliases: [
|
|
241
|
+
"kolumny",
|
|
242
|
+
"rząd",
|
|
243
|
+
"podzielić"
|
|
244
|
+
],
|
|
245
|
+
group: "Podstawowe bloki"
|
|
246
|
+
}
|
|
247
|
+
} }, M = { slash_menu: {
|
|
248
|
+
two_columns: {
|
|
249
|
+
title: "Duas Colunas",
|
|
250
|
+
subtext: "Duas colunas lado a lado",
|
|
251
|
+
aliases: [
|
|
252
|
+
"colunas",
|
|
253
|
+
"linha",
|
|
254
|
+
"dividir"
|
|
255
|
+
],
|
|
256
|
+
group: "Blocos básicos"
|
|
257
|
+
},
|
|
258
|
+
three_columns: {
|
|
259
|
+
title: "Três Colunas",
|
|
260
|
+
subtext: "Três colunas lado a lado",
|
|
261
|
+
aliases: [
|
|
262
|
+
"colunas",
|
|
263
|
+
"linha",
|
|
264
|
+
"dividir"
|
|
265
|
+
],
|
|
266
|
+
group: "Blocos básicos"
|
|
267
|
+
}
|
|
268
|
+
} }, N = { slash_menu: {
|
|
269
|
+
two_columns: {
|
|
270
|
+
title: "Два Столбца",
|
|
271
|
+
subtext: "Два столбца рядом",
|
|
272
|
+
aliases: [
|
|
273
|
+
"столбцы",
|
|
274
|
+
"ряд",
|
|
275
|
+
"разделить"
|
|
276
|
+
],
|
|
277
|
+
group: "Базовые блоки"
|
|
278
|
+
},
|
|
279
|
+
three_columns: {
|
|
280
|
+
title: "Три Столбца",
|
|
281
|
+
subtext: "Три столбца рядом",
|
|
282
|
+
aliases: [
|
|
283
|
+
"столбцы",
|
|
284
|
+
"ряд",
|
|
285
|
+
"разделить"
|
|
286
|
+
],
|
|
287
|
+
group: "Базовые блоки"
|
|
288
|
+
}
|
|
289
|
+
} }, P = { slash_menu: {
|
|
290
|
+
two_columns: {
|
|
291
|
+
title: "Hai Cột",
|
|
292
|
+
subtext: "Hai cột cạnh nhau",
|
|
293
|
+
aliases: [
|
|
294
|
+
"cột",
|
|
295
|
+
"hàng",
|
|
296
|
+
"chia"
|
|
297
|
+
],
|
|
298
|
+
group: "Khối cơ bản"
|
|
299
|
+
},
|
|
300
|
+
three_columns: {
|
|
301
|
+
title: "Ba Cột",
|
|
302
|
+
subtext: "Ba cột cạnh nhau",
|
|
303
|
+
aliases: [
|
|
304
|
+
"cột",
|
|
305
|
+
"hàng",
|
|
306
|
+
"chia"
|
|
307
|
+
],
|
|
308
|
+
group: "Khối cơ bản"
|
|
309
|
+
}
|
|
310
|
+
} }, F = { slash_menu: {
|
|
311
|
+
two_columns: {
|
|
312
|
+
title: "两列",
|
|
313
|
+
subtext: "两列并排",
|
|
314
|
+
aliases: [
|
|
315
|
+
"列",
|
|
316
|
+
"行",
|
|
317
|
+
"分割"
|
|
318
|
+
],
|
|
319
|
+
group: "基础"
|
|
320
|
+
},
|
|
321
|
+
three_columns: {
|
|
322
|
+
title: "三列",
|
|
323
|
+
subtext: "三列并排",
|
|
324
|
+
aliases: [
|
|
325
|
+
"列",
|
|
326
|
+
"行",
|
|
327
|
+
"分割"
|
|
328
|
+
],
|
|
329
|
+
group: "基础"
|
|
330
|
+
}
|
|
331
|
+
} }, I = /* @__PURE__ */ b({
|
|
332
|
+
ar: () => x,
|
|
333
|
+
de: () => S,
|
|
334
|
+
en: () => C,
|
|
335
|
+
es: () => w,
|
|
336
|
+
fr: () => T,
|
|
337
|
+
hr: () => E,
|
|
338
|
+
is: () => D,
|
|
339
|
+
ja: () => O,
|
|
340
|
+
ko: () => k,
|
|
341
|
+
nl: () => A,
|
|
342
|
+
pl: () => j,
|
|
343
|
+
pt: () => M,
|
|
344
|
+
ru: () => N,
|
|
345
|
+
vi: () => P,
|
|
346
|
+
zh: () => F
|
|
651
347
|
});
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
attr: void 0
|
|
658
|
-
}, O = g.createContext && /* @__PURE__ */ g.createContext(R), Ce = ["attr", "size", "title"];
|
|
659
|
-
function ve(e, t) {
|
|
660
|
-
if (e == null) return {};
|
|
661
|
-
var o = ye(e, t), n, u;
|
|
662
|
-
if (Object.getOwnPropertySymbols) {
|
|
663
|
-
var l = Object.getOwnPropertySymbols(e);
|
|
664
|
-
for (u = 0; u < l.length; u++)
|
|
665
|
-
n = l[u], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (o[n] = e[n]);
|
|
666
|
-
}
|
|
667
|
-
return o;
|
|
668
|
-
}
|
|
669
|
-
function ye(e, t) {
|
|
670
|
-
if (e == null) return {};
|
|
671
|
-
var o = {};
|
|
672
|
-
for (var n in e)
|
|
673
|
-
if (Object.prototype.hasOwnProperty.call(e, n)) {
|
|
674
|
-
if (t.indexOf(n) >= 0) continue;
|
|
675
|
-
o[n] = e[n];
|
|
676
|
-
}
|
|
677
|
-
return o;
|
|
678
|
-
}
|
|
679
|
-
function C() {
|
|
680
|
-
return C = Object.assign ? Object.assign.bind() : function(e) {
|
|
681
|
-
for (var t = 1; t < arguments.length; t++) {
|
|
682
|
-
var o = arguments[t];
|
|
683
|
-
for (var n in o)
|
|
684
|
-
Object.prototype.hasOwnProperty.call(o, n) && (e[n] = o[n]);
|
|
685
|
-
}
|
|
686
|
-
return e;
|
|
687
|
-
}, C.apply(this, arguments);
|
|
688
|
-
}
|
|
689
|
-
function T(e, t) {
|
|
690
|
-
var o = Object.keys(e);
|
|
691
|
-
if (Object.getOwnPropertySymbols) {
|
|
692
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
693
|
-
t && (n = n.filter(function(u) {
|
|
694
|
-
return Object.getOwnPropertyDescriptor(e, u).enumerable;
|
|
695
|
-
})), o.push.apply(o, n);
|
|
696
|
-
}
|
|
697
|
-
return o;
|
|
698
|
-
}
|
|
699
|
-
function v(e) {
|
|
700
|
-
for (var t = 1; t < arguments.length; t++) {
|
|
701
|
-
var o = arguments[t] != null ? arguments[t] : {};
|
|
702
|
-
t % 2 ? T(Object(o), !0).forEach(function(n) {
|
|
703
|
-
_e(e, n, o[n]);
|
|
704
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(o)) : T(Object(o)).forEach(function(n) {
|
|
705
|
-
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(o, n));
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
return e;
|
|
709
|
-
}
|
|
710
|
-
function _e(e, t, o) {
|
|
711
|
-
return t = ke(t), t in e ? Object.defineProperty(e, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = o, e;
|
|
712
|
-
}
|
|
713
|
-
function ke(e) {
|
|
714
|
-
var t = Pe(e, "string");
|
|
715
|
-
return typeof t == "symbol" ? t : t + "";
|
|
716
|
-
}
|
|
717
|
-
function Pe(e, t) {
|
|
718
|
-
if (typeof e != "object" || !e) return e;
|
|
719
|
-
var o = e[Symbol.toPrimitive];
|
|
720
|
-
if (o !== void 0) {
|
|
721
|
-
var n = o.call(e, t);
|
|
722
|
-
if (typeof n != "object") return n;
|
|
723
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
724
|
-
}
|
|
725
|
-
return (t === "string" ? String : Number)(e);
|
|
726
|
-
}
|
|
727
|
-
function W(e) {
|
|
728
|
-
return e && e.map((t, o) => /* @__PURE__ */ g.createElement(t.tag, v({
|
|
729
|
-
key: o
|
|
730
|
-
}, t.attr), W(t.child)));
|
|
731
|
-
}
|
|
732
|
-
function A(e) {
|
|
733
|
-
return (t) => /* @__PURE__ */ g.createElement(Ee, C({
|
|
734
|
-
attr: v({}, e.attr)
|
|
735
|
-
}, t), W(e.child));
|
|
736
|
-
}
|
|
737
|
-
function Ee(e) {
|
|
738
|
-
var t = (o) => {
|
|
739
|
-
var {
|
|
740
|
-
attr: n,
|
|
741
|
-
size: u,
|
|
742
|
-
title: l
|
|
743
|
-
} = e, s = ve(e, Ce), i = u || o.size || "1em", r;
|
|
744
|
-
return o.className && (r = o.className), e.className && (r = (r ? r + " " : "") + e.className), /* @__PURE__ */ g.createElement("svg", C({
|
|
745
|
-
stroke: "currentColor",
|
|
746
|
-
fill: "currentColor",
|
|
747
|
-
strokeWidth: "0"
|
|
748
|
-
}, o.attr, n, s, {
|
|
749
|
-
className: r,
|
|
750
|
-
style: v(v({
|
|
751
|
-
color: e.color || o.color
|
|
752
|
-
}, o.style), e.style),
|
|
753
|
-
height: i,
|
|
754
|
-
width: i,
|
|
755
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
756
|
-
}), l && /* @__PURE__ */ g.createElement("title", null, l), e.children);
|
|
757
|
-
};
|
|
758
|
-
return O !== void 0 ? /* @__PURE__ */ g.createElement(O.Consumer, null, (o) => t(o)) : t(R);
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/i18n/dictionary.ts
|
|
350
|
+
function L(e) {
|
|
351
|
+
if (!e.dictionary.multi_column) throw Error("Multi-column dictionary not found");
|
|
352
|
+
return e.dictionary.multi_column;
|
|
759
353
|
}
|
|
760
|
-
|
|
761
|
-
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/extensions/DropCursor/multiColumnDropCursor.ts
|
|
356
|
+
var R = .1;
|
|
357
|
+
function z(e, t, n) {
|
|
358
|
+
let r = t.posAtCoords({
|
|
359
|
+
left: e.clientX,
|
|
360
|
+
top: e.clientY
|
|
361
|
+
});
|
|
362
|
+
if (!r) return null;
|
|
363
|
+
let i = a(n.doc, r.pos), o = n.doc.resolve(i.posBeforeNode);
|
|
364
|
+
o.parent.type.name === "column" && (o = n.doc.resolve(o.before()));
|
|
365
|
+
let s = {
|
|
366
|
+
posBeforeNode: o.pos,
|
|
367
|
+
node: o.nodeAfter
|
|
368
|
+
}, c = t.nodeDOM(s.posBeforeNode);
|
|
369
|
+
if (c === null) return {
|
|
370
|
+
position: "regular",
|
|
371
|
+
posBeforeNode: s.posBeforeNode,
|
|
372
|
+
node: s.node
|
|
373
|
+
};
|
|
374
|
+
let l = c.getBoundingClientRect(), u = "regular";
|
|
375
|
+
return e.clientX <= l.left + l.width * R ? u = "left" : e.clientX >= l.right - l.width * R && (u = "right"), {
|
|
376
|
+
position: u,
|
|
377
|
+
posBeforeNode: s.posBeforeNode,
|
|
378
|
+
node: s.node
|
|
379
|
+
};
|
|
762
380
|
}
|
|
763
|
-
|
|
764
|
-
|
|
381
|
+
var B = { hooks: { computeDropPosition: (e) => {
|
|
382
|
+
let t = z(e.event, e.view, e.view.state);
|
|
383
|
+
return t === null || t.position === "regular" ? e.defaultPosition : {
|
|
384
|
+
pos: t.posBeforeNode,
|
|
385
|
+
orientation: t.position === "left" ? "block-vertical-left" : "block-vertical-right"
|
|
386
|
+
};
|
|
387
|
+
} } };
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/extensions/DropCursor/multiColumnHandleDropPlugin.ts
|
|
390
|
+
function V(e) {
|
|
391
|
+
return new c({ props: { handleDrop(n, r, a, o) {
|
|
392
|
+
let c = z(r, n, n.state);
|
|
393
|
+
if (c === null) return !1;
|
|
394
|
+
let l = i(c);
|
|
395
|
+
if (c.position === "regular" || a.content.childCount === 0) return !1;
|
|
396
|
+
let u = s(a.content.child(0), e.pmSchema);
|
|
397
|
+
if (l.blockNoteType === "column") {
|
|
398
|
+
let r = s(n.state.doc.resolve(l.bnBlock.beforePos).node(), e.pmSchema), i = 0;
|
|
399
|
+
r.children.forEach((e) => {
|
|
400
|
+
i += e.props.width;
|
|
401
|
+
});
|
|
402
|
+
let a = i / r.children.length;
|
|
403
|
+
if (a < .99 || a > 1.01) {
|
|
404
|
+
let e = 1 / a;
|
|
405
|
+
r.children.forEach((t) => {
|
|
406
|
+
t.props.width = t.props.width * e;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
let o = r.children.findIndex((e) => e.id === l.bnBlock.node.attrs.id), d = r.children.map((e) => ({
|
|
410
|
+
...e,
|
|
411
|
+
children: e.children.filter((e) => e.id !== u.id)
|
|
412
|
+
})).filter((e) => e.children.length > 0).toSpliced(c.position === "left" ? o : o + 1, 0, {
|
|
413
|
+
type: "column",
|
|
414
|
+
children: [u],
|
|
415
|
+
props: {},
|
|
416
|
+
content: void 0,
|
|
417
|
+
id: t.options.generateID()
|
|
418
|
+
});
|
|
419
|
+
e.getBlock(u.id) && e.removeBlocks([u]), e.updateBlock(r, { children: d });
|
|
420
|
+
} else {
|
|
421
|
+
let t = s(l.bnBlock.node, e.pmSchema);
|
|
422
|
+
if (t.id === u.id) return !0;
|
|
423
|
+
let n = c.position === "left" ? [u, t] : [t, u];
|
|
424
|
+
e.getBlock(u.id) && e.removeBlocks([u]), e.replaceBlocks([t], [{
|
|
425
|
+
type: "columnList",
|
|
426
|
+
children: n.map((e) => ({
|
|
427
|
+
type: "column",
|
|
428
|
+
children: [e]
|
|
429
|
+
}))
|
|
430
|
+
}]);
|
|
431
|
+
}
|
|
432
|
+
return !0;
|
|
433
|
+
} } });
|
|
765
434
|
}
|
|
766
|
-
|
|
767
|
-
|
|
435
|
+
var H = r(({ editor: e }) => ({
|
|
436
|
+
key: "multiColumnDropHandler",
|
|
437
|
+
prosemirrorPlugins: [V(e)]
|
|
438
|
+
})), U = new l("ColumnResizePlugin"), W = class {
|
|
439
|
+
editor;
|
|
440
|
+
view;
|
|
441
|
+
RESIZE_MARGIN_WIDTH_PX = 20;
|
|
442
|
+
COLUMN_MIN_WIDTH_PERCENT = .5;
|
|
443
|
+
constructor(e, t) {
|
|
444
|
+
this.editor = e, this.view = t, this.view.dom.addEventListener("mousedown", this.mouseDownHandler), document.body.addEventListener("mousemove", this.mouseMoveHandler), document.body.addEventListener("mouseup", this.mouseUpHandler);
|
|
445
|
+
}
|
|
446
|
+
getColumnHoverOrDefaultState = (e) => {
|
|
447
|
+
if (!this.editor.isEditable) return { type: "default" };
|
|
448
|
+
let t = e.target;
|
|
449
|
+
if (!this.view.dom.contains(t)) return { type: "default" };
|
|
450
|
+
let n = t.closest(".bn-block-column");
|
|
451
|
+
if (!n) return { type: "default" };
|
|
452
|
+
let r = e.clientX, i = n.getBoundingClientRect(), a = r < i.left + this.RESIZE_MARGIN_WIDTH_PX ? "left" : r > i.right - this.RESIZE_MARGIN_WIDTH_PX ? "right" : "none", s = a === "left" ? n.previousElementSibling : a === "right" ? n.nextElementSibling : void 0;
|
|
453
|
+
if (!s) return { type: "default" };
|
|
454
|
+
let c = a === "left" ? s : n, l = a === "left" ? n : s, u = c.getAttribute("data-id"), d = l.getAttribute("data-id"), f = o(u, this.view.state.doc), p = o(d, this.view.state.doc);
|
|
455
|
+
if (!f || !p || !f.posBeforeNode) throw Error("Column not found");
|
|
456
|
+
return {
|
|
457
|
+
type: "hover",
|
|
458
|
+
leftColumn: {
|
|
459
|
+
element: c,
|
|
460
|
+
id: u,
|
|
461
|
+
...f
|
|
462
|
+
},
|
|
463
|
+
rightColumn: {
|
|
464
|
+
element: l,
|
|
465
|
+
id: d,
|
|
466
|
+
...p
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
mouseDownHandler = (e) => {
|
|
471
|
+
let t = this.getColumnHoverOrDefaultState(e);
|
|
472
|
+
if (t.type === "default") return;
|
|
473
|
+
e.preventDefault();
|
|
474
|
+
let n = e.clientX, r = t.leftColumn.element.getBoundingClientRect().width, i = t.rightColumn.element.getBoundingClientRect().width, a = t.leftColumn.node.attrs.width, o = t.rightColumn.node.attrs.width;
|
|
475
|
+
t = {
|
|
476
|
+
type: "resize",
|
|
477
|
+
startPos: n,
|
|
478
|
+
leftColumn: {
|
|
479
|
+
...t.leftColumn,
|
|
480
|
+
widthPx: r,
|
|
481
|
+
widthPercent: a
|
|
482
|
+
},
|
|
483
|
+
rightColumn: {
|
|
484
|
+
...t.rightColumn,
|
|
485
|
+
widthPx: i,
|
|
486
|
+
widthPercent: o
|
|
487
|
+
}
|
|
488
|
+
}, this.view.dispatch(this.view.state.tr.setMeta(U, t)), this.editor.getExtension(f)?.freezeMenu();
|
|
489
|
+
};
|
|
490
|
+
mouseMoveHandler = (e) => {
|
|
491
|
+
let t = U.getState(this.view.state);
|
|
492
|
+
if (!t) return;
|
|
493
|
+
if (t.type !== "resize") {
|
|
494
|
+
let n = this.getColumnHoverOrDefaultState(e), r = t.type === "default" && n.type === "default", i = t.type !== "default" && n.type !== "default" && t.leftColumn.id === n.leftColumn.id && t.rightColumn.id === n.rightColumn.id;
|
|
495
|
+
if (r || i || n.type === "hover" && this.editor.getExtension(f)?.store.state?.show) return;
|
|
496
|
+
this.view.dispatch(this.view.state.tr.setMeta(U, n));
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
let n = (e.clientX - t.startPos) * t.leftColumn.widthPercent, r = (t.leftColumn.widthPx + n) / t.leftColumn.widthPx - 1, i = t.leftColumn.widthPercent + r, a = t.rightColumn.widthPercent - r;
|
|
500
|
+
i < this.COLUMN_MIN_WIDTH_PERCENT ? (a -= this.COLUMN_MIN_WIDTH_PERCENT - i, i = this.COLUMN_MIN_WIDTH_PERCENT) : a < this.COLUMN_MIN_WIDTH_PERCENT && (i -= this.COLUMN_MIN_WIDTH_PERCENT - a, a = this.COLUMN_MIN_WIDTH_PERCENT), this.view.dispatch(this.view.state.tr.setNodeAttribute(t.leftColumn.posBeforeNode, "width", i).setNodeAttribute(t.rightColumn.posBeforeNode, "width", a).setMeta("addToHistory", !1));
|
|
501
|
+
};
|
|
502
|
+
mouseUpHandler = (e) => {
|
|
503
|
+
let t = U.getState(this.view.state);
|
|
504
|
+
if (!t || t.type !== "resize") return;
|
|
505
|
+
let n = this.getColumnHoverOrDefaultState(e);
|
|
506
|
+
this.view.dispatch(this.view.state.tr.setMeta(U, n)), this.editor.getExtension(f)?.unfreezeMenu();
|
|
507
|
+
};
|
|
508
|
+
destroy() {
|
|
509
|
+
this.view.dom.removeEventListener("mousedown", this.mouseDownHandler), document.body.removeEventListener("mousemove", this.mouseMoveHandler), document.body.removeEventListener("mouseup", this.mouseUpHandler);
|
|
510
|
+
}
|
|
511
|
+
}, G = (e) => new c({
|
|
512
|
+
key: U,
|
|
513
|
+
props: { decorations: (e) => {
|
|
514
|
+
let t = U.getState(e);
|
|
515
|
+
return !t || t.type === "default" ? h.empty : h.create(e.doc, [m.node(t.leftColumn.posBeforeNode, t.leftColumn.posBeforeNode + t.leftColumn.node.nodeSize, { style: "box-shadow: 4px 0 0 #ccc; cursor: col-resize" }), m.node(t.rightColumn.posBeforeNode, t.rightColumn.posBeforeNode + t.rightColumn.node.nodeSize, { style: "cursor: col-resize" })]);
|
|
516
|
+
} },
|
|
517
|
+
state: {
|
|
518
|
+
init: () => ({ type: "default" }),
|
|
519
|
+
apply: (e, t) => {
|
|
520
|
+
let n = e.getMeta(U);
|
|
521
|
+
return n === void 0 ? t : n;
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
view: (t) => new W(e, t)
|
|
525
|
+
}), K = (e) => u.create({
|
|
526
|
+
name: "columnResize",
|
|
527
|
+
addProseMirrorPlugins() {
|
|
528
|
+
return [G(e)];
|
|
529
|
+
}
|
|
530
|
+
}), q = d.create({
|
|
531
|
+
name: "column",
|
|
532
|
+
group: "bnBlock childContainer",
|
|
533
|
+
content: "blockContainer+",
|
|
534
|
+
priority: 40,
|
|
535
|
+
defining: !0,
|
|
536
|
+
marks: "deletion insertion modification",
|
|
537
|
+
addAttributes() {
|
|
538
|
+
return { width: {
|
|
539
|
+
default: 1,
|
|
540
|
+
parseHTML: (e) => {
|
|
541
|
+
let t = e.getAttribute("data-width");
|
|
542
|
+
if (t === null) return null;
|
|
543
|
+
let n = parseFloat(t);
|
|
544
|
+
return isFinite(n) ? n : null;
|
|
545
|
+
},
|
|
546
|
+
renderHTML: (e) => ({
|
|
547
|
+
"data-width": e.width.toString(),
|
|
548
|
+
style: `flex-grow: ${e.width};`
|
|
549
|
+
})
|
|
550
|
+
} };
|
|
551
|
+
},
|
|
552
|
+
parseHTML() {
|
|
553
|
+
return [{
|
|
554
|
+
tag: "div",
|
|
555
|
+
getAttrs: (e) => typeof e == "string" ? !1 : e.getAttribute("data-node-type") === this.name ? {} : !1
|
|
556
|
+
}];
|
|
557
|
+
},
|
|
558
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
559
|
+
let t = document.createElement("div");
|
|
560
|
+
t.className = "bn-block-column", t.setAttribute("data-node-type", this.name);
|
|
561
|
+
for (let [n, r] of Object.entries(e)) t.setAttribute(n, r);
|
|
562
|
+
return {
|
|
563
|
+
dom: t,
|
|
564
|
+
contentDOM: t
|
|
565
|
+
};
|
|
566
|
+
},
|
|
567
|
+
addExtensions() {
|
|
568
|
+
return [K(this.options.editor)];
|
|
569
|
+
}
|
|
570
|
+
}), J = d.create({
|
|
571
|
+
name: "columnList",
|
|
572
|
+
group: "childContainer bnBlock blockGroupChild",
|
|
573
|
+
content: "column column+",
|
|
574
|
+
priority: 40,
|
|
575
|
+
defining: !0,
|
|
576
|
+
marks: "deletion insertion modification",
|
|
577
|
+
parseHTML() {
|
|
578
|
+
return [{
|
|
579
|
+
tag: "div",
|
|
580
|
+
getAttrs: (e) => typeof e == "string" ? !1 : e.getAttribute("data-node-type") === this.name ? {} : !1
|
|
581
|
+
}];
|
|
582
|
+
},
|
|
583
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
584
|
+
let t = document.createElement("div");
|
|
585
|
+
t.className = "bn-block-column-list", t.setAttribute("data-node-type", this.name);
|
|
586
|
+
for (let [n, r] of Object.entries(e)) t.setAttribute(n, r);
|
|
587
|
+
return t.style.display = "flex", {
|
|
588
|
+
dom: t,
|
|
589
|
+
contentDOM: t
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
}), Y = n({
|
|
593
|
+
node: q,
|
|
594
|
+
type: "column",
|
|
595
|
+
content: "none"
|
|
596
|
+
}, { width: { default: 1 } }, [H()]), X = n({
|
|
597
|
+
node: J,
|
|
598
|
+
type: "columnList",
|
|
599
|
+
content: "none"
|
|
600
|
+
}, {}), Z = e.create({ blockSpecs: {
|
|
601
|
+
column: Y,
|
|
602
|
+
columnList: X
|
|
603
|
+
} }), Q = (e) => e.extend({ blockSpecs: {
|
|
604
|
+
column: Y,
|
|
605
|
+
columnList: X
|
|
606
|
+
} });
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx
|
|
609
|
+
function $(e) {
|
|
610
|
+
return "column" in e.schema.blockSchema && e.schema.blockSchema.columnList === Z.blockSchema.columnList && "column" in e.schema.blockSchema && e.schema.blockSchema.column === Z.blockSchema.column;
|
|
768
611
|
}
|
|
769
|
-
function
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
{
|
|
810
|
-
type: "paragraph"
|
|
811
|
-
}
|
|
812
|
-
]
|
|
813
|
-
},
|
|
814
|
-
{
|
|
815
|
-
type: "column",
|
|
816
|
-
children: [
|
|
817
|
-
{
|
|
818
|
-
type: "paragraph"
|
|
819
|
-
}
|
|
820
|
-
]
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
type: "column",
|
|
824
|
-
children: [
|
|
825
|
-
{
|
|
826
|
-
type: "paragraph"
|
|
827
|
-
}
|
|
828
|
-
]
|
|
829
|
-
}
|
|
830
|
-
]
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
), t;
|
|
612
|
+
function ee(e) {
|
|
613
|
+
let t = [];
|
|
614
|
+
return $(e) && t.push({
|
|
615
|
+
...L(e).slash_menu.two_columns,
|
|
616
|
+
icon: /* @__PURE__ */ v(g, { size: 18 }),
|
|
617
|
+
onItemClick: () => {
|
|
618
|
+
p(e, {
|
|
619
|
+
type: "columnList",
|
|
620
|
+
children: [{
|
|
621
|
+
type: "column",
|
|
622
|
+
children: [{ type: "paragraph" }]
|
|
623
|
+
}, {
|
|
624
|
+
type: "column",
|
|
625
|
+
children: [{ type: "paragraph" }]
|
|
626
|
+
}]
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}, {
|
|
630
|
+
...L(e).slash_menu.three_columns,
|
|
631
|
+
icon: /* @__PURE__ */ v(_, { size: 18 }),
|
|
632
|
+
onItemClick: () => {
|
|
633
|
+
p(e, {
|
|
634
|
+
type: "columnList",
|
|
635
|
+
children: [
|
|
636
|
+
{
|
|
637
|
+
type: "column",
|
|
638
|
+
children: [{ type: "paragraph" }]
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
type: "column",
|
|
642
|
+
children: [{ type: "paragraph" }]
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
type: "column",
|
|
646
|
+
children: [{ type: "paragraph" }]
|
|
647
|
+
}
|
|
648
|
+
]
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}), t;
|
|
835
652
|
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
j as detectEdgePosition,
|
|
841
|
-
N as getMultiColumnDictionary,
|
|
842
|
-
We as getMultiColumnSlashMenuItems,
|
|
843
|
-
He as locales,
|
|
844
|
-
ze as multiColumnDropCursor,
|
|
845
|
-
D as multiColumnSchema,
|
|
846
|
-
Re as withMultiColumn
|
|
847
|
-
};
|
|
848
|
-
//# sourceMappingURL=blocknote-xl-multi-column.js.map
|
|
653
|
+
//#endregion
|
|
654
|
+
export { Y as ColumnBlock, X as ColumnListBlock, $ as checkMultiColumnBlocksInSchema, z as detectEdgePosition, L as getMultiColumnDictionary, ee as getMultiColumnSlashMenuItems, I as locales, B as multiColumnDropCursor, Z as multiColumnSchema, Q as withMultiColumn };
|
|
655
|
+
|
|
656
|
+
//# sourceMappingURL=blocknote-xl-multi-column.js.map
|