@blocknote/core 0.44.1 → 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-C-l154WP.js → BlockNoteSchema-BOW16JHv.js} +2 -2
- package/dist/{BlockNoteSchema-C-l154WP.js.map → BlockNoteSchema-BOW16JHv.js.map} +1 -1
- package/dist/{BlockNoteSchema-B4gm-Qco.cjs → BlockNoteSchema-CzZbr4Ed.cjs} +2 -2
- package/dist/{BlockNoteSchema-B4gm-Qco.cjs.map → BlockNoteSchema-CzZbr4Ed.cjs.map} +1 -1
- package/dist/{TrailingNode-B_zPMWxw.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 +1180 -1128
- 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-DgA_mtQV.js → defaultBlocks-DvCGYzqu.js} +164 -202
- 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/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/parsers/markdown/parseMarkdown.ts +11 -0
- package/src/blocks/ListItem/CheckListItem/block.ts +2 -2
- package/src/editor/BlockNoteEditor.test.ts +60 -1
- package/src/editor/BlockNoteEditor.ts +22 -35
- 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 +12 -32
- 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-B_zPMWxw.js.map +0 -1
- package/dist/TrailingNode-CRHrgOnK.cjs +0 -2
- package/dist/TrailingNode-CRHrgOnK.cjs.map +0 -1
- package/dist/defaultBlocks-DLJ4Q1_J.cjs +0 -6
- package/dist/defaultBlocks-DLJ4Q1_J.cjs.map +0 -1
- package/dist/defaultBlocks-DgA_mtQV.js.map +0 -1
package/dist/blocknote.js
CHANGED
|
@@ -1,208 +1,208 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (
|
|
4
|
-
import { Slice as N, Fragment as A, DOMSerializer as he, DOMParser as
|
|
5
|
-
import { ReplaceStep as
|
|
6
|
-
import { n as U, i as O, g as
|
|
7
|
-
import { B as
|
|
8
|
-
import { ak as
|
|
9
|
-
import { aw as
|
|
10
|
-
import { j as
|
|
11
|
-
import { s as Ct, B as
|
|
12
|
-
import { C as
|
|
13
|
-
import { Node as D, Extension as
|
|
14
|
-
import { E as
|
|
1
|
+
var Oe = Object.defineProperty;
|
|
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
|
+
import { ReplaceStep as Ve, ReplaceAroundStep as V } from "prosemirror-transform";
|
|
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
|
+
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
|
|
64
|
+
return Ke(o.propSchema);
|
|
65
65
|
},
|
|
66
66
|
addKeyboardShortcuts() {
|
|
67
|
-
return
|
|
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
|
-
return
|
|
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
|
|
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
|
-
const g =
|
|
363
|
-
|
|
362
|
+
const g = Be(
|
|
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
|
-
|
|
380
|
+
Ce(o, e.children, t, n)
|
|
381
381
|
)), d.dom;
|
|
382
382
|
}
|
|
383
|
-
function
|
|
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
|
|
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 Ee(
|
|
474
|
-
return !
|
|
473
|
+
function Ee(o) {
|
|
474
|
+
return !o || o.type !== "columnList";
|
|
475
475
|
}
|
|
476
|
-
function
|
|
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 Ee(
|
|
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
|
|
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 Ee(
|
|
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
|
|
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
|
}
|
|
@@ -619,7 +619,7 @@ class uo {
|
|
|
619
619
|
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
620
620
|
*/
|
|
621
621
|
get document() {
|
|
622
|
-
return this.editor.transact((e) =>
|
|
622
|
+
return this.editor.transact((e) => ze(e.doc, this.editor.pmSchema));
|
|
623
623
|
}
|
|
624
624
|
/**
|
|
625
625
|
* Gets a snapshot of an existing block from the editor.
|
|
@@ -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,32 +727,32 @@ 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.
|
|
741
741
|
*/
|
|
742
742
|
nestBlock() {
|
|
743
|
-
|
|
743
|
+
Te(this.editor);
|
|
744
744
|
}
|
|
745
745
|
/**
|
|
746
746
|
* Checks if the block containing the text cursor is nested.
|
|
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 ye {
|
|
|
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
|
-
return
|
|
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 ye {
|
|
|
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
|
|
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
|
|
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 Ye(s) ?
|
|
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 =
|
|
939
|
-
return
|
|
947
|
+
function Co(o, e) {
|
|
948
|
+
const t = ve(o);
|
|
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, {});
|
|
@@ -978,7 +988,7 @@ class Co {
|
|
|
978
988
|
* @returns The blocks parsed from the HTML string.
|
|
979
989
|
*/
|
|
980
990
|
tryParseHTMLToBlocks(e) {
|
|
981
|
-
return
|
|
991
|
+
return Pe(e, this.editor.pmSchema);
|
|
982
992
|
}
|
|
983
993
|
/**
|
|
984
994
|
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
@@ -987,7 +997,7 @@ class Co {
|
|
|
987
997
|
* @returns The blocks, serialized as a Markdown string.
|
|
988
998
|
*/
|
|
989
999
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
990
|
-
return
|
|
1000
|
+
return nt(e, this.editor.pmSchema, this.editor, {});
|
|
991
1001
|
}
|
|
992
1002
|
/**
|
|
993
1003
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -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.
|
|
@@ -1026,7 +1036,7 @@ class Co {
|
|
|
1026
1036
|
* @param markdown The markdown to paste.
|
|
1027
1037
|
*/
|
|
1028
1038
|
pasteMarkdown(e) {
|
|
1029
|
-
const t =
|
|
1039
|
+
const t = ve(e);
|
|
1030
1040
|
return this.pasteHTML(t);
|
|
1031
1041
|
}
|
|
1032
1042
|
}
|
|
@@ -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
|
|
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 ve(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,18 +1113,19 @@ async function ve(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;
|
|
1116
1126
|
d = e.transact((k) => {
|
|
1117
|
-
|
|
1127
|
+
var S;
|
|
1128
|
+
const g = _(k.doc, f.pos), y = (S = e.domElement) == null ? void 0 : S.querySelector(
|
|
1118
1129
|
`[data-id="${g.node.attrs.id}"]`
|
|
1119
1130
|
), T = y == null ? void 0 : y.getBoundingClientRect();
|
|
1120
1131
|
return le(
|
|
@@ -1136,7 +1147,7 @@ async function ve(n, e) {
|
|
|
1136
1147
|
}
|
|
1137
1148
|
}
|
|
1138
1149
|
}
|
|
1139
|
-
const
|
|
1150
|
+
const wo = (o) => E.create({
|
|
1140
1151
|
name: "dropFile",
|
|
1141
1152
|
addProseMirrorPlugins() {
|
|
1142
1153
|
return [
|
|
@@ -1144,98 +1155,98 @@ const Mo = (n) => x.create({
|
|
|
1144
1155
|
props: {
|
|
1145
1156
|
handleDOMEvents: {
|
|
1146
1157
|
drop(e, t) {
|
|
1147
|
-
if (!
|
|
1158
|
+
if (!o.isEditable)
|
|
1148
1159
|
return;
|
|
1149
|
-
let
|
|
1160
|
+
let n = null;
|
|
1150
1161
|
for (const s of oe)
|
|
1151
1162
|
if (t.dataTransfer.types.includes(s)) {
|
|
1152
|
-
|
|
1163
|
+
n = s;
|
|
1153
1164
|
break;
|
|
1154
1165
|
}
|
|
1155
|
-
return
|
|
1166
|
+
return n === null ? !0 : n === "Files" ? (Ie(t, o), !0) : !1;
|
|
1156
1167
|
}
|
|
1157
1168
|
}
|
|
1158
1169
|
}
|
|
1159
1170
|
})
|
|
1160
1171
|
];
|
|
1161
1172
|
}
|
|
1162
|
-
}),
|
|
1163
|
-
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) {
|
|
1164
1175
|
const { schema: t } = e.state;
|
|
1165
|
-
if (!
|
|
1176
|
+
if (!o.clipboardData)
|
|
1166
1177
|
return !1;
|
|
1167
|
-
const
|
|
1168
|
-
if (!
|
|
1178
|
+
const n = o.clipboardData.getData("text/plain");
|
|
1179
|
+
if (!n)
|
|
1169
1180
|
return !1;
|
|
1170
1181
|
if (!t.nodes.codeBlock)
|
|
1171
|
-
return e.pasteText(
|
|
1172
|
-
const s =
|
|
1173
|
-
return
|
|
1174
|
-
`<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(
|
|
1175
1186
|
/\r\n?/g,
|
|
1176
1187
|
`
|
|
1177
1188
|
`
|
|
1178
1189
|
)}</code></pre>`
|
|
1179
1190
|
), !0) : !1;
|
|
1180
1191
|
}
|
|
1181
|
-
function
|
|
1182
|
-
event:
|
|
1192
|
+
function zo({
|
|
1193
|
+
event: o,
|
|
1183
1194
|
editor: e,
|
|
1184
1195
|
prioritizeMarkdownOverHTML: t,
|
|
1185
|
-
plainTextAsMarkdown:
|
|
1196
|
+
plainTextAsMarkdown: n
|
|
1186
1197
|
}) {
|
|
1187
1198
|
var c;
|
|
1188
1199
|
if (e.transact(
|
|
1189
1200
|
(a) => a.selection.$from.parent.type.spec.code && a.selection.$to.parent.type.spec.code
|
|
1190
1201
|
)) {
|
|
1191
|
-
const a = (c =
|
|
1202
|
+
const a = (c = o.clipboardData) == null ? void 0 : c.getData("text/plain");
|
|
1192
1203
|
if (a)
|
|
1193
1204
|
return e.pasteText(a), !0;
|
|
1194
1205
|
}
|
|
1195
|
-
let
|
|
1206
|
+
let r;
|
|
1196
1207
|
for (const a of oe)
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1208
|
+
if (o.clipboardData.types.includes(a)) {
|
|
1209
|
+
r = a;
|
|
1199
1210
|
break;
|
|
1200
1211
|
}
|
|
1201
|
-
if (!
|
|
1212
|
+
if (!r)
|
|
1202
1213
|
return !0;
|
|
1203
|
-
if (
|
|
1204
|
-
return
|
|
1205
|
-
if (
|
|
1206
|
-
return
|
|
1207
|
-
const
|
|
1208
|
-
if (
|
|
1209
|
-
return e.pasteHTML(
|
|
1210
|
-
if (
|
|
1211
|
-
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;
|
|
1212
1223
|
if (t) {
|
|
1213
|
-
const a =
|
|
1214
|
-
if (
|
|
1224
|
+
const a = o.clipboardData.getData("text/plain");
|
|
1225
|
+
if (Vo(a))
|
|
1215
1226
|
return e.pasteMarkdown(a), !0;
|
|
1216
1227
|
}
|
|
1217
|
-
return
|
|
1228
|
+
return r === "text/html" ? (e.pasteHTML(i), !0) : n ? (e.pasteMarkdown(i), !0) : (e.pasteText(i), !0);
|
|
1218
1229
|
}
|
|
1219
|
-
const
|
|
1230
|
+
const Go = (o, e) => E.create({
|
|
1220
1231
|
name: "pasteFromClipboard",
|
|
1221
1232
|
addProseMirrorPlugins() {
|
|
1222
1233
|
return [
|
|
1223
1234
|
new ee({
|
|
1224
1235
|
props: {
|
|
1225
1236
|
handleDOMEvents: {
|
|
1226
|
-
paste(t,
|
|
1227
|
-
if (
|
|
1237
|
+
paste(t, n) {
|
|
1238
|
+
if (n.preventDefault(), !!o.isEditable)
|
|
1228
1239
|
return e({
|
|
1229
|
-
event:
|
|
1230
|
-
editor:
|
|
1240
|
+
event: n,
|
|
1241
|
+
editor: o,
|
|
1231
1242
|
defaultPasteHandler: ({
|
|
1232
1243
|
prioritizeMarkdownOverHTML: s = !0,
|
|
1233
|
-
plainTextAsMarkdown:
|
|
1234
|
-
} = {}) =>
|
|
1235
|
-
event:
|
|
1236
|
-
editor:
|
|
1244
|
+
plainTextAsMarkdown: r = !0
|
|
1245
|
+
} = {}) => zo({
|
|
1246
|
+
event: n,
|
|
1247
|
+
editor: o,
|
|
1237
1248
|
prioritizeMarkdownOverHTML: s,
|
|
1238
|
-
plainTextAsMarkdown:
|
|
1249
|
+
plainTextAsMarkdown: r
|
|
1239
1250
|
})
|
|
1240
1251
|
});
|
|
1241
1252
|
}
|
|
@@ -1245,85 +1256,85 @@ const zo = (n, e) => x.create({
|
|
|
1245
1256
|
];
|
|
1246
1257
|
}
|
|
1247
1258
|
});
|
|
1248
|
-
function
|
|
1259
|
+
function Ro(o, e, t) {
|
|
1249
1260
|
var c;
|
|
1250
|
-
let
|
|
1251
|
-
const s =
|
|
1261
|
+
let n = !1;
|
|
1262
|
+
const s = o.state.selection instanceof te;
|
|
1252
1263
|
if (!s) {
|
|
1253
|
-
const a =
|
|
1254
|
-
|
|
1255
|
-
|
|
1264
|
+
const a = o.state.doc.slice(
|
|
1265
|
+
o.state.selection.from,
|
|
1266
|
+
o.state.selection.to,
|
|
1256
1267
|
!1
|
|
1257
1268
|
).content, l = [];
|
|
1258
1269
|
for (let d = 0; d < a.childCount; d++)
|
|
1259
1270
|
l.push(a.child(d));
|
|
1260
|
-
|
|
1271
|
+
n = l.find(
|
|
1261
1272
|
(d) => d.type.isInGroup("bnBlock") || d.type.name === "blockGroup" || d.type.spec.group === "blockContent"
|
|
1262
|
-
) === void 0,
|
|
1273
|
+
) === void 0, n && (e = a);
|
|
1263
1274
|
}
|
|
1264
|
-
let
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1275
|
+
let r;
|
|
1276
|
+
const i = be(
|
|
1277
|
+
o.state.schema,
|
|
1267
1278
|
t
|
|
1268
1279
|
);
|
|
1269
1280
|
if (s) {
|
|
1270
1281
|
((c = e.firstChild) == null ? void 0 : c.type.name) === "table" && (e = e.firstChild.content);
|
|
1271
|
-
const a =
|
|
1282
|
+
const a = Ge(
|
|
1272
1283
|
e,
|
|
1273
1284
|
t.schema.inlineContentSchema,
|
|
1274
1285
|
t.schema.styleSchema
|
|
1275
1286
|
);
|
|
1276
|
-
|
|
1287
|
+
r = `<table>${i.exportInlineContent(
|
|
1277
1288
|
a,
|
|
1278
1289
|
{}
|
|
1279
1290
|
)}</table>`;
|
|
1280
|
-
} else if (
|
|
1281
|
-
const a =
|
|
1291
|
+
} else if (n) {
|
|
1292
|
+
const a = Re(
|
|
1282
1293
|
e,
|
|
1283
1294
|
t.schema.inlineContentSchema,
|
|
1284
1295
|
t.schema.styleSchema
|
|
1285
1296
|
);
|
|
1286
|
-
|
|
1297
|
+
r = i.exportInlineContent(a, {});
|
|
1287
1298
|
} else {
|
|
1288
|
-
const a =
|
|
1289
|
-
|
|
1299
|
+
const a = rt(e);
|
|
1300
|
+
r = i.exportBlocks(a, {});
|
|
1290
1301
|
}
|
|
1291
|
-
return
|
|
1302
|
+
return r;
|
|
1292
1303
|
}
|
|
1293
|
-
function
|
|
1294
|
-
"node" in
|
|
1295
|
-
(
|
|
1296
|
-
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))
|
|
1297
1308
|
)
|
|
1298
1309
|
);
|
|
1299
|
-
const t =
|
|
1300
|
-
|
|
1301
|
-
).dom.innerHTML,
|
|
1302
|
-
n,
|
|
1310
|
+
const t = o.serializeForClipboard(
|
|
1311
|
+
o.state.selection.content()
|
|
1312
|
+
).dom.innerHTML, n = o.state.selection.content().content, s = Ro(
|
|
1303
1313
|
o,
|
|
1314
|
+
n,
|
|
1304
1315
|
e
|
|
1305
|
-
),
|
|
1306
|
-
return { clipboardHTML: t, externalHTML: s, markdown:
|
|
1316
|
+
), r = st(s);
|
|
1317
|
+
return { clipboardHTML: t, externalHTML: s, markdown: r };
|
|
1307
1318
|
}
|
|
1308
1319
|
const de = () => {
|
|
1309
|
-
const
|
|
1310
|
-
if (!
|
|
1320
|
+
const o = window.getSelection();
|
|
1321
|
+
if (!o || o.isCollapsed)
|
|
1311
1322
|
return !0;
|
|
1312
|
-
let e =
|
|
1323
|
+
let e = o.focusNode;
|
|
1313
1324
|
for (; e; ) {
|
|
1314
1325
|
if (e instanceof HTMLElement && e.getAttribute("contenteditable") === "false")
|
|
1315
1326
|
return !0;
|
|
1316
1327
|
e = e.parentElement;
|
|
1317
1328
|
}
|
|
1318
1329
|
return !1;
|
|
1319
|
-
}, ue = (
|
|
1330
|
+
}, ue = (o, e, t) => {
|
|
1320
1331
|
t.preventDefault(), t.clipboardData.clearData();
|
|
1321
|
-
const { clipboardHTML:
|
|
1332
|
+
const { clipboardHTML: n, externalHTML: s, markdown: r } = Ae(
|
|
1322
1333
|
e,
|
|
1323
|
-
|
|
1334
|
+
o
|
|
1324
1335
|
);
|
|
1325
|
-
t.clipboardData.setData("blocknote/html",
|
|
1326
|
-
},
|
|
1336
|
+
t.clipboardData.setData("blocknote/html", n), t.clipboardData.setData("text/html", s), t.clipboardData.setData("text/plain", r);
|
|
1337
|
+
}, jo = (o) => E.create({
|
|
1327
1338
|
name: "copyToClipboard",
|
|
1328
1339
|
addProseMirrorPlugins() {
|
|
1329
1340
|
return [
|
|
@@ -1331,10 +1342,10 @@ const de = () => {
|
|
|
1331
1342
|
props: {
|
|
1332
1343
|
handleDOMEvents: {
|
|
1333
1344
|
copy(e, t) {
|
|
1334
|
-
return de() || ue(
|
|
1345
|
+
return de() || ue(o, e, t), !0;
|
|
1335
1346
|
},
|
|
1336
1347
|
cut(e, t) {
|
|
1337
|
-
return de() || (ue(
|
|
1348
|
+
return de() || (ue(o, e, t), e.editable && e.dispatch(e.state.tr.deleteSelection())), !0;
|
|
1338
1349
|
},
|
|
1339
1350
|
// This is for the use-case in which only a block without content
|
|
1340
1351
|
// is selected, e.g. an image block, and dragged (not using the
|
|
@@ -1342,34 +1353,34 @@ const de = () => {
|
|
|
1342
1353
|
dragstart(e, t) {
|
|
1343
1354
|
if (!("node" in e.state.selection) || e.state.selection.node.type.spec.group !== "blockContent")
|
|
1344
1355
|
return;
|
|
1345
|
-
|
|
1346
|
-
(
|
|
1356
|
+
o.transact(
|
|
1357
|
+
(i) => i.setSelection(
|
|
1347
1358
|
new L(
|
|
1348
|
-
|
|
1359
|
+
i.doc.resolve(e.state.selection.from - 1)
|
|
1349
1360
|
)
|
|
1350
1361
|
)
|
|
1351
1362
|
), t.preventDefault(), t.dataTransfer.clearData();
|
|
1352
|
-
const { clipboardHTML:
|
|
1353
|
-
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;
|
|
1354
1365
|
}
|
|
1355
1366
|
}
|
|
1356
1367
|
}
|
|
1357
1368
|
})
|
|
1358
1369
|
];
|
|
1359
1370
|
}
|
|
1360
|
-
}),
|
|
1371
|
+
}), Wo = E.create({
|
|
1361
1372
|
name: "blockBackgroundColor",
|
|
1362
1373
|
addGlobalAttributes() {
|
|
1363
1374
|
return [
|
|
1364
1375
|
{
|
|
1365
1376
|
types: ["tableCell", "tableHeader"],
|
|
1366
1377
|
attributes: {
|
|
1367
|
-
backgroundColor:
|
|
1378
|
+
backgroundColor: Qe()
|
|
1368
1379
|
}
|
|
1369
1380
|
}
|
|
1370
1381
|
];
|
|
1371
1382
|
}
|
|
1372
|
-
}),
|
|
1383
|
+
}), Ko = D.create({
|
|
1373
1384
|
name: "hardBreak",
|
|
1374
1385
|
inline: !0,
|
|
1375
1386
|
group: "inline",
|
|
@@ -1379,151 +1390,151 @@ const de = () => {
|
|
|
1379
1390
|
parseHTML() {
|
|
1380
1391
|
return [{ tag: "br" }];
|
|
1381
1392
|
},
|
|
1382
|
-
renderHTML({ HTMLAttributes:
|
|
1383
|
-
return ["br",
|
|
1393
|
+
renderHTML({ HTMLAttributes: o }) {
|
|
1394
|
+
return ["br", Et(this.options.HTMLAttributes, o)];
|
|
1384
1395
|
},
|
|
1385
1396
|
renderText() {
|
|
1386
1397
|
return `
|
|
1387
1398
|
`;
|
|
1388
1399
|
}
|
|
1389
|
-
}), J = (
|
|
1390
|
-
const t =
|
|
1391
|
-
if (
|
|
1400
|
+
}), J = (o, e) => {
|
|
1401
|
+
const t = o.resolve(e), n = t.index();
|
|
1402
|
+
if (n === 0)
|
|
1392
1403
|
return;
|
|
1393
|
-
const s = t.posAtIndex(
|
|
1394
|
-
return
|
|
1395
|
-
|
|
1404
|
+
const s = t.posAtIndex(n - 1);
|
|
1405
|
+
return Y(
|
|
1406
|
+
o.resolve(s)
|
|
1396
1407
|
);
|
|
1397
|
-
},
|
|
1408
|
+
}, _e = (o, e) => {
|
|
1398
1409
|
for (; e.childContainer; ) {
|
|
1399
|
-
const t = e.childContainer.node,
|
|
1400
|
-
e =
|
|
1410
|
+
const t = e.childContainer.node, n = o.resolve(e.childContainer.beforePos + 1).posAtIndex(t.childCount - 1);
|
|
1411
|
+
e = Y(o.resolve(n));
|
|
1401
1412
|
}
|
|
1402
1413
|
return e;
|
|
1403
|
-
},
|
|
1404
|
-
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)
|
|
1405
1416
|
throw new Error(
|
|
1406
|
-
`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`
|
|
1407
1418
|
);
|
|
1408
|
-
if (
|
|
1409
|
-
const s =
|
|
1410
|
-
|
|
1411
|
-
),
|
|
1412
|
-
|
|
1413
|
-
),
|
|
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);
|
|
1414
1425
|
if (e) {
|
|
1415
|
-
const c =
|
|
1416
|
-
|
|
1426
|
+
const c = o.doc.resolve(n.bnBlock.beforePos);
|
|
1427
|
+
o.tr.lift(i, c.depth);
|
|
1417
1428
|
}
|
|
1418
1429
|
}
|
|
1419
1430
|
if (e) {
|
|
1420
1431
|
if (!t.isBlockContainer)
|
|
1421
1432
|
throw new Error(
|
|
1422
|
-
`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`
|
|
1423
1434
|
);
|
|
1424
1435
|
e(
|
|
1425
|
-
|
|
1436
|
+
o.tr.delete(
|
|
1426
1437
|
t.blockContent.afterPos - 1,
|
|
1427
|
-
|
|
1438
|
+
n.blockContent.beforePos + 1
|
|
1428
1439
|
)
|
|
1429
1440
|
);
|
|
1430
1441
|
}
|
|
1431
1442
|
return !0;
|
|
1432
|
-
}, pe = (
|
|
1443
|
+
}, pe = (o) => ({
|
|
1433
1444
|
state: e,
|
|
1434
1445
|
dispatch: t
|
|
1435
1446
|
}) => {
|
|
1436
|
-
const
|
|
1447
|
+
const n = e.doc.resolve(o), s = Y(n), r = J(
|
|
1437
1448
|
e.doc,
|
|
1438
1449
|
s.bnBlock.beforePos
|
|
1439
1450
|
);
|
|
1440
|
-
if (!
|
|
1451
|
+
if (!r)
|
|
1441
1452
|
return !1;
|
|
1442
|
-
const
|
|
1453
|
+
const i = _e(
|
|
1443
1454
|
e.doc,
|
|
1444
|
-
|
|
1455
|
+
r
|
|
1445
1456
|
);
|
|
1446
|
-
return
|
|
1447
|
-
}, Yo =
|
|
1457
|
+
return Jo(i, s) ? qo(e, t, i, s) : !1;
|
|
1458
|
+
}, Yo = E.create({
|
|
1448
1459
|
priority: 50,
|
|
1449
1460
|
// TODO: The shortcuts need a refactor. Do we want to use a command priority
|
|
1450
1461
|
// design as there is now, or clump the logic into a single function?
|
|
1451
1462
|
addKeyboardShortcuts() {
|
|
1452
|
-
const
|
|
1463
|
+
const o = () => this.editor.commands.first(({ chain: n, commands: s }) => [
|
|
1453
1464
|
// Deletes the selection if it's not empty.
|
|
1454
1465
|
() => s.deleteSelection(),
|
|
1455
1466
|
// Undoes an input rule if one was triggered in the last editor state change.
|
|
1456
1467
|
() => s.undoInputRule(),
|
|
1457
1468
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
1458
|
-
() => s.command(({ state:
|
|
1459
|
-
const
|
|
1460
|
-
if (!
|
|
1469
|
+
() => s.command(({ state: r }) => {
|
|
1470
|
+
const i = B(r);
|
|
1471
|
+
if (!i.isBlockContainer)
|
|
1461
1472
|
return !1;
|
|
1462
|
-
const c =
|
|
1473
|
+
const c = r.selection.from === i.blockContent.beforePos + 1, a = i.blockContent.node.type.name === "paragraph";
|
|
1463
1474
|
return c && !a ? s.command(
|
|
1464
|
-
|
|
1475
|
+
Ze(i.bnBlock.beforePos, {
|
|
1465
1476
|
type: "paragraph",
|
|
1466
1477
|
props: {}
|
|
1467
1478
|
})
|
|
1468
1479
|
) : !1;
|
|
1469
1480
|
}),
|
|
1470
1481
|
// Removes a level of nesting if the block is indented if the selection is at the start of the block.
|
|
1471
|
-
() => s.command(({ state:
|
|
1472
|
-
const
|
|
1473
|
-
if (!
|
|
1482
|
+
() => s.command(({ state: r }) => {
|
|
1483
|
+
const i = B(r);
|
|
1484
|
+
if (!i.isBlockContainer)
|
|
1474
1485
|
return !1;
|
|
1475
|
-
const { blockContent: c } =
|
|
1476
|
-
return
|
|
1486
|
+
const { blockContent: c } = i;
|
|
1487
|
+
return r.selection.from === c.beforePos + 1 ? s.liftListItem("blockContainer") : !1;
|
|
1477
1488
|
}),
|
|
1478
1489
|
// Merges block with the previous one if it isn't indented, and the selection is at the start of the
|
|
1479
1490
|
// block. The target block for merging must contain inline content.
|
|
1480
|
-
() => s.command(({ state:
|
|
1481
|
-
const
|
|
1482
|
-
if (!
|
|
1491
|
+
() => s.command(({ state: r }) => {
|
|
1492
|
+
const i = B(r);
|
|
1493
|
+
if (!i.isBlockContainer)
|
|
1483
1494
|
return !1;
|
|
1484
|
-
const { bnBlock: c, blockContent: a } =
|
|
1485
|
-
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;
|
|
1486
1497
|
}),
|
|
1487
|
-
() => s.command(({ state:
|
|
1488
|
-
const a =
|
|
1489
|
-
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))
|
|
1490
1501
|
return !1;
|
|
1491
|
-
const d =
|
|
1502
|
+
const d = i.doc.resolve(a.bnBlock.beforePos);
|
|
1492
1503
|
if (d.nodeBefore || d.node().type.name !== "column")
|
|
1493
1504
|
return !1;
|
|
1494
|
-
const m =
|
|
1505
|
+
const m = i.doc.resolve(a.bnBlock.beforePos), f = i.doc.resolve(m.before()), k = f.before();
|
|
1495
1506
|
if (c) {
|
|
1496
|
-
const g =
|
|
1507
|
+
const g = i.doc.slice(
|
|
1497
1508
|
a.bnBlock.beforePos,
|
|
1498
1509
|
a.bnBlock.afterPos
|
|
1499
1510
|
).content;
|
|
1500
|
-
|
|
1511
|
+
i.delete(
|
|
1501
1512
|
a.bnBlock.beforePos,
|
|
1502
1513
|
a.bnBlock.afterPos
|
|
1503
|
-
), f.index() === 0 ? (W(
|
|
1504
|
-
M.near(
|
|
1505
|
-
)) : (
|
|
1506
|
-
M.near(
|
|
1507
|
-
), 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));
|
|
1508
1519
|
}
|
|
1509
1520
|
return !0;
|
|
1510
1521
|
}),
|
|
1511
1522
|
// Deletes the current block if it's an empty block with inline content,
|
|
1512
1523
|
// and moves the selection to the previous block.
|
|
1513
|
-
() => s.command(({ state:
|
|
1514
|
-
const
|
|
1515
|
-
if (!
|
|
1524
|
+
() => s.command(({ state: r }) => {
|
|
1525
|
+
const i = B(r);
|
|
1526
|
+
if (!i.isBlockContainer)
|
|
1516
1527
|
return !1;
|
|
1517
|
-
if (
|
|
1528
|
+
if (i.blockContent.node.childCount === 0 && i.blockContent.node.type.spec.content === "inline*") {
|
|
1518
1529
|
const a = J(
|
|
1519
|
-
|
|
1520
|
-
|
|
1530
|
+
r.doc,
|
|
1531
|
+
i.bnBlock.beforePos
|
|
1521
1532
|
);
|
|
1522
1533
|
if (!a || !a.isBlockContainer)
|
|
1523
1534
|
return !1;
|
|
1524
|
-
let l =
|
|
1535
|
+
let l = n();
|
|
1525
1536
|
if (a.blockContent.node.type.spec.content === "tableRow+") {
|
|
1526
|
-
const f =
|
|
1537
|
+
const f = i.bnBlock.beforePos - 1 - 1 - 1 - 1 - 1;
|
|
1527
1538
|
l = l.setTextSelection(
|
|
1528
1539
|
f
|
|
1529
1540
|
);
|
|
@@ -1537,8 +1548,8 @@ const de = () => {
|
|
|
1537
1548
|
l = l.setTextSelection(d);
|
|
1538
1549
|
}
|
|
1539
1550
|
return l.deleteRange({
|
|
1540
|
-
from:
|
|
1541
|
-
to:
|
|
1551
|
+
from: i.bnBlock.beforePos,
|
|
1552
|
+
to: i.bnBlock.afterPos
|
|
1542
1553
|
}).scrollIntoView().run();
|
|
1543
1554
|
}
|
|
1544
1555
|
return !1;
|
|
@@ -1546,26 +1557,26 @@ const de = () => {
|
|
|
1546
1557
|
// Deletes previous block if it contains no content and isn't a table,
|
|
1547
1558
|
// when the selection is empty and at the start of the block. Moves the
|
|
1548
1559
|
// current block into the deleted block's place.
|
|
1549
|
-
() => s.command(({ state:
|
|
1550
|
-
const
|
|
1551
|
-
if (!
|
|
1560
|
+
() => s.command(({ state: r }) => {
|
|
1561
|
+
const i = B(r);
|
|
1562
|
+
if (!i.isBlockContainer)
|
|
1552
1563
|
throw new Error("todo");
|
|
1553
|
-
const c =
|
|
1554
|
-
|
|
1555
|
-
|
|
1564
|
+
const c = r.selection.from === i.blockContent.beforePos + 1, a = r.selection.empty, l = J(
|
|
1565
|
+
r.doc,
|
|
1566
|
+
i.bnBlock.beforePos
|
|
1556
1567
|
);
|
|
1557
1568
|
if (l && c && a) {
|
|
1558
|
-
const d =
|
|
1559
|
-
|
|
1569
|
+
const d = _e(
|
|
1570
|
+
r.doc,
|
|
1560
1571
|
l
|
|
1561
1572
|
);
|
|
1562
1573
|
if (!d.isBlockContainer)
|
|
1563
1574
|
throw new Error("todo");
|
|
1564
1575
|
if (d.blockContent.node.type.spec.content === "" || d.blockContent.node.type.spec.content === "inline*" && d.blockContent.node.childCount === 0)
|
|
1565
|
-
return
|
|
1576
|
+
return n().cut(
|
|
1566
1577
|
{
|
|
1567
|
-
from:
|
|
1568
|
-
to:
|
|
1578
|
+
from: i.bnBlock.beforePos,
|
|
1579
|
+
to: i.bnBlock.afterPos
|
|
1569
1580
|
},
|
|
1570
1581
|
d.bnBlock.afterPos
|
|
1571
1582
|
).deleteRange({
|
|
@@ -1575,77 +1586,77 @@ const de = () => {
|
|
|
1575
1586
|
}
|
|
1576
1587
|
return !1;
|
|
1577
1588
|
})
|
|
1578
|
-
]), e = () => this.editor.commands.first(({ commands:
|
|
1589
|
+
]), e = () => this.editor.commands.first(({ commands: n }) => [
|
|
1579
1590
|
// Deletes the selection if it's not empty.
|
|
1580
|
-
() =>
|
|
1591
|
+
() => n.deleteSelection(),
|
|
1581
1592
|
// Merges block with the next one (at the same nesting level or lower),
|
|
1582
1593
|
// if one exists, the block has no children, and the selection is at the
|
|
1583
1594
|
// end of the block.
|
|
1584
|
-
() =>
|
|
1585
|
-
const
|
|
1586
|
-
if (!
|
|
1595
|
+
() => n.command(({ state: s }) => {
|
|
1596
|
+
const r = B(s);
|
|
1597
|
+
if (!r.isBlockContainer)
|
|
1587
1598
|
return !1;
|
|
1588
1599
|
const {
|
|
1589
|
-
bnBlock:
|
|
1600
|
+
bnBlock: i,
|
|
1590
1601
|
blockContent: c,
|
|
1591
1602
|
childContainer: a
|
|
1592
|
-
} =
|
|
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;
|
|
1593
1604
|
if (!d && u && p && !(a !== void 0)) {
|
|
1594
|
-
let f = l, k =
|
|
1605
|
+
let f = l, k = i.afterPos + 1, g = s.doc.resolve(k).depth;
|
|
1595
1606
|
for (; g < f; )
|
|
1596
1607
|
f = g, k += 2, g = s.doc.resolve(k).depth;
|
|
1597
|
-
return
|
|
1608
|
+
return n.command(pe(k - 1));
|
|
1598
1609
|
}
|
|
1599
1610
|
return !1;
|
|
1600
1611
|
})
|
|
1601
|
-
]), t = (
|
|
1612
|
+
]), t = (n = !1) => this.editor.commands.first(({ commands: s, tr: r }) => [
|
|
1602
1613
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
1603
1614
|
// of the block.
|
|
1604
|
-
() => s.command(({ state:
|
|
1605
|
-
const c =
|
|
1615
|
+
() => s.command(({ state: i }) => {
|
|
1616
|
+
const c = B(i);
|
|
1606
1617
|
if (!c.isBlockContainer)
|
|
1607
1618
|
return !1;
|
|
1608
|
-
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;
|
|
1609
1620
|
return u && p && m && f ? s.liftListItem("blockContainer") : !1;
|
|
1610
1621
|
}),
|
|
1611
1622
|
// Creates a hard break if block is configured to do so.
|
|
1612
|
-
() => s.command(({ state:
|
|
1623
|
+
() => s.command(({ state: i }) => {
|
|
1613
1624
|
var l;
|
|
1614
|
-
const c =
|
|
1625
|
+
const c = B(i), a = ((l = this.options.editor.schema.blockSchema[c.blockNoteType].meta) == null ? void 0 : l.hardBreakShortcut) ?? "shift+enter";
|
|
1615
1626
|
if (a === "none")
|
|
1616
1627
|
return !1;
|
|
1617
1628
|
if (
|
|
1618
1629
|
// If shortcut is not configured, or is configured as "shift+enter",
|
|
1619
1630
|
// create a hard break for shift+enter, but not for enter.
|
|
1620
|
-
a === "shift+enter" &&
|
|
1631
|
+
a === "shift+enter" && n || // If shortcut is configured as "enter", create a hard break for
|
|
1621
1632
|
// both enter and shift+enter.
|
|
1622
1633
|
a === "enter"
|
|
1623
1634
|
) {
|
|
1624
|
-
const d =
|
|
1635
|
+
const d = r.storedMarks || r.selection.$head.marks().filter(
|
|
1625
1636
|
(u) => this.editor.extensionManager.splittableMarks.includes(
|
|
1626
1637
|
u.type.name
|
|
1627
1638
|
)
|
|
1628
1639
|
);
|
|
1629
|
-
return
|
|
1630
|
-
|
|
1631
|
-
|
|
1640
|
+
return r.insert(
|
|
1641
|
+
r.selection.head,
|
|
1642
|
+
r.doc.type.schema.nodes.hardBreak.create()
|
|
1632
1643
|
).ensureMarks(d), !0;
|
|
1633
1644
|
}
|
|
1634
1645
|
return !1;
|
|
1635
1646
|
}),
|
|
1636
1647
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1637
1648
|
// empty & at the start of the block.
|
|
1638
|
-
() => s.command(({ state:
|
|
1639
|
-
const a =
|
|
1649
|
+
() => s.command(({ state: i, dispatch: c }) => {
|
|
1650
|
+
const a = B(i);
|
|
1640
1651
|
if (!a.isBlockContainer)
|
|
1641
1652
|
return !1;
|
|
1642
|
-
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;
|
|
1643
1654
|
if (u && p && m) {
|
|
1644
1655
|
const f = l.afterPos, k = f + 2;
|
|
1645
1656
|
if (c) {
|
|
1646
|
-
const g =
|
|
1647
|
-
|
|
1648
|
-
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))
|
|
1649
1660
|
);
|
|
1650
1661
|
}
|
|
1651
1662
|
return !0;
|
|
@@ -1654,14 +1665,14 @@ const de = () => {
|
|
|
1654
1665
|
}),
|
|
1655
1666
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
1656
1667
|
// deletes the selection beforehand, if it's not empty.
|
|
1657
|
-
() => s.command(({ state:
|
|
1658
|
-
const a =
|
|
1668
|
+
() => s.command(({ state: i, chain: c }) => {
|
|
1669
|
+
const a = B(i);
|
|
1659
1670
|
if (!a.isBlockContainer)
|
|
1660
1671
|
return !1;
|
|
1661
|
-
const { blockContent: l } = a, d =
|
|
1672
|
+
const { blockContent: l } = a, d = i.selection.$anchor.parentOffset === 0;
|
|
1662
1673
|
return l.node.childCount === 0 ? !1 : (c().deleteSelection().command(
|
|
1663
|
-
|
|
1664
|
-
|
|
1674
|
+
Xe(
|
|
1675
|
+
i.selection.from,
|
|
1665
1676
|
d,
|
|
1666
1677
|
d
|
|
1667
1678
|
)
|
|
@@ -1669,19 +1680,19 @@ const de = () => {
|
|
|
1669
1680
|
})
|
|
1670
1681
|
]);
|
|
1671
1682
|
return {
|
|
1672
|
-
Backspace:
|
|
1683
|
+
Backspace: o,
|
|
1673
1684
|
Delete: e,
|
|
1674
1685
|
Enter: () => t(),
|
|
1675
1686
|
"Shift-Enter": () => t(!0),
|
|
1676
1687
|
// Always returning true for tab key presses ensures they're not captured by the browser. Otherwise, they blur the
|
|
1677
1688
|
// editor since the browser will try to use tab for keyboard navigation.
|
|
1678
1689
|
Tab: () => {
|
|
1679
|
-
var
|
|
1680
|
-
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);
|
|
1681
1692
|
},
|
|
1682
1693
|
"Shift-Tab": () => {
|
|
1683
|
-
var
|
|
1684
|
-
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");
|
|
1685
1696
|
},
|
|
1686
1697
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1687
1698
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
@@ -1690,7 +1701,7 @@ const de = () => {
|
|
|
1690
1701
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1691
1702
|
};
|
|
1692
1703
|
}
|
|
1693
|
-
}),
|
|
1704
|
+
}), Qo = X.create({
|
|
1694
1705
|
name: "insertion",
|
|
1695
1706
|
inclusive: !1,
|
|
1696
1707
|
excludes: "deletion modification insertion",
|
|
@@ -1700,8 +1711,8 @@ const de = () => {
|
|
|
1700
1711
|
// note: validate is supported in prosemirror but not in tiptap, so this doesn't actually work (considered not critical)
|
|
1701
1712
|
};
|
|
1702
1713
|
},
|
|
1703
|
-
extendMarkSchema(
|
|
1704
|
-
return
|
|
1714
|
+
extendMarkSchema(o) {
|
|
1715
|
+
return o.name !== "insertion" ? {} : {
|
|
1705
1716
|
blocknoteIgnore: !0,
|
|
1706
1717
|
inclusive: !1,
|
|
1707
1718
|
toDOM(e, t) {
|
|
@@ -1728,7 +1739,7 @@ const de = () => {
|
|
|
1728
1739
|
]
|
|
1729
1740
|
};
|
|
1730
1741
|
}
|
|
1731
|
-
}),
|
|
1742
|
+
}), Xo = X.create({
|
|
1732
1743
|
name: "deletion",
|
|
1733
1744
|
inclusive: !1,
|
|
1734
1745
|
excludes: "insertion modification deletion",
|
|
@@ -1738,8 +1749,8 @@ const de = () => {
|
|
|
1738
1749
|
// note: validate is supported in prosemirror but not in tiptap
|
|
1739
1750
|
};
|
|
1740
1751
|
},
|
|
1741
|
-
extendMarkSchema(
|
|
1742
|
-
return
|
|
1752
|
+
extendMarkSchema(o) {
|
|
1753
|
+
return o.name !== "deletion" ? {} : {
|
|
1743
1754
|
blocknoteIgnore: !0,
|
|
1744
1755
|
inclusive: !1,
|
|
1745
1756
|
// attrs: {
|
|
@@ -1769,7 +1780,7 @@ const de = () => {
|
|
|
1769
1780
|
]
|
|
1770
1781
|
};
|
|
1771
1782
|
}
|
|
1772
|
-
}),
|
|
1783
|
+
}), Zo = X.create({
|
|
1773
1784
|
name: "modification",
|
|
1774
1785
|
inclusive: !1,
|
|
1775
1786
|
excludes: "deletion insertion",
|
|
@@ -1782,8 +1793,8 @@ const de = () => {
|
|
|
1782
1793
|
newValue: { default: null }
|
|
1783
1794
|
};
|
|
1784
1795
|
},
|
|
1785
|
-
extendMarkSchema(
|
|
1786
|
-
return
|
|
1796
|
+
extendMarkSchema(o) {
|
|
1797
|
+
return o.name !== "modification" ? {} : {
|
|
1787
1798
|
blocknoteIgnore: !0,
|
|
1788
1799
|
inclusive: !1,
|
|
1789
1800
|
// attrs: {
|
|
@@ -1832,7 +1843,7 @@ const de = () => {
|
|
|
1832
1843
|
]
|
|
1833
1844
|
};
|
|
1834
1845
|
}
|
|
1835
|
-
}),
|
|
1846
|
+
}), en = E.create({
|
|
1836
1847
|
name: "textAlignment",
|
|
1837
1848
|
addGlobalAttributes() {
|
|
1838
1849
|
return [
|
|
@@ -1845,34 +1856,34 @@ const de = () => {
|
|
|
1845
1856
|
attributes: {
|
|
1846
1857
|
textAlignment: {
|
|
1847
1858
|
default: "left",
|
|
1848
|
-
parseHTML: (
|
|
1849
|
-
renderHTML: (
|
|
1850
|
-
"data-text-alignment":
|
|
1859
|
+
parseHTML: (o) => o.getAttribute("data-text-alignment"),
|
|
1860
|
+
renderHTML: (o) => o.textAlignment === "left" ? {} : {
|
|
1861
|
+
"data-text-alignment": o.textAlignment
|
|
1851
1862
|
}
|
|
1852
1863
|
}
|
|
1853
1864
|
}
|
|
1854
1865
|
}
|
|
1855
1866
|
];
|
|
1856
1867
|
}
|
|
1857
|
-
}),
|
|
1868
|
+
}), tn = E.create({
|
|
1858
1869
|
name: "blockTextColor",
|
|
1859
1870
|
addGlobalAttributes() {
|
|
1860
1871
|
return [
|
|
1861
1872
|
{
|
|
1862
1873
|
types: ["table", "tableCell", "tableHeader"],
|
|
1863
1874
|
attributes: {
|
|
1864
|
-
textColor:
|
|
1875
|
+
textColor: et()
|
|
1865
1876
|
}
|
|
1866
1877
|
}
|
|
1867
1878
|
];
|
|
1868
1879
|
}
|
|
1869
|
-
}),
|
|
1880
|
+
}), on = {
|
|
1870
1881
|
blockColor: "data-block-color",
|
|
1871
1882
|
blockStyle: "data-block-style",
|
|
1872
1883
|
id: "data-id",
|
|
1873
1884
|
depth: "data-depth",
|
|
1874
1885
|
depthChange: "data-depth-change"
|
|
1875
|
-
},
|
|
1886
|
+
}, nn = D.create({
|
|
1876
1887
|
name: "blockContainer",
|
|
1877
1888
|
group: "blockGroupChild bnBlock",
|
|
1878
1889
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -1885,12 +1896,12 @@ const de = () => {
|
|
|
1885
1896
|
return [
|
|
1886
1897
|
{
|
|
1887
1898
|
tag: "div[data-node-type=" + this.name + "]",
|
|
1888
|
-
getAttrs: (
|
|
1889
|
-
if (typeof
|
|
1899
|
+
getAttrs: (o) => {
|
|
1900
|
+
if (typeof o == "string")
|
|
1890
1901
|
return !1;
|
|
1891
1902
|
const e = {};
|
|
1892
|
-
for (const [t,
|
|
1893
|
-
|
|
1903
|
+
for (const [t, n] of Object.entries(on))
|
|
1904
|
+
o.getAttribute(n) && (e[t] = o.getAttribute(n));
|
|
1894
1905
|
return e;
|
|
1895
1906
|
}
|
|
1896
1907
|
},
|
|
@@ -1901,25 +1912,25 @@ const de = () => {
|
|
|
1901
1912
|
}
|
|
1902
1913
|
];
|
|
1903
1914
|
},
|
|
1904
|
-
renderHTML({ HTMLAttributes:
|
|
1915
|
+
renderHTML({ HTMLAttributes: o }) {
|
|
1905
1916
|
var s;
|
|
1906
1917
|
const e = document.createElement("div");
|
|
1907
1918
|
e.className = "bn-block-outer", e.setAttribute("data-node-type", "blockOuter");
|
|
1908
|
-
for (const [
|
|
1909
|
-
|
|
1919
|
+
for (const [r, i] of Object.entries(o))
|
|
1920
|
+
r !== "class" && e.setAttribute(r, i);
|
|
1910
1921
|
const t = {
|
|
1911
1922
|
...((s = this.options.domAttributes) == null ? void 0 : s.block) || {},
|
|
1912
|
-
...
|
|
1913
|
-
},
|
|
1914
|
-
|
|
1915
|
-
for (const [
|
|
1916
|
-
|
|
1917
|
-
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), {
|
|
1918
1929
|
dom: e,
|
|
1919
|
-
contentDOM:
|
|
1930
|
+
contentDOM: n
|
|
1920
1931
|
};
|
|
1921
1932
|
}
|
|
1922
|
-
}),
|
|
1933
|
+
}), sn = D.create({
|
|
1923
1934
|
name: "blockGroup",
|
|
1924
1935
|
group: "childContainer",
|
|
1925
1936
|
content: "blockGroupChild+",
|
|
@@ -1928,128 +1939,138 @@ const de = () => {
|
|
|
1928
1939
|
return [
|
|
1929
1940
|
{
|
|
1930
1941
|
tag: "div",
|
|
1931
|
-
getAttrs: (
|
|
1942
|
+
getAttrs: (o) => typeof o == "string" ? !1 : o.getAttribute("data-node-type") === "blockGroup" ? null : !1
|
|
1932
1943
|
}
|
|
1933
1944
|
];
|
|
1934
1945
|
},
|
|
1935
|
-
renderHTML({ HTMLAttributes:
|
|
1936
|
-
var
|
|
1946
|
+
renderHTML({ HTMLAttributes: o }) {
|
|
1947
|
+
var n;
|
|
1937
1948
|
const e = {
|
|
1938
|
-
...((
|
|
1939
|
-
...
|
|
1949
|
+
...((n = this.options.domAttributes) == null ? void 0 : n.blockGroup) || {},
|
|
1950
|
+
...o
|
|
1940
1951
|
}, t = document.createElement("div");
|
|
1941
1952
|
t.className = Q(
|
|
1942
1953
|
"bn-block-group",
|
|
1943
1954
|
e.class
|
|
1944
1955
|
), t.setAttribute("data-node-type", "blockGroup");
|
|
1945
|
-
for (const [s,
|
|
1946
|
-
s !== "class" && t.setAttribute(s,
|
|
1956
|
+
for (const [s, r] of Object.entries(e))
|
|
1957
|
+
s !== "class" && t.setAttribute(s, r);
|
|
1947
1958
|
return {
|
|
1948
1959
|
dom: t,
|
|
1949
1960
|
contentDOM: t
|
|
1950
1961
|
};
|
|
1951
1962
|
}
|
|
1952
|
-
}),
|
|
1963
|
+
}), rn = D.create({
|
|
1953
1964
|
name: "doc",
|
|
1954
1965
|
topNode: !0,
|
|
1955
1966
|
content: "blockGroup",
|
|
1956
1967
|
marks: "insertion modification deletion"
|
|
1957
|
-
})
|
|
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
|
+
);
|
|
1958
1980
|
let fe = !1;
|
|
1959
|
-
function
|
|
1981
|
+
function cn(o, e) {
|
|
1960
1982
|
const t = [
|
|
1961
1983
|
I.ClipboardTextSerializer,
|
|
1962
1984
|
I.Commands,
|
|
1963
1985
|
I.Editable,
|
|
1964
1986
|
I.FocusEvents,
|
|
1965
1987
|
I.Tabindex,
|
|
1966
|
-
|
|
1988
|
+
Ft,
|
|
1967
1989
|
me.configure({
|
|
1968
1990
|
// everything from bnBlock group (nodes that represent a BlockNote block should have an id)
|
|
1969
1991
|
types: ["blockContainer", "columnList", "column"],
|
|
1970
1992
|
setIdAttribute: e.setIdAttribute
|
|
1971
1993
|
}),
|
|
1972
|
-
|
|
1994
|
+
Ko,
|
|
1973
1995
|
Ht,
|
|
1974
1996
|
// marks:
|
|
1975
|
-
qo,
|
|
1976
1997
|
Qo,
|
|
1977
1998
|
Xo,
|
|
1978
|
-
|
|
1999
|
+
Zo,
|
|
2000
|
+
$t.extend({
|
|
1979
2001
|
inclusive: !1
|
|
1980
2002
|
}).configure({
|
|
1981
2003
|
defaultProtocol: Bt,
|
|
1982
2004
|
// only call this once if we have multiple editors installed. Or fix https://github.com/ueberdosis/tiptap/issues/5450
|
|
1983
2005
|
protocols: fe ? [] : St
|
|
1984
2006
|
}),
|
|
1985
|
-
...Object.values(
|
|
1986
|
-
editor:
|
|
2007
|
+
...Object.values(o.schema.styleSpecs).map((n) => n.implementation.mark.configure({
|
|
2008
|
+
editor: o
|
|
1987
2009
|
})),
|
|
2010
|
+
tn,
|
|
2011
|
+
Wo,
|
|
1988
2012
|
en,
|
|
1989
|
-
jo,
|
|
1990
|
-
Zo,
|
|
1991
2013
|
// make sure escape blurs editor, so that we can tab to other elements in the host page (accessibility)
|
|
1992
|
-
|
|
2014
|
+
E.create({
|
|
1993
2015
|
name: "OverrideEscape",
|
|
1994
2016
|
addKeyboardShortcuts: () => ({
|
|
1995
2017
|
Escape: () => {
|
|
1996
|
-
var
|
|
1997
|
-
return (
|
|
2018
|
+
var n;
|
|
2019
|
+
return (n = o.getExtension(ge)) != null && n.shown() ? !1 : (o.blur(), !0);
|
|
1998
2020
|
}
|
|
1999
2021
|
})
|
|
2000
2022
|
}),
|
|
2001
2023
|
// nodes
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
editor:
|
|
2024
|
+
rn,
|
|
2025
|
+
nn.configure({
|
|
2026
|
+
editor: o,
|
|
2005
2027
|
domAttributes: e.domAttributes
|
|
2006
2028
|
}),
|
|
2007
2029
|
Yo.configure({
|
|
2008
|
-
editor:
|
|
2030
|
+
editor: o,
|
|
2009
2031
|
tabBehavior: e.tabBehavior
|
|
2010
2032
|
}),
|
|
2011
|
-
|
|
2033
|
+
sn.configure({
|
|
2012
2034
|
domAttributes: e.domAttributes
|
|
2013
2035
|
}),
|
|
2014
|
-
...Object.values(
|
|
2015
|
-
editor:
|
|
2036
|
+
...Object.values(o.schema.inlineContentSpecs).filter((n) => n.config !== "link" && n.config !== "text").map((n) => n.implementation.node.configure({
|
|
2037
|
+
editor: o
|
|
2016
2038
|
})),
|
|
2017
|
-
...Object.values(
|
|
2039
|
+
...Object.values(o.schema.blockSpecs).flatMap((n) => [
|
|
2018
2040
|
// the node extension implementations
|
|
2019
|
-
..."node" in
|
|
2020
|
-
|
|
2021
|
-
editor:
|
|
2041
|
+
..."node" in n.implementation ? [
|
|
2042
|
+
n.implementation.node.configure({
|
|
2043
|
+
editor: o,
|
|
2022
2044
|
domAttributes: e.domAttributes
|
|
2023
2045
|
})
|
|
2024
2046
|
] : []
|
|
2025
2047
|
]),
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
e.pasteHandler || ((
|
|
2048
|
+
jo(o),
|
|
2049
|
+
Go(
|
|
2050
|
+
o,
|
|
2051
|
+
e.pasteHandler || ((n) => n.defaultPasteHandler())
|
|
2030
2052
|
),
|
|
2031
|
-
|
|
2053
|
+
wo(o)
|
|
2032
2054
|
];
|
|
2033
2055
|
return fe = !0, t;
|
|
2034
2056
|
}
|
|
2035
|
-
function
|
|
2036
|
-
var o;
|
|
2057
|
+
function ln(o, e) {
|
|
2037
2058
|
const t = [
|
|
2038
|
-
|
|
2039
|
-
|
|
2059
|
+
ye(),
|
|
2060
|
+
ut(e),
|
|
2040
2061
|
G(e),
|
|
2041
2062
|
R(e),
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2063
|
+
pt(e),
|
|
2064
|
+
ft(),
|
|
2065
|
+
ht(e),
|
|
2066
|
+
Vt(e),
|
|
2067
|
+
mt(e),
|
|
2047
2068
|
ge(e),
|
|
2048
|
-
...e.trailingBlock !== !1 ? [
|
|
2069
|
+
...e.trailingBlock !== !1 ? [kt()] : []
|
|
2049
2070
|
];
|
|
2050
|
-
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;
|
|
2051
2072
|
}
|
|
2052
|
-
class
|
|
2073
|
+
class dn {
|
|
2053
2074
|
constructor(e, t) {
|
|
2054
2075
|
/**
|
|
2055
2076
|
* A set of extension keys which are disabled by the options
|
|
@@ -2073,27 +2094,27 @@ class cn {
|
|
|
2073
2094
|
*/
|
|
2074
2095
|
h(this, "extensionPlugins", /* @__PURE__ */ new Map());
|
|
2075
2096
|
this.editor = e, this.options = t, e.onMount(() => {
|
|
2076
|
-
for (const
|
|
2077
|
-
if (
|
|
2078
|
-
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({
|
|
2079
2100
|
dom: e.prosemirrorView.dom,
|
|
2080
2101
|
root: e.prosemirrorView.root,
|
|
2081
2102
|
signal: s.signal
|
|
2082
2103
|
});
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
}), this.abortMap.set(
|
|
2104
|
+
r && s.signal.addEventListener("abort", () => {
|
|
2105
|
+
r();
|
|
2106
|
+
}), this.abortMap.set(n, s);
|
|
2086
2107
|
}
|
|
2087
2108
|
}), e.onUnmount(() => {
|
|
2088
|
-
for (const [
|
|
2089
|
-
this.abortMap.delete(
|
|
2109
|
+
for (const [n, s] of this.abortMap.entries())
|
|
2110
|
+
this.abortMap.delete(n), s.abort();
|
|
2090
2111
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
2091
|
-
for (const
|
|
2092
|
-
this.addExtension(
|
|
2093
|
-
for (const
|
|
2094
|
-
this.addExtension(
|
|
2095
|
-
for (const
|
|
2096
|
-
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 ?? [])
|
|
2097
2118
|
this.addExtension(s);
|
|
2098
2119
|
}
|
|
2099
2120
|
/**
|
|
@@ -2102,26 +2123,26 @@ class cn {
|
|
|
2102
2123
|
* This allows users to switch on & off extensions "at runtime".
|
|
2103
2124
|
*/
|
|
2104
2125
|
registerExtension(e) {
|
|
2105
|
-
var
|
|
2126
|
+
var r;
|
|
2106
2127
|
const t = [].concat(e).filter(Boolean);
|
|
2107
2128
|
if (!t.length) {
|
|
2108
2129
|
console.warn("No extensions found to register", e);
|
|
2109
2130
|
return;
|
|
2110
2131
|
}
|
|
2111
|
-
const
|
|
2112
|
-
for (const
|
|
2113
|
-
|
|
2114
|
-
`Extension ${
|
|
2115
|
-
|
|
2116
|
-
), (
|
|
2117
|
-
`Extension ${
|
|
2118
|
-
|
|
2119
|
-
), 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(
|
|
2120
2141
|
(c) => {
|
|
2121
2142
|
s.add(c);
|
|
2122
2143
|
}
|
|
2123
2144
|
);
|
|
2124
|
-
this.updatePlugins((
|
|
2145
|
+
this.updatePlugins((i) => [...i, ...s]);
|
|
2125
2146
|
}
|
|
2126
2147
|
/**
|
|
2127
2148
|
* Register an extension to the editor
|
|
@@ -2132,10 +2153,13 @@ class cn {
|
|
|
2132
2153
|
let t;
|
|
2133
2154
|
if (typeof e == "function" ? t = e({ editor: this.editor }) : t = e, !(!t || this.disabledExtensions.has(t.key))) {
|
|
2134
2155
|
if (typeof e == "function") {
|
|
2135
|
-
const
|
|
2136
|
-
typeof
|
|
2156
|
+
const n = t[Ot];
|
|
2157
|
+
typeof n == "function" && this.extensionFactories.set(n, t);
|
|
2137
2158
|
}
|
|
2138
|
-
|
|
2159
|
+
if (this.extensions.push(t), t.blockNoteExtensions)
|
|
2160
|
+
for (const n of t.blockNoteExtensions)
|
|
2161
|
+
this.addExtension(n);
|
|
2162
|
+
return t;
|
|
2139
2163
|
}
|
|
2140
2164
|
}
|
|
2141
2165
|
/**
|
|
@@ -2146,16 +2170,16 @@ class cn {
|
|
|
2146
2170
|
resolveExtensions(e) {
|
|
2147
2171
|
const t = [];
|
|
2148
2172
|
if (typeof e == "function") {
|
|
2149
|
-
const
|
|
2150
|
-
|
|
2173
|
+
const n = this.extensionFactories.get(e);
|
|
2174
|
+
n && t.push(n);
|
|
2151
2175
|
} else if (Array.isArray(e))
|
|
2152
|
-
for (const
|
|
2153
|
-
t.push(...this.resolveExtensions(
|
|
2176
|
+
for (const n of e)
|
|
2177
|
+
t.push(...this.resolveExtensions(n));
|
|
2154
2178
|
else if (typeof e == "object" && "key" in e)
|
|
2155
2179
|
t.push(e);
|
|
2156
2180
|
else if (typeof e == "string") {
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2181
|
+
const n = this.extensions.find((s) => s.key === e);
|
|
2182
|
+
n && t.push(n);
|
|
2159
2183
|
}
|
|
2160
2184
|
return t;
|
|
2161
2185
|
}
|
|
@@ -2165,28 +2189,28 @@ class cn {
|
|
|
2165
2189
|
* @returns void
|
|
2166
2190
|
*/
|
|
2167
2191
|
unregisterExtension(e) {
|
|
2168
|
-
var
|
|
2192
|
+
var r;
|
|
2169
2193
|
const t = this.resolveExtensions(e);
|
|
2170
2194
|
if (!t.length) {
|
|
2171
2195
|
console.warn("No extensions found to unregister", e);
|
|
2172
2196
|
return;
|
|
2173
2197
|
}
|
|
2174
|
-
let
|
|
2198
|
+
let n = !1;
|
|
2175
2199
|
const s = /* @__PURE__ */ new Set();
|
|
2176
|
-
for (const
|
|
2177
|
-
this.extensions = this.extensions.filter((a) => a !==
|
|
2178
|
-
a ===
|
|
2179
|
-
}), (
|
|
2180
|
-
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);
|
|
2181
2205
|
c == null || c.forEach((a) => {
|
|
2182
2206
|
s.add(a);
|
|
2183
|
-
}), this.extensionPlugins.delete(
|
|
2184
|
-
`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.`,
|
|
2185
2209
|
e
|
|
2186
2210
|
));
|
|
2187
2211
|
}
|
|
2188
2212
|
this.updatePlugins(
|
|
2189
|
-
(
|
|
2213
|
+
(i) => i.filter((c) => !s.has(c))
|
|
2190
2214
|
);
|
|
2191
2215
|
}
|
|
2192
2216
|
/**
|
|
@@ -2195,44 +2219,44 @@ class cn {
|
|
|
2195
2219
|
* @returns void
|
|
2196
2220
|
*/
|
|
2197
2221
|
updatePlugins(e) {
|
|
2198
|
-
const t = this.editor.prosemirrorState,
|
|
2222
|
+
const t = this.editor.prosemirrorState, n = t.reconfigure({
|
|
2199
2223
|
plugins: e(t.plugins.slice())
|
|
2200
2224
|
});
|
|
2201
|
-
this.editor.prosemirrorView.updateState(
|
|
2225
|
+
this.editor.prosemirrorView.updateState(n);
|
|
2202
2226
|
}
|
|
2203
2227
|
/**
|
|
2204
2228
|
* Get all the extensions that are registered to the editor
|
|
2205
2229
|
*/
|
|
2206
2230
|
getTiptapExtensions() {
|
|
2207
2231
|
var s;
|
|
2208
|
-
const e =
|
|
2232
|
+
const e = cn(
|
|
2209
2233
|
this.editor,
|
|
2210
2234
|
this.options
|
|
2211
|
-
), t = Ct(this.extensions),
|
|
2212
|
-
for (const
|
|
2213
|
-
|
|
2214
|
-
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);
|
|
2215
2239
|
c.length && e.push(
|
|
2216
|
-
|
|
2217
|
-
name:
|
|
2218
|
-
priority:
|
|
2240
|
+
E.create({
|
|
2241
|
+
name: r.key,
|
|
2242
|
+
priority: i,
|
|
2219
2243
|
addProseMirrorPlugins: () => c
|
|
2220
2244
|
})
|
|
2221
|
-
), a.length && (
|
|
2245
|
+
), a.length && (n.has(i) || n.set(i, []), n.get(i).push(...a));
|
|
2222
2246
|
}
|
|
2223
2247
|
e.push(
|
|
2224
|
-
|
|
2248
|
+
E.create({
|
|
2225
2249
|
name: "blocknote-input-rules",
|
|
2226
2250
|
addProseMirrorPlugins() {
|
|
2227
|
-
const
|
|
2228
|
-
return Array.from(
|
|
2229
|
-
|
|
2230
|
-
}), [_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 })];
|
|
2231
2255
|
}
|
|
2232
2256
|
})
|
|
2233
2257
|
);
|
|
2234
|
-
for (const
|
|
2235
|
-
e.push(
|
|
2258
|
+
for (const r of ((s = this.options._tiptapOptions) == null ? void 0 : s.extensions) ?? [])
|
|
2259
|
+
e.push(r);
|
|
2236
2260
|
return e;
|
|
2237
2261
|
}
|
|
2238
2262
|
/**
|
|
@@ -2242,9 +2266,9 @@ class cn {
|
|
|
2242
2266
|
* - input rules
|
|
2243
2267
|
*/
|
|
2244
2268
|
getProsemirrorPluginsFromExtension(e) {
|
|
2245
|
-
var s,
|
|
2246
|
-
const t = [...e.prosemirrorPlugins ?? []],
|
|
2247
|
-
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(
|
|
2248
2272
|
...e.inputRules.map((c) => new Dt(c.find, (a, l, d, u) => {
|
|
2249
2273
|
const p = c.replace({
|
|
2250
2274
|
match: l,
|
|
@@ -2255,8 +2279,8 @@ class cn {
|
|
|
2255
2279
|
const m = this.editor.getTextCursorPosition();
|
|
2256
2280
|
if (this.editor.schema.blockSchema[m.block.type].content !== "inline")
|
|
2257
2281
|
return null;
|
|
2258
|
-
const f =
|
|
2259
|
-
return
|
|
2282
|
+
const f = $(a.tr), k = a.tr.deleteRange(d, u);
|
|
2283
|
+
return tt(k, f.bnBlock.beforePos, p), k;
|
|
2260
2284
|
}
|
|
2261
2285
|
return null;
|
|
2262
2286
|
}))
|
|
@@ -2269,7 +2293,7 @@ class cn {
|
|
|
2269
2293
|
])
|
|
2270
2294
|
)
|
|
2271
2295
|
)
|
|
2272
|
-
), { plugins: t, inputRules:
|
|
2296
|
+
), { plugins: t, inputRules: n });
|
|
2273
2297
|
}
|
|
2274
2298
|
/**
|
|
2275
2299
|
* Get all extensions
|
|
@@ -2281,7 +2305,7 @@ class cn {
|
|
|
2281
2305
|
}
|
|
2282
2306
|
getExtension(e) {
|
|
2283
2307
|
if (typeof e == "string") {
|
|
2284
|
-
const t = this.extensions.find((
|
|
2308
|
+
const t = this.extensions.find((n) => n.key === e);
|
|
2285
2309
|
return t || void 0;
|
|
2286
2310
|
} else if (typeof e == "function") {
|
|
2287
2311
|
const t = this.extensionFactories.get(e);
|
|
@@ -2296,58 +2320,76 @@ class cn {
|
|
|
2296
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;
|
|
2297
2321
|
}
|
|
2298
2322
|
}
|
|
2299
|
-
function
|
|
2300
|
-
|
|
2301
|
-
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)
|
|
2302
2344
|
return;
|
|
2303
|
-
const t =
|
|
2304
|
-
_(
|
|
2305
|
-
),
|
|
2306
|
-
_(
|
|
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
|
|
2307
2349
|
), s = (l, d) => {
|
|
2308
|
-
const u = t.posAtIndex(l, d), p =
|
|
2350
|
+
const u = t.posAtIndex(l, d), p = o.doc.resolve(u).nodeAfter;
|
|
2309
2351
|
if (!p)
|
|
2310
2352
|
throw new Error(
|
|
2311
2353
|
`Error getting selection - node not found at position ${u}`
|
|
2312
2354
|
);
|
|
2313
2355
|
return b(p, e);
|
|
2314
|
-
},
|
|
2315
|
-
if (t.depth >
|
|
2316
|
-
|
|
2317
|
-
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--)
|
|
2318
2360
|
if (t.node(l).type.isInGroup("childContainer")) {
|
|
2319
2361
|
const u = t.index(l) + 1, p = t.node(l).childCount;
|
|
2320
2362
|
for (let m = u; m < p; m++)
|
|
2321
|
-
|
|
2363
|
+
r.push(s(m, l));
|
|
2322
2364
|
}
|
|
2323
2365
|
} else
|
|
2324
|
-
|
|
2366
|
+
r.push(s(c, i));
|
|
2325
2367
|
for (let l = c + 1; l <= a; l++)
|
|
2326
|
-
|
|
2327
|
-
if (
|
|
2368
|
+
r.push(s(l, i));
|
|
2369
|
+
if (r.length === 0)
|
|
2328
2370
|
throw new Error(
|
|
2329
|
-
`Error getting selection - selection doesn't span any blocks (${
|
|
2371
|
+
`Error getting selection - selection doesn't span any blocks (${o.selection})`
|
|
2330
2372
|
);
|
|
2331
2373
|
return {
|
|
2332
|
-
blocks:
|
|
2374
|
+
blocks: r
|
|
2333
2375
|
};
|
|
2334
2376
|
}
|
|
2335
|
-
function
|
|
2336
|
-
const
|
|
2337
|
-
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)
|
|
2338
2380
|
throw new Error(
|
|
2339
|
-
`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})`
|
|
2340
2382
|
);
|
|
2341
|
-
const c =
|
|
2383
|
+
const c = x(n, o.doc);
|
|
2342
2384
|
if (!c)
|
|
2343
|
-
throw new Error(`Block with ID ${
|
|
2344
|
-
const a =
|
|
2385
|
+
throw new Error(`Block with ID ${n} not found`);
|
|
2386
|
+
const a = x(s, o.doc);
|
|
2345
2387
|
if (!a)
|
|
2346
2388
|
throw new Error(`Block with ID ${s} not found`);
|
|
2347
|
-
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];
|
|
2348
2390
|
if (!l.isBlockContainer || u.content === "none")
|
|
2349
2391
|
throw new Error(
|
|
2350
|
-
`Attempting to set selection anchor in block without content (id ${
|
|
2392
|
+
`Attempting to set selection anchor in block without content (id ${n})`
|
|
2351
2393
|
);
|
|
2352
2394
|
if (!d.isBlockContainer || p.content === "none")
|
|
2353
2395
|
throw new Error(
|
|
@@ -2364,76 +2406,76 @@ function dn(n, e, t) {
|
|
|
2364
2406
|
k.height - 1,
|
|
2365
2407
|
k.width - 1,
|
|
2366
2408
|
d.blockContent.node
|
|
2367
|
-
) + 1, y =
|
|
2409
|
+
) + 1, y = o.doc.resolve(g).nodeAfter.nodeSize;
|
|
2368
2410
|
f = g + y - 2;
|
|
2369
2411
|
} else
|
|
2370
2412
|
f = d.blockContent.afterPos - 1;
|
|
2371
|
-
|
|
2372
|
-
}
|
|
2373
|
-
function
|
|
2374
|
-
const
|
|
2375
|
-
let
|
|
2376
|
-
for (;
|
|
2377
|
-
|
|
2378
|
-
for (;
|
|
2379
|
-
|
|
2380
|
-
for (;
|
|
2381
|
-
|
|
2382
|
-
for (;
|
|
2383
|
-
|
|
2384
|
-
const
|
|
2385
|
-
|
|
2386
|
-
|
|
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
|
|
2387
2429
|
);
|
|
2388
2430
|
return {
|
|
2389
2431
|
_meta: {
|
|
2390
|
-
startPos:
|
|
2391
|
-
endPos:
|
|
2432
|
+
startPos: s.pos,
|
|
2433
|
+
endPos: r.pos
|
|
2392
2434
|
},
|
|
2393
|
-
...
|
|
2435
|
+
...i
|
|
2394
2436
|
};
|
|
2395
2437
|
}
|
|
2396
|
-
function
|
|
2397
|
-
const { bnBlock: e } =
|
|
2398
|
-
let
|
|
2399
|
-
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))), {
|
|
2400
2442
|
block: b(e.node, t),
|
|
2401
2443
|
prevBlock: s === null ? void 0 : b(s, t),
|
|
2402
|
-
nextBlock:
|
|
2403
|
-
parentBlock:
|
|
2444
|
+
nextBlock: r === null ? void 0 : b(r, t),
|
|
2445
|
+
parentBlock: i === void 0 ? void 0 : b(i, t)
|
|
2404
2446
|
};
|
|
2405
2447
|
}
|
|
2406
|
-
function
|
|
2407
|
-
const
|
|
2408
|
-
if (!
|
|
2409
|
-
throw new Error(`Block with ID ${
|
|
2410
|
-
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;
|
|
2411
2453
|
if (c.isBlockContainer) {
|
|
2412
2454
|
const l = c.blockContent;
|
|
2413
2455
|
if (a === "none") {
|
|
2414
|
-
|
|
2456
|
+
o.setSelection(L.create(o.doc, l.beforePos));
|
|
2415
2457
|
return;
|
|
2416
2458
|
}
|
|
2417
2459
|
if (a === "inline")
|
|
2418
|
-
t === "start" ?
|
|
2419
|
-
M.create(
|
|
2420
|
-
) :
|
|
2421
|
-
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)
|
|
2422
2464
|
);
|
|
2423
2465
|
else if (a === "table")
|
|
2424
|
-
t === "start" ?
|
|
2425
|
-
M.create(
|
|
2426
|
-
) :
|
|
2427
|
-
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)
|
|
2428
2470
|
);
|
|
2429
2471
|
else
|
|
2430
2472
|
throw new F(a);
|
|
2431
2473
|
} else {
|
|
2432
2474
|
const l = t === "start" ? c.childContainer.node.firstChild : c.childContainer.node.lastChild;
|
|
2433
|
-
|
|
2475
|
+
De(o, l.attrs.id, t);
|
|
2434
2476
|
}
|
|
2435
2477
|
}
|
|
2436
|
-
class
|
|
2478
|
+
class kn {
|
|
2437
2479
|
constructor(e) {
|
|
2438
2480
|
this.editor = e;
|
|
2439
2481
|
}
|
|
@@ -2444,7 +2486,7 @@ class fn {
|
|
|
2444
2486
|
* If the selection starts / ends halfway through a block, the returned data will contain the entire block.
|
|
2445
2487
|
*/
|
|
2446
2488
|
getSelection() {
|
|
2447
|
-
return this.editor.transact((e) =>
|
|
2489
|
+
return this.editor.transact((e) => pn(e));
|
|
2448
2490
|
}
|
|
2449
2491
|
/**
|
|
2450
2492
|
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
@@ -2453,8 +2495,8 @@ class fn {
|
|
|
2453
2495
|
* If the selection starts / ends halfway through a block, the returned block will be
|
|
2454
2496
|
* only the part of the block that is included in the selection.
|
|
2455
2497
|
*/
|
|
2456
|
-
getSelectionCutBlocks() {
|
|
2457
|
-
return this.editor.transact((
|
|
2498
|
+
getSelectionCutBlocks(e = !1) {
|
|
2499
|
+
return this.editor.transact((t) => hn(t, e));
|
|
2458
2500
|
}
|
|
2459
2501
|
/**
|
|
2460
2502
|
* Sets the selection to a range of blocks.
|
|
@@ -2462,14 +2504,14 @@ class fn {
|
|
|
2462
2504
|
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
2463
2505
|
*/
|
|
2464
2506
|
setSelection(e, t) {
|
|
2465
|
-
return this.editor.transact((
|
|
2507
|
+
return this.editor.transact((n) => fn(n, e, t));
|
|
2466
2508
|
}
|
|
2467
2509
|
/**
|
|
2468
2510
|
* Gets a snapshot of the current text cursor position.
|
|
2469
2511
|
* @returns A snapshot of the current text cursor position.
|
|
2470
2512
|
*/
|
|
2471
2513
|
getTextCursorPosition() {
|
|
2472
|
-
return this.editor.transact((e) =>
|
|
2514
|
+
return this.editor.transact((e) => mn(e));
|
|
2473
2515
|
}
|
|
2474
2516
|
/**
|
|
2475
2517
|
* Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
|
|
@@ -2479,7 +2521,7 @@ class fn {
|
|
|
2479
2521
|
*/
|
|
2480
2522
|
setTextCursorPosition(e, t = "start") {
|
|
2481
2523
|
return this.editor.transact(
|
|
2482
|
-
(
|
|
2524
|
+
(n) => De(n, e, t)
|
|
2483
2525
|
);
|
|
2484
2526
|
}
|
|
2485
2527
|
/**
|
|
@@ -2488,20 +2530,20 @@ class fn {
|
|
|
2488
2530
|
getSelectionBoundingBox() {
|
|
2489
2531
|
if (!this.editor.prosemirrorView)
|
|
2490
2532
|
return;
|
|
2491
|
-
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));
|
|
2492
2534
|
if (Mt(e)) {
|
|
2493
|
-
const
|
|
2494
|
-
if (
|
|
2495
|
-
return
|
|
2535
|
+
const r = this.editor.prosemirrorView.nodeDOM(n);
|
|
2536
|
+
if (r)
|
|
2537
|
+
return r.getBoundingClientRect();
|
|
2496
2538
|
}
|
|
2497
2539
|
return wt(
|
|
2498
2540
|
this.editor.prosemirrorView,
|
|
2499
|
-
|
|
2541
|
+
n,
|
|
2500
2542
|
s
|
|
2501
2543
|
).toJSON();
|
|
2502
2544
|
}
|
|
2503
2545
|
}
|
|
2504
|
-
class
|
|
2546
|
+
class gn {
|
|
2505
2547
|
constructor(e) {
|
|
2506
2548
|
/**
|
|
2507
2549
|
* Stores the currently active transaction, which is the accumulated transaction from all {@link dispatch} calls during a {@link transact} calls
|
|
@@ -2547,8 +2589,8 @@ class hn {
|
|
|
2547
2589
|
);
|
|
2548
2590
|
if (this.isInCan)
|
|
2549
2591
|
return this.canExec(e);
|
|
2550
|
-
const t = this.prosemirrorState,
|
|
2551
|
-
return e(t, (
|
|
2592
|
+
const t = this.prosemirrorState, n = this.prosemirrorView;
|
|
2593
|
+
return e(t, (r) => this.prosemirrorView.dispatch(r), n);
|
|
2552
2594
|
}
|
|
2553
2595
|
/**
|
|
2554
2596
|
* Check if a command can be executed. A command should return `false` if it is not valid in the current state.
|
|
@@ -2567,8 +2609,8 @@ class hn {
|
|
|
2567
2609
|
throw new Error(
|
|
2568
2610
|
"`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call"
|
|
2569
2611
|
);
|
|
2570
|
-
const t = this.prosemirrorState,
|
|
2571
|
-
return e(t, void 0,
|
|
2612
|
+
const t = this.prosemirrorState, n = this.prosemirrorView;
|
|
2613
|
+
return e(t, void 0, n);
|
|
2572
2614
|
}
|
|
2573
2615
|
/**
|
|
2574
2616
|
* Execute a function within a "blocknote transaction".
|
|
@@ -2594,9 +2636,9 @@ class hn {
|
|
|
2594
2636
|
return e(this.activeTransaction);
|
|
2595
2637
|
try {
|
|
2596
2638
|
this.activeTransaction = this.editor._tiptapEditor.state.tr;
|
|
2597
|
-
const t = e(this.activeTransaction),
|
|
2598
|
-
return this.activeTransaction = null,
|
|
2599
|
-
(
|
|
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;
|
|
2600
2642
|
} finally {
|
|
2601
2643
|
this.activeTransaction = null;
|
|
2602
2644
|
}
|
|
@@ -2677,17 +2719,17 @@ class hn {
|
|
|
2677
2719
|
throw new Error("No redo plugin found");
|
|
2678
2720
|
}
|
|
2679
2721
|
}
|
|
2680
|
-
function
|
|
2681
|
-
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 = "";
|
|
2682
2724
|
if (t.forEach((l) => {
|
|
2683
|
-
l.check(),
|
|
2684
|
-
}), s ===
|
|
2685
|
-
const { parent: l } =
|
|
2686
|
-
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);
|
|
2687
2729
|
}
|
|
2688
|
-
return
|
|
2730
|
+
return i ? o.insertText(a, s, r) : o.replaceWith(s, r, t), n.updateSelection && Tt(o, o.steps.length - 1, -1), !0;
|
|
2689
2731
|
}
|
|
2690
|
-
class
|
|
2732
|
+
class yn {
|
|
2691
2733
|
constructor(e) {
|
|
2692
2734
|
this.editor = e;
|
|
2693
2735
|
}
|
|
@@ -2697,15 +2739,15 @@ class kn {
|
|
|
2697
2739
|
* @param content can be a string, or array of partial inline content elements
|
|
2698
2740
|
*/
|
|
2699
2741
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2700
|
-
const
|
|
2742
|
+
const n = O(e, this.editor.pmSchema);
|
|
2701
2743
|
this.editor.transact((s) => {
|
|
2702
|
-
|
|
2744
|
+
bn(
|
|
2703
2745
|
s,
|
|
2704
2746
|
{
|
|
2705
2747
|
from: s.selection.from,
|
|
2706
2748
|
to: s.selection.to
|
|
2707
2749
|
},
|
|
2708
|
-
|
|
2750
|
+
n,
|
|
2709
2751
|
{
|
|
2710
2752
|
updateSelection: t
|
|
2711
2753
|
}
|
|
@@ -2717,16 +2759,16 @@ class kn {
|
|
|
2717
2759
|
*/
|
|
2718
2760
|
getActiveStyles() {
|
|
2719
2761
|
return this.editor.transact((e) => {
|
|
2720
|
-
const t = {},
|
|
2721
|
-
for (const s of
|
|
2722
|
-
const
|
|
2723
|
-
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) {
|
|
2724
2766
|
// Links are not considered styles in blocknote
|
|
2725
2767
|
s.type.name !== "link" && // "blocknoteIgnore" tagged marks (such as comments) are also not considered BlockNote "styles"
|
|
2726
2768
|
!s.type.spec.blocknoteIgnore && console.warn("mark not found in styleschema", s.type.name);
|
|
2727
2769
|
continue;
|
|
2728
2770
|
}
|
|
2729
|
-
|
|
2771
|
+
r.propSchema === "boolean" ? t[r.type] = !0 : t[r.type] = s.attrs.stringValue;
|
|
2730
2772
|
}
|
|
2731
2773
|
return t;
|
|
2732
2774
|
});
|
|
@@ -2736,7 +2778,7 @@ class kn {
|
|
|
2736
2778
|
* @param styles The styles to add.
|
|
2737
2779
|
*/
|
|
2738
2780
|
addStyles(e) {
|
|
2739
|
-
for (const [t,
|
|
2781
|
+
for (const [t, n] of Object.entries(e)) {
|
|
2740
2782
|
const s = this.editor.schema.styleSchema[t];
|
|
2741
2783
|
if (!s)
|
|
2742
2784
|
throw new Error(`style ${t} not found in styleSchema`);
|
|
@@ -2744,7 +2786,7 @@ class kn {
|
|
|
2744
2786
|
this.editor._tiptapEditor.commands.setMark(t);
|
|
2745
2787
|
else if (s.propSchema === "string")
|
|
2746
2788
|
this.editor._tiptapEditor.commands.setMark(t, {
|
|
2747
|
-
stringValue:
|
|
2789
|
+
stringValue: n
|
|
2748
2790
|
});
|
|
2749
2791
|
else
|
|
2750
2792
|
throw new F(s.propSchema);
|
|
@@ -2763,7 +2805,7 @@ class kn {
|
|
|
2763
2805
|
* @param styles The styles to toggle.
|
|
2764
2806
|
*/
|
|
2765
2807
|
toggleStyles(e) {
|
|
2766
|
-
for (const [t,
|
|
2808
|
+
for (const [t, n] of Object.entries(e)) {
|
|
2767
2809
|
const s = this.editor.schema.styleSchema[t];
|
|
2768
2810
|
if (!s)
|
|
2769
2811
|
throw new Error(`style ${t} not found in styleSchema`);
|
|
@@ -2771,7 +2813,7 @@ class kn {
|
|
|
2771
2813
|
this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2772
2814
|
else if (s.propSchema === "string")
|
|
2773
2815
|
this.editor._tiptapEditor.commands.toggleMark(t, {
|
|
2774
|
-
stringValue:
|
|
2816
|
+
stringValue: n
|
|
2775
2817
|
});
|
|
2776
2818
|
else
|
|
2777
2819
|
throw new F(s.propSchema);
|
|
@@ -2797,80 +2839,80 @@ class kn {
|
|
|
2797
2839
|
createLink(e, t) {
|
|
2798
2840
|
if (e === "")
|
|
2799
2841
|
return;
|
|
2800
|
-
const
|
|
2842
|
+
const n = this.editor.pmSchema.mark("link", { href: e });
|
|
2801
2843
|
this.editor.transact((s) => {
|
|
2802
|
-
const { from:
|
|
2803
|
-
t ? s.insertText(t,
|
|
2804
|
-
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(
|
|
2805
2846
|
r,
|
|
2806
|
-
|
|
2847
|
+
i,
|
|
2848
|
+
n
|
|
2807
2849
|
);
|
|
2808
2850
|
});
|
|
2809
2851
|
}
|
|
2810
2852
|
}
|
|
2811
|
-
function
|
|
2853
|
+
function Sn(o, e) {
|
|
2812
2854
|
const t = [];
|
|
2813
|
-
return
|
|
2814
|
-
|
|
2855
|
+
return o.forEach((n, s, r) => {
|
|
2856
|
+
r !== e && t.push(n);
|
|
2815
2857
|
}), Z.from(t);
|
|
2816
2858
|
}
|
|
2817
|
-
function
|
|
2859
|
+
function Bn(o, e) {
|
|
2818
2860
|
const t = [];
|
|
2819
|
-
for (let
|
|
2820
|
-
if (
|
|
2861
|
+
for (let n = 0; n < o.childCount; n++)
|
|
2862
|
+
if (o.child(n).type.name === "tableRow")
|
|
2821
2863
|
if (t.length > 0 && t[t.length - 1].type.name === "table") {
|
|
2822
|
-
const s = t[t.length - 1],
|
|
2823
|
-
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;
|
|
2824
2866
|
} else {
|
|
2825
2867
|
const s = e.nodes.table.createChecked(
|
|
2826
2868
|
void 0,
|
|
2827
|
-
|
|
2869
|
+
o.child(n)
|
|
2828
2870
|
);
|
|
2829
2871
|
t.push(s);
|
|
2830
2872
|
}
|
|
2831
2873
|
else
|
|
2832
|
-
t.push(
|
|
2833
|
-
return
|
|
2834
|
-
}
|
|
2835
|
-
function
|
|
2836
|
-
let t = Z.from(
|
|
2837
|
-
if (t =
|
|
2838
|
-
return new ne(t,
|
|
2839
|
-
for (let
|
|
2840
|
-
if (t.child(
|
|
2841
|
-
const s = [t.child(
|
|
2842
|
-
if (
|
|
2843
|
-
const
|
|
2844
|
-
(
|
|
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));
|
|
2845
2887
|
}
|
|
2846
|
-
const
|
|
2888
|
+
const r = e.state.schema.nodes.blockContainer.createChecked(
|
|
2847
2889
|
void 0,
|
|
2848
2890
|
s
|
|
2849
2891
|
);
|
|
2850
|
-
t = t.replaceChild(
|
|
2892
|
+
t = t.replaceChild(n, r);
|
|
2851
2893
|
}
|
|
2852
|
-
return new ne(t,
|
|
2894
|
+
return new ne(t, o.openStart, o.openEnd);
|
|
2853
2895
|
}
|
|
2854
|
-
function
|
|
2855
|
-
var
|
|
2856
|
-
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+";
|
|
2857
2899
|
if (t) {
|
|
2858
|
-
if (
|
|
2900
|
+
if (n)
|
|
2859
2901
|
return !1;
|
|
2860
2902
|
if (s) {
|
|
2861
|
-
const c =
|
|
2903
|
+
const c = B(e.state);
|
|
2862
2904
|
if (c.isBlockContainer)
|
|
2863
2905
|
return !(c.blockContent.node.type.spec.content === "tableRow+");
|
|
2864
2906
|
}
|
|
2865
2907
|
}
|
|
2866
2908
|
return !0;
|
|
2867
2909
|
}
|
|
2868
|
-
const
|
|
2910
|
+
const En = {
|
|
2869
2911
|
enableInputRules: !0,
|
|
2870
2912
|
enablePasteRules: !0,
|
|
2871
2913
|
enableCoreExtensions: !1
|
|
2872
2914
|
};
|
|
2873
|
-
class
|
|
2915
|
+
class Le extends Se {
|
|
2874
2916
|
constructor(t) {
|
|
2875
2917
|
var l, d, u, p, m, f, k, g, y, T;
|
|
2876
2918
|
super();
|
|
@@ -2960,23 +3002,23 @@ class De extends ye {
|
|
|
2960
3002
|
headers: ((p = t == null ? void 0 : t.tables) == null ? void 0 : p.headers) ?? !1
|
|
2961
3003
|
}
|
|
2962
3004
|
};
|
|
2963
|
-
const
|
|
3005
|
+
const n = {
|
|
2964
3006
|
defaultStyles: !0,
|
|
2965
|
-
schema: t.schema ||
|
|
3007
|
+
schema: t.schema || xt.create(),
|
|
2966
3008
|
...t,
|
|
2967
3009
|
placeholders: {
|
|
2968
3010
|
...this.dictionary.placeholders,
|
|
2969
3011
|
...t.placeholders
|
|
2970
3012
|
}
|
|
2971
3013
|
};
|
|
2972
|
-
if (this.schema =
|
|
2973
|
-
const
|
|
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;
|
|
2974
3016
|
this.uploadFile = async (P, w) => {
|
|
2975
3017
|
this.onUploadStartCallbacks.forEach(
|
|
2976
3018
|
(v) => v.apply(this, [w])
|
|
2977
3019
|
);
|
|
2978
3020
|
try {
|
|
2979
|
-
return await
|
|
3021
|
+
return await S(P, w);
|
|
2980
3022
|
} finally {
|
|
2981
3023
|
this.onUploadEndCallbacks.forEach(
|
|
2982
3024
|
(v) => v.apply(this, [w])
|
|
@@ -2984,37 +3026,37 @@ class De extends ye {
|
|
|
2984
3026
|
}
|
|
2985
3027
|
};
|
|
2986
3028
|
}
|
|
2987
|
-
this.resolveFileUrl =
|
|
2988
|
-
const s = this._extensionManager.getTiptapExtensions(),
|
|
2989
|
-
|
|
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(
|
|
2990
3032
|
"When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider"
|
|
2991
3033
|
);
|
|
2992
|
-
const
|
|
2993
|
-
...
|
|
2994
|
-
...
|
|
3034
|
+
const i = {
|
|
3035
|
+
...En,
|
|
3036
|
+
...n._tiptapOptions,
|
|
2995
3037
|
element: null,
|
|
2996
|
-
autofocus:
|
|
3038
|
+
autofocus: n.autofocus ?? !1,
|
|
2997
3039
|
extensions: s,
|
|
2998
3040
|
editorProps: {
|
|
2999
|
-
...(m =
|
|
3041
|
+
...(m = n._tiptapOptions) == null ? void 0 : m.editorProps,
|
|
3000
3042
|
attributes: {
|
|
3001
3043
|
// As of TipTap v2.5.0 the tabIndex is removed when the editor is not
|
|
3002
3044
|
// editable, so you can't focus it. We want to revert this as we have
|
|
3003
3045
|
// UI behaviour that relies on it.
|
|
3004
3046
|
tabIndex: "0",
|
|
3005
|
-
...(k = (f =
|
|
3006
|
-
...(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,
|
|
3007
3049
|
class: Q(
|
|
3008
3050
|
"bn-editor",
|
|
3009
|
-
|
|
3010
|
-
((T = (y =
|
|
3051
|
+
n.defaultStyles ? "bn-default-styles" : "",
|
|
3052
|
+
((T = (y = n.domAttributes) == null ? void 0 : y.editor) == null ? void 0 : T.class) || ""
|
|
3011
3053
|
)
|
|
3012
3054
|
},
|
|
3013
|
-
transformPasted:
|
|
3055
|
+
transformPasted: Cn
|
|
3014
3056
|
}
|
|
3015
3057
|
};
|
|
3016
3058
|
try {
|
|
3017
|
-
const
|
|
3059
|
+
const S = n.initialContent || (r ? [
|
|
3018
3060
|
{
|
|
3019
3061
|
type: "paragraph",
|
|
3020
3062
|
id: "initialBlockId"
|
|
@@ -3025,12 +3067,12 @@ class De extends ye {
|
|
|
3025
3067
|
id: me.options.generateID()
|
|
3026
3068
|
}
|
|
3027
3069
|
]);
|
|
3028
|
-
if (!Array.isArray(
|
|
3070
|
+
if (!Array.isArray(S) || S.length === 0)
|
|
3029
3071
|
throw new Error(
|
|
3030
|
-
"initialContent must be a non-empty array of blocks, received: " +
|
|
3072
|
+
"initialContent must be a non-empty array of blocks, received: " + S
|
|
3031
3073
|
);
|
|
3032
|
-
const P = Pt(
|
|
3033
|
-
(
|
|
3074
|
+
const P = Pt(i.extensions), w = S.map(
|
|
3075
|
+
(Ne) => q(Ne, P, this.schema.styleSchema).toJSON()
|
|
3034
3076
|
), v = vt(
|
|
3035
3077
|
{
|
|
3036
3078
|
type: "doc",
|
|
@@ -3042,29 +3084,29 @@ class De extends ye {
|
|
|
3042
3084
|
]
|
|
3043
3085
|
},
|
|
3044
3086
|
P,
|
|
3045
|
-
|
|
3087
|
+
i.parseOptions
|
|
3046
3088
|
);
|
|
3047
3089
|
this._tiptapEditor = new It({
|
|
3048
|
-
...
|
|
3090
|
+
...i,
|
|
3049
3091
|
content: v.toJSON()
|
|
3050
3092
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
3051
|
-
} catch (
|
|
3093
|
+
} catch (S) {
|
|
3052
3094
|
throw new Error(
|
|
3053
3095
|
"Error creating document from blocks passed as `initialContent`",
|
|
3054
|
-
{ cause:
|
|
3096
|
+
{ cause: S }
|
|
3055
3097
|
);
|
|
3056
3098
|
}
|
|
3057
3099
|
let c;
|
|
3058
3100
|
const a = this.pmSchema.nodes.doc.createAndFill;
|
|
3059
|
-
this.pmSchema.nodes.doc.createAndFill = (...
|
|
3101
|
+
this.pmSchema.nodes.doc.createAndFill = (...S) => {
|
|
3060
3102
|
if (c)
|
|
3061
3103
|
return c;
|
|
3062
|
-
const P = a.apply(this.pmSchema.nodes.doc,
|
|
3104
|
+
const P = a.apply(this.pmSchema.nodes.doc, S), w = JSON.parse(JSON.stringify(P.toJSON()));
|
|
3063
3105
|
return w.content[0].content[0].attrs.id = "initialBlockId", c = He.fromJSON(this.pmSchema, w), c;
|
|
3064
|
-
}, this.pmSchema.cached.blockNoteEditor = this, this._blockManager = new
|
|
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");
|
|
3065
3107
|
}
|
|
3066
3108
|
static create(t) {
|
|
3067
|
-
return new
|
|
3109
|
+
return new Le(t ?? {});
|
|
3068
3110
|
}
|
|
3069
3111
|
/**
|
|
3070
3112
|
* BlockNote extensions that are added to the editor, keyed by the extension key
|
|
@@ -3161,19 +3203,20 @@ class De extends ye {
|
|
|
3161
3203
|
* Blur the editor
|
|
3162
3204
|
*/
|
|
3163
3205
|
blur() {
|
|
3164
|
-
|
|
3206
|
+
var t;
|
|
3207
|
+
this.headless || (t = this.domElement) == null || t.blur();
|
|
3165
3208
|
}
|
|
3166
3209
|
// TODO move to extension
|
|
3167
3210
|
onUploadStart(t) {
|
|
3168
3211
|
return this.onUploadStartCallbacks.push(t), () => {
|
|
3169
|
-
const
|
|
3170
|
-
|
|
3212
|
+
const n = this.onUploadStartCallbacks.indexOf(t);
|
|
3213
|
+
n > -1 && this.onUploadStartCallbacks.splice(n, 1);
|
|
3171
3214
|
};
|
|
3172
3215
|
}
|
|
3173
3216
|
onUploadEnd(t) {
|
|
3174
3217
|
return this.onUploadEndCallbacks.push(t), () => {
|
|
3175
|
-
const
|
|
3176
|
-
|
|
3218
|
+
const n = this.onUploadEndCallbacks.indexOf(t);
|
|
3219
|
+
n > -1 && this.onUploadEndCallbacks.splice(n, 1);
|
|
3177
3220
|
};
|
|
3178
3221
|
}
|
|
3179
3222
|
/**
|
|
@@ -3237,8 +3280,8 @@ class De extends ye {
|
|
|
3237
3280
|
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
3238
3281
|
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
3239
3282
|
*/
|
|
3240
|
-
forEachBlock(t,
|
|
3241
|
-
this._blockManager.forEachBlock(t,
|
|
3283
|
+
forEachBlock(t, n = !1) {
|
|
3284
|
+
this._blockManager.forEachBlock(t, n);
|
|
3242
3285
|
}
|
|
3243
3286
|
/**
|
|
3244
3287
|
* Executes a callback whenever the editor's contents change.
|
|
@@ -3258,6 +3301,14 @@ class De extends ye {
|
|
|
3258
3301
|
onEditorSelectionChange(t) {
|
|
3259
3302
|
this._tiptapEditor.on("selectionUpdate", t);
|
|
3260
3303
|
}
|
|
3304
|
+
/**
|
|
3305
|
+
* Executes a callback before any change is applied to the editor, allowing you to cancel the change.
|
|
3306
|
+
* @param callback The callback to execute.
|
|
3307
|
+
* @returns A function to remove the callback.
|
|
3308
|
+
*/
|
|
3309
|
+
onBeforeChange(t) {
|
|
3310
|
+
return this._extensionManager.getExtension(ye).subscribe(t);
|
|
3311
|
+
}
|
|
3261
3312
|
/**
|
|
3262
3313
|
* Gets a snapshot of the current text cursor position.
|
|
3263
3314
|
* @returns A snapshot of the current text cursor position.
|
|
@@ -3271,8 +3322,8 @@ class De extends ye {
|
|
|
3271
3322
|
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
3272
3323
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
3273
3324
|
*/
|
|
3274
|
-
setTextCursorPosition(t,
|
|
3275
|
-
return this._selectionManager.setTextCursorPosition(t,
|
|
3325
|
+
setTextCursorPosition(t, n = "start") {
|
|
3326
|
+
return this._selectionManager.setTextCursorPosition(t, n);
|
|
3276
3327
|
}
|
|
3277
3328
|
/**
|
|
3278
3329
|
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
@@ -3290,16 +3341,16 @@ class De extends ye {
|
|
|
3290
3341
|
* If the selection starts / ends halfway through a block, the returned block will be
|
|
3291
3342
|
* only the part of the block that is included in the selection.
|
|
3292
3343
|
*/
|
|
3293
|
-
getSelectionCutBlocks() {
|
|
3294
|
-
return this._selectionManager.getSelectionCutBlocks();
|
|
3344
|
+
getSelectionCutBlocks(t = !1) {
|
|
3345
|
+
return this._selectionManager.getSelectionCutBlocks(t);
|
|
3295
3346
|
}
|
|
3296
3347
|
/**
|
|
3297
3348
|
* Sets the selection to a range of blocks.
|
|
3298
3349
|
* @param startBlock The identifier of the block that should be the start of the selection.
|
|
3299
3350
|
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
3300
3351
|
*/
|
|
3301
|
-
setSelection(t,
|
|
3302
|
-
return this._selectionManager.setSelection(t,
|
|
3352
|
+
setSelection(t, n) {
|
|
3353
|
+
return this._selectionManager.setSelection(t, n);
|
|
3303
3354
|
}
|
|
3304
3355
|
/**
|
|
3305
3356
|
* Checks if the editor is currently editable, or if it's locked.
|
|
@@ -3323,10 +3374,10 @@ class De extends ye {
|
|
|
3323
3374
|
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
3324
3375
|
* `referenceBlock`.
|
|
3325
3376
|
*/
|
|
3326
|
-
insertBlocks(t,
|
|
3377
|
+
insertBlocks(t, n, s = "before") {
|
|
3327
3378
|
return this._blockManager.insertBlocks(
|
|
3328
3379
|
t,
|
|
3329
|
-
|
|
3380
|
+
n,
|
|
3330
3381
|
s
|
|
3331
3382
|
);
|
|
3332
3383
|
}
|
|
@@ -3337,8 +3388,8 @@ class De extends ye {
|
|
|
3337
3388
|
* @param blockToUpdate The block that should be updated.
|
|
3338
3389
|
* @param update A partial block which defines how the existing block should be changed.
|
|
3339
3390
|
*/
|
|
3340
|
-
updateBlock(t,
|
|
3341
|
-
return this._blockManager.updateBlock(t,
|
|
3391
|
+
updateBlock(t, n) {
|
|
3392
|
+
return this._blockManager.updateBlock(t, n);
|
|
3342
3393
|
}
|
|
3343
3394
|
/**
|
|
3344
3395
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
@@ -3354,8 +3405,8 @@ class De extends ye {
|
|
|
3354
3405
|
* @param blocksToRemove An array of blocks that should be replaced.
|
|
3355
3406
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
3356
3407
|
*/
|
|
3357
|
-
replaceBlocks(t,
|
|
3358
|
-
return this._blockManager.replaceBlocks(t,
|
|
3408
|
+
replaceBlocks(t, n) {
|
|
3409
|
+
return this._blockManager.replaceBlocks(t, n);
|
|
3359
3410
|
}
|
|
3360
3411
|
/**
|
|
3361
3412
|
* Undo the last action.
|
|
@@ -3374,8 +3425,8 @@ class De extends ye {
|
|
|
3374
3425
|
*
|
|
3375
3426
|
* @param content can be a string, or array of partial inline content elements
|
|
3376
3427
|
*/
|
|
3377
|
-
insertInlineContent(t, { updateSelection:
|
|
3378
|
-
this._styleManager.insertInlineContent(t, { updateSelection:
|
|
3428
|
+
insertInlineContent(t, { updateSelection: n = !1 } = {}) {
|
|
3429
|
+
this._styleManager.insertInlineContent(t, { updateSelection: n });
|
|
3379
3430
|
}
|
|
3380
3431
|
/**
|
|
3381
3432
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -3421,8 +3472,8 @@ class De extends ye {
|
|
|
3421
3472
|
* @param url The link URL.
|
|
3422
3473
|
* @param text The text to display the link with.
|
|
3423
3474
|
*/
|
|
3424
|
-
createLink(t,
|
|
3425
|
-
this._styleManager.createLink(t,
|
|
3475
|
+
createLink(t, n) {
|
|
3476
|
+
this._styleManager.createLink(t, n);
|
|
3426
3477
|
}
|
|
3427
3478
|
/**
|
|
3428
3479
|
* Checks if the block containing the text cursor can be nested.
|
|
@@ -3521,8 +3572,8 @@ class De extends ye {
|
|
|
3521
3572
|
* @param callback The callback to execute.
|
|
3522
3573
|
* @returns A function to remove the callback.
|
|
3523
3574
|
*/
|
|
3524
|
-
onChange(t,
|
|
3525
|
-
return this._eventManager.onChange(t,
|
|
3575
|
+
onChange(t, n) {
|
|
3576
|
+
return this._eventManager.onChange(t, n);
|
|
3526
3577
|
}
|
|
3527
3578
|
/**
|
|
3528
3579
|
* A callback function that runs whenever the text cursor position or selection changes.
|
|
@@ -3530,10 +3581,10 @@ class De extends ye {
|
|
|
3530
3581
|
* @param callback The callback to execute.
|
|
3531
3582
|
* @returns A function to remove the callback.
|
|
3532
3583
|
*/
|
|
3533
|
-
onSelectionChange(t,
|
|
3584
|
+
onSelectionChange(t, n) {
|
|
3534
3585
|
return this._eventManager.onSelectionChange(
|
|
3535
3586
|
t,
|
|
3536
|
-
|
|
3587
|
+
n
|
|
3537
3588
|
);
|
|
3538
3589
|
}
|
|
3539
3590
|
/**
|
|
@@ -3574,8 +3625,8 @@ class De extends ye {
|
|
|
3574
3625
|
* @param html The HTML to paste.
|
|
3575
3626
|
* @param raw Whether to paste the HTML as is, or to convert it to BlockNote HTML.
|
|
3576
3627
|
*/
|
|
3577
|
-
pasteHTML(t,
|
|
3578
|
-
this._exportManager.pasteHTML(t,
|
|
3628
|
+
pasteHTML(t, n = !1) {
|
|
3629
|
+
this._exportManager.pasteHTML(t, n);
|
|
3579
3630
|
}
|
|
3580
3631
|
/**
|
|
3581
3632
|
* Paste text into the editor. Defaults to interpreting text as markdown.
|
|
@@ -3592,19 +3643,19 @@ class De extends ye {
|
|
|
3592
3643
|
return this._exportManager.pasteMarkdown(t);
|
|
3593
3644
|
}
|
|
3594
3645
|
}
|
|
3595
|
-
class
|
|
3596
|
-
constructor(e, t,
|
|
3597
|
-
this.mappings = t, this.options =
|
|
3646
|
+
class Xn {
|
|
3647
|
+
constructor(e, t, n) {
|
|
3648
|
+
this.mappings = t, this.options = n;
|
|
3598
3649
|
}
|
|
3599
3650
|
async resolveFile(e) {
|
|
3600
|
-
var
|
|
3601
|
-
if (!((
|
|
3651
|
+
var n;
|
|
3652
|
+
if (!((n = this.options) != null && n.resolveFileUrl))
|
|
3602
3653
|
return (await fetch(e)).blob();
|
|
3603
3654
|
const t = await this.options.resolveFileUrl(e);
|
|
3604
3655
|
return t instanceof Blob ? t : (await fetch(t)).blob();
|
|
3605
3656
|
}
|
|
3606
3657
|
mapStyles(e) {
|
|
3607
|
-
return Object.entries(e).map(([
|
|
3658
|
+
return Object.entries(e).map(([n, s]) => this.mappings.styleMapping[n](s, this));
|
|
3608
3659
|
}
|
|
3609
3660
|
mapInlineContent(e) {
|
|
3610
3661
|
return this.mappings.inlineContentMapping[e.type](
|
|
@@ -3615,200 +3666,201 @@ class Yn {
|
|
|
3615
3666
|
transformInlineContent(e) {
|
|
3616
3667
|
return e.map((t) => this.mapInlineContent(t));
|
|
3617
3668
|
}
|
|
3618
|
-
async mapBlock(e, t,
|
|
3669
|
+
async mapBlock(e, t, n, s) {
|
|
3619
3670
|
return this.mappings.blockMapping[e.type](
|
|
3620
3671
|
e,
|
|
3621
3672
|
this,
|
|
3622
3673
|
t,
|
|
3623
|
-
|
|
3674
|
+
n,
|
|
3624
3675
|
s
|
|
3625
3676
|
);
|
|
3626
3677
|
}
|
|
3627
3678
|
}
|
|
3628
|
-
function
|
|
3679
|
+
function Zn(o) {
|
|
3629
3680
|
return {
|
|
3630
3681
|
createBlockMapping: (e) => e,
|
|
3631
3682
|
createInlineContentMapping: (e) => e,
|
|
3632
3683
|
createStyleMapping: (e) => e
|
|
3633
3684
|
};
|
|
3634
3685
|
}
|
|
3635
|
-
function
|
|
3636
|
-
const t = [...
|
|
3637
|
-
for (const
|
|
3638
|
-
for (const s of
|
|
3639
|
-
const
|
|
3640
|
-
(
|
|
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
|
|
3641
3692
|
);
|
|
3642
|
-
|
|
3693
|
+
r === -1 ? t.push(s) : t.splice(r + 1, 0, s);
|
|
3643
3694
|
}
|
|
3644
3695
|
return t;
|
|
3645
3696
|
}
|
|
3646
3697
|
export {
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3698
|
+
Le as BlockNoteEditor,
|
|
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,
|
|
3705
|
+
Se as EventEmitter,
|
|
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,
|
|
3710
|
+
Pe as HTMLToBlocks,
|
|
3660
3711
|
me as UniqueID,
|
|
3661
3712
|
F as UnreachableCaseError,
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3713
|
+
Ms as addDefaultPropsExternalHTML,
|
|
3714
|
+
H as addInlineContentAttributes,
|
|
3715
|
+
We as addInlineContentKeyboardShortcuts,
|
|
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,
|
|
3725
|
+
nt as blocksToMarkdown,
|
|
3726
|
+
Ds as camelToDataKebab,
|
|
3727
|
+
Ls as captureCellAnchor,
|
|
3728
|
+
Zr as checkPageBreakBlocksInSchema,
|
|
3729
|
+
st as cleanHTMLToMarkdown,
|
|
3730
|
+
es as combineByGroup,
|
|
3731
|
+
Re as contentNodeToInlineContent,
|
|
3732
|
+
Ge as contentNodeToTableContent,
|
|
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,
|
|
3697
3748
|
be as createExternalHTMLExporter,
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
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,
|
|
3756
|
+
Je as createInlineContentSpecFromTipTapNode,
|
|
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,
|
|
3785
|
+
ze as docToBlocks,
|
|
3786
|
+
Mr as editorHasBlockWithType,
|
|
3787
|
+
un as expandPMRangeToWords,
|
|
3788
|
+
wr as fileParse,
|
|
3789
|
+
Tr as filenameFromURL,
|
|
3738
3790
|
W as fixColumnList,
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3791
|
+
Pr as formatKeyboardShortcut,
|
|
3792
|
+
Qe as getBackgroundColorAttribute,
|
|
3793
|
+
ao as getBlock,
|
|
3794
|
+
ss as getBlockCache,
|
|
3795
|
+
vr as getBlockFromPos,
|
|
3744
3796
|
z as getBlockInfo,
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3797
|
+
Y as getBlockInfoFromResolvedPos,
|
|
3798
|
+
B as getBlockInfoFromSelection,
|
|
3799
|
+
$ as getBlockInfoFromTransaction,
|
|
3800
|
+
rs as getBlockInfoWithManualOffset,
|
|
3749
3801
|
ke as getBlockNoteSchema,
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3802
|
+
is as getBlockSchema,
|
|
3803
|
+
ot as getBlocksChangedByTransaction,
|
|
3804
|
+
as as getColspan,
|
|
3805
|
+
Kt as getInlineContentParseRules,
|
|
3806
|
+
cs as getInlineContentSchema,
|
|
3807
|
+
Ir as getInlineContentSchemaFromSpecs,
|
|
3808
|
+
Ar as getLanguageId,
|
|
3757
3809
|
_ as getNearestBlockPos,
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
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,
|
|
3815
|
+
C as getPmSchema,
|
|
3816
|
+
co as getPrevBlock,
|
|
3817
|
+
ls as getRowspan,
|
|
3818
|
+
Dr as getStyleParseRules,
|
|
3819
|
+
ds as getStyleSchema,
|
|
3820
|
+
Lr as getStyleSchemaFromSpecs,
|
|
3821
|
+
Nr as getTextAlignmentAttribute,
|
|
3822
|
+
et as getTextColorAttribute,
|
|
3823
|
+
Or as imageParse,
|
|
3824
|
+
Fr as imageRender,
|
|
3825
|
+
$r as imageToExternalHTML,
|
|
3774
3826
|
O as inlineContentToNodes,
|
|
3775
|
-
|
|
3776
|
-
|
|
3827
|
+
Jt as insertBlocks,
|
|
3828
|
+
Hr as isAppleOS,
|
|
3777
3829
|
j as isEmptyColumn,
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
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,
|
|
3786
3838
|
Ye as isVideoUrl,
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3839
|
+
ks as mapTableCell,
|
|
3840
|
+
Zn as mappingFactory,
|
|
3841
|
+
Co as markdownToBlocks,
|
|
3842
|
+
ve as markdownToHTML,
|
|
3791
3843
|
Q as mergeCSSClasses,
|
|
3792
|
-
|
|
3844
|
+
Gr as mergeParagraphs,
|
|
3793
3845
|
b as nodeToBlock,
|
|
3794
3846
|
U as nodeToCustomInlineContent,
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3847
|
+
Rr as parseAudioElement,
|
|
3848
|
+
jr as parseDefaultProps,
|
|
3849
|
+
Ke as propsToAttributes,
|
|
3850
|
+
je as prosemirrorSliceToSlicedBlocks,
|
|
3799
3851
|
ie as removeAndInsertBlocks,
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3852
|
+
qt as removeEmptyColumns,
|
|
3853
|
+
Ae as selectedFragmentToHTML,
|
|
3854
|
+
Wr as stylePropsToAttributes,
|
|
3855
|
+
Ue as tableContentToNodes,
|
|
3856
|
+
Kr as tablePropSchema,
|
|
3857
|
+
Jr as trackPosition,
|
|
3858
|
+
qe as updateBlock,
|
|
3859
|
+
Ze as updateBlockCommand,
|
|
3860
|
+
tt as updateBlockTr,
|
|
3861
|
+
ni as uploadToTmpFilesDotOrg_DEV_ONLY,
|
|
3862
|
+
qr as videoParse,
|
|
3863
|
+
si as withPageBreak,
|
|
3864
|
+
Yr as wrapInBlockStructure
|
|
3813
3865
|
};
|
|
3814
3866
|
//# sourceMappingURL=blocknote.js.map
|