@blocknote/core 0.47.3 → 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/BlockNoteExtension-B6RhuQ3V.js +27 -0
- package/dist/BlockNoteExtension-B6RhuQ3V.js.map +1 -0
- package/dist/BlockNoteExtension-ab0REuob.cjs +2 -0
- package/dist/BlockNoteExtension-ab0REuob.cjs.map +1 -0
- package/dist/EventEmitter-CuPnGDYt.js +22 -0
- package/dist/EventEmitter-CuPnGDYt.js.map +1 -0
- package/dist/EventEmitter-DHdSnYCD.cjs +2 -0
- package/dist/EventEmitter-DHdSnYCD.cjs.map +1 -0
- package/dist/ShowSelection-BsHFfdMi.js +29 -0
- package/dist/ShowSelection-BsHFfdMi.js.map +1 -0
- package/dist/ShowSelection-DhXglbt8.cjs +2 -0
- package/dist/ShowSelection-DhXglbt8.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -5
- package/dist/blocknote.js +7 -4256
- package/dist/blocks-BEvIOzln.cjs +11 -0
- package/dist/blocks-BEvIOzln.cjs.map +1 -0
- package/dist/blocks-DYl7UTS4.js +3313 -0
- package/dist/blocks-DYl7UTS4.js.map +1 -0
- package/dist/blocks.cjs +1 -2
- package/dist/blocks.js +2 -74
- package/dist/comments.cjs +2 -2
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +604 -900
- package/dist/comments.js.map +1 -1
- package/dist/en-C4ykW581.cjs +2 -0
- package/dist/en-C4ykW581.cjs.map +1 -0
- package/dist/en-QsSI16s5.js +453 -0
- package/dist/en-QsSI16s5.js.map +1 -0
- package/dist/extensions-3nf9PPhA.js +1495 -0
- package/dist/extensions-3nf9PPhA.js.map +1 -0
- package/dist/extensions-D9y6evn6.cjs +2 -0
- package/dist/extensions-D9y6evn6.cjs.map +1 -0
- package/dist/extensions.cjs +1 -2
- package/dist/extensions.js +4 -36
- package/dist/locales.cjs +2 -2
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +10049 -9111
- package/dist/locales.js.map +1 -1
- package/dist/src-BKJH7Jla.cjs +5 -0
- package/dist/src-BKJH7Jla.cjs.map +1 -0
- package/dist/src-Hjv1f5lc.js +2386 -0
- package/dist/src-Hjv1f5lc.js.map +1 -0
- package/dist/style.css +2 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +2 -2
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +20 -38
- package/dist/yjs.js.map +1 -1
- package/package.json +8 -8
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +15 -1
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +5 -0
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +1095 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +661 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +128 -11
- package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +17 -23
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +346 -0
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +143 -71
- package/src/editor/Block.css +5 -8
- package/src/editor/BlockNoteEditor.ts +38 -1
- package/src/editor/editor.css +0 -20
- package/src/editor/managers/ExtensionManager/extensions.ts +12 -1
- package/src/editor/performance.test.ts +134 -0
- package/src/extensions/Collaboration/ForkYDoc.test.ts +115 -103
- package/src/extensions/Placeholder/Placeholder.ts +1 -1
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +86 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +33 -49
- package/src/extensions/SideMenu/SideMenu.ts +14 -8
- package/src/extensions/TableHandles/TableHandles.ts +14 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +57 -17
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +9 -8
- package/src/index.ts +1 -1
- package/src/schema/blocks/createSpec.ts +6 -2
- package/src/schema/inlineContent/types.ts +0 -1
- package/src/vite-env.d.ts +6 -0
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +14 -1
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +1 -0
- package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +13 -0
- package/types/src/editor/performance.test.d.ts +1 -0
- package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -0
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs +0 -2
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +0 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js +0 -25
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +0 -1
- package/dist/BlockNoteSchema-CCs_V3lo.cjs +0 -2
- package/dist/BlockNoteSchema-CCs_V3lo.cjs.map +0 -1
- package/dist/BlockNoteSchema-ooiKsd5B.js +0 -270
- package/dist/BlockNoteSchema-ooiKsd5B.js.map +0 -1
- package/dist/EventEmitter-CLwfmbqG.cjs +0 -2
- package/dist/EventEmitter-CLwfmbqG.cjs.map +0 -1
- package/dist/EventEmitter-CjSwpTbz.js +0 -27
- package/dist/EventEmitter-CjSwpTbz.js.map +0 -1
- package/dist/ShowSelection-B0ch3unP.js +0 -51
- package/dist/ShowSelection-B0ch3unP.js.map +0 -1
- package/dist/ShowSelection-BxnbRvy4.cjs +0 -2
- package/dist/ShowSelection-BxnbRvy4.cjs.map +0 -1
- package/dist/TrailingNode-GzE59m_7.js +0 -2288
- package/dist/TrailingNode-GzE59m_7.js.map +0 -1
- package/dist/TrailingNode-n0WdMPUl.cjs +0 -2
- package/dist/TrailingNode-n0WdMPUl.cjs.map +0 -1
- package/dist/blockToNode-BNoNIXU7.js +0 -1140
- package/dist/blockToNode-BNoNIXU7.js.map +0 -1
- package/dist/blockToNode-CumVjgem.cjs +0 -7
- package/dist/blockToNode-CumVjgem.cjs.map +0 -1
- package/dist/blocknote.cjs.map +0 -1
- package/dist/blocknote.js.map +0 -1
- package/dist/blocks.cjs.map +0 -1
- package/dist/blocks.js.map +0 -1
- package/dist/defaultBlocks-Dg9kQWXm.cjs +0 -6
- package/dist/defaultBlocks-Dg9kQWXm.cjs.map +0 -1
- package/dist/defaultBlocks-ZzGbYgQn.js +0 -3284
- package/dist/defaultBlocks-ZzGbYgQn.js.map +0 -1
- package/dist/en-Cl87Uuyf.cjs +0 -2
- package/dist/en-Cl87Uuyf.cjs.map +0 -1
- package/dist/en-njEqD7AG.js +0 -408
- package/dist/en-njEqD7AG.js.map +0 -1
- package/dist/extensions.cjs.map +0 -1
- package/dist/extensions.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/blocknote.js
CHANGED
|
@@ -1,4256 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { ak as G, al as Je, am as Ye, an as Qe, aj as P, a as Xe, ao as Ze, ap as et, a5 as tt, a8 as J, aq as ot, ar as nt, a6 as st, as as ee, a9 as ge, at as rt } from "./defaultBlocks-ZzGbYgQn.js";
|
|
9
|
-
import { aw as Ls, av as _s, E as Ds, F as Os, r as $s, N as Hs, a4 as Fs, ad as Vs, aG as Us, ax as zs, b as Rs, d as Gs, e as Ws, a0 as js, aM as qs, au as Ks, c as Js, f as Ys, ag as Qs, ah as Xs, aB as Zs, x as er, y as tr, A as or, z as nr, g as sr, h as rr, T as ir, j as ar, k as cr, l as lr, n as dr, o as ur, q as pr, s as fr, w as hr, aC as mr, aH as kr, B as br, C as gr, H as Br, I as yr, J as Cr, K as Sr, aE as xr, aI as Er, M as Pr, D as Tr, G as wr, S as Mr, O as vr, Q as Ir, W as Ar, U as Nr, _ as Lr, Z as _r, a2 as Dr, Y as Or, X as $r, R as Hr, $ as Fr, m as Vr, aN as Ur, ac as zr, aK as Rr, az as Gr, ab as Wr, af as jr, i as qr, ay as Kr, aD as Jr, ae as Yr, a7 as Qr, t as Xr, u as Zr, v as ei, aa as ti, aJ as oi, ai as ni, aL as si, a1 as ri, V as ii, p as ai, a3 as ci, aF as li, L as di, aO as ui, P as pi, aA as fi } from "./defaultBlocks-ZzGbYgQn.js";
|
|
10
|
-
import { l as it, m as Be, n as at, o as ct, p as lt, d as Y, F as dt, Y as ut, a as pt, b as ft, S as ht, B as ye, c as mt, L as kt, N as bt, P as gt, h as Bt, k as yt, H as Ct, j as St, f as xt, V as Et, e as Pt } from "./TrailingNode-GzE59m_7.js";
|
|
11
|
-
import { D as mi, g as ki, T as bi, i as gi, s as Bi, t as yi } from "./TrailingNode-GzE59m_7.js";
|
|
12
|
-
import { s as Tt, B as wt } from "./BlockNoteSchema-ooiKsd5B.js";
|
|
13
|
-
import { C as Si, b as xi, c as Ei, a as Pi, g as Ti, u as wi, w as Mi } from "./BlockNoteSchema-ooiKsd5B.js";
|
|
14
|
-
import { Node as O, Extension as T, mergeAttributes as Mt, Mark as te, extensions as N, isNodeSelection as vt, posToDOMRect as It, selectionToInsertionEnd as At, findParentNodeClosestToPos as Nt, getSchema as Lt, createDocument as _t, Editor as Dt } from "@tiptap/core";
|
|
15
|
-
import { E as Ce } from "./EventEmitter-CjSwpTbz.js";
|
|
16
|
-
import { Fragment as R, Slice as W } from "@tiptap/pm/model";
|
|
17
|
-
import { e as Ot } from "./en-njEqD7AG.js";
|
|
18
|
-
import { inputRules as $t, InputRule as Ht } from "@handlewithcare/prosemirror-inputrules";
|
|
19
|
-
import { keymap as Ft } from "@tiptap/pm/keymap";
|
|
20
|
-
import { c as Vt, o as Ut } from "./BlockNoteExtension-C2X7LW-V.js";
|
|
21
|
-
import { a as Ii } from "./BlockNoteExtension-C2X7LW-V.js";
|
|
22
|
-
import { Gapcursor as zt } from "@tiptap/extensions/gap-cursor";
|
|
23
|
-
import { Link as Rt } from "@tiptap/extension-link";
|
|
24
|
-
import { Text as Gt } from "@tiptap/extension-text";
|
|
25
|
-
import { NodeSelection as $, TextSelection as S, Plugin as oe } from "prosemirror-state";
|
|
26
|
-
import { CellSelection as ne, TableMap as re } from "prosemirror-tables";
|
|
27
|
-
import { S as Wt } from "./ShowSelection-B0ch3unP.js";
|
|
28
|
-
import jt from "remark-gfm";
|
|
29
|
-
import qt from "remark-parse";
|
|
30
|
-
import Kt, { defaultHandlers as ie } from "remark-rehype";
|
|
31
|
-
import Jt from "rehype-stringify";
|
|
32
|
-
import { unified as Yt } from "unified";
|
|
33
|
-
import { TextSelection as Qt } from "@tiptap/pm/state";
|
|
34
|
-
function Xt(o, e) {
|
|
35
|
-
const t = [
|
|
36
|
-
{
|
|
37
|
-
tag: `[data-inline-content-type="${o.type}"]`,
|
|
38
|
-
contentElement: (n) => {
|
|
39
|
-
const s = n;
|
|
40
|
-
return s.matches("[data-editable]") ? s : s.querySelector("[data-editable]") || s;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
return e && t.push({
|
|
45
|
-
tag: "*",
|
|
46
|
-
getAttrs(n) {
|
|
47
|
-
if (typeof n == "string")
|
|
48
|
-
return !1;
|
|
49
|
-
const s = e == null ? void 0 : e(n);
|
|
50
|
-
return s === void 0 ? !1 : s;
|
|
51
|
-
}
|
|
52
|
-
}), t;
|
|
53
|
-
}
|
|
54
|
-
function ps(o, e) {
|
|
55
|
-
var n;
|
|
56
|
-
const t = O.create({
|
|
57
|
-
name: o.type,
|
|
58
|
-
inline: !0,
|
|
59
|
-
group: "inline",
|
|
60
|
-
draggable: (n = e.meta) == null ? void 0 : n.draggable,
|
|
61
|
-
selectable: o.content === "styled",
|
|
62
|
-
atom: o.content === "none",
|
|
63
|
-
content: o.content === "styled" ? "inline*" : "",
|
|
64
|
-
addAttributes() {
|
|
65
|
-
return Ye(o.propSchema);
|
|
66
|
-
},
|
|
67
|
-
addKeyboardShortcuts() {
|
|
68
|
-
return Je(o);
|
|
69
|
-
},
|
|
70
|
-
parseHTML() {
|
|
71
|
-
return Xt(
|
|
72
|
-
o,
|
|
73
|
-
e.parse
|
|
74
|
-
);
|
|
75
|
-
},
|
|
76
|
-
renderHTML({ node: s }) {
|
|
77
|
-
const r = this.options.editor, i = e.render.call(
|
|
78
|
-
{ renderType: "dom", props: void 0 },
|
|
79
|
-
q(
|
|
80
|
-
s,
|
|
81
|
-
r.schema.inlineContentSchema,
|
|
82
|
-
r.schema.styleSchema
|
|
83
|
-
),
|
|
84
|
-
// TODO: fix cast
|
|
85
|
-
() => {
|
|
86
|
-
},
|
|
87
|
-
r
|
|
88
|
-
);
|
|
89
|
-
return G(
|
|
90
|
-
i,
|
|
91
|
-
o.type,
|
|
92
|
-
s.attrs,
|
|
93
|
-
o.propSchema
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
addNodeView() {
|
|
97
|
-
return (s) => {
|
|
98
|
-
const { node: r, getPos: i } = s, l = this.options.editor, a = e.render.call(
|
|
99
|
-
{ renderType: "nodeView", props: s },
|
|
100
|
-
q(
|
|
101
|
-
r,
|
|
102
|
-
l.schema.inlineContentSchema,
|
|
103
|
-
l.schema.styleSchema
|
|
104
|
-
),
|
|
105
|
-
// TODO: fix cast
|
|
106
|
-
(c) => {
|
|
107
|
-
const d = V([c], l.pmSchema), u = i();
|
|
108
|
-
u && l.transact(
|
|
109
|
-
(p) => p.replaceWith(u, u + r.nodeSize, d)
|
|
110
|
-
);
|
|
111
|
-
},
|
|
112
|
-
l
|
|
113
|
-
);
|
|
114
|
-
return G(
|
|
115
|
-
a,
|
|
116
|
-
o.type,
|
|
117
|
-
r.attrs,
|
|
118
|
-
o.propSchema
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return Qe(
|
|
124
|
-
t,
|
|
125
|
-
o.propSchema,
|
|
126
|
-
{
|
|
127
|
-
...e,
|
|
128
|
-
toExternalHTML: e.toExternalHTML,
|
|
129
|
-
render(s, r, i) {
|
|
130
|
-
const l = e.render(
|
|
131
|
-
s,
|
|
132
|
-
r,
|
|
133
|
-
i
|
|
134
|
-
);
|
|
135
|
-
return G(
|
|
136
|
-
l,
|
|
137
|
-
o.type,
|
|
138
|
-
s.props,
|
|
139
|
-
o.propSchema
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
function Zt(o, e, t, n = "before") {
|
|
146
|
-
const s = typeof t == "string" ? t : t.id, r = E(o), i = e.map(
|
|
147
|
-
(d) => Z(d, r)
|
|
148
|
-
), l = P(s, o.doc);
|
|
149
|
-
if (!l)
|
|
150
|
-
throw new Error(`Block with ID ${s} not found`);
|
|
151
|
-
let a = l.posBeforeNode;
|
|
152
|
-
return n === "after" && (a += l.node.nodeSize), o.step(
|
|
153
|
-
new Re(a, a, new F(M.from(i), 0, 0))
|
|
154
|
-
), i.map(
|
|
155
|
-
(d) => C(d, r)
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
function Q(o) {
|
|
159
|
-
if (!o || o.type.name !== "column")
|
|
160
|
-
throw new Error("Invalid columnPos: does not point to column node.");
|
|
161
|
-
const e = o.firstChild;
|
|
162
|
-
if (!e)
|
|
163
|
-
throw new Error("Invalid column: does not have child node.");
|
|
164
|
-
const t = e.firstChild;
|
|
165
|
-
if (!t)
|
|
166
|
-
throw new Error("Invalid blockContainer: does not have child node.");
|
|
167
|
-
return o.childCount === 1 && e.childCount === 1 && t.type.name === "paragraph" && t.content.content.length === 0;
|
|
168
|
-
}
|
|
169
|
-
function eo(o, e) {
|
|
170
|
-
const t = o.doc.resolve(e), n = t.nodeAfter;
|
|
171
|
-
if (!n || n.type.name !== "columnList")
|
|
172
|
-
throw new Error(
|
|
173
|
-
"Invalid columnListPos: does not point to columnList node."
|
|
174
|
-
);
|
|
175
|
-
for (let s = n.childCount - 1; s >= 0; s--) {
|
|
176
|
-
const r = o.doc.resolve(t.pos + 1).posAtIndex(s), l = o.doc.resolve(r).nodeAfter;
|
|
177
|
-
if (!l || l.type.name !== "column")
|
|
178
|
-
throw new Error("Invalid columnPos: does not point to column node.");
|
|
179
|
-
Q(l) && o.delete(r, r + l.nodeSize);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
function H(o, e) {
|
|
183
|
-
eo(o, e);
|
|
184
|
-
const n = o.doc.resolve(e).nodeAfter;
|
|
185
|
-
if (!n || n.type.name !== "columnList")
|
|
186
|
-
throw new Error(
|
|
187
|
-
"Invalid columnListPos: does not point to columnList node."
|
|
188
|
-
);
|
|
189
|
-
if (n.childCount > 2)
|
|
190
|
-
return;
|
|
191
|
-
if (n.childCount < 2)
|
|
192
|
-
throw new Error("Invalid columnList: contains fewer than two children.");
|
|
193
|
-
const s = e + 1, i = o.doc.resolve(s).nodeAfter, l = e + n.nodeSize - 1, c = o.doc.resolve(l).nodeBefore;
|
|
194
|
-
if (!i || !c)
|
|
195
|
-
throw new Error("Invalid columnList: does not contain children.");
|
|
196
|
-
const d = Q(i), u = Q(c);
|
|
197
|
-
if (d && u) {
|
|
198
|
-
o.delete(e, e + n.nodeSize);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (d) {
|
|
202
|
-
o.step(
|
|
203
|
-
new j(
|
|
204
|
-
// Replaces `columnList`.
|
|
205
|
-
e,
|
|
206
|
-
e + n.nodeSize,
|
|
207
|
-
// Replaces with content of last `column`.
|
|
208
|
-
l - c.nodeSize + 1,
|
|
209
|
-
l - 1,
|
|
210
|
-
// Doesn't append anything.
|
|
211
|
-
F.empty,
|
|
212
|
-
0,
|
|
213
|
-
!1
|
|
214
|
-
)
|
|
215
|
-
);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (u) {
|
|
219
|
-
o.step(
|
|
220
|
-
new j(
|
|
221
|
-
// Replaces `columnList`.
|
|
222
|
-
e,
|
|
223
|
-
e + n.nodeSize,
|
|
224
|
-
// Replaces with content of first `column`.
|
|
225
|
-
s + 1,
|
|
226
|
-
s + i.nodeSize - 1,
|
|
227
|
-
// Doesn't append anything.
|
|
228
|
-
F.empty,
|
|
229
|
-
0,
|
|
230
|
-
!1
|
|
231
|
-
)
|
|
232
|
-
);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
function ae(o, e, t) {
|
|
237
|
-
const n = E(o), s = t.map(
|
|
238
|
-
(u) => Z(u, n)
|
|
239
|
-
), r = new Set(
|
|
240
|
-
e.map(
|
|
241
|
-
(u) => typeof u == "string" ? u : u.id
|
|
242
|
-
)
|
|
243
|
-
), i = [], l = /* @__PURE__ */ new Set(), a = typeof e[0] == "string" ? e[0] : e[0].id;
|
|
244
|
-
let c = 0;
|
|
245
|
-
if (o.doc.descendants((u, p) => {
|
|
246
|
-
if (r.size === 0)
|
|
247
|
-
return !1;
|
|
248
|
-
if (!u.type.isInGroup("bnBlock") || !r.has(u.attrs.id))
|
|
249
|
-
return !0;
|
|
250
|
-
if (i.push(C(u, n)), r.delete(u.attrs.id), t.length > 0 && u.attrs.id === a) {
|
|
251
|
-
const b = o.doc.nodeSize;
|
|
252
|
-
o.insert(p, s);
|
|
253
|
-
const g = o.doc.nodeSize;
|
|
254
|
-
c += b - g;
|
|
255
|
-
}
|
|
256
|
-
const h = o.doc.nodeSize, f = o.doc.resolve(p - c);
|
|
257
|
-
f.node().type.name === "column" ? l.add(f.before(-1)) : f.node().type.name === "columnList" && l.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ? o.delete(f.before(), f.after()) : o.delete(p - c, p - c + u.nodeSize);
|
|
258
|
-
const m = o.doc.nodeSize;
|
|
259
|
-
return c += h - m, !1;
|
|
260
|
-
}), r.size > 0) {
|
|
261
|
-
const u = [...r].join(`
|
|
262
|
-
`);
|
|
263
|
-
throw Error(
|
|
264
|
-
"Blocks with the following IDs could not be found in the editor: " + u
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
return l.forEach((u) => H(o, u)), { insertedBlocks: s.map(
|
|
268
|
-
(u) => C(u, n)
|
|
269
|
-
), removedBlocks: i };
|
|
270
|
-
}
|
|
271
|
-
function to(o, e, t, n, s) {
|
|
272
|
-
let r;
|
|
273
|
-
if (e)
|
|
274
|
-
if (typeof e == "string")
|
|
275
|
-
r = V([e], o.pmSchema, n);
|
|
276
|
-
else if (Array.isArray(e))
|
|
277
|
-
r = V(e, o.pmSchema, n);
|
|
278
|
-
else if (e.type === "tableContent")
|
|
279
|
-
r = Ge(e, o.pmSchema);
|
|
280
|
-
else
|
|
281
|
-
throw new U(e.type);
|
|
282
|
-
else throw new Error("blockContent is required");
|
|
283
|
-
const l = ((s == null ? void 0 : s.document) ?? document).createDocumentFragment();
|
|
284
|
-
for (const a of r)
|
|
285
|
-
if (a.type.name !== "text" && o.schema.inlineContentSchema[a.type.name]) {
|
|
286
|
-
const c = o.schema.inlineContentSpecs[a.type.name].implementation;
|
|
287
|
-
if (c) {
|
|
288
|
-
const d = q(
|
|
289
|
-
a,
|
|
290
|
-
o.schema.inlineContentSchema,
|
|
291
|
-
o.schema.styleSchema
|
|
292
|
-
), u = c.render.call(
|
|
293
|
-
{
|
|
294
|
-
renderType: "dom",
|
|
295
|
-
props: void 0
|
|
296
|
-
},
|
|
297
|
-
d,
|
|
298
|
-
() => {
|
|
299
|
-
},
|
|
300
|
-
o
|
|
301
|
-
);
|
|
302
|
-
if (u) {
|
|
303
|
-
if (l.appendChild(u.dom), u.contentDOM) {
|
|
304
|
-
const p = t.serializeFragment(
|
|
305
|
-
a.content,
|
|
306
|
-
s
|
|
307
|
-
);
|
|
308
|
-
u.contentDOM.dataset.editable = "", u.contentDOM.appendChild(p);
|
|
309
|
-
}
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
} else if (a.type.name === "text") {
|
|
314
|
-
let c = document.createTextNode(
|
|
315
|
-
a.textContent
|
|
316
|
-
);
|
|
317
|
-
for (const d of a.marks.toReversed())
|
|
318
|
-
if (d.type.name in o.schema.styleSpecs) {
|
|
319
|
-
const u = o.schema.styleSpecs[d.type.name].implementation.render(d.attrs.stringValue, o);
|
|
320
|
-
u.contentDOM.appendChild(c), c = u.dom;
|
|
321
|
-
} else {
|
|
322
|
-
const u = d.type.spec.toDOM(d, !0), p = me.renderSpec(document, u);
|
|
323
|
-
p.contentDOM.appendChild(c), c = p.dom;
|
|
324
|
-
}
|
|
325
|
-
l.appendChild(c);
|
|
326
|
-
} else {
|
|
327
|
-
const c = t.serializeFragment(
|
|
328
|
-
M.from([a]),
|
|
329
|
-
s
|
|
330
|
-
);
|
|
331
|
-
l.appendChild(c);
|
|
332
|
-
}
|
|
333
|
-
return l;
|
|
334
|
-
}
|
|
335
|
-
function oo(o, e, t, n) {
|
|
336
|
-
var u, p, h, f, m;
|
|
337
|
-
const s = o.pmSchema.nodes.blockContainer, r = e.props || {};
|
|
338
|
-
for (const [b, g] of Object.entries(
|
|
339
|
-
o.schema.blockSchema[e.type].propSchema
|
|
340
|
-
))
|
|
341
|
-
!(b in r) && g.default !== void 0 && (r[b] = g.default);
|
|
342
|
-
const i = e.children || [], a = o.blockImplementations[e.type].implementation.render.call(
|
|
343
|
-
{
|
|
344
|
-
renderType: "dom",
|
|
345
|
-
props: void 0
|
|
346
|
-
},
|
|
347
|
-
{ ...e, props: r, children: i },
|
|
348
|
-
o
|
|
349
|
-
);
|
|
350
|
-
if (a.contentDOM && e.content) {
|
|
351
|
-
const b = to(
|
|
352
|
-
o,
|
|
353
|
-
e.content,
|
|
354
|
-
// TODO
|
|
355
|
-
t,
|
|
356
|
-
e.type,
|
|
357
|
-
n
|
|
358
|
-
);
|
|
359
|
-
a.contentDOM.appendChild(b);
|
|
360
|
-
}
|
|
361
|
-
if (o.pmSchema.nodes[e.type].isInGroup("bnBlock")) {
|
|
362
|
-
if (e.children && e.children.length > 0) {
|
|
363
|
-
const b = Se(
|
|
364
|
-
o,
|
|
365
|
-
e.children,
|
|
366
|
-
t,
|
|
367
|
-
n
|
|
368
|
-
);
|
|
369
|
-
(u = a.contentDOM) == null || u.append(b);
|
|
370
|
-
}
|
|
371
|
-
return a.dom;
|
|
372
|
-
}
|
|
373
|
-
const d = (h = (p = s.spec) == null ? void 0 : p.toDOM) == null ? void 0 : h.call(
|
|
374
|
-
p,
|
|
375
|
-
s.create({
|
|
376
|
-
id: e.id,
|
|
377
|
-
...r
|
|
378
|
-
})
|
|
379
|
-
);
|
|
380
|
-
return (f = d.contentDOM) == null || f.appendChild(a.dom), e.children && e.children.length > 0 && ((m = d.contentDOM) == null || m.appendChild(
|
|
381
|
-
xe(o, e.children, t, n)
|
|
382
|
-
)), d.dom;
|
|
383
|
-
}
|
|
384
|
-
function Se(o, e, t, n) {
|
|
385
|
-
const r = ((n == null ? void 0 : n.document) ?? document).createDocumentFragment();
|
|
386
|
-
for (const i of e) {
|
|
387
|
-
const l = oo(o, i, t, n);
|
|
388
|
-
r.appendChild(l);
|
|
389
|
-
}
|
|
390
|
-
return r;
|
|
391
|
-
}
|
|
392
|
-
const xe = (o, e, t, n) => {
|
|
393
|
-
var l;
|
|
394
|
-
const s = o.pmSchema.nodes.blockGroup, r = s.spec.toDOM(s.create({})), i = Se(o, e, t, n);
|
|
395
|
-
return (l = r.contentDOM) == null || l.appendChild(i), r.dom;
|
|
396
|
-
}, no = (o) => (o.querySelectorAll(
|
|
397
|
-
'[data-content-type="numberedListItem"]'
|
|
398
|
-
).forEach((t) => {
|
|
399
|
-
var s, r;
|
|
400
|
-
const n = (r = (s = t.closest(".bn-block-outer")) == null ? void 0 : s.previousElementSibling) == null ? void 0 : r.querySelector(
|
|
401
|
-
'[data-content-type="numberedListItem"]'
|
|
402
|
-
);
|
|
403
|
-
if (!n)
|
|
404
|
-
t.setAttribute(
|
|
405
|
-
"data-index",
|
|
406
|
-
t.getAttribute("data-start") || "1"
|
|
407
|
-
);
|
|
408
|
-
else {
|
|
409
|
-
const i = n.getAttribute("data-index");
|
|
410
|
-
t.setAttribute(
|
|
411
|
-
"data-index",
|
|
412
|
-
(parseInt(i || "0") + 1).toString()
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
}), o), so = (o) => (o.querySelectorAll(
|
|
416
|
-
'[data-content-type="checkListItem"] input'
|
|
417
|
-
).forEach((t) => {
|
|
418
|
-
t.disabled = !0;
|
|
419
|
-
}), o), ro = (o) => (o.querySelectorAll(
|
|
420
|
-
'.bn-toggle-wrapper[data-show-children="false"]'
|
|
421
|
-
).forEach((t) => {
|
|
422
|
-
t.setAttribute("data-show-children", "true");
|
|
423
|
-
}), o), io = (o) => (o.querySelectorAll('[data-content-type="table"] table').forEach((t) => {
|
|
424
|
-
t.setAttribute(
|
|
425
|
-
"style",
|
|
426
|
-
`--default-cell-min-width: ${Xe}px;`
|
|
427
|
-
), t.setAttribute("data-show-children", "true");
|
|
428
|
-
}), o), ao = (o) => (o.querySelectorAll('[data-content-type="table"] table').forEach((t) => {
|
|
429
|
-
var r;
|
|
430
|
-
const n = document.createElement("div");
|
|
431
|
-
n.className = "tableWrapper";
|
|
432
|
-
const s = document.createElement("div");
|
|
433
|
-
s.className = "tableWrapper-inner", n.appendChild(s), (r = t.parentElement) == null || r.appendChild(n), n.appendChild(t);
|
|
434
|
-
}), o), co = (o) => (o.querySelectorAll(
|
|
435
|
-
".bn-inline-content:empty"
|
|
436
|
-
).forEach((t) => {
|
|
437
|
-
const n = document.createElement("span");
|
|
438
|
-
n.className = "ProseMirror-trailingBreak", n.setAttribute("style", "display: inline-block;"), t.appendChild(n);
|
|
439
|
-
}), o), lo = (o, e) => {
|
|
440
|
-
const t = me.fromSchema(o), n = [
|
|
441
|
-
no,
|
|
442
|
-
so,
|
|
443
|
-
ro,
|
|
444
|
-
io,
|
|
445
|
-
ao,
|
|
446
|
-
co
|
|
447
|
-
];
|
|
448
|
-
return {
|
|
449
|
-
serializeBlocks: (s, r) => {
|
|
450
|
-
let i = xe(
|
|
451
|
-
e,
|
|
452
|
-
s,
|
|
453
|
-
t,
|
|
454
|
-
r
|
|
455
|
-
);
|
|
456
|
-
for (const l of n)
|
|
457
|
-
i = l(i);
|
|
458
|
-
return i.outerHTML;
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
};
|
|
462
|
-
function uo(o) {
|
|
463
|
-
return o.transact((e) => {
|
|
464
|
-
const t = D(e.doc, e.selection.anchor);
|
|
465
|
-
if (e.selection instanceof ne)
|
|
466
|
-
return {
|
|
467
|
-
type: "cell",
|
|
468
|
-
anchorBlockId: t.node.attrs.id,
|
|
469
|
-
anchorCellOffset: e.selection.$anchorCell.pos - t.posBeforeNode,
|
|
470
|
-
headCellOffset: e.selection.$headCell.pos - t.posBeforeNode
|
|
471
|
-
};
|
|
472
|
-
if (e.selection instanceof $)
|
|
473
|
-
return {
|
|
474
|
-
type: "node",
|
|
475
|
-
anchorBlockId: t.node.attrs.id
|
|
476
|
-
};
|
|
477
|
-
{
|
|
478
|
-
const n = D(e.doc, e.selection.head);
|
|
479
|
-
return {
|
|
480
|
-
type: "text",
|
|
481
|
-
anchorBlockId: t.node.attrs.id,
|
|
482
|
-
headBlockId: n.node.attrs.id,
|
|
483
|
-
anchorOffset: e.selection.anchor - t.posBeforeNode,
|
|
484
|
-
headOffset: e.selection.head - n.posBeforeNode
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
function po(o, e) {
|
|
490
|
-
var s, r;
|
|
491
|
-
const t = (s = P(e.anchorBlockId, o.doc)) == null ? void 0 : s.posBeforeNode;
|
|
492
|
-
if (t === void 0)
|
|
493
|
-
throw new Error(
|
|
494
|
-
`Could not find block with ID ${e.anchorBlockId} to update selection`
|
|
495
|
-
);
|
|
496
|
-
let n;
|
|
497
|
-
if (e.type === "cell")
|
|
498
|
-
n = ne.create(
|
|
499
|
-
o.doc,
|
|
500
|
-
t + e.anchorCellOffset,
|
|
501
|
-
t + e.headCellOffset
|
|
502
|
-
);
|
|
503
|
-
else if (e.type === "node")
|
|
504
|
-
n = $.create(o.doc, t + 1);
|
|
505
|
-
else {
|
|
506
|
-
const i = (r = P(e.headBlockId, o.doc)) == null ? void 0 : r.posBeforeNode;
|
|
507
|
-
if (i === void 0)
|
|
508
|
-
throw new Error(
|
|
509
|
-
`Could not find block with ID ${e.headBlockId} to update selection`
|
|
510
|
-
);
|
|
511
|
-
n = S.create(
|
|
512
|
-
o.doc,
|
|
513
|
-
t + e.anchorOffset,
|
|
514
|
-
i + e.headOffset
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
o.setSelection(n);
|
|
518
|
-
}
|
|
519
|
-
function X(o) {
|
|
520
|
-
return o.map((e) => e.type === "columnList" ? e.children.map((t) => X(t.children)).flat() : {
|
|
521
|
-
...e,
|
|
522
|
-
children: X(e.children)
|
|
523
|
-
}).flat();
|
|
524
|
-
}
|
|
525
|
-
function Ee(o, e, t) {
|
|
526
|
-
o.transact((n) => {
|
|
527
|
-
var i;
|
|
528
|
-
const s = ((i = o.getSelection()) == null ? void 0 : i.blocks) || [
|
|
529
|
-
o.getTextCursorPosition().block
|
|
530
|
-
], r = uo(o);
|
|
531
|
-
o.removeBlocks(s), o.insertBlocks(X(s), e, t), po(n, r);
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
function Pe(o) {
|
|
535
|
-
return !o || o.type !== "columnList";
|
|
536
|
-
}
|
|
537
|
-
function Te(o, e, t) {
|
|
538
|
-
let n, s;
|
|
539
|
-
if (e ? e.children.length > 0 ? (n = e.children[e.children.length - 1], s = "after") : (n = e, s = "before") : t && (n = t, s = "before"), !n || !s)
|
|
540
|
-
return;
|
|
541
|
-
const r = o.getParentBlock(n);
|
|
542
|
-
return Pe(r) ? { referenceBlock: n, placement: s } : Te(
|
|
543
|
-
o,
|
|
544
|
-
s === "after" ? n : o.getPrevBlock(n),
|
|
545
|
-
r
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
function we(o, e, t) {
|
|
549
|
-
let n, s;
|
|
550
|
-
if (e ? e.children.length > 0 ? (n = e.children[0], s = "before") : (n = e, s = "after") : t && (n = t, s = "after"), !n || !s)
|
|
551
|
-
return;
|
|
552
|
-
const r = o.getParentBlock(n);
|
|
553
|
-
return Pe(r) ? { referenceBlock: n, placement: s } : we(
|
|
554
|
-
o,
|
|
555
|
-
s === "before" ? n : o.getNextBlock(n),
|
|
556
|
-
r
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
function fo(o) {
|
|
560
|
-
o.transact(() => {
|
|
561
|
-
const e = o.getSelection(), t = (e == null ? void 0 : e.blocks[0]) || o.getTextCursorPosition().block, n = Te(
|
|
562
|
-
o,
|
|
563
|
-
o.getPrevBlock(t),
|
|
564
|
-
o.getParentBlock(t)
|
|
565
|
-
);
|
|
566
|
-
n && Ee(
|
|
567
|
-
o,
|
|
568
|
-
n.referenceBlock,
|
|
569
|
-
n.placement
|
|
570
|
-
);
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
function ho(o) {
|
|
574
|
-
o.transact(() => {
|
|
575
|
-
const e = o.getSelection(), t = (e == null ? void 0 : e.blocks[(e == null ? void 0 : e.blocks.length) - 1]) || o.getTextCursorPosition().block, n = we(
|
|
576
|
-
o,
|
|
577
|
-
o.getNextBlock(t),
|
|
578
|
-
o.getParentBlock(t)
|
|
579
|
-
);
|
|
580
|
-
n && Ee(
|
|
581
|
-
o,
|
|
582
|
-
n.referenceBlock,
|
|
583
|
-
n.placement
|
|
584
|
-
);
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
function mo(o, e, t) {
|
|
588
|
-
const { $from: n, $to: s } = o.selection, r = n.blockRange(
|
|
589
|
-
s,
|
|
590
|
-
(f) => f.childCount > 0 && (f.type.name === "blockGroup" || f.type.name === "column")
|
|
591
|
-
// change necessary to not look at first item child type
|
|
592
|
-
);
|
|
593
|
-
if (!r)
|
|
594
|
-
return !1;
|
|
595
|
-
const i = r.startIndex;
|
|
596
|
-
if (i === 0)
|
|
597
|
-
return !1;
|
|
598
|
-
const a = r.parent.child(i - 1);
|
|
599
|
-
if (a.type !== e)
|
|
600
|
-
return !1;
|
|
601
|
-
const c = a.lastChild && a.lastChild.type === t, d = M.from(c ? e.create() : null), u = new F(
|
|
602
|
-
M.from(
|
|
603
|
-
e.create(null, M.from(t.create(null, d)))
|
|
604
|
-
// change necessary to create "groupType" instead of parent.type
|
|
605
|
-
),
|
|
606
|
-
c ? 3 : 1,
|
|
607
|
-
0
|
|
608
|
-
), p = r.start, h = r.end;
|
|
609
|
-
return o.step(
|
|
610
|
-
new j(
|
|
611
|
-
p - (c ? 3 : 1),
|
|
612
|
-
h,
|
|
613
|
-
p,
|
|
614
|
-
h,
|
|
615
|
-
u,
|
|
616
|
-
1,
|
|
617
|
-
!0
|
|
618
|
-
)
|
|
619
|
-
).scrollIntoView(), !0;
|
|
620
|
-
}
|
|
621
|
-
function Me(o) {
|
|
622
|
-
return o.transact((e) => mo(
|
|
623
|
-
e,
|
|
624
|
-
o.pmSchema.nodes.blockContainer,
|
|
625
|
-
o.pmSchema.nodes.blockGroup
|
|
626
|
-
));
|
|
627
|
-
}
|
|
628
|
-
function ko(o) {
|
|
629
|
-
o._tiptapEditor.commands.liftListItem("blockContainer");
|
|
630
|
-
}
|
|
631
|
-
function bo(o) {
|
|
632
|
-
return o.transact((e) => {
|
|
633
|
-
const { bnBlock: t } = z(e);
|
|
634
|
-
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
function go(o) {
|
|
638
|
-
return o.transact((e) => {
|
|
639
|
-
const { bnBlock: t } = z(e);
|
|
640
|
-
return e.doc.resolve(t.beforePos).depth > 1;
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
function Bo(o, e) {
|
|
644
|
-
const t = typeof e == "string" ? e : e.id, n = E(o), s = P(t, o);
|
|
645
|
-
if (s)
|
|
646
|
-
return C(s.node, n);
|
|
647
|
-
}
|
|
648
|
-
function yo(o, e) {
|
|
649
|
-
const t = typeof e == "string" ? e : e.id, n = P(t, o), s = E(o);
|
|
650
|
-
if (!n)
|
|
651
|
-
return;
|
|
652
|
-
const i = o.resolve(n.posBeforeNode).nodeBefore;
|
|
653
|
-
if (i)
|
|
654
|
-
return C(i, s);
|
|
655
|
-
}
|
|
656
|
-
function Co(o, e) {
|
|
657
|
-
const t = typeof e == "string" ? e : e.id, n = P(t, o), s = E(o);
|
|
658
|
-
if (!n)
|
|
659
|
-
return;
|
|
660
|
-
const i = o.resolve(
|
|
661
|
-
n.posBeforeNode + n.node.nodeSize
|
|
662
|
-
).nodeAfter;
|
|
663
|
-
if (i)
|
|
664
|
-
return C(i, s);
|
|
665
|
-
}
|
|
666
|
-
function So(o, e) {
|
|
667
|
-
const t = typeof e == "string" ? e : e.id, n = E(o), s = P(t, o);
|
|
668
|
-
if (!s)
|
|
669
|
-
return;
|
|
670
|
-
const r = o.resolve(s.posBeforeNode), i = r.node(), l = r.node(-1), a = l.type.name !== "doc" ? i.type.name === "blockGroup" ? l : i : void 0;
|
|
671
|
-
if (a)
|
|
672
|
-
return C(a, n);
|
|
673
|
-
}
|
|
674
|
-
class xo {
|
|
675
|
-
constructor(e) {
|
|
676
|
-
this.editor = e;
|
|
677
|
-
}
|
|
678
|
-
/**
|
|
679
|
-
* Gets a snapshot of all top-level (non-nested) blocks in the editor.
|
|
680
|
-
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
681
|
-
*/
|
|
682
|
-
get document() {
|
|
683
|
-
return this.editor.transact((e) => We(e.doc, this.editor.pmSchema));
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Gets a snapshot of an existing block from the editor.
|
|
687
|
-
* @param blockIdentifier The identifier of an existing block that should be
|
|
688
|
-
* retrieved.
|
|
689
|
-
* @returns The block that matches the identifier, or `undefined` if no
|
|
690
|
-
* matching block was found.
|
|
691
|
-
*/
|
|
692
|
-
getBlock(e) {
|
|
693
|
-
return this.editor.transact((t) => Bo(t.doc, e));
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* Gets a snapshot of the previous sibling of an existing block from the
|
|
697
|
-
* editor.
|
|
698
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
699
|
-
* previous sibling should be retrieved.
|
|
700
|
-
* @returns The previous sibling of the block that matches the identifier.
|
|
701
|
-
* `undefined` if no matching block was found, or it's the first child/block
|
|
702
|
-
* in the document.
|
|
703
|
-
*/
|
|
704
|
-
getPrevBlock(e) {
|
|
705
|
-
return this.editor.transact((t) => yo(t.doc, e));
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Gets a snapshot of the next sibling of an existing block from the editor.
|
|
709
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
710
|
-
* next sibling should be retrieved.
|
|
711
|
-
* @returns The next sibling of the block that matches the identifier.
|
|
712
|
-
* `undefined` if no matching block was found, or it's the last child/block in
|
|
713
|
-
* the document.
|
|
714
|
-
*/
|
|
715
|
-
getNextBlock(e) {
|
|
716
|
-
return this.editor.transact((t) => Co(t.doc, e));
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Gets a snapshot of the parent of an existing block from the editor.
|
|
720
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
721
|
-
* parent should be retrieved.
|
|
722
|
-
* @returns The parent of the block that matches the identifier. `undefined`
|
|
723
|
-
* if no matching block was found, or the block isn't nested.
|
|
724
|
-
*/
|
|
725
|
-
getParentBlock(e) {
|
|
726
|
-
return this.editor.transact(
|
|
727
|
-
(t) => So(t.doc, e)
|
|
728
|
-
);
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
732
|
-
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
733
|
-
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
734
|
-
*/
|
|
735
|
-
forEachBlock(e, t = !1) {
|
|
736
|
-
const n = this.document.slice();
|
|
737
|
-
t && n.reverse();
|
|
738
|
-
function s(r) {
|
|
739
|
-
for (const i of r) {
|
|
740
|
-
if (e(i) === !1)
|
|
741
|
-
return !1;
|
|
742
|
-
const l = t ? i.children.slice().reverse() : i.children;
|
|
743
|
-
if (!s(l))
|
|
744
|
-
return !1;
|
|
745
|
-
}
|
|
746
|
-
return !0;
|
|
747
|
-
}
|
|
748
|
-
s(n);
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
752
|
-
* error if the reference block could not be found.
|
|
753
|
-
* @param blocksToInsert An array of partial blocks that should be inserted.
|
|
754
|
-
* @param referenceBlock An identifier for an existing block, at which the new blocks should be inserted.
|
|
755
|
-
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
756
|
-
* `referenceBlock`.
|
|
757
|
-
*/
|
|
758
|
-
insertBlocks(e, t, n = "before") {
|
|
759
|
-
return this.editor.transact(
|
|
760
|
-
(s) => Zt(s, e, t, n)
|
|
761
|
-
);
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
765
|
-
* defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
|
|
766
|
-
* not be found.
|
|
767
|
-
* @param blockToUpdate The block that should be updated.
|
|
768
|
-
* @param update A partial block which defines how the existing block should be changed.
|
|
769
|
-
*/
|
|
770
|
-
updateBlock(e, t) {
|
|
771
|
-
return this.editor.transact((n) => Ze(n, e, t));
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
775
|
-
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
776
|
-
*/
|
|
777
|
-
removeBlocks(e) {
|
|
778
|
-
return this.editor.transact(
|
|
779
|
-
(t) => ae(t, e, []).removedBlocks
|
|
780
|
-
);
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
784
|
-
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
785
|
-
* `blocksToRemove`. Throws an error if any of the blocks to remove could not be found.
|
|
786
|
-
* @param blocksToRemove An array of blocks that should be replaced.
|
|
787
|
-
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
788
|
-
*/
|
|
789
|
-
replaceBlocks(e, t) {
|
|
790
|
-
return this.editor.transact(
|
|
791
|
-
(n) => ae(n, e, t)
|
|
792
|
-
);
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* Checks if the block containing the text cursor can be nested.
|
|
796
|
-
*/
|
|
797
|
-
canNestBlock() {
|
|
798
|
-
return bo(this.editor);
|
|
799
|
-
}
|
|
800
|
-
/**
|
|
801
|
-
* Nests the block containing the text cursor into the block above it.
|
|
802
|
-
*/
|
|
803
|
-
nestBlock() {
|
|
804
|
-
Me(this.editor);
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Checks if the block containing the text cursor is nested.
|
|
808
|
-
*/
|
|
809
|
-
canUnnestBlock() {
|
|
810
|
-
return go(this.editor);
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Lifts the block containing the text cursor out of its parent.
|
|
814
|
-
*/
|
|
815
|
-
unnestBlock() {
|
|
816
|
-
ko(this.editor);
|
|
817
|
-
}
|
|
818
|
-
/**
|
|
819
|
-
* Moves the selected blocks up. If the previous block has children, moves
|
|
820
|
-
* them to the end of its children. If there is no previous block, but the
|
|
821
|
-
* current blocks share a common parent, moves them out of & before it.
|
|
822
|
-
*/
|
|
823
|
-
moveBlocksUp() {
|
|
824
|
-
return fo(this.editor);
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* Moves the selected blocks down. If the next block has children, moves
|
|
828
|
-
* them to the start of its children. If there is no next block, but the
|
|
829
|
-
* current blocks share a common parent, moves them out of & after it.
|
|
830
|
-
*/
|
|
831
|
-
moveBlocksDown() {
|
|
832
|
-
return ho(this.editor);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
class Eo extends Ce {
|
|
836
|
-
constructor(e) {
|
|
837
|
-
super(), this.editor = e, e.on("create", () => {
|
|
838
|
-
e._tiptapEditor.on(
|
|
839
|
-
"update",
|
|
840
|
-
({ transaction: t, appendedTransactions: n }) => {
|
|
841
|
-
this.emit("onChange", { editor: e, transaction: t, appendedTransactions: n });
|
|
842
|
-
}
|
|
843
|
-
), e._tiptapEditor.on("selectionUpdate", ({ transaction: t }) => {
|
|
844
|
-
this.emit("onSelectionChange", { editor: e, transaction: t });
|
|
845
|
-
}), e._tiptapEditor.on("mount", () => {
|
|
846
|
-
this.emit("onMount", { editor: e });
|
|
847
|
-
}), e._tiptapEditor.on("unmount", () => {
|
|
848
|
-
this.emit("onUnmount", { editor: e });
|
|
849
|
-
});
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* Register a callback that will be called when the editor changes.
|
|
854
|
-
*/
|
|
855
|
-
onChange(e, t = !0) {
|
|
856
|
-
const n = ({
|
|
857
|
-
transaction: s,
|
|
858
|
-
appendedTransactions: r
|
|
859
|
-
}) => {
|
|
860
|
-
!t && ce(s) || e(this.editor, {
|
|
861
|
-
getChanges() {
|
|
862
|
-
return it(
|
|
863
|
-
s,
|
|
864
|
-
r
|
|
865
|
-
);
|
|
866
|
-
}
|
|
867
|
-
});
|
|
868
|
-
};
|
|
869
|
-
return this.on("onChange", n), () => {
|
|
870
|
-
this.off("onChange", n);
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Register a callback that will be called when the selection changes.
|
|
875
|
-
*/
|
|
876
|
-
onSelectionChange(e, t = !1) {
|
|
877
|
-
const n = (s) => {
|
|
878
|
-
!t && ce(s.transaction) || e(this.editor);
|
|
879
|
-
};
|
|
880
|
-
return this.on("onSelectionChange", n), () => {
|
|
881
|
-
this.off("onSelectionChange", n);
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Register a callback that will be called when the editor is mounted.
|
|
886
|
-
*/
|
|
887
|
-
onMount(e) {
|
|
888
|
-
return this.on("onMount", e), () => {
|
|
889
|
-
this.off("onMount", e);
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Register a callback that will be called when the editor is unmounted.
|
|
894
|
-
*/
|
|
895
|
-
onUnmount(e) {
|
|
896
|
-
return this.on("onUnmount", e), () => {
|
|
897
|
-
this.off("onUnmount", e);
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
function ce(o) {
|
|
902
|
-
return !!o.getMeta("y-sync$");
|
|
903
|
-
}
|
|
904
|
-
function Po(o) {
|
|
905
|
-
return Array.prototype.indexOf.call(o.parentElement.childNodes, o);
|
|
906
|
-
}
|
|
907
|
-
function To(o) {
|
|
908
|
-
return o.nodeType === 3 && !/\S/.test(o.nodeValue || "");
|
|
909
|
-
}
|
|
910
|
-
function wo(o) {
|
|
911
|
-
o.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
912
|
-
const t = Po(e), n = e.parentElement, s = Array.from(n.childNodes).slice(
|
|
913
|
-
t + 1
|
|
914
|
-
);
|
|
915
|
-
e.remove(), s.forEach((r) => {
|
|
916
|
-
r.remove();
|
|
917
|
-
}), n.insertAdjacentElement("afterend", e), s.reverse().forEach((r) => {
|
|
918
|
-
if (To(r))
|
|
919
|
-
return;
|
|
920
|
-
const i = document.createElement("li");
|
|
921
|
-
i.append(r), e.insertAdjacentElement("afterend", i);
|
|
922
|
-
}), n.childNodes.length === 0 && n.remove();
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
function Mo(o) {
|
|
926
|
-
o.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
927
|
-
var r, i;
|
|
928
|
-
const t = e.previousElementSibling, n = document.createElement("div");
|
|
929
|
-
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
930
|
-
const s = document.createElement("div");
|
|
931
|
-
for (s.setAttribute("data-node-type", "blockGroup"), n.append(s); ((r = n.nextElementSibling) == null ? void 0 : r.nodeName) === "UL" || ((i = n.nextElementSibling) == null ? void 0 : i.nodeName) === "OL"; )
|
|
932
|
-
s.append(n.nextElementSibling);
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
let le = null;
|
|
936
|
-
function vo() {
|
|
937
|
-
return le || (le = document.implementation.createHTMLDocument("title"));
|
|
938
|
-
}
|
|
939
|
-
function Io(o) {
|
|
940
|
-
if (typeof o == "string") {
|
|
941
|
-
const e = vo().createElement("div");
|
|
942
|
-
e.innerHTML = o, o = e;
|
|
943
|
-
}
|
|
944
|
-
return wo(o), Mo(o), o;
|
|
945
|
-
}
|
|
946
|
-
function Ao(o) {
|
|
947
|
-
const e = o.ownerDocument.createTreeWalker(
|
|
948
|
-
o,
|
|
949
|
-
// NodeFilter.SHOW_COMMENT
|
|
950
|
-
128
|
|
951
|
-
);
|
|
952
|
-
let t;
|
|
953
|
-
for (; t = e.nextNode(); )
|
|
954
|
-
if (/^\s*notionvc:/.test(t.nodeValue || ""))
|
|
955
|
-
return !0;
|
|
956
|
-
return !1;
|
|
957
|
-
}
|
|
958
|
-
function No(o) {
|
|
959
|
-
const e = /* @__PURE__ */ new Set(["PRE", "CODE"]), t = o.ownerDocument.createTreeWalker(
|
|
960
|
-
o,
|
|
961
|
-
// NodeFilter.SHOW_TEXT
|
|
962
|
-
4,
|
|
963
|
-
{
|
|
964
|
-
acceptNode(r) {
|
|
965
|
-
let i = r.parentElement;
|
|
966
|
-
for (; i && i !== o; ) {
|
|
967
|
-
if (e.has(i.tagName))
|
|
968
|
-
return 2;
|
|
969
|
-
i = i.parentElement;
|
|
970
|
-
}
|
|
971
|
-
return 1;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
), n = [];
|
|
975
|
-
let s;
|
|
976
|
-
for (; s = t.nextNode(); )
|
|
977
|
-
n.push(s);
|
|
978
|
-
for (const r of n)
|
|
979
|
-
r.nodeValue && /[\r\n]/.test(r.nodeValue) && (r.nodeValue = r.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
980
|
-
}
|
|
981
|
-
function Lo(o) {
|
|
982
|
-
Ao(o) || No(o);
|
|
983
|
-
}
|
|
984
|
-
function ve(o, e) {
|
|
985
|
-
const t = Io(o);
|
|
986
|
-
Lo(t);
|
|
987
|
-
const s = Ue.fromSchema(e).parse(t, {
|
|
988
|
-
topNode: e.nodes.blockGroup.create()
|
|
989
|
-
}), r = [];
|
|
990
|
-
for (let i = 0; i < s.childCount; i++)
|
|
991
|
-
r.push(C(s.child(i), e));
|
|
992
|
-
return r;
|
|
993
|
-
}
|
|
994
|
-
function _o(o, e) {
|
|
995
|
-
const t = e.value ? e.value : "", n = {};
|
|
996
|
-
e.lang && (n["data-language"] = e.lang);
|
|
997
|
-
let s = {
|
|
998
|
-
type: "element",
|
|
999
|
-
tagName: "code",
|
|
1000
|
-
properties: n,
|
|
1001
|
-
children: [{ type: "text", value: t }]
|
|
1002
|
-
};
|
|
1003
|
-
return e.meta && (s.data = { meta: e.meta }), o.patch(e, s), s = o.applyData(e, s), s = {
|
|
1004
|
-
type: "element",
|
|
1005
|
-
tagName: "pre",
|
|
1006
|
-
properties: {},
|
|
1007
|
-
children: [s]
|
|
1008
|
-
}, o.patch(e, s), s;
|
|
1009
|
-
}
|
|
1010
|
-
function Do(o, e) {
|
|
1011
|
-
var r;
|
|
1012
|
-
const t = String((e == null ? void 0 : e.url) || ""), n = e != null && e.title ? String(e.title) : void 0;
|
|
1013
|
-
let s = {
|
|
1014
|
-
type: "element",
|
|
1015
|
-
tagName: "video",
|
|
1016
|
-
properties: {
|
|
1017
|
-
src: t,
|
|
1018
|
-
"data-name": n,
|
|
1019
|
-
"data-url": t,
|
|
1020
|
-
controls: !0
|
|
1021
|
-
},
|
|
1022
|
-
children: []
|
|
1023
|
-
};
|
|
1024
|
-
return (r = o.patch) == null || r.call(o, e, s), s = o.applyData ? o.applyData(e, s) : s, s;
|
|
1025
|
-
}
|
|
1026
|
-
function Ie(o) {
|
|
1027
|
-
return Yt().use(qt).use(jt).use(Kt, {
|
|
1028
|
-
handlers: {
|
|
1029
|
-
...ie,
|
|
1030
|
-
image: (t, n) => {
|
|
1031
|
-
const s = String((n == null ? void 0 : n.url) || "");
|
|
1032
|
-
return et(s) ? Do(t, n) : ie.image(t, n);
|
|
1033
|
-
},
|
|
1034
|
-
code: _o,
|
|
1035
|
-
blockquote: (t, n) => {
|
|
1036
|
-
const s = {
|
|
1037
|
-
type: "element",
|
|
1038
|
-
tagName: "blockquote",
|
|
1039
|
-
properties: {},
|
|
1040
|
-
// The only difference from the original is that we don't wrap the children with line endings
|
|
1041
|
-
children: t.wrap(t.all(n), !1)
|
|
1042
|
-
};
|
|
1043
|
-
return t.patch(n, s), t.applyData(n, s);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
}).use(Jt).processSync(o).value;
|
|
1047
|
-
}
|
|
1048
|
-
function Oo(o, e) {
|
|
1049
|
-
const t = Ie(o);
|
|
1050
|
-
return ve(t, e);
|
|
1051
|
-
}
|
|
1052
|
-
class $o {
|
|
1053
|
-
constructor(e) {
|
|
1054
|
-
this.editor = e;
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* Exports blocks into a simplified HTML string. To better conform to HTML standards, children of blocks which aren't list
|
|
1058
|
-
* items are un-nested in the output HTML.
|
|
1059
|
-
*
|
|
1060
|
-
* @param blocks An array of blocks that should be serialized into HTML.
|
|
1061
|
-
* @returns The blocks, serialized as an HTML string.
|
|
1062
|
-
*/
|
|
1063
|
-
blocksToHTMLLossy(e = this.editor.document) {
|
|
1064
|
-
return Be(
|
|
1065
|
-
this.editor.pmSchema,
|
|
1066
|
-
this.editor
|
|
1067
|
-
).exportBlocks(e, {});
|
|
1068
|
-
}
|
|
1069
|
-
/**
|
|
1070
|
-
* Serializes blocks into an HTML string in the format that would normally be rendered by the editor.
|
|
1071
|
-
*
|
|
1072
|
-
* Use this method if you want to server-side render HTML (for example, a blog post that has been edited in BlockNote)
|
|
1073
|
-
* and serve it to users without loading the editor on the client (i.e.: displaying the blog post)
|
|
1074
|
-
*
|
|
1075
|
-
* @param blocks An array of blocks that should be serialized into HTML.
|
|
1076
|
-
* @returns The blocks, serialized as an HTML string.
|
|
1077
|
-
*/
|
|
1078
|
-
blocksToFullHTML(e = this.editor.document) {
|
|
1079
|
-
return lo(
|
|
1080
|
-
this.editor.pmSchema,
|
|
1081
|
-
this.editor
|
|
1082
|
-
).serializeBlocks(e, {});
|
|
1083
|
-
}
|
|
1084
|
-
/**
|
|
1085
|
-
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
1086
|
-
* `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
|
|
1087
|
-
* doesn't recognize an HTML element's tag, it will parse it as a paragraph or plain text.
|
|
1088
|
-
* @param html The HTML string to parse blocks from.
|
|
1089
|
-
* @returns The blocks parsed from the HTML string.
|
|
1090
|
-
*/
|
|
1091
|
-
tryParseHTMLToBlocks(e) {
|
|
1092
|
-
return ve(e, this.editor.pmSchema);
|
|
1093
|
-
}
|
|
1094
|
-
/**
|
|
1095
|
-
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
1096
|
-
* BlockNote - children of blocks which aren't list items are un-nested and certain styles are removed.
|
|
1097
|
-
* @param blocks An array of blocks that should be serialized into Markdown.
|
|
1098
|
-
* @returns The blocks, serialized as a Markdown string.
|
|
1099
|
-
*/
|
|
1100
|
-
blocksToMarkdownLossy(e = this.editor.document) {
|
|
1101
|
-
return at(e, this.editor.pmSchema, this.editor, {});
|
|
1102
|
-
}
|
|
1103
|
-
/**
|
|
1104
|
-
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
1105
|
-
* Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
|
|
1106
|
-
* as text.
|
|
1107
|
-
* @param markdown The Markdown string to parse blocks from.
|
|
1108
|
-
* @returns The blocks parsed from the Markdown string.
|
|
1109
|
-
*/
|
|
1110
|
-
tryParseMarkdownToBlocks(e) {
|
|
1111
|
-
return Oo(e, this.editor.pmSchema);
|
|
1112
|
-
}
|
|
1113
|
-
/**
|
|
1114
|
-
* Paste HTML into the editor. Defaults to converting HTML to BlockNote HTML.
|
|
1115
|
-
* @param html The HTML to paste.
|
|
1116
|
-
* @param raw Whether to paste the HTML as is, or to convert it to BlockNote HTML.
|
|
1117
|
-
*/
|
|
1118
|
-
pasteHTML(e, t = !1) {
|
|
1119
|
-
var s;
|
|
1120
|
-
let n = e;
|
|
1121
|
-
if (!t) {
|
|
1122
|
-
const r = this.tryParseHTMLToBlocks(e);
|
|
1123
|
-
n = this.blocksToFullHTML(r);
|
|
1124
|
-
}
|
|
1125
|
-
n && ((s = this.editor.prosemirrorView) == null || s.pasteHTML(n));
|
|
1126
|
-
}
|
|
1127
|
-
/**
|
|
1128
|
-
* Paste text into the editor. Defaults to interpreting text as markdown.
|
|
1129
|
-
* @param text The text to paste.
|
|
1130
|
-
*/
|
|
1131
|
-
pasteText(e) {
|
|
1132
|
-
var t;
|
|
1133
|
-
return (t = this.editor.prosemirrorView) == null ? void 0 : t.pasteText(e);
|
|
1134
|
-
}
|
|
1135
|
-
/**
|
|
1136
|
-
* Paste markdown into the editor.
|
|
1137
|
-
* @param markdown The markdown to paste.
|
|
1138
|
-
*/
|
|
1139
|
-
pasteMarkdown(e) {
|
|
1140
|
-
const t = Ie(e);
|
|
1141
|
-
return this.pasteHTML(t);
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
const se = [
|
|
1145
|
-
"vscode-editor-data",
|
|
1146
|
-
"blocknote/html",
|
|
1147
|
-
"text/markdown",
|
|
1148
|
-
"text/html",
|
|
1149
|
-
"text/plain",
|
|
1150
|
-
"Files"
|
|
1151
|
-
];
|
|
1152
|
-
function Ho(o, e) {
|
|
1153
|
-
if (!o.startsWith(".") || !e.startsWith("."))
|
|
1154
|
-
throw new Error("The strings provided are not valid file extensions.");
|
|
1155
|
-
return o === e;
|
|
1156
|
-
}
|
|
1157
|
-
function Fo(o, e) {
|
|
1158
|
-
const t = o.split("/"), n = e.split("/");
|
|
1159
|
-
if (t.length !== 2)
|
|
1160
|
-
throw new Error(`The string ${o} is not a valid MIME type.`);
|
|
1161
|
-
if (n.length !== 2)
|
|
1162
|
-
throw new Error(`The string ${e} is not a valid MIME type.`);
|
|
1163
|
-
return t[1] === "*" || n[1] === "*" ? t[0] === n[0] : (t[0] === "*" || n[0] === "*" || t[0] === n[0]) && t[1] === n[1];
|
|
1164
|
-
}
|
|
1165
|
-
function de(o, e, t, n = "after") {
|
|
1166
|
-
let s;
|
|
1167
|
-
return Array.isArray(e.content) && e.content.length === 0 ? s = o.updateBlock(e, t).id : s = o.insertBlocks(
|
|
1168
|
-
[t],
|
|
1169
|
-
e,
|
|
1170
|
-
n
|
|
1171
|
-
)[0].id, s;
|
|
1172
|
-
}
|
|
1173
|
-
async function Ae(o, e) {
|
|
1174
|
-
var r;
|
|
1175
|
-
if (!e.uploadFile) {
|
|
1176
|
-
console.warn(
|
|
1177
|
-
"Attempted ot insert file, but uploadFile is not set in the BlockNote editor options"
|
|
1178
|
-
);
|
|
1179
|
-
return;
|
|
1180
|
-
}
|
|
1181
|
-
const t = "dataTransfer" in o ? o.dataTransfer : o.clipboardData;
|
|
1182
|
-
if (t === null)
|
|
1183
|
-
return;
|
|
1184
|
-
let n = null;
|
|
1185
|
-
for (const i of se)
|
|
1186
|
-
if (t.types.includes(i)) {
|
|
1187
|
-
n = i;
|
|
1188
|
-
break;
|
|
1189
|
-
}
|
|
1190
|
-
if (n !== "Files")
|
|
1191
|
-
return;
|
|
1192
|
-
const s = t.items;
|
|
1193
|
-
if (s) {
|
|
1194
|
-
o.preventDefault();
|
|
1195
|
-
for (let i = 0; i < s.length; i++) {
|
|
1196
|
-
let l = "file";
|
|
1197
|
-
for (const c of Object.values(e.schema.blockSpecs))
|
|
1198
|
-
for (const d of ((r = c.implementation.meta) == null ? void 0 : r.fileBlockAccept) || []) {
|
|
1199
|
-
const u = d.startsWith("."), p = s[i].getAsFile();
|
|
1200
|
-
if (p && (!u && p.type && Fo(s[i].type, d) || u && Ho(
|
|
1201
|
-
"." + p.name.split(".").pop(),
|
|
1202
|
-
d
|
|
1203
|
-
))) {
|
|
1204
|
-
l = c.config.type;
|
|
1205
|
-
break;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
const a = s[i].getAsFile();
|
|
1209
|
-
if (a) {
|
|
1210
|
-
const c = {
|
|
1211
|
-
type: l,
|
|
1212
|
-
props: {
|
|
1213
|
-
name: a.name
|
|
1214
|
-
}
|
|
1215
|
-
};
|
|
1216
|
-
let d;
|
|
1217
|
-
if (o.type === "paste") {
|
|
1218
|
-
const h = e.getTextCursorPosition().block;
|
|
1219
|
-
d = de(e, h, c);
|
|
1220
|
-
} else if (o.type === "drop") {
|
|
1221
|
-
const h = {
|
|
1222
|
-
left: o.clientX,
|
|
1223
|
-
top: o.clientY
|
|
1224
|
-
}, f = e.prosemirrorView.posAtCoords(h);
|
|
1225
|
-
if (!f)
|
|
1226
|
-
return;
|
|
1227
|
-
d = e.transact((m) => {
|
|
1228
|
-
var y;
|
|
1229
|
-
const b = D(m.doc, f.pos), g = (y = e.domElement) == null ? void 0 : y.querySelector(
|
|
1230
|
-
`[data-id="${b.node.attrs.id}"]`
|
|
1231
|
-
), x = g == null ? void 0 : g.getBoundingClientRect();
|
|
1232
|
-
return de(
|
|
1233
|
-
e,
|
|
1234
|
-
e.getBlock(b.node.attrs.id),
|
|
1235
|
-
c,
|
|
1236
|
-
x && (x.top + x.bottom) / 2 > h.top ? "before" : "after"
|
|
1237
|
-
);
|
|
1238
|
-
});
|
|
1239
|
-
} else
|
|
1240
|
-
return;
|
|
1241
|
-
const u = await e.uploadFile(a, d), p = typeof u == "string" ? {
|
|
1242
|
-
props: {
|
|
1243
|
-
url: u
|
|
1244
|
-
}
|
|
1245
|
-
} : { ...u };
|
|
1246
|
-
e.updateBlock(d, p);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
const Vo = (o) => T.create({
|
|
1252
|
-
name: "dropFile",
|
|
1253
|
-
addProseMirrorPlugins() {
|
|
1254
|
-
return [
|
|
1255
|
-
new oe({
|
|
1256
|
-
props: {
|
|
1257
|
-
handleDOMEvents: {
|
|
1258
|
-
drop(e, t) {
|
|
1259
|
-
if (!o.isEditable)
|
|
1260
|
-
return;
|
|
1261
|
-
let n = null;
|
|
1262
|
-
for (const s of se)
|
|
1263
|
-
if (t.dataTransfer.types.includes(s)) {
|
|
1264
|
-
n = s;
|
|
1265
|
-
break;
|
|
1266
|
-
}
|
|
1267
|
-
return n === null ? !0 : n === "Files" ? (Ae(t, o), !0) : !1;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
})
|
|
1272
|
-
];
|
|
1273
|
-
}
|
|
1274
|
-
}), Uo = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, zo = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, Ro = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, Go = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, Wo = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, jo = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, qo = /\n{2} {0,3}-{2,48}\n{2}/, Ko = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, Jo = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, Yo = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, Qo = /^\s*\|(.+\|)+\s*$/m, Xo = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, Zo = /^\s*\|(.+\|)+\s*$/m, en = (o) => Uo.test(o) || zo.test(o) || Ro.test(o) || Go.test(o) || Wo.test(o) || jo.test(o) || qo.test(o) || Ko.test(o) || Jo.test(o) || Yo.test(o) || Qo.test(o) || Xo.test(o) || Zo.test(o);
|
|
1275
|
-
async function tn(o, e) {
|
|
1276
|
-
const { schema: t } = e.state;
|
|
1277
|
-
if (!o.clipboardData)
|
|
1278
|
-
return !1;
|
|
1279
|
-
const n = o.clipboardData.getData("text/plain");
|
|
1280
|
-
if (!n)
|
|
1281
|
-
return !1;
|
|
1282
|
-
if (!t.nodes.codeBlock)
|
|
1283
|
-
return e.pasteText(n), !0;
|
|
1284
|
-
const s = o.clipboardData.getData("vscode-editor-data"), r = s ? JSON.parse(s) : void 0, i = r == null ? void 0 : r.mode;
|
|
1285
|
-
return i ? (e.pasteHTML(
|
|
1286
|
-
`<pre><code class="language-${i}">${n.replace(
|
|
1287
|
-
/\r\n?/g,
|
|
1288
|
-
`
|
|
1289
|
-
`
|
|
1290
|
-
)}</code></pre>`
|
|
1291
|
-
), !0) : !1;
|
|
1292
|
-
}
|
|
1293
|
-
function on({
|
|
1294
|
-
event: o,
|
|
1295
|
-
editor: e,
|
|
1296
|
-
prioritizeMarkdownOverHTML: t,
|
|
1297
|
-
plainTextAsMarkdown: n
|
|
1298
|
-
}) {
|
|
1299
|
-
var l;
|
|
1300
|
-
if (e.transact(
|
|
1301
|
-
(a) => a.selection.$from.parent.type.spec.code && a.selection.$to.parent.type.spec.code
|
|
1302
|
-
)) {
|
|
1303
|
-
const a = (l = o.clipboardData) == null ? void 0 : l.getData("text/plain");
|
|
1304
|
-
if (a)
|
|
1305
|
-
return e.pasteText(a), !0;
|
|
1306
|
-
}
|
|
1307
|
-
let r;
|
|
1308
|
-
for (const a of se)
|
|
1309
|
-
if (o.clipboardData.types.includes(a)) {
|
|
1310
|
-
r = a;
|
|
1311
|
-
break;
|
|
1312
|
-
}
|
|
1313
|
-
if (!r)
|
|
1314
|
-
return !0;
|
|
1315
|
-
if (r === "vscode-editor-data")
|
|
1316
|
-
return tn(o, e.prosemirrorView), !0;
|
|
1317
|
-
if (r === "Files")
|
|
1318
|
-
return Ae(o, e), !0;
|
|
1319
|
-
const i = o.clipboardData.getData(r);
|
|
1320
|
-
if (r === "blocknote/html")
|
|
1321
|
-
return e.pasteHTML(i, !0), !0;
|
|
1322
|
-
if (r === "text/markdown")
|
|
1323
|
-
return e.pasteMarkdown(i), !0;
|
|
1324
|
-
if (t) {
|
|
1325
|
-
const a = o.clipboardData.getData("text/plain");
|
|
1326
|
-
if (en(a))
|
|
1327
|
-
return e.pasteMarkdown(a), !0;
|
|
1328
|
-
}
|
|
1329
|
-
return r === "text/html" ? (e.pasteHTML(i), !0) : n ? (e.pasteMarkdown(i), !0) : (e.pasteText(i), !0);
|
|
1330
|
-
}
|
|
1331
|
-
const nn = (o, e) => T.create({
|
|
1332
|
-
name: "pasteFromClipboard",
|
|
1333
|
-
addProseMirrorPlugins() {
|
|
1334
|
-
return [
|
|
1335
|
-
new oe({
|
|
1336
|
-
props: {
|
|
1337
|
-
handleDOMEvents: {
|
|
1338
|
-
paste(t, n) {
|
|
1339
|
-
if (n.preventDefault(), !!o.isEditable)
|
|
1340
|
-
return e({
|
|
1341
|
-
event: n,
|
|
1342
|
-
editor: o,
|
|
1343
|
-
defaultPasteHandler: ({
|
|
1344
|
-
prioritizeMarkdownOverHTML: s = !0,
|
|
1345
|
-
plainTextAsMarkdown: r = !0
|
|
1346
|
-
} = {}) => on({
|
|
1347
|
-
event: n,
|
|
1348
|
-
editor: o,
|
|
1349
|
-
prioritizeMarkdownOverHTML: s,
|
|
1350
|
-
plainTextAsMarkdown: r
|
|
1351
|
-
})
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
})
|
|
1357
|
-
];
|
|
1358
|
-
}
|
|
1359
|
-
});
|
|
1360
|
-
function sn(o, e, t) {
|
|
1361
|
-
var l;
|
|
1362
|
-
let n = !1;
|
|
1363
|
-
const s = o.state.selection instanceof ne;
|
|
1364
|
-
if (!s) {
|
|
1365
|
-
const a = o.state.doc.slice(
|
|
1366
|
-
o.state.selection.from,
|
|
1367
|
-
o.state.selection.to,
|
|
1368
|
-
!1
|
|
1369
|
-
).content, c = [];
|
|
1370
|
-
for (let d = 0; d < a.childCount; d++)
|
|
1371
|
-
c.push(a.child(d));
|
|
1372
|
-
n = c.find(
|
|
1373
|
-
(d) => d.type.isInGroup("bnBlock") || d.type.name === "blockGroup" || d.type.spec.group === "blockContent"
|
|
1374
|
-
) === void 0, n && (e = a);
|
|
1375
|
-
}
|
|
1376
|
-
let r;
|
|
1377
|
-
const i = Be(
|
|
1378
|
-
o.state.schema,
|
|
1379
|
-
t
|
|
1380
|
-
);
|
|
1381
|
-
if (s) {
|
|
1382
|
-
((l = e.firstChild) == null ? void 0 : l.type.name) === "table" && (e = e.firstChild.content);
|
|
1383
|
-
const a = je(
|
|
1384
|
-
e,
|
|
1385
|
-
t.schema.inlineContentSchema,
|
|
1386
|
-
t.schema.styleSchema
|
|
1387
|
-
);
|
|
1388
|
-
r = `<table>${i.exportInlineContent(
|
|
1389
|
-
a,
|
|
1390
|
-
{}
|
|
1391
|
-
)}</table>`;
|
|
1392
|
-
} else if (n) {
|
|
1393
|
-
const a = qe(
|
|
1394
|
-
e,
|
|
1395
|
-
t.schema.inlineContentSchema,
|
|
1396
|
-
t.schema.styleSchema
|
|
1397
|
-
);
|
|
1398
|
-
r = i.exportInlineContent(a, {});
|
|
1399
|
-
} else {
|
|
1400
|
-
const a = lt(e);
|
|
1401
|
-
r = i.exportBlocks(a, {});
|
|
1402
|
-
}
|
|
1403
|
-
return r;
|
|
1404
|
-
}
|
|
1405
|
-
function Ne(o, e) {
|
|
1406
|
-
"node" in o.state.selection && o.state.selection.node.type.spec.group === "blockContent" && e.transact(
|
|
1407
|
-
(i) => i.setSelection(
|
|
1408
|
-
new $(i.doc.resolve(o.state.selection.from - 1))
|
|
1409
|
-
)
|
|
1410
|
-
);
|
|
1411
|
-
const t = o.serializeForClipboard(
|
|
1412
|
-
o.state.selection.content()
|
|
1413
|
-
).dom.innerHTML, n = o.state.selection.content().content, s = sn(
|
|
1414
|
-
o,
|
|
1415
|
-
n,
|
|
1416
|
-
e
|
|
1417
|
-
), r = ct(s);
|
|
1418
|
-
return { clipboardHTML: t, externalHTML: s, markdown: r };
|
|
1419
|
-
}
|
|
1420
|
-
const ue = () => {
|
|
1421
|
-
const o = window.getSelection();
|
|
1422
|
-
if (!o || o.isCollapsed)
|
|
1423
|
-
return !0;
|
|
1424
|
-
let e = o.focusNode;
|
|
1425
|
-
for (; e; ) {
|
|
1426
|
-
if (e instanceof HTMLElement && e.getAttribute("contenteditable") === "false")
|
|
1427
|
-
return !0;
|
|
1428
|
-
e = e.parentElement;
|
|
1429
|
-
}
|
|
1430
|
-
return !1;
|
|
1431
|
-
}, pe = (o, e, t) => {
|
|
1432
|
-
t.preventDefault(), t.clipboardData.clearData();
|
|
1433
|
-
const { clipboardHTML: n, externalHTML: s, markdown: r } = Ne(
|
|
1434
|
-
e,
|
|
1435
|
-
o
|
|
1436
|
-
);
|
|
1437
|
-
t.clipboardData.setData("blocknote/html", n), t.clipboardData.setData("text/html", s), t.clipboardData.setData("text/plain", r);
|
|
1438
|
-
}, rn = (o) => T.create({
|
|
1439
|
-
name: "copyToClipboard",
|
|
1440
|
-
addProseMirrorPlugins() {
|
|
1441
|
-
return [
|
|
1442
|
-
new oe({
|
|
1443
|
-
props: {
|
|
1444
|
-
handleDOMEvents: {
|
|
1445
|
-
copy(e, t) {
|
|
1446
|
-
return ue() || pe(o, e, t), !0;
|
|
1447
|
-
},
|
|
1448
|
-
cut(e, t) {
|
|
1449
|
-
return ue() || (pe(o, e, t), e.editable && e.dispatch(e.state.tr.deleteSelection())), !0;
|
|
1450
|
-
},
|
|
1451
|
-
// This is for the use-case in which only a block without content
|
|
1452
|
-
// is selected, e.g. an image block, and dragged (not using the
|
|
1453
|
-
// drag handle).
|
|
1454
|
-
dragstart(e, t) {
|
|
1455
|
-
if (!("node" in e.state.selection) || e.state.selection.node.type.spec.group !== "blockContent")
|
|
1456
|
-
return;
|
|
1457
|
-
o.transact(
|
|
1458
|
-
(i) => i.setSelection(
|
|
1459
|
-
new $(
|
|
1460
|
-
i.doc.resolve(e.state.selection.from - 1)
|
|
1461
|
-
)
|
|
1462
|
-
)
|
|
1463
|
-
), t.preventDefault(), t.dataTransfer.clearData();
|
|
1464
|
-
const { clipboardHTML: n, externalHTML: s, markdown: r } = Ne(e, o);
|
|
1465
|
-
return t.dataTransfer.setData("blocknote/html", n), t.dataTransfer.setData("text/html", s), t.dataTransfer.setData("text/plain", r), !0;
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
})
|
|
1470
|
-
];
|
|
1471
|
-
}
|
|
1472
|
-
}), an = T.create({
|
|
1473
|
-
name: "blockBackgroundColor",
|
|
1474
|
-
addGlobalAttributes() {
|
|
1475
|
-
return [
|
|
1476
|
-
{
|
|
1477
|
-
types: ["tableCell", "tableHeader"],
|
|
1478
|
-
attributes: {
|
|
1479
|
-
backgroundColor: tt()
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
];
|
|
1483
|
-
}
|
|
1484
|
-
}), cn = O.create({
|
|
1485
|
-
name: "hardBreak",
|
|
1486
|
-
inline: !0,
|
|
1487
|
-
group: "inline",
|
|
1488
|
-
selectable: !1,
|
|
1489
|
-
linebreakReplacement: !0,
|
|
1490
|
-
priority: 10,
|
|
1491
|
-
parseHTML() {
|
|
1492
|
-
return [{ tag: "br" }];
|
|
1493
|
-
},
|
|
1494
|
-
renderHTML({ HTMLAttributes: o }) {
|
|
1495
|
-
return ["br", Mt(this.options.HTMLAttributes, o)];
|
|
1496
|
-
},
|
|
1497
|
-
renderText() {
|
|
1498
|
-
return `
|
|
1499
|
-
`;
|
|
1500
|
-
}
|
|
1501
|
-
}), Le = (o, e) => {
|
|
1502
|
-
var l;
|
|
1503
|
-
const t = o.resolve(e), n = t.depth - 1, s = t.before(n), r = o.resolve(s).nodeAfter;
|
|
1504
|
-
return r ? (l = r.type.spec.group) != null && l.includes("bnBlock") ? v(
|
|
1505
|
-
o.resolve(s)
|
|
1506
|
-
) : Le(o, s) : void 0;
|
|
1507
|
-
}, _ = (o, e) => {
|
|
1508
|
-
const t = o.resolve(e), n = t.index();
|
|
1509
|
-
if (n === 0)
|
|
1510
|
-
return;
|
|
1511
|
-
const s = t.posAtIndex(n - 1);
|
|
1512
|
-
return v(
|
|
1513
|
-
o.resolve(s)
|
|
1514
|
-
);
|
|
1515
|
-
}, L = (o, e) => {
|
|
1516
|
-
const t = o.resolve(e), n = t.index();
|
|
1517
|
-
if (n === t.node().childCount - 1)
|
|
1518
|
-
return;
|
|
1519
|
-
const s = t.posAtIndex(n + 1);
|
|
1520
|
-
return v(
|
|
1521
|
-
o.resolve(s)
|
|
1522
|
-
);
|
|
1523
|
-
}, _e = (o, e) => {
|
|
1524
|
-
for (; e.childContainer; ) {
|
|
1525
|
-
const t = e.childContainer.node, n = o.resolve(e.childContainer.beforePos + 1).posAtIndex(t.childCount - 1);
|
|
1526
|
-
e = v(o.resolve(n));
|
|
1527
|
-
}
|
|
1528
|
-
return e;
|
|
1529
|
-
}, ln = (o, e) => o.isBlockContainer && o.blockContent.node.type.spec.content === "inline*" && o.blockContent.node.childCount > 0 && e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*", dn = (o, e, t, n) => {
|
|
1530
|
-
if (!n.isBlockContainer)
|
|
1531
|
-
throw new Error(
|
|
1532
|
-
`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`
|
|
1533
|
-
);
|
|
1534
|
-
if (n.childContainer) {
|
|
1535
|
-
const s = o.doc.resolve(
|
|
1536
|
-
n.childContainer.beforePos + 1
|
|
1537
|
-
), r = o.doc.resolve(
|
|
1538
|
-
n.childContainer.afterPos - 1
|
|
1539
|
-
), i = s.blockRange(r);
|
|
1540
|
-
if (e) {
|
|
1541
|
-
const l = o.doc.resolve(n.bnBlock.beforePos);
|
|
1542
|
-
o.tr.lift(i, l.depth);
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
if (e) {
|
|
1546
|
-
if (!t.isBlockContainer)
|
|
1547
|
-
throw new Error(
|
|
1548
|
-
`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`
|
|
1549
|
-
);
|
|
1550
|
-
e(
|
|
1551
|
-
o.tr.delete(
|
|
1552
|
-
t.blockContent.afterPos - 1,
|
|
1553
|
-
n.blockContent.beforePos + 1
|
|
1554
|
-
)
|
|
1555
|
-
);
|
|
1556
|
-
}
|
|
1557
|
-
return !0;
|
|
1558
|
-
}, fe = (o) => ({
|
|
1559
|
-
state: e,
|
|
1560
|
-
dispatch: t
|
|
1561
|
-
}) => {
|
|
1562
|
-
const n = e.doc.resolve(o), s = v(n), r = _(
|
|
1563
|
-
e.doc,
|
|
1564
|
-
s.bnBlock.beforePos
|
|
1565
|
-
);
|
|
1566
|
-
if (!r)
|
|
1567
|
-
return !1;
|
|
1568
|
-
const i = _e(
|
|
1569
|
-
e.doc,
|
|
1570
|
-
r
|
|
1571
|
-
);
|
|
1572
|
-
return ln(i, s) ? dn(e, t, i, s) : !1;
|
|
1573
|
-
}, un = T.create({
|
|
1574
|
-
priority: 50,
|
|
1575
|
-
// TODO: The shortcuts need a refactor. Do we want to use a command priority
|
|
1576
|
-
// design as there is now, or clump the logic into a single function?
|
|
1577
|
-
addKeyboardShortcuts() {
|
|
1578
|
-
const o = () => this.editor.commands.first(({ chain: n, commands: s }) => [
|
|
1579
|
-
// Deletes the selection if it's not empty.
|
|
1580
|
-
() => s.deleteSelection(),
|
|
1581
|
-
// Undoes an input rule if one was triggered in the last editor state change.
|
|
1582
|
-
() => s.undoInputRule(),
|
|
1583
|
-
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
1584
|
-
() => s.command(({ state: r }) => {
|
|
1585
|
-
const i = B(r);
|
|
1586
|
-
if (!i.isBlockContainer)
|
|
1587
|
-
return !1;
|
|
1588
|
-
const l = r.selection.from === i.blockContent.beforePos + 1, a = i.blockContent.node.type.name === "paragraph";
|
|
1589
|
-
return l && !a ? s.command(
|
|
1590
|
-
nt(i.bnBlock.beforePos, {
|
|
1591
|
-
type: "paragraph",
|
|
1592
|
-
props: {}
|
|
1593
|
-
})
|
|
1594
|
-
) : !1;
|
|
1595
|
-
}),
|
|
1596
|
-
// Removes a level of nesting if the block is indented if the selection is at the start of the block.
|
|
1597
|
-
() => s.command(({ state: r }) => {
|
|
1598
|
-
const i = B(r);
|
|
1599
|
-
if (!i.isBlockContainer)
|
|
1600
|
-
return !1;
|
|
1601
|
-
const { blockContent: l } = i;
|
|
1602
|
-
return r.selection.from === l.beforePos + 1 ? s.liftListItem("blockContainer") : !1;
|
|
1603
|
-
}),
|
|
1604
|
-
// Merges block with the previous one if it isn't indented, and the selection is at the start of the
|
|
1605
|
-
// block. The target block for merging must contain inline content.
|
|
1606
|
-
() => s.command(({ state: r }) => {
|
|
1607
|
-
const i = B(r);
|
|
1608
|
-
if (!i.isBlockContainer)
|
|
1609
|
-
return !1;
|
|
1610
|
-
const { bnBlock: l, blockContent: a } = i, c = _(
|
|
1611
|
-
r.doc,
|
|
1612
|
-
i.bnBlock.beforePos
|
|
1613
|
-
);
|
|
1614
|
-
if (!c || !c.isBlockContainer || c.blockContent.node.type.spec.content !== "inline*")
|
|
1615
|
-
return !1;
|
|
1616
|
-
const d = r.selection.from === a.beforePos + 1, u = r.selection.empty, p = l.beforePos;
|
|
1617
|
-
return d && u ? n().command(fe(p)).scrollIntoView().run() : !1;
|
|
1618
|
-
}),
|
|
1619
|
-
// If the previous block is a columnList, moves the current block to
|
|
1620
|
-
// the end of the last column in it.
|
|
1621
|
-
() => s.command(({ state: r, tr: i, dispatch: l }) => {
|
|
1622
|
-
const a = B(r);
|
|
1623
|
-
if (!a.isBlockContainer)
|
|
1624
|
-
return !1;
|
|
1625
|
-
const c = _(
|
|
1626
|
-
r.doc,
|
|
1627
|
-
a.bnBlock.beforePos
|
|
1628
|
-
);
|
|
1629
|
-
if (!c || c.isBlockContainer)
|
|
1630
|
-
return !1;
|
|
1631
|
-
if (l) {
|
|
1632
|
-
const d = c.bnBlock.afterPos - 1, u = i.doc.resolve(d - 1);
|
|
1633
|
-
return i.delete(
|
|
1634
|
-
a.bnBlock.beforePos,
|
|
1635
|
-
a.bnBlock.afterPos
|
|
1636
|
-
), i.insert(u.pos, a.bnBlock.node), i.setSelection(
|
|
1637
|
-
S.near(i.doc.resolve(u.pos + 1))
|
|
1638
|
-
), !0;
|
|
1639
|
-
}
|
|
1640
|
-
return !1;
|
|
1641
|
-
}),
|
|
1642
|
-
// If the block is the first in a column, moves it to the end of the
|
|
1643
|
-
// previous column. If there is no previous column, moves it above the
|
|
1644
|
-
// columnList.
|
|
1645
|
-
() => s.command(({ state: r, tr: i, dispatch: l }) => {
|
|
1646
|
-
const a = B(r);
|
|
1647
|
-
if (!a.isBlockContainer || !(i.selection.from === a.blockContent.beforePos + 1))
|
|
1648
|
-
return !1;
|
|
1649
|
-
const d = i.doc.resolve(a.bnBlock.beforePos);
|
|
1650
|
-
if (d.nodeBefore || d.node().type.name !== "column")
|
|
1651
|
-
return !1;
|
|
1652
|
-
const h = i.doc.resolve(a.bnBlock.beforePos), f = i.doc.resolve(h.before()), m = f.before();
|
|
1653
|
-
return l && (i.delete(
|
|
1654
|
-
a.bnBlock.beforePos,
|
|
1655
|
-
a.bnBlock.afterPos
|
|
1656
|
-
), H(i, m), f.pos === m + 1 ? (i.insert(m, a.bnBlock.node), i.setSelection(
|
|
1657
|
-
S.near(i.doc.resolve(m))
|
|
1658
|
-
)) : (i.insert(f.pos - 1, a.bnBlock.node), i.setSelection(
|
|
1659
|
-
S.near(i.doc.resolve(f.pos))
|
|
1660
|
-
))), !0;
|
|
1661
|
-
}),
|
|
1662
|
-
// Deletes the current block if it's an empty block with inline content,
|
|
1663
|
-
// and moves the selection to the previous block.
|
|
1664
|
-
() => s.command(({ state: r }) => {
|
|
1665
|
-
var a;
|
|
1666
|
-
const i = B(r);
|
|
1667
|
-
if (!i.isBlockContainer)
|
|
1668
|
-
return !1;
|
|
1669
|
-
if (i.blockContent.node.childCount === 0 && i.blockContent.node.type.spec.content === "inline*") {
|
|
1670
|
-
const c = _(
|
|
1671
|
-
r.doc,
|
|
1672
|
-
i.bnBlock.beforePos
|
|
1673
|
-
);
|
|
1674
|
-
if (!c || !c.isBlockContainer)
|
|
1675
|
-
return !1;
|
|
1676
|
-
let d = n();
|
|
1677
|
-
if (i.childContainer && d.insertContentAt(
|
|
1678
|
-
i.bnBlock.afterPos,
|
|
1679
|
-
(a = i.childContainer) == null ? void 0 : a.node.content
|
|
1680
|
-
), c.blockContent.node.type.spec.content === "tableRow+") {
|
|
1681
|
-
const m = i.bnBlock.beforePos - 1 - 1 - 1 - 1 - 1;
|
|
1682
|
-
d = d.setTextSelection(
|
|
1683
|
-
m
|
|
1684
|
-
);
|
|
1685
|
-
} else if (c.blockContent.node.type.spec.content === "")
|
|
1686
|
-
d = d.setNodeSelection(
|
|
1687
|
-
c.blockContent.beforePos
|
|
1688
|
-
);
|
|
1689
|
-
else {
|
|
1690
|
-
const u = c.blockContent.afterPos - 1;
|
|
1691
|
-
d = d.setTextSelection(u);
|
|
1692
|
-
}
|
|
1693
|
-
return d.deleteRange({
|
|
1694
|
-
from: i.bnBlock.beforePos,
|
|
1695
|
-
to: i.bnBlock.afterPos
|
|
1696
|
-
}).scrollIntoView().run();
|
|
1697
|
-
}
|
|
1698
|
-
return !1;
|
|
1699
|
-
}),
|
|
1700
|
-
// Deletes previous block if it contains no content and isn't a table,
|
|
1701
|
-
// when the selection is empty and at the start of the block. Moves the
|
|
1702
|
-
// current block into the deleted block's place.
|
|
1703
|
-
() => s.command(({ state: r }) => {
|
|
1704
|
-
const i = B(r);
|
|
1705
|
-
if (!i.isBlockContainer)
|
|
1706
|
-
return !1;
|
|
1707
|
-
const l = r.selection.from === i.blockContent.beforePos + 1, a = r.selection.empty, c = _(
|
|
1708
|
-
r.doc,
|
|
1709
|
-
i.bnBlock.beforePos
|
|
1710
|
-
);
|
|
1711
|
-
if (c && l && a) {
|
|
1712
|
-
const d = _e(
|
|
1713
|
-
r.doc,
|
|
1714
|
-
c
|
|
1715
|
-
);
|
|
1716
|
-
if (!d.isBlockContainer)
|
|
1717
|
-
return !1;
|
|
1718
|
-
if (d.blockContent.node.type.spec.content === "" || d.blockContent.node.type.spec.content === "inline*" && d.blockContent.node.childCount === 0)
|
|
1719
|
-
return n().cut(
|
|
1720
|
-
{
|
|
1721
|
-
from: i.bnBlock.beforePos,
|
|
1722
|
-
to: i.bnBlock.afterPos
|
|
1723
|
-
},
|
|
1724
|
-
d.bnBlock.afterPos
|
|
1725
|
-
).deleteRange({
|
|
1726
|
-
from: d.bnBlock.beforePos,
|
|
1727
|
-
to: d.bnBlock.afterPos
|
|
1728
|
-
}).run();
|
|
1729
|
-
}
|
|
1730
|
-
return !1;
|
|
1731
|
-
})
|
|
1732
|
-
]), e = () => this.editor.commands.first(({ chain: n, commands: s }) => [
|
|
1733
|
-
// Deletes the selection if it's not empty.
|
|
1734
|
-
() => s.deleteSelection(),
|
|
1735
|
-
// Deletes the first child block and un-nests its children, if the
|
|
1736
|
-
// selection is empty and at the end of the current block. If both the
|
|
1737
|
-
// parent and child blocks have inline content, the child block's
|
|
1738
|
-
// content is appended to the parent's. The child block's own children
|
|
1739
|
-
// are unindented before it's deleted.
|
|
1740
|
-
() => s.command(({ state: r }) => {
|
|
1741
|
-
var p;
|
|
1742
|
-
const i = B(r);
|
|
1743
|
-
if (!i.isBlockContainer || !i.childContainer)
|
|
1744
|
-
return !1;
|
|
1745
|
-
const { blockContent: l, childContainer: a } = i, c = r.selection.from === l.afterPos - 1, d = r.selection.empty, u = v(
|
|
1746
|
-
r.doc.resolve(a.beforePos + 1)
|
|
1747
|
-
);
|
|
1748
|
-
if (!u.isBlockContainer)
|
|
1749
|
-
return !1;
|
|
1750
|
-
if (c && d) {
|
|
1751
|
-
const h = u.blockContent.node, f = h.type.spec.content === "inline*", m = l.node.type.spec.content === "inline*";
|
|
1752
|
-
return n().insertContentAt(
|
|
1753
|
-
u.bnBlock.afterPos,
|
|
1754
|
-
((p = u.childContainer) == null ? void 0 : p.node.content) || M.empty
|
|
1755
|
-
).deleteRange(
|
|
1756
|
-
// Deletes whole child container if there's only one child.
|
|
1757
|
-
a.node.childCount === 1 ? {
|
|
1758
|
-
from: a.beforePos,
|
|
1759
|
-
to: a.afterPos
|
|
1760
|
-
} : {
|
|
1761
|
-
from: u.bnBlock.beforePos,
|
|
1762
|
-
to: u.bnBlock.afterPos
|
|
1763
|
-
}
|
|
1764
|
-
).insertContentAt(
|
|
1765
|
-
r.selection.from,
|
|
1766
|
-
f && m ? h.content : null
|
|
1767
|
-
).setTextSelection(r.selection.from).scrollIntoView().run();
|
|
1768
|
-
}
|
|
1769
|
-
return !1;
|
|
1770
|
-
}),
|
|
1771
|
-
// Merges block with the next one (at the same nesting level or lower),
|
|
1772
|
-
// if one exists, the block has no children, and the selection is at the
|
|
1773
|
-
// end of the block.
|
|
1774
|
-
() => s.command(({ state: r }) => {
|
|
1775
|
-
const i = B(r);
|
|
1776
|
-
if (!i.isBlockContainer)
|
|
1777
|
-
return !1;
|
|
1778
|
-
const { bnBlock: l, blockContent: a } = i, c = L(
|
|
1779
|
-
r.doc,
|
|
1780
|
-
i.bnBlock.beforePos
|
|
1781
|
-
);
|
|
1782
|
-
if (!c || !c.isBlockContainer)
|
|
1783
|
-
return !1;
|
|
1784
|
-
const d = r.selection.from === a.afterPos - 1, u = r.selection.empty, p = l.afterPos;
|
|
1785
|
-
return d && u ? n().command(fe(p)).scrollIntoView().run() : !1;
|
|
1786
|
-
}),
|
|
1787
|
-
// If the previous block is a columnList, moves the current block to
|
|
1788
|
-
// the end of the last column in it.
|
|
1789
|
-
() => s.command(({ state: r, tr: i, dispatch: l }) => {
|
|
1790
|
-
const a = B(r);
|
|
1791
|
-
if (!a.isBlockContainer)
|
|
1792
|
-
return !1;
|
|
1793
|
-
const c = L(
|
|
1794
|
-
r.doc,
|
|
1795
|
-
a.bnBlock.beforePos
|
|
1796
|
-
);
|
|
1797
|
-
if (!c || c.isBlockContainer)
|
|
1798
|
-
return !1;
|
|
1799
|
-
if (l) {
|
|
1800
|
-
const d = c.bnBlock.beforePos + 1, u = i.doc.resolve(d + 1);
|
|
1801
|
-
return i.delete(
|
|
1802
|
-
u.pos,
|
|
1803
|
-
u.pos + u.nodeAfter.nodeSize
|
|
1804
|
-
), H(i, c.bnBlock.beforePos), i.insert(a.bnBlock.afterPos, u.nodeAfter), i.setSelection(
|
|
1805
|
-
S.near(i.doc.resolve(u.pos))
|
|
1806
|
-
), !0;
|
|
1807
|
-
}
|
|
1808
|
-
return !1;
|
|
1809
|
-
}),
|
|
1810
|
-
// If the block is the last in a column, moves it to the start of the
|
|
1811
|
-
// next column. If there is no next column, moves it below the
|
|
1812
|
-
// columnList.
|
|
1813
|
-
() => s.command(({ state: r, tr: i, dispatch: l }) => {
|
|
1814
|
-
const a = B(r);
|
|
1815
|
-
if (!a.isBlockContainer || !(i.selection.from === a.blockContent.afterPos - 1))
|
|
1816
|
-
return !1;
|
|
1817
|
-
const d = i.doc.resolve(a.bnBlock.afterPos);
|
|
1818
|
-
if (d.nodeAfter || d.node().type.name !== "column")
|
|
1819
|
-
return !1;
|
|
1820
|
-
const h = i.doc.resolve(a.bnBlock.afterPos), f = i.doc.resolve(h.after()), m = f.after();
|
|
1821
|
-
if (l) {
|
|
1822
|
-
const b = f.pos === m - 1 ? m : f.pos + 1, g = v(
|
|
1823
|
-
i.doc.resolve(b)
|
|
1824
|
-
);
|
|
1825
|
-
i.delete(
|
|
1826
|
-
g.bnBlock.beforePos,
|
|
1827
|
-
g.bnBlock.afterPos
|
|
1828
|
-
), H(
|
|
1829
|
-
i,
|
|
1830
|
-
m - f.node().nodeSize
|
|
1831
|
-
), i.insert(h.pos, g.bnBlock.node), i.setSelection(
|
|
1832
|
-
S.near(i.doc.resolve(b))
|
|
1833
|
-
);
|
|
1834
|
-
}
|
|
1835
|
-
return !0;
|
|
1836
|
-
}),
|
|
1837
|
-
// Deletes the next block at either the same or lower nesting level, if
|
|
1838
|
-
// the selection is empty and at the end of the block. If both the
|
|
1839
|
-
// current and next blocks have inline content, the next block's
|
|
1840
|
-
// content is appended to the current block's. The next block's own
|
|
1841
|
-
// children are unindented before it's deleted.
|
|
1842
|
-
() => s.command(({ state: r }) => {
|
|
1843
|
-
var d;
|
|
1844
|
-
const i = B(r);
|
|
1845
|
-
if (!i.isBlockContainer)
|
|
1846
|
-
return !1;
|
|
1847
|
-
const { blockContent: l } = i, a = r.selection.from === l.afterPos - 1, c = r.selection.empty;
|
|
1848
|
-
if (a && c) {
|
|
1849
|
-
const u = (b, g) => {
|
|
1850
|
-
const x = L(b, g);
|
|
1851
|
-
if (x)
|
|
1852
|
-
return x;
|
|
1853
|
-
const y = Le(b, g);
|
|
1854
|
-
if (y)
|
|
1855
|
-
return u(
|
|
1856
|
-
b,
|
|
1857
|
-
y.bnBlock.beforePos
|
|
1858
|
-
);
|
|
1859
|
-
}, p = u(
|
|
1860
|
-
r.doc,
|
|
1861
|
-
i.bnBlock.beforePos
|
|
1862
|
-
);
|
|
1863
|
-
if (!p || !p.isBlockContainer)
|
|
1864
|
-
return !1;
|
|
1865
|
-
const h = p.blockContent.node, f = h.type.spec.content === "inline*", m = l.node.type.spec.content === "inline*";
|
|
1866
|
-
return n().insertContentAt(
|
|
1867
|
-
p.bnBlock.afterPos,
|
|
1868
|
-
((d = p.childContainer) == null ? void 0 : d.node.content) || M.empty
|
|
1869
|
-
).deleteRange({
|
|
1870
|
-
from: p.bnBlock.beforePos,
|
|
1871
|
-
to: p.bnBlock.afterPos
|
|
1872
|
-
}).insertContentAt(
|
|
1873
|
-
r.selection.from,
|
|
1874
|
-
f && m ? h.content : null
|
|
1875
|
-
).setTextSelection(r.selection.from).scrollIntoView().run();
|
|
1876
|
-
}
|
|
1877
|
-
return !1;
|
|
1878
|
-
}),
|
|
1879
|
-
// Deletes the current block if it's an empty block with inline content,
|
|
1880
|
-
// and moves the selection to the next block.
|
|
1881
|
-
() => s.command(({ state: r }) => {
|
|
1882
|
-
const i = B(r);
|
|
1883
|
-
if (!i.isBlockContainer)
|
|
1884
|
-
return !1;
|
|
1885
|
-
if (i.blockContent.node.childCount === 0 && i.blockContent.node.type.spec.content === "inline*") {
|
|
1886
|
-
const a = L(
|
|
1887
|
-
r.doc,
|
|
1888
|
-
i.bnBlock.beforePos
|
|
1889
|
-
);
|
|
1890
|
-
if (!a || !a.isBlockContainer)
|
|
1891
|
-
return !1;
|
|
1892
|
-
let c = n();
|
|
1893
|
-
if (a.blockContent.node.type.spec.content === "tableRow+") {
|
|
1894
|
-
const f = i.bnBlock.afterPos + 1 + 1 + 1 + 1 + 1;
|
|
1895
|
-
c = c.setTextSelection(
|
|
1896
|
-
f
|
|
1897
|
-
);
|
|
1898
|
-
} else a.blockContent.node.type.spec.content === "" ? c = c.setNodeSelection(
|
|
1899
|
-
a.blockContent.beforePos
|
|
1900
|
-
) : c = c.setTextSelection(
|
|
1901
|
-
a.blockContent.beforePos + 1
|
|
1902
|
-
);
|
|
1903
|
-
return c.deleteRange({
|
|
1904
|
-
from: i.bnBlock.beforePos,
|
|
1905
|
-
to: i.bnBlock.afterPos
|
|
1906
|
-
}).scrollIntoView().run();
|
|
1907
|
-
}
|
|
1908
|
-
return !1;
|
|
1909
|
-
}),
|
|
1910
|
-
// Deletes next block if it contains no content and isn't a table,
|
|
1911
|
-
// when the selection is empty and at the end of the block. Moves the
|
|
1912
|
-
// current block into the deleted block's place.
|
|
1913
|
-
() => s.command(({ state: r }) => {
|
|
1914
|
-
const i = B(r);
|
|
1915
|
-
if (!i.isBlockContainer)
|
|
1916
|
-
return !1;
|
|
1917
|
-
const l = r.selection.from === i.blockContent.afterPos - 1, a = r.selection.empty, c = L(
|
|
1918
|
-
r.doc,
|
|
1919
|
-
i.bnBlock.beforePos
|
|
1920
|
-
);
|
|
1921
|
-
if (!c || !c.isBlockContainer)
|
|
1922
|
-
return !1;
|
|
1923
|
-
if (c && l && a && (c.blockContent.node.type.spec.content === "" || c.blockContent.node.type.spec.content === "inline*" && c.blockContent.node.childCount === 0)) {
|
|
1924
|
-
const u = c.bnBlock.node.lastChild.content;
|
|
1925
|
-
return n().deleteRange({
|
|
1926
|
-
from: c.bnBlock.beforePos,
|
|
1927
|
-
to: c.bnBlock.afterPos
|
|
1928
|
-
}).insertContentAt(
|
|
1929
|
-
i.bnBlock.afterPos,
|
|
1930
|
-
c.bnBlock.node.childCount === 2 ? u : null
|
|
1931
|
-
).run();
|
|
1932
|
-
}
|
|
1933
|
-
return !1;
|
|
1934
|
-
})
|
|
1935
|
-
]), t = (n = !1) => this.editor.commands.first(({ commands: s, tr: r }) => [
|
|
1936
|
-
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
1937
|
-
// of the block.
|
|
1938
|
-
() => s.command(({ state: i }) => {
|
|
1939
|
-
const l = B(i);
|
|
1940
|
-
if (!l.isBlockContainer)
|
|
1941
|
-
return !1;
|
|
1942
|
-
const { bnBlock: a, blockContent: c } = l, { depth: d } = i.doc.resolve(a.beforePos), u = i.selection.$anchor.parentOffset === 0, p = i.selection.anchor === i.selection.head, h = c.node.childCount === 0, f = d > 1;
|
|
1943
|
-
return u && p && h && f ? s.liftListItem("blockContainer") : !1;
|
|
1944
|
-
}),
|
|
1945
|
-
// Creates a hard break if block is configured to do so.
|
|
1946
|
-
() => s.command(({ state: i }) => {
|
|
1947
|
-
var c;
|
|
1948
|
-
const l = B(i), a = ((c = this.options.editor.schema.blockSchema[l.blockNoteType].meta) == null ? void 0 : c.hardBreakShortcut) ?? "shift+enter";
|
|
1949
|
-
if (a === "none")
|
|
1950
|
-
return !1;
|
|
1951
|
-
if (
|
|
1952
|
-
// If shortcut is not configured, or is configured as "shift+enter",
|
|
1953
|
-
// create a hard break for shift+enter, but not for enter.
|
|
1954
|
-
a === "shift+enter" && n || // If shortcut is configured as "enter", create a hard break for
|
|
1955
|
-
// both enter and shift+enter.
|
|
1956
|
-
a === "enter"
|
|
1957
|
-
) {
|
|
1958
|
-
const d = r.storedMarks || r.selection.$head.marks().filter(
|
|
1959
|
-
(u) => this.editor.extensionManager.splittableMarks.includes(
|
|
1960
|
-
u.type.name
|
|
1961
|
-
)
|
|
1962
|
-
);
|
|
1963
|
-
return r.insert(
|
|
1964
|
-
r.selection.head,
|
|
1965
|
-
r.doc.type.schema.nodes.hardBreak.create()
|
|
1966
|
-
).ensureMarks(d), !0;
|
|
1967
|
-
}
|
|
1968
|
-
return !1;
|
|
1969
|
-
}),
|
|
1970
|
-
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1971
|
-
// empty & at the start of the block.
|
|
1972
|
-
() => s.command(({ state: i, dispatch: l, tr: a }) => {
|
|
1973
|
-
var m;
|
|
1974
|
-
const c = B(i);
|
|
1975
|
-
if (!c.isBlockContainer)
|
|
1976
|
-
return !1;
|
|
1977
|
-
const { bnBlock: d, blockContent: u } = c, p = i.selection.$anchor.parentOffset === 0, h = i.selection.anchor === i.selection.head, f = u.node.childCount === 0;
|
|
1978
|
-
if (p && h && f) {
|
|
1979
|
-
const b = d.afterPos, g = b + 2;
|
|
1980
|
-
if (l) {
|
|
1981
|
-
const x = i.schema.nodes.blockContainer.createAndFill(
|
|
1982
|
-
void 0,
|
|
1983
|
-
[
|
|
1984
|
-
i.schema.nodes.paragraph.createAndFill() || void 0,
|
|
1985
|
-
(m = c.childContainer) == null ? void 0 : m.node
|
|
1986
|
-
].filter((y) => y !== void 0)
|
|
1987
|
-
);
|
|
1988
|
-
a.insert(b, x).setSelection(
|
|
1989
|
-
new S(a.doc.resolve(g))
|
|
1990
|
-
).scrollIntoView(), c.childContainer && a.delete(
|
|
1991
|
-
c.childContainer.beforePos,
|
|
1992
|
-
c.childContainer.afterPos
|
|
1993
|
-
);
|
|
1994
|
-
}
|
|
1995
|
-
return !0;
|
|
1996
|
-
}
|
|
1997
|
-
return !1;
|
|
1998
|
-
}),
|
|
1999
|
-
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
2000
|
-
// deletes the selection beforehand, if it's not empty.
|
|
2001
|
-
() => s.command(({ state: i, chain: l }) => {
|
|
2002
|
-
const a = B(i);
|
|
2003
|
-
if (!a.isBlockContainer)
|
|
2004
|
-
return !1;
|
|
2005
|
-
const { blockContent: c } = a, d = i.selection.$anchor.parentOffset === 0;
|
|
2006
|
-
return c.node.childCount === 0 ? !1 : (l().deleteSelection().command(
|
|
2007
|
-
ot(
|
|
2008
|
-
i.selection.from,
|
|
2009
|
-
d,
|
|
2010
|
-
d
|
|
2011
|
-
)
|
|
2012
|
-
).run(), !0);
|
|
2013
|
-
})
|
|
2014
|
-
]);
|
|
2015
|
-
return {
|
|
2016
|
-
Backspace: o,
|
|
2017
|
-
Delete: e,
|
|
2018
|
-
Enter: () => t(),
|
|
2019
|
-
"Shift-Enter": () => t(!0),
|
|
2020
|
-
// Always returning true for tab key presses ensures they're not captured by the browser. Otherwise, they blur the
|
|
2021
|
-
// editor since the browser will try to use tab for keyboard navigation.
|
|
2022
|
-
Tab: () => {
|
|
2023
|
-
var n, s;
|
|
2024
|
-
return this.options.tabBehavior !== "prefer-indent" && ((n = this.options.editor.getExtension(Y)) != null && n.store.state || ((s = this.options.editor.getExtension(J)) == null ? void 0 : s.store.state) !== void 0) ? !1 : Me(this.options.editor);
|
|
2025
|
-
},
|
|
2026
|
-
"Shift-Tab": () => {
|
|
2027
|
-
var n, s;
|
|
2028
|
-
return this.options.tabBehavior !== "prefer-indent" && ((n = this.options.editor.getExtension(Y)) != null && n.store.state || ((s = this.options.editor.getExtension(J)) == null ? void 0 : s.store.state) !== void 0) ? !1 : this.editor.commands.liftListItem("blockContainer");
|
|
2029
|
-
},
|
|
2030
|
-
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
2031
|
-
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
2032
|
-
"Mod-z": () => this.options.editor.undo(),
|
|
2033
|
-
"Mod-y": () => this.options.editor.redo(),
|
|
2034
|
-
"Shift-Mod-z": () => this.options.editor.redo()
|
|
2035
|
-
};
|
|
2036
|
-
}
|
|
2037
|
-
}), pn = te.create({
|
|
2038
|
-
name: "insertion",
|
|
2039
|
-
inclusive: !1,
|
|
2040
|
-
excludes: "deletion modification insertion",
|
|
2041
|
-
addAttributes() {
|
|
2042
|
-
return {
|
|
2043
|
-
id: { default: null, validate: "number" }
|
|
2044
|
-
// note: validate is supported in prosemirror but not in tiptap, so this doesn't actually work (considered not critical)
|
|
2045
|
-
};
|
|
2046
|
-
},
|
|
2047
|
-
extendMarkSchema(o) {
|
|
2048
|
-
return o.name !== "insertion" ? {} : {
|
|
2049
|
-
blocknoteIgnore: !0,
|
|
2050
|
-
inclusive: !1,
|
|
2051
|
-
toDOM(e, t) {
|
|
2052
|
-
return [
|
|
2053
|
-
"ins",
|
|
2054
|
-
{
|
|
2055
|
-
"data-id": String(e.attrs.id),
|
|
2056
|
-
"data-inline": String(t),
|
|
2057
|
-
...!t && { style: "display: contents" }
|
|
2058
|
-
// changed to "contents" to make this work for table rows
|
|
2059
|
-
},
|
|
2060
|
-
0
|
|
2061
|
-
];
|
|
2062
|
-
},
|
|
2063
|
-
parseDOM: [
|
|
2064
|
-
{
|
|
2065
|
-
tag: "ins",
|
|
2066
|
-
getAttrs(e) {
|
|
2067
|
-
return e.dataset.id ? {
|
|
2068
|
-
id: parseInt(e.dataset.id, 10)
|
|
2069
|
-
} : !1;
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
]
|
|
2073
|
-
};
|
|
2074
|
-
}
|
|
2075
|
-
}), fn = te.create({
|
|
2076
|
-
name: "deletion",
|
|
2077
|
-
inclusive: !1,
|
|
2078
|
-
excludes: "insertion modification deletion",
|
|
2079
|
-
addAttributes() {
|
|
2080
|
-
return {
|
|
2081
|
-
id: { default: null, validate: "number" }
|
|
2082
|
-
// note: validate is supported in prosemirror but not in tiptap
|
|
2083
|
-
};
|
|
2084
|
-
},
|
|
2085
|
-
extendMarkSchema(o) {
|
|
2086
|
-
return o.name !== "deletion" ? {} : {
|
|
2087
|
-
blocknoteIgnore: !0,
|
|
2088
|
-
inclusive: !1,
|
|
2089
|
-
// attrs: {
|
|
2090
|
-
// id: { validate: "number" },
|
|
2091
|
-
// },
|
|
2092
|
-
toDOM(e, t) {
|
|
2093
|
-
return [
|
|
2094
|
-
"del",
|
|
2095
|
-
{
|
|
2096
|
-
"data-id": String(e.attrs.id),
|
|
2097
|
-
"data-inline": String(t),
|
|
2098
|
-
...!t && { style: "display: contents" }
|
|
2099
|
-
// changed to "contents" to make this work for table rows
|
|
2100
|
-
},
|
|
2101
|
-
0
|
|
2102
|
-
];
|
|
2103
|
-
},
|
|
2104
|
-
parseDOM: [
|
|
2105
|
-
{
|
|
2106
|
-
tag: "del",
|
|
2107
|
-
getAttrs(e) {
|
|
2108
|
-
return e.dataset.id ? {
|
|
2109
|
-
id: parseInt(e.dataset.id, 10)
|
|
2110
|
-
} : !1;
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
]
|
|
2114
|
-
};
|
|
2115
|
-
}
|
|
2116
|
-
}), hn = te.create({
|
|
2117
|
-
name: "modification",
|
|
2118
|
-
inclusive: !1,
|
|
2119
|
-
excludes: "deletion insertion",
|
|
2120
|
-
addAttributes() {
|
|
2121
|
-
return {
|
|
2122
|
-
id: { default: null, validate: "number" },
|
|
2123
|
-
type: { validate: "string" },
|
|
2124
|
-
attrName: { default: null, validate: "string|null" },
|
|
2125
|
-
previousValue: { default: null },
|
|
2126
|
-
newValue: { default: null }
|
|
2127
|
-
};
|
|
2128
|
-
},
|
|
2129
|
-
extendMarkSchema(o) {
|
|
2130
|
-
return o.name !== "modification" ? {} : {
|
|
2131
|
-
blocknoteIgnore: !0,
|
|
2132
|
-
inclusive: !1,
|
|
2133
|
-
// attrs: {
|
|
2134
|
-
// id: { validate: "number" },
|
|
2135
|
-
// type: { validate: "string" },
|
|
2136
|
-
// attrName: { default: null, validate: "string|null" },
|
|
2137
|
-
// previousValue: { default: null },
|
|
2138
|
-
// newValue: { default: null },
|
|
2139
|
-
// },
|
|
2140
|
-
toDOM(e, t) {
|
|
2141
|
-
return [
|
|
2142
|
-
t ? "span" : "div",
|
|
2143
|
-
{
|
|
2144
|
-
"data-type": "modification",
|
|
2145
|
-
"data-id": String(e.attrs.id),
|
|
2146
|
-
"data-mod-type": e.attrs.type,
|
|
2147
|
-
"data-mod-prev-val": JSON.stringify(e.attrs.previousValue),
|
|
2148
|
-
// TODO: Try to serialize marks with toJSON?
|
|
2149
|
-
"data-mod-new-val": JSON.stringify(e.attrs.newValue)
|
|
2150
|
-
},
|
|
2151
|
-
0
|
|
2152
|
-
];
|
|
2153
|
-
},
|
|
2154
|
-
parseDOM: [
|
|
2155
|
-
{
|
|
2156
|
-
tag: "span[data-type='modification']",
|
|
2157
|
-
getAttrs(e) {
|
|
2158
|
-
return e.dataset.id ? {
|
|
2159
|
-
id: parseInt(e.dataset.id, 10),
|
|
2160
|
-
type: e.dataset.modType,
|
|
2161
|
-
previousValue: e.dataset.modPrevVal,
|
|
2162
|
-
newValue: e.dataset.modNewVal
|
|
2163
|
-
} : !1;
|
|
2164
|
-
}
|
|
2165
|
-
},
|
|
2166
|
-
{
|
|
2167
|
-
tag: "div[data-type='modification']",
|
|
2168
|
-
getAttrs(e) {
|
|
2169
|
-
return e.dataset.id ? {
|
|
2170
|
-
id: parseInt(e.dataset.id, 10),
|
|
2171
|
-
type: e.dataset.modType,
|
|
2172
|
-
previousValue: e.dataset.modPrevVal
|
|
2173
|
-
} : !1;
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
]
|
|
2177
|
-
};
|
|
2178
|
-
}
|
|
2179
|
-
}), mn = T.create({
|
|
2180
|
-
name: "textAlignment",
|
|
2181
|
-
addGlobalAttributes() {
|
|
2182
|
-
return [
|
|
2183
|
-
{
|
|
2184
|
-
// Generally text alignment is handled through props using the custom
|
|
2185
|
-
// blocks API. Tables are the only blocks that are created as TipTap
|
|
2186
|
-
// nodes and ported to blocks, so we need to add text alignment in a
|
|
2187
|
-
// separate extension.
|
|
2188
|
-
types: ["tableCell", "tableHeader"],
|
|
2189
|
-
attributes: {
|
|
2190
|
-
textAlignment: {
|
|
2191
|
-
default: "left",
|
|
2192
|
-
parseHTML: (o) => o.getAttribute("data-text-alignment"),
|
|
2193
|
-
renderHTML: (o) => o.textAlignment === "left" ? {} : {
|
|
2194
|
-
"data-text-alignment": o.textAlignment
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
|
-
];
|
|
2200
|
-
}
|
|
2201
|
-
}), kn = T.create({
|
|
2202
|
-
name: "blockTextColor",
|
|
2203
|
-
addGlobalAttributes() {
|
|
2204
|
-
return [
|
|
2205
|
-
{
|
|
2206
|
-
types: ["table", "tableCell", "tableHeader"],
|
|
2207
|
-
attributes: {
|
|
2208
|
-
textColor: st()
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
];
|
|
2212
|
-
}
|
|
2213
|
-
}), bn = {
|
|
2214
|
-
blockColor: "data-block-color",
|
|
2215
|
-
blockStyle: "data-block-style",
|
|
2216
|
-
id: "data-id",
|
|
2217
|
-
depth: "data-depth",
|
|
2218
|
-
depthChange: "data-depth-change"
|
|
2219
|
-
}, gn = O.create({
|
|
2220
|
-
name: "blockContainer",
|
|
2221
|
-
group: "blockGroupChild bnBlock",
|
|
2222
|
-
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
2223
|
-
content: "blockContent blockGroup?",
|
|
2224
|
-
// Ensures content-specific keyboard handlers trigger first.
|
|
2225
|
-
priority: 50,
|
|
2226
|
-
defining: !0,
|
|
2227
|
-
marks: "insertion modification deletion",
|
|
2228
|
-
parseHTML() {
|
|
2229
|
-
return [
|
|
2230
|
-
{
|
|
2231
|
-
tag: "div[data-node-type=" + this.name + "]",
|
|
2232
|
-
getAttrs: (o) => {
|
|
2233
|
-
if (typeof o == "string")
|
|
2234
|
-
return !1;
|
|
2235
|
-
const e = {};
|
|
2236
|
-
for (const [t, n] of Object.entries(bn))
|
|
2237
|
-
o.getAttribute(n) && (e[t] = o.getAttribute(n));
|
|
2238
|
-
return e;
|
|
2239
|
-
}
|
|
2240
|
-
},
|
|
2241
|
-
// Ignore `blockOuter` divs, but parse the `blockContainer` divs inside them.
|
|
2242
|
-
{
|
|
2243
|
-
tag: 'div[data-node-type="blockOuter"]',
|
|
2244
|
-
skip: !0
|
|
2245
|
-
}
|
|
2246
|
-
];
|
|
2247
|
-
},
|
|
2248
|
-
renderHTML({ HTMLAttributes: o }) {
|
|
2249
|
-
var s;
|
|
2250
|
-
const e = document.createElement("div");
|
|
2251
|
-
e.className = "bn-block-outer", e.setAttribute("data-node-type", "blockOuter");
|
|
2252
|
-
for (const [r, i] of Object.entries(o))
|
|
2253
|
-
r !== "class" && e.setAttribute(r, i);
|
|
2254
|
-
const t = {
|
|
2255
|
-
...((s = this.options.domAttributes) == null ? void 0 : s.block) || {},
|
|
2256
|
-
...o
|
|
2257
|
-
}, n = document.createElement("div");
|
|
2258
|
-
n.className = ee("bn-block", t.class), n.setAttribute("data-node-type", this.name);
|
|
2259
|
-
for (const [r, i] of Object.entries(t))
|
|
2260
|
-
r !== "class" && n.setAttribute(r, i);
|
|
2261
|
-
return e.appendChild(n), {
|
|
2262
|
-
dom: e,
|
|
2263
|
-
contentDOM: n
|
|
2264
|
-
};
|
|
2265
|
-
}
|
|
2266
|
-
}), Bn = O.create({
|
|
2267
|
-
name: "blockGroup",
|
|
2268
|
-
group: "childContainer",
|
|
2269
|
-
content: "blockGroupChild+",
|
|
2270
|
-
marks: "deletion insertion modification",
|
|
2271
|
-
parseHTML() {
|
|
2272
|
-
return [
|
|
2273
|
-
{
|
|
2274
|
-
tag: "div",
|
|
2275
|
-
getAttrs: (o) => typeof o == "string" ? !1 : o.getAttribute("data-node-type") === "blockGroup" ? null : !1
|
|
2276
|
-
}
|
|
2277
|
-
];
|
|
2278
|
-
},
|
|
2279
|
-
renderHTML({ HTMLAttributes: o }) {
|
|
2280
|
-
var n;
|
|
2281
|
-
const e = {
|
|
2282
|
-
...((n = this.options.domAttributes) == null ? void 0 : n.blockGroup) || {},
|
|
2283
|
-
...o
|
|
2284
|
-
}, t = document.createElement("div");
|
|
2285
|
-
t.className = ee(
|
|
2286
|
-
"bn-block-group",
|
|
2287
|
-
e.class
|
|
2288
|
-
), t.setAttribute("data-node-type", "blockGroup");
|
|
2289
|
-
for (const [s, r] of Object.entries(e))
|
|
2290
|
-
s !== "class" && t.setAttribute(s, r);
|
|
2291
|
-
return {
|
|
2292
|
-
dom: t,
|
|
2293
|
-
contentDOM: t
|
|
2294
|
-
};
|
|
2295
|
-
}
|
|
2296
|
-
}), yn = O.create({
|
|
2297
|
-
name: "doc",
|
|
2298
|
-
topNode: !0,
|
|
2299
|
-
content: "blockGroup",
|
|
2300
|
-
marks: "insertion modification deletion"
|
|
2301
|
-
}), Cn = Vt(
|
|
2302
|
-
({ options: o }) => ({
|
|
2303
|
-
key: "collaboration",
|
|
2304
|
-
blockNoteExtensions: [
|
|
2305
|
-
dt(o),
|
|
2306
|
-
ut(o),
|
|
2307
|
-
pt(o),
|
|
2308
|
-
ft(),
|
|
2309
|
-
ht(o)
|
|
2310
|
-
]
|
|
2311
|
-
})
|
|
2312
|
-
);
|
|
2313
|
-
let he = !1;
|
|
2314
|
-
function Sn(o, e) {
|
|
2315
|
-
const t = [
|
|
2316
|
-
N.ClipboardTextSerializer,
|
|
2317
|
-
N.Commands,
|
|
2318
|
-
N.Editable,
|
|
2319
|
-
N.FocusEvents,
|
|
2320
|
-
N.Tabindex,
|
|
2321
|
-
zt,
|
|
2322
|
-
ke.configure({
|
|
2323
|
-
// everything from bnBlock group (nodes that represent a BlockNote block should have an id)
|
|
2324
|
-
types: ["blockContainer", "columnList", "column"],
|
|
2325
|
-
setIdAttribute: e.setIdAttribute
|
|
2326
|
-
}),
|
|
2327
|
-
cn,
|
|
2328
|
-
Gt,
|
|
2329
|
-
// marks:
|
|
2330
|
-
pn,
|
|
2331
|
-
fn,
|
|
2332
|
-
hn,
|
|
2333
|
-
Rt.extend({
|
|
2334
|
-
inclusive: !1
|
|
2335
|
-
}).configure({
|
|
2336
|
-
defaultProtocol: Pt,
|
|
2337
|
-
// only call this once if we have multiple editors installed. Or fix https://github.com/ueberdosis/tiptap/issues/5450
|
|
2338
|
-
protocols: he ? [] : Et
|
|
2339
|
-
}),
|
|
2340
|
-
...Object.values(o.schema.styleSpecs).map((n) => n.implementation.mark.configure({
|
|
2341
|
-
editor: o
|
|
2342
|
-
})),
|
|
2343
|
-
kn,
|
|
2344
|
-
an,
|
|
2345
|
-
mn,
|
|
2346
|
-
// make sure escape blurs editor, so that we can tab to other elements in the host page (accessibility)
|
|
2347
|
-
T.create({
|
|
2348
|
-
name: "OverrideEscape",
|
|
2349
|
-
addKeyboardShortcuts: () => ({
|
|
2350
|
-
Escape: () => {
|
|
2351
|
-
var n;
|
|
2352
|
-
return (n = o.getExtension(ge)) != null && n.shown() ? !1 : (o.blur(), !0);
|
|
2353
|
-
}
|
|
2354
|
-
})
|
|
2355
|
-
}),
|
|
2356
|
-
// nodes
|
|
2357
|
-
yn,
|
|
2358
|
-
gn.configure({
|
|
2359
|
-
editor: o,
|
|
2360
|
-
domAttributes: e.domAttributes
|
|
2361
|
-
}),
|
|
2362
|
-
un.configure({
|
|
2363
|
-
editor: o,
|
|
2364
|
-
tabBehavior: e.tabBehavior
|
|
2365
|
-
}),
|
|
2366
|
-
Bn.configure({
|
|
2367
|
-
domAttributes: e.domAttributes
|
|
2368
|
-
}),
|
|
2369
|
-
...Object.values(o.schema.inlineContentSpecs).filter((n) => n.config !== "link" && n.config !== "text").map((n) => n.implementation.node.configure({
|
|
2370
|
-
editor: o
|
|
2371
|
-
})),
|
|
2372
|
-
...Object.values(o.schema.blockSpecs).flatMap((n) => [
|
|
2373
|
-
// the node extension implementations
|
|
2374
|
-
..."node" in n.implementation ? [
|
|
2375
|
-
n.implementation.node.configure({
|
|
2376
|
-
editor: o,
|
|
2377
|
-
domAttributes: e.domAttributes
|
|
2378
|
-
})
|
|
2379
|
-
] : []
|
|
2380
|
-
]),
|
|
2381
|
-
rn(o),
|
|
2382
|
-
nn(
|
|
2383
|
-
o,
|
|
2384
|
-
e.pasteHandler || ((n) => n.defaultPasteHandler())
|
|
2385
|
-
),
|
|
2386
|
-
Vo(o)
|
|
2387
|
-
];
|
|
2388
|
-
return he = !0, t;
|
|
2389
|
-
}
|
|
2390
|
-
function xn(o, e) {
|
|
2391
|
-
const t = [
|
|
2392
|
-
ye(),
|
|
2393
|
-
mt(e),
|
|
2394
|
-
J(e),
|
|
2395
|
-
Y(e),
|
|
2396
|
-
kt(e),
|
|
2397
|
-
bt(),
|
|
2398
|
-
gt(e),
|
|
2399
|
-
Wt(e),
|
|
2400
|
-
Bt(e),
|
|
2401
|
-
ge(e),
|
|
2402
|
-
...e.trailingBlock !== !1 ? [yt()] : []
|
|
2403
|
-
];
|
|
2404
|
-
return e.collaboration ? t.push(Cn(e.collaboration)) : t.push(Ct()), "table" in o.schema.blockSpecs && t.push(St(e)), e.animations !== !1 && t.push(xt()), t;
|
|
2405
|
-
}
|
|
2406
|
-
class En {
|
|
2407
|
-
constructor(e, t) {
|
|
2408
|
-
/**
|
|
2409
|
-
* A set of extension keys which are disabled by the options
|
|
2410
|
-
*/
|
|
2411
|
-
k(this, "disabledExtensions", /* @__PURE__ */ new Set());
|
|
2412
|
-
/**
|
|
2413
|
-
* A list of all the extensions that are registered to the editor
|
|
2414
|
-
*/
|
|
2415
|
-
k(this, "extensions", []);
|
|
2416
|
-
/**
|
|
2417
|
-
* A map of all the abort controllers for each extension that has an init method defined
|
|
2418
|
-
*/
|
|
2419
|
-
k(this, "abortMap", /* @__PURE__ */ new Map());
|
|
2420
|
-
/**
|
|
2421
|
-
* A map of all the extension factories that are registered to the editor
|
|
2422
|
-
*/
|
|
2423
|
-
k(this, "extensionFactories", /* @__PURE__ */ new Map());
|
|
2424
|
-
/**
|
|
2425
|
-
* Because a single blocknote extension can both have it's own prosemirror plugins & additional generated ones (e.g. keymap & input rules plugins)
|
|
2426
|
-
* We need to keep track of all the plugins for each extension, so that we can remove them when the extension is unregistered
|
|
2427
|
-
*/
|
|
2428
|
-
k(this, "extensionPlugins", /* @__PURE__ */ new Map());
|
|
2429
|
-
this.editor = e, this.options = t, e.onMount(() => {
|
|
2430
|
-
for (const n of this.extensions)
|
|
2431
|
-
if (n.mount) {
|
|
2432
|
-
const s = new window.AbortController(), r = n.mount({
|
|
2433
|
-
dom: e.prosemirrorView.dom,
|
|
2434
|
-
root: e.prosemirrorView.root,
|
|
2435
|
-
signal: s.signal
|
|
2436
|
-
});
|
|
2437
|
-
r && s.signal.addEventListener("abort", () => {
|
|
2438
|
-
r();
|
|
2439
|
-
}), this.abortMap.set(n, s);
|
|
2440
|
-
}
|
|
2441
|
-
}), e.onUnmount(() => {
|
|
2442
|
-
for (const [n, s] of this.abortMap.entries())
|
|
2443
|
-
this.abortMap.delete(n), s.abort();
|
|
2444
|
-
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
2445
|
-
for (const n of xn(this.editor, this.options))
|
|
2446
|
-
this.addExtension(n);
|
|
2447
|
-
for (const n of this.options.extensions ?? [])
|
|
2448
|
-
this.addExtension(n);
|
|
2449
|
-
for (const n of Object.values(this.editor.schema.blockSpecs))
|
|
2450
|
-
for (const s of n.extensions ?? [])
|
|
2451
|
-
this.addExtension(s);
|
|
2452
|
-
}
|
|
2453
|
-
/**
|
|
2454
|
-
* Register one or more extensions to the editor after the editor is initialized.
|
|
2455
|
-
*
|
|
2456
|
-
* This allows users to switch on & off extensions "at runtime".
|
|
2457
|
-
*/
|
|
2458
|
-
registerExtension(e) {
|
|
2459
|
-
var r;
|
|
2460
|
-
const t = [].concat(e).filter(Boolean);
|
|
2461
|
-
if (!t.length) {
|
|
2462
|
-
console.warn("No extensions found to register", e);
|
|
2463
|
-
return;
|
|
2464
|
-
}
|
|
2465
|
-
const n = t.map((i) => this.addExtension(i)).filter(Boolean), s = /* @__PURE__ */ new Set();
|
|
2466
|
-
for (const i of n)
|
|
2467
|
-
i != null && i.tiptapExtensions && console.warn(
|
|
2468
|
-
`Extension ${i.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,
|
|
2469
|
-
i
|
|
2470
|
-
), (r = i == null ? void 0 : i.inputRules) != null && r.length && console.warn(
|
|
2471
|
-
`Extension ${i.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,
|
|
2472
|
-
i
|
|
2473
|
-
), this.getProsemirrorPluginsFromExtension(i).plugins.forEach(
|
|
2474
|
-
(l) => {
|
|
2475
|
-
s.add(l);
|
|
2476
|
-
}
|
|
2477
|
-
);
|
|
2478
|
-
this.updatePlugins((i) => [...i, ...s]);
|
|
2479
|
-
}
|
|
2480
|
-
/**
|
|
2481
|
-
* Register an extension to the editor
|
|
2482
|
-
* @param extension - The extension to register
|
|
2483
|
-
* @returns The extension instance
|
|
2484
|
-
*/
|
|
2485
|
-
addExtension(e) {
|
|
2486
|
-
let t;
|
|
2487
|
-
if (typeof e == "function" ? t = e({ editor: this.editor }) : t = e, !(!t || this.disabledExtensions.has(t.key))) {
|
|
2488
|
-
if (typeof e == "function") {
|
|
2489
|
-
const n = t[Ut];
|
|
2490
|
-
typeof n == "function" && this.extensionFactories.set(n, t);
|
|
2491
|
-
}
|
|
2492
|
-
if (this.extensions.push(t), t.blockNoteExtensions)
|
|
2493
|
-
for (const n of t.blockNoteExtensions)
|
|
2494
|
-
this.addExtension(n);
|
|
2495
|
-
return t;
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
/**
|
|
2499
|
-
* Resolve an extension or a list of extensions into a list of extension instances
|
|
2500
|
-
* @param toResolve - The extension or list of extensions to resolve
|
|
2501
|
-
* @returns A list of extension instances
|
|
2502
|
-
*/
|
|
2503
|
-
resolveExtensions(e) {
|
|
2504
|
-
const t = [];
|
|
2505
|
-
if (typeof e == "function") {
|
|
2506
|
-
const n = this.extensionFactories.get(e);
|
|
2507
|
-
n && t.push(n);
|
|
2508
|
-
} else if (Array.isArray(e))
|
|
2509
|
-
for (const n of e)
|
|
2510
|
-
t.push(...this.resolveExtensions(n));
|
|
2511
|
-
else if (typeof e == "object" && "key" in e)
|
|
2512
|
-
t.push(e);
|
|
2513
|
-
else if (typeof e == "string") {
|
|
2514
|
-
const n = this.extensions.find((s) => s.key === e);
|
|
2515
|
-
n && t.push(n);
|
|
2516
|
-
}
|
|
2517
|
-
return t;
|
|
2518
|
-
}
|
|
2519
|
-
/**
|
|
2520
|
-
* Unregister an extension from the editor
|
|
2521
|
-
* @param toUnregister - The extension to unregister
|
|
2522
|
-
* @returns void
|
|
2523
|
-
*/
|
|
2524
|
-
unregisterExtension(e) {
|
|
2525
|
-
var r;
|
|
2526
|
-
const t = this.resolveExtensions(e);
|
|
2527
|
-
if (!t.length) {
|
|
2528
|
-
console.warn("No extensions found to unregister", e);
|
|
2529
|
-
return;
|
|
2530
|
-
}
|
|
2531
|
-
let n = !1;
|
|
2532
|
-
const s = /* @__PURE__ */ new Set();
|
|
2533
|
-
for (const i of t) {
|
|
2534
|
-
this.extensions = this.extensions.filter((a) => a !== i), this.extensionFactories.forEach((a, c) => {
|
|
2535
|
-
a === i && this.extensionFactories.delete(c);
|
|
2536
|
-
}), (r = this.abortMap.get(i)) == null || r.abort(), this.abortMap.delete(i);
|
|
2537
|
-
const l = this.extensionPlugins.get(i);
|
|
2538
|
-
l == null || l.forEach((a) => {
|
|
2539
|
-
s.add(a);
|
|
2540
|
-
}), this.extensionPlugins.delete(i), i.tiptapExtensions && !n && (n = !0, console.warn(
|
|
2541
|
-
`Extension ${i.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`,
|
|
2542
|
-
e
|
|
2543
|
-
));
|
|
2544
|
-
}
|
|
2545
|
-
this.updatePlugins(
|
|
2546
|
-
(i) => i.filter((l) => !s.has(l))
|
|
2547
|
-
);
|
|
2548
|
-
}
|
|
2549
|
-
/**
|
|
2550
|
-
* Allows resetting the current prosemirror state's plugins
|
|
2551
|
-
* @param update - A function that takes the current plugins and returns the new plugins
|
|
2552
|
-
* @returns void
|
|
2553
|
-
*/
|
|
2554
|
-
updatePlugins(e) {
|
|
2555
|
-
const t = this.editor.prosemirrorState, n = t.reconfigure({
|
|
2556
|
-
plugins: e(t.plugins.slice())
|
|
2557
|
-
});
|
|
2558
|
-
this.editor.prosemirrorView.updateState(n);
|
|
2559
|
-
}
|
|
2560
|
-
/**
|
|
2561
|
-
* Get all the extensions that are registered to the editor
|
|
2562
|
-
*/
|
|
2563
|
-
getTiptapExtensions() {
|
|
2564
|
-
var s;
|
|
2565
|
-
const e = Sn(
|
|
2566
|
-
this.editor,
|
|
2567
|
-
this.options
|
|
2568
|
-
).filter((r) => !this.disabledExtensions.has(r.name)), t = Tt(this.extensions), n = /* @__PURE__ */ new Map();
|
|
2569
|
-
for (const r of this.extensions) {
|
|
2570
|
-
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
2571
|
-
const i = t(r.key), { plugins: l, inputRules: a } = this.getProsemirrorPluginsFromExtension(r);
|
|
2572
|
-
l.length && e.push(
|
|
2573
|
-
T.create({
|
|
2574
|
-
name: r.key,
|
|
2575
|
-
priority: i,
|
|
2576
|
-
addProseMirrorPlugins: () => l
|
|
2577
|
-
})
|
|
2578
|
-
), a.length && (n.has(i) || n.set(i, []), n.get(i).push(...a));
|
|
2579
|
-
}
|
|
2580
|
-
e.push(
|
|
2581
|
-
T.create({
|
|
2582
|
-
name: "blocknote-input-rules",
|
|
2583
|
-
addProseMirrorPlugins() {
|
|
2584
|
-
const r = [];
|
|
2585
|
-
return Array.from(n.keys()).sort().reverse().forEach((i) => {
|
|
2586
|
-
r.push(...n.get(i));
|
|
2587
|
-
}), [$t({ rules: r })];
|
|
2588
|
-
}
|
|
2589
|
-
})
|
|
2590
|
-
);
|
|
2591
|
-
for (const r of ((s = this.options._tiptapOptions) == null ? void 0 : s.extensions) ?? [])
|
|
2592
|
-
e.push(r);
|
|
2593
|
-
return e;
|
|
2594
|
-
}
|
|
2595
|
-
/**
|
|
2596
|
-
* This maps a blocknote extension into an array of Prosemirror plugins if it has any of the following:
|
|
2597
|
-
* - plugins
|
|
2598
|
-
* - keyboard shortcuts
|
|
2599
|
-
* - input rules
|
|
2600
|
-
*/
|
|
2601
|
-
getProsemirrorPluginsFromExtension(e) {
|
|
2602
|
-
var s, r, i;
|
|
2603
|
-
const t = [...e.prosemirrorPlugins ?? []], n = [];
|
|
2604
|
-
return !((s = e.prosemirrorPlugins) != null && s.length) && !Object.keys(e.keyboardShortcuts || {}).length && !((r = e.inputRules) != null && r.length) ? { plugins: t, inputRules: n } : (this.extensionPlugins.set(e, t), (i = e.inputRules) != null && i.length && n.push(
|
|
2605
|
-
...e.inputRules.map((l) => new Ht(l.find, (a, c, d, u) => {
|
|
2606
|
-
const p = l.replace({
|
|
2607
|
-
match: c,
|
|
2608
|
-
range: { from: d, to: u },
|
|
2609
|
-
editor: this.editor
|
|
2610
|
-
});
|
|
2611
|
-
if (p) {
|
|
2612
|
-
const h = this.editor.getTextCursorPosition();
|
|
2613
|
-
if (this.editor.schema.blockSchema[h.block.type].content !== "inline")
|
|
2614
|
-
return null;
|
|
2615
|
-
const f = z(a.tr), m = a.tr.deleteRange(d, u);
|
|
2616
|
-
return rt(m, f.bnBlock.beforePos, p), m;
|
|
2617
|
-
}
|
|
2618
|
-
return null;
|
|
2619
|
-
}))
|
|
2620
|
-
), Object.keys(e.keyboardShortcuts || {}).length && t.push(
|
|
2621
|
-
Ft(
|
|
2622
|
-
Object.fromEntries(
|
|
2623
|
-
Object.entries(e.keyboardShortcuts).map(([l, a]) => [
|
|
2624
|
-
l,
|
|
2625
|
-
() => a({ editor: this.editor })
|
|
2626
|
-
])
|
|
2627
|
-
)
|
|
2628
|
-
)
|
|
2629
|
-
), { plugins: t, inputRules: n });
|
|
2630
|
-
}
|
|
2631
|
-
/**
|
|
2632
|
-
* Get all extensions
|
|
2633
|
-
*/
|
|
2634
|
-
getExtensions() {
|
|
2635
|
-
return new Map(
|
|
2636
|
-
this.extensions.map((e) => [e.key, e])
|
|
2637
|
-
);
|
|
2638
|
-
}
|
|
2639
|
-
getExtension(e) {
|
|
2640
|
-
if (typeof e == "string") {
|
|
2641
|
-
const t = this.extensions.find((n) => n.key === e);
|
|
2642
|
-
return t || void 0;
|
|
2643
|
-
} else if (typeof e == "function") {
|
|
2644
|
-
const t = this.extensionFactories.get(e);
|
|
2645
|
-
return t || void 0;
|
|
2646
|
-
}
|
|
2647
|
-
throw new Error(`Invalid extension type: ${typeof e}`);
|
|
2648
|
-
}
|
|
2649
|
-
/**
|
|
2650
|
-
* Check if an extension exists
|
|
2651
|
-
*/
|
|
2652
|
-
hasExtension(e) {
|
|
2653
|
-
return typeof e == "string" ? this.extensions.some((t) => t.key === e) : typeof e == "object" && "key" in e ? this.extensions.some((t) => t.key === e.key) : typeof e == "function" ? this.extensionFactories.has(e) : !1;
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
function Pn(o, e) {
|
|
2657
|
-
let { $from: t, $to: n } = e;
|
|
2658
|
-
if (t.pos > t.start() && t.pos < o.content.size) {
|
|
2659
|
-
const s = o.textBetween(t.pos, t.pos + 1);
|
|
2660
|
-
if (/^[\w\p{P}]$/u.test(s)) {
|
|
2661
|
-
const i = o.textBetween(t.start(), t.pos).match(/[\w\p{P}]+$/u);
|
|
2662
|
-
i && (t = o.resolve(t.pos - i[0].length));
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
if (n.pos < n.end() && n.pos > 0) {
|
|
2666
|
-
const s = o.textBetween(n.pos - 1, n.pos);
|
|
2667
|
-
if (/^[\w\p{P}]$/u.test(s)) {
|
|
2668
|
-
const i = o.textBetween(n.pos, n.end()).match(/^[\w\p{P}]+/u);
|
|
2669
|
-
i && (n = o.resolve(n.pos + i[0].length));
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
return { $from: t, $to: n, from: t.pos, to: n.pos };
|
|
2673
|
-
}
|
|
2674
|
-
function Tn(o) {
|
|
2675
|
-
const e = E(o);
|
|
2676
|
-
if (o.selection.empty || "node" in o.selection)
|
|
2677
|
-
return;
|
|
2678
|
-
const t = o.doc.resolve(
|
|
2679
|
-
D(o.doc, o.selection.from).posBeforeNode
|
|
2680
|
-
), n = o.doc.resolve(
|
|
2681
|
-
D(o.doc, o.selection.to).posBeforeNode
|
|
2682
|
-
), s = (c, d) => {
|
|
2683
|
-
const u = t.posAtIndex(c, d), p = o.doc.resolve(u).nodeAfter;
|
|
2684
|
-
if (!p)
|
|
2685
|
-
throw new Error(
|
|
2686
|
-
`Error getting selection - node not found at position ${u}`
|
|
2687
|
-
);
|
|
2688
|
-
return C(p, e);
|
|
2689
|
-
}, r = [], i = t.sharedDepth(n.pos), l = t.index(i), a = n.index(i);
|
|
2690
|
-
if (t.depth > i) {
|
|
2691
|
-
r.push(C(t.nodeAfter, e));
|
|
2692
|
-
for (let c = t.depth; c > i; c--)
|
|
2693
|
-
if (t.node(c).type.isInGroup("childContainer")) {
|
|
2694
|
-
const u = t.index(c) + 1, p = t.node(c).childCount;
|
|
2695
|
-
for (let h = u; h < p; h++)
|
|
2696
|
-
r.push(s(h, c));
|
|
2697
|
-
}
|
|
2698
|
-
} else
|
|
2699
|
-
r.push(s(l, i));
|
|
2700
|
-
for (let c = l + 1; c <= a; c++)
|
|
2701
|
-
r.push(s(c, i));
|
|
2702
|
-
if (r.length === 0)
|
|
2703
|
-
throw new Error(
|
|
2704
|
-
`Error getting selection - selection doesn't span any blocks (${o.selection})`
|
|
2705
|
-
);
|
|
2706
|
-
return {
|
|
2707
|
-
blocks: r
|
|
2708
|
-
};
|
|
2709
|
-
}
|
|
2710
|
-
function wn(o, e, t) {
|
|
2711
|
-
const n = typeof e == "string" ? e : e.id, s = typeof t == "string" ? t : t.id, r = E(o), i = be(r);
|
|
2712
|
-
if (n === s)
|
|
2713
|
-
throw new Error(
|
|
2714
|
-
`Attempting to set selection with the same anchor and head blocks (id ${n})`
|
|
2715
|
-
);
|
|
2716
|
-
const l = P(n, o.doc);
|
|
2717
|
-
if (!l)
|
|
2718
|
-
throw new Error(`Block with ID ${n} not found`);
|
|
2719
|
-
const a = P(s, o.doc);
|
|
2720
|
-
if (!a)
|
|
2721
|
-
throw new Error(`Block with ID ${s} not found`);
|
|
2722
|
-
const c = K(l), d = K(a), u = i.blockSchema[c.blockNoteType], p = i.blockSchema[d.blockNoteType];
|
|
2723
|
-
if (!c.isBlockContainer || u.content === "none")
|
|
2724
|
-
throw new Error(
|
|
2725
|
-
`Attempting to set selection anchor in block without content (id ${n})`
|
|
2726
|
-
);
|
|
2727
|
-
if (!d.isBlockContainer || p.content === "none")
|
|
2728
|
-
throw new Error(
|
|
2729
|
-
`Attempting to set selection anchor in block without content (id ${s})`
|
|
2730
|
-
);
|
|
2731
|
-
let h, f;
|
|
2732
|
-
if (u.content === "table") {
|
|
2733
|
-
const m = re.get(c.blockContent.node);
|
|
2734
|
-
h = c.blockContent.beforePos + m.positionAt(0, 0, c.blockContent.node) + 1 + 2;
|
|
2735
|
-
} else
|
|
2736
|
-
h = c.blockContent.beforePos + 1;
|
|
2737
|
-
if (p.content === "table") {
|
|
2738
|
-
const m = re.get(d.blockContent.node), b = d.blockContent.beforePos + m.positionAt(
|
|
2739
|
-
m.height - 1,
|
|
2740
|
-
m.width - 1,
|
|
2741
|
-
d.blockContent.node
|
|
2742
|
-
) + 1, g = o.doc.resolve(b).nodeAfter.nodeSize;
|
|
2743
|
-
f = b + g - 2;
|
|
2744
|
-
} else
|
|
2745
|
-
f = d.blockContent.afterPos - 1;
|
|
2746
|
-
o.setSelection(S.create(o.doc, h, f));
|
|
2747
|
-
}
|
|
2748
|
-
function Mn(o, e = !1) {
|
|
2749
|
-
const t = E(o), n = e ? Pn(o.doc, o.selection) : o.selection;
|
|
2750
|
-
let s = n.$from, r = n.$to;
|
|
2751
|
-
for (; r.parentOffset >= r.parent.nodeSize - 2 && r.depth > 0; )
|
|
2752
|
-
r = o.doc.resolve(r.pos + 1);
|
|
2753
|
-
for (; r.parentOffset === 0 && r.depth > 0; )
|
|
2754
|
-
r = o.doc.resolve(r.pos - 1);
|
|
2755
|
-
for (; s.parentOffset === 0 && s.depth > 0; )
|
|
2756
|
-
s = o.doc.resolve(s.pos - 1);
|
|
2757
|
-
for (; s.parentOffset >= s.parent.nodeSize - 2 && s.depth > 0; )
|
|
2758
|
-
s = o.doc.resolve(s.pos + 1);
|
|
2759
|
-
const i = Ke(
|
|
2760
|
-
o.doc.slice(s.pos, r.pos, !0),
|
|
2761
|
-
t
|
|
2762
|
-
);
|
|
2763
|
-
return {
|
|
2764
|
-
_meta: {
|
|
2765
|
-
startPos: s.pos,
|
|
2766
|
-
endPos: r.pos
|
|
2767
|
-
},
|
|
2768
|
-
...i
|
|
2769
|
-
};
|
|
2770
|
-
}
|
|
2771
|
-
function vn(o) {
|
|
2772
|
-
const { bnBlock: e } = z(o), t = E(o.doc), n = o.doc.resolve(e.beforePos), s = n.nodeBefore, r = o.doc.resolve(e.afterPos).nodeAfter;
|
|
2773
|
-
let i;
|
|
2774
|
-
return n.depth > 1 && (i = n.node(), i.type.isInGroup("bnBlock") || (i = n.node(n.depth - 1))), {
|
|
2775
|
-
block: C(e.node, t),
|
|
2776
|
-
prevBlock: s === null ? void 0 : C(s, t),
|
|
2777
|
-
nextBlock: r === null ? void 0 : C(r, t),
|
|
2778
|
-
parentBlock: i === void 0 ? void 0 : C(i, t)
|
|
2779
|
-
};
|
|
2780
|
-
}
|
|
2781
|
-
function De(o, e, t = "start") {
|
|
2782
|
-
const n = typeof e == "string" ? e : e.id, s = E(o.doc), r = be(s), i = P(n, o.doc);
|
|
2783
|
-
if (!i)
|
|
2784
|
-
throw new Error(`Block with ID ${n} not found`);
|
|
2785
|
-
const l = K(i), a = r.blockSchema[l.blockNoteType].content;
|
|
2786
|
-
if (l.isBlockContainer) {
|
|
2787
|
-
const c = l.blockContent;
|
|
2788
|
-
if (a === "none") {
|
|
2789
|
-
o.setSelection($.create(o.doc, c.beforePos));
|
|
2790
|
-
return;
|
|
2791
|
-
}
|
|
2792
|
-
if (a === "inline")
|
|
2793
|
-
t === "start" ? o.setSelection(
|
|
2794
|
-
S.create(o.doc, c.beforePos + 1)
|
|
2795
|
-
) : o.setSelection(
|
|
2796
|
-
S.create(o.doc, c.afterPos - 1)
|
|
2797
|
-
);
|
|
2798
|
-
else if (a === "table")
|
|
2799
|
-
t === "start" ? o.setSelection(
|
|
2800
|
-
S.create(o.doc, c.beforePos + 4)
|
|
2801
|
-
) : o.setSelection(
|
|
2802
|
-
S.create(o.doc, c.afterPos - 4)
|
|
2803
|
-
);
|
|
2804
|
-
else
|
|
2805
|
-
throw new U(a);
|
|
2806
|
-
} else {
|
|
2807
|
-
const c = t === "start" ? l.childContainer.node.firstChild : l.childContainer.node.lastChild;
|
|
2808
|
-
De(o, c.attrs.id, t);
|
|
2809
|
-
}
|
|
2810
|
-
}
|
|
2811
|
-
class In {
|
|
2812
|
-
constructor(e) {
|
|
2813
|
-
this.editor = e;
|
|
2814
|
-
}
|
|
2815
|
-
/**
|
|
2816
|
-
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
2817
|
-
* that the selection spans across.
|
|
2818
|
-
*
|
|
2819
|
-
* If the selection starts / ends halfway through a block, the returned data will contain the entire block.
|
|
2820
|
-
*/
|
|
2821
|
-
getSelection() {
|
|
2822
|
-
return this.editor.transact((e) => Tn(e));
|
|
2823
|
-
}
|
|
2824
|
-
/**
|
|
2825
|
-
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
2826
|
-
* that the selection spans across.
|
|
2827
|
-
*
|
|
2828
|
-
* If the selection starts / ends halfway through a block, the returned block will be
|
|
2829
|
-
* only the part of the block that is included in the selection.
|
|
2830
|
-
*/
|
|
2831
|
-
getSelectionCutBlocks(e = !1) {
|
|
2832
|
-
return this.editor.transact(
|
|
2833
|
-
(t) => Mn(t, e)
|
|
2834
|
-
);
|
|
2835
|
-
}
|
|
2836
|
-
/**
|
|
2837
|
-
* Sets the selection to a range of blocks.
|
|
2838
|
-
* @param startBlock The identifier of the block that should be the start of the selection.
|
|
2839
|
-
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
2840
|
-
*/
|
|
2841
|
-
setSelection(e, t) {
|
|
2842
|
-
return this.editor.transact((n) => wn(n, e, t));
|
|
2843
|
-
}
|
|
2844
|
-
/**
|
|
2845
|
-
* Gets a snapshot of the current text cursor position.
|
|
2846
|
-
* @returns A snapshot of the current text cursor position.
|
|
2847
|
-
*/
|
|
2848
|
-
getTextCursorPosition() {
|
|
2849
|
-
return this.editor.transact((e) => vn(e));
|
|
2850
|
-
}
|
|
2851
|
-
/**
|
|
2852
|
-
* Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
|
|
2853
|
-
* not be found.
|
|
2854
|
-
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
2855
|
-
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
2856
|
-
*/
|
|
2857
|
-
setTextCursorPosition(e, t = "start") {
|
|
2858
|
-
return this.editor.transact(
|
|
2859
|
-
(n) => De(n, e, t)
|
|
2860
|
-
);
|
|
2861
|
-
}
|
|
2862
|
-
/**
|
|
2863
|
-
* Gets the bounding box of the current selection.
|
|
2864
|
-
*/
|
|
2865
|
-
getSelectionBoundingBox() {
|
|
2866
|
-
if (!this.editor.prosemirrorView)
|
|
2867
|
-
return;
|
|
2868
|
-
const { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((r) => r.$from.pos)), s = Math.max(...t.map((r) => r.$to.pos));
|
|
2869
|
-
if (vt(e)) {
|
|
2870
|
-
const r = this.editor.prosemirrorView.nodeDOM(n);
|
|
2871
|
-
if (r)
|
|
2872
|
-
return r.getBoundingClientRect();
|
|
2873
|
-
}
|
|
2874
|
-
return It(
|
|
2875
|
-
this.editor.prosemirrorView,
|
|
2876
|
-
n,
|
|
2877
|
-
s
|
|
2878
|
-
).toJSON();
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
class An {
|
|
2882
|
-
constructor(e) {
|
|
2883
|
-
/**
|
|
2884
|
-
* Stores the currently active transaction, which is the accumulated transaction from all {@link dispatch} calls during a {@link transact} calls
|
|
2885
|
-
*/
|
|
2886
|
-
k(this, "activeTransaction", null);
|
|
2887
|
-
// Flag to indicate if we're in a `can` call
|
|
2888
|
-
k(this, "isInCan", !1);
|
|
2889
|
-
this.editor = e;
|
|
2890
|
-
}
|
|
2891
|
-
/**
|
|
2892
|
-
* For any command that can be executed, you can check if it can be executed by calling `editor.can(command)`.
|
|
2893
|
-
* @example
|
|
2894
|
-
* ```ts
|
|
2895
|
-
* if (editor.can(editor.undo)) {
|
|
2896
|
-
* // show button
|
|
2897
|
-
* } else {
|
|
2898
|
-
* // hide button
|
|
2899
|
-
* }
|
|
2900
|
-
*/
|
|
2901
|
-
can(e) {
|
|
2902
|
-
try {
|
|
2903
|
-
return this.isInCan = !0, e();
|
|
2904
|
-
} finally {
|
|
2905
|
-
this.isInCan = !1;
|
|
2906
|
-
}
|
|
2907
|
-
}
|
|
2908
|
-
/**
|
|
2909
|
-
* Execute a prosemirror command. This is mostly for backwards compatibility with older code.
|
|
2910
|
-
*
|
|
2911
|
-
* @note You should prefer the {@link transact} method when possible, as it will automatically handle the dispatching of the transaction and work across blocknote transactions.
|
|
2912
|
-
*
|
|
2913
|
-
* @example
|
|
2914
|
-
* ```ts
|
|
2915
|
-
* editor.exec((state, dispatch, view) => {
|
|
2916
|
-
* dispatch(state.tr.insertText("Hello, world!"));
|
|
2917
|
-
* });
|
|
2918
|
-
* ```
|
|
2919
|
-
*/
|
|
2920
|
-
exec(e) {
|
|
2921
|
-
if (this.activeTransaction)
|
|
2922
|
-
throw new Error(
|
|
2923
|
-
"`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call"
|
|
2924
|
-
);
|
|
2925
|
-
if (this.isInCan)
|
|
2926
|
-
return this.canExec(e);
|
|
2927
|
-
const t = this.prosemirrorState, n = this.prosemirrorView;
|
|
2928
|
-
return e(t, (r) => this.prosemirrorView.dispatch(r), n);
|
|
2929
|
-
}
|
|
2930
|
-
/**
|
|
2931
|
-
* Check if a command can be executed. A command should return `false` if it is not valid in the current state.
|
|
2932
|
-
*
|
|
2933
|
-
* @example
|
|
2934
|
-
* ```ts
|
|
2935
|
-
* if (editor.canExec(command)) {
|
|
2936
|
-
* // show button
|
|
2937
|
-
* } else {
|
|
2938
|
-
* // hide button
|
|
2939
|
-
* }
|
|
2940
|
-
* ```
|
|
2941
|
-
*/
|
|
2942
|
-
canExec(e) {
|
|
2943
|
-
if (this.activeTransaction)
|
|
2944
|
-
throw new Error(
|
|
2945
|
-
"`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call"
|
|
2946
|
-
);
|
|
2947
|
-
const t = this.prosemirrorState, n = this.prosemirrorView;
|
|
2948
|
-
return e(t, void 0, n);
|
|
2949
|
-
}
|
|
2950
|
-
/**
|
|
2951
|
-
* Execute a function within a "blocknote transaction".
|
|
2952
|
-
* All changes to the editor within the transaction will be grouped together, so that
|
|
2953
|
-
* we can dispatch them as a single operation (thus creating only a single undo step)
|
|
2954
|
-
*
|
|
2955
|
-
* @note There is no need to dispatch the transaction, as it will be automatically dispatched when the callback is complete.
|
|
2956
|
-
*
|
|
2957
|
-
* @example
|
|
2958
|
-
* ```ts
|
|
2959
|
-
* // All changes to the editor will be grouped together
|
|
2960
|
-
* editor.transact((tr) => {
|
|
2961
|
-
* tr.insertText("Hello, world!");
|
|
2962
|
-
* // These two operations will be grouped together in a single undo step
|
|
2963
|
-
* editor.transact((tr) => {
|
|
2964
|
-
* tr.insertText("Hello, world!");
|
|
2965
|
-
* });
|
|
2966
|
-
* });
|
|
2967
|
-
* ```
|
|
2968
|
-
*/
|
|
2969
|
-
transact(e) {
|
|
2970
|
-
if (this.activeTransaction)
|
|
2971
|
-
return e(this.activeTransaction);
|
|
2972
|
-
try {
|
|
2973
|
-
this.activeTransaction = this.editor._tiptapEditor.state.tr;
|
|
2974
|
-
const t = e(this.activeTransaction), n = this.activeTransaction;
|
|
2975
|
-
return this.activeTransaction = null, n && // Only dispatch if the transaction was actually modified in some way
|
|
2976
|
-
(n.docChanged || n.selectionSet || n.scrolledIntoView || n.storedMarksSet || !n.isGeneric) && this.prosemirrorView.dispatch(n), t;
|
|
2977
|
-
} finally {
|
|
2978
|
-
this.activeTransaction = null;
|
|
2979
|
-
}
|
|
2980
|
-
}
|
|
2981
|
-
/**
|
|
2982
|
-
* Get the underlying prosemirror state
|
|
2983
|
-
* @note Prefer using `editor.transact` to read the current editor state, as that will ensure the state is up to date
|
|
2984
|
-
* @see https://prosemirror.net/docs/ref/#state.EditorState
|
|
2985
|
-
*/
|
|
2986
|
-
get prosemirrorState() {
|
|
2987
|
-
if (this.activeTransaction)
|
|
2988
|
-
throw new Error(
|
|
2989
|
-
"`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state"
|
|
2990
|
-
);
|
|
2991
|
-
return this.editor._tiptapEditor.state;
|
|
2992
|
-
}
|
|
2993
|
-
/**
|
|
2994
|
-
* Get the underlying prosemirror view
|
|
2995
|
-
* @see https://prosemirror.net/docs/ref/#view.EditorView
|
|
2996
|
-
*/
|
|
2997
|
-
get prosemirrorView() {
|
|
2998
|
-
return this.editor._tiptapEditor.view;
|
|
2999
|
-
}
|
|
3000
|
-
isFocused() {
|
|
3001
|
-
var e;
|
|
3002
|
-
return ((e = this.prosemirrorView) == null ? void 0 : e.hasFocus()) || !1;
|
|
3003
|
-
}
|
|
3004
|
-
focus() {
|
|
3005
|
-
var e;
|
|
3006
|
-
(e = this.prosemirrorView) == null || e.focus();
|
|
3007
|
-
}
|
|
3008
|
-
/**
|
|
3009
|
-
* Checks if the editor is currently editable, or if it's locked.
|
|
3010
|
-
* @returns True if the editor is editable, false otherwise.
|
|
3011
|
-
*/
|
|
3012
|
-
get isEditable() {
|
|
3013
|
-
if (!this.editor._tiptapEditor) {
|
|
3014
|
-
if (!this.editor.headless)
|
|
3015
|
-
throw new Error("no editor, but also not headless?");
|
|
3016
|
-
return !1;
|
|
3017
|
-
}
|
|
3018
|
-
return this.editor._tiptapEditor.isEditable === void 0 ? !0 : this.editor._tiptapEditor.isEditable;
|
|
3019
|
-
}
|
|
3020
|
-
/**
|
|
3021
|
-
* Makes the editor editable or locks it, depending on the argument passed.
|
|
3022
|
-
* @param editable True to make the editor editable, or false to lock it.
|
|
3023
|
-
*/
|
|
3024
|
-
set isEditable(e) {
|
|
3025
|
-
if (!this.editor._tiptapEditor) {
|
|
3026
|
-
if (!this.editor.headless)
|
|
3027
|
-
throw new Error("no editor, but also not headless?");
|
|
3028
|
-
return;
|
|
3029
|
-
}
|
|
3030
|
-
this.editor._tiptapEditor.options.editable !== e && this.editor._tiptapEditor.setEditable(e);
|
|
3031
|
-
}
|
|
3032
|
-
/**
|
|
3033
|
-
* Undo the last action.
|
|
3034
|
-
*/
|
|
3035
|
-
undo() {
|
|
3036
|
-
const e = this.editor.getExtension("yUndo");
|
|
3037
|
-
if (e)
|
|
3038
|
-
return this.exec(e.undoCommand);
|
|
3039
|
-
const t = this.editor.getExtension("history");
|
|
3040
|
-
if (t)
|
|
3041
|
-
return this.exec(t.undoCommand);
|
|
3042
|
-
throw new Error("No undo plugin found");
|
|
3043
|
-
}
|
|
3044
|
-
/**
|
|
3045
|
-
* Redo the last action.
|
|
3046
|
-
*/
|
|
3047
|
-
redo() {
|
|
3048
|
-
const e = this.editor.getExtension("yUndo");
|
|
3049
|
-
if (e)
|
|
3050
|
-
return this.exec(e.redoCommand);
|
|
3051
|
-
const t = this.editor.getExtension("history");
|
|
3052
|
-
if (t)
|
|
3053
|
-
return this.exec(t.redoCommand);
|
|
3054
|
-
throw new Error("No redo plugin found");
|
|
3055
|
-
}
|
|
3056
|
-
}
|
|
3057
|
-
function Nn(o, e, t, n = { updateSelection: !0 }) {
|
|
3058
|
-
let { from: s, to: r } = typeof e == "number" ? { from: e, to: e } : { from: e.from, to: e.to }, i = !0, l = !0, a = "";
|
|
3059
|
-
if (t.forEach((c) => {
|
|
3060
|
-
c.check(), i && c.isText && c.marks.length === 0 ? a += c.text : i = !1, l = l ? c.isBlock : !1;
|
|
3061
|
-
}), s === r && l) {
|
|
3062
|
-
const { parent: c } = o.doc.resolve(s);
|
|
3063
|
-
c.isTextblock && !c.type.spec.code && !c.childCount && (s -= 1, r += 1);
|
|
3064
|
-
}
|
|
3065
|
-
return i ? o.insertText(a, s, r) : o.replaceWith(s, r, t), n.updateSelection && At(o, o.steps.length - 1, -1), !0;
|
|
3066
|
-
}
|
|
3067
|
-
class Ln {
|
|
3068
|
-
constructor(e) {
|
|
3069
|
-
this.editor = e;
|
|
3070
|
-
}
|
|
3071
|
-
/**
|
|
3072
|
-
* Insert a piece of content at the current cursor position.
|
|
3073
|
-
*
|
|
3074
|
-
* @param content can be a string, or array of partial inline content elements
|
|
3075
|
-
*/
|
|
3076
|
-
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
3077
|
-
const n = V(e, this.editor.pmSchema);
|
|
3078
|
-
this.editor.transact((s) => {
|
|
3079
|
-
Nn(
|
|
3080
|
-
s,
|
|
3081
|
-
{
|
|
3082
|
-
from: s.selection.from,
|
|
3083
|
-
to: s.selection.to
|
|
3084
|
-
},
|
|
3085
|
-
n,
|
|
3086
|
-
{
|
|
3087
|
-
updateSelection: t
|
|
3088
|
-
}
|
|
3089
|
-
);
|
|
3090
|
-
});
|
|
3091
|
-
}
|
|
3092
|
-
/**
|
|
3093
|
-
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
3094
|
-
*/
|
|
3095
|
-
getActiveStyles() {
|
|
3096
|
-
return this.editor.transact((e) => {
|
|
3097
|
-
const t = {}, n = e.selection.$to.marks();
|
|
3098
|
-
for (const s of n) {
|
|
3099
|
-
const r = this.editor.schema.styleSchema[s.type.name];
|
|
3100
|
-
if (!r) {
|
|
3101
|
-
// Links are not considered styles in blocknote
|
|
3102
|
-
s.type.name !== "link" && // "blocknoteIgnore" tagged marks (such as comments) are also not considered BlockNote "styles"
|
|
3103
|
-
!s.type.spec.blocknoteIgnore && console.warn("mark not found in styleschema", s.type.name);
|
|
3104
|
-
continue;
|
|
3105
|
-
}
|
|
3106
|
-
r.propSchema === "boolean" ? t[r.type] = !0 : t[r.type] = s.attrs.stringValue;
|
|
3107
|
-
}
|
|
3108
|
-
return t;
|
|
3109
|
-
});
|
|
3110
|
-
}
|
|
3111
|
-
/**
|
|
3112
|
-
* Adds styles to the currently selected content.
|
|
3113
|
-
* @param styles The styles to add.
|
|
3114
|
-
*/
|
|
3115
|
-
addStyles(e) {
|
|
3116
|
-
for (const [t, n] of Object.entries(e)) {
|
|
3117
|
-
const s = this.editor.schema.styleSchema[t];
|
|
3118
|
-
if (!s)
|
|
3119
|
-
throw new Error(`style ${t} not found in styleSchema`);
|
|
3120
|
-
if (s.propSchema === "boolean")
|
|
3121
|
-
this.editor._tiptapEditor.commands.setMark(t);
|
|
3122
|
-
else if (s.propSchema === "string")
|
|
3123
|
-
this.editor._tiptapEditor.commands.setMark(t, {
|
|
3124
|
-
stringValue: n
|
|
3125
|
-
});
|
|
3126
|
-
else
|
|
3127
|
-
throw new U(s.propSchema);
|
|
3128
|
-
}
|
|
3129
|
-
}
|
|
3130
|
-
/**
|
|
3131
|
-
* Removes styles from the currently selected content.
|
|
3132
|
-
* @param styles The styles to remove.
|
|
3133
|
-
*/
|
|
3134
|
-
removeStyles(e) {
|
|
3135
|
-
for (const t of Object.keys(e))
|
|
3136
|
-
this.editor._tiptapEditor.commands.unsetMark(t);
|
|
3137
|
-
}
|
|
3138
|
-
/**
|
|
3139
|
-
* Toggles styles on the currently selected content.
|
|
3140
|
-
* @param styles The styles to toggle.
|
|
3141
|
-
*/
|
|
3142
|
-
toggleStyles(e) {
|
|
3143
|
-
for (const [t, n] of Object.entries(e)) {
|
|
3144
|
-
const s = this.editor.schema.styleSchema[t];
|
|
3145
|
-
if (!s)
|
|
3146
|
-
throw new Error(`style ${t} not found in styleSchema`);
|
|
3147
|
-
if (s.propSchema === "boolean")
|
|
3148
|
-
this.editor._tiptapEditor.commands.toggleMark(t);
|
|
3149
|
-
else if (s.propSchema === "string")
|
|
3150
|
-
this.editor._tiptapEditor.commands.toggleMark(t, {
|
|
3151
|
-
stringValue: n
|
|
3152
|
-
});
|
|
3153
|
-
else
|
|
3154
|
-
throw new U(s.propSchema);
|
|
3155
|
-
}
|
|
3156
|
-
}
|
|
3157
|
-
/**
|
|
3158
|
-
* Gets the currently selected text.
|
|
3159
|
-
*/
|
|
3160
|
-
getSelectedText() {
|
|
3161
|
-
return this.editor.transact((e) => e.doc.textBetween(e.selection.from, e.selection.to));
|
|
3162
|
-
}
|
|
3163
|
-
/**
|
|
3164
|
-
* Gets the URL of the last link in the current selection, or `undefined` if there are no links in the selection.
|
|
3165
|
-
*/
|
|
3166
|
-
getSelectedLinkUrl() {
|
|
3167
|
-
return this.editor._tiptapEditor.getAttributes("link").href;
|
|
3168
|
-
}
|
|
3169
|
-
/**
|
|
3170
|
-
* Creates a new link to replace the selected content.
|
|
3171
|
-
* @param url The link URL.
|
|
3172
|
-
* @param text The text to display the link with.
|
|
3173
|
-
*/
|
|
3174
|
-
createLink(e, t) {
|
|
3175
|
-
if (e === "")
|
|
3176
|
-
return;
|
|
3177
|
-
const n = this.editor.pmSchema.mark("link", { href: e });
|
|
3178
|
-
this.editor.transact((s) => {
|
|
3179
|
-
const { from: r, to: i } = s.selection;
|
|
3180
|
-
t ? s.insertText(t, r, i).addMark(r, r + t.length, n) : s.setSelection(Qt.create(s.doc, i)).addMark(
|
|
3181
|
-
r,
|
|
3182
|
-
i,
|
|
3183
|
-
n
|
|
3184
|
-
);
|
|
3185
|
-
});
|
|
3186
|
-
}
|
|
3187
|
-
}
|
|
3188
|
-
function _n(o) {
|
|
3189
|
-
return Nt(o.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
3190
|
-
}
|
|
3191
|
-
function Oe(o, e) {
|
|
3192
|
-
var s;
|
|
3193
|
-
const t = e.nodes.hardBreak;
|
|
3194
|
-
let n = R.empty;
|
|
3195
|
-
return o.forEach((r) => {
|
|
3196
|
-
r.isTextblock && r.childCount > 0 ? (n = n.append(r.content), n = n.addToEnd(t.create())) : r.isText ? n = n.addToEnd(r) : r.isBlock && r.childCount > 0 && (n = n.append(
|
|
3197
|
-
Oe(r.content, e)
|
|
3198
|
-
), n = n.addToEnd(t.create()));
|
|
3199
|
-
}), ((s = n.lastChild) == null ? void 0 : s.type) === t && (n = n.cut(0, n.size - 1)), n;
|
|
3200
|
-
}
|
|
3201
|
-
function Dn(o, e) {
|
|
3202
|
-
const t = [];
|
|
3203
|
-
return o.forEach((n, s, r) => {
|
|
3204
|
-
r !== e && t.push(n);
|
|
3205
|
-
}), R.from(t);
|
|
3206
|
-
}
|
|
3207
|
-
function On(o, e) {
|
|
3208
|
-
const t = [];
|
|
3209
|
-
for (let n = 0; n < o.childCount; n++)
|
|
3210
|
-
if (o.child(n).type.name === "tableRow")
|
|
3211
|
-
if (t.length > 0 && t[t.length - 1].type.name === "table") {
|
|
3212
|
-
const s = t[t.length - 1], r = s.copy(s.content.addToEnd(o.child(n)));
|
|
3213
|
-
t[t.length - 1] = r;
|
|
3214
|
-
} else {
|
|
3215
|
-
const s = e.nodes.table.createChecked(
|
|
3216
|
-
void 0,
|
|
3217
|
-
o.child(n)
|
|
3218
|
-
);
|
|
3219
|
-
t.push(s);
|
|
3220
|
-
}
|
|
3221
|
-
else
|
|
3222
|
-
t.push(o.child(n));
|
|
3223
|
-
return o = R.from(t), o;
|
|
3224
|
-
}
|
|
3225
|
-
function $n(o, e) {
|
|
3226
|
-
let t = R.from(o.content);
|
|
3227
|
-
if (t = On(t, e.state.schema), _n(e)) {
|
|
3228
|
-
let n = !1;
|
|
3229
|
-
if (t.descendants((s) => {
|
|
3230
|
-
s.type.isInGroup("tableContent") && (n = !0);
|
|
3231
|
-
}), !n && // is the content valid for a table paragraph?
|
|
3232
|
-
!e.state.schema.nodes.tableParagraph.validContent(t))
|
|
3233
|
-
return new W(
|
|
3234
|
-
Oe(t, e.state.schema),
|
|
3235
|
-
0,
|
|
3236
|
-
0
|
|
3237
|
-
);
|
|
3238
|
-
}
|
|
3239
|
-
if (!Hn(t, e))
|
|
3240
|
-
return new W(t, o.openStart, o.openEnd);
|
|
3241
|
-
for (let n = 0; n < t.childCount; n++)
|
|
3242
|
-
if (t.child(n).type.spec.group === "blockContent") {
|
|
3243
|
-
const s = [t.child(n)];
|
|
3244
|
-
if (n + 1 < t.childCount && t.child(n + 1).type.name === "blockGroup") {
|
|
3245
|
-
const i = t.child(n + 1).child(0).child(0);
|
|
3246
|
-
(i.type.name === "bulletListItem" || i.type.name === "numberedListItem" || i.type.name === "checkListItem") && (s.push(t.child(n + 1)), t = Dn(t, n + 1));
|
|
3247
|
-
}
|
|
3248
|
-
const r = e.state.schema.nodes.blockContainer.createChecked(
|
|
3249
|
-
void 0,
|
|
3250
|
-
s
|
|
3251
|
-
);
|
|
3252
|
-
t = t.replaceChild(n, r);
|
|
3253
|
-
}
|
|
3254
|
-
return new W(t, o.openStart, o.openEnd);
|
|
3255
|
-
}
|
|
3256
|
-
function Hn(o, e) {
|
|
3257
|
-
var r, i;
|
|
3258
|
-
const t = o.childCount === 1, n = ((r = o.firstChild) == null ? void 0 : r.type.spec.content) === "inline*", s = ((i = o.firstChild) == null ? void 0 : i.type.spec.content) === "tableRow+";
|
|
3259
|
-
if (t) {
|
|
3260
|
-
if (n)
|
|
3261
|
-
return !1;
|
|
3262
|
-
if (s) {
|
|
3263
|
-
const l = B(e.state);
|
|
3264
|
-
if (l.isBlockContainer)
|
|
3265
|
-
return !(l.blockContent.node.type.spec.content === "tableRow+");
|
|
3266
|
-
}
|
|
3267
|
-
}
|
|
3268
|
-
return !0;
|
|
3269
|
-
}
|
|
3270
|
-
const Fn = {
|
|
3271
|
-
enableInputRules: !0,
|
|
3272
|
-
enablePasteRules: !0,
|
|
3273
|
-
enableCoreExtensions: !1
|
|
3274
|
-
};
|
|
3275
|
-
class $e extends Ce {
|
|
3276
|
-
constructor(t) {
|
|
3277
|
-
var c, d, u, p, h, f, m, b, g, x;
|
|
3278
|
-
super();
|
|
3279
|
-
/**
|
|
3280
|
-
* The underlying prosemirror schema
|
|
3281
|
-
*/
|
|
3282
|
-
k(this, "pmSchema");
|
|
3283
|
-
k(this, "_tiptapEditor");
|
|
3284
|
-
/**
|
|
3285
|
-
* Used by React to store a reference to an `ElementRenderer` helper utility to make sure we can render React elements
|
|
3286
|
-
* in the correct context (used by `ReactRenderUtil`)
|
|
3287
|
-
*/
|
|
3288
|
-
k(this, "elementRenderer", null);
|
|
3289
|
-
/**
|
|
3290
|
-
* Cache of all blocks. This makes sure we don't have to "recompute" blocks if underlying Prosemirror Nodes haven't changed.
|
|
3291
|
-
* This is especially useful when we want to keep track of the same block across multiple operations,
|
|
3292
|
-
* with this cache, blocks stay the same object reference (referential equality with ===).
|
|
3293
|
-
*/
|
|
3294
|
-
k(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
3295
|
-
/**
|
|
3296
|
-
* The dictionary contains translations for the editor.
|
|
3297
|
-
*/
|
|
3298
|
-
k(this, "dictionary");
|
|
3299
|
-
/**
|
|
3300
|
-
* The schema of the editor. The schema defines which Blocks, InlineContent, and Styles are available in the editor.
|
|
3301
|
-
*/
|
|
3302
|
-
k(this, "schema");
|
|
3303
|
-
k(this, "blockImplementations");
|
|
3304
|
-
k(this, "inlineContentImplementations");
|
|
3305
|
-
k(this, "styleImplementations");
|
|
3306
|
-
/**
|
|
3307
|
-
* The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
|
|
3308
|
-
* This method should set when creating the editor as this is application-specific.
|
|
3309
|
-
*
|
|
3310
|
-
* `undefined` means the application doesn't support file uploads.
|
|
3311
|
-
*
|
|
3312
|
-
* @param file The file that should be uploaded.
|
|
3313
|
-
* @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id)
|
|
3314
|
-
*/
|
|
3315
|
-
k(this, "uploadFile");
|
|
3316
|
-
k(this, "onUploadStartCallbacks", []);
|
|
3317
|
-
k(this, "onUploadEndCallbacks", []);
|
|
3318
|
-
k(this, "resolveFileUrl");
|
|
3319
|
-
/**
|
|
3320
|
-
* Editor settings
|
|
3321
|
-
*/
|
|
3322
|
-
k(this, "settings");
|
|
3323
|
-
// Manager instances
|
|
3324
|
-
k(this, "_blockManager");
|
|
3325
|
-
k(this, "_eventManager");
|
|
3326
|
-
k(this, "_exportManager");
|
|
3327
|
-
k(this, "_extensionManager");
|
|
3328
|
-
k(this, "_selectionManager");
|
|
3329
|
-
k(this, "_stateManager");
|
|
3330
|
-
k(this, "_styleManager");
|
|
3331
|
-
/**
|
|
3332
|
-
* Remove extension(s) from the editor
|
|
3333
|
-
*/
|
|
3334
|
-
k(this, "unregisterExtension", (...t) => this._extensionManager.unregisterExtension(...t));
|
|
3335
|
-
/**
|
|
3336
|
-
* Register extension(s) to the editor
|
|
3337
|
-
*/
|
|
3338
|
-
k(this, "registerExtension", (...t) => this._extensionManager.registerExtension(...t));
|
|
3339
|
-
/**
|
|
3340
|
-
* Get an extension from the editor
|
|
3341
|
-
*/
|
|
3342
|
-
k(this, "getExtension", (...t) => this._extensionManager.getExtension(...t));
|
|
3343
|
-
/**
|
|
3344
|
-
* Mount the editor to a DOM element.
|
|
3345
|
-
*
|
|
3346
|
-
* @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
|
|
3347
|
-
*/
|
|
3348
|
-
k(this, "mount", (t) => {
|
|
3349
|
-
this._tiptapEditor.mount({ mount: t });
|
|
3350
|
-
});
|
|
3351
|
-
/**
|
|
3352
|
-
* Unmount the editor from the DOM element it is bound to
|
|
3353
|
-
*/
|
|
3354
|
-
k(this, "unmount", () => {
|
|
3355
|
-
this._tiptapEditor.unmount();
|
|
3356
|
-
});
|
|
3357
|
-
this.options = t, this.dictionary = t.dictionary || Ot, this.settings = {
|
|
3358
|
-
tables: {
|
|
3359
|
-
splitCells: ((c = t == null ? void 0 : t.tables) == null ? void 0 : c.splitCells) ?? !1,
|
|
3360
|
-
cellBackgroundColor: ((d = t == null ? void 0 : t.tables) == null ? void 0 : d.cellBackgroundColor) ?? !1,
|
|
3361
|
-
cellTextColor: ((u = t == null ? void 0 : t.tables) == null ? void 0 : u.cellTextColor) ?? !1,
|
|
3362
|
-
headers: ((p = t == null ? void 0 : t.tables) == null ? void 0 : p.headers) ?? !1
|
|
3363
|
-
}
|
|
3364
|
-
};
|
|
3365
|
-
const n = {
|
|
3366
|
-
defaultStyles: !0,
|
|
3367
|
-
schema: t.schema || wt.create(),
|
|
3368
|
-
...t,
|
|
3369
|
-
placeholders: {
|
|
3370
|
-
...this.dictionary.placeholders,
|
|
3371
|
-
...t.placeholders
|
|
3372
|
-
}
|
|
3373
|
-
};
|
|
3374
|
-
if (this.schema = n.schema, this.blockImplementations = n.schema.blockSpecs, this.inlineContentImplementations = n.schema.inlineContentSpecs, this.styleImplementations = n.schema.styleSpecs, n.uploadFile) {
|
|
3375
|
-
const y = n.uploadFile;
|
|
3376
|
-
this.uploadFile = async (I, w) => {
|
|
3377
|
-
this.onUploadStartCallbacks.forEach(
|
|
3378
|
-
(A) => A.apply(this, [w])
|
|
3379
|
-
);
|
|
3380
|
-
try {
|
|
3381
|
-
return await y(I, w);
|
|
3382
|
-
} finally {
|
|
3383
|
-
this.onUploadEndCallbacks.forEach(
|
|
3384
|
-
(A) => A.apply(this, [w])
|
|
3385
|
-
);
|
|
3386
|
-
}
|
|
3387
|
-
};
|
|
3388
|
-
}
|
|
3389
|
-
this.resolveFileUrl = n.resolveFileUrl, this._eventManager = new Eo(this), this._extensionManager = new En(this, n);
|
|
3390
|
-
const s = this._extensionManager.getTiptapExtensions(), r = this._extensionManager.hasExtension("ySync") || this._extensionManager.hasExtension("liveblocksExtension");
|
|
3391
|
-
r && n.initialContent && console.warn(
|
|
3392
|
-
"When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider"
|
|
3393
|
-
);
|
|
3394
|
-
const i = {
|
|
3395
|
-
...Fn,
|
|
3396
|
-
...n._tiptapOptions,
|
|
3397
|
-
element: null,
|
|
3398
|
-
autofocus: n.autofocus ?? !1,
|
|
3399
|
-
extensions: s,
|
|
3400
|
-
editorProps: {
|
|
3401
|
-
...(h = n._tiptapOptions) == null ? void 0 : h.editorProps,
|
|
3402
|
-
attributes: {
|
|
3403
|
-
// As of TipTap v2.5.0 the tabIndex is removed when the editor is not
|
|
3404
|
-
// editable, so you can't focus it. We want to revert this as we have
|
|
3405
|
-
// UI behaviour that relies on it.
|
|
3406
|
-
tabIndex: "0",
|
|
3407
|
-
...(m = (f = n._tiptapOptions) == null ? void 0 : f.editorProps) == null ? void 0 : m.attributes,
|
|
3408
|
-
...(b = n.domAttributes) == null ? void 0 : b.editor,
|
|
3409
|
-
class: ee(
|
|
3410
|
-
"bn-editor",
|
|
3411
|
-
n.defaultStyles ? "bn-default-styles" : "",
|
|
3412
|
-
((x = (g = n.domAttributes) == null ? void 0 : g.editor) == null ? void 0 : x.class) || ""
|
|
3413
|
-
)
|
|
3414
|
-
},
|
|
3415
|
-
transformPasted: $n
|
|
3416
|
-
}
|
|
3417
|
-
};
|
|
3418
|
-
try {
|
|
3419
|
-
const y = n.initialContent || (r ? [
|
|
3420
|
-
{
|
|
3421
|
-
type: "paragraph",
|
|
3422
|
-
id: "initialBlockId"
|
|
3423
|
-
}
|
|
3424
|
-
] : [
|
|
3425
|
-
{
|
|
3426
|
-
type: "paragraph",
|
|
3427
|
-
id: ke.options.generateID()
|
|
3428
|
-
}
|
|
3429
|
-
]);
|
|
3430
|
-
if (!Array.isArray(y) || y.length === 0)
|
|
3431
|
-
throw new Error(
|
|
3432
|
-
"initialContent must be a non-empty array of blocks, received: " + y
|
|
3433
|
-
);
|
|
3434
|
-
const I = Lt(i.extensions), w = y.map(
|
|
3435
|
-
(He) => Z(He, I, this.schema.styleSchema).toJSON()
|
|
3436
|
-
), A = _t(
|
|
3437
|
-
{
|
|
3438
|
-
type: "doc",
|
|
3439
|
-
content: [
|
|
3440
|
-
{
|
|
3441
|
-
type: "blockGroup",
|
|
3442
|
-
content: w
|
|
3443
|
-
}
|
|
3444
|
-
]
|
|
3445
|
-
},
|
|
3446
|
-
I,
|
|
3447
|
-
i.parseOptions
|
|
3448
|
-
);
|
|
3449
|
-
this._tiptapEditor = new Dt({
|
|
3450
|
-
...i,
|
|
3451
|
-
content: A.toJSON()
|
|
3452
|
-
}), this.pmSchema = this._tiptapEditor.schema;
|
|
3453
|
-
} catch (y) {
|
|
3454
|
-
throw new Error(
|
|
3455
|
-
"Error creating document from blocks passed as `initialContent`",
|
|
3456
|
-
{ cause: y }
|
|
3457
|
-
);
|
|
3458
|
-
}
|
|
3459
|
-
let l;
|
|
3460
|
-
const a = this.pmSchema.nodes.doc.createAndFill;
|
|
3461
|
-
this.pmSchema.nodes.doc.createAndFill = (...y) => {
|
|
3462
|
-
if (l)
|
|
3463
|
-
return l;
|
|
3464
|
-
const I = a.apply(this.pmSchema.nodes.doc, y), w = JSON.parse(JSON.stringify(I.toJSON()));
|
|
3465
|
-
return w.content[0].content[0].attrs.id = "initialBlockId", l = ze.fromJSON(this.pmSchema, w), l;
|
|
3466
|
-
}, this.pmSchema.cached.blockNoteEditor = this, this._blockManager = new xo(this), this._exportManager = new $o(this), this._selectionManager = new In(this), this._stateManager = new An(this), this._styleManager = new Ln(this), this.emit("create");
|
|
3467
|
-
}
|
|
3468
|
-
static create(t) {
|
|
3469
|
-
return new $e(t ?? {});
|
|
3470
|
-
}
|
|
3471
|
-
/**
|
|
3472
|
-
* BlockNote extensions that are added to the editor, keyed by the extension key
|
|
3473
|
-
*/
|
|
3474
|
-
get extensions() {
|
|
3475
|
-
return this._extensionManager.getExtensions();
|
|
3476
|
-
}
|
|
3477
|
-
/**
|
|
3478
|
-
* Execute a prosemirror command. This is mostly for backwards compatibility with older code.
|
|
3479
|
-
*
|
|
3480
|
-
* @note You should prefer the {@link transact} method when possible, as it will automatically handle the dispatching of the transaction and work across blocknote transactions.
|
|
3481
|
-
*
|
|
3482
|
-
* @example
|
|
3483
|
-
* ```ts
|
|
3484
|
-
* editor.exec((state, dispatch, view) => {
|
|
3485
|
-
* dispatch(state.tr.insertText("Hello, world!"));
|
|
3486
|
-
* });
|
|
3487
|
-
* ```
|
|
3488
|
-
*/
|
|
3489
|
-
exec(t) {
|
|
3490
|
-
return this._stateManager.exec(t);
|
|
3491
|
-
}
|
|
3492
|
-
/**
|
|
3493
|
-
* Check if a command can be executed. A command should return `false` if it is not valid in the current state.
|
|
3494
|
-
*
|
|
3495
|
-
* @example
|
|
3496
|
-
* ```ts
|
|
3497
|
-
* if (editor.canExec(command)) {
|
|
3498
|
-
* // show button
|
|
3499
|
-
* } else {
|
|
3500
|
-
* // hide button
|
|
3501
|
-
* }
|
|
3502
|
-
* ```
|
|
3503
|
-
*/
|
|
3504
|
-
canExec(t) {
|
|
3505
|
-
return this._stateManager.canExec(t);
|
|
3506
|
-
}
|
|
3507
|
-
/**
|
|
3508
|
-
* Execute a function within a "blocknote transaction".
|
|
3509
|
-
* All changes to the editor within the transaction will be grouped together, so that
|
|
3510
|
-
* we can dispatch them as a single operation (thus creating only a single undo step)
|
|
3511
|
-
*
|
|
3512
|
-
* @note There is no need to dispatch the transaction, as it will be automatically dispatched when the callback is complete.
|
|
3513
|
-
*
|
|
3514
|
-
* @example
|
|
3515
|
-
* ```ts
|
|
3516
|
-
* // All changes to the editor will be grouped together
|
|
3517
|
-
* editor.transact((tr) => {
|
|
3518
|
-
* tr.insertText("Hello, world!");
|
|
3519
|
-
* // These two operations will be grouped together in a single undo step
|
|
3520
|
-
* editor.transact((tr) => {
|
|
3521
|
-
* tr.insertText("Hello, world!");
|
|
3522
|
-
* });
|
|
3523
|
-
* });
|
|
3524
|
-
* ```
|
|
3525
|
-
*/
|
|
3526
|
-
transact(t) {
|
|
3527
|
-
return this._stateManager.transact(t);
|
|
3528
|
-
}
|
|
3529
|
-
/**
|
|
3530
|
-
* Get the underlying prosemirror state
|
|
3531
|
-
* @note Prefer using `editor.transact` to read the current editor state, as that will ensure the state is up to date
|
|
3532
|
-
* @see https://prosemirror.net/docs/ref/#state.EditorState
|
|
3533
|
-
*/
|
|
3534
|
-
get prosemirrorState() {
|
|
3535
|
-
return this._stateManager.prosemirrorState;
|
|
3536
|
-
}
|
|
3537
|
-
/**
|
|
3538
|
-
* Get the underlying prosemirror view
|
|
3539
|
-
* @see https://prosemirror.net/docs/ref/#view.EditorView
|
|
3540
|
-
*/
|
|
3541
|
-
get prosemirrorView() {
|
|
3542
|
-
return this._stateManager.prosemirrorView;
|
|
3543
|
-
}
|
|
3544
|
-
get domElement() {
|
|
3545
|
-
var t;
|
|
3546
|
-
if (!this.headless)
|
|
3547
|
-
return (t = this.prosemirrorView) == null ? void 0 : t.dom;
|
|
3548
|
-
}
|
|
3549
|
-
isFocused() {
|
|
3550
|
-
var t;
|
|
3551
|
-
return this.headless ? !1 : ((t = this.prosemirrorView) == null ? void 0 : t.hasFocus()) || !1;
|
|
3552
|
-
}
|
|
3553
|
-
get headless() {
|
|
3554
|
-
return !this._tiptapEditor.isInitialized;
|
|
3555
|
-
}
|
|
3556
|
-
/**
|
|
3557
|
-
* Focus on the editor
|
|
3558
|
-
*/
|
|
3559
|
-
focus() {
|
|
3560
|
-
this.headless || this.prosemirrorView.focus();
|
|
3561
|
-
}
|
|
3562
|
-
/**
|
|
3563
|
-
* Blur the editor
|
|
3564
|
-
*/
|
|
3565
|
-
blur() {
|
|
3566
|
-
var t;
|
|
3567
|
-
this.headless || (t = this.domElement) == null || t.blur();
|
|
3568
|
-
}
|
|
3569
|
-
// TODO move to extension
|
|
3570
|
-
onUploadStart(t) {
|
|
3571
|
-
return this.onUploadStartCallbacks.push(t), () => {
|
|
3572
|
-
const n = this.onUploadStartCallbacks.indexOf(t);
|
|
3573
|
-
n > -1 && this.onUploadStartCallbacks.splice(n, 1);
|
|
3574
|
-
};
|
|
3575
|
-
}
|
|
3576
|
-
onUploadEnd(t) {
|
|
3577
|
-
return this.onUploadEndCallbacks.push(t), () => {
|
|
3578
|
-
const n = this.onUploadEndCallbacks.indexOf(t);
|
|
3579
|
-
n > -1 && this.onUploadEndCallbacks.splice(n, 1);
|
|
3580
|
-
};
|
|
3581
|
-
}
|
|
3582
|
-
/**
|
|
3583
|
-
* @deprecated, use `editor.document` instead
|
|
3584
|
-
*/
|
|
3585
|
-
get topLevelBlocks() {
|
|
3586
|
-
return this.document;
|
|
3587
|
-
}
|
|
3588
|
-
/**
|
|
3589
|
-
* Gets a snapshot of all top-level (non-nested) blocks in the editor.
|
|
3590
|
-
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
3591
|
-
*/
|
|
3592
|
-
get document() {
|
|
3593
|
-
return this._blockManager.document;
|
|
3594
|
-
}
|
|
3595
|
-
/**
|
|
3596
|
-
* Gets a snapshot of an existing block from the editor.
|
|
3597
|
-
* @param blockIdentifier The identifier of an existing block that should be
|
|
3598
|
-
* retrieved.
|
|
3599
|
-
* @returns The block that matches the identifier, or `undefined` if no
|
|
3600
|
-
* matching block was found.
|
|
3601
|
-
*/
|
|
3602
|
-
getBlock(t) {
|
|
3603
|
-
return this._blockManager.getBlock(t);
|
|
3604
|
-
}
|
|
3605
|
-
/**
|
|
3606
|
-
* Gets a snapshot of the previous sibling of an existing block from the
|
|
3607
|
-
* editor.
|
|
3608
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
3609
|
-
* previous sibling should be retrieved.
|
|
3610
|
-
* @returns The previous sibling of the block that matches the identifier.
|
|
3611
|
-
* `undefined` if no matching block was found, or it's the first child/block
|
|
3612
|
-
* in the document.
|
|
3613
|
-
*/
|
|
3614
|
-
getPrevBlock(t) {
|
|
3615
|
-
return this._blockManager.getPrevBlock(t);
|
|
3616
|
-
}
|
|
3617
|
-
/**
|
|
3618
|
-
* Gets a snapshot of the next sibling of an existing block from the editor.
|
|
3619
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
3620
|
-
* next sibling should be retrieved.
|
|
3621
|
-
* @returns The next sibling of the block that matches the identifier.
|
|
3622
|
-
* `undefined` if no matching block was found, or it's the last child/block in
|
|
3623
|
-
* the document.
|
|
3624
|
-
*/
|
|
3625
|
-
getNextBlock(t) {
|
|
3626
|
-
return this._blockManager.getNextBlock(t);
|
|
3627
|
-
}
|
|
3628
|
-
/**
|
|
3629
|
-
* Gets a snapshot of the parent of an existing block from the editor.
|
|
3630
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
3631
|
-
* parent should be retrieved.
|
|
3632
|
-
* @returns The parent of the block that matches the identifier. `undefined`
|
|
3633
|
-
* if no matching block was found, or the block isn't nested.
|
|
3634
|
-
*/
|
|
3635
|
-
getParentBlock(t) {
|
|
3636
|
-
return this._blockManager.getParentBlock(t);
|
|
3637
|
-
}
|
|
3638
|
-
/**
|
|
3639
|
-
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
3640
|
-
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
3641
|
-
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
3642
|
-
*/
|
|
3643
|
-
forEachBlock(t, n = !1) {
|
|
3644
|
-
this._blockManager.forEachBlock(t, n);
|
|
3645
|
-
}
|
|
3646
|
-
/**
|
|
3647
|
-
* Executes a callback whenever the editor's contents change.
|
|
3648
|
-
* @param callback The callback to execute.
|
|
3649
|
-
*
|
|
3650
|
-
* @deprecated use {@link BlockNoteEditor.onChange} instead
|
|
3651
|
-
*/
|
|
3652
|
-
onEditorContentChange(t) {
|
|
3653
|
-
this._tiptapEditor.on("update", t);
|
|
3654
|
-
}
|
|
3655
|
-
/**
|
|
3656
|
-
* Executes a callback whenever the editor's selection changes.
|
|
3657
|
-
* @param callback The callback to execute.
|
|
3658
|
-
*
|
|
3659
|
-
* @deprecated use `onSelectionChange` instead
|
|
3660
|
-
*/
|
|
3661
|
-
onEditorSelectionChange(t) {
|
|
3662
|
-
this._tiptapEditor.on("selectionUpdate", t);
|
|
3663
|
-
}
|
|
3664
|
-
/**
|
|
3665
|
-
* Executes a callback before any change is applied to the editor, allowing you to cancel the change.
|
|
3666
|
-
* @param callback The callback to execute.
|
|
3667
|
-
* @returns A function to remove the callback.
|
|
3668
|
-
*/
|
|
3669
|
-
onBeforeChange(t) {
|
|
3670
|
-
return this._extensionManager.getExtension(ye).subscribe(t);
|
|
3671
|
-
}
|
|
3672
|
-
/**
|
|
3673
|
-
* Gets a snapshot of the current text cursor position.
|
|
3674
|
-
* @returns A snapshot of the current text cursor position.
|
|
3675
|
-
*/
|
|
3676
|
-
getTextCursorPosition() {
|
|
3677
|
-
return this._selectionManager.getTextCursorPosition();
|
|
3678
|
-
}
|
|
3679
|
-
/**
|
|
3680
|
-
* Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
|
|
3681
|
-
* not be found.
|
|
3682
|
-
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
3683
|
-
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
3684
|
-
*/
|
|
3685
|
-
setTextCursorPosition(t, n = "start") {
|
|
3686
|
-
return this._selectionManager.setTextCursorPosition(t, n);
|
|
3687
|
-
}
|
|
3688
|
-
/**
|
|
3689
|
-
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
3690
|
-
* that the selection spans across.
|
|
3691
|
-
*
|
|
3692
|
-
* If the selection starts / ends halfway through a block, the returned data will contain the entire block.
|
|
3693
|
-
*/
|
|
3694
|
-
getSelection() {
|
|
3695
|
-
return this._selectionManager.getSelection();
|
|
3696
|
-
}
|
|
3697
|
-
/**
|
|
3698
|
-
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
3699
|
-
* that the selection spans across.
|
|
3700
|
-
*
|
|
3701
|
-
* If the selection starts / ends halfway through a block, the returned block will be
|
|
3702
|
-
* only the part of the block that is included in the selection.
|
|
3703
|
-
*/
|
|
3704
|
-
getSelectionCutBlocks(t = !1) {
|
|
3705
|
-
return this._selectionManager.getSelectionCutBlocks(t);
|
|
3706
|
-
}
|
|
3707
|
-
/**
|
|
3708
|
-
* Sets the selection to a range of blocks.
|
|
3709
|
-
* @param startBlock The identifier of the block that should be the start of the selection.
|
|
3710
|
-
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
3711
|
-
*/
|
|
3712
|
-
setSelection(t, n) {
|
|
3713
|
-
return this._selectionManager.setSelection(t, n);
|
|
3714
|
-
}
|
|
3715
|
-
/**
|
|
3716
|
-
* Checks if the editor is currently editable, or if it's locked.
|
|
3717
|
-
* @returns True if the editor is editable, false otherwise.
|
|
3718
|
-
*/
|
|
3719
|
-
get isEditable() {
|
|
3720
|
-
return this._stateManager.isEditable;
|
|
3721
|
-
}
|
|
3722
|
-
/**
|
|
3723
|
-
* Makes the editor editable or locks it, depending on the argument passed.
|
|
3724
|
-
* @param editable True to make the editor editable, or false to lock it.
|
|
3725
|
-
*/
|
|
3726
|
-
set isEditable(t) {
|
|
3727
|
-
this._stateManager.isEditable = t;
|
|
3728
|
-
}
|
|
3729
|
-
/**
|
|
3730
|
-
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
3731
|
-
* error if the reference block could not be found.
|
|
3732
|
-
* @param blocksToInsert An array of partial blocks that should be inserted.
|
|
3733
|
-
* @param referenceBlock An identifier for an existing block, at which the new blocks should be inserted.
|
|
3734
|
-
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
3735
|
-
* `referenceBlock`.
|
|
3736
|
-
*/
|
|
3737
|
-
insertBlocks(t, n, s = "before") {
|
|
3738
|
-
return this._blockManager.insertBlocks(
|
|
3739
|
-
t,
|
|
3740
|
-
n,
|
|
3741
|
-
s
|
|
3742
|
-
);
|
|
3743
|
-
}
|
|
3744
|
-
/**
|
|
3745
|
-
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
3746
|
-
* defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
|
|
3747
|
-
* not be found.
|
|
3748
|
-
* @param blockToUpdate The block that should be updated.
|
|
3749
|
-
* @param update A partial block which defines how the existing block should be changed.
|
|
3750
|
-
*/
|
|
3751
|
-
updateBlock(t, n) {
|
|
3752
|
-
return this._blockManager.updateBlock(t, n);
|
|
3753
|
-
}
|
|
3754
|
-
/**
|
|
3755
|
-
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
3756
|
-
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
3757
|
-
*/
|
|
3758
|
-
removeBlocks(t) {
|
|
3759
|
-
return this._blockManager.removeBlocks(t);
|
|
3760
|
-
}
|
|
3761
|
-
/**
|
|
3762
|
-
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
3763
|
-
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
3764
|
-
* `blocksToRemove`. Throws an error if any of the blocks to remove could not be found.
|
|
3765
|
-
* @param blocksToRemove An array of blocks that should be replaced.
|
|
3766
|
-
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
3767
|
-
*/
|
|
3768
|
-
replaceBlocks(t, n) {
|
|
3769
|
-
return this._blockManager.replaceBlocks(t, n);
|
|
3770
|
-
}
|
|
3771
|
-
/**
|
|
3772
|
-
* Undo the last action.
|
|
3773
|
-
*/
|
|
3774
|
-
undo() {
|
|
3775
|
-
return this._stateManager.undo();
|
|
3776
|
-
}
|
|
3777
|
-
/**
|
|
3778
|
-
* Redo the last action.
|
|
3779
|
-
*/
|
|
3780
|
-
redo() {
|
|
3781
|
-
return this._stateManager.redo();
|
|
3782
|
-
}
|
|
3783
|
-
/**
|
|
3784
|
-
* Insert a piece of content at the current cursor position.
|
|
3785
|
-
*
|
|
3786
|
-
* @param content can be a string, or array of partial inline content elements
|
|
3787
|
-
*/
|
|
3788
|
-
insertInlineContent(t, { updateSelection: n = !1 } = {}) {
|
|
3789
|
-
this._styleManager.insertInlineContent(t, { updateSelection: n });
|
|
3790
|
-
}
|
|
3791
|
-
/**
|
|
3792
|
-
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
3793
|
-
*/
|
|
3794
|
-
getActiveStyles() {
|
|
3795
|
-
return this._styleManager.getActiveStyles();
|
|
3796
|
-
}
|
|
3797
|
-
/**
|
|
3798
|
-
* Adds styles to the currently selected content.
|
|
3799
|
-
* @param styles The styles to add.
|
|
3800
|
-
*/
|
|
3801
|
-
addStyles(t) {
|
|
3802
|
-
this._styleManager.addStyles(t);
|
|
3803
|
-
}
|
|
3804
|
-
/**
|
|
3805
|
-
* Removes styles from the currently selected content.
|
|
3806
|
-
* @param styles The styles to remove.
|
|
3807
|
-
*/
|
|
3808
|
-
removeStyles(t) {
|
|
3809
|
-
this._styleManager.removeStyles(t);
|
|
3810
|
-
}
|
|
3811
|
-
/**
|
|
3812
|
-
* Toggles styles on the currently selected content.
|
|
3813
|
-
* @param styles The styles to toggle.
|
|
3814
|
-
*/
|
|
3815
|
-
toggleStyles(t) {
|
|
3816
|
-
this._styleManager.toggleStyles(t);
|
|
3817
|
-
}
|
|
3818
|
-
/**
|
|
3819
|
-
* Gets the currently selected text.
|
|
3820
|
-
*/
|
|
3821
|
-
getSelectedText() {
|
|
3822
|
-
return this._styleManager.getSelectedText();
|
|
3823
|
-
}
|
|
3824
|
-
/**
|
|
3825
|
-
* Gets the URL of the last link in the current selection, or `undefined` if there are no links in the selection.
|
|
3826
|
-
*/
|
|
3827
|
-
getSelectedLinkUrl() {
|
|
3828
|
-
return this._styleManager.getSelectedLinkUrl();
|
|
3829
|
-
}
|
|
3830
|
-
/**
|
|
3831
|
-
* Creates a new link to replace the selected content.
|
|
3832
|
-
* @param url The link URL.
|
|
3833
|
-
* @param text The text to display the link with.
|
|
3834
|
-
*/
|
|
3835
|
-
createLink(t, n) {
|
|
3836
|
-
this._styleManager.createLink(t, n);
|
|
3837
|
-
}
|
|
3838
|
-
/**
|
|
3839
|
-
* Checks if the block containing the text cursor can be nested.
|
|
3840
|
-
*/
|
|
3841
|
-
canNestBlock() {
|
|
3842
|
-
return this._blockManager.canNestBlock();
|
|
3843
|
-
}
|
|
3844
|
-
/**
|
|
3845
|
-
* Nests the block containing the text cursor into the block above it.
|
|
3846
|
-
*/
|
|
3847
|
-
nestBlock() {
|
|
3848
|
-
this._blockManager.nestBlock();
|
|
3849
|
-
}
|
|
3850
|
-
/**
|
|
3851
|
-
* Checks if the block containing the text cursor is nested.
|
|
3852
|
-
*/
|
|
3853
|
-
canUnnestBlock() {
|
|
3854
|
-
return this._blockManager.canUnnestBlock();
|
|
3855
|
-
}
|
|
3856
|
-
/**
|
|
3857
|
-
* Lifts the block containing the text cursor out of its parent.
|
|
3858
|
-
*/
|
|
3859
|
-
unnestBlock() {
|
|
3860
|
-
this._blockManager.unnestBlock();
|
|
3861
|
-
}
|
|
3862
|
-
/**
|
|
3863
|
-
* Moves the selected blocks up. If the previous block has children, moves
|
|
3864
|
-
* them to the end of its children. If there is no previous block, but the
|
|
3865
|
-
* current blocks share a common parent, moves them out of & before it.
|
|
3866
|
-
*/
|
|
3867
|
-
moveBlocksUp() {
|
|
3868
|
-
return this._blockManager.moveBlocksUp();
|
|
3869
|
-
}
|
|
3870
|
-
/**
|
|
3871
|
-
* Moves the selected blocks down. If the next block has children, moves
|
|
3872
|
-
* them to the start of its children. If there is no next block, but the
|
|
3873
|
-
* current blocks share a common parent, moves them out of & after it.
|
|
3874
|
-
*/
|
|
3875
|
-
moveBlocksDown() {
|
|
3876
|
-
return this._blockManager.moveBlocksDown();
|
|
3877
|
-
}
|
|
3878
|
-
/**
|
|
3879
|
-
* Exports blocks into a simplified HTML string. To better conform to HTML standards, children of blocks which aren't list
|
|
3880
|
-
* items are un-nested in the output HTML.
|
|
3881
|
-
*
|
|
3882
|
-
* @param blocks An array of blocks that should be serialized into HTML.
|
|
3883
|
-
* @returns The blocks, serialized as an HTML string.
|
|
3884
|
-
*/
|
|
3885
|
-
blocksToHTMLLossy(t = this.document) {
|
|
3886
|
-
return this._exportManager.blocksToHTMLLossy(t);
|
|
3887
|
-
}
|
|
3888
|
-
/**
|
|
3889
|
-
* Serializes blocks into an HTML string in the format that would normally be rendered by the editor.
|
|
3890
|
-
*
|
|
3891
|
-
* Use this method if you want to server-side render HTML (for example, a blog post that has been edited in BlockNote)
|
|
3892
|
-
* and serve it to users without loading the editor on the client (i.e.: displaying the blog post)
|
|
3893
|
-
*
|
|
3894
|
-
* @param blocks An array of blocks that should be serialized into HTML.
|
|
3895
|
-
* @returns The blocks, serialized as an HTML string.
|
|
3896
|
-
*/
|
|
3897
|
-
blocksToFullHTML(t = this.document) {
|
|
3898
|
-
return this._exportManager.blocksToFullHTML(t);
|
|
3899
|
-
}
|
|
3900
|
-
/**
|
|
3901
|
-
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
3902
|
-
* `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
|
|
3903
|
-
* doesn't recognize an HTML element's tag, it will parse it as a paragraph or plain text.
|
|
3904
|
-
* @param html The HTML string to parse blocks from.
|
|
3905
|
-
* @returns The blocks parsed from the HTML string.
|
|
3906
|
-
*/
|
|
3907
|
-
tryParseHTMLToBlocks(t) {
|
|
3908
|
-
return this._exportManager.tryParseHTMLToBlocks(t);
|
|
3909
|
-
}
|
|
3910
|
-
/**
|
|
3911
|
-
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
3912
|
-
* BlockNote - children of blocks which aren't list items are un-nested and certain styles are removed.
|
|
3913
|
-
* @param blocks An array of blocks that should be serialized into Markdown.
|
|
3914
|
-
* @returns The blocks, serialized as a Markdown string.
|
|
3915
|
-
*/
|
|
3916
|
-
blocksToMarkdownLossy(t = this.document) {
|
|
3917
|
-
return this._exportManager.blocksToMarkdownLossy(t);
|
|
3918
|
-
}
|
|
3919
|
-
/**
|
|
3920
|
-
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
3921
|
-
* Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
|
|
3922
|
-
* as text.
|
|
3923
|
-
* @param markdown The Markdown string to parse blocks from.
|
|
3924
|
-
* @returns The blocks parsed from the Markdown string.
|
|
3925
|
-
*/
|
|
3926
|
-
tryParseMarkdownToBlocks(t) {
|
|
3927
|
-
return this._exportManager.tryParseMarkdownToBlocks(t);
|
|
3928
|
-
}
|
|
3929
|
-
/**
|
|
3930
|
-
* A callback function that runs whenever the editor's contents change.
|
|
3931
|
-
*
|
|
3932
|
-
* @param callback The callback to execute.
|
|
3933
|
-
* @returns A function to remove the callback.
|
|
3934
|
-
*/
|
|
3935
|
-
onChange(t, n) {
|
|
3936
|
-
return this._eventManager.onChange(t, n);
|
|
3937
|
-
}
|
|
3938
|
-
/**
|
|
3939
|
-
* A callback function that runs whenever the text cursor position or selection changes.
|
|
3940
|
-
*
|
|
3941
|
-
* @param callback The callback to execute.
|
|
3942
|
-
* @returns A function to remove the callback.
|
|
3943
|
-
*/
|
|
3944
|
-
onSelectionChange(t, n) {
|
|
3945
|
-
return this._eventManager.onSelectionChange(
|
|
3946
|
-
t,
|
|
3947
|
-
n
|
|
3948
|
-
);
|
|
3949
|
-
}
|
|
3950
|
-
/**
|
|
3951
|
-
* A callback function that runs when the editor has been mounted.
|
|
3952
|
-
*
|
|
3953
|
-
* This can be useful for plugins to initialize themselves after the editor has been mounted.
|
|
3954
|
-
*
|
|
3955
|
-
* @param callback The callback to execute.
|
|
3956
|
-
* @returns A function to remove the callback.
|
|
3957
|
-
*/
|
|
3958
|
-
onMount(t) {
|
|
3959
|
-
this._eventManager.onMount(t);
|
|
3960
|
-
}
|
|
3961
|
-
/**
|
|
3962
|
-
* A callback function that runs when the editor has been unmounted.
|
|
3963
|
-
*
|
|
3964
|
-
* This can be useful for plugins to clean up themselves after the editor has been unmounted.
|
|
3965
|
-
*
|
|
3966
|
-
* @param callback The callback to execute.
|
|
3967
|
-
* @returns A function to remove the callback.
|
|
3968
|
-
*/
|
|
3969
|
-
onUnmount(t) {
|
|
3970
|
-
this._eventManager.onUnmount(t);
|
|
3971
|
-
}
|
|
3972
|
-
/**
|
|
3973
|
-
* Gets the bounding box of the current selection.
|
|
3974
|
-
* @returns The bounding box of the current selection.
|
|
3975
|
-
*/
|
|
3976
|
-
getSelectionBoundingBox() {
|
|
3977
|
-
return this._selectionManager.getSelectionBoundingBox();
|
|
3978
|
-
}
|
|
3979
|
-
get isEmpty() {
|
|
3980
|
-
const t = this.document;
|
|
3981
|
-
return t.length === 0 || t.length === 1 && t[0].type === "paragraph" && t[0].content.length === 0;
|
|
3982
|
-
}
|
|
3983
|
-
/**
|
|
3984
|
-
* Paste HTML into the editor. Defaults to converting HTML to BlockNote HTML.
|
|
3985
|
-
* @param html The HTML to paste.
|
|
3986
|
-
* @param raw Whether to paste the HTML as is, or to convert it to BlockNote HTML.
|
|
3987
|
-
*/
|
|
3988
|
-
pasteHTML(t, n = !1) {
|
|
3989
|
-
this._exportManager.pasteHTML(t, n);
|
|
3990
|
-
}
|
|
3991
|
-
/**
|
|
3992
|
-
* Paste text into the editor. Defaults to interpreting text as markdown.
|
|
3993
|
-
* @param text The text to paste.
|
|
3994
|
-
*/
|
|
3995
|
-
pasteText(t) {
|
|
3996
|
-
return this._exportManager.pasteText(t);
|
|
3997
|
-
}
|
|
3998
|
-
/**
|
|
3999
|
-
* Paste markdown into the editor.
|
|
4000
|
-
* @param markdown The markdown to paste.
|
|
4001
|
-
*/
|
|
4002
|
-
pasteMarkdown(t) {
|
|
4003
|
-
return this._exportManager.pasteMarkdown(t);
|
|
4004
|
-
}
|
|
4005
|
-
}
|
|
4006
|
-
class fs {
|
|
4007
|
-
constructor(e, t, n) {
|
|
4008
|
-
this.mappings = t, this.options = n;
|
|
4009
|
-
}
|
|
4010
|
-
async resolveFile(e) {
|
|
4011
|
-
var n;
|
|
4012
|
-
if (!((n = this.options) != null && n.resolveFileUrl))
|
|
4013
|
-
return (await fetch(e)).blob();
|
|
4014
|
-
const t = await this.options.resolveFileUrl(e);
|
|
4015
|
-
return t instanceof Blob ? t : (await fetch(t)).blob();
|
|
4016
|
-
}
|
|
4017
|
-
mapStyles(e) {
|
|
4018
|
-
return Object.entries(e).map(([n, s]) => this.mappings.styleMapping[n](s, this));
|
|
4019
|
-
}
|
|
4020
|
-
mapInlineContent(e) {
|
|
4021
|
-
return this.mappings.inlineContentMapping[e.type](
|
|
4022
|
-
e,
|
|
4023
|
-
this
|
|
4024
|
-
);
|
|
4025
|
-
}
|
|
4026
|
-
transformInlineContent(e) {
|
|
4027
|
-
return e.map((t) => this.mapInlineContent(t));
|
|
4028
|
-
}
|
|
4029
|
-
async mapBlock(e, t, n, s) {
|
|
4030
|
-
return this.mappings.blockMapping[e.type](
|
|
4031
|
-
e,
|
|
4032
|
-
this,
|
|
4033
|
-
t,
|
|
4034
|
-
n,
|
|
4035
|
-
s
|
|
4036
|
-
);
|
|
4037
|
-
}
|
|
4038
|
-
}
|
|
4039
|
-
function hs(o) {
|
|
4040
|
-
return {
|
|
4041
|
-
createBlockMapping: (e) => e,
|
|
4042
|
-
createInlineContentMapping: (e) => e,
|
|
4043
|
-
createStyleMapping: (e) => e
|
|
4044
|
-
};
|
|
4045
|
-
}
|
|
4046
|
-
function ms(o, ...e) {
|
|
4047
|
-
const t = [...o];
|
|
4048
|
-
for (const n of e)
|
|
4049
|
-
for (const s of n) {
|
|
4050
|
-
const r = t.findLastIndex(
|
|
4051
|
-
(i) => i.group === s.group
|
|
4052
|
-
);
|
|
4053
|
-
r === -1 ? t.push(s) : t.splice(r + 1, 0, s);
|
|
4054
|
-
}
|
|
4055
|
-
return t;
|
|
4056
|
-
}
|
|
4057
|
-
export {
|
|
4058
|
-
ye as BlockChangeExtension,
|
|
4059
|
-
$e as BlockNoteEditor,
|
|
4060
|
-
wt as BlockNoteSchema,
|
|
4061
|
-
Ls as COLORS_DARK_MODE_DEFAULT,
|
|
4062
|
-
_s as COLORS_DEFAULT,
|
|
4063
|
-
Si as CustomBlockNoteSchema,
|
|
4064
|
-
Pt as DEFAULT_LINK_PROTOCOL,
|
|
4065
|
-
mi as DRAG_EXCLUSION_CLASSNAME,
|
|
4066
|
-
mt as DropCursorExtension,
|
|
4067
|
-
Ds as EMPTY_CELL_HEIGHT,
|
|
4068
|
-
Xe as EMPTY_CELL_WIDTH,
|
|
4069
|
-
Ce as EventEmitter,
|
|
4070
|
-
fs as Exporter,
|
|
4071
|
-
Os as FILE_AUDIO_ICON_SVG,
|
|
4072
|
-
$s as FILE_IMAGE_ICON_SVG,
|
|
4073
|
-
Hs as FILE_VIDEO_ICON_SVG,
|
|
4074
|
-
J as FilePanelExtension,
|
|
4075
|
-
dt as ForkYDocExtension,
|
|
4076
|
-
Y as FormattingToolbarExtension,
|
|
4077
|
-
ve as HTMLToBlocks,
|
|
4078
|
-
Ct as HistoryExtension,
|
|
4079
|
-
kt as LinkToolbarExtension,
|
|
4080
|
-
bt as NodeSelectionKeyboardExtension,
|
|
4081
|
-
gt as PlaceholderExtension,
|
|
4082
|
-
xt as PreviousBlockTypeExtension,
|
|
4083
|
-
ht as SchemaMigration,
|
|
4084
|
-
Wt as ShowSelectionExtension,
|
|
4085
|
-
Bt as SideMenuExtension,
|
|
4086
|
-
ki as SideMenuView,
|
|
4087
|
-
ge as SuggestionMenu,
|
|
4088
|
-
St as TableHandlesExtension,
|
|
4089
|
-
bi as TableHandlesView,
|
|
4090
|
-
yt as TrailingNodeExtension,
|
|
4091
|
-
ke as UniqueID,
|
|
4092
|
-
U as UnreachableCaseError,
|
|
4093
|
-
Et as VALID_LINK_PROTOCOLS,
|
|
4094
|
-
ut as YCursorExtension,
|
|
4095
|
-
pt as YSyncExtension,
|
|
4096
|
-
ft as YUndoExtension,
|
|
4097
|
-
Fs as addDefaultPropsExternalHTML,
|
|
4098
|
-
G as addInlineContentAttributes,
|
|
4099
|
-
Je as addInlineContentKeyboardShortcuts,
|
|
4100
|
-
Vs as addNodeAndExtensionsToSpec,
|
|
4101
|
-
Us as addStyleAttributes,
|
|
4102
|
-
zs as applyNonSelectableBlockFix,
|
|
4103
|
-
gs as assertEmpty,
|
|
4104
|
-
Rs as audioParse,
|
|
4105
|
-
Gs as audioRender,
|
|
4106
|
-
Ws as audioToExternalHTML,
|
|
4107
|
-
js as blockHasType,
|
|
4108
|
-
Z as blockToNode,
|
|
4109
|
-
at as blocksToMarkdown,
|
|
4110
|
-
qs as camelToDataKebab,
|
|
4111
|
-
Ks as captureCellAnchor,
|
|
4112
|
-
xi as checkPageBreakBlocksInSchema,
|
|
4113
|
-
ct as cleanHTMLToMarkdown,
|
|
4114
|
-
ms as combineByGroup,
|
|
4115
|
-
qe as contentNodeToInlineContent,
|
|
4116
|
-
je as contentNodeToTableContent,
|
|
4117
|
-
Js as createAudioBlockConfig,
|
|
4118
|
-
Ys as createAudioBlockSpec,
|
|
4119
|
-
Qs as createBlockConfig,
|
|
4120
|
-
Xs as createBlockSpec,
|
|
4121
|
-
Zs as createBlockSpecFromTiptapNode,
|
|
4122
|
-
er as createBulletListItemBlockConfig,
|
|
4123
|
-
tr as createBulletListItemBlockSpec,
|
|
4124
|
-
or as createCheckListItemBlockSpec,
|
|
4125
|
-
nr as createCheckListItemConfig,
|
|
4126
|
-
sr as createCodeBlockConfig,
|
|
4127
|
-
rr as createCodeBlockSpec,
|
|
4128
|
-
ir as createDefaultBlockDOMOutputSpec,
|
|
4129
|
-
ar as createDividerBlockConfig,
|
|
4130
|
-
cr as createDividerBlockSpec,
|
|
4131
|
-
Vt as createExtension,
|
|
4132
|
-
Be as createExternalHTMLExporter,
|
|
4133
|
-
lr as createFileBlockConfig,
|
|
4134
|
-
dr as createFileBlockSpec,
|
|
4135
|
-
ur as createHeadingBlockConfig,
|
|
4136
|
-
pr as createHeadingBlockSpec,
|
|
4137
|
-
fr as createImageBlockConfig,
|
|
4138
|
-
hr as createImageBlockSpec,
|
|
4139
|
-
ps as createInlineContentSpec,
|
|
4140
|
-
Qe as createInlineContentSpecFromTipTapNode,
|
|
4141
|
-
lo as createInternalHTMLSerializer,
|
|
4142
|
-
mr as createInternalInlineContentSpec,
|
|
4143
|
-
kr as createInternalStyleSpec,
|
|
4144
|
-
br as createNumberedListItemBlockConfig,
|
|
4145
|
-
gr as createNumberedListItemBlockSpec,
|
|
4146
|
-
Ei as createPageBreakBlockConfig,
|
|
4147
|
-
Pi as createPageBreakBlockSpec,
|
|
4148
|
-
Br as createParagraphBlockConfig,
|
|
4149
|
-
yr as createParagraphBlockSpec,
|
|
4150
|
-
Cr as createQuoteBlockConfig,
|
|
4151
|
-
Sr as createQuoteBlockSpec,
|
|
4152
|
-
Ii as createStore,
|
|
4153
|
-
xr as createStyleSpec,
|
|
4154
|
-
Er as createStyleSpecFromTipTapMark,
|
|
4155
|
-
Pr as createTableBlockSpec,
|
|
4156
|
-
Tr as createToggleListItemBlockConfig,
|
|
4157
|
-
wr as createToggleListItemBlockSpec,
|
|
4158
|
-
Mr as createToggleWrapper,
|
|
4159
|
-
vr as createVideoBlockConfig,
|
|
4160
|
-
Ir as createVideoBlockSpec,
|
|
4161
|
-
Ar as defaultBlockSpecs,
|
|
4162
|
-
Nr as defaultBlockToHTML,
|
|
4163
|
-
Lr as defaultInlineContentSchema,
|
|
4164
|
-
_r as defaultInlineContentSpecs,
|
|
4165
|
-
Dr as defaultProps,
|
|
4166
|
-
Or as defaultStyleSchema,
|
|
4167
|
-
$r as defaultStyleSpecs,
|
|
4168
|
-
Hr as defaultToggledState,
|
|
4169
|
-
We as docToBlocks,
|
|
4170
|
-
Fr as editorHasBlockWithType,
|
|
4171
|
-
Pn as expandPMRangeToWords,
|
|
4172
|
-
Vr as fileParse,
|
|
4173
|
-
Ur as filenameFromURL,
|
|
4174
|
-
zr as filterSuggestionItems,
|
|
4175
|
-
H as fixColumnList,
|
|
4176
|
-
Rr as formatKeyboardShortcut,
|
|
4177
|
-
tt as getBackgroundColorAttribute,
|
|
4178
|
-
Bo as getBlock,
|
|
4179
|
-
Bs as getBlockCache,
|
|
4180
|
-
Gr as getBlockFromPos,
|
|
4181
|
-
K as getBlockInfo,
|
|
4182
|
-
v as getBlockInfoFromResolvedPos,
|
|
4183
|
-
B as getBlockInfoFromSelection,
|
|
4184
|
-
z as getBlockInfoFromTransaction,
|
|
4185
|
-
ys as getBlockInfoWithManualOffset,
|
|
4186
|
-
be as getBlockNoteSchema,
|
|
4187
|
-
Cs as getBlockSchema,
|
|
4188
|
-
it as getBlocksChangedByTransaction,
|
|
4189
|
-
Ss as getColspan,
|
|
4190
|
-
gi as getDefaultEmojiPickerItems,
|
|
4191
|
-
Wr as getDefaultSlashMenuItems,
|
|
4192
|
-
Xt as getInlineContentParseRules,
|
|
4193
|
-
xs as getInlineContentSchema,
|
|
4194
|
-
jr as getInlineContentSchemaFromSpecs,
|
|
4195
|
-
qr as getLanguageId,
|
|
4196
|
-
D as getNearestBlockPos,
|
|
4197
|
-
Co as getNextBlock,
|
|
4198
|
-
P as getNodeById,
|
|
4199
|
-
Ti as getPageBreakSlashMenuItems,
|
|
4200
|
-
So as getParentBlock,
|
|
4201
|
-
Kr as getParseRules,
|
|
4202
|
-
E as getPmSchema,
|
|
4203
|
-
yo as getPrevBlock,
|
|
4204
|
-
Es as getRowspan,
|
|
4205
|
-
Jr as getStyleParseRules,
|
|
4206
|
-
Ps as getStyleSchema,
|
|
4207
|
-
Yr as getStyleSchemaFromSpecs,
|
|
4208
|
-
Qr as getTextAlignmentAttribute,
|
|
4209
|
-
st as getTextColorAttribute,
|
|
4210
|
-
Xr as imageParse,
|
|
4211
|
-
Zr as imageRender,
|
|
4212
|
-
ei as imageToExternalHTML,
|
|
4213
|
-
V as inlineContentToNodes,
|
|
4214
|
-
Zt as insertBlocks,
|
|
4215
|
-
ti as insertOrUpdateBlockForSlashMenu,
|
|
4216
|
-
oi as isAppleOS,
|
|
4217
|
-
Q as isEmptyColumn,
|
|
4218
|
-
Ts as isLinkInlineContent,
|
|
4219
|
-
ni as isNodeBlock,
|
|
4220
|
-
ws as isPartialLinkInlineContent,
|
|
4221
|
-
Ms as isPartialTableCell,
|
|
4222
|
-
si as isSafari,
|
|
4223
|
-
vs as isStyledTextInlineContent,
|
|
4224
|
-
Is as isTableCell,
|
|
4225
|
-
ri as isTableCellSelection,
|
|
4226
|
-
et as isVideoUrl,
|
|
4227
|
-
As as mapTableCell,
|
|
4228
|
-
hs as mappingFactory,
|
|
4229
|
-
Oo as markdownToBlocks,
|
|
4230
|
-
Ie as markdownToHTML,
|
|
4231
|
-
ee as mergeCSSClasses,
|
|
4232
|
-
ii as mergeParagraphs,
|
|
4233
|
-
C as nodeToBlock,
|
|
4234
|
-
q as nodeToCustomInlineContent,
|
|
4235
|
-
ai as parseAudioElement,
|
|
4236
|
-
ci as parseDefaultProps,
|
|
4237
|
-
Ye as propsToAttributes,
|
|
4238
|
-
Ke as prosemirrorSliceToSlicedBlocks,
|
|
4239
|
-
ae as removeAndInsertBlocks,
|
|
4240
|
-
eo as removeEmptyColumns,
|
|
4241
|
-
Ne as selectedFragmentToHTML,
|
|
4242
|
-
Bi as sideMenuPluginKey,
|
|
4243
|
-
li as stylePropsToAttributes,
|
|
4244
|
-
Ge as tableContentToNodes,
|
|
4245
|
-
yi as tableHandlesPluginKey,
|
|
4246
|
-
di as tablePropSchema,
|
|
4247
|
-
ui as trackPosition,
|
|
4248
|
-
Ze as updateBlock,
|
|
4249
|
-
nt as updateBlockCommand,
|
|
4250
|
-
rt as updateBlockTr,
|
|
4251
|
-
wi as uploadToTmpFilesDotOrg_DEV_ONLY,
|
|
4252
|
-
pi as videoParse,
|
|
4253
|
-
Mi as withPageBreak,
|
|
4254
|
-
fi as wrapInBlockStructure
|
|
4255
|
-
};
|
|
4256
|
-
//# sourceMappingURL=blocknote.js.map
|
|
1
|
+
import { $ as e, $t as t, A as n, An as r, At as i, B as a, Bn as o, C as s, Cn as c, Ct as l, D as u, Dn as d, Dt as f, E as p, En as m, Et as h, F as g, Fn as _, G as v, Gn as y, Gt as b, H as x, Hn as S, I as C, In as w, J as T, Jn as E, Jt as D, K as O, Kn as k, Kt as A, L as j, Ln as M, M as N, Mn as P, N as F, Nn as I, O as L, On as R, Ot as z, P as B, Pn as V, Q as H, Qt as U, R as W, Rn as G, S as K, Sn as q, St as J, T as Y, Tn as X, Tt as Z, U as Q, Un as $, Ut as ee, Vn as te, Vt as ne, W as re, Wn as ie, Wt as ae, X as oe, Xt as se, Y as ce, Yt as le, Z as ue, Zt as de, _ as fe, _n as pe, _t as me, a as he, an as ge, at as _e, b as ve, bn as ye, bt as be, c as xe, cn as Se, ct as Ce, d as we, dn as Te, dt as Ee, en as De, et as Oe, f as ke, fn as Ae, ft as je, g as Me, gn as Ne, gt as Pe, h as Fe, hn as Ie, ht as Le, i as Re, in as ze, it as Be, j as Ve, jn as He, k as Ue, kn as We, kt as Ge, l as Ke, ln as qe, lt as Je, m as Ye, mn as Xe, mt as Ze, n as Qe, nn as $e, nt as et, o as tt, on as nt, ot as rt, p as it, pn as at, pt as ot, q as st, qn as ct, qt as lt, r as ut, rn as dt, rt as ft, s as pt, sn as mt, st as ht, t as gt, tn as _t, tt as vt, u as yt, un as bt, ut as xt, v as St, vn as Ct, vt as wt, w as Tt, wn as Et, wt as Dt, x as Ot, xn as kt, xt as At, y as jt, yn as Mt, yt as Nt, z as Pt, zn as Ft } from "./blocks-DYl7UTS4.js";
|
|
2
|
+
import { _ as It, a as Lt, b as Rt, c as zt, d as Bt, f as Vt, g as Ht, h as Ut, i as Wt, l as Gt, m as Kt, n as qt, o as Jt, p as Yt, r as Xt, s as Zt, t as Qt, u as $t, v as en, x as tn, y as nn } from "./src-Hjv1f5lc.js";
|
|
3
|
+
import { C as rn, D as an, E as on, O as sn, S as cn, T as ln, _ as un, a as dn, b as fn, c as pn, d as mn, f as hn, g as gn, h as _n, i as vn, k as yn, m as bn, n as xn, o as Sn, p as Cn, r as wn, s as Tn, t as En, u as Dn, v as On, w as kn, x as An, y as jn } from "./extensions-3nf9PPhA.js";
|
|
4
|
+
import { n as Mn, t as Nn } from "./BlockNoteExtension-B6RhuQ3V.js";
|
|
5
|
+
import { t as Pn } from "./ShowSelection-BsHFfdMi.js";
|
|
6
|
+
import { t as Fn } from "./EventEmitter-CuPnGDYt.js";
|
|
7
|
+
export { an as BlockChangeExtension, Wt as BlockNoteEditor, gt as BlockNoteSchema, be as COLORS_DARK_MODE_DEFAULT, At as COLORS_DEFAULT, ne as CustomBlockNoteSchema, _n as DEFAULT_LINK_PROTOCOL, fn as DRAG_EXCLUSION_CLASSNAME, An as DropCursorExtension, Tt as EMPTY_CELL_HEIGHT, Y as EMPTY_CELL_WIDTH, Fn as EventEmitter, Xt as Exporter, rt as FILE_AUDIO_ICON_SVG, x as FILE_IMAGE_ICON_SVG, St as FILE_VIDEO_ICON_SVG, ot as FilePanelExtension, rn as ForkYDocExtension, jn as FormattingToolbarExtension, Gt as HTMLToBlocks, On as HistoryExtension, un as LinkToolbarExtension, bn as NodeSelectionKeyboardExtension, Cn as PlaceholderExtension, hn as PreviousBlockTypeExtension, cn as SchemaMigration, Pn as ShowSelectionExtension, Sn as SideMenuExtension, Tn as SideMenuView, ke as SuggestionMenu, xn as TableHandlesExtension, wn as TableHandlesView, En as TrailingNodeExtension, E as UniqueID, G as UnreachableCaseError, gn as VALID_LINK_PROTOCOLS, on as YCursorExtension, ln as YSyncExtension, kn as YUndoExtension, Ze as addDefaultPropsExternalHTML, se as addInlineContentAttributes, de as addInlineContentKeyboardShortcuts, Mt as addNodeAndExtensionsToSpec, b as addStyleAttributes, ye as applyNonSelectableBlockFix, Ft as assertEmpty, ht as audioParse, Ce as audioRender, Je as audioToExternalHTML, Ye as blockHasType, z as blockToNode, Dn as blocksToMarkdown, R as camelToDataKebab, J as captureCellAnchor, pt as checkPageBreakBlocksInSchema, mn as cleanHTMLToMarkdown, Qt as combineByGroup, _t as contentNodeToInlineContent, $e as contentNodeToTableContent, xt as createAudioBlockConfig, Ee as createAudioBlockSpec, kt as createBlockConfig, q as createBlockSpec, Et as createBlockSpecFromTiptapNode, Pt as createBulletListItemBlockConfig, a as createBulletListItemBlockSpec, j as createCheckListItemBlockSpec, W as createCheckListItemConfig, ft as createCodeBlockConfig, Be as createCodeBlockSpec, He as createDefaultBlockDOMOutputSpec, vt as createDividerBlockConfig, et as createDividerBlockSpec, Nn as createExtension, yn as createExternalHTMLExporter, H as createFileBlockConfig, e as createFileBlockSpec, T as createHeadingBlockConfig, ce as createHeadingBlockSpec, Q as createImageBlockConfig, re as createImageBlockSpec, Rt as createInlineContentSpec, U as createInlineContentSpecFromTipTapNode, Kt as createInternalHTMLSerializer, t as createInternalInlineContentSpec, A as createInternalStyleSpec, g as createNumberedListItemBlockConfig, C as createNumberedListItemBlockSpec, n as createPageBreakBlockConfig, Ve as createPageBreakBlockSpec, L as createParagraphBlockConfig, Ue as createParagraphBlockSpec, p as createQuoteBlockConfig, u as createQuoteBlockSpec, Mn as createStore, ee as createStyleSpec, lt as createStyleSpecFromTipTapMark, K as createTableBlockSpec, F as createToggleListItemBlockConfig, B as createToggleListItemBlockSpec, oe as createToggleWrapper, jt as createVideoBlockConfig, ve as createVideoBlockSpec, Qe as defaultBlockSpecs, P as defaultBlockToHTML, ut as defaultInlineContentSchema, Re as defaultInlineContentSpecs, Le as defaultProps, he as defaultStyleSchema, tt as defaultStyleSpecs, ue as defaultToggledState, dt as docToBlocks, Fe as editorHasBlockWithType, Lt as expandPMRangeToWords, Oe as fileParse, We as filenameFromURL, Ke as filterSuggestionItems, Ht as fixColumnList, V as formatKeyboardShortcut, Pe as getBackgroundColorAttribute, $t as getBlock, mt as getBlockCache, X as getBlockFromPos, at as getBlockInfo, Xe as getBlockInfoFromResolvedPos, Ie as getBlockInfoFromSelection, Ne as getBlockInfoFromTransaction, pe as getBlockInfoWithManualOffset, Se as getBlockNoteSchema, qe as getBlockSchema, sn as getBlocksChangedByTransaction, o as getColspan, dn as getDefaultEmojiPickerItems, yt as getDefaultSlashMenuItems, tn as getInlineContentParseRules, bt as getInlineContentSchema, De as getInlineContentSchemaFromSpecs, _e as getLanguageId, Ct as getNearestBlockPos, Bt as getNextBlock, h as getNodeById, xe as getPageBreakSlashMenuItems, Vt as getParentBlock, c as getParseRules, Te as getPmSchema, Yt as getPrevBlock, te as getRowspan, ae as getStyleParseRules, Ae as getStyleSchema, D as getStyleSchemaFromSpecs, me as getTextAlignmentAttribute, wt as getTextColorAttribute, v as imageParse, O as imageRender, st as imageToExternalHTML, Ge as inlineContentToNodes, nn as insertBlocks, we as insertOrUpdateBlockForSlashMenu, _ as isAppleOS, It as isEmptyColumn, y as isLinkInlineContent, f as isNodeBlock, k as isPartialLinkInlineContent, S as isPartialTableCell, w as isSafari, ct as isStyledTextInlineContent, $ as isTableCell, Me as isTableCellSelection, r as isVideoUrl, ie as mapTableCell, qt as mappingFactory, Zt as markdownToBlocks, zt as markdownToHTML, M as mergeCSSClasses, I as mergeParagraphs, ze as nodeToBlock, ge as nodeToCustomInlineContent, je as parseAudioElement, Nt as parseDefaultProps, m as propsToAttributes, nt as prosemirrorSliceToSlicedBlocks, Ut as removeAndInsertBlocks, en as removeEmptyColumns, Jt as selectedFragmentToHTML, pn as sideMenuPluginKey, le as stylePropsToAttributes, i as tableContentToNodes, vn as tableHandlesPluginKey, s as tablePropSchema, it as trackPosition, l as updateBlock, Dt as updateBlockCommand, Z as updateBlockTr, fe as uploadToTmpFilesDotOrg_DEV_ONLY, Ot as videoParse, N as withPageBreak, d as wrapInBlockStructure };
|