@blocknote/core 0.44.2 → 0.45.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-BWw0r8Gy.cjs.map +1 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
- package/dist/{BlockNoteSchema-BsTi0fNS.js → BlockNoteSchema-BOW16JHv.js} +2 -2
- package/dist/{BlockNoteSchema-BsTi0fNS.js.map → BlockNoteSchema-BOW16JHv.js.map} +1 -1
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs → BlockNoteSchema-CzZbr4Ed.cjs} +2 -2
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs.map → BlockNoteSchema-CzZbr4Ed.cjs.map} +1 -1
- package/dist/{TrailingNode-CG2a-HDA.js → TrailingNode-8cXFaQUm.js} +484 -487
- package/dist/TrailingNode-8cXFaQUm.js.map +1 -0
- package/dist/TrailingNode-DPu6X9ym.cjs +2 -0
- package/dist/TrailingNode-DPu6X9ym.cjs.map +1 -0
- package/dist/{blockToNode-DBNbhwwC.js → blockToNode-BNoNIXU7.js} +2 -2
- package/dist/{blockToNode-DBNbhwwC.js.map → blockToNode-BNoNIXU7.js.map} +1 -1
- package/dist/{blockToNode-w7H99R6p.cjs → blockToNode-CumVjgem.cjs} +2 -2
- package/dist/{blockToNode-w7H99R6p.cjs.map → blockToNode-CumVjgem.cjs.map} +1 -1
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1118 -1077
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/defaultBlocks-D1cc0lV9.cjs +6 -0
- package/dist/defaultBlocks-D1cc0lV9.cjs.map +1 -0
- package/dist/{defaultBlocks-B63ufZ5N.js → defaultBlocks-DvCGYzqu.js} +168 -206
- package/dist/defaultBlocks-DvCGYzqu.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +15 -15
- package/src/api/blockManipulation/selections/selection.ts +9 -4
- package/src/api/blockManipulation/tables/tables.test.ts +140 -0
- package/src/api/blockManipulation/tables/tables.ts +1 -1
- package/src/api/parsers/markdown/parseMarkdown.ts +11 -0
- package/src/blocks/ListItem/CheckListItem/block.ts +2 -2
- package/src/blocks/ListItem/NumberedListItem/block.ts +5 -1
- package/src/editor/BlockNoteEditor.test.ts +0 -1
- package/src/editor/BlockNoteEditor.ts +9 -39
- package/src/editor/BlockNoteExtension.ts +5 -0
- package/src/editor/managers/EventManager.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +2 -12
- package/src/editor/managers/ExtensionManager/index.ts +7 -2
- package/src/editor/managers/SelectionManager.ts +10 -10
- package/src/extensions/BlockChange/BlockChange.ts +2 -2
- package/src/extensions/Collaboration/Collaboration.ts +55 -0
- package/src/extensions/Collaboration/ForkYDoc.ts +4 -9
- package/src/extensions/Collaboration/YCursorPlugin.ts +56 -60
- package/src/extensions/Collaboration/YSync.ts +2 -2
- package/src/extensions/Collaboration/YUndo.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +40 -68
- package/src/extensions/TableHandles/TableHandles.ts +9 -5
- package/src/index.ts +2 -1
- package/src/schema/blocks/createSpec.ts +3 -0
- package/src/util/expandToWords.ts +38 -0
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/editor/BlockNoteEditor.d.ts +5 -34
- package/types/src/editor/BlockNoteExtension.d.ts +4 -0
- package/types/src/editor/managers/SelectionManager.d.ts +4 -4
- package/types/src/extensions/Collaboration/Collaboration.d.ts +76 -0
- package/types/src/extensions/Collaboration/ForkYDoc.d.ts +2 -11
- package/types/src/extensions/Collaboration/YCursorPlugin.d.ts +3 -11
- package/types/src/extensions/Collaboration/YSync.d.ts +2 -4
- package/types/src/extensions/Collaboration/YUndo.d.ts +1 -1
- package/types/src/index.d.ts +2 -1
- package/types/src/util/expandToWords.d.ts +13 -0
- package/dist/TrailingNode-CG2a-HDA.js.map +0 -1
- package/dist/TrailingNode-Du4SNHun.cjs +0 -2
- package/dist/TrailingNode-Du4SNHun.cjs.map +0 -1
- package/dist/defaultBlocks-B63ufZ5N.js.map +0 -1
- package/dist/defaultBlocks-BX6UxQa8.cjs +0 -6
- package/dist/defaultBlocks-BX6UxQa8.cjs.map +0 -1
package/dist/blocknote.js
CHANGED
|
@@ -1,208 +1,208 @@
|
|
|
1
1
|
var Oe = Object.defineProperty;
|
|
2
|
-
var Fe = (
|
|
3
|
-
var h = (
|
|
4
|
-
import { Slice as N, Fragment as A, DOMSerializer as he, DOMParser as
|
|
2
|
+
var Fe = (o, e, t) => e in o ? Oe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var h = (o, e, t) => Fe(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Slice as N, Fragment as A, DOMSerializer as he, DOMParser as $e, Node as He } from "prosemirror-model";
|
|
5
5
|
import { ReplaceStep as Ve, ReplaceAroundStep as V } from "prosemirror-transform";
|
|
6
|
-
import { n as U, i as O, g as C, b as
|
|
7
|
-
import { B as
|
|
8
|
-
import { ak as
|
|
9
|
-
import { aw as
|
|
10
|
-
import { j as ot, k as be, l as nt, m as st, n as rt, c as R,
|
|
11
|
-
import { s as Ct, B as
|
|
12
|
-
import { C as
|
|
13
|
-
import { Node as D, Extension as
|
|
6
|
+
import { n as U, i as O, g as C, b as q, a as b, t as Ue, U as F, q as _, r as $, d as ze, s as Ge, u as Re, v as Y, w as B, x as me, y as je, z as ke, A as z } from "./blockToNode-BNoNIXU7.js";
|
|
7
|
+
import { B as ns, G as ss, C as rs, D as is, N as as, E as cs, O as ls, F as ds, H as us, I as ps, L as fs, J as hs, M as ms, K as ks } from "./blockToNode-BNoNIXU7.js";
|
|
8
|
+
import { ak as H, al as We, am as Ke, an as Je, aj as x, ao as qe, ap as Ye, a5 as Qe, a8 as G, aq as Xe, ar as Ze, a6 as et, as as Q, a9 as ge, at as tt } from "./defaultBlocks-DvCGYzqu.js";
|
|
9
|
+
import { aw as bs, av as ys, E as Ss, a as Bs, F as Cs, r as xs, N as Es, a4 as Ms, ad as ws, aG as Ts, ax as Ps, b as vs, d as Is, e as As, a0 as _s, aM as Ds, au as Ls, c as Ns, f as Os, ag as Fs, ah as $s, aB as Hs, x as Vs, y as Us, A as zs, z as Gs, g as Rs, h as js, T as Ws, j as Ks, k as Js, l as qs, n as Ys, o as Qs, q as Xs, s as Zs, w as er, aC as tr, aH as or, B as nr, C as sr, H as rr, I as ir, J as ar, K as cr, aE as lr, aI as dr, M as ur, D as pr, G as fr, S as hr, O as mr, Q as kr, W as gr, U as br, _ as yr, Z as Sr, a2 as Br, Y as Cr, X as xr, R as Er, $ as Mr, m as wr, aN as Tr, aK as Pr, az as vr, af as Ir, i as Ar, ay as _r, aD as Dr, ae as Lr, a7 as Nr, t as Or, u as Fr, v as $r, aJ as Hr, ai as Vr, aL as Ur, a1 as zr, V as Gr, p as Rr, a3 as jr, aF as Wr, L as Kr, aO as Jr, P as qr, aA as Yr } from "./defaultBlocks-DvCGYzqu.js";
|
|
10
|
+
import { j as ot, k as be, l as nt, m as st, n as rt, c as R, F as it, Y as at, a as ct, b as lt, S as dt, B as ye, D as ut, L as pt, N as ft, P as ht, g as mt, i as kt, H as gt, h as bt, e as yt, V as St, d as Bt } from "./TrailingNode-8cXFaQUm.js";
|
|
11
|
+
import { s as Ct, B as xt } from "./BlockNoteSchema-BOW16JHv.js";
|
|
12
|
+
import { C as Xr, b as Zr, c as ei, a as ti, g as oi, u as ni, w as si } from "./BlockNoteSchema-BOW16JHv.js";
|
|
13
|
+
import { Node as D, Extension as E, mergeAttributes as Et, Mark as X, extensions as I, isNodeSelection as Mt, posToDOMRect as wt, selectionToInsertionEnd as Tt, getSchema as Pt, createDocument as vt, Editor as It } from "@tiptap/core";
|
|
14
14
|
import { E as Se } from "./EventEmitter-CjSwpTbz.js";
|
|
15
15
|
import { Fragment as Z, Slice as ne } from "@tiptap/pm/model";
|
|
16
16
|
import { e as At } from "./en-njEqD7AG.js";
|
|
17
17
|
import { inputRules as _t, InputRule as Dt } from "@handlewithcare/prosemirror-inputrules";
|
|
18
18
|
import { keymap as Lt } from "@tiptap/pm/keymap";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { Gapcursor as
|
|
22
|
-
import { Link as
|
|
19
|
+
import { c as Nt, o as Ot } from "./BlockNoteExtension-C2X7LW-V.js";
|
|
20
|
+
import { a as ii } from "./BlockNoteExtension-C2X7LW-V.js";
|
|
21
|
+
import { Gapcursor as Ft } from "@tiptap/extension-gapcursor";
|
|
22
|
+
import { Link as $t } from "@tiptap/extension-link";
|
|
23
23
|
import { Text as Ht } from "@tiptap/extension-text";
|
|
24
24
|
import { NodeSelection as L, TextSelection as M, Plugin as ee } from "prosemirror-state";
|
|
25
25
|
import { CellSelection as te, TableMap as se } from "prosemirror-tables";
|
|
26
|
-
import { S as
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import { unified as
|
|
32
|
-
import { TextSelection as
|
|
33
|
-
function
|
|
26
|
+
import { S as Vt } from "./ShowSelection-Dz-NEase.js";
|
|
27
|
+
import Ut from "remark-gfm";
|
|
28
|
+
import zt from "remark-parse";
|
|
29
|
+
import Gt, { defaultHandlers as re } from "remark-rehype";
|
|
30
|
+
import Rt from "rehype-stringify";
|
|
31
|
+
import { unified as jt } from "unified";
|
|
32
|
+
import { TextSelection as Wt } from "@tiptap/pm/state";
|
|
33
|
+
function Kt(o, e) {
|
|
34
34
|
const t = [
|
|
35
35
|
{
|
|
36
|
-
tag: `[data-inline-content-type="${
|
|
37
|
-
contentElement: (
|
|
38
|
-
const s =
|
|
36
|
+
tag: `[data-inline-content-type="${o.type}"]`,
|
|
37
|
+
contentElement: (n) => {
|
|
38
|
+
const s = n;
|
|
39
39
|
return s.matches("[data-editable]") ? s : s.querySelector("[data-editable]") || s;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
];
|
|
43
43
|
return e && t.push({
|
|
44
44
|
tag: "*",
|
|
45
|
-
getAttrs(
|
|
46
|
-
if (typeof
|
|
45
|
+
getAttrs(n) {
|
|
46
|
+
if (typeof n == "string")
|
|
47
47
|
return !1;
|
|
48
|
-
const s = e == null ? void 0 : e(
|
|
48
|
+
const s = e == null ? void 0 : e(n);
|
|
49
49
|
return s === void 0 ? !1 : s;
|
|
50
50
|
}
|
|
51
51
|
}), t;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
var
|
|
53
|
+
function Qn(o, e) {
|
|
54
|
+
var n;
|
|
55
55
|
const t = D.create({
|
|
56
|
-
name:
|
|
56
|
+
name: o.type,
|
|
57
57
|
inline: !0,
|
|
58
58
|
group: "inline",
|
|
59
|
-
draggable: (
|
|
60
|
-
selectable:
|
|
61
|
-
atom:
|
|
62
|
-
content:
|
|
59
|
+
draggable: (n = e.meta) == null ? void 0 : n.draggable,
|
|
60
|
+
selectable: o.content === "styled",
|
|
61
|
+
atom: o.content === "none",
|
|
62
|
+
content: o.content === "styled" ? "inline*" : "",
|
|
63
63
|
addAttributes() {
|
|
64
|
-
return Ke(
|
|
64
|
+
return Ke(o.propSchema);
|
|
65
65
|
},
|
|
66
66
|
addKeyboardShortcuts() {
|
|
67
|
-
return We(
|
|
67
|
+
return We(o);
|
|
68
68
|
},
|
|
69
69
|
parseHTML() {
|
|
70
|
-
return
|
|
71
|
-
|
|
70
|
+
return Kt(
|
|
71
|
+
o,
|
|
72
72
|
e.parse
|
|
73
73
|
);
|
|
74
74
|
},
|
|
75
75
|
renderHTML({ node: s }) {
|
|
76
|
-
const
|
|
76
|
+
const r = this.options.editor, i = e.render.call(
|
|
77
77
|
{ renderType: "dom", props: void 0 },
|
|
78
78
|
U(
|
|
79
79
|
s,
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
r.schema.inlineContentSchema,
|
|
81
|
+
r.schema.styleSchema
|
|
82
82
|
),
|
|
83
83
|
// TODO: fix cast
|
|
84
84
|
() => {
|
|
85
85
|
},
|
|
86
|
-
|
|
86
|
+
r
|
|
87
87
|
);
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
return H(
|
|
89
|
+
i,
|
|
90
|
+
o.type,
|
|
91
91
|
s.attrs,
|
|
92
|
-
|
|
92
|
+
o.propSchema
|
|
93
93
|
);
|
|
94
94
|
},
|
|
95
95
|
addNodeView() {
|
|
96
96
|
return (s) => {
|
|
97
|
-
const { node:
|
|
97
|
+
const { node: r, getPos: i } = s, c = this.options.editor, a = e.render.call(
|
|
98
98
|
{ renderType: "nodeView", props: s },
|
|
99
99
|
U(
|
|
100
|
-
|
|
100
|
+
r,
|
|
101
101
|
c.schema.inlineContentSchema,
|
|
102
102
|
c.schema.styleSchema
|
|
103
103
|
),
|
|
104
104
|
// TODO: fix cast
|
|
105
105
|
(l) => {
|
|
106
|
-
const d = O([l], c.pmSchema), u =
|
|
106
|
+
const d = O([l], c.pmSchema), u = i();
|
|
107
107
|
u && c.transact(
|
|
108
|
-
(p) => p.replaceWith(u, u +
|
|
108
|
+
(p) => p.replaceWith(u, u + r.nodeSize, d)
|
|
109
109
|
);
|
|
110
110
|
},
|
|
111
111
|
c
|
|
112
112
|
);
|
|
113
|
-
return
|
|
113
|
+
return H(
|
|
114
114
|
a,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
o.type,
|
|
116
|
+
r.attrs,
|
|
117
|
+
o.propSchema
|
|
118
118
|
);
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
return Je(
|
|
123
123
|
t,
|
|
124
|
-
|
|
124
|
+
o.propSchema,
|
|
125
125
|
{
|
|
126
126
|
...e,
|
|
127
127
|
toExternalHTML: e.toExternalHTML,
|
|
128
|
-
render(s,
|
|
128
|
+
render(s, r, i) {
|
|
129
129
|
const c = e.render(
|
|
130
130
|
s,
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
r,
|
|
132
|
+
i
|
|
133
133
|
);
|
|
134
|
-
return
|
|
134
|
+
return H(
|
|
135
135
|
c,
|
|
136
|
-
|
|
136
|
+
o.type,
|
|
137
137
|
s.props,
|
|
138
|
-
|
|
138
|
+
o.propSchema
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
const s = typeof t == "string" ? t : t.id,
|
|
146
|
-
(d) =>
|
|
147
|
-
), c =
|
|
144
|
+
function Jt(o, e, t, n = "before") {
|
|
145
|
+
const s = typeof t == "string" ? t : t.id, r = C(o), i = e.map(
|
|
146
|
+
(d) => q(d, r)
|
|
147
|
+
), c = x(s, o.doc);
|
|
148
148
|
if (!c)
|
|
149
149
|
throw new Error(`Block with ID ${s} not found`);
|
|
150
150
|
let a = c.posBeforeNode;
|
|
151
|
-
return
|
|
152
|
-
new Ve(a, a, new N(A.from(
|
|
153
|
-
),
|
|
154
|
-
(d) => b(d,
|
|
151
|
+
return n === "after" && (a += c.node.nodeSize), o.step(
|
|
152
|
+
new Ve(a, a, new N(A.from(i), 0, 0))
|
|
153
|
+
), i.map(
|
|
154
|
+
(d) => b(d, r)
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
|
-
function j(
|
|
158
|
-
if (!
|
|
157
|
+
function j(o) {
|
|
158
|
+
if (!o || o.type.name !== "column")
|
|
159
159
|
throw new Error("Invalid columnPos: does not point to column node.");
|
|
160
|
-
const e =
|
|
160
|
+
const e = o.firstChild;
|
|
161
161
|
if (!e)
|
|
162
162
|
throw new Error("Invalid column: does not have child node.");
|
|
163
163
|
const t = e.firstChild;
|
|
164
164
|
if (!t)
|
|
165
165
|
throw new Error("Invalid blockContainer: does not have child node.");
|
|
166
|
-
return
|
|
166
|
+
return o.childCount === 1 && e.childCount === 1 && t.type.name === "paragraph" && t.content.content.length === 0;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
const t =
|
|
170
|
-
if (!
|
|
168
|
+
function qt(o, e) {
|
|
169
|
+
const t = o.doc.resolve(e), n = t.nodeAfter;
|
|
170
|
+
if (!n || n.type.name !== "columnList")
|
|
171
171
|
throw new Error(
|
|
172
172
|
"Invalid columnListPos: does not point to columnList node."
|
|
173
173
|
);
|
|
174
|
-
for (let s =
|
|
175
|
-
const
|
|
174
|
+
for (let s = n.childCount - 1; s >= 0; s--) {
|
|
175
|
+
const r = o.doc.resolve(t.pos + 1).posAtIndex(s), c = o.doc.resolve(r).nodeAfter;
|
|
176
176
|
if (!c || c.type.name !== "column")
|
|
177
177
|
throw new Error("Invalid columnPos: does not point to column node.");
|
|
178
|
-
j(c) &&
|
|
178
|
+
j(c) && o.delete(r, r + c.nodeSize);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
function W(
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
if (!
|
|
181
|
+
function W(o, e) {
|
|
182
|
+
qt(o, e);
|
|
183
|
+
const n = o.doc.resolve(e).nodeAfter;
|
|
184
|
+
if (!n || n.type.name !== "columnList")
|
|
185
185
|
throw new Error(
|
|
186
186
|
"Invalid columnListPos: does not point to columnList node."
|
|
187
187
|
);
|
|
188
|
-
if (
|
|
188
|
+
if (n.childCount > 2)
|
|
189
189
|
return;
|
|
190
|
-
if (
|
|
190
|
+
if (n.childCount < 2)
|
|
191
191
|
throw new Error("Invalid columnList: contains fewer than two children.");
|
|
192
|
-
const s = e + 1,
|
|
193
|
-
if (!
|
|
192
|
+
const s = e + 1, i = o.doc.resolve(s).nodeAfter, c = e + n.nodeSize - 1, l = o.doc.resolve(c).nodeBefore;
|
|
193
|
+
if (!i || !l)
|
|
194
194
|
throw new Error("Invalid columnList: does not contain children.");
|
|
195
|
-
const d = j(
|
|
195
|
+
const d = j(i), u = j(l);
|
|
196
196
|
if (d && u) {
|
|
197
|
-
|
|
197
|
+
o.delete(e, e + n.nodeSize);
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
200
|
if (d) {
|
|
201
|
-
|
|
201
|
+
o.step(
|
|
202
202
|
new V(
|
|
203
203
|
// Replaces `columnList`.
|
|
204
204
|
e,
|
|
205
|
-
e +
|
|
205
|
+
e + n.nodeSize,
|
|
206
206
|
// Replaces with content of last `column`.
|
|
207
207
|
c - l.nodeSize + 1,
|
|
208
208
|
c - 1,
|
|
@@ -215,14 +215,14 @@ function W(n, e) {
|
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
if (u) {
|
|
218
|
-
|
|
218
|
+
o.step(
|
|
219
219
|
new V(
|
|
220
220
|
// Replaces `columnList`.
|
|
221
221
|
e,
|
|
222
|
-
e +
|
|
222
|
+
e + n.nodeSize,
|
|
223
223
|
// Replaces with content of first `column`.
|
|
224
224
|
s + 1,
|
|
225
|
-
s +
|
|
225
|
+
s + i.nodeSize - 1,
|
|
226
226
|
// Doesn't append anything.
|
|
227
227
|
N.empty,
|
|
228
228
|
0,
|
|
@@ -232,62 +232,62 @@ function W(n, e) {
|
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
function ie(
|
|
236
|
-
const
|
|
237
|
-
(u) =>
|
|
238
|
-
),
|
|
235
|
+
function ie(o, e, t) {
|
|
236
|
+
const n = C(o), s = t.map(
|
|
237
|
+
(u) => q(u, n)
|
|
238
|
+
), r = new Set(
|
|
239
239
|
e.map(
|
|
240
240
|
(u) => typeof u == "string" ? u : u.id
|
|
241
241
|
)
|
|
242
|
-
),
|
|
242
|
+
), i = [], c = /* @__PURE__ */ new Set(), a = typeof e[0] == "string" ? e[0] : e[0].id;
|
|
243
243
|
let l = 0;
|
|
244
|
-
if (
|
|
245
|
-
if (
|
|
244
|
+
if (o.doc.descendants((u, p) => {
|
|
245
|
+
if (r.size === 0)
|
|
246
246
|
return !1;
|
|
247
|
-
if (!u.type.isInGroup("bnBlock") || !
|
|
247
|
+
if (!u.type.isInGroup("bnBlock") || !r.has(u.attrs.id))
|
|
248
248
|
return !0;
|
|
249
|
-
if (
|
|
250
|
-
const g =
|
|
251
|
-
|
|
252
|
-
const y =
|
|
249
|
+
if (i.push(b(u, n)), r.delete(u.attrs.id), t.length > 0 && u.attrs.id === a) {
|
|
250
|
+
const g = o.doc.nodeSize;
|
|
251
|
+
o.insert(p, s);
|
|
252
|
+
const y = o.doc.nodeSize;
|
|
253
253
|
l += g - y;
|
|
254
254
|
}
|
|
255
|
-
const m =
|
|
256
|
-
f.node().type.name === "column" ? c.add(f.before(-1)) : f.node().type.name === "columnList" && c.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ?
|
|
257
|
-
const k =
|
|
255
|
+
const m = o.doc.nodeSize, f = o.doc.resolve(p - l);
|
|
256
|
+
f.node().type.name === "column" ? c.add(f.before(-1)) : f.node().type.name === "columnList" && c.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 - l, p - l + u.nodeSize);
|
|
257
|
+
const k = o.doc.nodeSize;
|
|
258
258
|
return l += m - k, !1;
|
|
259
|
-
}),
|
|
260
|
-
const u = [...
|
|
259
|
+
}), r.size > 0) {
|
|
260
|
+
const u = [...r].join(`
|
|
261
261
|
`);
|
|
262
262
|
throw Error(
|
|
263
263
|
"Blocks with the following IDs could not be found in the editor: " + u
|
|
264
264
|
);
|
|
265
265
|
}
|
|
266
|
-
return c.forEach((u) => W(
|
|
267
|
-
(u) => b(u,
|
|
268
|
-
), removedBlocks:
|
|
266
|
+
return c.forEach((u) => W(o, u)), { insertedBlocks: s.map(
|
|
267
|
+
(u) => b(u, n)
|
|
268
|
+
), removedBlocks: i };
|
|
269
269
|
}
|
|
270
|
-
function Yt(
|
|
271
|
-
let
|
|
270
|
+
function Yt(o, e, t, n, s) {
|
|
271
|
+
let r;
|
|
272
272
|
if (e)
|
|
273
273
|
if (typeof e == "string")
|
|
274
|
-
|
|
274
|
+
r = O([e], o.pmSchema, n);
|
|
275
275
|
else if (Array.isArray(e))
|
|
276
|
-
|
|
276
|
+
r = O(e, o.pmSchema, n);
|
|
277
277
|
else if (e.type === "tableContent")
|
|
278
|
-
|
|
278
|
+
r = Ue(e, o.pmSchema);
|
|
279
279
|
else
|
|
280
280
|
throw new F(e.type);
|
|
281
281
|
else throw new Error("blockContent is required");
|
|
282
282
|
const c = ((s == null ? void 0 : s.document) ?? document).createDocumentFragment();
|
|
283
|
-
for (const a of
|
|
284
|
-
if (a.type.name !== "text" &&
|
|
285
|
-
const l =
|
|
283
|
+
for (const a of r)
|
|
284
|
+
if (a.type.name !== "text" && o.schema.inlineContentSchema[a.type.name]) {
|
|
285
|
+
const l = o.schema.inlineContentSpecs[a.type.name].implementation;
|
|
286
286
|
if (l) {
|
|
287
287
|
const d = U(
|
|
288
288
|
a,
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
o.schema.inlineContentSchema,
|
|
290
|
+
o.schema.styleSchema
|
|
291
291
|
), u = l.render.call(
|
|
292
292
|
{
|
|
293
293
|
renderType: "dom",
|
|
@@ -296,7 +296,7 @@ function Yt(n, e, t, o, s) {
|
|
|
296
296
|
d,
|
|
297
297
|
() => {
|
|
298
298
|
},
|
|
299
|
-
|
|
299
|
+
o
|
|
300
300
|
);
|
|
301
301
|
if (u) {
|
|
302
302
|
if (c.appendChild(u.dom), u.contentDOM) {
|
|
@@ -314,8 +314,8 @@ function Yt(n, e, t, o, s) {
|
|
|
314
314
|
a.textContent
|
|
315
315
|
);
|
|
316
316
|
for (const d of a.marks.toReversed())
|
|
317
|
-
if (d.type.name in
|
|
318
|
-
const u =
|
|
317
|
+
if (d.type.name in o.schema.styleSpecs) {
|
|
318
|
+
const u = o.schema.styleSpecs[d.type.name].implementation.render(d.attrs.stringValue, o);
|
|
319
319
|
u.contentDOM.appendChild(l), l = u.dom;
|
|
320
320
|
} else {
|
|
321
321
|
const u = d.type.spec.toDOM(d, !0), p = he.renderSpec(document, u);
|
|
@@ -331,39 +331,39 @@ function Yt(n, e, t, o, s) {
|
|
|
331
331
|
}
|
|
332
332
|
return c;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function Qt(o, e, t, n) {
|
|
335
335
|
var u, p, m, f, k;
|
|
336
|
-
const s =
|
|
336
|
+
const s = o.pmSchema.nodes.blockContainer, r = e.props || {};
|
|
337
337
|
for (const [g, y] of Object.entries(
|
|
338
|
-
|
|
338
|
+
o.schema.blockSchema[e.type].propSchema
|
|
339
339
|
))
|
|
340
|
-
!(g in
|
|
341
|
-
const
|
|
340
|
+
!(g in r) && y.default !== void 0 && (r[g] = y.default);
|
|
341
|
+
const i = e.children || [], a = o.blockImplementations[e.type].implementation.render.call(
|
|
342
342
|
{
|
|
343
343
|
renderType: "dom",
|
|
344
344
|
props: void 0
|
|
345
345
|
},
|
|
346
|
-
{ ...e, props:
|
|
347
|
-
|
|
346
|
+
{ ...e, props: r, children: i },
|
|
347
|
+
o
|
|
348
348
|
);
|
|
349
349
|
if (a.contentDOM && e.content) {
|
|
350
350
|
const g = Yt(
|
|
351
|
-
|
|
351
|
+
o,
|
|
352
352
|
e.content,
|
|
353
353
|
// TODO
|
|
354
354
|
t,
|
|
355
355
|
e.type,
|
|
356
|
-
|
|
356
|
+
n
|
|
357
357
|
);
|
|
358
358
|
a.contentDOM.appendChild(g);
|
|
359
359
|
}
|
|
360
|
-
if (
|
|
360
|
+
if (o.pmSchema.nodes[e.type].isInGroup("bnBlock")) {
|
|
361
361
|
if (e.children && e.children.length > 0) {
|
|
362
362
|
const g = Be(
|
|
363
|
-
|
|
363
|
+
o,
|
|
364
364
|
e.children,
|
|
365
365
|
t,
|
|
366
|
-
|
|
366
|
+
n
|
|
367
367
|
);
|
|
368
368
|
(u = a.contentDOM) == null || u.append(g);
|
|
369
369
|
}
|
|
@@ -373,33 +373,33 @@ function qt(n, e, t, o) {
|
|
|
373
373
|
p,
|
|
374
374
|
s.create({
|
|
375
375
|
id: e.id,
|
|
376
|
-
...
|
|
376
|
+
...r
|
|
377
377
|
})
|
|
378
378
|
);
|
|
379
379
|
return (f = d.contentDOM) == null || f.appendChild(a.dom), e.children && e.children.length > 0 && ((k = d.contentDOM) == null || k.appendChild(
|
|
380
|
-
Ce(
|
|
380
|
+
Ce(o, e.children, t, n)
|
|
381
381
|
)), d.dom;
|
|
382
382
|
}
|
|
383
|
-
function Be(
|
|
384
|
-
const
|
|
385
|
-
for (const
|
|
386
|
-
const c =
|
|
387
|
-
|
|
383
|
+
function Be(o, e, t, n) {
|
|
384
|
+
const r = ((n == null ? void 0 : n.document) ?? document).createDocumentFragment();
|
|
385
|
+
for (const i of e) {
|
|
386
|
+
const c = Qt(o, i, t, n);
|
|
387
|
+
r.appendChild(c);
|
|
388
388
|
}
|
|
389
|
-
return
|
|
389
|
+
return r;
|
|
390
390
|
}
|
|
391
|
-
const Ce = (
|
|
391
|
+
const Ce = (o, e, t, n) => {
|
|
392
392
|
var c;
|
|
393
|
-
const s =
|
|
394
|
-
return (c =
|
|
395
|
-
},
|
|
396
|
-
const t = he.fromSchema(
|
|
393
|
+
const s = o.pmSchema.nodes.blockGroup, r = s.spec.toDOM(s.create({})), i = Be(o, e, t, n);
|
|
394
|
+
return (c = r.contentDOM) == null || c.appendChild(i), r.dom;
|
|
395
|
+
}, Xt = (o, e) => {
|
|
396
|
+
const t = he.fromSchema(o);
|
|
397
397
|
return {
|
|
398
|
-
serializeBlocks: (
|
|
398
|
+
serializeBlocks: (n, s) => Ce(e, n, t, s).outerHTML
|
|
399
399
|
};
|
|
400
400
|
};
|
|
401
|
-
function
|
|
402
|
-
return
|
|
401
|
+
function Zt(o) {
|
|
402
|
+
return o.transact((e) => {
|
|
403
403
|
const t = _(e.doc, e.selection.anchor);
|
|
404
404
|
if (e.selection instanceof te)
|
|
405
405
|
return {
|
|
@@ -414,127 +414,127 @@ function Xt(n) {
|
|
|
414
414
|
anchorBlockId: t.node.attrs.id
|
|
415
415
|
};
|
|
416
416
|
{
|
|
417
|
-
const
|
|
417
|
+
const n = _(e.doc, e.selection.head);
|
|
418
418
|
return {
|
|
419
419
|
type: "text",
|
|
420
420
|
anchorBlockId: t.node.attrs.id,
|
|
421
|
-
headBlockId:
|
|
421
|
+
headBlockId: n.node.attrs.id,
|
|
422
422
|
anchorOffset: e.selection.anchor - t.posBeforeNode,
|
|
423
|
-
headOffset: e.selection.head -
|
|
423
|
+
headOffset: e.selection.head - n.posBeforeNode
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
|
-
function
|
|
429
|
-
var s,
|
|
430
|
-
const t = (s =
|
|
428
|
+
function eo(o, e) {
|
|
429
|
+
var s, r;
|
|
430
|
+
const t = (s = x(e.anchorBlockId, o.doc)) == null ? void 0 : s.posBeforeNode;
|
|
431
431
|
if (t === void 0)
|
|
432
432
|
throw new Error(
|
|
433
433
|
`Could not find block with ID ${e.anchorBlockId} to update selection`
|
|
434
434
|
);
|
|
435
|
-
let
|
|
435
|
+
let n;
|
|
436
436
|
if (e.type === "cell")
|
|
437
|
-
|
|
438
|
-
|
|
437
|
+
n = te.create(
|
|
438
|
+
o.doc,
|
|
439
439
|
t + e.anchorCellOffset,
|
|
440
440
|
t + e.headCellOffset
|
|
441
441
|
);
|
|
442
442
|
else if (e.type === "node")
|
|
443
|
-
|
|
443
|
+
n = L.create(o.doc, t + 1);
|
|
444
444
|
else {
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
445
|
+
const i = (r = x(e.headBlockId, o.doc)) == null ? void 0 : r.posBeforeNode;
|
|
446
|
+
if (i === void 0)
|
|
447
447
|
throw new Error(
|
|
448
448
|
`Could not find block with ID ${e.headBlockId} to update selection`
|
|
449
449
|
);
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
n = M.create(
|
|
451
|
+
o.doc,
|
|
452
452
|
t + e.anchorOffset,
|
|
453
|
-
|
|
453
|
+
i + e.headOffset
|
|
454
454
|
);
|
|
455
455
|
}
|
|
456
|
-
|
|
456
|
+
o.setSelection(n);
|
|
457
457
|
}
|
|
458
|
-
function K(
|
|
459
|
-
return
|
|
458
|
+
function K(o) {
|
|
459
|
+
return o.map((e) => e.type === "columnList" ? e.children.map((t) => K(t.children)).flat() : {
|
|
460
460
|
...e,
|
|
461
461
|
children: K(e.children)
|
|
462
462
|
}).flat();
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
|
|
466
|
-
var
|
|
467
|
-
const s = ((
|
|
468
|
-
|
|
469
|
-
],
|
|
470
|
-
|
|
464
|
+
function xe(o, e, t) {
|
|
465
|
+
o.transact((n) => {
|
|
466
|
+
var i;
|
|
467
|
+
const s = ((i = o.getSelection()) == null ? void 0 : i.blocks) || [
|
|
468
|
+
o.getTextCursorPosition().block
|
|
469
|
+
], r = Zt(o);
|
|
470
|
+
o.removeBlocks(s), o.insertBlocks(K(s), e, t), eo(n, r);
|
|
471
471
|
});
|
|
472
472
|
}
|
|
473
|
-
function
|
|
474
|
-
return !
|
|
473
|
+
function Ee(o) {
|
|
474
|
+
return !o || o.type !== "columnList";
|
|
475
475
|
}
|
|
476
|
-
function Me(
|
|
477
|
-
let
|
|
478
|
-
if (e ? e.children.length > 0 ? (
|
|
476
|
+
function Me(o, e, t) {
|
|
477
|
+
let n, s;
|
|
478
|
+
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)
|
|
479
479
|
return;
|
|
480
|
-
const
|
|
481
|
-
return
|
|
482
|
-
|
|
483
|
-
s === "after" ?
|
|
484
|
-
|
|
480
|
+
const r = o.getParentBlock(n);
|
|
481
|
+
return Ee(r) ? { referenceBlock: n, placement: s } : Me(
|
|
482
|
+
o,
|
|
483
|
+
s === "after" ? n : o.getPrevBlock(n),
|
|
484
|
+
r
|
|
485
485
|
);
|
|
486
486
|
}
|
|
487
|
-
function we(
|
|
488
|
-
let
|
|
489
|
-
if (e ? e.children.length > 0 ? (
|
|
487
|
+
function we(o, e, t) {
|
|
488
|
+
let n, s;
|
|
489
|
+
if (e ? e.children.length > 0 ? (n = e.children[0], s = "before") : (n = e, s = "after") : t && (n = t, s = "after"), !n || !s)
|
|
490
490
|
return;
|
|
491
|
-
const
|
|
492
|
-
return
|
|
493
|
-
|
|
494
|
-
s === "before" ?
|
|
495
|
-
|
|
491
|
+
const r = o.getParentBlock(n);
|
|
492
|
+
return Ee(r) ? { referenceBlock: n, placement: s } : we(
|
|
493
|
+
o,
|
|
494
|
+
s === "before" ? n : o.getNextBlock(n),
|
|
495
|
+
r
|
|
496
496
|
);
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
|
|
500
|
-
const e =
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
498
|
+
function to(o) {
|
|
499
|
+
o.transact(() => {
|
|
500
|
+
const e = o.getSelection(), t = (e == null ? void 0 : e.blocks[0]) || o.getTextCursorPosition().block, n = Me(
|
|
501
|
+
o,
|
|
502
|
+
o.getPrevBlock(t),
|
|
503
|
+
o.getParentBlock(t)
|
|
504
504
|
);
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
505
|
+
n && xe(
|
|
506
|
+
o,
|
|
507
|
+
n.referenceBlock,
|
|
508
|
+
n.placement
|
|
509
509
|
);
|
|
510
510
|
});
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
const e =
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
512
|
+
function oo(o) {
|
|
513
|
+
o.transact(() => {
|
|
514
|
+
const e = o.getSelection(), t = (e == null ? void 0 : e.blocks[(e == null ? void 0 : e.blocks.length) - 1]) || o.getTextCursorPosition().block, n = we(
|
|
515
|
+
o,
|
|
516
|
+
o.getNextBlock(t),
|
|
517
|
+
o.getParentBlock(t)
|
|
518
518
|
);
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
519
|
+
n && xe(
|
|
520
|
+
o,
|
|
521
|
+
n.referenceBlock,
|
|
522
|
+
n.placement
|
|
523
523
|
);
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
|
-
function
|
|
527
|
-
const { $from:
|
|
526
|
+
function no(o, e, t) {
|
|
527
|
+
const { $from: n, $to: s } = o.selection, r = n.blockRange(
|
|
528
528
|
s,
|
|
529
529
|
(f) => f.childCount > 0 && (f.type.name === "blockGroup" || f.type.name === "column")
|
|
530
530
|
// change necessary to not look at first item child type
|
|
531
531
|
);
|
|
532
|
-
if (!
|
|
532
|
+
if (!r)
|
|
533
533
|
return !1;
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
534
|
+
const i = r.startIndex;
|
|
535
|
+
if (i === 0)
|
|
536
536
|
return !1;
|
|
537
|
-
const a =
|
|
537
|
+
const a = r.parent.child(i - 1);
|
|
538
538
|
if (a.type !== e)
|
|
539
539
|
return !1;
|
|
540
540
|
const l = a.lastChild && a.lastChild.type === t, d = A.from(l ? e.create() : null), u = new N(
|
|
@@ -544,8 +544,8 @@ function oo(n, e, t) {
|
|
|
544
544
|
),
|
|
545
545
|
l ? 3 : 1,
|
|
546
546
|
0
|
|
547
|
-
), p =
|
|
548
|
-
return
|
|
547
|
+
), p = r.start, m = r.end;
|
|
548
|
+
return o.step(
|
|
549
549
|
new V(
|
|
550
550
|
p - (l ? 3 : 1),
|
|
551
551
|
m,
|
|
@@ -557,60 +557,60 @@ function oo(n, e, t) {
|
|
|
557
557
|
)
|
|
558
558
|
).scrollIntoView(), !0;
|
|
559
559
|
}
|
|
560
|
-
function Te(
|
|
561
|
-
return
|
|
560
|
+
function Te(o) {
|
|
561
|
+
return o.transact((e) => no(
|
|
562
562
|
e,
|
|
563
|
-
|
|
564
|
-
|
|
563
|
+
o.pmSchema.nodes.blockContainer,
|
|
564
|
+
o.pmSchema.nodes.blockGroup
|
|
565
565
|
));
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
|
|
567
|
+
function so(o) {
|
|
568
|
+
o._tiptapEditor.commands.liftListItem("blockContainer");
|
|
569
569
|
}
|
|
570
|
-
function
|
|
571
|
-
return
|
|
572
|
-
const { bnBlock: t } =
|
|
570
|
+
function ro(o) {
|
|
571
|
+
return o.transact((e) => {
|
|
572
|
+
const { bnBlock: t } = $(e);
|
|
573
573
|
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
|
-
function
|
|
577
|
-
return
|
|
578
|
-
const { bnBlock: t } =
|
|
576
|
+
function io(o) {
|
|
577
|
+
return o.transact((e) => {
|
|
578
|
+
const { bnBlock: t } = $(e);
|
|
579
579
|
return e.doc.resolve(t.beforePos).depth > 1;
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
|
-
function
|
|
583
|
-
const t = typeof e == "string" ? e : e.id,
|
|
582
|
+
function ao(o, e) {
|
|
583
|
+
const t = typeof e == "string" ? e : e.id, n = C(o), s = x(t, o);
|
|
584
584
|
if (s)
|
|
585
|
-
return b(s.node,
|
|
585
|
+
return b(s.node, n);
|
|
586
586
|
}
|
|
587
|
-
function
|
|
588
|
-
const t = typeof e == "string" ? e : e.id,
|
|
589
|
-
if (!
|
|
587
|
+
function co(o, e) {
|
|
588
|
+
const t = typeof e == "string" ? e : e.id, n = x(t, o), s = C(o);
|
|
589
|
+
if (!n)
|
|
590
590
|
return;
|
|
591
|
-
const
|
|
592
|
-
if (
|
|
593
|
-
return b(
|
|
591
|
+
const i = o.resolve(n.posBeforeNode).nodeBefore;
|
|
592
|
+
if (i)
|
|
593
|
+
return b(i, s);
|
|
594
594
|
}
|
|
595
|
-
function
|
|
596
|
-
const t = typeof e == "string" ? e : e.id,
|
|
597
|
-
if (!
|
|
595
|
+
function lo(o, e) {
|
|
596
|
+
const t = typeof e == "string" ? e : e.id, n = x(t, o), s = C(o);
|
|
597
|
+
if (!n)
|
|
598
598
|
return;
|
|
599
|
-
const
|
|
600
|
-
|
|
599
|
+
const i = o.resolve(
|
|
600
|
+
n.posBeforeNode + n.node.nodeSize
|
|
601
601
|
).nodeAfter;
|
|
602
|
-
if (
|
|
603
|
-
return b(
|
|
602
|
+
if (i)
|
|
603
|
+
return b(i, s);
|
|
604
604
|
}
|
|
605
|
-
function
|
|
606
|
-
const t = typeof e == "string" ? e : e.id,
|
|
605
|
+
function uo(o, e) {
|
|
606
|
+
const t = typeof e == "string" ? e : e.id, n = C(o), s = x(t, o);
|
|
607
607
|
if (!s)
|
|
608
608
|
return;
|
|
609
|
-
const
|
|
609
|
+
const r = o.resolve(s.posBeforeNode), i = r.node(), c = r.node(-1), a = c.type.name !== "doc" ? i.type.name === "blockGroup" ? c : i : void 0;
|
|
610
610
|
if (a)
|
|
611
|
-
return b(a,
|
|
611
|
+
return b(a, n);
|
|
612
612
|
}
|
|
613
|
-
class
|
|
613
|
+
class po {
|
|
614
614
|
constructor(e) {
|
|
615
615
|
this.editor = e;
|
|
616
616
|
}
|
|
@@ -629,7 +629,7 @@ class uo {
|
|
|
629
629
|
* matching block was found.
|
|
630
630
|
*/
|
|
631
631
|
getBlock(e) {
|
|
632
|
-
return this.editor.transact((t) =>
|
|
632
|
+
return this.editor.transact((t) => ao(t.doc, e));
|
|
633
633
|
}
|
|
634
634
|
/**
|
|
635
635
|
* Gets a snapshot of the previous sibling of an existing block from the
|
|
@@ -641,7 +641,7 @@ class uo {
|
|
|
641
641
|
* in the document.
|
|
642
642
|
*/
|
|
643
643
|
getPrevBlock(e) {
|
|
644
|
-
return this.editor.transact((t) =>
|
|
644
|
+
return this.editor.transact((t) => co(t.doc, e));
|
|
645
645
|
}
|
|
646
646
|
/**
|
|
647
647
|
* Gets a snapshot of the next sibling of an existing block from the editor.
|
|
@@ -652,7 +652,7 @@ class uo {
|
|
|
652
652
|
* the document.
|
|
653
653
|
*/
|
|
654
654
|
getNextBlock(e) {
|
|
655
|
-
return this.editor.transact((t) =>
|
|
655
|
+
return this.editor.transact((t) => lo(t.doc, e));
|
|
656
656
|
}
|
|
657
657
|
/**
|
|
658
658
|
* Gets a snapshot of the parent of an existing block from the editor.
|
|
@@ -663,7 +663,7 @@ class uo {
|
|
|
663
663
|
*/
|
|
664
664
|
getParentBlock(e) {
|
|
665
665
|
return this.editor.transact(
|
|
666
|
-
(t) =>
|
|
666
|
+
(t) => uo(t.doc, e)
|
|
667
667
|
);
|
|
668
668
|
}
|
|
669
669
|
/**
|
|
@@ -672,19 +672,19 @@ class uo {
|
|
|
672
672
|
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
673
673
|
*/
|
|
674
674
|
forEachBlock(e, t = !1) {
|
|
675
|
-
const
|
|
676
|
-
t &&
|
|
677
|
-
function s(
|
|
678
|
-
for (const
|
|
679
|
-
if (e(
|
|
675
|
+
const n = this.document.slice();
|
|
676
|
+
t && n.reverse();
|
|
677
|
+
function s(r) {
|
|
678
|
+
for (const i of r) {
|
|
679
|
+
if (e(i) === !1)
|
|
680
680
|
return !1;
|
|
681
|
-
const c = t ?
|
|
681
|
+
const c = t ? i.children.slice().reverse() : i.children;
|
|
682
682
|
if (!s(c))
|
|
683
683
|
return !1;
|
|
684
684
|
}
|
|
685
685
|
return !0;
|
|
686
686
|
}
|
|
687
|
-
s(
|
|
687
|
+
s(n);
|
|
688
688
|
}
|
|
689
689
|
/**
|
|
690
690
|
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
@@ -694,9 +694,9 @@ class uo {
|
|
|
694
694
|
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
695
695
|
* `referenceBlock`.
|
|
696
696
|
*/
|
|
697
|
-
insertBlocks(e, t,
|
|
697
|
+
insertBlocks(e, t, n = "before") {
|
|
698
698
|
return this.editor.transact(
|
|
699
|
-
(s) =>
|
|
699
|
+
(s) => Jt(s, e, t, n)
|
|
700
700
|
);
|
|
701
701
|
}
|
|
702
702
|
/**
|
|
@@ -707,7 +707,7 @@ class uo {
|
|
|
707
707
|
* @param update A partial block which defines how the existing block should be changed.
|
|
708
708
|
*/
|
|
709
709
|
updateBlock(e, t) {
|
|
710
|
-
return this.editor.transact((
|
|
710
|
+
return this.editor.transact((n) => qe(n, e, t));
|
|
711
711
|
}
|
|
712
712
|
/**
|
|
713
713
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
@@ -727,14 +727,14 @@ class uo {
|
|
|
727
727
|
*/
|
|
728
728
|
replaceBlocks(e, t) {
|
|
729
729
|
return this.editor.transact(
|
|
730
|
-
(
|
|
730
|
+
(n) => ie(n, e, t)
|
|
731
731
|
);
|
|
732
732
|
}
|
|
733
733
|
/**
|
|
734
734
|
* Checks if the block containing the text cursor can be nested.
|
|
735
735
|
*/
|
|
736
736
|
canNestBlock() {
|
|
737
|
-
return
|
|
737
|
+
return ro(this.editor);
|
|
738
738
|
}
|
|
739
739
|
/**
|
|
740
740
|
* Nests the block containing the text cursor into the block above it.
|
|
@@ -746,13 +746,13 @@ class uo {
|
|
|
746
746
|
* Checks if the block containing the text cursor is nested.
|
|
747
747
|
*/
|
|
748
748
|
canUnnestBlock() {
|
|
749
|
-
return
|
|
749
|
+
return io(this.editor);
|
|
750
750
|
}
|
|
751
751
|
/**
|
|
752
752
|
* Lifts the block containing the text cursor out of its parent.
|
|
753
753
|
*/
|
|
754
754
|
unnestBlock() {
|
|
755
|
-
|
|
755
|
+
so(this.editor);
|
|
756
756
|
}
|
|
757
757
|
/**
|
|
758
758
|
* Moves the selected blocks up. If the previous block has children, moves
|
|
@@ -760,7 +760,7 @@ class uo {
|
|
|
760
760
|
* current blocks share a common parent, moves them out of & before it.
|
|
761
761
|
*/
|
|
762
762
|
moveBlocksUp() {
|
|
763
|
-
return
|
|
763
|
+
return to(this.editor);
|
|
764
764
|
}
|
|
765
765
|
/**
|
|
766
766
|
* Moves the selected blocks down. If the next block has children, moves
|
|
@@ -768,16 +768,16 @@ class uo {
|
|
|
768
768
|
* current blocks share a common parent, moves them out of & after it.
|
|
769
769
|
*/
|
|
770
770
|
moveBlocksDown() {
|
|
771
|
-
return
|
|
771
|
+
return oo(this.editor);
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
|
-
class
|
|
774
|
+
class fo extends Se {
|
|
775
775
|
constructor(e) {
|
|
776
776
|
super(), this.editor = e, e.on("create", () => {
|
|
777
777
|
e._tiptapEditor.on(
|
|
778
778
|
"update",
|
|
779
|
-
({ transaction: t, appendedTransactions:
|
|
780
|
-
this.emit("onChange", { editor: e, transaction: t, appendedTransactions:
|
|
779
|
+
({ transaction: t, appendedTransactions: n }) => {
|
|
780
|
+
this.emit("onChange", { editor: e, transaction: t, appendedTransactions: n });
|
|
781
781
|
}
|
|
782
782
|
), e._tiptapEditor.on("selectionUpdate", ({ transaction: t }) => {
|
|
783
783
|
this.emit("onSelectionChange", { editor: e, transaction: t });
|
|
@@ -792,32 +792,32 @@ class po extends Se {
|
|
|
792
792
|
* Register a callback that will be called when the editor changes.
|
|
793
793
|
*/
|
|
794
794
|
onChange(e, t = !0) {
|
|
795
|
-
const
|
|
795
|
+
const n = ({
|
|
796
796
|
transaction: s,
|
|
797
|
-
appendedTransactions:
|
|
797
|
+
appendedTransactions: r
|
|
798
798
|
}) => {
|
|
799
799
|
!t && ae(s) || e(this.editor, {
|
|
800
800
|
getChanges() {
|
|
801
801
|
return ot(
|
|
802
802
|
s,
|
|
803
|
-
|
|
803
|
+
r
|
|
804
804
|
);
|
|
805
805
|
}
|
|
806
806
|
});
|
|
807
807
|
};
|
|
808
|
-
return this.on("onChange",
|
|
809
|
-
this.off("onChange",
|
|
808
|
+
return this.on("onChange", n), () => {
|
|
809
|
+
this.off("onChange", n);
|
|
810
810
|
};
|
|
811
811
|
}
|
|
812
812
|
/**
|
|
813
813
|
* Register a callback that will be called when the selection changes.
|
|
814
814
|
*/
|
|
815
815
|
onSelectionChange(e, t = !1) {
|
|
816
|
-
const
|
|
816
|
+
const n = (s) => {
|
|
817
817
|
!t && ae(s.transaction) || e(this.editor);
|
|
818
818
|
};
|
|
819
|
-
return this.on("onSelectionChange",
|
|
820
|
-
this.off("onSelectionChange",
|
|
819
|
+
return this.on("onSelectionChange", n), () => {
|
|
820
|
+
this.off("onSelectionChange", n);
|
|
821
821
|
};
|
|
822
822
|
}
|
|
823
823
|
/**
|
|
@@ -837,108 +837,118 @@ class po extends Se {
|
|
|
837
837
|
};
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
function ae(
|
|
841
|
-
return !!
|
|
840
|
+
function ae(o) {
|
|
841
|
+
return !!o.getMeta("y-sync$");
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
return Array.prototype.indexOf.call(
|
|
843
|
+
function ho(o) {
|
|
844
|
+
return Array.prototype.indexOf.call(o.parentElement.childNodes, o);
|
|
845
845
|
}
|
|
846
|
-
function
|
|
847
|
-
return
|
|
846
|
+
function mo(o) {
|
|
847
|
+
return o.nodeType === 3 && !/\S/.test(o.nodeValue || "");
|
|
848
848
|
}
|
|
849
|
-
function
|
|
850
|
-
|
|
851
|
-
const t =
|
|
849
|
+
function ko(o) {
|
|
850
|
+
o.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
851
|
+
const t = ho(e), n = e.parentElement, s = Array.from(n.childNodes).slice(
|
|
852
852
|
t + 1
|
|
853
853
|
);
|
|
854
|
-
e.remove(), s.forEach((
|
|
855
|
-
|
|
856
|
-
}),
|
|
857
|
-
if (
|
|
854
|
+
e.remove(), s.forEach((r) => {
|
|
855
|
+
r.remove();
|
|
856
|
+
}), n.insertAdjacentElement("afterend", e), s.reverse().forEach((r) => {
|
|
857
|
+
if (mo(r))
|
|
858
858
|
return;
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
}),
|
|
859
|
+
const i = document.createElement("li");
|
|
860
|
+
i.append(r), e.insertAdjacentElement("afterend", i);
|
|
861
|
+
}), n.childNodes.length === 0 && n.remove();
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
|
-
function
|
|
865
|
-
|
|
866
|
-
var
|
|
867
|
-
const t = e.previousElementSibling,
|
|
868
|
-
t.insertAdjacentElement("afterend",
|
|
864
|
+
function go(o) {
|
|
865
|
+
o.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
866
|
+
var r, i;
|
|
867
|
+
const t = e.previousElementSibling, n = document.createElement("div");
|
|
868
|
+
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
869
869
|
const s = document.createElement("div");
|
|
870
|
-
for (s.setAttribute("data-node-type", "blockGroup"),
|
|
871
|
-
s.append(
|
|
870
|
+
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"; )
|
|
871
|
+
s.append(n.nextElementSibling);
|
|
872
872
|
});
|
|
873
873
|
}
|
|
874
874
|
let ce = null;
|
|
875
|
-
function
|
|
875
|
+
function bo() {
|
|
876
876
|
return ce || (ce = document.implementation.createHTMLDocument("title"));
|
|
877
877
|
}
|
|
878
|
-
function
|
|
879
|
-
if (typeof
|
|
880
|
-
const e =
|
|
881
|
-
e.innerHTML =
|
|
878
|
+
function yo(o) {
|
|
879
|
+
if (typeof o == "string") {
|
|
880
|
+
const e = bo().createElement("div");
|
|
881
|
+
e.innerHTML = o, o = e;
|
|
882
882
|
}
|
|
883
|
-
return
|
|
883
|
+
return ko(o), go(o), o;
|
|
884
884
|
}
|
|
885
|
-
function Pe(
|
|
886
|
-
const t =
|
|
885
|
+
function Pe(o, e) {
|
|
886
|
+
const t = yo(o), s = $e.fromSchema(e).parse(t, {
|
|
887
887
|
topNode: e.nodes.blockGroup.create()
|
|
888
|
-
}),
|
|
889
|
-
for (let
|
|
890
|
-
|
|
891
|
-
return
|
|
892
|
-
}
|
|
893
|
-
function
|
|
894
|
-
const t = e.value ? e.value : "",
|
|
895
|
-
e.lang && (
|
|
888
|
+
}), r = [];
|
|
889
|
+
for (let i = 0; i < s.childCount; i++)
|
|
890
|
+
r.push(b(s.child(i), e));
|
|
891
|
+
return r;
|
|
892
|
+
}
|
|
893
|
+
function So(o, e) {
|
|
894
|
+
const t = e.value ? e.value : "", n = {};
|
|
895
|
+
e.lang && (n["data-language"] = e.lang);
|
|
896
896
|
let s = {
|
|
897
897
|
type: "element",
|
|
898
898
|
tagName: "code",
|
|
899
|
-
properties:
|
|
899
|
+
properties: n,
|
|
900
900
|
children: [{ type: "text", value: t }]
|
|
901
901
|
};
|
|
902
|
-
return e.meta && (s.data = { meta: e.meta }),
|
|
902
|
+
return e.meta && (s.data = { meta: e.meta }), o.patch(e, s), s = o.applyData(e, s), s = {
|
|
903
903
|
type: "element",
|
|
904
904
|
tagName: "pre",
|
|
905
905
|
properties: {},
|
|
906
906
|
children: [s]
|
|
907
|
-
},
|
|
907
|
+
}, o.patch(e, s), s;
|
|
908
908
|
}
|
|
909
|
-
function
|
|
910
|
-
var
|
|
911
|
-
const t = String((e == null ? void 0 : e.url) || ""),
|
|
909
|
+
function Bo(o, e) {
|
|
910
|
+
var r;
|
|
911
|
+
const t = String((e == null ? void 0 : e.url) || ""), n = e != null && e.title ? String(e.title) : void 0;
|
|
912
912
|
let s = {
|
|
913
913
|
type: "element",
|
|
914
914
|
tagName: "video",
|
|
915
915
|
properties: {
|
|
916
916
|
src: t,
|
|
917
|
-
"data-name":
|
|
917
|
+
"data-name": n,
|
|
918
918
|
"data-url": t,
|
|
919
919
|
controls: !0
|
|
920
920
|
},
|
|
921
921
|
children: []
|
|
922
922
|
};
|
|
923
|
-
return (
|
|
923
|
+
return (r = o.patch) == null || r.call(o, e, s), s = o.applyData ? o.applyData(e, s) : s, s;
|
|
924
924
|
}
|
|
925
|
-
function ve(
|
|
926
|
-
return
|
|
925
|
+
function ve(o) {
|
|
926
|
+
return jt().use(zt).use(Ut).use(Gt, {
|
|
927
927
|
handlers: {
|
|
928
928
|
...re,
|
|
929
|
-
image: (t,
|
|
930
|
-
const s = String((
|
|
931
|
-
return
|
|
929
|
+
image: (t, n) => {
|
|
930
|
+
const s = String((n == null ? void 0 : n.url) || "");
|
|
931
|
+
return Ye(s) ? Bo(t, n) : re.image(t, n);
|
|
932
932
|
},
|
|
933
|
-
code:
|
|
933
|
+
code: So,
|
|
934
|
+
blockquote: (t, n) => {
|
|
935
|
+
const s = {
|
|
936
|
+
type: "element",
|
|
937
|
+
tagName: "blockquote",
|
|
938
|
+
properties: {},
|
|
939
|
+
// The only difference from the original is that we don't wrap the children with line endings
|
|
940
|
+
children: t.wrap(t.all(n), !1)
|
|
941
|
+
};
|
|
942
|
+
return t.patch(n, s), t.applyData(n, s);
|
|
943
|
+
}
|
|
934
944
|
}
|
|
935
|
-
}).use(
|
|
945
|
+
}).use(Rt).processSync(o).value;
|
|
936
946
|
}
|
|
937
|
-
function
|
|
938
|
-
const t = ve(
|
|
947
|
+
function Co(o, e) {
|
|
948
|
+
const t = ve(o);
|
|
939
949
|
return Pe(t, e);
|
|
940
950
|
}
|
|
941
|
-
class
|
|
951
|
+
class xo {
|
|
942
952
|
constructor(e) {
|
|
943
953
|
this.editor = e;
|
|
944
954
|
}
|
|
@@ -965,7 +975,7 @@ class Co {
|
|
|
965
975
|
* @returns The blocks, serialized as an HTML string.
|
|
966
976
|
*/
|
|
967
977
|
blocksToFullHTML(e = this.editor.document) {
|
|
968
|
-
return
|
|
978
|
+
return Xt(
|
|
969
979
|
this.editor.pmSchema,
|
|
970
980
|
this.editor
|
|
971
981
|
).serializeBlocks(e, {});
|
|
@@ -997,7 +1007,7 @@ class Co {
|
|
|
997
1007
|
* @returns The blocks parsed from the Markdown string.
|
|
998
1008
|
*/
|
|
999
1009
|
tryParseMarkdownToBlocks(e) {
|
|
1000
|
-
return
|
|
1010
|
+
return Co(e, this.editor.pmSchema);
|
|
1001
1011
|
}
|
|
1002
1012
|
/**
|
|
1003
1013
|
* Paste HTML into the editor. Defaults to converting HTML to BlockNote HTML.
|
|
@@ -1006,12 +1016,12 @@ class Co {
|
|
|
1006
1016
|
*/
|
|
1007
1017
|
pasteHTML(e, t = !1) {
|
|
1008
1018
|
var s;
|
|
1009
|
-
let
|
|
1019
|
+
let n = e;
|
|
1010
1020
|
if (!t) {
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1021
|
+
const r = this.tryParseHTMLToBlocks(e);
|
|
1022
|
+
n = this.blocksToFullHTML(r);
|
|
1013
1023
|
}
|
|
1014
|
-
|
|
1024
|
+
n && ((s = this.editor.prosemirrorView) == null || s.pasteHTML(n));
|
|
1015
1025
|
}
|
|
1016
1026
|
/**
|
|
1017
1027
|
* Paste text into the editor. Defaults to interpreting text as markdown.
|
|
@@ -1038,55 +1048,55 @@ const oe = [
|
|
|
1038
1048
|
"text/plain",
|
|
1039
1049
|
"Files"
|
|
1040
1050
|
];
|
|
1041
|
-
function Eo(
|
|
1042
|
-
if (!
|
|
1051
|
+
function Eo(o, e) {
|
|
1052
|
+
if (!o.startsWith(".") || !e.startsWith("."))
|
|
1043
1053
|
throw new Error("The strings provided are not valid file extensions.");
|
|
1044
|
-
return
|
|
1054
|
+
return o === e;
|
|
1045
1055
|
}
|
|
1046
|
-
function
|
|
1047
|
-
const t =
|
|
1056
|
+
function Mo(o, e) {
|
|
1057
|
+
const t = o.split("/"), n = e.split("/");
|
|
1048
1058
|
if (t.length !== 2)
|
|
1049
|
-
throw new Error(`The string ${
|
|
1050
|
-
if (
|
|
1059
|
+
throw new Error(`The string ${o} is not a valid MIME type.`);
|
|
1060
|
+
if (n.length !== 2)
|
|
1051
1061
|
throw new Error(`The string ${e} is not a valid MIME type.`);
|
|
1052
|
-
return t[1] === "*" ||
|
|
1062
|
+
return t[1] === "*" || n[1] === "*" ? t[0] === n[0] : (t[0] === "*" || n[0] === "*" || t[0] === n[0]) && t[1] === n[1];
|
|
1053
1063
|
}
|
|
1054
|
-
function le(
|
|
1064
|
+
function le(o, e, t, n = "after") {
|
|
1055
1065
|
let s;
|
|
1056
|
-
return Array.isArray(e.content) && e.content.length === 0 ? s =
|
|
1066
|
+
return Array.isArray(e.content) && e.content.length === 0 ? s = o.updateBlock(e, t).id : s = o.insertBlocks(
|
|
1057
1067
|
[t],
|
|
1058
1068
|
e,
|
|
1059
|
-
|
|
1069
|
+
n
|
|
1060
1070
|
)[0].id, s;
|
|
1061
1071
|
}
|
|
1062
|
-
async function Ie(
|
|
1063
|
-
var
|
|
1072
|
+
async function Ie(o, e) {
|
|
1073
|
+
var r;
|
|
1064
1074
|
if (!e.uploadFile) {
|
|
1065
1075
|
console.warn(
|
|
1066
1076
|
"Attempted ot insert file, but uploadFile is not set in the BlockNote editor options"
|
|
1067
1077
|
);
|
|
1068
1078
|
return;
|
|
1069
1079
|
}
|
|
1070
|
-
const t = "dataTransfer" in
|
|
1080
|
+
const t = "dataTransfer" in o ? o.dataTransfer : o.clipboardData;
|
|
1071
1081
|
if (t === null)
|
|
1072
1082
|
return;
|
|
1073
|
-
let
|
|
1074
|
-
for (const
|
|
1075
|
-
if (t.types.includes(
|
|
1076
|
-
|
|
1083
|
+
let n = null;
|
|
1084
|
+
for (const i of oe)
|
|
1085
|
+
if (t.types.includes(i)) {
|
|
1086
|
+
n = i;
|
|
1077
1087
|
break;
|
|
1078
1088
|
}
|
|
1079
|
-
if (
|
|
1089
|
+
if (n !== "Files")
|
|
1080
1090
|
return;
|
|
1081
1091
|
const s = t.items;
|
|
1082
1092
|
if (s) {
|
|
1083
|
-
|
|
1084
|
-
for (let
|
|
1093
|
+
o.preventDefault();
|
|
1094
|
+
for (let i = 0; i < s.length; i++) {
|
|
1085
1095
|
let c = "file";
|
|
1086
1096
|
for (const l of Object.values(e.schema.blockSpecs))
|
|
1087
|
-
for (const d of ((
|
|
1088
|
-
const u = d.startsWith("."), p = s[
|
|
1089
|
-
if (p && (!u && p.type &&
|
|
1097
|
+
for (const d of ((r = l.implementation.meta) == null ? void 0 : r.fileBlockAccept) || []) {
|
|
1098
|
+
const u = d.startsWith("."), p = s[i].getAsFile();
|
|
1099
|
+
if (p && (!u && p.type && Mo(s[i].type, d) || u && Eo(
|
|
1090
1100
|
"." + p.name.split(".").pop(),
|
|
1091
1101
|
d
|
|
1092
1102
|
))) {
|
|
@@ -1094,7 +1104,7 @@ async function Ie(n, e) {
|
|
|
1094
1104
|
break;
|
|
1095
1105
|
}
|
|
1096
1106
|
}
|
|
1097
|
-
const a = s[
|
|
1107
|
+
const a = s[i].getAsFile();
|
|
1098
1108
|
if (a) {
|
|
1099
1109
|
const l = {
|
|
1100
1110
|
type: c,
|
|
@@ -1103,13 +1113,13 @@ async function Ie(n, e) {
|
|
|
1103
1113
|
}
|
|
1104
1114
|
};
|
|
1105
1115
|
let d;
|
|
1106
|
-
if (
|
|
1116
|
+
if (o.type === "paste") {
|
|
1107
1117
|
const m = e.getTextCursorPosition().block;
|
|
1108
1118
|
d = le(e, m, l);
|
|
1109
|
-
} else if (
|
|
1119
|
+
} else if (o.type === "drop") {
|
|
1110
1120
|
const m = {
|
|
1111
|
-
left:
|
|
1112
|
-
top:
|
|
1121
|
+
left: o.clientX,
|
|
1122
|
+
top: o.clientY
|
|
1113
1123
|
}, f = e.prosemirrorView.posAtCoords(m);
|
|
1114
1124
|
if (!f)
|
|
1115
1125
|
return;
|
|
@@ -1137,7 +1147,7 @@ async function Ie(n, e) {
|
|
|
1137
1147
|
}
|
|
1138
1148
|
}
|
|
1139
1149
|
}
|
|
1140
|
-
const
|
|
1150
|
+
const wo = (o) => E.create({
|
|
1141
1151
|
name: "dropFile",
|
|
1142
1152
|
addProseMirrorPlugins() {
|
|
1143
1153
|
return [
|
|
@@ -1145,98 +1155,98 @@ const Mo = (n) => x.create({
|
|
|
1145
1155
|
props: {
|
|
1146
1156
|
handleDOMEvents: {
|
|
1147
1157
|
drop(e, t) {
|
|
1148
|
-
if (!
|
|
1158
|
+
if (!o.isEditable)
|
|
1149
1159
|
return;
|
|
1150
|
-
let
|
|
1160
|
+
let n = null;
|
|
1151
1161
|
for (const s of oe)
|
|
1152
1162
|
if (t.dataTransfer.types.includes(s)) {
|
|
1153
|
-
|
|
1163
|
+
n = s;
|
|
1154
1164
|
break;
|
|
1155
1165
|
}
|
|
1156
|
-
return
|
|
1166
|
+
return n === null ? !0 : n === "Files" ? (Ie(t, o), !0) : !1;
|
|
1157
1167
|
}
|
|
1158
1168
|
}
|
|
1159
1169
|
}
|
|
1160
1170
|
})
|
|
1161
1171
|
];
|
|
1162
1172
|
}
|
|
1163
|
-
}),
|
|
1164
|
-
async function
|
|
1173
|
+
}), To = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, Po = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, vo = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, Io = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, Ao = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, _o = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, Do = /\n{2} {0,3}-{2,48}\n{2}/, Lo = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, No = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, Oo = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, Fo = /^\s*\|(.+\|)+\s*$/m, $o = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, Ho = /^\s*\|(.+\|)+\s*$/m, Vo = (o) => To.test(o) || Po.test(o) || vo.test(o) || Io.test(o) || Ao.test(o) || _o.test(o) || Do.test(o) || Lo.test(o) || No.test(o) || Oo.test(o) || Fo.test(o) || $o.test(o) || Ho.test(o);
|
|
1174
|
+
async function Uo(o, e) {
|
|
1165
1175
|
const { schema: t } = e.state;
|
|
1166
|
-
if (!
|
|
1176
|
+
if (!o.clipboardData)
|
|
1167
1177
|
return !1;
|
|
1168
|
-
const
|
|
1169
|
-
if (!
|
|
1178
|
+
const n = o.clipboardData.getData("text/plain");
|
|
1179
|
+
if (!n)
|
|
1170
1180
|
return !1;
|
|
1171
1181
|
if (!t.nodes.codeBlock)
|
|
1172
|
-
return e.pasteText(
|
|
1173
|
-
const s =
|
|
1174
|
-
return
|
|
1175
|
-
`<pre><code class="language-${
|
|
1182
|
+
return e.pasteText(n), !0;
|
|
1183
|
+
const s = o.clipboardData.getData("vscode-editor-data"), r = s ? JSON.parse(s) : void 0, i = r == null ? void 0 : r.mode;
|
|
1184
|
+
return i ? (e.pasteHTML(
|
|
1185
|
+
`<pre><code class="language-${i}">${n.replace(
|
|
1176
1186
|
/\r\n?/g,
|
|
1177
1187
|
`
|
|
1178
1188
|
`
|
|
1179
1189
|
)}</code></pre>`
|
|
1180
1190
|
), !0) : !1;
|
|
1181
1191
|
}
|
|
1182
|
-
function
|
|
1183
|
-
event:
|
|
1192
|
+
function zo({
|
|
1193
|
+
event: o,
|
|
1184
1194
|
editor: e,
|
|
1185
1195
|
prioritizeMarkdownOverHTML: t,
|
|
1186
|
-
plainTextAsMarkdown:
|
|
1196
|
+
plainTextAsMarkdown: n
|
|
1187
1197
|
}) {
|
|
1188
1198
|
var c;
|
|
1189
1199
|
if (e.transact(
|
|
1190
1200
|
(a) => a.selection.$from.parent.type.spec.code && a.selection.$to.parent.type.spec.code
|
|
1191
1201
|
)) {
|
|
1192
|
-
const a = (c =
|
|
1202
|
+
const a = (c = o.clipboardData) == null ? void 0 : c.getData("text/plain");
|
|
1193
1203
|
if (a)
|
|
1194
1204
|
return e.pasteText(a), !0;
|
|
1195
1205
|
}
|
|
1196
|
-
let
|
|
1206
|
+
let r;
|
|
1197
1207
|
for (const a of oe)
|
|
1198
|
-
if (
|
|
1199
|
-
|
|
1208
|
+
if (o.clipboardData.types.includes(a)) {
|
|
1209
|
+
r = a;
|
|
1200
1210
|
break;
|
|
1201
1211
|
}
|
|
1202
|
-
if (!
|
|
1212
|
+
if (!r)
|
|
1203
1213
|
return !0;
|
|
1204
|
-
if (
|
|
1205
|
-
return
|
|
1206
|
-
if (
|
|
1207
|
-
return Ie(
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1210
|
-
return e.pasteHTML(
|
|
1211
|
-
if (
|
|
1212
|
-
return e.pasteMarkdown(
|
|
1214
|
+
if (r === "vscode-editor-data")
|
|
1215
|
+
return Uo(o, e.prosemirrorView), !0;
|
|
1216
|
+
if (r === "Files")
|
|
1217
|
+
return Ie(o, e), !0;
|
|
1218
|
+
const i = o.clipboardData.getData(r);
|
|
1219
|
+
if (r === "blocknote/html")
|
|
1220
|
+
return e.pasteHTML(i, !0), !0;
|
|
1221
|
+
if (r === "text/markdown")
|
|
1222
|
+
return e.pasteMarkdown(i), !0;
|
|
1213
1223
|
if (t) {
|
|
1214
|
-
const a =
|
|
1215
|
-
if (
|
|
1224
|
+
const a = o.clipboardData.getData("text/plain");
|
|
1225
|
+
if (Vo(a))
|
|
1216
1226
|
return e.pasteMarkdown(a), !0;
|
|
1217
1227
|
}
|
|
1218
|
-
return
|
|
1228
|
+
return r === "text/html" ? (e.pasteHTML(i), !0) : n ? (e.pasteMarkdown(i), !0) : (e.pasteText(i), !0);
|
|
1219
1229
|
}
|
|
1220
|
-
const
|
|
1230
|
+
const Go = (o, e) => E.create({
|
|
1221
1231
|
name: "pasteFromClipboard",
|
|
1222
1232
|
addProseMirrorPlugins() {
|
|
1223
1233
|
return [
|
|
1224
1234
|
new ee({
|
|
1225
1235
|
props: {
|
|
1226
1236
|
handleDOMEvents: {
|
|
1227
|
-
paste(t,
|
|
1228
|
-
if (
|
|
1237
|
+
paste(t, n) {
|
|
1238
|
+
if (n.preventDefault(), !!o.isEditable)
|
|
1229
1239
|
return e({
|
|
1230
|
-
event:
|
|
1231
|
-
editor:
|
|
1240
|
+
event: n,
|
|
1241
|
+
editor: o,
|
|
1232
1242
|
defaultPasteHandler: ({
|
|
1233
1243
|
prioritizeMarkdownOverHTML: s = !0,
|
|
1234
|
-
plainTextAsMarkdown:
|
|
1235
|
-
} = {}) =>
|
|
1236
|
-
event:
|
|
1237
|
-
editor:
|
|
1244
|
+
plainTextAsMarkdown: r = !0
|
|
1245
|
+
} = {}) => zo({
|
|
1246
|
+
event: n,
|
|
1247
|
+
editor: o,
|
|
1238
1248
|
prioritizeMarkdownOverHTML: s,
|
|
1239
|
-
plainTextAsMarkdown:
|
|
1249
|
+
plainTextAsMarkdown: r
|
|
1240
1250
|
})
|
|
1241
1251
|
});
|
|
1242
1252
|
}
|
|
@@ -1246,25 +1256,25 @@ const zo = (n, e) => x.create({
|
|
|
1246
1256
|
];
|
|
1247
1257
|
}
|
|
1248
1258
|
});
|
|
1249
|
-
function
|
|
1259
|
+
function Ro(o, e, t) {
|
|
1250
1260
|
var c;
|
|
1251
|
-
let
|
|
1252
|
-
const s =
|
|
1261
|
+
let n = !1;
|
|
1262
|
+
const s = o.state.selection instanceof te;
|
|
1253
1263
|
if (!s) {
|
|
1254
|
-
const a =
|
|
1255
|
-
|
|
1256
|
-
|
|
1264
|
+
const a = o.state.doc.slice(
|
|
1265
|
+
o.state.selection.from,
|
|
1266
|
+
o.state.selection.to,
|
|
1257
1267
|
!1
|
|
1258
1268
|
).content, l = [];
|
|
1259
1269
|
for (let d = 0; d < a.childCount; d++)
|
|
1260
1270
|
l.push(a.child(d));
|
|
1261
|
-
|
|
1271
|
+
n = l.find(
|
|
1262
1272
|
(d) => d.type.isInGroup("bnBlock") || d.type.name === "blockGroup" || d.type.spec.group === "blockContent"
|
|
1263
|
-
) === void 0,
|
|
1273
|
+
) === void 0, n && (e = a);
|
|
1264
1274
|
}
|
|
1265
|
-
let
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1275
|
+
let r;
|
|
1276
|
+
const i = be(
|
|
1277
|
+
o.state.schema,
|
|
1268
1278
|
t
|
|
1269
1279
|
);
|
|
1270
1280
|
if (s) {
|
|
@@ -1274,57 +1284,57 @@ function Go(n, e, t) {
|
|
|
1274
1284
|
t.schema.inlineContentSchema,
|
|
1275
1285
|
t.schema.styleSchema
|
|
1276
1286
|
);
|
|
1277
|
-
|
|
1287
|
+
r = `<table>${i.exportInlineContent(
|
|
1278
1288
|
a,
|
|
1279
1289
|
{}
|
|
1280
1290
|
)}</table>`;
|
|
1281
|
-
} else if (
|
|
1291
|
+
} else if (n) {
|
|
1282
1292
|
const a = Re(
|
|
1283
1293
|
e,
|
|
1284
1294
|
t.schema.inlineContentSchema,
|
|
1285
1295
|
t.schema.styleSchema
|
|
1286
1296
|
);
|
|
1287
|
-
|
|
1297
|
+
r = i.exportInlineContent(a, {});
|
|
1288
1298
|
} else {
|
|
1289
1299
|
const a = rt(e);
|
|
1290
|
-
|
|
1300
|
+
r = i.exportBlocks(a, {});
|
|
1291
1301
|
}
|
|
1292
|
-
return
|
|
1302
|
+
return r;
|
|
1293
1303
|
}
|
|
1294
|
-
function Ae(
|
|
1295
|
-
"node" in
|
|
1296
|
-
(
|
|
1297
|
-
new L(
|
|
1304
|
+
function Ae(o, e) {
|
|
1305
|
+
"node" in o.state.selection && o.state.selection.node.type.spec.group === "blockContent" && e.transact(
|
|
1306
|
+
(i) => i.setSelection(
|
|
1307
|
+
new L(i.doc.resolve(o.state.selection.from - 1))
|
|
1298
1308
|
)
|
|
1299
1309
|
);
|
|
1300
|
-
const t =
|
|
1301
|
-
|
|
1302
|
-
).dom.innerHTML,
|
|
1303
|
-
n,
|
|
1310
|
+
const t = o.serializeForClipboard(
|
|
1311
|
+
o.state.selection.content()
|
|
1312
|
+
).dom.innerHTML, n = o.state.selection.content().content, s = Ro(
|
|
1304
1313
|
o,
|
|
1314
|
+
n,
|
|
1305
1315
|
e
|
|
1306
|
-
),
|
|
1307
|
-
return { clipboardHTML: t, externalHTML: s, markdown:
|
|
1316
|
+
), r = st(s);
|
|
1317
|
+
return { clipboardHTML: t, externalHTML: s, markdown: r };
|
|
1308
1318
|
}
|
|
1309
1319
|
const de = () => {
|
|
1310
|
-
const
|
|
1311
|
-
if (!
|
|
1320
|
+
const o = window.getSelection();
|
|
1321
|
+
if (!o || o.isCollapsed)
|
|
1312
1322
|
return !0;
|
|
1313
|
-
let e =
|
|
1323
|
+
let e = o.focusNode;
|
|
1314
1324
|
for (; e; ) {
|
|
1315
1325
|
if (e instanceof HTMLElement && e.getAttribute("contenteditable") === "false")
|
|
1316
1326
|
return !0;
|
|
1317
1327
|
e = e.parentElement;
|
|
1318
1328
|
}
|
|
1319
1329
|
return !1;
|
|
1320
|
-
}, ue = (
|
|
1330
|
+
}, ue = (o, e, t) => {
|
|
1321
1331
|
t.preventDefault(), t.clipboardData.clearData();
|
|
1322
|
-
const { clipboardHTML:
|
|
1332
|
+
const { clipboardHTML: n, externalHTML: s, markdown: r } = Ae(
|
|
1323
1333
|
e,
|
|
1324
|
-
|
|
1334
|
+
o
|
|
1325
1335
|
);
|
|
1326
|
-
t.clipboardData.setData("blocknote/html",
|
|
1327
|
-
},
|
|
1336
|
+
t.clipboardData.setData("blocknote/html", n), t.clipboardData.setData("text/html", s), t.clipboardData.setData("text/plain", r);
|
|
1337
|
+
}, jo = (o) => E.create({
|
|
1328
1338
|
name: "copyToClipboard",
|
|
1329
1339
|
addProseMirrorPlugins() {
|
|
1330
1340
|
return [
|
|
@@ -1332,10 +1342,10 @@ const de = () => {
|
|
|
1332
1342
|
props: {
|
|
1333
1343
|
handleDOMEvents: {
|
|
1334
1344
|
copy(e, t) {
|
|
1335
|
-
return de() || ue(
|
|
1345
|
+
return de() || ue(o, e, t), !0;
|
|
1336
1346
|
},
|
|
1337
1347
|
cut(e, t) {
|
|
1338
|
-
return de() || (ue(
|
|
1348
|
+
return de() || (ue(o, e, t), e.editable && e.dispatch(e.state.tr.deleteSelection())), !0;
|
|
1339
1349
|
},
|
|
1340
1350
|
// This is for the use-case in which only a block without content
|
|
1341
1351
|
// is selected, e.g. an image block, and dragged (not using the
|
|
@@ -1343,22 +1353,22 @@ const de = () => {
|
|
|
1343
1353
|
dragstart(e, t) {
|
|
1344
1354
|
if (!("node" in e.state.selection) || e.state.selection.node.type.spec.group !== "blockContent")
|
|
1345
1355
|
return;
|
|
1346
|
-
|
|
1347
|
-
(
|
|
1356
|
+
o.transact(
|
|
1357
|
+
(i) => i.setSelection(
|
|
1348
1358
|
new L(
|
|
1349
|
-
|
|
1359
|
+
i.doc.resolve(e.state.selection.from - 1)
|
|
1350
1360
|
)
|
|
1351
1361
|
)
|
|
1352
1362
|
), t.preventDefault(), t.dataTransfer.clearData();
|
|
1353
|
-
const { clipboardHTML:
|
|
1354
|
-
return t.dataTransfer.setData("blocknote/html",
|
|
1363
|
+
const { clipboardHTML: n, externalHTML: s, markdown: r } = Ae(e, o);
|
|
1364
|
+
return t.dataTransfer.setData("blocknote/html", n), t.dataTransfer.setData("text/html", s), t.dataTransfer.setData("text/plain", r), !0;
|
|
1355
1365
|
}
|
|
1356
1366
|
}
|
|
1357
1367
|
}
|
|
1358
1368
|
})
|
|
1359
1369
|
];
|
|
1360
1370
|
}
|
|
1361
|
-
}),
|
|
1371
|
+
}), Wo = E.create({
|
|
1362
1372
|
name: "blockBackgroundColor",
|
|
1363
1373
|
addGlobalAttributes() {
|
|
1364
1374
|
return [
|
|
@@ -1370,7 +1380,7 @@ const de = () => {
|
|
|
1370
1380
|
}
|
|
1371
1381
|
];
|
|
1372
1382
|
}
|
|
1373
|
-
}),
|
|
1383
|
+
}), Ko = D.create({
|
|
1374
1384
|
name: "hardBreak",
|
|
1375
1385
|
inline: !0,
|
|
1376
1386
|
group: "inline",
|
|
@@ -1380,151 +1390,151 @@ const de = () => {
|
|
|
1380
1390
|
parseHTML() {
|
|
1381
1391
|
return [{ tag: "br" }];
|
|
1382
1392
|
},
|
|
1383
|
-
renderHTML({ HTMLAttributes:
|
|
1384
|
-
return ["br",
|
|
1393
|
+
renderHTML({ HTMLAttributes: o }) {
|
|
1394
|
+
return ["br", Et(this.options.HTMLAttributes, o)];
|
|
1385
1395
|
},
|
|
1386
1396
|
renderText() {
|
|
1387
1397
|
return `
|
|
1388
1398
|
`;
|
|
1389
1399
|
}
|
|
1390
|
-
}), J = (
|
|
1391
|
-
const t =
|
|
1392
|
-
if (
|
|
1400
|
+
}), J = (o, e) => {
|
|
1401
|
+
const t = o.resolve(e), n = t.index();
|
|
1402
|
+
if (n === 0)
|
|
1393
1403
|
return;
|
|
1394
|
-
const s = t.posAtIndex(
|
|
1395
|
-
return
|
|
1396
|
-
|
|
1404
|
+
const s = t.posAtIndex(n - 1);
|
|
1405
|
+
return Y(
|
|
1406
|
+
o.resolve(s)
|
|
1397
1407
|
);
|
|
1398
|
-
}, _e = (
|
|
1408
|
+
}, _e = (o, e) => {
|
|
1399
1409
|
for (; e.childContainer; ) {
|
|
1400
|
-
const t = e.childContainer.node,
|
|
1401
|
-
e =
|
|
1410
|
+
const t = e.childContainer.node, n = o.resolve(e.childContainer.beforePos + 1).posAtIndex(t.childCount - 1);
|
|
1411
|
+
e = Y(o.resolve(n));
|
|
1402
1412
|
}
|
|
1403
1413
|
return e;
|
|
1404
|
-
},
|
|
1405
|
-
if (!
|
|
1414
|
+
}, Jo = (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*", qo = (o, e, t, n) => {
|
|
1415
|
+
if (!n.isBlockContainer)
|
|
1406
1416
|
throw new Error(
|
|
1407
|
-
`Attempted to merge block at position ${
|
|
1417
|
+
`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`
|
|
1408
1418
|
);
|
|
1409
|
-
if (
|
|
1410
|
-
const s =
|
|
1411
|
-
|
|
1412
|
-
),
|
|
1413
|
-
|
|
1414
|
-
),
|
|
1419
|
+
if (n.childContainer) {
|
|
1420
|
+
const s = o.doc.resolve(
|
|
1421
|
+
n.childContainer.beforePos + 1
|
|
1422
|
+
), r = o.doc.resolve(
|
|
1423
|
+
n.childContainer.afterPos - 1
|
|
1424
|
+
), i = s.blockRange(r);
|
|
1415
1425
|
if (e) {
|
|
1416
|
-
const c =
|
|
1417
|
-
|
|
1426
|
+
const c = o.doc.resolve(n.bnBlock.beforePos);
|
|
1427
|
+
o.tr.lift(i, c.depth);
|
|
1418
1428
|
}
|
|
1419
1429
|
}
|
|
1420
1430
|
if (e) {
|
|
1421
1431
|
if (!t.isBlockContainer)
|
|
1422
1432
|
throw new Error(
|
|
1423
|
-
`Attempted to merge block at position ${
|
|
1433
|
+
`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`
|
|
1424
1434
|
);
|
|
1425
1435
|
e(
|
|
1426
|
-
|
|
1436
|
+
o.tr.delete(
|
|
1427
1437
|
t.blockContent.afterPos - 1,
|
|
1428
|
-
|
|
1438
|
+
n.blockContent.beforePos + 1
|
|
1429
1439
|
)
|
|
1430
1440
|
);
|
|
1431
1441
|
}
|
|
1432
1442
|
return !0;
|
|
1433
|
-
}, pe = (
|
|
1443
|
+
}, pe = (o) => ({
|
|
1434
1444
|
state: e,
|
|
1435
1445
|
dispatch: t
|
|
1436
1446
|
}) => {
|
|
1437
|
-
const
|
|
1447
|
+
const n = e.doc.resolve(o), s = Y(n), r = J(
|
|
1438
1448
|
e.doc,
|
|
1439
1449
|
s.bnBlock.beforePos
|
|
1440
1450
|
);
|
|
1441
|
-
if (!
|
|
1451
|
+
if (!r)
|
|
1442
1452
|
return !1;
|
|
1443
|
-
const
|
|
1453
|
+
const i = _e(
|
|
1444
1454
|
e.doc,
|
|
1445
|
-
|
|
1455
|
+
r
|
|
1446
1456
|
);
|
|
1447
|
-
return
|
|
1448
|
-
}, Yo =
|
|
1457
|
+
return Jo(i, s) ? qo(e, t, i, s) : !1;
|
|
1458
|
+
}, Yo = E.create({
|
|
1449
1459
|
priority: 50,
|
|
1450
1460
|
// TODO: The shortcuts need a refactor. Do we want to use a command priority
|
|
1451
1461
|
// design as there is now, or clump the logic into a single function?
|
|
1452
1462
|
addKeyboardShortcuts() {
|
|
1453
|
-
const
|
|
1463
|
+
const o = () => this.editor.commands.first(({ chain: n, commands: s }) => [
|
|
1454
1464
|
// Deletes the selection if it's not empty.
|
|
1455
1465
|
() => s.deleteSelection(),
|
|
1456
1466
|
// Undoes an input rule if one was triggered in the last editor state change.
|
|
1457
1467
|
() => s.undoInputRule(),
|
|
1458
1468
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
1459
|
-
() => s.command(({ state:
|
|
1460
|
-
const
|
|
1461
|
-
if (!
|
|
1469
|
+
() => s.command(({ state: r }) => {
|
|
1470
|
+
const i = B(r);
|
|
1471
|
+
if (!i.isBlockContainer)
|
|
1462
1472
|
return !1;
|
|
1463
|
-
const c =
|
|
1473
|
+
const c = r.selection.from === i.blockContent.beforePos + 1, a = i.blockContent.node.type.name === "paragraph";
|
|
1464
1474
|
return c && !a ? s.command(
|
|
1465
|
-
Ze(
|
|
1475
|
+
Ze(i.bnBlock.beforePos, {
|
|
1466
1476
|
type: "paragraph",
|
|
1467
1477
|
props: {}
|
|
1468
1478
|
})
|
|
1469
1479
|
) : !1;
|
|
1470
1480
|
}),
|
|
1471
1481
|
// Removes a level of nesting if the block is indented if the selection is at the start of the block.
|
|
1472
|
-
() => s.command(({ state:
|
|
1473
|
-
const
|
|
1474
|
-
if (!
|
|
1482
|
+
() => s.command(({ state: r }) => {
|
|
1483
|
+
const i = B(r);
|
|
1484
|
+
if (!i.isBlockContainer)
|
|
1475
1485
|
return !1;
|
|
1476
|
-
const { blockContent: c } =
|
|
1477
|
-
return
|
|
1486
|
+
const { blockContent: c } = i;
|
|
1487
|
+
return r.selection.from === c.beforePos + 1 ? s.liftListItem("blockContainer") : !1;
|
|
1478
1488
|
}),
|
|
1479
1489
|
// Merges block with the previous one if it isn't indented, and the selection is at the start of the
|
|
1480
1490
|
// block. The target block for merging must contain inline content.
|
|
1481
|
-
() => s.command(({ state:
|
|
1482
|
-
const
|
|
1483
|
-
if (!
|
|
1491
|
+
() => s.command(({ state: r }) => {
|
|
1492
|
+
const i = B(r);
|
|
1493
|
+
if (!i.isBlockContainer)
|
|
1484
1494
|
return !1;
|
|
1485
|
-
const { bnBlock: c, blockContent: a } =
|
|
1486
|
-
return l && d ?
|
|
1495
|
+
const { bnBlock: c, blockContent: a } = i, l = r.selection.from === a.beforePos + 1, d = r.selection.empty, u = c.beforePos;
|
|
1496
|
+
return l && d ? n().command(pe(u)).scrollIntoView().run() : !1;
|
|
1487
1497
|
}),
|
|
1488
|
-
() => s.command(({ state:
|
|
1489
|
-
const a = B(
|
|
1490
|
-
if (!a.isBlockContainer || !(
|
|
1498
|
+
() => s.command(({ state: r, tr: i, dispatch: c }) => {
|
|
1499
|
+
const a = B(r);
|
|
1500
|
+
if (!a.isBlockContainer || !(i.selection.from === a.blockContent.beforePos + 1))
|
|
1491
1501
|
return !1;
|
|
1492
|
-
const d =
|
|
1502
|
+
const d = i.doc.resolve(a.bnBlock.beforePos);
|
|
1493
1503
|
if (d.nodeBefore || d.node().type.name !== "column")
|
|
1494
1504
|
return !1;
|
|
1495
|
-
const m =
|
|
1505
|
+
const m = i.doc.resolve(a.bnBlock.beforePos), f = i.doc.resolve(m.before()), k = f.before();
|
|
1496
1506
|
if (c) {
|
|
1497
|
-
const g =
|
|
1507
|
+
const g = i.doc.slice(
|
|
1498
1508
|
a.bnBlock.beforePos,
|
|
1499
1509
|
a.bnBlock.afterPos
|
|
1500
1510
|
).content;
|
|
1501
|
-
|
|
1511
|
+
i.delete(
|
|
1502
1512
|
a.bnBlock.beforePos,
|
|
1503
1513
|
a.bnBlock.afterPos
|
|
1504
|
-
), f.index() === 0 ? (W(
|
|
1505
|
-
M.near(
|
|
1506
|
-
)) : (
|
|
1507
|
-
M.near(
|
|
1508
|
-
), W(
|
|
1514
|
+
), f.index() === 0 ? (W(i, k), i.insert(k, g), i.setSelection(
|
|
1515
|
+
M.near(i.doc.resolve(k))
|
|
1516
|
+
)) : (i.insert(f.pos - 1, g), i.setSelection(
|
|
1517
|
+
M.near(i.doc.resolve(f.pos - 1))
|
|
1518
|
+
), W(i, k));
|
|
1509
1519
|
}
|
|
1510
1520
|
return !0;
|
|
1511
1521
|
}),
|
|
1512
1522
|
// Deletes the current block if it's an empty block with inline content,
|
|
1513
1523
|
// and moves the selection to the previous block.
|
|
1514
|
-
() => s.command(({ state:
|
|
1515
|
-
const
|
|
1516
|
-
if (!
|
|
1524
|
+
() => s.command(({ state: r }) => {
|
|
1525
|
+
const i = B(r);
|
|
1526
|
+
if (!i.isBlockContainer)
|
|
1517
1527
|
return !1;
|
|
1518
|
-
if (
|
|
1528
|
+
if (i.blockContent.node.childCount === 0 && i.blockContent.node.type.spec.content === "inline*") {
|
|
1519
1529
|
const a = J(
|
|
1520
|
-
|
|
1521
|
-
|
|
1530
|
+
r.doc,
|
|
1531
|
+
i.bnBlock.beforePos
|
|
1522
1532
|
);
|
|
1523
1533
|
if (!a || !a.isBlockContainer)
|
|
1524
1534
|
return !1;
|
|
1525
|
-
let l =
|
|
1535
|
+
let l = n();
|
|
1526
1536
|
if (a.blockContent.node.type.spec.content === "tableRow+") {
|
|
1527
|
-
const f =
|
|
1537
|
+
const f = i.bnBlock.beforePos - 1 - 1 - 1 - 1 - 1;
|
|
1528
1538
|
l = l.setTextSelection(
|
|
1529
1539
|
f
|
|
1530
1540
|
);
|
|
@@ -1538,8 +1548,8 @@ const de = () => {
|
|
|
1538
1548
|
l = l.setTextSelection(d);
|
|
1539
1549
|
}
|
|
1540
1550
|
return l.deleteRange({
|
|
1541
|
-
from:
|
|
1542
|
-
to:
|
|
1551
|
+
from: i.bnBlock.beforePos,
|
|
1552
|
+
to: i.bnBlock.afterPos
|
|
1543
1553
|
}).scrollIntoView().run();
|
|
1544
1554
|
}
|
|
1545
1555
|
return !1;
|
|
@@ -1547,26 +1557,26 @@ const de = () => {
|
|
|
1547
1557
|
// Deletes previous block if it contains no content and isn't a table,
|
|
1548
1558
|
// when the selection is empty and at the start of the block. Moves the
|
|
1549
1559
|
// current block into the deleted block's place.
|
|
1550
|
-
() => s.command(({ state:
|
|
1551
|
-
const
|
|
1552
|
-
if (!
|
|
1560
|
+
() => s.command(({ state: r }) => {
|
|
1561
|
+
const i = B(r);
|
|
1562
|
+
if (!i.isBlockContainer)
|
|
1553
1563
|
throw new Error("todo");
|
|
1554
|
-
const c =
|
|
1555
|
-
|
|
1556
|
-
|
|
1564
|
+
const c = r.selection.from === i.blockContent.beforePos + 1, a = r.selection.empty, l = J(
|
|
1565
|
+
r.doc,
|
|
1566
|
+
i.bnBlock.beforePos
|
|
1557
1567
|
);
|
|
1558
1568
|
if (l && c && a) {
|
|
1559
1569
|
const d = _e(
|
|
1560
|
-
|
|
1570
|
+
r.doc,
|
|
1561
1571
|
l
|
|
1562
1572
|
);
|
|
1563
1573
|
if (!d.isBlockContainer)
|
|
1564
1574
|
throw new Error("todo");
|
|
1565
1575
|
if (d.blockContent.node.type.spec.content === "" || d.blockContent.node.type.spec.content === "inline*" && d.blockContent.node.childCount === 0)
|
|
1566
|
-
return
|
|
1576
|
+
return n().cut(
|
|
1567
1577
|
{
|
|
1568
|
-
from:
|
|
1569
|
-
to:
|
|
1578
|
+
from: i.bnBlock.beforePos,
|
|
1579
|
+
to: i.bnBlock.afterPos
|
|
1570
1580
|
},
|
|
1571
1581
|
d.bnBlock.afterPos
|
|
1572
1582
|
).deleteRange({
|
|
@@ -1576,77 +1586,77 @@ const de = () => {
|
|
|
1576
1586
|
}
|
|
1577
1587
|
return !1;
|
|
1578
1588
|
})
|
|
1579
|
-
]), e = () => this.editor.commands.first(({ commands:
|
|
1589
|
+
]), e = () => this.editor.commands.first(({ commands: n }) => [
|
|
1580
1590
|
// Deletes the selection if it's not empty.
|
|
1581
|
-
() =>
|
|
1591
|
+
() => n.deleteSelection(),
|
|
1582
1592
|
// Merges block with the next one (at the same nesting level or lower),
|
|
1583
1593
|
// if one exists, the block has no children, and the selection is at the
|
|
1584
1594
|
// end of the block.
|
|
1585
|
-
() =>
|
|
1586
|
-
const
|
|
1587
|
-
if (!
|
|
1595
|
+
() => n.command(({ state: s }) => {
|
|
1596
|
+
const r = B(s);
|
|
1597
|
+
if (!r.isBlockContainer)
|
|
1588
1598
|
return !1;
|
|
1589
1599
|
const {
|
|
1590
|
-
bnBlock:
|
|
1600
|
+
bnBlock: i,
|
|
1591
1601
|
blockContent: c,
|
|
1592
1602
|
childContainer: a
|
|
1593
|
-
} =
|
|
1603
|
+
} = r, { depth: l } = s.doc.resolve(i.beforePos), d = i.afterPos === s.doc.nodeSize - 3, u = s.selection.from === c.afterPos - 1, p = s.selection.empty;
|
|
1594
1604
|
if (!d && u && p && !(a !== void 0)) {
|
|
1595
|
-
let f = l, k =
|
|
1605
|
+
let f = l, k = i.afterPos + 1, g = s.doc.resolve(k).depth;
|
|
1596
1606
|
for (; g < f; )
|
|
1597
1607
|
f = g, k += 2, g = s.doc.resolve(k).depth;
|
|
1598
|
-
return
|
|
1608
|
+
return n.command(pe(k - 1));
|
|
1599
1609
|
}
|
|
1600
1610
|
return !1;
|
|
1601
1611
|
})
|
|
1602
|
-
]), t = (
|
|
1612
|
+
]), t = (n = !1) => this.editor.commands.first(({ commands: s, tr: r }) => [
|
|
1603
1613
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
1604
1614
|
// of the block.
|
|
1605
|
-
() => s.command(({ state:
|
|
1606
|
-
const c = B(
|
|
1615
|
+
() => s.command(({ state: i }) => {
|
|
1616
|
+
const c = B(i);
|
|
1607
1617
|
if (!c.isBlockContainer)
|
|
1608
1618
|
return !1;
|
|
1609
|
-
const { bnBlock: a, blockContent: l } = c, { depth: d } =
|
|
1619
|
+
const { bnBlock: a, blockContent: l } = c, { depth: d } = i.doc.resolve(a.beforePos), u = i.selection.$anchor.parentOffset === 0, p = i.selection.anchor === i.selection.head, m = l.node.childCount === 0, f = d > 1;
|
|
1610
1620
|
return u && p && m && f ? s.liftListItem("blockContainer") : !1;
|
|
1611
1621
|
}),
|
|
1612
1622
|
// Creates a hard break if block is configured to do so.
|
|
1613
|
-
() => s.command(({ state:
|
|
1623
|
+
() => s.command(({ state: i }) => {
|
|
1614
1624
|
var l;
|
|
1615
|
-
const c = B(
|
|
1625
|
+
const c = B(i), a = ((l = this.options.editor.schema.blockSchema[c.blockNoteType].meta) == null ? void 0 : l.hardBreakShortcut) ?? "shift+enter";
|
|
1616
1626
|
if (a === "none")
|
|
1617
1627
|
return !1;
|
|
1618
1628
|
if (
|
|
1619
1629
|
// If shortcut is not configured, or is configured as "shift+enter",
|
|
1620
1630
|
// create a hard break for shift+enter, but not for enter.
|
|
1621
|
-
a === "shift+enter" &&
|
|
1631
|
+
a === "shift+enter" && n || // If shortcut is configured as "enter", create a hard break for
|
|
1622
1632
|
// both enter and shift+enter.
|
|
1623
1633
|
a === "enter"
|
|
1624
1634
|
) {
|
|
1625
|
-
const d =
|
|
1635
|
+
const d = r.storedMarks || r.selection.$head.marks().filter(
|
|
1626
1636
|
(u) => this.editor.extensionManager.splittableMarks.includes(
|
|
1627
1637
|
u.type.name
|
|
1628
1638
|
)
|
|
1629
1639
|
);
|
|
1630
|
-
return
|
|
1631
|
-
|
|
1632
|
-
|
|
1640
|
+
return r.insert(
|
|
1641
|
+
r.selection.head,
|
|
1642
|
+
r.doc.type.schema.nodes.hardBreak.create()
|
|
1633
1643
|
).ensureMarks(d), !0;
|
|
1634
1644
|
}
|
|
1635
1645
|
return !1;
|
|
1636
1646
|
}),
|
|
1637
1647
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1638
1648
|
// empty & at the start of the block.
|
|
1639
|
-
() => s.command(({ state:
|
|
1640
|
-
const a = B(
|
|
1649
|
+
() => s.command(({ state: i, dispatch: c }) => {
|
|
1650
|
+
const a = B(i);
|
|
1641
1651
|
if (!a.isBlockContainer)
|
|
1642
1652
|
return !1;
|
|
1643
|
-
const { bnBlock: l, blockContent: d } = a, u =
|
|
1653
|
+
const { bnBlock: l, blockContent: d } = a, u = i.selection.$anchor.parentOffset === 0, p = i.selection.anchor === i.selection.head, m = d.node.childCount === 0;
|
|
1644
1654
|
if (u && p && m) {
|
|
1645
1655
|
const f = l.afterPos, k = f + 2;
|
|
1646
1656
|
if (c) {
|
|
1647
|
-
const g =
|
|
1648
|
-
|
|
1649
|
-
new M(
|
|
1657
|
+
const g = i.schema.nodes.blockContainer.createAndFill();
|
|
1658
|
+
i.tr.insert(f, g).scrollIntoView(), i.tr.setSelection(
|
|
1659
|
+
new M(i.doc.resolve(k))
|
|
1650
1660
|
);
|
|
1651
1661
|
}
|
|
1652
1662
|
return !0;
|
|
@@ -1655,14 +1665,14 @@ const de = () => {
|
|
|
1655
1665
|
}),
|
|
1656
1666
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
1657
1667
|
// deletes the selection beforehand, if it's not empty.
|
|
1658
|
-
() => s.command(({ state:
|
|
1659
|
-
const a = B(
|
|
1668
|
+
() => s.command(({ state: i, chain: c }) => {
|
|
1669
|
+
const a = B(i);
|
|
1660
1670
|
if (!a.isBlockContainer)
|
|
1661
1671
|
return !1;
|
|
1662
|
-
const { blockContent: l } = a, d =
|
|
1672
|
+
const { blockContent: l } = a, d = i.selection.$anchor.parentOffset === 0;
|
|
1663
1673
|
return l.node.childCount === 0 ? !1 : (c().deleteSelection().command(
|
|
1664
1674
|
Xe(
|
|
1665
|
-
|
|
1675
|
+
i.selection.from,
|
|
1666
1676
|
d,
|
|
1667
1677
|
d
|
|
1668
1678
|
)
|
|
@@ -1670,19 +1680,19 @@ const de = () => {
|
|
|
1670
1680
|
})
|
|
1671
1681
|
]);
|
|
1672
1682
|
return {
|
|
1673
|
-
Backspace:
|
|
1683
|
+
Backspace: o,
|
|
1674
1684
|
Delete: e,
|
|
1675
1685
|
Enter: () => t(),
|
|
1676
1686
|
"Shift-Enter": () => t(!0),
|
|
1677
1687
|
// Always returning true for tab key presses ensures they're not captured by the browser. Otherwise, they blur the
|
|
1678
1688
|
// editor since the browser will try to use tab for keyboard navigation.
|
|
1679
1689
|
Tab: () => {
|
|
1680
|
-
var
|
|
1681
|
-
return this.options.tabBehavior !== "prefer-indent" && ((
|
|
1690
|
+
var n, s;
|
|
1691
|
+
return this.options.tabBehavior !== "prefer-indent" && ((n = this.options.editor.getExtension(R)) != null && n.store.state || ((s = this.options.editor.getExtension(G)) == null ? void 0 : s.store.state) !== void 0) ? !1 : Te(this.options.editor);
|
|
1682
1692
|
},
|
|
1683
1693
|
"Shift-Tab": () => {
|
|
1684
|
-
var
|
|
1685
|
-
return this.options.tabBehavior !== "prefer-indent" && ((
|
|
1694
|
+
var n, s;
|
|
1695
|
+
return this.options.tabBehavior !== "prefer-indent" && ((n = this.options.editor.getExtension(R)) != null && n.store.state || ((s = this.options.editor.getExtension(G)) == null ? void 0 : s.store.state) !== void 0) ? !1 : this.editor.commands.liftListItem("blockContainer");
|
|
1686
1696
|
},
|
|
1687
1697
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1688
1698
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
@@ -1691,7 +1701,7 @@ const de = () => {
|
|
|
1691
1701
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1692
1702
|
};
|
|
1693
1703
|
}
|
|
1694
|
-
}),
|
|
1704
|
+
}), Qo = X.create({
|
|
1695
1705
|
name: "insertion",
|
|
1696
1706
|
inclusive: !1,
|
|
1697
1707
|
excludes: "deletion modification insertion",
|
|
@@ -1701,8 +1711,8 @@ const de = () => {
|
|
|
1701
1711
|
// note: validate is supported in prosemirror but not in tiptap, so this doesn't actually work (considered not critical)
|
|
1702
1712
|
};
|
|
1703
1713
|
},
|
|
1704
|
-
extendMarkSchema(
|
|
1705
|
-
return
|
|
1714
|
+
extendMarkSchema(o) {
|
|
1715
|
+
return o.name !== "insertion" ? {} : {
|
|
1706
1716
|
blocknoteIgnore: !0,
|
|
1707
1717
|
inclusive: !1,
|
|
1708
1718
|
toDOM(e, t) {
|
|
@@ -1729,7 +1739,7 @@ const de = () => {
|
|
|
1729
1739
|
]
|
|
1730
1740
|
};
|
|
1731
1741
|
}
|
|
1732
|
-
}),
|
|
1742
|
+
}), Xo = X.create({
|
|
1733
1743
|
name: "deletion",
|
|
1734
1744
|
inclusive: !1,
|
|
1735
1745
|
excludes: "insertion modification deletion",
|
|
@@ -1739,8 +1749,8 @@ const de = () => {
|
|
|
1739
1749
|
// note: validate is supported in prosemirror but not in tiptap
|
|
1740
1750
|
};
|
|
1741
1751
|
},
|
|
1742
|
-
extendMarkSchema(
|
|
1743
|
-
return
|
|
1752
|
+
extendMarkSchema(o) {
|
|
1753
|
+
return o.name !== "deletion" ? {} : {
|
|
1744
1754
|
blocknoteIgnore: !0,
|
|
1745
1755
|
inclusive: !1,
|
|
1746
1756
|
// attrs: {
|
|
@@ -1770,7 +1780,7 @@ const de = () => {
|
|
|
1770
1780
|
]
|
|
1771
1781
|
};
|
|
1772
1782
|
}
|
|
1773
|
-
}),
|
|
1783
|
+
}), Zo = X.create({
|
|
1774
1784
|
name: "modification",
|
|
1775
1785
|
inclusive: !1,
|
|
1776
1786
|
excludes: "deletion insertion",
|
|
@@ -1783,8 +1793,8 @@ const de = () => {
|
|
|
1783
1793
|
newValue: { default: null }
|
|
1784
1794
|
};
|
|
1785
1795
|
},
|
|
1786
|
-
extendMarkSchema(
|
|
1787
|
-
return
|
|
1796
|
+
extendMarkSchema(o) {
|
|
1797
|
+
return o.name !== "modification" ? {} : {
|
|
1788
1798
|
blocknoteIgnore: !0,
|
|
1789
1799
|
inclusive: !1,
|
|
1790
1800
|
// attrs: {
|
|
@@ -1833,7 +1843,7 @@ const de = () => {
|
|
|
1833
1843
|
]
|
|
1834
1844
|
};
|
|
1835
1845
|
}
|
|
1836
|
-
}),
|
|
1846
|
+
}), en = E.create({
|
|
1837
1847
|
name: "textAlignment",
|
|
1838
1848
|
addGlobalAttributes() {
|
|
1839
1849
|
return [
|
|
@@ -1846,16 +1856,16 @@ const de = () => {
|
|
|
1846
1856
|
attributes: {
|
|
1847
1857
|
textAlignment: {
|
|
1848
1858
|
default: "left",
|
|
1849
|
-
parseHTML: (
|
|
1850
|
-
renderHTML: (
|
|
1851
|
-
"data-text-alignment":
|
|
1859
|
+
parseHTML: (o) => o.getAttribute("data-text-alignment"),
|
|
1860
|
+
renderHTML: (o) => o.textAlignment === "left" ? {} : {
|
|
1861
|
+
"data-text-alignment": o.textAlignment
|
|
1852
1862
|
}
|
|
1853
1863
|
}
|
|
1854
1864
|
}
|
|
1855
1865
|
}
|
|
1856
1866
|
];
|
|
1857
1867
|
}
|
|
1858
|
-
}),
|
|
1868
|
+
}), tn = E.create({
|
|
1859
1869
|
name: "blockTextColor",
|
|
1860
1870
|
addGlobalAttributes() {
|
|
1861
1871
|
return [
|
|
@@ -1867,13 +1877,13 @@ const de = () => {
|
|
|
1867
1877
|
}
|
|
1868
1878
|
];
|
|
1869
1879
|
}
|
|
1870
|
-
}),
|
|
1880
|
+
}), on = {
|
|
1871
1881
|
blockColor: "data-block-color",
|
|
1872
1882
|
blockStyle: "data-block-style",
|
|
1873
1883
|
id: "data-id",
|
|
1874
1884
|
depth: "data-depth",
|
|
1875
1885
|
depthChange: "data-depth-change"
|
|
1876
|
-
},
|
|
1886
|
+
}, nn = D.create({
|
|
1877
1887
|
name: "blockContainer",
|
|
1878
1888
|
group: "blockGroupChild bnBlock",
|
|
1879
1889
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -1886,12 +1896,12 @@ const de = () => {
|
|
|
1886
1896
|
return [
|
|
1887
1897
|
{
|
|
1888
1898
|
tag: "div[data-node-type=" + this.name + "]",
|
|
1889
|
-
getAttrs: (
|
|
1890
|
-
if (typeof
|
|
1899
|
+
getAttrs: (o) => {
|
|
1900
|
+
if (typeof o == "string")
|
|
1891
1901
|
return !1;
|
|
1892
1902
|
const e = {};
|
|
1893
|
-
for (const [t,
|
|
1894
|
-
|
|
1903
|
+
for (const [t, n] of Object.entries(on))
|
|
1904
|
+
o.getAttribute(n) && (e[t] = o.getAttribute(n));
|
|
1895
1905
|
return e;
|
|
1896
1906
|
}
|
|
1897
1907
|
},
|
|
@@ -1902,25 +1912,25 @@ const de = () => {
|
|
|
1902
1912
|
}
|
|
1903
1913
|
];
|
|
1904
1914
|
},
|
|
1905
|
-
renderHTML({ HTMLAttributes:
|
|
1915
|
+
renderHTML({ HTMLAttributes: o }) {
|
|
1906
1916
|
var s;
|
|
1907
1917
|
const e = document.createElement("div");
|
|
1908
1918
|
e.className = "bn-block-outer", e.setAttribute("data-node-type", "blockOuter");
|
|
1909
|
-
for (const [
|
|
1910
|
-
|
|
1919
|
+
for (const [r, i] of Object.entries(o))
|
|
1920
|
+
r !== "class" && e.setAttribute(r, i);
|
|
1911
1921
|
const t = {
|
|
1912
1922
|
...((s = this.options.domAttributes) == null ? void 0 : s.block) || {},
|
|
1913
|
-
...
|
|
1914
|
-
},
|
|
1915
|
-
|
|
1916
|
-
for (const [
|
|
1917
|
-
|
|
1918
|
-
return e.appendChild(
|
|
1923
|
+
...o
|
|
1924
|
+
}, n = document.createElement("div");
|
|
1925
|
+
n.className = Q("bn-block", t.class), n.setAttribute("data-node-type", this.name);
|
|
1926
|
+
for (const [r, i] of Object.entries(t))
|
|
1927
|
+
r !== "class" && n.setAttribute(r, i);
|
|
1928
|
+
return e.appendChild(n), {
|
|
1919
1929
|
dom: e,
|
|
1920
|
-
contentDOM:
|
|
1930
|
+
contentDOM: n
|
|
1921
1931
|
};
|
|
1922
1932
|
}
|
|
1923
|
-
}),
|
|
1933
|
+
}), sn = D.create({
|
|
1924
1934
|
name: "blockGroup",
|
|
1925
1935
|
group: "childContainer",
|
|
1926
1936
|
content: "blockGroupChild+",
|
|
@@ -1929,128 +1939,138 @@ const de = () => {
|
|
|
1929
1939
|
return [
|
|
1930
1940
|
{
|
|
1931
1941
|
tag: "div",
|
|
1932
|
-
getAttrs: (
|
|
1942
|
+
getAttrs: (o) => typeof o == "string" ? !1 : o.getAttribute("data-node-type") === "blockGroup" ? null : !1
|
|
1933
1943
|
}
|
|
1934
1944
|
];
|
|
1935
1945
|
},
|
|
1936
|
-
renderHTML({ HTMLAttributes:
|
|
1937
|
-
var
|
|
1946
|
+
renderHTML({ HTMLAttributes: o }) {
|
|
1947
|
+
var n;
|
|
1938
1948
|
const e = {
|
|
1939
|
-
...((
|
|
1940
|
-
...
|
|
1949
|
+
...((n = this.options.domAttributes) == null ? void 0 : n.blockGroup) || {},
|
|
1950
|
+
...o
|
|
1941
1951
|
}, t = document.createElement("div");
|
|
1942
1952
|
t.className = Q(
|
|
1943
1953
|
"bn-block-group",
|
|
1944
1954
|
e.class
|
|
1945
1955
|
), t.setAttribute("data-node-type", "blockGroup");
|
|
1946
|
-
for (const [s,
|
|
1947
|
-
s !== "class" && t.setAttribute(s,
|
|
1956
|
+
for (const [s, r] of Object.entries(e))
|
|
1957
|
+
s !== "class" && t.setAttribute(s, r);
|
|
1948
1958
|
return {
|
|
1949
1959
|
dom: t,
|
|
1950
1960
|
contentDOM: t
|
|
1951
1961
|
};
|
|
1952
1962
|
}
|
|
1953
|
-
}),
|
|
1963
|
+
}), rn = D.create({
|
|
1954
1964
|
name: "doc",
|
|
1955
1965
|
topNode: !0,
|
|
1956
1966
|
content: "blockGroup",
|
|
1957
1967
|
marks: "insertion modification deletion"
|
|
1958
|
-
})
|
|
1968
|
+
}), an = Nt(
|
|
1969
|
+
({ options: o }) => ({
|
|
1970
|
+
key: "collaboration",
|
|
1971
|
+
blockNoteExtensions: [
|
|
1972
|
+
it(o),
|
|
1973
|
+
at(o),
|
|
1974
|
+
ct(o),
|
|
1975
|
+
lt(),
|
|
1976
|
+
dt(o)
|
|
1977
|
+
]
|
|
1978
|
+
})
|
|
1979
|
+
);
|
|
1959
1980
|
let fe = !1;
|
|
1960
|
-
function
|
|
1981
|
+
function cn(o, e) {
|
|
1961
1982
|
const t = [
|
|
1962
1983
|
I.ClipboardTextSerializer,
|
|
1963
1984
|
I.Commands,
|
|
1964
1985
|
I.Editable,
|
|
1965
1986
|
I.FocusEvents,
|
|
1966
1987
|
I.Tabindex,
|
|
1967
|
-
|
|
1988
|
+
Ft,
|
|
1968
1989
|
me.configure({
|
|
1969
1990
|
// everything from bnBlock group (nodes that represent a BlockNote block should have an id)
|
|
1970
1991
|
types: ["blockContainer", "columnList", "column"],
|
|
1971
1992
|
setIdAttribute: e.setIdAttribute
|
|
1972
1993
|
}),
|
|
1973
|
-
|
|
1994
|
+
Ko,
|
|
1974
1995
|
Ht,
|
|
1975
1996
|
// marks:
|
|
1976
|
-
qo,
|
|
1977
1997
|
Qo,
|
|
1978
1998
|
Xo,
|
|
1979
|
-
|
|
1999
|
+
Zo,
|
|
2000
|
+
$t.extend({
|
|
1980
2001
|
inclusive: !1
|
|
1981
2002
|
}).configure({
|
|
1982
2003
|
defaultProtocol: Bt,
|
|
1983
2004
|
// only call this once if we have multiple editors installed. Or fix https://github.com/ueberdosis/tiptap/issues/5450
|
|
1984
2005
|
protocols: fe ? [] : St
|
|
1985
2006
|
}),
|
|
1986
|
-
...Object.values(
|
|
1987
|
-
editor:
|
|
2007
|
+
...Object.values(o.schema.styleSpecs).map((n) => n.implementation.mark.configure({
|
|
2008
|
+
editor: o
|
|
1988
2009
|
})),
|
|
2010
|
+
tn,
|
|
2011
|
+
Wo,
|
|
1989
2012
|
en,
|
|
1990
|
-
jo,
|
|
1991
|
-
Zo,
|
|
1992
2013
|
// make sure escape blurs editor, so that we can tab to other elements in the host page (accessibility)
|
|
1993
|
-
|
|
2014
|
+
E.create({
|
|
1994
2015
|
name: "OverrideEscape",
|
|
1995
2016
|
addKeyboardShortcuts: () => ({
|
|
1996
2017
|
Escape: () => {
|
|
1997
|
-
var
|
|
1998
|
-
return (
|
|
2018
|
+
var n;
|
|
2019
|
+
return (n = o.getExtension(ge)) != null && n.shown() ? !1 : (o.blur(), !0);
|
|
1999
2020
|
}
|
|
2000
2021
|
})
|
|
2001
2022
|
}),
|
|
2002
2023
|
// nodes
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
editor:
|
|
2024
|
+
rn,
|
|
2025
|
+
nn.configure({
|
|
2026
|
+
editor: o,
|
|
2006
2027
|
domAttributes: e.domAttributes
|
|
2007
2028
|
}),
|
|
2008
2029
|
Yo.configure({
|
|
2009
|
-
editor:
|
|
2030
|
+
editor: o,
|
|
2010
2031
|
tabBehavior: e.tabBehavior
|
|
2011
2032
|
}),
|
|
2012
|
-
|
|
2033
|
+
sn.configure({
|
|
2013
2034
|
domAttributes: e.domAttributes
|
|
2014
2035
|
}),
|
|
2015
|
-
...Object.values(
|
|
2016
|
-
editor:
|
|
2036
|
+
...Object.values(o.schema.inlineContentSpecs).filter((n) => n.config !== "link" && n.config !== "text").map((n) => n.implementation.node.configure({
|
|
2037
|
+
editor: o
|
|
2017
2038
|
})),
|
|
2018
|
-
...Object.values(
|
|
2039
|
+
...Object.values(o.schema.blockSpecs).flatMap((n) => [
|
|
2019
2040
|
// the node extension implementations
|
|
2020
|
-
..."node" in
|
|
2021
|
-
|
|
2022
|
-
editor:
|
|
2041
|
+
..."node" in n.implementation ? [
|
|
2042
|
+
n.implementation.node.configure({
|
|
2043
|
+
editor: o,
|
|
2023
2044
|
domAttributes: e.domAttributes
|
|
2024
2045
|
})
|
|
2025
2046
|
] : []
|
|
2026
2047
|
]),
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
e.pasteHandler || ((
|
|
2048
|
+
jo(o),
|
|
2049
|
+
Go(
|
|
2050
|
+
o,
|
|
2051
|
+
e.pasteHandler || ((n) => n.defaultPasteHandler())
|
|
2031
2052
|
),
|
|
2032
|
-
|
|
2053
|
+
wo(o)
|
|
2033
2054
|
];
|
|
2034
2055
|
return fe = !0, t;
|
|
2035
2056
|
}
|
|
2036
|
-
function
|
|
2037
|
-
var o;
|
|
2057
|
+
function ln(o, e) {
|
|
2038
2058
|
const t = [
|
|
2039
2059
|
ye(),
|
|
2040
|
-
|
|
2060
|
+
ut(e),
|
|
2041
2061
|
G(e),
|
|
2042
2062
|
R(e),
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2063
|
+
pt(e),
|
|
2064
|
+
ft(),
|
|
2065
|
+
ht(e),
|
|
2066
|
+
Vt(e),
|
|
2067
|
+
mt(e),
|
|
2048
2068
|
ge(e),
|
|
2049
|
-
...e.trailingBlock !== !1 ? [
|
|
2069
|
+
...e.trailingBlock !== !1 ? [kt()] : []
|
|
2050
2070
|
];
|
|
2051
|
-
return e.collaboration ?
|
|
2071
|
+
return e.collaboration ? t.push(an(e.collaboration)) : t.push(gt()), "table" in o.schema.blockSpecs && t.push(bt(e)), e.animations !== !1 && t.push(yt()), t;
|
|
2052
2072
|
}
|
|
2053
|
-
class
|
|
2073
|
+
class dn {
|
|
2054
2074
|
constructor(e, t) {
|
|
2055
2075
|
/**
|
|
2056
2076
|
* A set of extension keys which are disabled by the options
|
|
@@ -2074,27 +2094,27 @@ class cn {
|
|
|
2074
2094
|
*/
|
|
2075
2095
|
h(this, "extensionPlugins", /* @__PURE__ */ new Map());
|
|
2076
2096
|
this.editor = e, this.options = t, e.onMount(() => {
|
|
2077
|
-
for (const
|
|
2078
|
-
if (
|
|
2079
|
-
const s = new window.AbortController(),
|
|
2097
|
+
for (const n of this.extensions)
|
|
2098
|
+
if (n.mount) {
|
|
2099
|
+
const s = new window.AbortController(), r = n.mount({
|
|
2080
2100
|
dom: e.prosemirrorView.dom,
|
|
2081
2101
|
root: e.prosemirrorView.root,
|
|
2082
2102
|
signal: s.signal
|
|
2083
2103
|
});
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
}), this.abortMap.set(
|
|
2104
|
+
r && s.signal.addEventListener("abort", () => {
|
|
2105
|
+
r();
|
|
2106
|
+
}), this.abortMap.set(n, s);
|
|
2087
2107
|
}
|
|
2088
2108
|
}), e.onUnmount(() => {
|
|
2089
|
-
for (const [
|
|
2090
|
-
this.abortMap.delete(
|
|
2109
|
+
for (const [n, s] of this.abortMap.entries())
|
|
2110
|
+
this.abortMap.delete(n), s.abort();
|
|
2091
2111
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
2092
|
-
for (const
|
|
2093
|
-
this.addExtension(
|
|
2094
|
-
for (const
|
|
2095
|
-
this.addExtension(
|
|
2096
|
-
for (const
|
|
2097
|
-
for (const s of
|
|
2112
|
+
for (const n of ln(this.editor, this.options))
|
|
2113
|
+
this.addExtension(n);
|
|
2114
|
+
for (const n of this.options.extensions ?? [])
|
|
2115
|
+
this.addExtension(n);
|
|
2116
|
+
for (const n of Object.values(this.editor.schema.blockSpecs))
|
|
2117
|
+
for (const s of n.extensions ?? [])
|
|
2098
2118
|
this.addExtension(s);
|
|
2099
2119
|
}
|
|
2100
2120
|
/**
|
|
@@ -2103,26 +2123,26 @@ class cn {
|
|
|
2103
2123
|
* This allows users to switch on & off extensions "at runtime".
|
|
2104
2124
|
*/
|
|
2105
2125
|
registerExtension(e) {
|
|
2106
|
-
var
|
|
2126
|
+
var r;
|
|
2107
2127
|
const t = [].concat(e).filter(Boolean);
|
|
2108
2128
|
if (!t.length) {
|
|
2109
2129
|
console.warn("No extensions found to register", e);
|
|
2110
2130
|
return;
|
|
2111
2131
|
}
|
|
2112
|
-
const
|
|
2113
|
-
for (const
|
|
2114
|
-
|
|
2115
|
-
`Extension ${
|
|
2116
|
-
|
|
2117
|
-
), (
|
|
2118
|
-
`Extension ${
|
|
2119
|
-
|
|
2120
|
-
), this.getProsemirrorPluginsFromExtension(
|
|
2132
|
+
const n = t.map((i) => this.addExtension(i)).filter(Boolean), s = /* @__PURE__ */ new Set();
|
|
2133
|
+
for (const i of n)
|
|
2134
|
+
i != null && i.tiptapExtensions && console.warn(
|
|
2135
|
+
`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.`,
|
|
2136
|
+
i
|
|
2137
|
+
), (r = i == null ? void 0 : i.inputRules) != null && r.length && console.warn(
|
|
2138
|
+
`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.`,
|
|
2139
|
+
i
|
|
2140
|
+
), this.getProsemirrorPluginsFromExtension(i).plugins.forEach(
|
|
2121
2141
|
(c) => {
|
|
2122
2142
|
s.add(c);
|
|
2123
2143
|
}
|
|
2124
2144
|
);
|
|
2125
|
-
this.updatePlugins((
|
|
2145
|
+
this.updatePlugins((i) => [...i, ...s]);
|
|
2126
2146
|
}
|
|
2127
2147
|
/**
|
|
2128
2148
|
* Register an extension to the editor
|
|
@@ -2133,10 +2153,13 @@ class cn {
|
|
|
2133
2153
|
let t;
|
|
2134
2154
|
if (typeof e == "function" ? t = e({ editor: this.editor }) : t = e, !(!t || this.disabledExtensions.has(t.key))) {
|
|
2135
2155
|
if (typeof e == "function") {
|
|
2136
|
-
const
|
|
2137
|
-
typeof
|
|
2156
|
+
const n = t[Ot];
|
|
2157
|
+
typeof n == "function" && this.extensionFactories.set(n, t);
|
|
2138
2158
|
}
|
|
2139
|
-
|
|
2159
|
+
if (this.extensions.push(t), t.blockNoteExtensions)
|
|
2160
|
+
for (const n of t.blockNoteExtensions)
|
|
2161
|
+
this.addExtension(n);
|
|
2162
|
+
return t;
|
|
2140
2163
|
}
|
|
2141
2164
|
}
|
|
2142
2165
|
/**
|
|
@@ -2147,16 +2170,16 @@ class cn {
|
|
|
2147
2170
|
resolveExtensions(e) {
|
|
2148
2171
|
const t = [];
|
|
2149
2172
|
if (typeof e == "function") {
|
|
2150
|
-
const
|
|
2151
|
-
|
|
2173
|
+
const n = this.extensionFactories.get(e);
|
|
2174
|
+
n && t.push(n);
|
|
2152
2175
|
} else if (Array.isArray(e))
|
|
2153
|
-
for (const
|
|
2154
|
-
t.push(...this.resolveExtensions(
|
|
2176
|
+
for (const n of e)
|
|
2177
|
+
t.push(...this.resolveExtensions(n));
|
|
2155
2178
|
else if (typeof e == "object" && "key" in e)
|
|
2156
2179
|
t.push(e);
|
|
2157
2180
|
else if (typeof e == "string") {
|
|
2158
|
-
const
|
|
2159
|
-
|
|
2181
|
+
const n = this.extensions.find((s) => s.key === e);
|
|
2182
|
+
n && t.push(n);
|
|
2160
2183
|
}
|
|
2161
2184
|
return t;
|
|
2162
2185
|
}
|
|
@@ -2166,28 +2189,28 @@ class cn {
|
|
|
2166
2189
|
* @returns void
|
|
2167
2190
|
*/
|
|
2168
2191
|
unregisterExtension(e) {
|
|
2169
|
-
var
|
|
2192
|
+
var r;
|
|
2170
2193
|
const t = this.resolveExtensions(e);
|
|
2171
2194
|
if (!t.length) {
|
|
2172
2195
|
console.warn("No extensions found to unregister", e);
|
|
2173
2196
|
return;
|
|
2174
2197
|
}
|
|
2175
|
-
let
|
|
2198
|
+
let n = !1;
|
|
2176
2199
|
const s = /* @__PURE__ */ new Set();
|
|
2177
|
-
for (const
|
|
2178
|
-
this.extensions = this.extensions.filter((a) => a !==
|
|
2179
|
-
a ===
|
|
2180
|
-
}), (
|
|
2181
|
-
const c = this.extensionPlugins.get(
|
|
2200
|
+
for (const i of t) {
|
|
2201
|
+
this.extensions = this.extensions.filter((a) => a !== i), this.extensionFactories.forEach((a, l) => {
|
|
2202
|
+
a === i && this.extensionFactories.delete(l);
|
|
2203
|
+
}), (r = this.abortMap.get(i)) == null || r.abort(), this.abortMap.delete(i);
|
|
2204
|
+
const c = this.extensionPlugins.get(i);
|
|
2182
2205
|
c == null || c.forEach((a) => {
|
|
2183
2206
|
s.add(a);
|
|
2184
|
-
}), this.extensionPlugins.delete(
|
|
2185
|
-
`Extension ${
|
|
2207
|
+
}), this.extensionPlugins.delete(i), i.tiptapExtensions && !n && (n = !0, console.warn(
|
|
2208
|
+
`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.`,
|
|
2186
2209
|
e
|
|
2187
2210
|
));
|
|
2188
2211
|
}
|
|
2189
2212
|
this.updatePlugins(
|
|
2190
|
-
(
|
|
2213
|
+
(i) => i.filter((c) => !s.has(c))
|
|
2191
2214
|
);
|
|
2192
2215
|
}
|
|
2193
2216
|
/**
|
|
@@ -2196,44 +2219,44 @@ class cn {
|
|
|
2196
2219
|
* @returns void
|
|
2197
2220
|
*/
|
|
2198
2221
|
updatePlugins(e) {
|
|
2199
|
-
const t = this.editor.prosemirrorState,
|
|
2222
|
+
const t = this.editor.prosemirrorState, n = t.reconfigure({
|
|
2200
2223
|
plugins: e(t.plugins.slice())
|
|
2201
2224
|
});
|
|
2202
|
-
this.editor.prosemirrorView.updateState(
|
|
2225
|
+
this.editor.prosemirrorView.updateState(n);
|
|
2203
2226
|
}
|
|
2204
2227
|
/**
|
|
2205
2228
|
* Get all the extensions that are registered to the editor
|
|
2206
2229
|
*/
|
|
2207
2230
|
getTiptapExtensions() {
|
|
2208
2231
|
var s;
|
|
2209
|
-
const e =
|
|
2232
|
+
const e = cn(
|
|
2210
2233
|
this.editor,
|
|
2211
2234
|
this.options
|
|
2212
|
-
), t = Ct(this.extensions),
|
|
2213
|
-
for (const
|
|
2214
|
-
|
|
2215
|
-
const
|
|
2235
|
+
).filter((r) => !this.disabledExtensions.has(r.name)), t = Ct(this.extensions), n = /* @__PURE__ */ new Map();
|
|
2236
|
+
for (const r of this.extensions) {
|
|
2237
|
+
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
2238
|
+
const i = t(r.key), { plugins: c, inputRules: a } = this.getProsemirrorPluginsFromExtension(r);
|
|
2216
2239
|
c.length && e.push(
|
|
2217
|
-
|
|
2218
|
-
name:
|
|
2219
|
-
priority:
|
|
2240
|
+
E.create({
|
|
2241
|
+
name: r.key,
|
|
2242
|
+
priority: i,
|
|
2220
2243
|
addProseMirrorPlugins: () => c
|
|
2221
2244
|
})
|
|
2222
|
-
), a.length && (
|
|
2245
|
+
), a.length && (n.has(i) || n.set(i, []), n.get(i).push(...a));
|
|
2223
2246
|
}
|
|
2224
2247
|
e.push(
|
|
2225
|
-
|
|
2248
|
+
E.create({
|
|
2226
2249
|
name: "blocknote-input-rules",
|
|
2227
2250
|
addProseMirrorPlugins() {
|
|
2228
|
-
const
|
|
2229
|
-
return Array.from(
|
|
2230
|
-
|
|
2231
|
-
}), [_t({ rules:
|
|
2251
|
+
const r = [];
|
|
2252
|
+
return Array.from(n.keys()).sort().reverse().forEach((i) => {
|
|
2253
|
+
r.push(...n.get(i));
|
|
2254
|
+
}), [_t({ rules: r })];
|
|
2232
2255
|
}
|
|
2233
2256
|
})
|
|
2234
2257
|
);
|
|
2235
|
-
for (const
|
|
2236
|
-
e.push(
|
|
2258
|
+
for (const r of ((s = this.options._tiptapOptions) == null ? void 0 : s.extensions) ?? [])
|
|
2259
|
+
e.push(r);
|
|
2237
2260
|
return e;
|
|
2238
2261
|
}
|
|
2239
2262
|
/**
|
|
@@ -2243,9 +2266,9 @@ class cn {
|
|
|
2243
2266
|
* - input rules
|
|
2244
2267
|
*/
|
|
2245
2268
|
getProsemirrorPluginsFromExtension(e) {
|
|
2246
|
-
var s,
|
|
2247
|
-
const t = [...e.prosemirrorPlugins ?? []],
|
|
2248
|
-
return !((s = e.prosemirrorPlugins) != null && s.length) && !Object.keys(e.keyboardShortcuts || {}).length && !((
|
|
2269
|
+
var s, r, i;
|
|
2270
|
+
const t = [...e.prosemirrorPlugins ?? []], n = [];
|
|
2271
|
+
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(
|
|
2249
2272
|
...e.inputRules.map((c) => new Dt(c.find, (a, l, d, u) => {
|
|
2250
2273
|
const p = c.replace({
|
|
2251
2274
|
match: l,
|
|
@@ -2256,7 +2279,7 @@ class cn {
|
|
|
2256
2279
|
const m = this.editor.getTextCursorPosition();
|
|
2257
2280
|
if (this.editor.schema.blockSchema[m.block.type].content !== "inline")
|
|
2258
2281
|
return null;
|
|
2259
|
-
const f =
|
|
2282
|
+
const f = $(a.tr), k = a.tr.deleteRange(d, u);
|
|
2260
2283
|
return tt(k, f.bnBlock.beforePos, p), k;
|
|
2261
2284
|
}
|
|
2262
2285
|
return null;
|
|
@@ -2270,7 +2293,7 @@ class cn {
|
|
|
2270
2293
|
])
|
|
2271
2294
|
)
|
|
2272
2295
|
)
|
|
2273
|
-
), { plugins: t, inputRules:
|
|
2296
|
+
), { plugins: t, inputRules: n });
|
|
2274
2297
|
}
|
|
2275
2298
|
/**
|
|
2276
2299
|
* Get all extensions
|
|
@@ -2282,7 +2305,7 @@ class cn {
|
|
|
2282
2305
|
}
|
|
2283
2306
|
getExtension(e) {
|
|
2284
2307
|
if (typeof e == "string") {
|
|
2285
|
-
const t = this.extensions.find((
|
|
2308
|
+
const t = this.extensions.find((n) => n.key === e);
|
|
2286
2309
|
return t || void 0;
|
|
2287
2310
|
} else if (typeof e == "function") {
|
|
2288
2311
|
const t = this.extensionFactories.get(e);
|
|
@@ -2297,58 +2320,76 @@ class cn {
|
|
|
2297
2320
|
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;
|
|
2298
2321
|
}
|
|
2299
2322
|
}
|
|
2300
|
-
function
|
|
2301
|
-
|
|
2302
|
-
if (
|
|
2323
|
+
function un(o, e) {
|
|
2324
|
+
let { $from: t, $to: n } = e;
|
|
2325
|
+
if (t.pos > t.start() && t.pos < o.content.size) {
|
|
2326
|
+
const s = o.textBetween(t.pos, t.pos + 1);
|
|
2327
|
+
if (/^[\w\p{P}]$/u.test(s)) {
|
|
2328
|
+
const i = o.textBetween(t.start(), t.pos).match(/[\w\p{P}]+$/u);
|
|
2329
|
+
i && (t = o.resolve(t.pos - i[0].length));
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
if (n.pos < n.end() && n.pos > 0) {
|
|
2333
|
+
const s = o.textBetween(n.pos - 1, n.pos);
|
|
2334
|
+
if (/^[\w\p{P}]$/u.test(s)) {
|
|
2335
|
+
const i = o.textBetween(n.pos, n.end()).match(/^[\w\p{P}]+/u);
|
|
2336
|
+
i && (n = o.resolve(n.pos + i[0].length));
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
return { $from: t, $to: n, from: t.pos, to: n.pos };
|
|
2340
|
+
}
|
|
2341
|
+
function pn(o) {
|
|
2342
|
+
const e = C(o);
|
|
2343
|
+
if (o.selection.empty || "node" in o.selection)
|
|
2303
2344
|
return;
|
|
2304
|
-
const t =
|
|
2305
|
-
_(
|
|
2306
|
-
),
|
|
2307
|
-
_(
|
|
2345
|
+
const t = o.doc.resolve(
|
|
2346
|
+
_(o.doc, o.selection.from).posBeforeNode
|
|
2347
|
+
), n = o.doc.resolve(
|
|
2348
|
+
_(o.doc, o.selection.to).posBeforeNode
|
|
2308
2349
|
), s = (l, d) => {
|
|
2309
|
-
const u = t.posAtIndex(l, d), p =
|
|
2350
|
+
const u = t.posAtIndex(l, d), p = o.doc.resolve(u).nodeAfter;
|
|
2310
2351
|
if (!p)
|
|
2311
2352
|
throw new Error(
|
|
2312
2353
|
`Error getting selection - node not found at position ${u}`
|
|
2313
2354
|
);
|
|
2314
2355
|
return b(p, e);
|
|
2315
|
-
},
|
|
2316
|
-
if (t.depth >
|
|
2317
|
-
|
|
2318
|
-
for (let l = t.depth; l >
|
|
2356
|
+
}, r = [], i = t.sharedDepth(n.pos), c = t.index(i), a = n.index(i);
|
|
2357
|
+
if (t.depth > i) {
|
|
2358
|
+
r.push(b(t.nodeAfter, e));
|
|
2359
|
+
for (let l = t.depth; l > i; l--)
|
|
2319
2360
|
if (t.node(l).type.isInGroup("childContainer")) {
|
|
2320
2361
|
const u = t.index(l) + 1, p = t.node(l).childCount;
|
|
2321
2362
|
for (let m = u; m < p; m++)
|
|
2322
|
-
|
|
2363
|
+
r.push(s(m, l));
|
|
2323
2364
|
}
|
|
2324
2365
|
} else
|
|
2325
|
-
|
|
2366
|
+
r.push(s(c, i));
|
|
2326
2367
|
for (let l = c + 1; l <= a; l++)
|
|
2327
|
-
|
|
2328
|
-
if (
|
|
2368
|
+
r.push(s(l, i));
|
|
2369
|
+
if (r.length === 0)
|
|
2329
2370
|
throw new Error(
|
|
2330
|
-
`Error getting selection - selection doesn't span any blocks (${
|
|
2371
|
+
`Error getting selection - selection doesn't span any blocks (${o.selection})`
|
|
2331
2372
|
);
|
|
2332
2373
|
return {
|
|
2333
|
-
blocks:
|
|
2374
|
+
blocks: r
|
|
2334
2375
|
};
|
|
2335
2376
|
}
|
|
2336
|
-
function
|
|
2337
|
-
const
|
|
2338
|
-
if (
|
|
2377
|
+
function fn(o, e, t) {
|
|
2378
|
+
const n = typeof e == "string" ? e : e.id, s = typeof t == "string" ? t : t.id, r = C(o), i = ke(r);
|
|
2379
|
+
if (n === s)
|
|
2339
2380
|
throw new Error(
|
|
2340
|
-
`Attempting to set selection with the same anchor and head blocks (id ${
|
|
2381
|
+
`Attempting to set selection with the same anchor and head blocks (id ${n})`
|
|
2341
2382
|
);
|
|
2342
|
-
const c =
|
|
2383
|
+
const c = x(n, o.doc);
|
|
2343
2384
|
if (!c)
|
|
2344
|
-
throw new Error(`Block with ID ${
|
|
2345
|
-
const a =
|
|
2385
|
+
throw new Error(`Block with ID ${n} not found`);
|
|
2386
|
+
const a = x(s, o.doc);
|
|
2346
2387
|
if (!a)
|
|
2347
2388
|
throw new Error(`Block with ID ${s} not found`);
|
|
2348
|
-
const l = z(c), d = z(a), u =
|
|
2389
|
+
const l = z(c), d = z(a), u = i.blockSchema[l.blockNoteType], p = i.blockSchema[d.blockNoteType];
|
|
2349
2390
|
if (!l.isBlockContainer || u.content === "none")
|
|
2350
2391
|
throw new Error(
|
|
2351
|
-
`Attempting to set selection anchor in block without content (id ${
|
|
2392
|
+
`Attempting to set selection anchor in block without content (id ${n})`
|
|
2352
2393
|
);
|
|
2353
2394
|
if (!d.isBlockContainer || p.content === "none")
|
|
2354
2395
|
throw new Error(
|
|
@@ -2365,76 +2406,76 @@ function dn(n, e, t) {
|
|
|
2365
2406
|
k.height - 1,
|
|
2366
2407
|
k.width - 1,
|
|
2367
2408
|
d.blockContent.node
|
|
2368
|
-
) + 1, y =
|
|
2409
|
+
) + 1, y = o.doc.resolve(g).nodeAfter.nodeSize;
|
|
2369
2410
|
f = g + y - 2;
|
|
2370
2411
|
} else
|
|
2371
2412
|
f = d.blockContent.afterPos - 1;
|
|
2372
|
-
|
|
2373
|
-
}
|
|
2374
|
-
function
|
|
2375
|
-
const
|
|
2376
|
-
let
|
|
2377
|
-
for (;
|
|
2378
|
-
|
|
2379
|
-
for (;
|
|
2380
|
-
|
|
2381
|
-
for (;
|
|
2382
|
-
|
|
2383
|
-
for (;
|
|
2384
|
-
|
|
2385
|
-
const
|
|
2386
|
-
|
|
2387
|
-
|
|
2413
|
+
o.setSelection(M.create(o.doc, m, f));
|
|
2414
|
+
}
|
|
2415
|
+
function hn(o, e = !1) {
|
|
2416
|
+
const t = C(o), n = e ? un(o.doc, o.selection) : o.selection;
|
|
2417
|
+
let s = n.$from, r = n.$to;
|
|
2418
|
+
for (; r.parentOffset >= r.parent.nodeSize - 2 && r.depth > 0; )
|
|
2419
|
+
r = o.doc.resolve(r.pos + 1);
|
|
2420
|
+
for (; r.parentOffset === 0 && r.depth > 0; )
|
|
2421
|
+
r = o.doc.resolve(r.pos - 1);
|
|
2422
|
+
for (; s.parentOffset === 0 && s.depth > 0; )
|
|
2423
|
+
s = o.doc.resolve(s.pos - 1);
|
|
2424
|
+
for (; s.parentOffset >= s.parent.nodeSize - 2 && s.depth > 0; )
|
|
2425
|
+
s = o.doc.resolve(s.pos + 1);
|
|
2426
|
+
const i = je(
|
|
2427
|
+
o.doc.slice(s.pos, r.pos, !0),
|
|
2428
|
+
t
|
|
2388
2429
|
);
|
|
2389
2430
|
return {
|
|
2390
2431
|
_meta: {
|
|
2391
|
-
startPos:
|
|
2392
|
-
endPos:
|
|
2432
|
+
startPos: s.pos,
|
|
2433
|
+
endPos: r.pos
|
|
2393
2434
|
},
|
|
2394
|
-
...
|
|
2435
|
+
...i
|
|
2395
2436
|
};
|
|
2396
2437
|
}
|
|
2397
|
-
function
|
|
2398
|
-
const { bnBlock: e } =
|
|
2399
|
-
let
|
|
2400
|
-
return
|
|
2438
|
+
function mn(o) {
|
|
2439
|
+
const { bnBlock: e } = $(o), t = C(o.doc), n = o.doc.resolve(e.beforePos), s = n.nodeBefore, r = o.doc.resolve(e.afterPos).nodeAfter;
|
|
2440
|
+
let i;
|
|
2441
|
+
return n.depth > 1 && (i = n.node(), i.type.isInGroup("bnBlock") || (i = n.node(n.depth - 1))), {
|
|
2401
2442
|
block: b(e.node, t),
|
|
2402
2443
|
prevBlock: s === null ? void 0 : b(s, t),
|
|
2403
|
-
nextBlock:
|
|
2404
|
-
parentBlock:
|
|
2444
|
+
nextBlock: r === null ? void 0 : b(r, t),
|
|
2445
|
+
parentBlock: i === void 0 ? void 0 : b(i, t)
|
|
2405
2446
|
};
|
|
2406
2447
|
}
|
|
2407
|
-
function De(
|
|
2408
|
-
const
|
|
2409
|
-
if (!
|
|
2410
|
-
throw new Error(`Block with ID ${
|
|
2411
|
-
const c = z(
|
|
2448
|
+
function De(o, e, t = "start") {
|
|
2449
|
+
const n = typeof e == "string" ? e : e.id, s = C(o.doc), r = ke(s), i = x(n, o.doc);
|
|
2450
|
+
if (!i)
|
|
2451
|
+
throw new Error(`Block with ID ${n} not found`);
|
|
2452
|
+
const c = z(i), a = r.blockSchema[c.blockNoteType].content;
|
|
2412
2453
|
if (c.isBlockContainer) {
|
|
2413
2454
|
const l = c.blockContent;
|
|
2414
2455
|
if (a === "none") {
|
|
2415
|
-
|
|
2456
|
+
o.setSelection(L.create(o.doc, l.beforePos));
|
|
2416
2457
|
return;
|
|
2417
2458
|
}
|
|
2418
2459
|
if (a === "inline")
|
|
2419
|
-
t === "start" ?
|
|
2420
|
-
M.create(
|
|
2421
|
-
) :
|
|
2422
|
-
M.create(
|
|
2460
|
+
t === "start" ? o.setSelection(
|
|
2461
|
+
M.create(o.doc, l.beforePos + 1)
|
|
2462
|
+
) : o.setSelection(
|
|
2463
|
+
M.create(o.doc, l.afterPos - 1)
|
|
2423
2464
|
);
|
|
2424
2465
|
else if (a === "table")
|
|
2425
|
-
t === "start" ?
|
|
2426
|
-
M.create(
|
|
2427
|
-
) :
|
|
2428
|
-
M.create(
|
|
2466
|
+
t === "start" ? o.setSelection(
|
|
2467
|
+
M.create(o.doc, l.beforePos + 4)
|
|
2468
|
+
) : o.setSelection(
|
|
2469
|
+
M.create(o.doc, l.afterPos - 4)
|
|
2429
2470
|
);
|
|
2430
2471
|
else
|
|
2431
2472
|
throw new F(a);
|
|
2432
2473
|
} else {
|
|
2433
2474
|
const l = t === "start" ? c.childContainer.node.firstChild : c.childContainer.node.lastChild;
|
|
2434
|
-
De(
|
|
2475
|
+
De(o, l.attrs.id, t);
|
|
2435
2476
|
}
|
|
2436
2477
|
}
|
|
2437
|
-
class
|
|
2478
|
+
class kn {
|
|
2438
2479
|
constructor(e) {
|
|
2439
2480
|
this.editor = e;
|
|
2440
2481
|
}
|
|
@@ -2445,7 +2486,7 @@ class fn {
|
|
|
2445
2486
|
* If the selection starts / ends halfway through a block, the returned data will contain the entire block.
|
|
2446
2487
|
*/
|
|
2447
2488
|
getSelection() {
|
|
2448
|
-
return this.editor.transact((e) =>
|
|
2489
|
+
return this.editor.transact((e) => pn(e));
|
|
2449
2490
|
}
|
|
2450
2491
|
/**
|
|
2451
2492
|
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
@@ -2454,8 +2495,8 @@ class fn {
|
|
|
2454
2495
|
* If the selection starts / ends halfway through a block, the returned block will be
|
|
2455
2496
|
* only the part of the block that is included in the selection.
|
|
2456
2497
|
*/
|
|
2457
|
-
getSelectionCutBlocks() {
|
|
2458
|
-
return this.editor.transact((
|
|
2498
|
+
getSelectionCutBlocks(e = !1) {
|
|
2499
|
+
return this.editor.transact((t) => hn(t, e));
|
|
2459
2500
|
}
|
|
2460
2501
|
/**
|
|
2461
2502
|
* Sets the selection to a range of blocks.
|
|
@@ -2463,14 +2504,14 @@ class fn {
|
|
|
2463
2504
|
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
2464
2505
|
*/
|
|
2465
2506
|
setSelection(e, t) {
|
|
2466
|
-
return this.editor.transact((
|
|
2507
|
+
return this.editor.transact((n) => fn(n, e, t));
|
|
2467
2508
|
}
|
|
2468
2509
|
/**
|
|
2469
2510
|
* Gets a snapshot of the current text cursor position.
|
|
2470
2511
|
* @returns A snapshot of the current text cursor position.
|
|
2471
2512
|
*/
|
|
2472
2513
|
getTextCursorPosition() {
|
|
2473
|
-
return this.editor.transact((e) =>
|
|
2514
|
+
return this.editor.transact((e) => mn(e));
|
|
2474
2515
|
}
|
|
2475
2516
|
/**
|
|
2476
2517
|
* Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
|
|
@@ -2480,7 +2521,7 @@ class fn {
|
|
|
2480
2521
|
*/
|
|
2481
2522
|
setTextCursorPosition(e, t = "start") {
|
|
2482
2523
|
return this.editor.transact(
|
|
2483
|
-
(
|
|
2524
|
+
(n) => De(n, e, t)
|
|
2484
2525
|
);
|
|
2485
2526
|
}
|
|
2486
2527
|
/**
|
|
@@ -2489,20 +2530,20 @@ class fn {
|
|
|
2489
2530
|
getSelectionBoundingBox() {
|
|
2490
2531
|
if (!this.editor.prosemirrorView)
|
|
2491
2532
|
return;
|
|
2492
|
-
const { selection: e } = this.editor.prosemirrorState, { ranges: t } = e,
|
|
2533
|
+
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));
|
|
2493
2534
|
if (Mt(e)) {
|
|
2494
|
-
const
|
|
2495
|
-
if (
|
|
2496
|
-
return
|
|
2535
|
+
const r = this.editor.prosemirrorView.nodeDOM(n);
|
|
2536
|
+
if (r)
|
|
2537
|
+
return r.getBoundingClientRect();
|
|
2497
2538
|
}
|
|
2498
2539
|
return wt(
|
|
2499
2540
|
this.editor.prosemirrorView,
|
|
2500
|
-
|
|
2541
|
+
n,
|
|
2501
2542
|
s
|
|
2502
2543
|
).toJSON();
|
|
2503
2544
|
}
|
|
2504
2545
|
}
|
|
2505
|
-
class
|
|
2546
|
+
class gn {
|
|
2506
2547
|
constructor(e) {
|
|
2507
2548
|
/**
|
|
2508
2549
|
* Stores the currently active transaction, which is the accumulated transaction from all {@link dispatch} calls during a {@link transact} calls
|
|
@@ -2548,8 +2589,8 @@ class hn {
|
|
|
2548
2589
|
);
|
|
2549
2590
|
if (this.isInCan)
|
|
2550
2591
|
return this.canExec(e);
|
|
2551
|
-
const t = this.prosemirrorState,
|
|
2552
|
-
return e(t, (
|
|
2592
|
+
const t = this.prosemirrorState, n = this.prosemirrorView;
|
|
2593
|
+
return e(t, (r) => this.prosemirrorView.dispatch(r), n);
|
|
2553
2594
|
}
|
|
2554
2595
|
/**
|
|
2555
2596
|
* Check if a command can be executed. A command should return `false` if it is not valid in the current state.
|
|
@@ -2568,8 +2609,8 @@ class hn {
|
|
|
2568
2609
|
throw new Error(
|
|
2569
2610
|
"`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call"
|
|
2570
2611
|
);
|
|
2571
|
-
const t = this.prosemirrorState,
|
|
2572
|
-
return e(t, void 0,
|
|
2612
|
+
const t = this.prosemirrorState, n = this.prosemirrorView;
|
|
2613
|
+
return e(t, void 0, n);
|
|
2573
2614
|
}
|
|
2574
2615
|
/**
|
|
2575
2616
|
* Execute a function within a "blocknote transaction".
|
|
@@ -2595,9 +2636,9 @@ class hn {
|
|
|
2595
2636
|
return e(this.activeTransaction);
|
|
2596
2637
|
try {
|
|
2597
2638
|
this.activeTransaction = this.editor._tiptapEditor.state.tr;
|
|
2598
|
-
const t = e(this.activeTransaction),
|
|
2599
|
-
return this.activeTransaction = null,
|
|
2600
|
-
(
|
|
2639
|
+
const t = e(this.activeTransaction), n = this.activeTransaction;
|
|
2640
|
+
return this.activeTransaction = null, n && // Only dispatch if the transaction was actually modified in some way
|
|
2641
|
+
(n.docChanged || n.selectionSet || n.scrolledIntoView || n.storedMarksSet || !n.isGeneric) && this.prosemirrorView.dispatch(n), t;
|
|
2601
2642
|
} finally {
|
|
2602
2643
|
this.activeTransaction = null;
|
|
2603
2644
|
}
|
|
@@ -2678,17 +2719,17 @@ class hn {
|
|
|
2678
2719
|
throw new Error("No redo plugin found");
|
|
2679
2720
|
}
|
|
2680
2721
|
}
|
|
2681
|
-
function
|
|
2682
|
-
let { from: s, to:
|
|
2722
|
+
function bn(o, e, t, n = { updateSelection: !0 }) {
|
|
2723
|
+
let { from: s, to: r } = typeof e == "number" ? { from: e, to: e } : { from: e.from, to: e.to }, i = !0, c = !0, a = "";
|
|
2683
2724
|
if (t.forEach((l) => {
|
|
2684
|
-
l.check(),
|
|
2685
|
-
}), s ===
|
|
2686
|
-
const { parent: l } =
|
|
2687
|
-
l.isTextblock && !l.type.spec.code && !l.childCount && (s -= 1,
|
|
2725
|
+
l.check(), i && l.isText && l.marks.length === 0 ? a += l.text : i = !1, c = c ? l.isBlock : !1;
|
|
2726
|
+
}), s === r && c) {
|
|
2727
|
+
const { parent: l } = o.doc.resolve(s);
|
|
2728
|
+
l.isTextblock && !l.type.spec.code && !l.childCount && (s -= 1, r += 1);
|
|
2688
2729
|
}
|
|
2689
|
-
return
|
|
2730
|
+
return i ? o.insertText(a, s, r) : o.replaceWith(s, r, t), n.updateSelection && Tt(o, o.steps.length - 1, -1), !0;
|
|
2690
2731
|
}
|
|
2691
|
-
class
|
|
2732
|
+
class yn {
|
|
2692
2733
|
constructor(e) {
|
|
2693
2734
|
this.editor = e;
|
|
2694
2735
|
}
|
|
@@ -2698,15 +2739,15 @@ class kn {
|
|
|
2698
2739
|
* @param content can be a string, or array of partial inline content elements
|
|
2699
2740
|
*/
|
|
2700
2741
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2701
|
-
const
|
|
2742
|
+
const n = O(e, this.editor.pmSchema);
|
|
2702
2743
|
this.editor.transact((s) => {
|
|
2703
|
-
|
|
2744
|
+
bn(
|
|
2704
2745
|
s,
|
|
2705
2746
|
{
|
|
2706
2747
|
from: s.selection.from,
|
|
2707
2748
|
to: s.selection.to
|
|
2708
2749
|
},
|
|
2709
|
-
|
|
2750
|
+
n,
|
|
2710
2751
|
{
|
|
2711
2752
|
updateSelection: t
|
|
2712
2753
|
}
|
|
@@ -2718,16 +2759,16 @@ class kn {
|
|
|
2718
2759
|
*/
|
|
2719
2760
|
getActiveStyles() {
|
|
2720
2761
|
return this.editor.transact((e) => {
|
|
2721
|
-
const t = {},
|
|
2722
|
-
for (const s of
|
|
2723
|
-
const
|
|
2724
|
-
if (!
|
|
2762
|
+
const t = {}, n = e.selection.$to.marks();
|
|
2763
|
+
for (const s of n) {
|
|
2764
|
+
const r = this.editor.schema.styleSchema[s.type.name];
|
|
2765
|
+
if (!r) {
|
|
2725
2766
|
// Links are not considered styles in blocknote
|
|
2726
2767
|
s.type.name !== "link" && // "blocknoteIgnore" tagged marks (such as comments) are also not considered BlockNote "styles"
|
|
2727
2768
|
!s.type.spec.blocknoteIgnore && console.warn("mark not found in styleschema", s.type.name);
|
|
2728
2769
|
continue;
|
|
2729
2770
|
}
|
|
2730
|
-
|
|
2771
|
+
r.propSchema === "boolean" ? t[r.type] = !0 : t[r.type] = s.attrs.stringValue;
|
|
2731
2772
|
}
|
|
2732
2773
|
return t;
|
|
2733
2774
|
});
|
|
@@ -2737,7 +2778,7 @@ class kn {
|
|
|
2737
2778
|
* @param styles The styles to add.
|
|
2738
2779
|
*/
|
|
2739
2780
|
addStyles(e) {
|
|
2740
|
-
for (const [t,
|
|
2781
|
+
for (const [t, n] of Object.entries(e)) {
|
|
2741
2782
|
const s = this.editor.schema.styleSchema[t];
|
|
2742
2783
|
if (!s)
|
|
2743
2784
|
throw new Error(`style ${t} not found in styleSchema`);
|
|
@@ -2745,7 +2786,7 @@ class kn {
|
|
|
2745
2786
|
this.editor._tiptapEditor.commands.setMark(t);
|
|
2746
2787
|
else if (s.propSchema === "string")
|
|
2747
2788
|
this.editor._tiptapEditor.commands.setMark(t, {
|
|
2748
|
-
stringValue:
|
|
2789
|
+
stringValue: n
|
|
2749
2790
|
});
|
|
2750
2791
|
else
|
|
2751
2792
|
throw new F(s.propSchema);
|
|
@@ -2764,7 +2805,7 @@ class kn {
|
|
|
2764
2805
|
* @param styles The styles to toggle.
|
|
2765
2806
|
*/
|
|
2766
2807
|
toggleStyles(e) {
|
|
2767
|
-
for (const [t,
|
|
2808
|
+
for (const [t, n] of Object.entries(e)) {
|
|
2768
2809
|
const s = this.editor.schema.styleSchema[t];
|
|
2769
2810
|
if (!s)
|
|
2770
2811
|
throw new Error(`style ${t} not found in styleSchema`);
|
|
@@ -2772,7 +2813,7 @@ class kn {
|
|
|
2772
2813
|
this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2773
2814
|
else if (s.propSchema === "string")
|
|
2774
2815
|
this.editor._tiptapEditor.commands.toggleMark(t, {
|
|
2775
|
-
stringValue:
|
|
2816
|
+
stringValue: n
|
|
2776
2817
|
});
|
|
2777
2818
|
else
|
|
2778
2819
|
throw new F(s.propSchema);
|
|
@@ -2798,65 +2839,65 @@ class kn {
|
|
|
2798
2839
|
createLink(e, t) {
|
|
2799
2840
|
if (e === "")
|
|
2800
2841
|
return;
|
|
2801
|
-
const
|
|
2842
|
+
const n = this.editor.pmSchema.mark("link", { href: e });
|
|
2802
2843
|
this.editor.transact((s) => {
|
|
2803
|
-
const { from:
|
|
2804
|
-
t ? s.insertText(t,
|
|
2805
|
-
i,
|
|
2844
|
+
const { from: r, to: i } = s.selection;
|
|
2845
|
+
t ? s.insertText(t, r, i).addMark(r, r + t.length, n) : s.setSelection(Wt.create(s.doc, i)).addMark(
|
|
2806
2846
|
r,
|
|
2807
|
-
|
|
2847
|
+
i,
|
|
2848
|
+
n
|
|
2808
2849
|
);
|
|
2809
2850
|
});
|
|
2810
2851
|
}
|
|
2811
2852
|
}
|
|
2812
|
-
function
|
|
2853
|
+
function Sn(o, e) {
|
|
2813
2854
|
const t = [];
|
|
2814
|
-
return
|
|
2815
|
-
|
|
2855
|
+
return o.forEach((n, s, r) => {
|
|
2856
|
+
r !== e && t.push(n);
|
|
2816
2857
|
}), Z.from(t);
|
|
2817
2858
|
}
|
|
2818
|
-
function
|
|
2859
|
+
function Bn(o, e) {
|
|
2819
2860
|
const t = [];
|
|
2820
|
-
for (let
|
|
2821
|
-
if (
|
|
2861
|
+
for (let n = 0; n < o.childCount; n++)
|
|
2862
|
+
if (o.child(n).type.name === "tableRow")
|
|
2822
2863
|
if (t.length > 0 && t[t.length - 1].type.name === "table") {
|
|
2823
|
-
const s = t[t.length - 1],
|
|
2824
|
-
t[t.length - 1] =
|
|
2864
|
+
const s = t[t.length - 1], r = s.copy(s.content.addToEnd(o.child(n)));
|
|
2865
|
+
t[t.length - 1] = r;
|
|
2825
2866
|
} else {
|
|
2826
2867
|
const s = e.nodes.table.createChecked(
|
|
2827
2868
|
void 0,
|
|
2828
|
-
|
|
2869
|
+
o.child(n)
|
|
2829
2870
|
);
|
|
2830
2871
|
t.push(s);
|
|
2831
2872
|
}
|
|
2832
2873
|
else
|
|
2833
|
-
t.push(
|
|
2834
|
-
return
|
|
2835
|
-
}
|
|
2836
|
-
function
|
|
2837
|
-
let t = Z.from(
|
|
2838
|
-
if (t =
|
|
2839
|
-
return new ne(t,
|
|
2840
|
-
for (let
|
|
2841
|
-
if (t.child(
|
|
2842
|
-
const s = [t.child(
|
|
2843
|
-
if (
|
|
2844
|
-
const
|
|
2845
|
-
(
|
|
2874
|
+
t.push(o.child(n));
|
|
2875
|
+
return o = Z.from(t), o;
|
|
2876
|
+
}
|
|
2877
|
+
function Cn(o, e) {
|
|
2878
|
+
let t = Z.from(o.content);
|
|
2879
|
+
if (t = Bn(t, e.state.schema), !xn(t, e))
|
|
2880
|
+
return new ne(t, o.openStart, o.openEnd);
|
|
2881
|
+
for (let n = 0; n < t.childCount; n++)
|
|
2882
|
+
if (t.child(n).type.spec.group === "blockContent") {
|
|
2883
|
+
const s = [t.child(n)];
|
|
2884
|
+
if (n + 1 < t.childCount && t.child(n + 1).type.name === "blockGroup") {
|
|
2885
|
+
const i = t.child(n + 1).child(0).child(0);
|
|
2886
|
+
(i.type.name === "bulletListItem" || i.type.name === "numberedListItem" || i.type.name === "checkListItem") && (s.push(t.child(n + 1)), t = Sn(t, n + 1));
|
|
2846
2887
|
}
|
|
2847
|
-
const
|
|
2888
|
+
const r = e.state.schema.nodes.blockContainer.createChecked(
|
|
2848
2889
|
void 0,
|
|
2849
2890
|
s
|
|
2850
2891
|
);
|
|
2851
|
-
t = t.replaceChild(
|
|
2892
|
+
t = t.replaceChild(n, r);
|
|
2852
2893
|
}
|
|
2853
|
-
return new ne(t,
|
|
2894
|
+
return new ne(t, o.openStart, o.openEnd);
|
|
2854
2895
|
}
|
|
2855
|
-
function
|
|
2856
|
-
var
|
|
2857
|
-
const t =
|
|
2896
|
+
function xn(o, e) {
|
|
2897
|
+
var r, i;
|
|
2898
|
+
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+";
|
|
2858
2899
|
if (t) {
|
|
2859
|
-
if (
|
|
2900
|
+
if (n)
|
|
2860
2901
|
return !1;
|
|
2861
2902
|
if (s) {
|
|
2862
2903
|
const c = B(e.state);
|
|
@@ -2866,7 +2907,7 @@ function Sn(n, e) {
|
|
|
2866
2907
|
}
|
|
2867
2908
|
return !0;
|
|
2868
2909
|
}
|
|
2869
|
-
const
|
|
2910
|
+
const En = {
|
|
2870
2911
|
enableInputRules: !0,
|
|
2871
2912
|
enablePasteRules: !0,
|
|
2872
2913
|
enableCoreExtensions: !1
|
|
@@ -2961,17 +3002,17 @@ class Le extends Se {
|
|
|
2961
3002
|
headers: ((p = t == null ? void 0 : t.tables) == null ? void 0 : p.headers) ?? !1
|
|
2962
3003
|
}
|
|
2963
3004
|
};
|
|
2964
|
-
const
|
|
3005
|
+
const n = {
|
|
2965
3006
|
defaultStyles: !0,
|
|
2966
|
-
schema: t.schema ||
|
|
3007
|
+
schema: t.schema || xt.create(),
|
|
2967
3008
|
...t,
|
|
2968
3009
|
placeholders: {
|
|
2969
3010
|
...this.dictionary.placeholders,
|
|
2970
3011
|
...t.placeholders
|
|
2971
3012
|
}
|
|
2972
3013
|
};
|
|
2973
|
-
if (this.schema =
|
|
2974
|
-
const S =
|
|
3014
|
+
if (this.schema = n.schema, this.blockImplementations = n.schema.blockSpecs, this.inlineContentImplementations = n.schema.inlineContentSpecs, this.styleImplementations = n.schema.styleSpecs, n.uploadFile) {
|
|
3015
|
+
const S = n.uploadFile;
|
|
2975
3016
|
this.uploadFile = async (P, w) => {
|
|
2976
3017
|
this.onUploadStartCallbacks.forEach(
|
|
2977
3018
|
(v) => v.apply(this, [w])
|
|
@@ -2985,37 +3026,37 @@ class Le extends Se {
|
|
|
2985
3026
|
}
|
|
2986
3027
|
};
|
|
2987
3028
|
}
|
|
2988
|
-
this.resolveFileUrl =
|
|
2989
|
-
const s = this._extensionManager.getTiptapExtensions(),
|
|
2990
|
-
|
|
3029
|
+
this.resolveFileUrl = n.resolveFileUrl, this._eventManager = new fo(this), this._extensionManager = new dn(this, n);
|
|
3030
|
+
const s = this._extensionManager.getTiptapExtensions(), r = this._extensionManager.hasExtension("ySync") || this._extensionManager.hasExtension("liveblocksExtension");
|
|
3031
|
+
r && n.initialContent && console.warn(
|
|
2991
3032
|
"When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider"
|
|
2992
3033
|
);
|
|
2993
|
-
const
|
|
2994
|
-
...
|
|
2995
|
-
...
|
|
3034
|
+
const i = {
|
|
3035
|
+
...En,
|
|
3036
|
+
...n._tiptapOptions,
|
|
2996
3037
|
element: null,
|
|
2997
|
-
autofocus:
|
|
3038
|
+
autofocus: n.autofocus ?? !1,
|
|
2998
3039
|
extensions: s,
|
|
2999
3040
|
editorProps: {
|
|
3000
|
-
...(m =
|
|
3041
|
+
...(m = n._tiptapOptions) == null ? void 0 : m.editorProps,
|
|
3001
3042
|
attributes: {
|
|
3002
3043
|
// As of TipTap v2.5.0 the tabIndex is removed when the editor is not
|
|
3003
3044
|
// editable, so you can't focus it. We want to revert this as we have
|
|
3004
3045
|
// UI behaviour that relies on it.
|
|
3005
3046
|
tabIndex: "0",
|
|
3006
|
-
...(k = (f =
|
|
3007
|
-
...(g =
|
|
3047
|
+
...(k = (f = n._tiptapOptions) == null ? void 0 : f.editorProps) == null ? void 0 : k.attributes,
|
|
3048
|
+
...(g = n.domAttributes) == null ? void 0 : g.editor,
|
|
3008
3049
|
class: Q(
|
|
3009
3050
|
"bn-editor",
|
|
3010
|
-
|
|
3011
|
-
((T = (y =
|
|
3051
|
+
n.defaultStyles ? "bn-default-styles" : "",
|
|
3052
|
+
((T = (y = n.domAttributes) == null ? void 0 : y.editor) == null ? void 0 : T.class) || ""
|
|
3012
3053
|
)
|
|
3013
3054
|
},
|
|
3014
|
-
transformPasted:
|
|
3055
|
+
transformPasted: Cn
|
|
3015
3056
|
}
|
|
3016
3057
|
};
|
|
3017
3058
|
try {
|
|
3018
|
-
const S =
|
|
3059
|
+
const S = n.initialContent || (r ? [
|
|
3019
3060
|
{
|
|
3020
3061
|
type: "paragraph",
|
|
3021
3062
|
id: "initialBlockId"
|
|
@@ -3030,8 +3071,8 @@ class Le extends Se {
|
|
|
3030
3071
|
throw new Error(
|
|
3031
3072
|
"initialContent must be a non-empty array of blocks, received: " + S
|
|
3032
3073
|
);
|
|
3033
|
-
const P = Pt(
|
|
3034
|
-
(Ne) =>
|
|
3074
|
+
const P = Pt(i.extensions), w = S.map(
|
|
3075
|
+
(Ne) => q(Ne, P, this.schema.styleSchema).toJSON()
|
|
3035
3076
|
), v = vt(
|
|
3036
3077
|
{
|
|
3037
3078
|
type: "doc",
|
|
@@ -3043,10 +3084,10 @@ class Le extends Se {
|
|
|
3043
3084
|
]
|
|
3044
3085
|
},
|
|
3045
3086
|
P,
|
|
3046
|
-
|
|
3087
|
+
i.parseOptions
|
|
3047
3088
|
);
|
|
3048
3089
|
this._tiptapEditor = new It({
|
|
3049
|
-
...
|
|
3090
|
+
...i,
|
|
3050
3091
|
content: v.toJSON()
|
|
3051
3092
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
3052
3093
|
} catch (S) {
|
|
@@ -3061,8 +3102,8 @@ class Le extends Se {
|
|
|
3061
3102
|
if (c)
|
|
3062
3103
|
return c;
|
|
3063
3104
|
const P = a.apply(this.pmSchema.nodes.doc, S), w = JSON.parse(JSON.stringify(P.toJSON()));
|
|
3064
|
-
return w.content[0].content[0].attrs.id = "initialBlockId", c =
|
|
3065
|
-
}, this.pmSchema.cached.blockNoteEditor = this, this._blockManager = new
|
|
3105
|
+
return w.content[0].content[0].attrs.id = "initialBlockId", c = He.fromJSON(this.pmSchema, w), c;
|
|
3106
|
+
}, this.pmSchema.cached.blockNoteEditor = this, this._blockManager = new po(this), this._exportManager = new xo(this), this._selectionManager = new kn(this), this._stateManager = new gn(this), this._styleManager = new yn(this), this.emit("create");
|
|
3066
3107
|
}
|
|
3067
3108
|
static create(t) {
|
|
3068
3109
|
return new Le(t ?? {});
|
|
@@ -3168,14 +3209,14 @@ class Le extends Se {
|
|
|
3168
3209
|
// TODO move to extension
|
|
3169
3210
|
onUploadStart(t) {
|
|
3170
3211
|
return this.onUploadStartCallbacks.push(t), () => {
|
|
3171
|
-
const
|
|
3172
|
-
|
|
3212
|
+
const n = this.onUploadStartCallbacks.indexOf(t);
|
|
3213
|
+
n > -1 && this.onUploadStartCallbacks.splice(n, 1);
|
|
3173
3214
|
};
|
|
3174
3215
|
}
|
|
3175
3216
|
onUploadEnd(t) {
|
|
3176
3217
|
return this.onUploadEndCallbacks.push(t), () => {
|
|
3177
|
-
const
|
|
3178
|
-
|
|
3218
|
+
const n = this.onUploadEndCallbacks.indexOf(t);
|
|
3219
|
+
n > -1 && this.onUploadEndCallbacks.splice(n, 1);
|
|
3179
3220
|
};
|
|
3180
3221
|
}
|
|
3181
3222
|
/**
|
|
@@ -3239,8 +3280,8 @@ class Le extends Se {
|
|
|
3239
3280
|
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
3240
3281
|
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
3241
3282
|
*/
|
|
3242
|
-
forEachBlock(t,
|
|
3243
|
-
this._blockManager.forEachBlock(t,
|
|
3283
|
+
forEachBlock(t, n = !1) {
|
|
3284
|
+
this._blockManager.forEachBlock(t, n);
|
|
3244
3285
|
}
|
|
3245
3286
|
/**
|
|
3246
3287
|
* Executes a callback whenever the editor's contents change.
|
|
@@ -3266,8 +3307,7 @@ class Le extends Se {
|
|
|
3266
3307
|
* @returns A function to remove the callback.
|
|
3267
3308
|
*/
|
|
3268
3309
|
onBeforeChange(t) {
|
|
3269
|
-
|
|
3270
|
-
return (o = this._extensionManager.getExtension(ye)) == null ? void 0 : o.subscribe(t);
|
|
3310
|
+
return this._extensionManager.getExtension(ye).subscribe(t);
|
|
3271
3311
|
}
|
|
3272
3312
|
/**
|
|
3273
3313
|
* Gets a snapshot of the current text cursor position.
|
|
@@ -3282,8 +3322,8 @@ class Le extends Se {
|
|
|
3282
3322
|
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
3283
3323
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
3284
3324
|
*/
|
|
3285
|
-
setTextCursorPosition(t,
|
|
3286
|
-
return this._selectionManager.setTextCursorPosition(t,
|
|
3325
|
+
setTextCursorPosition(t, n = "start") {
|
|
3326
|
+
return this._selectionManager.setTextCursorPosition(t, n);
|
|
3287
3327
|
}
|
|
3288
3328
|
/**
|
|
3289
3329
|
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
@@ -3301,16 +3341,16 @@ class Le extends Se {
|
|
|
3301
3341
|
* If the selection starts / ends halfway through a block, the returned block will be
|
|
3302
3342
|
* only the part of the block that is included in the selection.
|
|
3303
3343
|
*/
|
|
3304
|
-
getSelectionCutBlocks() {
|
|
3305
|
-
return this._selectionManager.getSelectionCutBlocks();
|
|
3344
|
+
getSelectionCutBlocks(t = !1) {
|
|
3345
|
+
return this._selectionManager.getSelectionCutBlocks(t);
|
|
3306
3346
|
}
|
|
3307
3347
|
/**
|
|
3308
3348
|
* Sets the selection to a range of blocks.
|
|
3309
3349
|
* @param startBlock The identifier of the block that should be the start of the selection.
|
|
3310
3350
|
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
3311
3351
|
*/
|
|
3312
|
-
setSelection(t,
|
|
3313
|
-
return this._selectionManager.setSelection(t,
|
|
3352
|
+
setSelection(t, n) {
|
|
3353
|
+
return this._selectionManager.setSelection(t, n);
|
|
3314
3354
|
}
|
|
3315
3355
|
/**
|
|
3316
3356
|
* Checks if the editor is currently editable, or if it's locked.
|
|
@@ -3334,10 +3374,10 @@ class Le extends Se {
|
|
|
3334
3374
|
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
3335
3375
|
* `referenceBlock`.
|
|
3336
3376
|
*/
|
|
3337
|
-
insertBlocks(t,
|
|
3377
|
+
insertBlocks(t, n, s = "before") {
|
|
3338
3378
|
return this._blockManager.insertBlocks(
|
|
3339
3379
|
t,
|
|
3340
|
-
|
|
3380
|
+
n,
|
|
3341
3381
|
s
|
|
3342
3382
|
);
|
|
3343
3383
|
}
|
|
@@ -3348,8 +3388,8 @@ class Le extends Se {
|
|
|
3348
3388
|
* @param blockToUpdate The block that should be updated.
|
|
3349
3389
|
* @param update A partial block which defines how the existing block should be changed.
|
|
3350
3390
|
*/
|
|
3351
|
-
updateBlock(t,
|
|
3352
|
-
return this._blockManager.updateBlock(t,
|
|
3391
|
+
updateBlock(t, n) {
|
|
3392
|
+
return this._blockManager.updateBlock(t, n);
|
|
3353
3393
|
}
|
|
3354
3394
|
/**
|
|
3355
3395
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
@@ -3365,8 +3405,8 @@ class Le extends Se {
|
|
|
3365
3405
|
* @param blocksToRemove An array of blocks that should be replaced.
|
|
3366
3406
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
3367
3407
|
*/
|
|
3368
|
-
replaceBlocks(t,
|
|
3369
|
-
return this._blockManager.replaceBlocks(t,
|
|
3408
|
+
replaceBlocks(t, n) {
|
|
3409
|
+
return this._blockManager.replaceBlocks(t, n);
|
|
3370
3410
|
}
|
|
3371
3411
|
/**
|
|
3372
3412
|
* Undo the last action.
|
|
@@ -3385,8 +3425,8 @@ class Le extends Se {
|
|
|
3385
3425
|
*
|
|
3386
3426
|
* @param content can be a string, or array of partial inline content elements
|
|
3387
3427
|
*/
|
|
3388
|
-
insertInlineContent(t, { updateSelection:
|
|
3389
|
-
this._styleManager.insertInlineContent(t, { updateSelection:
|
|
3428
|
+
insertInlineContent(t, { updateSelection: n = !1 } = {}) {
|
|
3429
|
+
this._styleManager.insertInlineContent(t, { updateSelection: n });
|
|
3390
3430
|
}
|
|
3391
3431
|
/**
|
|
3392
3432
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -3432,8 +3472,8 @@ class Le extends Se {
|
|
|
3432
3472
|
* @param url The link URL.
|
|
3433
3473
|
* @param text The text to display the link with.
|
|
3434
3474
|
*/
|
|
3435
|
-
createLink(t,
|
|
3436
|
-
this._styleManager.createLink(t,
|
|
3475
|
+
createLink(t, n) {
|
|
3476
|
+
this._styleManager.createLink(t, n);
|
|
3437
3477
|
}
|
|
3438
3478
|
/**
|
|
3439
3479
|
* Checks if the block containing the text cursor can be nested.
|
|
@@ -3532,8 +3572,8 @@ class Le extends Se {
|
|
|
3532
3572
|
* @param callback The callback to execute.
|
|
3533
3573
|
* @returns A function to remove the callback.
|
|
3534
3574
|
*/
|
|
3535
|
-
onChange(t,
|
|
3536
|
-
return this._eventManager.onChange(t,
|
|
3575
|
+
onChange(t, n) {
|
|
3576
|
+
return this._eventManager.onChange(t, n);
|
|
3537
3577
|
}
|
|
3538
3578
|
/**
|
|
3539
3579
|
* A callback function that runs whenever the text cursor position or selection changes.
|
|
@@ -3541,10 +3581,10 @@ class Le extends Se {
|
|
|
3541
3581
|
* @param callback The callback to execute.
|
|
3542
3582
|
* @returns A function to remove the callback.
|
|
3543
3583
|
*/
|
|
3544
|
-
onSelectionChange(t,
|
|
3584
|
+
onSelectionChange(t, n) {
|
|
3545
3585
|
return this._eventManager.onSelectionChange(
|
|
3546
3586
|
t,
|
|
3547
|
-
|
|
3587
|
+
n
|
|
3548
3588
|
);
|
|
3549
3589
|
}
|
|
3550
3590
|
/**
|
|
@@ -3585,8 +3625,8 @@ class Le extends Se {
|
|
|
3585
3625
|
* @param html The HTML to paste.
|
|
3586
3626
|
* @param raw Whether to paste the HTML as is, or to convert it to BlockNote HTML.
|
|
3587
3627
|
*/
|
|
3588
|
-
pasteHTML(t,
|
|
3589
|
-
this._exportManager.pasteHTML(t,
|
|
3628
|
+
pasteHTML(t, n = !1) {
|
|
3629
|
+
this._exportManager.pasteHTML(t, n);
|
|
3590
3630
|
}
|
|
3591
3631
|
/**
|
|
3592
3632
|
* Paste text into the editor. Defaults to interpreting text as markdown.
|
|
@@ -3603,19 +3643,19 @@ class Le extends Se {
|
|
|
3603
3643
|
return this._exportManager.pasteMarkdown(t);
|
|
3604
3644
|
}
|
|
3605
3645
|
}
|
|
3606
|
-
class
|
|
3607
|
-
constructor(e, t,
|
|
3608
|
-
this.mappings = t, this.options =
|
|
3646
|
+
class Xn {
|
|
3647
|
+
constructor(e, t, n) {
|
|
3648
|
+
this.mappings = t, this.options = n;
|
|
3609
3649
|
}
|
|
3610
3650
|
async resolveFile(e) {
|
|
3611
|
-
var
|
|
3612
|
-
if (!((
|
|
3651
|
+
var n;
|
|
3652
|
+
if (!((n = this.options) != null && n.resolveFileUrl))
|
|
3613
3653
|
return (await fetch(e)).blob();
|
|
3614
3654
|
const t = await this.options.resolveFileUrl(e);
|
|
3615
3655
|
return t instanceof Blob ? t : (await fetch(t)).blob();
|
|
3616
3656
|
}
|
|
3617
3657
|
mapStyles(e) {
|
|
3618
|
-
return Object.entries(e).map(([
|
|
3658
|
+
return Object.entries(e).map(([n, s]) => this.mappings.styleMapping[n](s, this));
|
|
3619
3659
|
}
|
|
3620
3660
|
mapInlineContent(e) {
|
|
3621
3661
|
return this.mappings.inlineContentMapping[e.type](
|
|
@@ -3626,200 +3666,201 @@ class Yn {
|
|
|
3626
3666
|
transformInlineContent(e) {
|
|
3627
3667
|
return e.map((t) => this.mapInlineContent(t));
|
|
3628
3668
|
}
|
|
3629
|
-
async mapBlock(e, t,
|
|
3669
|
+
async mapBlock(e, t, n, s) {
|
|
3630
3670
|
return this.mappings.blockMapping[e.type](
|
|
3631
3671
|
e,
|
|
3632
3672
|
this,
|
|
3633
3673
|
t,
|
|
3634
|
-
|
|
3674
|
+
n,
|
|
3635
3675
|
s
|
|
3636
3676
|
);
|
|
3637
3677
|
}
|
|
3638
3678
|
}
|
|
3639
|
-
function
|
|
3679
|
+
function Zn(o) {
|
|
3640
3680
|
return {
|
|
3641
3681
|
createBlockMapping: (e) => e,
|
|
3642
3682
|
createInlineContentMapping: (e) => e,
|
|
3643
3683
|
createStyleMapping: (e) => e
|
|
3644
3684
|
};
|
|
3645
3685
|
}
|
|
3646
|
-
function
|
|
3647
|
-
const t = [...
|
|
3648
|
-
for (const
|
|
3649
|
-
for (const s of
|
|
3650
|
-
const
|
|
3651
|
-
(
|
|
3686
|
+
function es(o, ...e) {
|
|
3687
|
+
const t = [...o];
|
|
3688
|
+
for (const n of e)
|
|
3689
|
+
for (const s of n) {
|
|
3690
|
+
const r = t.findLastIndex(
|
|
3691
|
+
(i) => i.group === s.group
|
|
3652
3692
|
);
|
|
3653
|
-
|
|
3693
|
+
r === -1 ? t.push(s) : t.splice(r + 1, 0, s);
|
|
3654
3694
|
}
|
|
3655
3695
|
return t;
|
|
3656
3696
|
}
|
|
3657
3697
|
export {
|
|
3658
3698
|
Le as BlockNoteEditor,
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3699
|
+
xt as BlockNoteSchema,
|
|
3700
|
+
bs as COLORS_DARK_MODE_DEFAULT,
|
|
3701
|
+
ys as COLORS_DEFAULT,
|
|
3702
|
+
Xr as CustomBlockNoteSchema,
|
|
3703
|
+
Ss as EMPTY_CELL_HEIGHT,
|
|
3704
|
+
Bs as EMPTY_CELL_WIDTH,
|
|
3665
3705
|
Se as EventEmitter,
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3706
|
+
Xn as Exporter,
|
|
3707
|
+
Cs as FILE_AUDIO_ICON_SVG,
|
|
3708
|
+
xs as FILE_IMAGE_ICON_SVG,
|
|
3709
|
+
Es as FILE_VIDEO_ICON_SVG,
|
|
3670
3710
|
Pe as HTMLToBlocks,
|
|
3671
3711
|
me as UniqueID,
|
|
3672
3712
|
F as UnreachableCaseError,
|
|
3673
|
-
|
|
3674
|
-
|
|
3713
|
+
Ms as addDefaultPropsExternalHTML,
|
|
3714
|
+
H as addInlineContentAttributes,
|
|
3675
3715
|
We as addInlineContentKeyboardShortcuts,
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3716
|
+
ws as addNodeAndExtensionsToSpec,
|
|
3717
|
+
Ts as addStyleAttributes,
|
|
3718
|
+
Ps as applyNonSelectableBlockFix,
|
|
3719
|
+
ns as assertEmpty,
|
|
3720
|
+
vs as audioParse,
|
|
3721
|
+
Is as audioRender,
|
|
3722
|
+
As as audioToExternalHTML,
|
|
3723
|
+
_s as blockHasType,
|
|
3724
|
+
q as blockToNode,
|
|
3685
3725
|
nt as blocksToMarkdown,
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3726
|
+
Ds as camelToDataKebab,
|
|
3727
|
+
Ls as captureCellAnchor,
|
|
3728
|
+
Zr as checkPageBreakBlocksInSchema,
|
|
3689
3729
|
st as cleanHTMLToMarkdown,
|
|
3690
|
-
|
|
3730
|
+
es as combineByGroup,
|
|
3691
3731
|
Re as contentNodeToInlineContent,
|
|
3692
3732
|
Ge as contentNodeToTableContent,
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3733
|
+
Ns as createAudioBlockConfig,
|
|
3734
|
+
Os as createAudioBlockSpec,
|
|
3735
|
+
Fs as createBlockConfig,
|
|
3736
|
+
$s as createBlockSpec,
|
|
3737
|
+
Hs as createBlockSpecFromTiptapNode,
|
|
3738
|
+
Vs as createBulletListItemBlockConfig,
|
|
3739
|
+
Us as createBulletListItemBlockSpec,
|
|
3740
|
+
zs as createCheckListItemBlockSpec,
|
|
3741
|
+
Gs as createCheckListItemConfig,
|
|
3742
|
+
Rs as createCodeBlockConfig,
|
|
3743
|
+
js as createCodeBlockSpec,
|
|
3744
|
+
Ws as createDefaultBlockDOMOutputSpec,
|
|
3745
|
+
Ks as createDividerBlockConfig,
|
|
3746
|
+
Js as createDividerBlockSpec,
|
|
3747
|
+
Nt as createExtension,
|
|
3708
3748
|
be as createExternalHTMLExporter,
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3749
|
+
qs as createFileBlockConfig,
|
|
3750
|
+
Ys as createFileBlockSpec,
|
|
3751
|
+
Qs as createHeadingBlockConfig,
|
|
3752
|
+
Xs as createHeadingBlockSpec,
|
|
3753
|
+
Zs as createImageBlockConfig,
|
|
3754
|
+
er as createImageBlockSpec,
|
|
3755
|
+
Qn as createInlineContentSpec,
|
|
3716
3756
|
Je as createInlineContentSpecFromTipTapNode,
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3757
|
+
Xt as createInternalHTMLSerializer,
|
|
3758
|
+
tr as createInternalInlineContentSpec,
|
|
3759
|
+
or as createInternalStyleSpec,
|
|
3760
|
+
nr as createNumberedListItemBlockConfig,
|
|
3761
|
+
sr as createNumberedListItemBlockSpec,
|
|
3762
|
+
ei as createPageBreakBlockConfig,
|
|
3763
|
+
ti as createPageBreakBlockSpec,
|
|
3764
|
+
rr as createParagraphBlockConfig,
|
|
3765
|
+
ir as createParagraphBlockSpec,
|
|
3766
|
+
ar as createQuoteBlockConfig,
|
|
3767
|
+
cr as createQuoteBlockSpec,
|
|
3768
|
+
ii as createStore,
|
|
3769
|
+
lr as createStyleSpec,
|
|
3770
|
+
dr as createStyleSpecFromTipTapMark,
|
|
3771
|
+
ur as createTableBlockSpec,
|
|
3772
|
+
pr as createToggleListItemBlockConfig,
|
|
3773
|
+
fr as createToggleListItemBlockSpec,
|
|
3774
|
+
hr as createToggleWrapper,
|
|
3775
|
+
mr as createVideoBlockConfig,
|
|
3776
|
+
kr as createVideoBlockSpec,
|
|
3777
|
+
gr as defaultBlockSpecs,
|
|
3778
|
+
br as defaultBlockToHTML,
|
|
3779
|
+
yr as defaultInlineContentSchema,
|
|
3780
|
+
Sr as defaultInlineContentSpecs,
|
|
3781
|
+
Br as defaultProps,
|
|
3782
|
+
Cr as defaultStyleSchema,
|
|
3783
|
+
xr as defaultStyleSpecs,
|
|
3784
|
+
Er as defaultToggledState,
|
|
3745
3785
|
ze as docToBlocks,
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3786
|
+
Mr as editorHasBlockWithType,
|
|
3787
|
+
un as expandPMRangeToWords,
|
|
3788
|
+
wr as fileParse,
|
|
3789
|
+
Tr as filenameFromURL,
|
|
3749
3790
|
W as fixColumnList,
|
|
3750
|
-
|
|
3791
|
+
Pr as formatKeyboardShortcut,
|
|
3751
3792
|
Qe as getBackgroundColorAttribute,
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3793
|
+
ao as getBlock,
|
|
3794
|
+
ss as getBlockCache,
|
|
3795
|
+
vr as getBlockFromPos,
|
|
3755
3796
|
z as getBlockInfo,
|
|
3756
|
-
|
|
3797
|
+
Y as getBlockInfoFromResolvedPos,
|
|
3757
3798
|
B as getBlockInfoFromSelection,
|
|
3758
|
-
|
|
3759
|
-
|
|
3799
|
+
$ as getBlockInfoFromTransaction,
|
|
3800
|
+
rs as getBlockInfoWithManualOffset,
|
|
3760
3801
|
ke as getBlockNoteSchema,
|
|
3761
|
-
|
|
3802
|
+
is as getBlockSchema,
|
|
3762
3803
|
ot as getBlocksChangedByTransaction,
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3804
|
+
as as getColspan,
|
|
3805
|
+
Kt as getInlineContentParseRules,
|
|
3806
|
+
cs as getInlineContentSchema,
|
|
3807
|
+
Ir as getInlineContentSchemaFromSpecs,
|
|
3808
|
+
Ar as getLanguageId,
|
|
3768
3809
|
_ as getNearestBlockPos,
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3810
|
+
lo as getNextBlock,
|
|
3811
|
+
x as getNodeById,
|
|
3812
|
+
oi as getPageBreakSlashMenuItems,
|
|
3813
|
+
uo as getParentBlock,
|
|
3814
|
+
_r as getParseRules,
|
|
3774
3815
|
C as getPmSchema,
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3816
|
+
co as getPrevBlock,
|
|
3817
|
+
ls as getRowspan,
|
|
3818
|
+
Dr as getStyleParseRules,
|
|
3819
|
+
ds as getStyleSchema,
|
|
3820
|
+
Lr as getStyleSchemaFromSpecs,
|
|
3821
|
+
Nr as getTextAlignmentAttribute,
|
|
3781
3822
|
et as getTextColorAttribute,
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3823
|
+
Or as imageParse,
|
|
3824
|
+
Fr as imageRender,
|
|
3825
|
+
$r as imageToExternalHTML,
|
|
3785
3826
|
O as inlineContentToNodes,
|
|
3786
|
-
|
|
3787
|
-
|
|
3827
|
+
Jt as insertBlocks,
|
|
3828
|
+
Hr as isAppleOS,
|
|
3788
3829
|
j as isEmptyColumn,
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3830
|
+
us as isLinkInlineContent,
|
|
3831
|
+
Vr as isNodeBlock,
|
|
3832
|
+
ps as isPartialLinkInlineContent,
|
|
3833
|
+
fs as isPartialTableCell,
|
|
3834
|
+
Ur as isSafari,
|
|
3835
|
+
hs as isStyledTextInlineContent,
|
|
3836
|
+
ms as isTableCell,
|
|
3837
|
+
zr as isTableCellSelection,
|
|
3838
|
+
Ye as isVideoUrl,
|
|
3839
|
+
ks as mapTableCell,
|
|
3840
|
+
Zn as mappingFactory,
|
|
3841
|
+
Co as markdownToBlocks,
|
|
3801
3842
|
ve as markdownToHTML,
|
|
3802
3843
|
Q as mergeCSSClasses,
|
|
3803
|
-
|
|
3844
|
+
Gr as mergeParagraphs,
|
|
3804
3845
|
b as nodeToBlock,
|
|
3805
3846
|
U as nodeToCustomInlineContent,
|
|
3806
|
-
|
|
3807
|
-
|
|
3847
|
+
Rr as parseAudioElement,
|
|
3848
|
+
jr as parseDefaultProps,
|
|
3808
3849
|
Ke as propsToAttributes,
|
|
3809
3850
|
je as prosemirrorSliceToSlicedBlocks,
|
|
3810
3851
|
ie as removeAndInsertBlocks,
|
|
3811
|
-
|
|
3852
|
+
qt as removeEmptyColumns,
|
|
3812
3853
|
Ae as selectedFragmentToHTML,
|
|
3813
|
-
|
|
3854
|
+
Wr as stylePropsToAttributes,
|
|
3814
3855
|
Ue as tableContentToNodes,
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3856
|
+
Kr as tablePropSchema,
|
|
3857
|
+
Jr as trackPosition,
|
|
3858
|
+
qe as updateBlock,
|
|
3818
3859
|
Ze as updateBlockCommand,
|
|
3819
3860
|
tt as updateBlockTr,
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3861
|
+
ni as uploadToTmpFilesDotOrg_DEV_ONLY,
|
|
3862
|
+
qr as videoParse,
|
|
3863
|
+
si as withPageBreak,
|
|
3864
|
+
Yr as wrapInBlockStructure
|
|
3824
3865
|
};
|
|
3825
3866
|
//# sourceMappingURL=blocknote.js.map
|