@blocknote/core 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +353 -318
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +2 -2
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +21 -21
- package/src/BlockNoteEditor.ts +46 -10
- package/src/BlockNoteExtensions.ts +50 -1
- package/src/editor.module.css +32 -2
- package/src/extensions/Blocks/nodes/Block.module.css +15 -11
- package/types/src/BlockNoteEditor.d.ts +36 -3
- package/types/src/BlockNoteExtensions.d.ts +10 -0
- package/types/src/CustomBlock.d.ts +15 -0
- package/types/src/extensions/Blocks/api/alertBlock.d.ts +13 -0
- package/types/src/extensions/Blocks/api/alertBlock2.d.ts +13 -0
- package/types/src/extensions/Blocks/api/block.d.ts +15 -0
- package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +81 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableCol.d.ts +2 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableContent.d.ts +2 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableRow.d.ts +2 -0
package/dist/blocknote.js
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
var Et = Object.defineProperty;
|
|
2
2
|
var Ct = (o, t, e) => t in o ? Et(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
3
|
var u = (o, t, e) => (Ct(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
-
import { Extension as E, findChildren as
|
|
4
|
+
import { Extension as E, findChildren as G, combineTransactionSteps as Mt, getChangedRanges as Bt, findChildrenInRange as Tt, Mark as rt, Node as S, mergeAttributes as w, InputRule as j, findParentNode as wt, isTextSelection as St, isNodeSelection as xt, posToDOMRect as nt, getMarkRange as X, extensions as N, Editor as It } from "@tiptap/core";
|
|
5
5
|
import { Slice as P, Fragment as L, DOMSerializer as Pt, DOMParser as Lt } from "prosemirror-model";
|
|
6
|
-
import { Plugin as C, PluginKey as v, TextSelection as Q, Selection as
|
|
7
|
-
import { v4 as
|
|
6
|
+
import { Plugin as C, PluginKey as v, TextSelection as Q, Selection as $, NodeSelection as _t } from "prosemirror-state";
|
|
7
|
+
import { v4 as At } from "uuid";
|
|
8
8
|
import it from "rehype-parse";
|
|
9
9
|
import Nt from "rehype-remark";
|
|
10
10
|
import st from "rehype-stringify";
|
|
11
11
|
import at from "remark-gfm";
|
|
12
|
-
import
|
|
12
|
+
import Ht from "remark-parse";
|
|
13
13
|
import Ot from "remark-rehype";
|
|
14
14
|
import Dt from "remark-stringify";
|
|
15
|
-
import { unified as
|
|
15
|
+
import { unified as W } from "unified";
|
|
16
16
|
import { fromDom as Z } from "hast-util-from-dom";
|
|
17
17
|
import { Bold as Ft } from "@tiptap/extension-bold";
|
|
18
18
|
import { Code as Rt } from "@tiptap/extension-code";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import
|
|
19
|
+
import zt from "@tiptap/extension-collaboration";
|
|
20
|
+
import Ut from "@tiptap/extension-collaboration-cursor";
|
|
21
|
+
import { Dropcursor as $t } from "@tiptap/extension-dropcursor";
|
|
22
|
+
import { Gapcursor as Gt } from "@tiptap/extension-gapcursor";
|
|
23
|
+
import { HardBreak as qt } from "@tiptap/extension-hard-break";
|
|
24
|
+
import { History as jt } from "@tiptap/extension-history";
|
|
25
|
+
import { Italic as Wt } from "@tiptap/extension-italic";
|
|
26
|
+
import { Link as lt } from "@tiptap/extension-link";
|
|
27
|
+
import { Strike as Yt } from "@tiptap/extension-strike";
|
|
28
|
+
import { Text as Kt } from "@tiptap/extension-text";
|
|
29
|
+
import { Underline as Vt } from "@tiptap/extension-underline";
|
|
30
|
+
import * as Jt from "prosemirror-view";
|
|
29
31
|
import { Decoration as D, DecorationSet as F } from "prosemirror-view";
|
|
30
|
-
const
|
|
32
|
+
const O = [
|
|
31
33
|
"backgroundColor",
|
|
32
34
|
"textColor",
|
|
33
35
|
"textAlignment"
|
|
34
36
|
], tt = {
|
|
35
|
-
paragraph: /* @__PURE__ */ new Set([...
|
|
37
|
+
paragraph: /* @__PURE__ */ new Set([...O]),
|
|
36
38
|
heading: /* @__PURE__ */ new Set([
|
|
37
|
-
...
|
|
39
|
+
...O,
|
|
38
40
|
"level"
|
|
39
41
|
]),
|
|
40
42
|
numberedListItem: /* @__PURE__ */ new Set([
|
|
41
|
-
...
|
|
43
|
+
...O
|
|
42
44
|
]),
|
|
43
|
-
bulletListItem: /* @__PURE__ */ new Set([...
|
|
45
|
+
bulletListItem: /* @__PURE__ */ new Set([...O])
|
|
44
46
|
};
|
|
45
47
|
function g(o, t) {
|
|
46
48
|
if (t < 0 || t > o.nodeSize)
|
|
@@ -54,30 +56,30 @@ function g(o, t) {
|
|
|
54
56
|
break;
|
|
55
57
|
i -= 1, n = e.node(i);
|
|
56
58
|
}
|
|
57
|
-
const a = n.attrs.id, s = n.firstChild,
|
|
59
|
+
const a = n.attrs.id, s = n.firstChild, l = s.type, d = n.childCount === 2 ? n.lastChild.childCount : 0, c = e.start(i), h = e.end(i);
|
|
58
60
|
return {
|
|
59
61
|
id: a,
|
|
60
62
|
node: n,
|
|
61
63
|
contentNode: s,
|
|
62
|
-
contentType:
|
|
63
|
-
numChildBlocks:
|
|
64
|
+
contentType: l,
|
|
65
|
+
numChildBlocks: d,
|
|
64
66
|
startPos: c,
|
|
65
67
|
endPos: h,
|
|
66
68
|
depth: i
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
|
-
function
|
|
71
|
+
function Xt(o, t = JSON.stringify) {
|
|
70
72
|
const e = {};
|
|
71
73
|
return o.filter((r) => {
|
|
72
74
|
const n = t(r);
|
|
73
75
|
return Object.prototype.hasOwnProperty.call(e, n) ? !1 : e[n] = !0;
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
|
-
function
|
|
78
|
+
function Qt(o) {
|
|
77
79
|
const t = o.filter(
|
|
78
80
|
(r, n) => o.indexOf(r) !== n
|
|
79
81
|
);
|
|
80
|
-
return
|
|
82
|
+
return Xt(t);
|
|
81
83
|
}
|
|
82
84
|
const Y = E.create({
|
|
83
85
|
name: "uniqueID",
|
|
@@ -88,7 +90,7 @@ const Y = E.create({
|
|
|
88
90
|
return {
|
|
89
91
|
attributeName: "id",
|
|
90
92
|
types: [],
|
|
91
|
-
generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) :
|
|
93
|
+
generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) : At(),
|
|
92
94
|
filterTransaction: null
|
|
93
95
|
};
|
|
94
96
|
},
|
|
@@ -111,13 +113,13 @@ const Y = E.create({
|
|
|
111
113
|
// check initial content for missing ids
|
|
112
114
|
onCreate() {
|
|
113
115
|
if (this.editor.extensionManager.extensions.find(
|
|
114
|
-
(
|
|
116
|
+
(l) => l.name === "collaboration"
|
|
115
117
|
))
|
|
116
118
|
return;
|
|
117
119
|
const { view: o, state: t } = this.editor, { tr: e, doc: r } = t, { types: n, attributeName: i, generateID: a } = this.options;
|
|
118
|
-
|
|
119
|
-
e.setNodeMarkup(
|
|
120
|
-
...
|
|
120
|
+
G(r, (l) => n.includes(l.type.name) && l.attrs[i] === null).forEach(({ node: l, pos: d }) => {
|
|
121
|
+
e.setNodeMarkup(d, void 0, {
|
|
122
|
+
...l.attrs,
|
|
121
123
|
[i]: a()
|
|
122
124
|
});
|
|
123
125
|
}), e.setMeta("addToHistory", !1), o.dispatch(e);
|
|
@@ -134,7 +136,7 @@ const Y = E.create({
|
|
|
134
136
|
});
|
|
135
137
|
if (!i || a)
|
|
136
138
|
return;
|
|
137
|
-
const { tr: s } = n, { types:
|
|
139
|
+
const { tr: s } = n, { types: l, attributeName: d, generateID: c } = this.options, h = Mt(
|
|
138
140
|
r.doc,
|
|
139
141
|
e
|
|
140
142
|
), { mapping: f } = h;
|
|
@@ -142,22 +144,22 @@ const Y = E.create({
|
|
|
142
144
|
const y = Tt(
|
|
143
145
|
n.doc,
|
|
144
146
|
m,
|
|
145
|
-
(M) =>
|
|
146
|
-
), k = y.map(({ node: M }) => M.attrs[
|
|
147
|
-
y.forEach(({ node: M, pos:
|
|
147
|
+
(M) => l.includes(M.type.name)
|
|
148
|
+
), k = y.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), z = Qt(k);
|
|
149
|
+
y.forEach(({ node: M, pos: H }) => {
|
|
148
150
|
var U;
|
|
149
|
-
const J = (U = s.doc.nodeAt(
|
|
151
|
+
const J = (U = s.doc.nodeAt(H)) === null || U === void 0 ? void 0 : U.attrs[d];
|
|
150
152
|
if (J === null) {
|
|
151
|
-
s.setNodeMarkup(
|
|
153
|
+
s.setNodeMarkup(H, void 0, {
|
|
152
154
|
...M.attrs,
|
|
153
|
-
[
|
|
155
|
+
[d]: c()
|
|
154
156
|
});
|
|
155
157
|
return;
|
|
156
158
|
}
|
|
157
|
-
const { deleted: vt } = f.invert().mapResult(
|
|
158
|
-
vt && z.includes(J) && s.setNodeMarkup(
|
|
159
|
+
const { deleted: vt } = f.invert().mapResult(H);
|
|
160
|
+
vt && z.includes(J) && s.setNodeMarkup(H, void 0, {
|
|
159
161
|
...M.attrs,
|
|
160
|
-
[
|
|
162
|
+
[d]: c()
|
|
161
163
|
});
|
|
162
164
|
});
|
|
163
165
|
}), !!s.steps.length)
|
|
@@ -195,24 +197,24 @@ const Y = E.create({
|
|
|
195
197
|
return e;
|
|
196
198
|
const { types: r, attributeName: n } = this.options, i = (a) => {
|
|
197
199
|
const s = [];
|
|
198
|
-
return a.forEach((
|
|
199
|
-
if (
|
|
200
|
-
s.push(
|
|
200
|
+
return a.forEach((l) => {
|
|
201
|
+
if (l.isText) {
|
|
202
|
+
s.push(l);
|
|
201
203
|
return;
|
|
202
204
|
}
|
|
203
|
-
if (!r.includes(
|
|
204
|
-
s.push(
|
|
205
|
+
if (!r.includes(l.type.name)) {
|
|
206
|
+
s.push(l.copy(i(l.content)));
|
|
205
207
|
return;
|
|
206
208
|
}
|
|
207
|
-
const
|
|
209
|
+
const d = l.type.create(
|
|
208
210
|
{
|
|
209
|
-
...
|
|
211
|
+
...l.attrs,
|
|
210
212
|
[n]: null
|
|
211
213
|
},
|
|
212
|
-
i(
|
|
213
|
-
|
|
214
|
+
i(l.content),
|
|
215
|
+
l.marks
|
|
214
216
|
);
|
|
215
|
-
s.push(
|
|
217
|
+
s.push(d);
|
|
216
218
|
}), L.from(s);
|
|
217
219
|
};
|
|
218
220
|
return t = !1, new P(
|
|
@@ -226,25 +228,25 @@ const Y = E.create({
|
|
|
226
228
|
];
|
|
227
229
|
}
|
|
228
230
|
});
|
|
229
|
-
class
|
|
231
|
+
class Zt extends Error {
|
|
230
232
|
constructor(t) {
|
|
231
233
|
super(`Unreachable case: ${t}`);
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
|
-
const
|
|
236
|
+
const dt = /* @__PURE__ */ new Set([
|
|
235
237
|
"bold",
|
|
236
238
|
"italic",
|
|
237
239
|
"underline",
|
|
238
240
|
"strike",
|
|
239
241
|
"code"
|
|
240
242
|
]), ct = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
241
|
-
function
|
|
243
|
+
function te(o, t) {
|
|
242
244
|
const e = [];
|
|
243
245
|
for (const [r, n] of Object.entries(o.styles))
|
|
244
|
-
|
|
246
|
+
dt.has(r) ? e.push(t.mark(r)) : ct.has(r) && e.push(t.mark(r, { color: n }));
|
|
245
247
|
return t.text(o.text, e);
|
|
246
248
|
}
|
|
247
|
-
function
|
|
249
|
+
function ee(o, t) {
|
|
248
250
|
const e = t.marks.link.create({
|
|
249
251
|
href: o.href
|
|
250
252
|
});
|
|
@@ -255,18 +257,18 @@ function ut(o, t) {
|
|
|
255
257
|
if (typeof o == "string")
|
|
256
258
|
return e.push(t.text(o)), e;
|
|
257
259
|
for (const r of o)
|
|
258
|
-
e.push(
|
|
260
|
+
e.push(te(r, t));
|
|
259
261
|
return e;
|
|
260
262
|
}
|
|
261
263
|
function ht(o, t) {
|
|
262
264
|
let e = [];
|
|
263
265
|
for (const r of o)
|
|
264
266
|
if (r.type === "link")
|
|
265
|
-
e.push(...
|
|
267
|
+
e.push(...ee(r, t));
|
|
266
268
|
else if (r.type === "text")
|
|
267
269
|
e.push(...ut([r], t));
|
|
268
270
|
else
|
|
269
|
-
throw new
|
|
271
|
+
throw new Zt(r);
|
|
270
272
|
return e;
|
|
271
273
|
}
|
|
272
274
|
function R(o, t) {
|
|
@@ -299,7 +301,7 @@ function R(o, t) {
|
|
|
299
301
|
i.length > 0 ? [n, a] : n
|
|
300
302
|
);
|
|
301
303
|
}
|
|
302
|
-
function
|
|
304
|
+
function oe(o) {
|
|
303
305
|
const t = [];
|
|
304
306
|
let e;
|
|
305
307
|
return o.content.forEach((r) => {
|
|
@@ -308,7 +310,7 @@ function te(o) {
|
|
|
308
310
|
for (const a of r.marks)
|
|
309
311
|
if (a.type.name === "link")
|
|
310
312
|
i = a;
|
|
311
|
-
else if (
|
|
313
|
+
else if (dt.has(a.type.name))
|
|
312
314
|
n[a.type.name] = !0;
|
|
313
315
|
else if (ct.has(a.type.name))
|
|
314
316
|
n[a.type.name] = a.attrs.color;
|
|
@@ -347,7 +349,7 @@ function B(o, t) {
|
|
|
347
349
|
let n = r.id;
|
|
348
350
|
n === null && (n = Y.options.generateID());
|
|
349
351
|
const i = {};
|
|
350
|
-
for (const [
|
|
352
|
+
for (const [d, c] of Object.entries({
|
|
351
353
|
...r.node.attrs,
|
|
352
354
|
...r.contentNode.attrs
|
|
353
355
|
})) {
|
|
@@ -355,19 +357,19 @@ function B(o, t) {
|
|
|
355
357
|
throw Error(
|
|
356
358
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
357
359
|
);
|
|
358
|
-
tt[r.contentType.name].has(
|
|
360
|
+
tt[r.contentType.name].has(d) && (i[d] = c);
|
|
359
361
|
}
|
|
360
|
-
const a =
|
|
361
|
-
for (let
|
|
362
|
-
s.push(B(r.node.lastChild.child(
|
|
363
|
-
const
|
|
362
|
+
const a = oe(r.contentNode), s = [];
|
|
363
|
+
for (let d = 0; d < r.numChildBlocks; d++)
|
|
364
|
+
s.push(B(r.node.lastChild.child(d)));
|
|
365
|
+
const l = {
|
|
364
366
|
id: n,
|
|
365
367
|
type: r.contentType.name,
|
|
366
368
|
props: i,
|
|
367
369
|
content: a,
|
|
368
370
|
children: s
|
|
369
371
|
};
|
|
370
|
-
return t == null || t.set(o,
|
|
372
|
+
return t == null || t.set(o, l), l;
|
|
371
373
|
}
|
|
372
374
|
function K(o, t) {
|
|
373
375
|
let e, r;
|
|
@@ -380,27 +382,27 @@ function K(o, t) {
|
|
|
380
382
|
}
|
|
381
383
|
function pt(o, t, e = "before", r) {
|
|
382
384
|
const n = typeof t == "string" ? t : t.id, i = [];
|
|
383
|
-
for (const
|
|
384
|
-
i.push(R(
|
|
385
|
+
for (const d of o)
|
|
386
|
+
i.push(R(d, r.schema));
|
|
385
387
|
let a = -1;
|
|
386
|
-
const { node: s, posBeforeNode:
|
|
387
|
-
if (e === "before" && (a =
|
|
388
|
+
const { node: s, posBeforeNode: l } = K(n, r.state.doc);
|
|
389
|
+
if (e === "before" && (a = l), e === "after" && (a = l + s.nodeSize), e === "nested") {
|
|
388
390
|
if (s.childCount < 2) {
|
|
389
|
-
a =
|
|
390
|
-
const
|
|
391
|
+
a = l + s.firstChild.nodeSize + 1;
|
|
392
|
+
const d = r.state.schema.nodes.blockGroup.create(
|
|
391
393
|
{},
|
|
392
394
|
i
|
|
393
395
|
);
|
|
394
396
|
r.view.dispatch(
|
|
395
|
-
r.state.tr.insert(a,
|
|
397
|
+
r.state.tr.insert(a, d)
|
|
396
398
|
);
|
|
397
399
|
return;
|
|
398
400
|
}
|
|
399
|
-
a =
|
|
401
|
+
a = l + s.firstChild.nodeSize + 2;
|
|
400
402
|
}
|
|
401
403
|
r.view.dispatch(r.state.tr.insert(a, i));
|
|
402
404
|
}
|
|
403
|
-
function
|
|
405
|
+
function re(o, t, e) {
|
|
404
406
|
const r = typeof o == "string" ? o : o.id, { posBeforeNode: n } = K(r, e.state.doc);
|
|
405
407
|
e.commands.BNUpdateBlock(n + 1, t);
|
|
406
408
|
}
|
|
@@ -429,10 +431,10 @@ function ft(o, t) {
|
|
|
429
431
|
);
|
|
430
432
|
}
|
|
431
433
|
}
|
|
432
|
-
function
|
|
434
|
+
function ne(o, t, e) {
|
|
433
435
|
pt(t, o[0], "before", e), ft(o, e);
|
|
434
436
|
}
|
|
435
|
-
function
|
|
437
|
+
function ie() {
|
|
436
438
|
const o = (t) => {
|
|
437
439
|
let e = t.children.length;
|
|
438
440
|
for (let r = 0; r < e; r++) {
|
|
@@ -448,17 +450,17 @@ function re() {
|
|
|
448
450
|
};
|
|
449
451
|
return o;
|
|
450
452
|
}
|
|
451
|
-
function
|
|
453
|
+
function se(o) {
|
|
452
454
|
const t = /* @__PURE__ */ new Set([
|
|
453
455
|
...o.orderedListItemBlockTypes,
|
|
454
456
|
...o.unorderedListItemBlockTypes
|
|
455
457
|
]), e = (r) => {
|
|
456
458
|
let n = r.children.length, i;
|
|
457
459
|
for (let a = 0; a < n; a++) {
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
+
const l = r.children[a].children[0], d = l.children[0], c = l.children.length === 2 ? l.children[1] : null, h = t.has(
|
|
461
|
+
d.properties.dataContentType
|
|
460
462
|
), f = h ? o.orderedListItemBlockTypes.has(
|
|
461
|
-
|
|
463
|
+
d.properties.dataContentType
|
|
462
464
|
) ? "ol" : "ul" : null;
|
|
463
465
|
if (c !== null && e(c), i && i.tagName !== f) {
|
|
464
466
|
r.children.splice(
|
|
@@ -476,13 +478,13 @@ function ne(o) {
|
|
|
476
478
|
const p = Z(
|
|
477
479
|
document.createElement("li")
|
|
478
480
|
);
|
|
479
|
-
p.children.push(
|
|
481
|
+
p.children.push(d.children[0]), c !== null && p.children.push(...c.children), i.children.push(p);
|
|
480
482
|
} else if (c !== null) {
|
|
481
|
-
r.children.splice(a + 1, 0, ...c.children), r.children[a] =
|
|
483
|
+
r.children.splice(a + 1, 0, ...c.children), r.children[a] = d.children[0];
|
|
482
484
|
const p = c.children.length;
|
|
483
485
|
a += p, n += p;
|
|
484
486
|
} else
|
|
485
|
-
r.children[a] =
|
|
487
|
+
r.children[a] = d.children[0];
|
|
486
488
|
}
|
|
487
489
|
i && r.children.splice(
|
|
488
490
|
n - i.children.length,
|
|
@@ -498,7 +500,7 @@ async function mt(o, t) {
|
|
|
498
500
|
const a = R(i, t), s = r.serializeNode(a);
|
|
499
501
|
e.appendChild(s);
|
|
500
502
|
}
|
|
501
|
-
return (await
|
|
503
|
+
return (await W().use(it, { fragment: !0 }).use(se, {
|
|
502
504
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
503
505
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
504
506
|
}).use(st).process(e.innerHTML)).value;
|
|
@@ -511,14 +513,21 @@ async function gt(o, t) {
|
|
|
511
513
|
i.push(B(n.firstChild.child(a)));
|
|
512
514
|
return i;
|
|
513
515
|
}
|
|
514
|
-
async function
|
|
515
|
-
return (await
|
|
516
|
+
async function ae(o, t) {
|
|
517
|
+
return (await W().use(it, { fragment: !0 }).use(ie).use(Nt).use(at).use(Dt).process(await mt(o, t))).value;
|
|
516
518
|
}
|
|
517
|
-
async function
|
|
518
|
-
const e = await
|
|
519
|
+
async function le(o, t) {
|
|
520
|
+
const e = await W().use(Ht).use(at).use(Ot).use(st).process(o);
|
|
519
521
|
return gt(e.value, t);
|
|
520
522
|
}
|
|
521
|
-
const
|
|
523
|
+
const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_ywyu7_35", he = "_dragPreview_ywyu7_69", _ = {
|
|
524
|
+
bnEditor: de,
|
|
525
|
+
bnRoot: ce,
|
|
526
|
+
defaultStyles: ue,
|
|
527
|
+
dragPreview: he,
|
|
528
|
+
"collaboration-cursor__caret": "_collaboration-cursor__caret_ywyu7_75",
|
|
529
|
+
"collaboration-cursor__label": "_collaboration-cursor__label_ywyu7_86"
|
|
530
|
+
}, pe = E.create({
|
|
522
531
|
name: "blockBackgroundColor",
|
|
523
532
|
addGlobalAttributes() {
|
|
524
533
|
return [
|
|
@@ -548,7 +557,7 @@ const ae = E.create({
|
|
|
548
557
|
}
|
|
549
558
|
};
|
|
550
559
|
}
|
|
551
|
-
}),
|
|
560
|
+
}), fe = rt.create({
|
|
552
561
|
name: "backgroundColor",
|
|
553
562
|
addAttributes() {
|
|
554
563
|
return {
|
|
@@ -577,7 +586,7 @@ const ae = E.create({
|
|
|
577
586
|
setBackgroundColor: (o) => ({ commands: t }) => o !== "default" ? t.setMark(this.name, { color: o }) : t.unsetMark(this.name)
|
|
578
587
|
};
|
|
579
588
|
}
|
|
580
|
-
}), et = new v("previous-blocks"),
|
|
589
|
+
}), et = new v("previous-blocks"), me = {
|
|
581
590
|
// Numbered List Items
|
|
582
591
|
index: "index",
|
|
583
592
|
// Headings
|
|
@@ -586,7 +595,7 @@ const ae = E.create({
|
|
|
586
595
|
type: "type",
|
|
587
596
|
depth: "depth",
|
|
588
597
|
"depth-change": "depth-change"
|
|
589
|
-
},
|
|
598
|
+
}, ge = () => {
|
|
590
599
|
let o;
|
|
591
600
|
return new C({
|
|
592
601
|
key: et,
|
|
@@ -619,17 +628,17 @@ const ae = E.create({
|
|
|
619
628
|
apply(t, e, r, n) {
|
|
620
629
|
if (e.currentTransactionOldBlockAttrs = {}, e.updatedBlocks.clear(), !t.docChanged || r.doc.eq(n.doc))
|
|
621
630
|
return e;
|
|
622
|
-
const i = {}, a =
|
|
623
|
-
a.map((
|
|
624
|
-
),
|
|
625
|
-
for (let
|
|
626
|
-
const c = s.get(
|
|
631
|
+
const i = {}, a = G(r.doc, (d) => d.attrs.id), s = new Map(
|
|
632
|
+
a.map((d) => [d.node.attrs.id, d])
|
|
633
|
+
), l = G(n.doc, (d) => d.attrs.id);
|
|
634
|
+
for (let d of l) {
|
|
635
|
+
const c = s.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, f = d.node.firstChild;
|
|
627
636
|
if (c && h && f) {
|
|
628
637
|
const p = {
|
|
629
638
|
index: f.attrs.index,
|
|
630
639
|
level: f.attrs.level,
|
|
631
640
|
type: f.type.name,
|
|
632
|
-
depth: n.doc.resolve(
|
|
641
|
+
depth: n.doc.resolve(d.pos).depth
|
|
633
642
|
};
|
|
634
643
|
let m = {
|
|
635
644
|
index: h.attrs.index,
|
|
@@ -637,7 +646,7 @@ const ae = E.create({
|
|
|
637
646
|
type: h.type.name,
|
|
638
647
|
depth: r.doc.resolve(c.pos).depth
|
|
639
648
|
};
|
|
640
|
-
i[
|
|
649
|
+
i[d.node.attrs.id] = m, t.getMeta("numberedListIndexing") && (d.node.attrs.id in e.prevTransactionOldBlockAttrs && (m = e.prevTransactionOldBlockAttrs[d.node.attrs.id]), p.type === "numberedListItem" && (m.index = p.index)), e.currentTransactionOldBlockAttrs[d.node.attrs.id] = m, JSON.stringify(m) !== JSON.stringify(p) && (m["depth-change"] = m.depth - p.depth, e.updatedBlocks.add(d.node.attrs.id));
|
|
641
650
|
}
|
|
642
651
|
}
|
|
643
652
|
return e.prevTransactionOldBlockAttrs = i, e;
|
|
@@ -653,31 +662,31 @@ const ae = E.create({
|
|
|
653
662
|
if (!n.attrs.id || !e.updatedBlocks.has(n.attrs.id))
|
|
654
663
|
return;
|
|
655
664
|
const a = e.currentTransactionOldBlockAttrs[n.attrs.id], s = {};
|
|
656
|
-
for (let [
|
|
657
|
-
s["data-prev-" +
|
|
658
|
-
const
|
|
665
|
+
for (let [d, c] of Object.entries(a))
|
|
666
|
+
s["data-prev-" + me[d]] = c || "none";
|
|
667
|
+
const l = D.node(i, i + n.nodeSize, {
|
|
659
668
|
...s
|
|
660
669
|
});
|
|
661
|
-
r.push(
|
|
670
|
+
r.push(l);
|
|
662
671
|
}), F.create(t.doc, r);
|
|
663
672
|
}
|
|
664
673
|
}
|
|
665
674
|
});
|
|
666
|
-
},
|
|
667
|
-
blockOuter:
|
|
668
|
-
blockContent:
|
|
669
|
-
blockGroup:
|
|
670
|
-
block:
|
|
671
|
-
isEmpty:
|
|
672
|
-
isFilter:
|
|
673
|
-
hasAnchor:
|
|
674
|
-
},
|
|
675
|
+
}, ke = "_blockOuter_1qj38_5", ye = "_blockContent_1qj38_10", be = "_blockGroup_1qj38_30", ve = "_block_1qj38_5", Ee = "_isEmpty_1qj38_228", Ce = "_isFilter_1qj38_229", Me = "_hasAnchor_1qj38_251", b = {
|
|
676
|
+
blockOuter: ke,
|
|
677
|
+
blockContent: ye,
|
|
678
|
+
blockGroup: be,
|
|
679
|
+
block: ve,
|
|
680
|
+
isEmpty: Ee,
|
|
681
|
+
isFilter: Ce,
|
|
682
|
+
hasAnchor: Me
|
|
683
|
+
}, Be = {
|
|
675
684
|
blockColor: "data-block-color",
|
|
676
685
|
blockStyle: "data-block-style",
|
|
677
686
|
id: "data-id",
|
|
678
687
|
depth: "data-depth",
|
|
679
688
|
depthChange: "data-depth-change"
|
|
680
|
-
},
|
|
689
|
+
}, Te = S.create({
|
|
681
690
|
name: "blockContainer",
|
|
682
691
|
group: "blockContainer",
|
|
683
692
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -698,7 +707,7 @@ const ae = E.create({
|
|
|
698
707
|
if (typeof o == "string")
|
|
699
708
|
return !1;
|
|
700
709
|
const t = {};
|
|
701
|
-
for (let [e, r] of Object.entries(
|
|
710
|
+
for (let [e, r] of Object.entries(Be))
|
|
702
711
|
o.getAttribute(r) && (t[e] = o.getAttribute(r));
|
|
703
712
|
return o.getAttribute("data-node-type") === "blockContainer" ? t : !1;
|
|
704
713
|
}
|
|
@@ -743,34 +752,34 @@ const ae = E.create({
|
|
|
743
752
|
const n = g(e.doc, o);
|
|
744
753
|
if (n === void 0)
|
|
745
754
|
return !1;
|
|
746
|
-
const { startPos: i, endPos: a, node: s, contentNode:
|
|
755
|
+
const { startPos: i, endPos: a, node: s, contentNode: l } = n;
|
|
747
756
|
if (r) {
|
|
748
757
|
if (t.children !== void 0) {
|
|
749
|
-
const
|
|
758
|
+
const d = [];
|
|
750
759
|
for (const c of t.children)
|
|
751
|
-
|
|
760
|
+
d.push(R(c, e.schema));
|
|
752
761
|
s.childCount === 2 ? e.tr.replace(
|
|
753
|
-
i +
|
|
762
|
+
i + l.nodeSize + 1,
|
|
754
763
|
a - 1,
|
|
755
|
-
new P(L.from(
|
|
764
|
+
new P(L.from(d), 0, 0)
|
|
756
765
|
) : e.tr.insert(
|
|
757
|
-
i +
|
|
758
|
-
e.schema.nodes.blockGroup.create({},
|
|
766
|
+
i + l.nodeSize,
|
|
767
|
+
e.schema.nodes.blockGroup.create({}, d)
|
|
759
768
|
);
|
|
760
769
|
}
|
|
761
770
|
if (t.content !== void 0) {
|
|
762
|
-
let
|
|
763
|
-
typeof t.content == "string" ?
|
|
771
|
+
let d = [];
|
|
772
|
+
typeof t.content == "string" ? d.push(e.schema.text(t.content)) : d = ht(t.content, e.schema), e.tr.replace(
|
|
764
773
|
i + 1,
|
|
765
|
-
i +
|
|
766
|
-
new P(L.from(
|
|
774
|
+
i + l.nodeSize - 1,
|
|
775
|
+
new P(L.from(d), 0, 0)
|
|
767
776
|
);
|
|
768
777
|
}
|
|
769
778
|
e.tr.setNodeMarkup(
|
|
770
779
|
i,
|
|
771
780
|
t.type === void 0 ? void 0 : e.schema.nodes[t.type],
|
|
772
781
|
{
|
|
773
|
-
...
|
|
782
|
+
...l.attrs,
|
|
774
783
|
...t.props
|
|
775
784
|
}
|
|
776
785
|
), e.tr.setNodeMarkup(i - 1, void 0, {
|
|
@@ -804,18 +813,18 @@ const ae = E.create({
|
|
|
804
813
|
const i = g(
|
|
805
814
|
t.doc,
|
|
806
815
|
o + 1
|
|
807
|
-
), { node: a, contentNode: s, startPos:
|
|
816
|
+
), { node: a, contentNode: s, startPos: l, endPos: d, depth: c } = i;
|
|
808
817
|
if (a.childCount === 2) {
|
|
809
818
|
const p = t.doc.resolve(
|
|
810
|
-
|
|
811
|
-
), m = t.doc.resolve(
|
|
819
|
+
l + s.nodeSize + 1
|
|
820
|
+
), m = t.doc.resolve(d - 1), y = p.blockRange(m);
|
|
812
821
|
e && t.tr.lift(y, c - 1);
|
|
813
822
|
}
|
|
814
823
|
let h = o - 1, f = g(t.doc, h);
|
|
815
824
|
for (; f.numChildBlocks > 0; )
|
|
816
825
|
if (h--, f = g(t.doc, h), f === void 0)
|
|
817
826
|
return !1;
|
|
818
|
-
return e && (t.tr.deleteRange(
|
|
827
|
+
return e && (t.tr.deleteRange(l, l + s.nodeSize), t.tr.insertText(s.textContent, h - 1), t.tr.setSelection(
|
|
819
828
|
new Q(t.doc.resolve(h - 1))
|
|
820
829
|
)), !0;
|
|
821
830
|
},
|
|
@@ -825,14 +834,14 @@ const ae = E.create({
|
|
|
825
834
|
const n = g(e.doc, o);
|
|
826
835
|
if (n === void 0)
|
|
827
836
|
return !1;
|
|
828
|
-
const { contentNode: i, contentType: a, startPos: s, endPos:
|
|
837
|
+
const { contentNode: i, contentType: a, startPos: s, endPos: l, depth: d } = n, c = e.doc.cut(s + 1, o), h = e.doc.cut(o, l - 1), f = e.schema.nodes.blockContainer.createAndFill(), p = l + 1, m = p + 2;
|
|
829
838
|
return r && (e.tr.insert(p, f), e.tr.replace(
|
|
830
839
|
m,
|
|
831
840
|
m + 1,
|
|
832
841
|
h.content.size > 0 ? new P(
|
|
833
842
|
L.from(h),
|
|
834
|
-
|
|
835
|
-
|
|
843
|
+
d + 2,
|
|
844
|
+
d + 2
|
|
836
845
|
) : void 0
|
|
837
846
|
), t && e.tr.setBlockType(
|
|
838
847
|
m,
|
|
@@ -843,18 +852,18 @@ const ae = E.create({
|
|
|
843
852
|
new Q(e.doc.resolve(m))
|
|
844
853
|
), e.tr.replace(
|
|
845
854
|
s + 1,
|
|
846
|
-
|
|
855
|
+
l - 1,
|
|
847
856
|
c.content.size > 0 ? new P(
|
|
848
857
|
L.from(c),
|
|
849
|
-
|
|
850
|
-
|
|
858
|
+
d + 2,
|
|
859
|
+
d + 2
|
|
851
860
|
) : void 0
|
|
852
861
|
)), !0;
|
|
853
862
|
}
|
|
854
863
|
};
|
|
855
864
|
},
|
|
856
865
|
addProseMirrorPlugins() {
|
|
857
|
-
return [
|
|
866
|
+
return [ge()];
|
|
858
867
|
},
|
|
859
868
|
addKeyboardShortcuts() {
|
|
860
869
|
return {
|
|
@@ -882,8 +891,8 @@ const ae = E.create({
|
|
|
882
891
|
const { depth: n, startPos: i } = g(
|
|
883
892
|
r.doc,
|
|
884
893
|
r.selection.from
|
|
885
|
-
), a = r.selection.$anchor.parentOffset === 0, s = r.selection.anchor === r.selection.head,
|
|
886
|
-
return !
|
|
894
|
+
), a = r.selection.$anchor.parentOffset === 0, s = r.selection.anchor === r.selection.head, l = i === 2, d = i - 1;
|
|
895
|
+
return !l && a && s && n === 2 ? e.BNMergeBlocks(d) : !1;
|
|
887
896
|
})
|
|
888
897
|
]),
|
|
889
898
|
Enter: () => this.editor.commands.first(({ commands: e }) => [
|
|
@@ -893,8 +902,8 @@ const ae = E.create({
|
|
|
893
902
|
const { node: n, depth: i } = g(
|
|
894
903
|
r.doc,
|
|
895
904
|
r.selection.from
|
|
896
|
-
), a = r.selection.$anchor.parentOffset === 0, s = r.selection.anchor === r.selection.head,
|
|
897
|
-
return a && s &&
|
|
905
|
+
), a = r.selection.$anchor.parentOffset === 0, s = r.selection.anchor === r.selection.head, l = n.textContent.length === 0, d = i > 2;
|
|
906
|
+
return a && s && l && d ? e.liftListItem("blockContainer") : !1;
|
|
898
907
|
}),
|
|
899
908
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
900
909
|
// empty & at the start of the block.
|
|
@@ -902,8 +911,8 @@ const ae = E.create({
|
|
|
902
911
|
const { node: i, endPos: a } = g(
|
|
903
912
|
r.doc,
|
|
904
913
|
r.selection.from
|
|
905
|
-
), s = r.selection.$anchor.parentOffset === 0,
|
|
906
|
-
if (s &&
|
|
914
|
+
), s = r.selection.$anchor.parentOffset === 0, l = r.selection.anchor === r.selection.head, d = i.textContent.length === 0;
|
|
915
|
+
if (s && l && d) {
|
|
907
916
|
const c = a + 1, h = c + 2;
|
|
908
917
|
return n().BNCreateBlock(c).setTextSelection(h).run(), !0;
|
|
909
918
|
}
|
|
@@ -954,7 +963,7 @@ const ae = E.create({
|
|
|
954
963
|
})
|
|
955
964
|
};
|
|
956
965
|
}
|
|
957
|
-
}),
|
|
966
|
+
}), we = S.create({
|
|
958
967
|
name: "blockGroup",
|
|
959
968
|
group: "blockGroup",
|
|
960
969
|
content: "blockContainer+",
|
|
@@ -981,7 +990,7 @@ const ae = E.create({
|
|
|
981
990
|
0
|
|
982
991
|
];
|
|
983
992
|
}
|
|
984
|
-
}),
|
|
993
|
+
}), Se = S.create({
|
|
985
994
|
name: "paragraph",
|
|
986
995
|
group: "blockContent",
|
|
987
996
|
content: "inline*",
|
|
@@ -1004,7 +1013,7 @@ const ae = E.create({
|
|
|
1004
1013
|
["p", 0]
|
|
1005
1014
|
];
|
|
1006
1015
|
}
|
|
1007
|
-
}),
|
|
1016
|
+
}), xe = S.create({
|
|
1008
1017
|
name: "heading",
|
|
1009
1018
|
group: "blockContent",
|
|
1010
1019
|
content: "inline*",
|
|
@@ -1022,7 +1031,7 @@ const ae = E.create({
|
|
|
1022
1031
|
},
|
|
1023
1032
|
addInputRules() {
|
|
1024
1033
|
return [
|
|
1025
|
-
...["1", "2", "3"].map((o) => new
|
|
1034
|
+
...["1", "2", "3"].map((o) => new j({
|
|
1026
1035
|
find: new RegExp(`^(#{${parseInt(o)}})\\s$`),
|
|
1027
1036
|
handler: ({ state: t, chain: e, range: r }) => {
|
|
1028
1037
|
e().BNUpdateBlock(t.selection.from, {
|
|
@@ -1083,14 +1092,14 @@ const ae = E.create({
|
|
|
1083
1092
|
a.command(() => t.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(n.selection.from, !0).run(), !0) : !1)
|
|
1084
1093
|
)
|
|
1085
1094
|
]);
|
|
1086
|
-
},
|
|
1095
|
+
}, Ie = S.create({
|
|
1087
1096
|
name: "bulletListItem",
|
|
1088
1097
|
group: "blockContent",
|
|
1089
1098
|
content: "inline*",
|
|
1090
1099
|
addInputRules() {
|
|
1091
1100
|
return [
|
|
1092
1101
|
// Creates an unordered list when starting with "-", "+", or "*".
|
|
1093
|
-
new
|
|
1102
|
+
new j({
|
|
1094
1103
|
find: new RegExp("^[-+*]\\s$"),
|
|
1095
1104
|
handler: ({ state: o, chain: t, range: e }) => {
|
|
1096
1105
|
t().BNUpdateBlock(o.selection.from, {
|
|
@@ -1143,8 +1152,8 @@ const ae = E.create({
|
|
|
1143
1152
|
["p", 0]
|
|
1144
1153
|
];
|
|
1145
1154
|
}
|
|
1146
|
-
}),
|
|
1147
|
-
key:
|
|
1155
|
+
}), Pe = new v("numbered-list-indexing"), Le = () => new C({
|
|
1156
|
+
key: Pe,
|
|
1148
1157
|
appendTransaction: (o, t, e) => {
|
|
1149
1158
|
const r = e.tr;
|
|
1150
1159
|
r.setMeta("numberedListIndexing", !0);
|
|
@@ -1152,14 +1161,14 @@ const ae = E.create({
|
|
|
1152
1161
|
return e.doc.descendants((i, a) => {
|
|
1153
1162
|
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
1154
1163
|
let s = "1";
|
|
1155
|
-
const
|
|
1156
|
-
if (
|
|
1164
|
+
const l = a === 1, d = g(r.doc, a + 1);
|
|
1165
|
+
if (d === void 0)
|
|
1157
1166
|
return;
|
|
1158
|
-
if (!
|
|
1167
|
+
if (!l) {
|
|
1159
1168
|
const f = g(r.doc, a - 2);
|
|
1160
1169
|
if (f === void 0)
|
|
1161
1170
|
return;
|
|
1162
|
-
if (!(
|
|
1171
|
+
if (!(d.depth !== f.depth)) {
|
|
1163
1172
|
const m = f.contentNode;
|
|
1164
1173
|
if (f.contentType.name === "numberedListItem") {
|
|
1165
1174
|
const z = m.attrs.index;
|
|
@@ -1167,13 +1176,13 @@ const ae = E.create({
|
|
|
1167
1176
|
}
|
|
1168
1177
|
}
|
|
1169
1178
|
}
|
|
1170
|
-
|
|
1179
|
+
d.contentNode.attrs.index !== s && (n = !0, r.setNodeMarkup(a + 1, void 0, {
|
|
1171
1180
|
index: s
|
|
1172
1181
|
}));
|
|
1173
1182
|
}
|
|
1174
1183
|
}), n ? r : null;
|
|
1175
1184
|
}
|
|
1176
|
-
}),
|
|
1185
|
+
}), _e = S.create({
|
|
1177
1186
|
name: "numberedListItem",
|
|
1178
1187
|
group: "blockContent",
|
|
1179
1188
|
content: "inline*",
|
|
@@ -1191,7 +1200,7 @@ const ae = E.create({
|
|
|
1191
1200
|
addInputRules() {
|
|
1192
1201
|
return [
|
|
1193
1202
|
// Creates an ordered list when starting with "1.".
|
|
1194
|
-
new
|
|
1203
|
+
new j({
|
|
1195
1204
|
find: new RegExp("^1\\.\\s$"),
|
|
1196
1205
|
handler: ({ state: o, chain: t, range: e }) => {
|
|
1197
1206
|
t().BNUpdateBlock(o.selection.from, {
|
|
@@ -1208,7 +1217,7 @@ const ae = E.create({
|
|
|
1208
1217
|
};
|
|
1209
1218
|
},
|
|
1210
1219
|
addProseMirrorPlugins() {
|
|
1211
|
-
return [
|
|
1220
|
+
return [Le()];
|
|
1212
1221
|
},
|
|
1213
1222
|
parseHTML() {
|
|
1214
1223
|
return [
|
|
@@ -1251,24 +1260,19 @@ const ae = E.create({
|
|
|
1251
1260
|
["p", 0]
|
|
1252
1261
|
];
|
|
1253
1262
|
}
|
|
1254
|
-
}),
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1263
|
+
}), Ae = [
|
|
1264
|
+
Se,
|
|
1265
|
+
xe,
|
|
1266
|
+
Ie,
|
|
1267
|
+
_e,
|
|
1268
|
+
Te,
|
|
1258
1269
|
we,
|
|
1259
|
-
be,
|
|
1260
|
-
ve,
|
|
1261
1270
|
S.create({
|
|
1262
1271
|
name: "doc",
|
|
1263
1272
|
topNode: !0,
|
|
1264
1273
|
content: "blockGroup"
|
|
1265
1274
|
})
|
|
1266
|
-
],
|
|
1267
|
-
bnEditor: xe,
|
|
1268
|
-
bnRoot: Ie,
|
|
1269
|
-
defaultStyles: Pe,
|
|
1270
|
-
dragPreview: Le
|
|
1271
|
-
}, Ae = wt(
|
|
1275
|
+
], Ne = wt(
|
|
1272
1276
|
(o) => o.type.name === "blockContainer"
|
|
1273
1277
|
);
|
|
1274
1278
|
function q() {
|
|
@@ -1312,10 +1316,10 @@ class He {
|
|
|
1312
1316
|
const r = this.pluginKey.getState(e), n = this.pluginKey.getState(t.state), i = !r.active && n.active, a = r.active && !n.active, s = r.active && n.active;
|
|
1313
1317
|
!i && !s && !a || (this.pluginState = a ? r : n, (a || !this.editor.isEditable) && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
|
|
1314
1318
|
"mousedown",
|
|
1315
|
-
(
|
|
1319
|
+
(l) => l.preventDefault()
|
|
1316
1320
|
)), s && this.suggestionsMenu.render(this.getDynamicParams(), !1), i && this.editor.isEditable && (this.suggestionsMenu.render(this.getDynamicParams(), !0), this.suggestionsMenu.element.addEventListener(
|
|
1317
1321
|
"mousedown",
|
|
1318
|
-
(
|
|
1322
|
+
(l) => l.preventDefault()
|
|
1319
1323
|
)));
|
|
1320
1324
|
}
|
|
1321
1325
|
destroy() {
|
|
@@ -1337,7 +1341,7 @@ class He {
|
|
|
1337
1341
|
};
|
|
1338
1342
|
}
|
|
1339
1343
|
}
|
|
1340
|
-
function
|
|
1344
|
+
function Oe({
|
|
1341
1345
|
pluginKey: o,
|
|
1342
1346
|
editor: t,
|
|
1343
1347
|
defaultTriggerCharacter: e,
|
|
@@ -1356,8 +1360,8 @@ function Ne({
|
|
|
1356
1360
|
view: (s) => new He({
|
|
1357
1361
|
editor: t,
|
|
1358
1362
|
pluginKey: o,
|
|
1359
|
-
onSelectItem: (
|
|
1360
|
-
a(s), n(
|
|
1363
|
+
onSelectItem: (l) => {
|
|
1364
|
+
a(s), n(l);
|
|
1361
1365
|
},
|
|
1362
1366
|
suggestionsMenuFactory: r
|
|
1363
1367
|
}),
|
|
@@ -1367,10 +1371,10 @@ function Ne({
|
|
|
1367
1371
|
return q();
|
|
1368
1372
|
},
|
|
1369
1373
|
// Apply changes to the plugin state from an editor transaction.
|
|
1370
|
-
apply(s,
|
|
1374
|
+
apply(s, l, d, c) {
|
|
1371
1375
|
var f, p, m, y;
|
|
1372
1376
|
if (s.getMeta("orderedListIndexing") !== void 0)
|
|
1373
|
-
return
|
|
1377
|
+
return l;
|
|
1374
1378
|
if ((f = s.getMeta(o)) != null && f.activate)
|
|
1375
1379
|
return {
|
|
1376
1380
|
active: !0,
|
|
@@ -1383,41 +1387,41 @@ function Ne({
|
|
|
1383
1387
|
notFoundCount: 0,
|
|
1384
1388
|
decorationId: `id_${Math.floor(Math.random() * 4294967295)}`
|
|
1385
1389
|
};
|
|
1386
|
-
if (!
|
|
1387
|
-
return
|
|
1388
|
-
const h = { ...
|
|
1390
|
+
if (!l.active)
|
|
1391
|
+
return l;
|
|
1392
|
+
const h = { ...l };
|
|
1389
1393
|
if (h.items = i(
|
|
1390
|
-
c.doc.textBetween(
|
|
1394
|
+
c.doc.textBetween(l.queryStartPos, c.selection.from)
|
|
1391
1395
|
), h.notFoundCount = 0, h.items.length === 0 && (h.notFoundCount = Math.max(
|
|
1392
1396
|
0,
|
|
1393
|
-
|
|
1397
|
+
l.notFoundCount + (c.selection.from - d.selection.from)
|
|
1394
1398
|
)), // Highlighting text should hide the menu.
|
|
1395
1399
|
c.selection.from !== c.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
|
|
1396
1400
|
(m = s.getMeta(o)) != null && m.deactivate || // Certain mouse events should hide the menu.
|
|
1397
1401
|
// TODO: Change to global mousedown listener.
|
|
1398
1402
|
s.getMeta("focus") || s.getMeta("blur") || s.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1399
|
-
|
|
1403
|
+
l.active && c.selection.from < l.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
|
|
1400
1404
|
// the menu.
|
|
1401
1405
|
h.notFoundCount > 3)
|
|
1402
1406
|
return q();
|
|
1403
1407
|
if (((y = s.getMeta(o)) == null ? void 0 : y.selectedItemIndexChanged) !== void 0) {
|
|
1404
1408
|
let k = s.getMeta(o).selectedItemIndexChanged;
|
|
1405
|
-
k < 0 ? k =
|
|
1409
|
+
k < 0 ? k = l.items.length - 1 : k >= l.items.length && (k = 0), h.keyboardHoveredItemIndex = k;
|
|
1406
1410
|
}
|
|
1407
1411
|
return h;
|
|
1408
1412
|
}
|
|
1409
1413
|
},
|
|
1410
1414
|
props: {
|
|
1411
|
-
handleKeyDown(s,
|
|
1412
|
-
const
|
|
1413
|
-
if (
|
|
1415
|
+
handleKeyDown(s, l) {
|
|
1416
|
+
const d = this.getState(s.state).active;
|
|
1417
|
+
if (l.key === e && !d)
|
|
1414
1418
|
return s.dispatch(
|
|
1415
1419
|
s.state.tr.insertText(e).scrollIntoView().setMeta(o, {
|
|
1416
1420
|
activate: !0,
|
|
1417
1421
|
triggerCharacter: e
|
|
1418
1422
|
})
|
|
1419
1423
|
), !0;
|
|
1420
|
-
if (!
|
|
1424
|
+
if (!d)
|
|
1421
1425
|
return !1;
|
|
1422
1426
|
const {
|
|
1423
1427
|
triggerCharacter: c,
|
|
@@ -1425,21 +1429,21 @@ function Ne({
|
|
|
1425
1429
|
items: f,
|
|
1426
1430
|
keyboardHoveredItemIndex: p
|
|
1427
1431
|
} = o.getState(s.state);
|
|
1428
|
-
return
|
|
1432
|
+
return l.key === "ArrowUp" ? (s.dispatch(
|
|
1429
1433
|
s.state.tr.setMeta(o, {
|
|
1430
1434
|
selectedItemIndexChanged: p - 1
|
|
1431
1435
|
})
|
|
1432
|
-
), !0) :
|
|
1436
|
+
), !0) : l.key === "ArrowDown" ? (s.dispatch(
|
|
1433
1437
|
s.state.tr.setMeta(o, {
|
|
1434
1438
|
selectedItemIndexChanged: p + 1
|
|
1435
1439
|
})
|
|
1436
|
-
), !0) :
|
|
1440
|
+
), !0) : l.key === "Enter" ? (a(s), t._tiptapEditor.chain().focus().deleteRange({
|
|
1437
1441
|
from: h - c.length,
|
|
1438
1442
|
to: t._tiptapEditor.state.selection.from
|
|
1439
1443
|
}).run(), n({
|
|
1440
1444
|
item: f[p],
|
|
1441
1445
|
editor: t
|
|
1442
|
-
}), !0) :
|
|
1446
|
+
}), !0) : l.key === "Escape" ? (a(s), !0) : !1;
|
|
1443
1447
|
},
|
|
1444
1448
|
// Hides menu in cases where mouse click does not cause an editor state change.
|
|
1445
1449
|
handleClick(s) {
|
|
@@ -1447,11 +1451,11 @@ function Ne({
|
|
|
1447
1451
|
},
|
|
1448
1452
|
// Setup decorator on the currently active suggestion.
|
|
1449
1453
|
decorations(s) {
|
|
1450
|
-
const { active:
|
|
1451
|
-
if (!
|
|
1454
|
+
const { active: l, decorationId: d, queryStartPos: c, triggerCharacter: h } = this.getState(s);
|
|
1455
|
+
if (!l)
|
|
1452
1456
|
return null;
|
|
1453
1457
|
if (h === "") {
|
|
1454
|
-
const f =
|
|
1458
|
+
const f = Ne(s.selection);
|
|
1455
1459
|
if (f)
|
|
1456
1460
|
return F.create(s.doc, [
|
|
1457
1461
|
D.node(
|
|
@@ -1460,7 +1464,7 @@ function Ne({
|
|
|
1460
1464
|
{
|
|
1461
1465
|
nodeName: "span",
|
|
1462
1466
|
class: "suggestion-decorator",
|
|
1463
|
-
"data-decoration-id":
|
|
1467
|
+
"data-decoration-id": d
|
|
1464
1468
|
}
|
|
1465
1469
|
)
|
|
1466
1470
|
]);
|
|
@@ -1472,7 +1476,7 @@ function Ne({
|
|
|
1472
1476
|
{
|
|
1473
1477
|
nodeName: "span",
|
|
1474
1478
|
class: "suggestion-decorator",
|
|
1475
|
-
"data-decoration-id":
|
|
1479
|
+
"data-decoration-id": d
|
|
1476
1480
|
}
|
|
1477
1481
|
)
|
|
1478
1482
|
]);
|
|
@@ -1480,7 +1484,7 @@ function Ne({
|
|
|
1480
1484
|
}
|
|
1481
1485
|
});
|
|
1482
1486
|
}
|
|
1483
|
-
const V = new v("suggestions-slash-commands"),
|
|
1487
|
+
const V = new v("suggestions-slash-commands"), De = E.create({
|
|
1484
1488
|
name: "slash-command",
|
|
1485
1489
|
addOptions() {
|
|
1486
1490
|
return {
|
|
@@ -1494,7 +1498,7 @@ const V = new v("suggestions-slash-commands"), _e = E.create({
|
|
|
1494
1498
|
throw new Error("required args not defined for SlashMenuExtension");
|
|
1495
1499
|
const o = this.options.commands;
|
|
1496
1500
|
return [
|
|
1497
|
-
|
|
1501
|
+
Oe({
|
|
1498
1502
|
pluginKey: V,
|
|
1499
1503
|
editor: this.options.editor,
|
|
1500
1504
|
defaultTriggerCharacter: "/",
|
|
@@ -1507,7 +1511,7 @@ const V = new v("suggestions-slash-commands"), _e = E.create({
|
|
|
1507
1511
|
];
|
|
1508
1512
|
}
|
|
1509
1513
|
});
|
|
1510
|
-
class A extends
|
|
1514
|
+
class A extends $ {
|
|
1511
1515
|
constructor(e, r) {
|
|
1512
1516
|
super(e, r);
|
|
1513
1517
|
u(this, "nodes");
|
|
@@ -1533,7 +1537,7 @@ class A extends G {
|
|
|
1533
1537
|
}
|
|
1534
1538
|
map(e, r) {
|
|
1535
1539
|
let n = r.mapResult(this.from), i = r.mapResult(this.to);
|
|
1536
|
-
return i.deleted ?
|
|
1540
|
+
return i.deleted ? $.near(e.resolve(n.pos)) : n.deleted ? $.near(e.resolve(i.pos)) : new A(
|
|
1537
1541
|
e.resolve(n.pos),
|
|
1538
1542
|
e.resolve(i.pos)
|
|
1539
1543
|
);
|
|
@@ -1542,7 +1546,7 @@ class A extends G {
|
|
|
1542
1546
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
1543
1547
|
}
|
|
1544
1548
|
}
|
|
1545
|
-
const
|
|
1549
|
+
const Fe = Jt.__serializeForClipboard;
|
|
1546
1550
|
let T;
|
|
1547
1551
|
function yt(o, t) {
|
|
1548
1552
|
var n;
|
|
@@ -1559,7 +1563,7 @@ function yt(o, t) {
|
|
|
1559
1563
|
return { node: r, id: r.getAttribute("data-id") };
|
|
1560
1564
|
}
|
|
1561
1565
|
}
|
|
1562
|
-
function
|
|
1566
|
+
function Re(o, t) {
|
|
1563
1567
|
let e = yt(o, t);
|
|
1564
1568
|
if (e && e.node.nodeType === 1) {
|
|
1565
1569
|
const r = t.docView;
|
|
@@ -1568,12 +1572,12 @@ function De(o, t) {
|
|
|
1568
1572
|
}
|
|
1569
1573
|
return null;
|
|
1570
1574
|
}
|
|
1571
|
-
function
|
|
1575
|
+
function ze(o, t) {
|
|
1572
1576
|
let e, r;
|
|
1573
1577
|
const n = t.resolve(o.from).node().type.spec.group === "blockContent", i = t.resolve(o.to).node().type.spec.group === "blockContent", a = Math.min(o.$anchor.depth, o.$head.depth);
|
|
1574
1578
|
if (n && i) {
|
|
1575
|
-
const s = o.$from.start(a - 1),
|
|
1576
|
-
e = t.resolve(s - 1).pos, r = t.resolve(
|
|
1579
|
+
const s = o.$from.start(a - 1), l = o.$to.end(a - 1);
|
|
1580
|
+
e = t.resolve(s - 1).pos, r = t.resolve(l + 1).pos;
|
|
1577
1581
|
} else
|
|
1578
1582
|
e = o.from, r = o.to;
|
|
1579
1583
|
return { from: e, to: r };
|
|
@@ -1592,15 +1596,15 @@ function ot(o, t, e = t) {
|
|
|
1592
1596
|
for (let c = n.childElementCount - 1; c >= 0; c--)
|
|
1593
1597
|
(c > s || c < a) && r.removeChild(r.children[c]);
|
|
1594
1598
|
bt(), T = r;
|
|
1595
|
-
const
|
|
1599
|
+
const d = o.dom.className.split(" ").filter(
|
|
1596
1600
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
1597
1601
|
).join(" ");
|
|
1598
|
-
T.className = T.className + " " +
|
|
1602
|
+
T.className = T.className + " " + _.dragPreview + " " + d, document.body.appendChild(T);
|
|
1599
1603
|
}
|
|
1600
1604
|
function bt() {
|
|
1601
1605
|
T !== void 0 && (document.body.removeChild(T), T = void 0);
|
|
1602
1606
|
}
|
|
1603
|
-
function
|
|
1607
|
+
function Ue(o, t) {
|
|
1604
1608
|
if (!o.dataTransfer)
|
|
1605
1609
|
return;
|
|
1606
1610
|
const e = t.dom.getBoundingClientRect();
|
|
@@ -1608,19 +1612,19 @@ function Re(o, t) {
|
|
|
1608
1612
|
left: e.left + e.width / 2,
|
|
1609
1613
|
// take middle of editor
|
|
1610
1614
|
top: o.clientY
|
|
1611
|
-
}, n =
|
|
1615
|
+
}, n = Re(r, t);
|
|
1612
1616
|
if (n != null) {
|
|
1613
|
-
const i = t.state.selection, a = t.state.doc, { from: s, to:
|
|
1614
|
-
|
|
1615
|
-
t.state.tr.setSelection(A.create(a, s,
|
|
1616
|
-
), ot(t, s,
|
|
1617
|
-
t.state.tr.setSelection(
|
|
1617
|
+
const i = t.state.selection, a = t.state.doc, { from: s, to: l } = ze(i, a), d = s <= n && n < l, c = i.$anchor.node() !== i.$head.node() || i instanceof A;
|
|
1618
|
+
d && c ? (t.dispatch(
|
|
1619
|
+
t.state.tr.setSelection(A.create(a, s, l))
|
|
1620
|
+
), ot(t, s, l)) : (t.dispatch(
|
|
1621
|
+
t.state.tr.setSelection(_t.create(t.state.doc, n))
|
|
1618
1622
|
), ot(t, n));
|
|
1619
|
-
let h = t.state.selection.content(), { dom: f, text: p } =
|
|
1623
|
+
let h = t.state.selection.content(), { dom: f, text: p } = Fe(t, h);
|
|
1620
1624
|
o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", f.innerHTML), o.dataTransfer.setData("text/plain", p), o.dataTransfer.effectAllowed = "move", o.dataTransfer.setDragImage(T, 0, 0), t.dragging = { slice: h, move: !0 };
|
|
1621
1625
|
}
|
|
1622
1626
|
}
|
|
1623
|
-
class
|
|
1627
|
+
class $e {
|
|
1624
1628
|
constructor({
|
|
1625
1629
|
tiptapEditor: t,
|
|
1626
1630
|
editor: e,
|
|
@@ -1724,8 +1728,8 @@ class ze {
|
|
|
1724
1728
|
return;
|
|
1725
1729
|
const { contentNode: i, endPos: a } = n;
|
|
1726
1730
|
if (i.textContent.length !== 0) {
|
|
1727
|
-
const s = a + 1,
|
|
1728
|
-
this.ttEditor.chain().BNCreateBlock(s).BNUpdateBlock(
|
|
1731
|
+
const s = a + 1, l = s + 2;
|
|
1732
|
+
this.ttEditor.chain().BNCreateBlock(s).BNUpdateBlock(l, { type: "paragraph", props: {} }).setTextSelection(l).run();
|
|
1729
1733
|
} else
|
|
1730
1734
|
this.ttEditor.commands.setTextSelection(a);
|
|
1731
1735
|
this.ttEditor.view.focus(), this.ttEditor.view.dispatch(
|
|
@@ -1741,7 +1745,7 @@ class ze {
|
|
|
1741
1745
|
editor: this.editor,
|
|
1742
1746
|
addBlock: () => this.addBlock(),
|
|
1743
1747
|
blockDragStart: (t) => {
|
|
1744
|
-
this.isDragging = !0,
|
|
1748
|
+
this.isDragging = !0, Ue(t, this.ttEditor.view);
|
|
1745
1749
|
},
|
|
1746
1750
|
blockDragEnd: () => bt(),
|
|
1747
1751
|
freezeMenu: () => {
|
|
@@ -1765,15 +1769,15 @@ class ze {
|
|
|
1765
1769
|
};
|
|
1766
1770
|
}
|
|
1767
1771
|
}
|
|
1768
|
-
const
|
|
1772
|
+
const Ge = (o) => new C({
|
|
1769
1773
|
key: new v("DraggableBlocksPlugin"),
|
|
1770
|
-
view: () => new
|
|
1774
|
+
view: () => new $e({
|
|
1771
1775
|
tiptapEditor: o.tiptapEditor,
|
|
1772
1776
|
editor: o.editor,
|
|
1773
1777
|
blockMenuFactory: o.blockSideMenuFactory,
|
|
1774
1778
|
horizontalPosAnchoredAtRoot: !0
|
|
1775
1779
|
})
|
|
1776
|
-
}),
|
|
1780
|
+
}), qe = E.create({
|
|
1777
1781
|
name: "DraggableBlocksExtension",
|
|
1778
1782
|
priority: 1e3,
|
|
1779
1783
|
// Need to be high, in order to hide menu when typing slash
|
|
@@ -1783,7 +1787,7 @@ const Ue = (o) => new C({
|
|
|
1783
1787
|
"UI Element factory not defined for DraggableBlocksExtension"
|
|
1784
1788
|
);
|
|
1785
1789
|
return [
|
|
1786
|
-
|
|
1790
|
+
Ge({
|
|
1787
1791
|
tiptapEditor: this.editor,
|
|
1788
1792
|
editor: this.options.editor,
|
|
1789
1793
|
blockSideMenuFactory: this.options.blockSideMenuFactory
|
|
@@ -1791,7 +1795,7 @@ const Ue = (o) => new C({
|
|
|
1791
1795
|
];
|
|
1792
1796
|
}
|
|
1793
1797
|
});
|
|
1794
|
-
class
|
|
1798
|
+
class je {
|
|
1795
1799
|
constructor({
|
|
1796
1800
|
editor: t,
|
|
1797
1801
|
tiptapEditor: e,
|
|
@@ -1808,8 +1812,8 @@ class $e {
|
|
|
1808
1812
|
u(this, "toolbarIsOpen", !1);
|
|
1809
1813
|
u(this, "prevWasEditable", null);
|
|
1810
1814
|
u(this, "shouldShow", ({ view: t, state: e, from: r, to: n }) => {
|
|
1811
|
-
const { doc: i, selection: a } = e, { empty: s } = a,
|
|
1812
|
-
return !(!t.hasFocus() || s ||
|
|
1815
|
+
const { doc: i, selection: a } = e, { empty: s } = a, l = !i.textBetween(r, n).length && St(e.selection);
|
|
1816
|
+
return !(!t.hasFocus() || s || l);
|
|
1813
1817
|
});
|
|
1814
1818
|
u(this, "viewMousedownHandler", () => {
|
|
1815
1819
|
this.preventShow = !0;
|
|
@@ -1844,12 +1848,12 @@ class $e {
|
|
|
1844
1848
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (n || s))
|
|
1845
1849
|
return;
|
|
1846
1850
|
this.prevWasEditable = this.editor.isEditable;
|
|
1847
|
-
const { ranges:
|
|
1851
|
+
const { ranges: l } = a, d = Math.min(...l.map((p) => p.$from.pos)), c = Math.max(...l.map((p) => p.$to.pos)), h = (f = this.shouldShow) == null ? void 0 : f.call(this, {
|
|
1848
1852
|
editor: this.editor,
|
|
1849
1853
|
view: t,
|
|
1850
1854
|
state: r,
|
|
1851
1855
|
oldState: e,
|
|
1852
|
-
from:
|
|
1856
|
+
from: d,
|
|
1853
1857
|
to: c
|
|
1854
1858
|
});
|
|
1855
1859
|
if (this.editor.isEditable && !this.toolbarIsOpen && !this.preventShow && (h || this.preventHide)) {
|
|
@@ -1894,10 +1898,10 @@ class $e {
|
|
|
1894
1898
|
};
|
|
1895
1899
|
}
|
|
1896
1900
|
}
|
|
1897
|
-
const
|
|
1901
|
+
const We = (o) => new C({
|
|
1898
1902
|
key: new v("FormattingToolbarPlugin"),
|
|
1899
|
-
view: (t) => new
|
|
1900
|
-
}),
|
|
1903
|
+
view: (t) => new je({ view: t, ...o })
|
|
1904
|
+
}), Ye = E.create({
|
|
1901
1905
|
name: "FormattingToolbarExtension",
|
|
1902
1906
|
addProseMirrorPlugins() {
|
|
1903
1907
|
if (!this.options.formattingToolbarFactory || !this.options.editor)
|
|
@@ -1905,7 +1909,7 @@ const qe = (o) => new C({
|
|
|
1905
1909
|
"required args not defined for FormattingToolbarExtension"
|
|
1906
1910
|
);
|
|
1907
1911
|
return [
|
|
1908
|
-
|
|
1912
|
+
We({
|
|
1909
1913
|
tiptapEditor: this.editor,
|
|
1910
1914
|
editor: this.options.editor,
|
|
1911
1915
|
formattingToolbarFactory: this.options.formattingToolbarFactory,
|
|
@@ -1913,8 +1917,8 @@ const qe = (o) => new C({
|
|
|
1913
1917
|
})
|
|
1914
1918
|
];
|
|
1915
1919
|
}
|
|
1916
|
-
}),
|
|
1917
|
-
class
|
|
1920
|
+
}), Ke = new v("HyperlinkToolbarPlugin");
|
|
1921
|
+
class Ve {
|
|
1918
1922
|
constructor({ editor: t, hyperlinkToolbarFactory: e }) {
|
|
1919
1923
|
u(this, "editor");
|
|
1920
1924
|
u(this, "hyperlinkToolbar");
|
|
@@ -2041,13 +2045,13 @@ class Ye {
|
|
|
2041
2045
|
};
|
|
2042
2046
|
}
|
|
2043
2047
|
}
|
|
2044
|
-
const
|
|
2045
|
-
key:
|
|
2046
|
-
view: () => new
|
|
2048
|
+
const Je = (o, t) => new C({
|
|
2049
|
+
key: Ke,
|
|
2050
|
+
view: () => new Ve({
|
|
2047
2051
|
editor: o,
|
|
2048
2052
|
hyperlinkToolbarFactory: t.hyperlinkToolbarFactory
|
|
2049
2053
|
})
|
|
2050
|
-
}),
|
|
2054
|
+
}), Xe = lt.extend({
|
|
2051
2055
|
priority: 500,
|
|
2052
2056
|
addProseMirrorPlugins() {
|
|
2053
2057
|
var o;
|
|
@@ -2055,12 +2059,12 @@ const Ke = (o, t) => new C({
|
|
|
2055
2059
|
throw new Error("UI Element factory not defined for HyperlinkMark");
|
|
2056
2060
|
return [
|
|
2057
2061
|
...((o = this.parent) == null ? void 0 : o.call(this)) || [],
|
|
2058
|
-
|
|
2062
|
+
Je(this.editor, {
|
|
2059
2063
|
hyperlinkToolbarFactory: this.options.hyperlinkToolbarFactory
|
|
2060
2064
|
})
|
|
2061
2065
|
];
|
|
2062
2066
|
}
|
|
2063
|
-
}),
|
|
2067
|
+
}), Qe = new v("blocknote-placeholder"), Ze = E.create({
|
|
2064
2068
|
name: "placeholder",
|
|
2065
2069
|
addOptions() {
|
|
2066
2070
|
return {
|
|
@@ -2077,17 +2081,17 @@ const Ke = (o, t) => new C({
|
|
|
2077
2081
|
addProseMirrorPlugins() {
|
|
2078
2082
|
return [
|
|
2079
2083
|
new C({
|
|
2080
|
-
key:
|
|
2084
|
+
key: Qe,
|
|
2081
2085
|
props: {
|
|
2082
2086
|
decorations: (o) => {
|
|
2083
2087
|
const { doc: t, selection: e } = o, r = V.getState(o), n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = e, a = [];
|
|
2084
2088
|
if (n)
|
|
2085
|
-
return t.descendants((s,
|
|
2086
|
-
const
|
|
2087
|
-
if ((
|
|
2089
|
+
return t.descendants((s, l) => {
|
|
2090
|
+
const d = i >= l && i <= l + s.nodeSize, c = !s.isLeaf && !s.childCount;
|
|
2091
|
+
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
2088
2092
|
const h = [this.options.emptyNodeClass];
|
|
2089
|
-
this.editor.isEmpty && h.push(this.options.emptyEditorClass),
|
|
2090
|
-
const f = D.node(
|
|
2093
|
+
this.editor.isEmpty && h.push(this.options.emptyEditorClass), d && h.push(this.options.hasAnchorClass), (r == null ? void 0 : r.triggerCharacter) === "" && (r != null && r.active) && h.push(this.options.isFilterClass);
|
|
2094
|
+
const f = D.node(l, l + s.nodeSize, {
|
|
2091
2095
|
class: h.join(" ")
|
|
2092
2096
|
});
|
|
2093
2097
|
a.push(f);
|
|
@@ -2100,12 +2104,12 @@ const Ke = (o, t) => new C({
|
|
|
2100
2104
|
];
|
|
2101
2105
|
}
|
|
2102
2106
|
});
|
|
2103
|
-
class
|
|
2107
|
+
class to {
|
|
2104
2108
|
constructor(t, e) {
|
|
2105
2109
|
this.name = t, this.match = e;
|
|
2106
2110
|
}
|
|
2107
2111
|
}
|
|
2108
|
-
class x extends
|
|
2112
|
+
class x extends to {
|
|
2109
2113
|
/**
|
|
2110
2114
|
* Constructs a new slash-command.
|
|
2111
2115
|
*
|
|
@@ -2123,7 +2127,7 @@ function I(o, t) {
|
|
|
2123
2127
|
const e = o.getTextCursorPosition().block;
|
|
2124
2128
|
e.content.length === 1 && e.content[0].type === "text" && e.content[0].text === "/" || e.content.length === 0 ? o.updateBlock(e, t) : (o.insertBlocks([t], e, "after"), o.setTextCursorPosition(o.getTextCursorPosition().nextBlock));
|
|
2125
2129
|
}
|
|
2126
|
-
const
|
|
2130
|
+
const eo = [
|
|
2127
2131
|
// Command for creating a level 1 heading
|
|
2128
2132
|
new x(
|
|
2129
2133
|
"Heading",
|
|
@@ -2266,7 +2270,7 @@ const Ze = [
|
|
|
2266
2270
|
// TableIcon,
|
|
2267
2271
|
// "Used to create a simple table"
|
|
2268
2272
|
// ),
|
|
2269
|
-
],
|
|
2273
|
+
], oo = E.create({
|
|
2270
2274
|
name: "textAlignment",
|
|
2271
2275
|
addGlobalAttributes() {
|
|
2272
2276
|
return [
|
|
@@ -2304,7 +2308,7 @@ const Ze = [
|
|
|
2304
2308
|
}
|
|
2305
2309
|
};
|
|
2306
2310
|
}
|
|
2307
|
-
}),
|
|
2311
|
+
}), ro = E.create({
|
|
2308
2312
|
name: "blockTextColor",
|
|
2309
2313
|
addGlobalAttributes() {
|
|
2310
2314
|
return [
|
|
@@ -2330,7 +2334,7 @@ const Ze = [
|
|
|
2330
2334
|
}
|
|
2331
2335
|
};
|
|
2332
2336
|
}
|
|
2333
|
-
}),
|
|
2337
|
+
}), no = rt.create({
|
|
2334
2338
|
name: "textColor",
|
|
2335
2339
|
addAttributes() {
|
|
2336
2340
|
return {
|
|
@@ -2359,7 +2363,7 @@ const Ze = [
|
|
|
2359
2363
|
setTextColor: (o) => ({ commands: t }) => o !== "default" ? t.setMark(this.name, { color: o }) : t.unsetMark(this.name)
|
|
2360
2364
|
};
|
|
2361
2365
|
}
|
|
2362
|
-
}),
|
|
2366
|
+
}), io = E.create({
|
|
2363
2367
|
name: "trailingNode",
|
|
2364
2368
|
addProseMirrorPlugins() {
|
|
2365
2369
|
const o = new v(this.name);
|
|
@@ -2367,11 +2371,11 @@ const Ze = [
|
|
|
2367
2371
|
new C({
|
|
2368
2372
|
key: o,
|
|
2369
2373
|
appendTransaction: (t, e, r) => {
|
|
2370
|
-
const { doc: n, tr: i, schema: a } = r, s = o.getState(r),
|
|
2374
|
+
const { doc: n, tr: i, schema: a } = r, s = o.getState(r), l = n.content.size - 2, d = a.nodes.blockContainer, c = a.nodes.paragraph;
|
|
2371
2375
|
if (s)
|
|
2372
2376
|
return i.insert(
|
|
2373
|
-
|
|
2374
|
-
|
|
2377
|
+
l,
|
|
2378
|
+
d.create(void 0, c.create())
|
|
2375
2379
|
);
|
|
2376
2380
|
},
|
|
2377
2381
|
state: {
|
|
@@ -2391,17 +2395,17 @@ const Ze = [
|
|
|
2391
2395
|
})
|
|
2392
2396
|
];
|
|
2393
2397
|
}
|
|
2394
|
-
}),
|
|
2398
|
+
}), so = (o) => {
|
|
2395
2399
|
const t = [
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2400
|
+
N.ClipboardTextSerializer,
|
|
2401
|
+
N.Commands,
|
|
2402
|
+
N.Editable,
|
|
2403
|
+
N.FocusEvents,
|
|
2404
|
+
N.Tabindex,
|
|
2401
2405
|
// DevTools,
|
|
2402
|
-
|
|
2406
|
+
Gt,
|
|
2403
2407
|
// DropCursor,
|
|
2404
|
-
|
|
2408
|
+
Ze.configure({
|
|
2405
2409
|
emptyNodeClass: b.isEmpty,
|
|
2406
2410
|
hasAnchorClass: b.hasAnchor,
|
|
2407
2411
|
isFilterClass: b.isFilter,
|
|
@@ -2411,71 +2415,92 @@ const Ze = [
|
|
|
2411
2415
|
Y.configure({
|
|
2412
2416
|
types: ["blockContainer"]
|
|
2413
2417
|
}),
|
|
2414
|
-
|
|
2418
|
+
qt,
|
|
2415
2419
|
// Comments,
|
|
2416
2420
|
// basics:
|
|
2417
|
-
|
|
2421
|
+
Kt,
|
|
2418
2422
|
// marks:
|
|
2419
2423
|
Ft,
|
|
2420
2424
|
Rt,
|
|
2421
|
-
qt,
|
|
2422
2425
|
Wt,
|
|
2423
2426
|
Yt,
|
|
2427
|
+
Vt,
|
|
2428
|
+
no,
|
|
2429
|
+
ro,
|
|
2430
|
+
fe,
|
|
2431
|
+
pe,
|
|
2424
2432
|
oo,
|
|
2425
|
-
eo,
|
|
2426
|
-
de,
|
|
2427
|
-
ae,
|
|
2428
|
-
to,
|
|
2429
2433
|
// custom blocks:
|
|
2430
|
-
...
|
|
2431
|
-
|
|
2432
|
-
$t,
|
|
2434
|
+
...Ae,
|
|
2435
|
+
$t.configure({ width: 5, color: "#ddeeff" }),
|
|
2433
2436
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
2434
2437
|
// should be handled before Enter handlers in other components like splitListItem
|
|
2435
|
-
|
|
2438
|
+
io
|
|
2436
2439
|
];
|
|
2440
|
+
if (o.collaboration) {
|
|
2441
|
+
t.push(
|
|
2442
|
+
zt.configure({
|
|
2443
|
+
fragment: o.collaboration.fragment
|
|
2444
|
+
})
|
|
2445
|
+
);
|
|
2446
|
+
const e = (r) => {
|
|
2447
|
+
const n = document.createElement("span");
|
|
2448
|
+
n.classList.add(_["collaboration-cursor__caret"]), n.setAttribute("style", `border-color: ${r.color}`);
|
|
2449
|
+
const i = document.createElement("span");
|
|
2450
|
+
i.classList.add(_["collaboration-cursor__label"]), i.setAttribute("style", `background-color: ${r.color}`), i.insertBefore(document.createTextNode(r.name), null);
|
|
2451
|
+
const a = document.createTextNode(""), s = document.createTextNode("");
|
|
2452
|
+
return n.insertBefore(a, null), n.insertBefore(i, null), n.insertBefore(s, null), n;
|
|
2453
|
+
};
|
|
2454
|
+
t.push(
|
|
2455
|
+
Ut.configure({
|
|
2456
|
+
user: o.collaboration.user,
|
|
2457
|
+
render: o.collaboration.renderCursor || e,
|
|
2458
|
+
provider: o.collaboration.provider
|
|
2459
|
+
})
|
|
2460
|
+
);
|
|
2461
|
+
} else
|
|
2462
|
+
t.push(jt);
|
|
2437
2463
|
return o.uiFactories.blockSideMenuFactory && t.push(
|
|
2438
|
-
|
|
2464
|
+
qe.configure({
|
|
2439
2465
|
editor: o.editor,
|
|
2440
2466
|
blockSideMenuFactory: o.uiFactories.blockSideMenuFactory
|
|
2441
2467
|
})
|
|
2442
2468
|
), o.uiFactories.formattingToolbarFactory && t.push(
|
|
2443
|
-
|
|
2469
|
+
Ye.configure({
|
|
2444
2470
|
editor: o.editor,
|
|
2445
2471
|
formattingToolbarFactory: o.uiFactories.formattingToolbarFactory
|
|
2446
2472
|
})
|
|
2447
2473
|
), o.uiFactories.hyperlinkToolbarFactory ? t.push(
|
|
2448
|
-
|
|
2474
|
+
Xe.configure({
|
|
2449
2475
|
hyperlinkToolbarFactory: o.uiFactories.hyperlinkToolbarFactory
|
|
2450
2476
|
})
|
|
2451
|
-
) : t.push(
|
|
2452
|
-
|
|
2477
|
+
) : t.push(lt), o.uiFactories.slashMenuFactory && t.push(
|
|
2478
|
+
De.configure({
|
|
2453
2479
|
editor: o.editor,
|
|
2454
2480
|
commands: o.slashCommands,
|
|
2455
2481
|
slashMenuFactory: o.uiFactories.slashMenuFactory
|
|
2456
2482
|
})
|
|
2457
2483
|
), t;
|
|
2458
|
-
},
|
|
2484
|
+
}, ao = {
|
|
2459
2485
|
enableInputRules: !0,
|
|
2460
2486
|
enablePasteRules: !0,
|
|
2461
2487
|
enableCoreExtensions: !1
|
|
2462
2488
|
};
|
|
2463
|
-
class
|
|
2489
|
+
class Fo {
|
|
2464
2490
|
constructor(t = {}) {
|
|
2465
2491
|
u(this, "_tiptapEditor");
|
|
2466
2492
|
u(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
2467
|
-
var i, a
|
|
2468
|
-
t = {
|
|
2493
|
+
var n, i, a;
|
|
2494
|
+
this.options = t, t = {
|
|
2469
2495
|
defaultStyles: !0,
|
|
2470
2496
|
...t
|
|
2471
2497
|
};
|
|
2472
|
-
const e =
|
|
2498
|
+
const e = so({
|
|
2473
2499
|
editor: this,
|
|
2474
2500
|
uiFactories: t.uiFactories || {},
|
|
2475
|
-
slashCommands: t.slashCommands ||
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
const n = {
|
|
2501
|
+
slashCommands: t.slashCommands || eo,
|
|
2502
|
+
collaboration: t.collaboration
|
|
2503
|
+
}), r = {
|
|
2479
2504
|
// TODO: This approach to setting initial content is "cleaner" but requires the PM editor schema, which is only
|
|
2480
2505
|
// created after initializing the TipTap editor. Not sure it's feasible.
|
|
2481
2506
|
// content:
|
|
@@ -2483,36 +2508,36 @@ class No {
|
|
|
2483
2508
|
// options.initialContent.map((block) =>
|
|
2484
2509
|
// blockToNode(block, this._tiptapEditor.schema).toJSON()
|
|
2485
2510
|
// ),
|
|
2486
|
-
...
|
|
2511
|
+
...ao,
|
|
2487
2512
|
...t._tiptapOptions,
|
|
2488
2513
|
onCreate: () => {
|
|
2489
|
-
var
|
|
2490
|
-
(
|
|
2514
|
+
var s;
|
|
2515
|
+
(s = t.onEditorReady) == null || s.call(t, this), t.initialContent && this.replaceBlocks(this.topLevelBlocks, t.initialContent);
|
|
2491
2516
|
},
|
|
2492
2517
|
onUpdate: () => {
|
|
2493
|
-
var
|
|
2494
|
-
(
|
|
2518
|
+
var s;
|
|
2519
|
+
(s = t.onEditorContentChange) == null || s.call(t, this);
|
|
2495
2520
|
},
|
|
2496
2521
|
onSelectionUpdate: () => {
|
|
2497
|
-
var
|
|
2498
|
-
(
|
|
2522
|
+
var s;
|
|
2523
|
+
(s = t.onTextCursorPositionChange) == null || s.call(t, this);
|
|
2499
2524
|
},
|
|
2500
2525
|
editable: t.editable === void 0 ? !0 : t.editable,
|
|
2501
|
-
extensions: t.enableBlockNoteExtensions === !1 ? (
|
|
2526
|
+
extensions: t.enableBlockNoteExtensions === !1 ? (n = t._tiptapOptions) == null ? void 0 : n.extensions : [...((i = t._tiptapOptions) == null ? void 0 : i.extensions) || [], ...e],
|
|
2502
2527
|
editorProps: {
|
|
2503
2528
|
attributes: {
|
|
2504
2529
|
"data-theme": t.theme || "light",
|
|
2505
2530
|
...t.editorDOMAttributes || {},
|
|
2506
2531
|
class: [
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
t.defaultStyles ?
|
|
2510
|
-
((
|
|
2532
|
+
_.bnEditor,
|
|
2533
|
+
_.bnRoot,
|
|
2534
|
+
t.defaultStyles ? _.defaultStyles : "",
|
|
2535
|
+
((a = t.editorDOMAttributes) == null ? void 0 : a.class) || ""
|
|
2511
2536
|
].join(" ")
|
|
2512
2537
|
}
|
|
2513
2538
|
}
|
|
2514
2539
|
};
|
|
2515
|
-
t.parentElement && (
|
|
2540
|
+
t.parentElement && (r.element = t.parentElement), this._tiptapEditor = new It(r);
|
|
2516
2541
|
}
|
|
2517
2542
|
get domElement() {
|
|
2518
2543
|
return this._tiptapEditor.view.dom;
|
|
@@ -2569,11 +2594,11 @@ class No {
|
|
|
2569
2594
|
), i = this._tiptapEditor.state.doc.resolve(n).index(e - 1), a = this._tiptapEditor.state.doc.resolve(n + 1).node().childCount;
|
|
2570
2595
|
let s;
|
|
2571
2596
|
i > 0 && (s = this._tiptapEditor.state.doc.resolve(r - 2).node());
|
|
2572
|
-
let
|
|
2573
|
-
return i < a - 1 && (
|
|
2597
|
+
let l;
|
|
2598
|
+
return i < a - 1 && (l = this._tiptapEditor.state.doc.resolve(n + 2).node()), {
|
|
2574
2599
|
block: B(t, this.blockCache),
|
|
2575
2600
|
prevBlock: s === void 0 ? void 0 : B(s, this.blockCache),
|
|
2576
|
-
nextBlock:
|
|
2601
|
+
nextBlock: l === void 0 ? void 0 : B(l, this.blockCache)
|
|
2577
2602
|
};
|
|
2578
2603
|
}
|
|
2579
2604
|
/**
|
|
@@ -2638,7 +2663,7 @@ class No {
|
|
|
2638
2663
|
* @param update A partial block which defines how the existing block should be changed.
|
|
2639
2664
|
*/
|
|
2640
2665
|
updateBlock(t, e) {
|
|
2641
|
-
|
|
2666
|
+
re(t, e, this._tiptapEditor);
|
|
2642
2667
|
}
|
|
2643
2668
|
/**
|
|
2644
2669
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
@@ -2655,7 +2680,7 @@ class No {
|
|
|
2655
2680
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
2656
2681
|
*/
|
|
2657
2682
|
replaceBlocks(t, e) {
|
|
2658
|
-
|
|
2683
|
+
ne(t, e, this._tiptapEditor);
|
|
2659
2684
|
}
|
|
2660
2685
|
/**
|
|
2661
2686
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -2798,7 +2823,7 @@ class No {
|
|
|
2798
2823
|
* @returns The blocks, serialized as a Markdown string.
|
|
2799
2824
|
*/
|
|
2800
2825
|
async blocksToMarkdown(t) {
|
|
2801
|
-
return
|
|
2826
|
+
return ae(t, this._tiptapEditor.schema);
|
|
2802
2827
|
}
|
|
2803
2828
|
/**
|
|
2804
2829
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -2808,15 +2833,25 @@ class No {
|
|
|
2808
2833
|
* @returns The blocks parsed from the Markdown string.
|
|
2809
2834
|
*/
|
|
2810
2835
|
async markdownToBlocks(t) {
|
|
2811
|
-
return
|
|
2836
|
+
return le(t, this._tiptapEditor.schema);
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Updates the user info for the current user that's shown to other collaborators.
|
|
2840
|
+
*/
|
|
2841
|
+
updateCollaborationUserInfo(t) {
|
|
2842
|
+
if (!this.options.collaboration)
|
|
2843
|
+
throw new Error(
|
|
2844
|
+
"Cannot update collaboration user info when collaboration is disabled."
|
|
2845
|
+
);
|
|
2846
|
+
this._tiptapEditor.commands.updateUser(t);
|
|
2812
2847
|
}
|
|
2813
2848
|
}
|
|
2814
2849
|
export {
|
|
2815
2850
|
x as BaseSlashMenuItem,
|
|
2816
|
-
|
|
2851
|
+
Fo as BlockNoteEditor,
|
|
2817
2852
|
tt as blockProps,
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2853
|
+
eo as defaultSlashMenuItems,
|
|
2854
|
+
so as getBlockNoteExtensions,
|
|
2855
|
+
O as globalProps
|
|
2821
2856
|
};
|
|
2822
2857
|
//# sourceMappingURL=blocknote.js.map
|