@blocknote/core 0.44.1 → 0.44.2
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/{BlockNoteSchema-C-l154WP.js → BlockNoteSchema-BsTi0fNS.js} +2 -2
- package/dist/{BlockNoteSchema-C-l154WP.js.map → BlockNoteSchema-BsTi0fNS.js.map} +1 -1
- package/dist/{BlockNoteSchema-B4gm-Qco.cjs → BlockNoteSchema-CBNkNhkw.cjs} +2 -2
- package/dist/{BlockNoteSchema-B4gm-Qco.cjs.map → BlockNoteSchema-CBNkNhkw.cjs.map} +1 -1
- package/dist/{TrailingNode-B_zPMWxw.js → TrailingNode-CG2a-HDA.js} +2 -2
- package/dist/{TrailingNode-B_zPMWxw.js.map → TrailingNode-CG2a-HDA.js.map} +1 -1
- package/dist/{TrailingNode-CRHrgOnK.cjs → TrailingNode-Du4SNHun.cjs} +2 -2
- package/dist/{TrailingNode-CRHrgOnK.cjs.map → TrailingNode-Du4SNHun.cjs.map} +1 -1
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +146 -135
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/{defaultBlocks-DgA_mtQV.js → defaultBlocks-B63ufZ5N.js} +5 -5
- package/dist/defaultBlocks-B63ufZ5N.js.map +1 -0
- package/dist/{defaultBlocks-DLJ4Q1_J.cjs → defaultBlocks-BX6UxQa8.cjs} +4 -4
- package/dist/{defaultBlocks-DLJ4Q1_J.cjs.map → defaultBlocks-BX6UxQa8.cjs.map} +1 -1
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/blocks/ListItem/NumberedListItem/block.ts +1 -5
- package/src/editor/BlockNoteEditor.test.ts +60 -0
- package/src/editor/BlockNoteEditor.ts +18 -1
- package/types/src/editor/BlockNoteEditor.d.ts +9 -0
- package/dist/defaultBlocks-DgA_mtQV.js.map +0 -1
package/dist/blocknote.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (n, e, t) =>
|
|
4
|
-
import { Slice as N, Fragment as A, DOMSerializer as he, DOMParser as
|
|
5
|
-
import { ReplaceStep as
|
|
6
|
-
import { n as U, i as O, g as
|
|
1
|
+
var Oe = Object.defineProperty;
|
|
2
|
+
var Fe = (n, e, t) => e in n ? Oe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var h = (n, e, t) => Fe(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Slice as N, Fragment as A, DOMSerializer as he, DOMParser as He, Node as $e } from "prosemirror-model";
|
|
5
|
+
import { ReplaceStep as Ve, ReplaceAroundStep as V } from "prosemirror-transform";
|
|
6
|
+
import { n as U, i as O, g as C, b as Y, a as b, t as Ue, U as F, q as _, r as H, d as ze, s as Ge, u as Re, v as q, w as B, x as me, y as je, z as ke, A as z } from "./blockToNode-DBNbhwwC.js";
|
|
7
7
|
import { B as es, G as ts, C as os, D as ns, N as ss, E as rs, O as is, F as as, H as cs, I as ls, L as ds, J as us, M as ps, K as fs } from "./blockToNode-DBNbhwwC.js";
|
|
8
|
-
import { ak as $, al as
|
|
9
|
-
import { aw as ms, av as ks, E as gs, a as bs, F as ys, r as Ss, N as Bs, a4 as Cs, ad as Es, aG as xs, ax as Ms, b as ws, d as Ts, e as Ps, a0 as vs, aM as Is, au as As, c as _s, f as Ds, ag as Ls, ah as Ns, aB as Os, x as Fs, y as Hs, A as $s, z as Vs, g as Us, h as zs, T as Gs, j as Rs, k as js, l as Ws, n as Ks, o as Js, q as Ys, s as qs, w as Qs, aC as Xs, aH as Zs, B as er, C as tr, H as or, I as nr, J as sr, K as rr, aE as ir, aI as ar, M as cr, D as lr, G as dr, S as ur, O as pr, Q as fr, W as hr, U as mr, _ as kr, Z as gr, a2 as br, Y as yr, X as Sr, R as Br, $ as Cr, m as Er, aN as xr, aK as Mr, az as wr, af as Tr, i as Pr, ay as vr, aD as Ir, ae as Ar, a7 as _r, t as Dr, u as Lr, v as Nr, aJ as Or, ai as Fr, aL as Hr, a1 as $r, V as Vr, p as Ur, a3 as zr, aF as Gr, L as Rr, aO as jr, P as Wr, aA as Kr } from "./defaultBlocks-
|
|
10
|
-
import { j as
|
|
11
|
-
import { s as Ct, B as Et } from "./BlockNoteSchema-
|
|
12
|
-
import { C as Yr, b as qr, c as Qr, a as Xr, g as Zr, u as ei, w as ti } from "./BlockNoteSchema-
|
|
8
|
+
import { ak as $, al as We, am as Ke, an as Je, aj as E, ao as Ye, ap as qe, a5 as Qe, a8 as G, aq as Xe, ar as Ze, a6 as et, as as Q, a9 as ge, at as tt } from "./defaultBlocks-B63ufZ5N.js";
|
|
9
|
+
import { aw as ms, av as ks, E as gs, a as bs, F as ys, r as Ss, N as Bs, a4 as Cs, ad as Es, aG as xs, ax as Ms, b as ws, d as Ts, e as Ps, a0 as vs, aM as Is, au as As, c as _s, f as Ds, ag as Ls, ah as Ns, aB as Os, x as Fs, y as Hs, A as $s, z as Vs, g as Us, h as zs, T as Gs, j as Rs, k as js, l as Ws, n as Ks, o as Js, q as Ys, s as qs, w as Qs, aC as Xs, aH as Zs, B as er, C as tr, H as or, I as nr, J as sr, K as rr, aE as ir, aI as ar, M as cr, D as lr, G as dr, S as ur, O as pr, Q as fr, W as hr, U as mr, _ as kr, Z as gr, a2 as br, Y as yr, X as Sr, R as Br, $ as Cr, m as Er, aN as xr, aK as Mr, az as wr, af as Tr, i as Pr, ay as vr, aD as Ir, ae as Ar, a7 as _r, t as Dr, u as Lr, v as Nr, aJ as Or, ai as Fr, aL as Hr, a1 as $r, V as Vr, p as Ur, a3 as zr, aF as Gr, L as Rr, aO as jr, P as Wr, aA as Kr } from "./defaultBlocks-B63ufZ5N.js";
|
|
10
|
+
import { j as ot, k as be, l as nt, m as st, n as rt, c as R, B as ye, D as it, L as at, N as ct, P as lt, g as dt, i as ut, F as pt, Y as ft, a as ht, b as mt, S as kt, H as gt, h as bt, e as yt, V as St, d as Bt } from "./TrailingNode-CG2a-HDA.js";
|
|
11
|
+
import { s as Ct, B as Et } from "./BlockNoteSchema-BsTi0fNS.js";
|
|
12
|
+
import { C as Yr, b as qr, c as Qr, a as Xr, g as Zr, u as ei, w as ti } from "./BlockNoteSchema-BsTi0fNS.js";
|
|
13
13
|
import { Node as D, Extension as x, mergeAttributes as xt, Mark as X, extensions as I, isNodeSelection as Mt, posToDOMRect as wt, selectionToInsertionEnd as Tt, getSchema as Pt, createDocument as vt, Editor as It } from "@tiptap/core";
|
|
14
|
-
import { E as
|
|
14
|
+
import { E as Se } from "./EventEmitter-CjSwpTbz.js";
|
|
15
15
|
import { Fragment as Z, Slice as ne } from "@tiptap/pm/model";
|
|
16
16
|
import { e as At } from "./en-njEqD7AG.js";
|
|
17
17
|
import { inputRules as _t, InputRule as Dt } from "@handlewithcare/prosemirror-inputrules";
|
|
@@ -61,10 +61,10 @@ function Jn(n, e) {
|
|
|
61
61
|
atom: n.content === "none",
|
|
62
62
|
content: n.content === "styled" ? "inline*" : "",
|
|
63
63
|
addAttributes() {
|
|
64
|
-
return
|
|
64
|
+
return Ke(n.propSchema);
|
|
65
65
|
},
|
|
66
66
|
addKeyboardShortcuts() {
|
|
67
|
-
return
|
|
67
|
+
return We(n);
|
|
68
68
|
},
|
|
69
69
|
parseHTML() {
|
|
70
70
|
return Wt(
|
|
@@ -119,7 +119,7 @@ function Jn(n, e) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
|
-
return
|
|
122
|
+
return Je(
|
|
123
123
|
t,
|
|
124
124
|
n.propSchema,
|
|
125
125
|
{
|
|
@@ -142,14 +142,14 @@ function Jn(n, e) {
|
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
function Kt(n, e, t, o = "before") {
|
|
145
|
-
const s = typeof t == "string" ? t : t.id, i =
|
|
145
|
+
const s = typeof t == "string" ? t : t.id, i = C(n), r = e.map(
|
|
146
146
|
(d) => Y(d, i)
|
|
147
147
|
), c = E(s, n.doc);
|
|
148
148
|
if (!c)
|
|
149
149
|
throw new Error(`Block with ID ${s} not found`);
|
|
150
150
|
let a = c.posBeforeNode;
|
|
151
151
|
return o === "after" && (a += c.node.nodeSize), n.step(
|
|
152
|
-
new
|
|
152
|
+
new Ve(a, a, new N(A.from(r), 0, 0))
|
|
153
153
|
), r.map(
|
|
154
154
|
(d) => b(d, i)
|
|
155
155
|
);
|
|
@@ -233,7 +233,7 @@ function W(n, e) {
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
function ie(n, e, t) {
|
|
236
|
-
const o =
|
|
236
|
+
const o = C(n), s = t.map(
|
|
237
237
|
(u) => Y(u, o)
|
|
238
238
|
), i = new Set(
|
|
239
239
|
e.map(
|
|
@@ -275,7 +275,7 @@ function Yt(n, e, t, o, s) {
|
|
|
275
275
|
else if (Array.isArray(e))
|
|
276
276
|
i = O(e, n.pmSchema, o);
|
|
277
277
|
else if (e.type === "tableContent")
|
|
278
|
-
i =
|
|
278
|
+
i = Ue(e, n.pmSchema);
|
|
279
279
|
else
|
|
280
280
|
throw new F(e.type);
|
|
281
281
|
else throw new Error("blockContent is required");
|
|
@@ -359,7 +359,7 @@ function qt(n, e, t, o) {
|
|
|
359
359
|
}
|
|
360
360
|
if (n.pmSchema.nodes[e.type].isInGroup("bnBlock")) {
|
|
361
361
|
if (e.children && e.children.length > 0) {
|
|
362
|
-
const g =
|
|
362
|
+
const g = Be(
|
|
363
363
|
n,
|
|
364
364
|
e.children,
|
|
365
365
|
t,
|
|
@@ -377,10 +377,10 @@ function qt(n, e, t, o) {
|
|
|
377
377
|
})
|
|
378
378
|
);
|
|
379
379
|
return (f = d.contentDOM) == null || f.appendChild(a.dom), e.children && e.children.length > 0 && ((k = d.contentDOM) == null || k.appendChild(
|
|
380
|
-
|
|
380
|
+
Ce(n, e.children, t, o)
|
|
381
381
|
)), d.dom;
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function Be(n, e, t, o) {
|
|
384
384
|
const i = ((o == null ? void 0 : o.document) ?? document).createDocumentFragment();
|
|
385
385
|
for (const r of e) {
|
|
386
386
|
const c = qt(n, r, t, o);
|
|
@@ -388,14 +388,14 @@ function Se(n, e, t, o) {
|
|
|
388
388
|
}
|
|
389
389
|
return i;
|
|
390
390
|
}
|
|
391
|
-
const
|
|
391
|
+
const Ce = (n, e, t, o) => {
|
|
392
392
|
var c;
|
|
393
|
-
const s = n.pmSchema.nodes.blockGroup, i = s.spec.toDOM(s.create({})), r =
|
|
393
|
+
const s = n.pmSchema.nodes.blockGroup, i = s.spec.toDOM(s.create({})), r = Be(n, e, t, o);
|
|
394
394
|
return (c = i.contentDOM) == null || c.appendChild(r), i.dom;
|
|
395
395
|
}, Qt = (n, e) => {
|
|
396
396
|
const t = he.fromSchema(n);
|
|
397
397
|
return {
|
|
398
|
-
serializeBlocks: (o, s) =>
|
|
398
|
+
serializeBlocks: (o, s) => Ce(e, o, t, s).outerHTML
|
|
399
399
|
};
|
|
400
400
|
};
|
|
401
401
|
function Xt(n) {
|
|
@@ -461,7 +461,7 @@ function K(n) {
|
|
|
461
461
|
children: K(e.children)
|
|
462
462
|
}).flat();
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function Ee(n, e, t) {
|
|
465
465
|
n.transact((o) => {
|
|
466
466
|
var r;
|
|
467
467
|
const s = ((r = n.getSelection()) == null ? void 0 : r.blocks) || [
|
|
@@ -470,26 +470,26 @@ function Ce(n, e, t) {
|
|
|
470
470
|
n.removeBlocks(s), n.insertBlocks(K(s), e, t), Zt(o, i);
|
|
471
471
|
});
|
|
472
472
|
}
|
|
473
|
-
function
|
|
473
|
+
function xe(n) {
|
|
474
474
|
return !n || n.type !== "columnList";
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function Me(n, e, t) {
|
|
477
477
|
let o, s;
|
|
478
478
|
if (e ? e.children.length > 0 ? (o = e.children[e.children.length - 1], s = "after") : (o = e, s = "before") : t && (o = t, s = "before"), !o || !s)
|
|
479
479
|
return;
|
|
480
480
|
const i = n.getParentBlock(o);
|
|
481
|
-
return
|
|
481
|
+
return xe(i) ? { referenceBlock: o, placement: s } : Me(
|
|
482
482
|
n,
|
|
483
483
|
s === "after" ? o : n.getPrevBlock(o),
|
|
484
484
|
i
|
|
485
485
|
);
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function we(n, e, t) {
|
|
488
488
|
let o, s;
|
|
489
489
|
if (e ? e.children.length > 0 ? (o = e.children[0], s = "before") : (o = e, s = "after") : t && (o = t, s = "after"), !o || !s)
|
|
490
490
|
return;
|
|
491
491
|
const i = n.getParentBlock(o);
|
|
492
|
-
return
|
|
492
|
+
return xe(i) ? { referenceBlock: o, placement: s } : we(
|
|
493
493
|
n,
|
|
494
494
|
s === "before" ? o : n.getNextBlock(o),
|
|
495
495
|
i
|
|
@@ -497,12 +497,12 @@ function Me(n, e, t) {
|
|
|
497
497
|
}
|
|
498
498
|
function eo(n) {
|
|
499
499
|
n.transact(() => {
|
|
500
|
-
const e = n.getSelection(), t = (e == null ? void 0 : e.blocks[0]) || n.getTextCursorPosition().block, o =
|
|
500
|
+
const e = n.getSelection(), t = (e == null ? void 0 : e.blocks[0]) || n.getTextCursorPosition().block, o = Me(
|
|
501
501
|
n,
|
|
502
502
|
n.getPrevBlock(t),
|
|
503
503
|
n.getParentBlock(t)
|
|
504
504
|
);
|
|
505
|
-
o &&
|
|
505
|
+
o && Ee(
|
|
506
506
|
n,
|
|
507
507
|
o.referenceBlock,
|
|
508
508
|
o.placement
|
|
@@ -511,12 +511,12 @@ function eo(n) {
|
|
|
511
511
|
}
|
|
512
512
|
function to(n) {
|
|
513
513
|
n.transact(() => {
|
|
514
|
-
const e = n.getSelection(), t = (e == null ? void 0 : e.blocks[(e == null ? void 0 : e.blocks.length) - 1]) || n.getTextCursorPosition().block, o =
|
|
514
|
+
const e = n.getSelection(), t = (e == null ? void 0 : e.blocks[(e == null ? void 0 : e.blocks.length) - 1]) || n.getTextCursorPosition().block, o = we(
|
|
515
515
|
n,
|
|
516
516
|
n.getNextBlock(t),
|
|
517
517
|
n.getParentBlock(t)
|
|
518
518
|
);
|
|
519
|
-
o &&
|
|
519
|
+
o && Ee(
|
|
520
520
|
n,
|
|
521
521
|
o.referenceBlock,
|
|
522
522
|
o.placement
|
|
@@ -557,7 +557,7 @@ function oo(n, e, t) {
|
|
|
557
557
|
)
|
|
558
558
|
).scrollIntoView(), !0;
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function Te(n) {
|
|
561
561
|
return n.transact((e) => oo(
|
|
562
562
|
e,
|
|
563
563
|
n.pmSchema.nodes.blockContainer,
|
|
@@ -580,12 +580,12 @@ function ro(n) {
|
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
582
|
function io(n, e) {
|
|
583
|
-
const t = typeof e == "string" ? e : e.id, o =
|
|
583
|
+
const t = typeof e == "string" ? e : e.id, o = C(n), s = E(t, n);
|
|
584
584
|
if (s)
|
|
585
585
|
return b(s.node, o);
|
|
586
586
|
}
|
|
587
587
|
function ao(n, e) {
|
|
588
|
-
const t = typeof e == "string" ? e : e.id, o = E(t, n), s =
|
|
588
|
+
const t = typeof e == "string" ? e : e.id, o = E(t, n), s = C(n);
|
|
589
589
|
if (!o)
|
|
590
590
|
return;
|
|
591
591
|
const r = n.resolve(o.posBeforeNode).nodeBefore;
|
|
@@ -593,7 +593,7 @@ function ao(n, e) {
|
|
|
593
593
|
return b(r, s);
|
|
594
594
|
}
|
|
595
595
|
function co(n, e) {
|
|
596
|
-
const t = typeof e == "string" ? e : e.id, o = E(t, n), s =
|
|
596
|
+
const t = typeof e == "string" ? e : e.id, o = E(t, n), s = C(n);
|
|
597
597
|
if (!o)
|
|
598
598
|
return;
|
|
599
599
|
const r = n.resolve(
|
|
@@ -603,7 +603,7 @@ function co(n, e) {
|
|
|
603
603
|
return b(r, s);
|
|
604
604
|
}
|
|
605
605
|
function lo(n, e) {
|
|
606
|
-
const t = typeof e == "string" ? e : e.id, o =
|
|
606
|
+
const t = typeof e == "string" ? e : e.id, o = C(n), s = E(t, n);
|
|
607
607
|
if (!s)
|
|
608
608
|
return;
|
|
609
609
|
const i = n.resolve(s.posBeforeNode), r = i.node(), c = i.node(-1), a = c.type.name !== "doc" ? r.type.name === "blockGroup" ? c : r : void 0;
|
|
@@ -619,7 +619,7 @@ class uo {
|
|
|
619
619
|
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
620
620
|
*/
|
|
621
621
|
get document() {
|
|
622
|
-
return this.editor.transact((e) =>
|
|
622
|
+
return this.editor.transact((e) => ze(e.doc, this.editor.pmSchema));
|
|
623
623
|
}
|
|
624
624
|
/**
|
|
625
625
|
* Gets a snapshot of an existing block from the editor.
|
|
@@ -707,7 +707,7 @@ class uo {
|
|
|
707
707
|
* @param update A partial block which defines how the existing block should be changed.
|
|
708
708
|
*/
|
|
709
709
|
updateBlock(e, t) {
|
|
710
|
-
return this.editor.transact((o) =>
|
|
710
|
+
return this.editor.transact((o) => Ye(o, e, t));
|
|
711
711
|
}
|
|
712
712
|
/**
|
|
713
713
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
@@ -740,7 +740,7 @@ class uo {
|
|
|
740
740
|
* Nests the block containing the text cursor into the block above it.
|
|
741
741
|
*/
|
|
742
742
|
nestBlock() {
|
|
743
|
-
|
|
743
|
+
Te(this.editor);
|
|
744
744
|
}
|
|
745
745
|
/**
|
|
746
746
|
* Checks if the block containing the text cursor is nested.
|
|
@@ -771,7 +771,7 @@ class uo {
|
|
|
771
771
|
return to(this.editor);
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
|
-
class po extends
|
|
774
|
+
class po extends Se {
|
|
775
775
|
constructor(e) {
|
|
776
776
|
super(), this.editor = e, e.on("create", () => {
|
|
777
777
|
e._tiptapEditor.on(
|
|
@@ -798,7 +798,7 @@ class po extends ye {
|
|
|
798
798
|
}) => {
|
|
799
799
|
!t && ae(s) || e(this.editor, {
|
|
800
800
|
getChanges() {
|
|
801
|
-
return
|
|
801
|
+
return ot(
|
|
802
802
|
s,
|
|
803
803
|
i
|
|
804
804
|
);
|
|
@@ -882,8 +882,8 @@ function bo(n) {
|
|
|
882
882
|
}
|
|
883
883
|
return mo(n), ko(n), n;
|
|
884
884
|
}
|
|
885
|
-
function
|
|
886
|
-
const t = bo(n), s =
|
|
885
|
+
function Pe(n, e) {
|
|
886
|
+
const t = bo(n), s = He.fromSchema(e).parse(t, {
|
|
887
887
|
topNode: e.nodes.blockGroup.create()
|
|
888
888
|
}), i = [];
|
|
889
889
|
for (let r = 0; r < s.childCount; r++)
|
|
@@ -922,21 +922,21 @@ function So(n, e) {
|
|
|
922
922
|
};
|
|
923
923
|
return (i = n.patch) == null || i.call(n, e, s), s = n.applyData ? n.applyData(e, s) : s, s;
|
|
924
924
|
}
|
|
925
|
-
function
|
|
925
|
+
function ve(n) {
|
|
926
926
|
return Rt().use(Ut).use(Vt).use(zt, {
|
|
927
927
|
handlers: {
|
|
928
928
|
...re,
|
|
929
929
|
image: (t, o) => {
|
|
930
930
|
const s = String((o == null ? void 0 : o.url) || "");
|
|
931
|
-
return
|
|
931
|
+
return qe(s) ? So(t, o) : re.image(t, o);
|
|
932
932
|
},
|
|
933
933
|
code: yo
|
|
934
934
|
}
|
|
935
935
|
}).use(Gt).processSync(n).value;
|
|
936
936
|
}
|
|
937
937
|
function Bo(n, e) {
|
|
938
|
-
const t =
|
|
939
|
-
return
|
|
938
|
+
const t = ve(n);
|
|
939
|
+
return Pe(t, e);
|
|
940
940
|
}
|
|
941
941
|
class Co {
|
|
942
942
|
constructor(e) {
|
|
@@ -978,7 +978,7 @@ class Co {
|
|
|
978
978
|
* @returns The blocks parsed from the HTML string.
|
|
979
979
|
*/
|
|
980
980
|
tryParseHTMLToBlocks(e) {
|
|
981
|
-
return
|
|
981
|
+
return Pe(e, this.editor.pmSchema);
|
|
982
982
|
}
|
|
983
983
|
/**
|
|
984
984
|
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
@@ -987,7 +987,7 @@ class Co {
|
|
|
987
987
|
* @returns The blocks, serialized as a Markdown string.
|
|
988
988
|
*/
|
|
989
989
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
990
|
-
return
|
|
990
|
+
return nt(e, this.editor.pmSchema, this.editor, {});
|
|
991
991
|
}
|
|
992
992
|
/**
|
|
993
993
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -1026,7 +1026,7 @@ class Co {
|
|
|
1026
1026
|
* @param markdown The markdown to paste.
|
|
1027
1027
|
*/
|
|
1028
1028
|
pasteMarkdown(e) {
|
|
1029
|
-
const t =
|
|
1029
|
+
const t = ve(e);
|
|
1030
1030
|
return this.pasteHTML(t);
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
@@ -1059,7 +1059,7 @@ function le(n, e, t, o = "after") {
|
|
|
1059
1059
|
o
|
|
1060
1060
|
)[0].id, s;
|
|
1061
1061
|
}
|
|
1062
|
-
async function
|
|
1062
|
+
async function Ie(n, e) {
|
|
1063
1063
|
var i;
|
|
1064
1064
|
if (!e.uploadFile) {
|
|
1065
1065
|
console.warn(
|
|
@@ -1114,7 +1114,8 @@ async function ve(n, e) {
|
|
|
1114
1114
|
if (!f)
|
|
1115
1115
|
return;
|
|
1116
1116
|
d = e.transact((k) => {
|
|
1117
|
-
|
|
1117
|
+
var S;
|
|
1118
|
+
const g = _(k.doc, f.pos), y = (S = e.domElement) == null ? void 0 : S.querySelector(
|
|
1118
1119
|
`[data-id="${g.node.attrs.id}"]`
|
|
1119
1120
|
), T = y == null ? void 0 : y.getBoundingClientRect();
|
|
1120
1121
|
return le(
|
|
@@ -1152,7 +1153,7 @@ const Mo = (n) => x.create({
|
|
|
1152
1153
|
o = s;
|
|
1153
1154
|
break;
|
|
1154
1155
|
}
|
|
1155
|
-
return o === null ? !0 : o === "Files" ? (
|
|
1156
|
+
return o === null ? !0 : o === "Files" ? (Ie(t, n), !0) : !1;
|
|
1156
1157
|
}
|
|
1157
1158
|
}
|
|
1158
1159
|
}
|
|
@@ -1203,7 +1204,7 @@ function Uo({
|
|
|
1203
1204
|
if (i === "vscode-editor-data")
|
|
1204
1205
|
return Vo(n, e.prosemirrorView), !0;
|
|
1205
1206
|
if (i === "Files")
|
|
1206
|
-
return
|
|
1207
|
+
return Ie(n, e), !0;
|
|
1207
1208
|
const r = n.clipboardData.getData(i);
|
|
1208
1209
|
if (i === "blocknote/html")
|
|
1209
1210
|
return e.pasteHTML(r, !0), !0;
|
|
@@ -1268,7 +1269,7 @@ function Go(n, e, t) {
|
|
|
1268
1269
|
);
|
|
1269
1270
|
if (s) {
|
|
1270
1271
|
((c = e.firstChild) == null ? void 0 : c.type.name) === "table" && (e = e.firstChild.content);
|
|
1271
|
-
const a =
|
|
1272
|
+
const a = Ge(
|
|
1272
1273
|
e,
|
|
1273
1274
|
t.schema.inlineContentSchema,
|
|
1274
1275
|
t.schema.styleSchema
|
|
@@ -1278,19 +1279,19 @@ function Go(n, e, t) {
|
|
|
1278
1279
|
{}
|
|
1279
1280
|
)}</table>`;
|
|
1280
1281
|
} else if (o) {
|
|
1281
|
-
const a =
|
|
1282
|
+
const a = Re(
|
|
1282
1283
|
e,
|
|
1283
1284
|
t.schema.inlineContentSchema,
|
|
1284
1285
|
t.schema.styleSchema
|
|
1285
1286
|
);
|
|
1286
1287
|
i = r.exportInlineContent(a, {});
|
|
1287
1288
|
} else {
|
|
1288
|
-
const a =
|
|
1289
|
+
const a = rt(e);
|
|
1289
1290
|
i = r.exportBlocks(a, {});
|
|
1290
1291
|
}
|
|
1291
1292
|
return i;
|
|
1292
1293
|
}
|
|
1293
|
-
function
|
|
1294
|
+
function Ae(n, e) {
|
|
1294
1295
|
"node" in n.state.selection && n.state.selection.node.type.spec.group === "blockContent" && e.transact(
|
|
1295
1296
|
(r) => r.setSelection(
|
|
1296
1297
|
new L(r.doc.resolve(n.state.selection.from - 1))
|
|
@@ -1302,7 +1303,7 @@ function Ie(n, e) {
|
|
|
1302
1303
|
n,
|
|
1303
1304
|
o,
|
|
1304
1305
|
e
|
|
1305
|
-
), i =
|
|
1306
|
+
), i = st(s);
|
|
1306
1307
|
return { clipboardHTML: t, externalHTML: s, markdown: i };
|
|
1307
1308
|
}
|
|
1308
1309
|
const de = () => {
|
|
@@ -1318,7 +1319,7 @@ const de = () => {
|
|
|
1318
1319
|
return !1;
|
|
1319
1320
|
}, ue = (n, e, t) => {
|
|
1320
1321
|
t.preventDefault(), t.clipboardData.clearData();
|
|
1321
|
-
const { clipboardHTML: o, externalHTML: s, markdown: i } =
|
|
1322
|
+
const { clipboardHTML: o, externalHTML: s, markdown: i } = Ae(
|
|
1322
1323
|
e,
|
|
1323
1324
|
n
|
|
1324
1325
|
);
|
|
@@ -1349,7 +1350,7 @@ const de = () => {
|
|
|
1349
1350
|
)
|
|
1350
1351
|
)
|
|
1351
1352
|
), t.preventDefault(), t.dataTransfer.clearData();
|
|
1352
|
-
const { clipboardHTML: o, externalHTML: s, markdown: i } =
|
|
1353
|
+
const { clipboardHTML: o, externalHTML: s, markdown: i } = Ae(e, n);
|
|
1353
1354
|
return t.dataTransfer.setData("blocknote/html", o), t.dataTransfer.setData("text/html", s), t.dataTransfer.setData("text/plain", i), !0;
|
|
1354
1355
|
}
|
|
1355
1356
|
}
|
|
@@ -1364,7 +1365,7 @@ const de = () => {
|
|
|
1364
1365
|
{
|
|
1365
1366
|
types: ["tableCell", "tableHeader"],
|
|
1366
1367
|
attributes: {
|
|
1367
|
-
backgroundColor:
|
|
1368
|
+
backgroundColor: Qe()
|
|
1368
1369
|
}
|
|
1369
1370
|
}
|
|
1370
1371
|
];
|
|
@@ -1394,7 +1395,7 @@ const de = () => {
|
|
|
1394
1395
|
return q(
|
|
1395
1396
|
n.resolve(s)
|
|
1396
1397
|
);
|
|
1397
|
-
},
|
|
1398
|
+
}, _e = (n, e) => {
|
|
1398
1399
|
for (; e.childContainer; ) {
|
|
1399
1400
|
const t = e.childContainer.node, o = n.resolve(e.childContainer.beforePos + 1).posAtIndex(t.childCount - 1);
|
|
1400
1401
|
e = q(n.resolve(o));
|
|
@@ -1439,7 +1440,7 @@ const de = () => {
|
|
|
1439
1440
|
);
|
|
1440
1441
|
if (!i)
|
|
1441
1442
|
return !1;
|
|
1442
|
-
const r =
|
|
1443
|
+
const r = _e(
|
|
1443
1444
|
e.doc,
|
|
1444
1445
|
i
|
|
1445
1446
|
);
|
|
@@ -1456,12 +1457,12 @@ const de = () => {
|
|
|
1456
1457
|
() => s.undoInputRule(),
|
|
1457
1458
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
1458
1459
|
() => s.command(({ state: i }) => {
|
|
1459
|
-
const r =
|
|
1460
|
+
const r = B(i);
|
|
1460
1461
|
if (!r.isBlockContainer)
|
|
1461
1462
|
return !1;
|
|
1462
1463
|
const c = i.selection.from === r.blockContent.beforePos + 1, a = r.blockContent.node.type.name === "paragraph";
|
|
1463
1464
|
return c && !a ? s.command(
|
|
1464
|
-
|
|
1465
|
+
Ze(r.bnBlock.beforePos, {
|
|
1465
1466
|
type: "paragraph",
|
|
1466
1467
|
props: {}
|
|
1467
1468
|
})
|
|
@@ -1469,7 +1470,7 @@ const de = () => {
|
|
|
1469
1470
|
}),
|
|
1470
1471
|
// Removes a level of nesting if the block is indented if the selection is at the start of the block.
|
|
1471
1472
|
() => s.command(({ state: i }) => {
|
|
1472
|
-
const r =
|
|
1473
|
+
const r = B(i);
|
|
1473
1474
|
if (!r.isBlockContainer)
|
|
1474
1475
|
return !1;
|
|
1475
1476
|
const { blockContent: c } = r;
|
|
@@ -1478,14 +1479,14 @@ const de = () => {
|
|
|
1478
1479
|
// Merges block with the previous one if it isn't indented, and the selection is at the start of the
|
|
1479
1480
|
// block. The target block for merging must contain inline content.
|
|
1480
1481
|
() => s.command(({ state: i }) => {
|
|
1481
|
-
const r =
|
|
1482
|
+
const r = B(i);
|
|
1482
1483
|
if (!r.isBlockContainer)
|
|
1483
1484
|
return !1;
|
|
1484
1485
|
const { bnBlock: c, blockContent: a } = r, l = i.selection.from === a.beforePos + 1, d = i.selection.empty, u = c.beforePos;
|
|
1485
1486
|
return l && d ? o().command(pe(u)).scrollIntoView().run() : !1;
|
|
1486
1487
|
}),
|
|
1487
1488
|
() => s.command(({ state: i, tr: r, dispatch: c }) => {
|
|
1488
|
-
const a =
|
|
1489
|
+
const a = B(i);
|
|
1489
1490
|
if (!a.isBlockContainer || !(r.selection.from === a.blockContent.beforePos + 1))
|
|
1490
1491
|
return !1;
|
|
1491
1492
|
const d = r.doc.resolve(a.bnBlock.beforePos);
|
|
@@ -1511,7 +1512,7 @@ const de = () => {
|
|
|
1511
1512
|
// Deletes the current block if it's an empty block with inline content,
|
|
1512
1513
|
// and moves the selection to the previous block.
|
|
1513
1514
|
() => s.command(({ state: i }) => {
|
|
1514
|
-
const r =
|
|
1515
|
+
const r = B(i);
|
|
1515
1516
|
if (!r.isBlockContainer)
|
|
1516
1517
|
return !1;
|
|
1517
1518
|
if (r.blockContent.node.childCount === 0 && r.blockContent.node.type.spec.content === "inline*") {
|
|
@@ -1547,7 +1548,7 @@ const de = () => {
|
|
|
1547
1548
|
// when the selection is empty and at the start of the block. Moves the
|
|
1548
1549
|
// current block into the deleted block's place.
|
|
1549
1550
|
() => s.command(({ state: i }) => {
|
|
1550
|
-
const r =
|
|
1551
|
+
const r = B(i);
|
|
1551
1552
|
if (!r.isBlockContainer)
|
|
1552
1553
|
throw new Error("todo");
|
|
1553
1554
|
const c = i.selection.from === r.blockContent.beforePos + 1, a = i.selection.empty, l = J(
|
|
@@ -1555,7 +1556,7 @@ const de = () => {
|
|
|
1555
1556
|
r.bnBlock.beforePos
|
|
1556
1557
|
);
|
|
1557
1558
|
if (l && c && a) {
|
|
1558
|
-
const d =
|
|
1559
|
+
const d = _e(
|
|
1559
1560
|
i.doc,
|
|
1560
1561
|
l
|
|
1561
1562
|
);
|
|
@@ -1582,7 +1583,7 @@ const de = () => {
|
|
|
1582
1583
|
// if one exists, the block has no children, and the selection is at the
|
|
1583
1584
|
// end of the block.
|
|
1584
1585
|
() => o.command(({ state: s }) => {
|
|
1585
|
-
const i =
|
|
1586
|
+
const i = B(s);
|
|
1586
1587
|
if (!i.isBlockContainer)
|
|
1587
1588
|
return !1;
|
|
1588
1589
|
const {
|
|
@@ -1602,7 +1603,7 @@ const de = () => {
|
|
|
1602
1603
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
1603
1604
|
// of the block.
|
|
1604
1605
|
() => s.command(({ state: r }) => {
|
|
1605
|
-
const c =
|
|
1606
|
+
const c = B(r);
|
|
1606
1607
|
if (!c.isBlockContainer)
|
|
1607
1608
|
return !1;
|
|
1608
1609
|
const { bnBlock: a, blockContent: l } = c, { depth: d } = r.doc.resolve(a.beforePos), u = r.selection.$anchor.parentOffset === 0, p = r.selection.anchor === r.selection.head, m = l.node.childCount === 0, f = d > 1;
|
|
@@ -1611,7 +1612,7 @@ const de = () => {
|
|
|
1611
1612
|
// Creates a hard break if block is configured to do so.
|
|
1612
1613
|
() => s.command(({ state: r }) => {
|
|
1613
1614
|
var l;
|
|
1614
|
-
const c =
|
|
1615
|
+
const c = B(r), a = ((l = this.options.editor.schema.blockSchema[c.blockNoteType].meta) == null ? void 0 : l.hardBreakShortcut) ?? "shift+enter";
|
|
1615
1616
|
if (a === "none")
|
|
1616
1617
|
return !1;
|
|
1617
1618
|
if (
|
|
@@ -1636,7 +1637,7 @@ const de = () => {
|
|
|
1636
1637
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1637
1638
|
// empty & at the start of the block.
|
|
1638
1639
|
() => s.command(({ state: r, dispatch: c }) => {
|
|
1639
|
-
const a =
|
|
1640
|
+
const a = B(r);
|
|
1640
1641
|
if (!a.isBlockContainer)
|
|
1641
1642
|
return !1;
|
|
1642
1643
|
const { bnBlock: l, blockContent: d } = a, u = r.selection.$anchor.parentOffset === 0, p = r.selection.anchor === r.selection.head, m = d.node.childCount === 0;
|
|
@@ -1655,12 +1656,12 @@ const de = () => {
|
|
|
1655
1656
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
1656
1657
|
// deletes the selection beforehand, if it's not empty.
|
|
1657
1658
|
() => s.command(({ state: r, chain: c }) => {
|
|
1658
|
-
const a =
|
|
1659
|
+
const a = B(r);
|
|
1659
1660
|
if (!a.isBlockContainer)
|
|
1660
1661
|
return !1;
|
|
1661
1662
|
const { blockContent: l } = a, d = r.selection.$anchor.parentOffset === 0;
|
|
1662
1663
|
return l.node.childCount === 0 ? !1 : (c().deleteSelection().command(
|
|
1663
|
-
|
|
1664
|
+
Xe(
|
|
1664
1665
|
r.selection.from,
|
|
1665
1666
|
d,
|
|
1666
1667
|
d
|
|
@@ -1677,7 +1678,7 @@ const de = () => {
|
|
|
1677
1678
|
// editor since the browser will try to use tab for keyboard navigation.
|
|
1678
1679
|
Tab: () => {
|
|
1679
1680
|
var o, s;
|
|
1680
|
-
return this.options.tabBehavior !== "prefer-indent" && ((o = this.options.editor.getExtension(R)) != null && o.store.state || ((s = this.options.editor.getExtension(G)) == null ? void 0 : s.store.state) !== void 0) ? !1 :
|
|
1681
|
+
return this.options.tabBehavior !== "prefer-indent" && ((o = this.options.editor.getExtension(R)) != null && o.store.state || ((s = this.options.editor.getExtension(G)) == null ? void 0 : s.store.state) !== void 0) ? !1 : Te(this.options.editor);
|
|
1681
1682
|
},
|
|
1682
1683
|
"Shift-Tab": () => {
|
|
1683
1684
|
var o, s;
|
|
@@ -1861,7 +1862,7 @@ const de = () => {
|
|
|
1861
1862
|
{
|
|
1862
1863
|
types: ["table", "tableCell", "tableHeader"],
|
|
1863
1864
|
attributes: {
|
|
1864
|
-
textColor:
|
|
1865
|
+
textColor: et()
|
|
1865
1866
|
}
|
|
1866
1867
|
}
|
|
1867
1868
|
];
|
|
@@ -2035,7 +2036,7 @@ function rn(n, e) {
|
|
|
2035
2036
|
function an(n, e) {
|
|
2036
2037
|
var o;
|
|
2037
2038
|
const t = [
|
|
2038
|
-
|
|
2039
|
+
ye(),
|
|
2039
2040
|
it(e),
|
|
2040
2041
|
G(e),
|
|
2041
2042
|
R(e),
|
|
@@ -2256,7 +2257,7 @@ class cn {
|
|
|
2256
2257
|
if (this.editor.schema.blockSchema[m.block.type].content !== "inline")
|
|
2257
2258
|
return null;
|
|
2258
2259
|
const f = H(a.tr), k = a.tr.deleteRange(d, u);
|
|
2259
|
-
return
|
|
2260
|
+
return tt(k, f.bnBlock.beforePos, p), k;
|
|
2260
2261
|
}
|
|
2261
2262
|
return null;
|
|
2262
2263
|
}))
|
|
@@ -2297,7 +2298,7 @@ class cn {
|
|
|
2297
2298
|
}
|
|
2298
2299
|
}
|
|
2299
2300
|
function ln(n) {
|
|
2300
|
-
const e =
|
|
2301
|
+
const e = C(n);
|
|
2301
2302
|
if (n.selection.empty || "node" in n.selection)
|
|
2302
2303
|
return;
|
|
2303
2304
|
const t = n.doc.resolve(
|
|
@@ -2333,7 +2334,7 @@ function ln(n) {
|
|
|
2333
2334
|
};
|
|
2334
2335
|
}
|
|
2335
2336
|
function dn(n, e, t) {
|
|
2336
|
-
const o = typeof e == "string" ? e : e.id, s = typeof t == "string" ? t : t.id, i =
|
|
2337
|
+
const o = typeof e == "string" ? e : e.id, s = typeof t == "string" ? t : t.id, i = C(n), r = ke(i);
|
|
2337
2338
|
if (o === s)
|
|
2338
2339
|
throw new Error(
|
|
2339
2340
|
`Attempting to set selection with the same anchor and head blocks (id ${o})`
|
|
@@ -2371,7 +2372,7 @@ function dn(n, e, t) {
|
|
|
2371
2372
|
n.setSelection(M.create(n.doc, m, f));
|
|
2372
2373
|
}
|
|
2373
2374
|
function un(n) {
|
|
2374
|
-
const e =
|
|
2375
|
+
const e = C(n);
|
|
2375
2376
|
let t = n.selection.$from, o = n.selection.$to;
|
|
2376
2377
|
for (; o.parentOffset >= o.parent.nodeSize - 2 && o.depth > 0; )
|
|
2377
2378
|
o = n.doc.resolve(o.pos + 1);
|
|
@@ -2381,7 +2382,7 @@ function un(n) {
|
|
|
2381
2382
|
t = n.doc.resolve(t.pos - 1);
|
|
2382
2383
|
for (; t.parentOffset >= t.parent.nodeSize - 2 && t.depth > 0; )
|
|
2383
2384
|
t = n.doc.resolve(t.pos + 1);
|
|
2384
|
-
const s =
|
|
2385
|
+
const s = je(
|
|
2385
2386
|
n.doc.slice(t.pos, o.pos, !0),
|
|
2386
2387
|
e
|
|
2387
2388
|
);
|
|
@@ -2394,7 +2395,7 @@ function un(n) {
|
|
|
2394
2395
|
};
|
|
2395
2396
|
}
|
|
2396
2397
|
function pn(n) {
|
|
2397
|
-
const { bnBlock: e } = H(n), t =
|
|
2398
|
+
const { bnBlock: e } = H(n), t = C(n.doc), o = n.doc.resolve(e.beforePos), s = o.nodeBefore, i = n.doc.resolve(e.afterPos).nodeAfter;
|
|
2398
2399
|
let r;
|
|
2399
2400
|
return o.depth > 1 && (r = o.node(), r.type.isInGroup("bnBlock") || (r = o.node(o.depth - 1))), {
|
|
2400
2401
|
block: b(e.node, t),
|
|
@@ -2403,8 +2404,8 @@ function pn(n) {
|
|
|
2403
2404
|
parentBlock: r === void 0 ? void 0 : b(r, t)
|
|
2404
2405
|
};
|
|
2405
2406
|
}
|
|
2406
|
-
function
|
|
2407
|
-
const o = typeof e == "string" ? e : e.id, s =
|
|
2407
|
+
function De(n, e, t = "start") {
|
|
2408
|
+
const o = typeof e == "string" ? e : e.id, s = C(n.doc), i = ke(s), r = E(o, n.doc);
|
|
2408
2409
|
if (!r)
|
|
2409
2410
|
throw new Error(`Block with ID ${o} not found`);
|
|
2410
2411
|
const c = z(r), a = i.blockSchema[c.blockNoteType].content;
|
|
@@ -2430,7 +2431,7 @@ function _e(n, e, t = "start") {
|
|
|
2430
2431
|
throw new F(a);
|
|
2431
2432
|
} else {
|
|
2432
2433
|
const l = t === "start" ? c.childContainer.node.firstChild : c.childContainer.node.lastChild;
|
|
2433
|
-
|
|
2434
|
+
De(n, l.attrs.id, t);
|
|
2434
2435
|
}
|
|
2435
2436
|
}
|
|
2436
2437
|
class fn {
|
|
@@ -2479,7 +2480,7 @@ class fn {
|
|
|
2479
2480
|
*/
|
|
2480
2481
|
setTextCursorPosition(e, t = "start") {
|
|
2481
2482
|
return this.editor.transact(
|
|
2482
|
-
(o) =>
|
|
2483
|
+
(o) => De(o, e, t)
|
|
2483
2484
|
);
|
|
2484
2485
|
}
|
|
2485
2486
|
/**
|
|
@@ -2858,7 +2859,7 @@ function Sn(n, e) {
|
|
|
2858
2859
|
if (o)
|
|
2859
2860
|
return !1;
|
|
2860
2861
|
if (s) {
|
|
2861
|
-
const c =
|
|
2862
|
+
const c = B(e.state);
|
|
2862
2863
|
if (c.isBlockContainer)
|
|
2863
2864
|
return !(c.blockContent.node.type.spec.content === "tableRow+");
|
|
2864
2865
|
}
|
|
@@ -2870,7 +2871,7 @@ const Bn = {
|
|
|
2870
2871
|
enablePasteRules: !0,
|
|
2871
2872
|
enableCoreExtensions: !1
|
|
2872
2873
|
};
|
|
2873
|
-
class
|
|
2874
|
+
class Le extends Se {
|
|
2874
2875
|
constructor(t) {
|
|
2875
2876
|
var l, d, u, p, m, f, k, g, y, T;
|
|
2876
2877
|
super();
|
|
@@ -2970,13 +2971,13 @@ class De extends ye {
|
|
|
2970
2971
|
}
|
|
2971
2972
|
};
|
|
2972
2973
|
if (this.schema = o.schema, this.blockImplementations = o.schema.blockSpecs, this.inlineContentImplementations = o.schema.inlineContentSpecs, this.styleImplementations = o.schema.styleSpecs, o.uploadFile) {
|
|
2973
|
-
const
|
|
2974
|
+
const S = o.uploadFile;
|
|
2974
2975
|
this.uploadFile = async (P, w) => {
|
|
2975
2976
|
this.onUploadStartCallbacks.forEach(
|
|
2976
2977
|
(v) => v.apply(this, [w])
|
|
2977
2978
|
);
|
|
2978
2979
|
try {
|
|
2979
|
-
return await
|
|
2980
|
+
return await S(P, w);
|
|
2980
2981
|
} finally {
|
|
2981
2982
|
this.onUploadEndCallbacks.forEach(
|
|
2982
2983
|
(v) => v.apply(this, [w])
|
|
@@ -3014,7 +3015,7 @@ class De extends ye {
|
|
|
3014
3015
|
}
|
|
3015
3016
|
};
|
|
3016
3017
|
try {
|
|
3017
|
-
const
|
|
3018
|
+
const S = o.initialContent || (i ? [
|
|
3018
3019
|
{
|
|
3019
3020
|
type: "paragraph",
|
|
3020
3021
|
id: "initialBlockId"
|
|
@@ -3025,12 +3026,12 @@ class De extends ye {
|
|
|
3025
3026
|
id: me.options.generateID()
|
|
3026
3027
|
}
|
|
3027
3028
|
]);
|
|
3028
|
-
if (!Array.isArray(
|
|
3029
|
+
if (!Array.isArray(S) || S.length === 0)
|
|
3029
3030
|
throw new Error(
|
|
3030
|
-
"initialContent must be a non-empty array of blocks, received: " +
|
|
3031
|
+
"initialContent must be a non-empty array of blocks, received: " + S
|
|
3031
3032
|
);
|
|
3032
|
-
const P = Pt(r.extensions), w =
|
|
3033
|
-
(
|
|
3033
|
+
const P = Pt(r.extensions), w = S.map(
|
|
3034
|
+
(Ne) => Y(Ne, P, this.schema.styleSchema).toJSON()
|
|
3034
3035
|
), v = vt(
|
|
3035
3036
|
{
|
|
3036
3037
|
type: "doc",
|
|
@@ -3048,23 +3049,23 @@ class De extends ye {
|
|
|
3048
3049
|
...r,
|
|
3049
3050
|
content: v.toJSON()
|
|
3050
3051
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
3051
|
-
} catch (
|
|
3052
|
+
} catch (S) {
|
|
3052
3053
|
throw new Error(
|
|
3053
3054
|
"Error creating document from blocks passed as `initialContent`",
|
|
3054
|
-
{ cause:
|
|
3055
|
+
{ cause: S }
|
|
3055
3056
|
);
|
|
3056
3057
|
}
|
|
3057
3058
|
let c;
|
|
3058
3059
|
const a = this.pmSchema.nodes.doc.createAndFill;
|
|
3059
|
-
this.pmSchema.nodes.doc.createAndFill = (...
|
|
3060
|
+
this.pmSchema.nodes.doc.createAndFill = (...S) => {
|
|
3060
3061
|
if (c)
|
|
3061
3062
|
return c;
|
|
3062
|
-
const P = a.apply(this.pmSchema.nodes.doc,
|
|
3063
|
-
return w.content[0].content[0].attrs.id = "initialBlockId", c =
|
|
3063
|
+
const P = a.apply(this.pmSchema.nodes.doc, S), w = JSON.parse(JSON.stringify(P.toJSON()));
|
|
3064
|
+
return w.content[0].content[0].attrs.id = "initialBlockId", c = $e.fromJSON(this.pmSchema, w), c;
|
|
3064
3065
|
}, this.pmSchema.cached.blockNoteEditor = this, this._blockManager = new uo(this), this._exportManager = new Co(this), this._selectionManager = new fn(this), this._stateManager = new hn(this), this._styleManager = new kn(this), this.emit("create");
|
|
3065
3066
|
}
|
|
3066
3067
|
static create(t) {
|
|
3067
|
-
return new
|
|
3068
|
+
return new Le(t ?? {});
|
|
3068
3069
|
}
|
|
3069
3070
|
/**
|
|
3070
3071
|
* BlockNote extensions that are added to the editor, keyed by the extension key
|
|
@@ -3161,7 +3162,8 @@ class De extends ye {
|
|
|
3161
3162
|
* Blur the editor
|
|
3162
3163
|
*/
|
|
3163
3164
|
blur() {
|
|
3164
|
-
|
|
3165
|
+
var t;
|
|
3166
|
+
this.headless || (t = this.domElement) == null || t.blur();
|
|
3165
3167
|
}
|
|
3166
3168
|
// TODO move to extension
|
|
3167
3169
|
onUploadStart(t) {
|
|
@@ -3258,6 +3260,15 @@ class De extends ye {
|
|
|
3258
3260
|
onEditorSelectionChange(t) {
|
|
3259
3261
|
this._tiptapEditor.on("selectionUpdate", t);
|
|
3260
3262
|
}
|
|
3263
|
+
/**
|
|
3264
|
+
* Executes a callback before any change is applied to the editor, allowing you to cancel the change.
|
|
3265
|
+
* @param callback The callback to execute.
|
|
3266
|
+
* @returns A function to remove the callback.
|
|
3267
|
+
*/
|
|
3268
|
+
onBeforeChange(t) {
|
|
3269
|
+
var o;
|
|
3270
|
+
return (o = this._extensionManager.getExtension(ye)) == null ? void 0 : o.subscribe(t);
|
|
3271
|
+
}
|
|
3261
3272
|
/**
|
|
3262
3273
|
* Gets a snapshot of the current text cursor position.
|
|
3263
3274
|
* @returns A snapshot of the current text cursor position.
|
|
@@ -3644,24 +3655,24 @@ function Qn(n, ...e) {
|
|
|
3644
3655
|
return t;
|
|
3645
3656
|
}
|
|
3646
3657
|
export {
|
|
3647
|
-
|
|
3658
|
+
Le as BlockNoteEditor,
|
|
3648
3659
|
Et as BlockNoteSchema,
|
|
3649
3660
|
ms as COLORS_DARK_MODE_DEFAULT,
|
|
3650
3661
|
ks as COLORS_DEFAULT,
|
|
3651
3662
|
Yr as CustomBlockNoteSchema,
|
|
3652
3663
|
gs as EMPTY_CELL_HEIGHT,
|
|
3653
3664
|
bs as EMPTY_CELL_WIDTH,
|
|
3654
|
-
|
|
3665
|
+
Se as EventEmitter,
|
|
3655
3666
|
Yn as Exporter,
|
|
3656
3667
|
ys as FILE_AUDIO_ICON_SVG,
|
|
3657
3668
|
Ss as FILE_IMAGE_ICON_SVG,
|
|
3658
3669
|
Bs as FILE_VIDEO_ICON_SVG,
|
|
3659
|
-
|
|
3670
|
+
Pe as HTMLToBlocks,
|
|
3660
3671
|
me as UniqueID,
|
|
3661
3672
|
F as UnreachableCaseError,
|
|
3662
3673
|
Cs as addDefaultPropsExternalHTML,
|
|
3663
3674
|
$ as addInlineContentAttributes,
|
|
3664
|
-
|
|
3675
|
+
We as addInlineContentKeyboardShortcuts,
|
|
3665
3676
|
Es as addNodeAndExtensionsToSpec,
|
|
3666
3677
|
xs as addStyleAttributes,
|
|
3667
3678
|
Ms as applyNonSelectableBlockFix,
|
|
@@ -3671,14 +3682,14 @@ export {
|
|
|
3671
3682
|
Ps as audioToExternalHTML,
|
|
3672
3683
|
vs as blockHasType,
|
|
3673
3684
|
Y as blockToNode,
|
|
3674
|
-
|
|
3685
|
+
nt as blocksToMarkdown,
|
|
3675
3686
|
Is as camelToDataKebab,
|
|
3676
3687
|
As as captureCellAnchor,
|
|
3677
3688
|
qr as checkPageBreakBlocksInSchema,
|
|
3678
|
-
|
|
3689
|
+
st as cleanHTMLToMarkdown,
|
|
3679
3690
|
Qn as combineByGroup,
|
|
3680
|
-
|
|
3681
|
-
|
|
3691
|
+
Re as contentNodeToInlineContent,
|
|
3692
|
+
Ge as contentNodeToTableContent,
|
|
3682
3693
|
_s as createAudioBlockConfig,
|
|
3683
3694
|
Ds as createAudioBlockSpec,
|
|
3684
3695
|
Ls as createBlockConfig,
|
|
@@ -3702,7 +3713,7 @@ export {
|
|
|
3702
3713
|
qs as createImageBlockConfig,
|
|
3703
3714
|
Qs as createImageBlockSpec,
|
|
3704
3715
|
Jn as createInlineContentSpec,
|
|
3705
|
-
|
|
3716
|
+
Je as createInlineContentSpecFromTipTapNode,
|
|
3706
3717
|
Qt as createInternalHTMLSerializer,
|
|
3707
3718
|
Xs as createInternalInlineContentSpec,
|
|
3708
3719
|
Zs as createInternalStyleSpec,
|
|
@@ -3731,24 +3742,24 @@ export {
|
|
|
3731
3742
|
yr as defaultStyleSchema,
|
|
3732
3743
|
Sr as defaultStyleSpecs,
|
|
3733
3744
|
Br as defaultToggledState,
|
|
3734
|
-
|
|
3745
|
+
ze as docToBlocks,
|
|
3735
3746
|
Cr as editorHasBlockWithType,
|
|
3736
3747
|
Er as fileParse,
|
|
3737
3748
|
xr as filenameFromURL,
|
|
3738
3749
|
W as fixColumnList,
|
|
3739
3750
|
Mr as formatKeyboardShortcut,
|
|
3740
|
-
|
|
3751
|
+
Qe as getBackgroundColorAttribute,
|
|
3741
3752
|
io as getBlock,
|
|
3742
3753
|
ts as getBlockCache,
|
|
3743
3754
|
wr as getBlockFromPos,
|
|
3744
3755
|
z as getBlockInfo,
|
|
3745
3756
|
q as getBlockInfoFromResolvedPos,
|
|
3746
|
-
|
|
3757
|
+
B as getBlockInfoFromSelection,
|
|
3747
3758
|
H as getBlockInfoFromTransaction,
|
|
3748
3759
|
os as getBlockInfoWithManualOffset,
|
|
3749
3760
|
ke as getBlockNoteSchema,
|
|
3750
3761
|
ns as getBlockSchema,
|
|
3751
|
-
|
|
3762
|
+
ot as getBlocksChangedByTransaction,
|
|
3752
3763
|
ss as getColspan,
|
|
3753
3764
|
Wt as getInlineContentParseRules,
|
|
3754
3765
|
rs as getInlineContentSchema,
|
|
@@ -3760,14 +3771,14 @@ export {
|
|
|
3760
3771
|
Zr as getPageBreakSlashMenuItems,
|
|
3761
3772
|
lo as getParentBlock,
|
|
3762
3773
|
vr as getParseRules,
|
|
3763
|
-
|
|
3774
|
+
C as getPmSchema,
|
|
3764
3775
|
ao as getPrevBlock,
|
|
3765
3776
|
is as getRowspan,
|
|
3766
3777
|
Ir as getStyleParseRules,
|
|
3767
3778
|
as as getStyleSchema,
|
|
3768
3779
|
Ar as getStyleSchemaFromSpecs,
|
|
3769
3780
|
_r as getTextAlignmentAttribute,
|
|
3770
|
-
|
|
3781
|
+
et as getTextColorAttribute,
|
|
3771
3782
|
Dr as imageParse,
|
|
3772
3783
|
Lr as imageRender,
|
|
3773
3784
|
Nr as imageToExternalHTML,
|
|
@@ -3783,29 +3794,29 @@ export {
|
|
|
3783
3794
|
us as isStyledTextInlineContent,
|
|
3784
3795
|
ps as isTableCell,
|
|
3785
3796
|
$r as isTableCellSelection,
|
|
3786
|
-
|
|
3797
|
+
qe as isVideoUrl,
|
|
3787
3798
|
fs as mapTableCell,
|
|
3788
3799
|
qn as mappingFactory,
|
|
3789
3800
|
Bo as markdownToBlocks,
|
|
3790
|
-
|
|
3801
|
+
ve as markdownToHTML,
|
|
3791
3802
|
Q as mergeCSSClasses,
|
|
3792
3803
|
Vr as mergeParagraphs,
|
|
3793
3804
|
b as nodeToBlock,
|
|
3794
3805
|
U as nodeToCustomInlineContent,
|
|
3795
3806
|
Ur as parseAudioElement,
|
|
3796
3807
|
zr as parseDefaultProps,
|
|
3797
|
-
|
|
3798
|
-
|
|
3808
|
+
Ke as propsToAttributes,
|
|
3809
|
+
je as prosemirrorSliceToSlicedBlocks,
|
|
3799
3810
|
ie as removeAndInsertBlocks,
|
|
3800
3811
|
Jt as removeEmptyColumns,
|
|
3801
|
-
|
|
3812
|
+
Ae as selectedFragmentToHTML,
|
|
3802
3813
|
Gr as stylePropsToAttributes,
|
|
3803
|
-
|
|
3814
|
+
Ue as tableContentToNodes,
|
|
3804
3815
|
Rr as tablePropSchema,
|
|
3805
3816
|
jr as trackPosition,
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3817
|
+
Ye as updateBlock,
|
|
3818
|
+
Ze as updateBlockCommand,
|
|
3819
|
+
tt as updateBlockTr,
|
|
3809
3820
|
ei as uploadToTmpFilesDotOrg_DEV_ONLY,
|
|
3810
3821
|
Wr as videoParse,
|
|
3811
3822
|
ti as withPageBreak,
|