@blocknote/core 0.9.4 → 0.9.5
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 +759 -728
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +7 -7
- package/dist/blocknote.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/src/extensions/Blocks/api/block.ts +33 -1
- package/src/extensions/Blocks/nodes/BlockContainer.ts +49 -1
- package/src/shared/plugins/suggestion/SuggestionPlugin.ts +4 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/Image.d.ts +0 -6
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/uploadToTmpFilesOrg_DEV_ONLY.d.ts +0 -1
package/dist/blocknote.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var Yt = Object.defineProperty;
|
|
2
|
-
var Jt = (n,
|
|
3
|
-
var u = (n,
|
|
2
|
+
var Jt = (n, t, e) => t in n ? Yt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var u = (n, t, e) => (Jt(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
4
|
import { Extension as A, Mark as ht, combineTransactionSteps as Zt, getChangedRanges as Qt, findChildrenInRange as te, findChildren as nt, Node as G, mergeAttributes as N, findParentNode as ee, extensions as R, InputRule as Z, isTextSelection as oe, isNodeSelection as ne, posToDOMRect as K, getMarkRange as rt, Editor as re } from "@tiptap/core";
|
|
5
5
|
import { Bold as ie } from "@tiptap/extension-bold";
|
|
6
6
|
import { Code as se } from "@tiptap/extension-code";
|
|
@@ -16,47 +16,47 @@ import { Strike as fe } from "@tiptap/extension-strike";
|
|
|
16
16
|
import { Text as ge } from "@tiptap/extension-text";
|
|
17
17
|
import { Underline as ke } from "@tiptap/extension-underline";
|
|
18
18
|
import { Slice as L, Fragment as P, DOMSerializer as Y, DOMParser as be } from "prosemirror-model";
|
|
19
|
-
import { Plugin as
|
|
19
|
+
import { Plugin as B, PluginKey as M, NodeSelection as mt, TextSelection as it, Selection as X } from "prosemirror-state";
|
|
20
20
|
import { v4 as ye } from "uuid";
|
|
21
21
|
import * as ve from "prosemirror-view";
|
|
22
|
-
import { Decoration as
|
|
22
|
+
import { Decoration as $, DecorationSet as W } from "prosemirror-view";
|
|
23
23
|
import ft from "rehype-parse";
|
|
24
24
|
import we from "rehype-remark";
|
|
25
25
|
import gt from "rehype-stringify";
|
|
26
26
|
import kt from "remark-gfm";
|
|
27
27
|
import Ce from "remark-parse";
|
|
28
28
|
import Ee, { defaultHandlers as Se } from "remark-rehype";
|
|
29
|
-
import
|
|
29
|
+
import Be from "remark-stringify";
|
|
30
30
|
import { unified as Q } from "unified";
|
|
31
31
|
import { fromDom as st } from "hast-util-from-dom";
|
|
32
|
-
const
|
|
33
|
-
bnEditor:
|
|
34
|
-
bnRoot:
|
|
32
|
+
const Te = "_bnEditor_12je0_3", Me = "_bnRoot_12je0_19", xe = "_defaultStyles_12je0_34", Ie = "_dragPreview_12je0_57", D = {
|
|
33
|
+
bnEditor: Te,
|
|
34
|
+
bnRoot: Me,
|
|
35
35
|
defaultStyles: xe,
|
|
36
36
|
dragPreview: Ie,
|
|
37
37
|
"collaboration-cursor__caret": "_collaboration-cursor__caret_12je0_63",
|
|
38
38
|
"collaboration-cursor__label": "_collaboration-cursor__label_12je0_74"
|
|
39
39
|
};
|
|
40
40
|
function bt(n) {
|
|
41
|
-
const
|
|
41
|
+
const t = n.attrs.id, e = n.firstChild, o = e.type, r = n.childCount === 2 ? n.lastChild.childCount : 0;
|
|
42
42
|
return {
|
|
43
|
-
id:
|
|
43
|
+
id: t,
|
|
44
44
|
node: n,
|
|
45
|
-
contentNode:
|
|
45
|
+
contentNode: e,
|
|
46
46
|
contentType: o,
|
|
47
47
|
numChildBlocks: r
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function b(n,
|
|
50
|
+
function b(n, t) {
|
|
51
51
|
const o = n.nodeSize - 2;
|
|
52
|
-
if (
|
|
53
|
-
for (
|
|
54
|
-
|
|
55
|
-
else if (
|
|
56
|
-
for (
|
|
57
|
-
|
|
58
|
-
n.resolve(
|
|
59
|
-
const r = n.resolve(
|
|
52
|
+
if (t <= 1)
|
|
53
|
+
for (t = 1 + 1; n.resolve(t).parent.type.name !== "blockContainer" && t < o; )
|
|
54
|
+
t++;
|
|
55
|
+
else if (t >= o)
|
|
56
|
+
for (t = o - 1; n.resolve(t).parent.type.name !== "blockContainer" && t > 1; )
|
|
57
|
+
t--;
|
|
58
|
+
n.resolve(t).parent.type.name === "blockGroup" && t++;
|
|
59
|
+
const r = n.resolve(t), i = r.depth;
|
|
60
60
|
let s = r.node(i), l = i;
|
|
61
61
|
for (; ; ) {
|
|
62
62
|
if (l < 0)
|
|
@@ -110,12 +110,12 @@ const C = {
|
|
|
110
110
|
},
|
|
111
111
|
addCommands() {
|
|
112
112
|
return {
|
|
113
|
-
setBlockBackgroundColor: (n,
|
|
114
|
-
const r = b(
|
|
115
|
-
return r === void 0 ? !1 : (
|
|
113
|
+
setBlockBackgroundColor: (n, t) => ({ state: e, view: o }) => {
|
|
114
|
+
const r = b(e.doc, n);
|
|
115
|
+
return r === void 0 ? !1 : (e.tr.setNodeAttribute(
|
|
116
116
|
r.startPos - 1,
|
|
117
117
|
"backgroundColor",
|
|
118
|
-
|
|
118
|
+
t
|
|
119
119
|
), o.focus(), !0);
|
|
120
120
|
}
|
|
121
121
|
};
|
|
@@ -146,22 +146,22 @@ const C = {
|
|
|
146
146
|
},
|
|
147
147
|
addCommands() {
|
|
148
148
|
return {
|
|
149
|
-
setBackgroundColor: (n) => ({ commands:
|
|
149
|
+
setBackgroundColor: (n) => ({ commands: t }) => n !== C.backgroundColor.default ? t.setMark(this.name, { color: n }) : t.unsetMark(this.name)
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
function He(n,
|
|
154
|
-
const
|
|
153
|
+
function He(n, t = JSON.stringify) {
|
|
154
|
+
const e = {};
|
|
155
155
|
return n.filter((o) => {
|
|
156
|
-
const r =
|
|
157
|
-
return Object.prototype.hasOwnProperty.call(
|
|
156
|
+
const r = t(o);
|
|
157
|
+
return Object.prototype.hasOwnProperty.call(e, r) ? !1 : e[r] = !0;
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
function Le(n) {
|
|
161
|
-
const
|
|
161
|
+
const t = n.filter(
|
|
162
162
|
(o, r) => n.indexOf(o) !== r
|
|
163
163
|
);
|
|
164
|
-
return He(
|
|
164
|
+
return He(t);
|
|
165
165
|
}
|
|
166
166
|
const j = A.create({
|
|
167
167
|
name: "uniqueID",
|
|
@@ -229,12 +229,12 @@ const j = A.create({
|
|
|
229
229
|
// view.dispatch(tr);
|
|
230
230
|
// },
|
|
231
231
|
addProseMirrorPlugins() {
|
|
232
|
-
let n = null,
|
|
232
|
+
let n = null, t = !1;
|
|
233
233
|
return [
|
|
234
|
-
new
|
|
235
|
-
key: new
|
|
236
|
-
appendTransaction: (
|
|
237
|
-
const i =
|
|
234
|
+
new B({
|
|
235
|
+
key: new M("uniqueID"),
|
|
236
|
+
appendTransaction: (e, o, r) => {
|
|
237
|
+
const i = e.some((f) => f.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && e.some((f) => {
|
|
238
238
|
let k, v;
|
|
239
239
|
return !(!((v = (k = this.options).filterTransaction) === null || v === void 0) && v.call(k, f));
|
|
240
240
|
});
|
|
@@ -242,7 +242,7 @@ const j = A.create({
|
|
|
242
242
|
return;
|
|
243
243
|
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, m = Zt(
|
|
244
244
|
o.doc,
|
|
245
|
-
|
|
245
|
+
e
|
|
246
246
|
), { mapping: h } = m;
|
|
247
247
|
if (Qt(m).forEach(({ newRange: f }) => {
|
|
248
248
|
const k = te(
|
|
@@ -252,8 +252,8 @@ const j = A.create({
|
|
|
252
252
|
), v = k.map(({ node: E }) => E.attrs[d]).filter((E) => E !== null), w = Le(v);
|
|
253
253
|
k.forEach(({ node: E, pos: _ }) => {
|
|
254
254
|
let y;
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
255
|
+
const T = (y = l.doc.nodeAt(_)) === null || y === void 0 ? void 0 : y.attrs[d];
|
|
256
|
+
if (T === null) {
|
|
257
257
|
l.setNodeMarkup(_, void 0, {
|
|
258
258
|
...E.attrs,
|
|
259
259
|
[d]: c()
|
|
@@ -261,7 +261,7 @@ const j = A.create({
|
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
263
|
const { deleted: ot } = h.invert().mapResult(_);
|
|
264
|
-
ot && w.includes(
|
|
264
|
+
ot && w.includes(T) && l.setNodeMarkup(_, void 0, {
|
|
265
265
|
...E.attrs,
|
|
266
266
|
[d]: c()
|
|
267
267
|
});
|
|
@@ -270,10 +270,10 @@ const j = A.create({
|
|
|
270
270
|
return l;
|
|
271
271
|
},
|
|
272
272
|
// we register a global drag handler to track the current drag source element
|
|
273
|
-
view(
|
|
273
|
+
view(e) {
|
|
274
274
|
const o = (r) => {
|
|
275
275
|
let i;
|
|
276
|
-
n = !((i =
|
|
276
|
+
n = !((i = e.dom.parentElement) === null || i === void 0) && i.contains(r.target) ? e.dom.parentElement : null;
|
|
277
277
|
};
|
|
278
278
|
return window.addEventListener("dragstart", o), {
|
|
279
279
|
destroy() {
|
|
@@ -287,18 +287,18 @@ const j = A.create({
|
|
|
287
287
|
handleDOMEvents: {
|
|
288
288
|
// only create new ids for dropped content while holding `alt`
|
|
289
289
|
// or content is dragged from another editor
|
|
290
|
-
drop: (
|
|
290
|
+
drop: (e, o) => {
|
|
291
291
|
let r;
|
|
292
|
-
return (n !==
|
|
292
|
+
return (n !== e.dom.parentElement || ((r = o.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy") && (n = null, t = !0), !1;
|
|
293
293
|
},
|
|
294
294
|
// always create new ids on pasted content
|
|
295
|
-
paste: () => (
|
|
295
|
+
paste: () => (t = !0, !1)
|
|
296
296
|
},
|
|
297
297
|
// we’ll remove ids for every pasted node
|
|
298
298
|
// so we can create a new one within `appendTransaction`
|
|
299
|
-
transformPasted: (
|
|
300
|
-
if (!
|
|
301
|
-
return
|
|
299
|
+
transformPasted: (e) => {
|
|
300
|
+
if (!t)
|
|
301
|
+
return e;
|
|
302
302
|
const { types: o, attributeName: r } = this.options, i = (s) => {
|
|
303
303
|
const l = [];
|
|
304
304
|
return s.forEach((a) => {
|
|
@@ -321,10 +321,10 @@ const j = A.create({
|
|
|
321
321
|
l.push(d);
|
|
322
322
|
}), P.from(l);
|
|
323
323
|
};
|
|
324
|
-
return
|
|
325
|
-
i(
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
return t = !1, new L(
|
|
325
|
+
i(e.content),
|
|
326
|
+
e.openStart,
|
|
327
|
+
e.openEnd
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
330
|
}
|
|
@@ -332,15 +332,15 @@ const j = A.create({
|
|
|
332
332
|
];
|
|
333
333
|
}
|
|
334
334
|
}), Ne = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
|
335
|
-
function
|
|
335
|
+
function Tn(n) {
|
|
336
336
|
return Ne() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
|
|
337
337
|
}
|
|
338
338
|
function S(...n) {
|
|
339
|
-
return n.filter((
|
|
339
|
+
return n.filter((t) => t).join(" ");
|
|
340
340
|
}
|
|
341
341
|
class Pe extends Error {
|
|
342
|
-
constructor(
|
|
343
|
-
super(`Unreachable case: ${
|
|
342
|
+
constructor(t) {
|
|
343
|
+
super(`Unreachable case: ${t}`);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
const yt = /* @__PURE__ */ new Set([
|
|
@@ -350,84 +350,84 @@ const yt = /* @__PURE__ */ new Set([
|
|
|
350
350
|
"strike",
|
|
351
351
|
"code"
|
|
352
352
|
]), vt = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
353
|
-
function at(n,
|
|
354
|
-
const
|
|
353
|
+
function at(n, t) {
|
|
354
|
+
const e = [];
|
|
355
355
|
for (const [o, r] of Object.entries(n.styles))
|
|
356
|
-
yt.has(o) ?
|
|
356
|
+
yt.has(o) ? e.push(t.mark(o)) : vt.has(o) && e.push(t.mark(o, { color: r }));
|
|
357
357
|
return n.text.split(/(\n)/g).filter((o) => o.length > 0).map((o) => o === `
|
|
358
|
-
` ?
|
|
358
|
+
` ? t.nodes.hardBreak.create() : t.text(o, e));
|
|
359
359
|
}
|
|
360
|
-
function De(n,
|
|
361
|
-
const
|
|
360
|
+
function De(n, t) {
|
|
361
|
+
const e = t.marks.link.create({
|
|
362
362
|
href: n.href
|
|
363
363
|
});
|
|
364
|
-
return wt(n.content,
|
|
364
|
+
return wt(n.content, t).map((o) => {
|
|
365
365
|
if (o.type.name === "text")
|
|
366
|
-
return o.mark([...o.marks,
|
|
366
|
+
return o.mark([...o.marks, e]);
|
|
367
367
|
if (o.type.name === "hardBreak")
|
|
368
368
|
return o;
|
|
369
369
|
throw new Error("unexpected node type");
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
|
-
function wt(n,
|
|
373
|
-
const
|
|
372
|
+
function wt(n, t) {
|
|
373
|
+
const e = [];
|
|
374
374
|
if (typeof n == "string")
|
|
375
|
-
return
|
|
376
|
-
...at({ type: "text", text: n, styles: {} },
|
|
377
|
-
),
|
|
375
|
+
return e.push(
|
|
376
|
+
...at({ type: "text", text: n, styles: {} }, t)
|
|
377
|
+
), e;
|
|
378
378
|
for (const o of n)
|
|
379
|
-
|
|
380
|
-
return
|
|
379
|
+
e.push(...at(o, t));
|
|
380
|
+
return e;
|
|
381
381
|
}
|
|
382
|
-
function Ct(n,
|
|
383
|
-
const
|
|
382
|
+
function Ct(n, t) {
|
|
383
|
+
const e = [];
|
|
384
384
|
for (const o of n)
|
|
385
385
|
if (o.type === "link")
|
|
386
|
-
|
|
386
|
+
e.push(...De(o, t));
|
|
387
387
|
else if (o.type === "text")
|
|
388
|
-
|
|
388
|
+
e.push(...wt([o], t));
|
|
389
389
|
else
|
|
390
390
|
throw new Pe(o);
|
|
391
|
-
return
|
|
391
|
+
return e;
|
|
392
392
|
}
|
|
393
|
-
function V(n,
|
|
394
|
-
let
|
|
395
|
-
|
|
393
|
+
function V(n, t) {
|
|
394
|
+
let e = n.id;
|
|
395
|
+
e === void 0 && (e = j.options.generateID());
|
|
396
396
|
let o = n.type;
|
|
397
397
|
o === void 0 && (o = "paragraph");
|
|
398
398
|
let r;
|
|
399
399
|
if (!n.content)
|
|
400
|
-
r =
|
|
400
|
+
r = t.nodes[o].create(n.props);
|
|
401
401
|
else if (typeof n.content == "string")
|
|
402
|
-
r =
|
|
402
|
+
r = t.nodes[o].create(
|
|
403
403
|
n.props,
|
|
404
|
-
|
|
404
|
+
t.text(n.content)
|
|
405
405
|
);
|
|
406
406
|
else {
|
|
407
|
-
const l = Ct(n.content,
|
|
408
|
-
r =
|
|
407
|
+
const l = Ct(n.content, t);
|
|
408
|
+
r = t.nodes[o].create(n.props, l);
|
|
409
409
|
}
|
|
410
410
|
const i = [];
|
|
411
411
|
if (n.children)
|
|
412
412
|
for (const l of n.children)
|
|
413
|
-
i.push(V(l,
|
|
414
|
-
const s =
|
|
415
|
-
return
|
|
413
|
+
i.push(V(l, t));
|
|
414
|
+
const s = t.nodes.blockGroup.create({}, i);
|
|
415
|
+
return t.nodes.blockContainer.create(
|
|
416
416
|
{
|
|
417
|
-
id:
|
|
417
|
+
id: e,
|
|
418
418
|
...n.props
|
|
419
419
|
},
|
|
420
420
|
i.length > 0 ? [r, s] : r
|
|
421
421
|
);
|
|
422
422
|
}
|
|
423
423
|
function Oe(n) {
|
|
424
|
-
const
|
|
425
|
-
let
|
|
424
|
+
const t = [];
|
|
425
|
+
let e;
|
|
426
426
|
return n.content.forEach((o) => {
|
|
427
427
|
if (o.type.name === "hardBreak") {
|
|
428
|
-
|
|
429
|
-
` :
|
|
430
|
-
`) :
|
|
428
|
+
e ? e.type === "text" ? e.text += `
|
|
429
|
+
` : e.type === "link" && (e.content[e.content.length - 1].text += `
|
|
430
|
+
`) : e = {
|
|
431
431
|
type: "text",
|
|
432
432
|
text: `
|
|
433
433
|
`,
|
|
@@ -446,7 +446,7 @@ function Oe(n) {
|
|
|
446
446
|
r[s.type.name] = s.attrs.color;
|
|
447
447
|
else
|
|
448
448
|
throw Error("Mark is of an unrecognized type: " + s.type.name);
|
|
449
|
-
|
|
449
|
+
e ? e.type === "text" ? i ? (t.push(e), e = {
|
|
450
450
|
type: "link",
|
|
451
451
|
href: i.attrs.href,
|
|
452
452
|
content: [
|
|
@@ -456,17 +456,17 @@ function Oe(n) {
|
|
|
456
456
|
styles: r
|
|
457
457
|
}
|
|
458
458
|
]
|
|
459
|
-
}) : JSON.stringify(
|
|
459
|
+
}) : JSON.stringify(e.styles) === JSON.stringify(r) ? e.text += o.textContent : (t.push(e), e = {
|
|
460
460
|
type: "text",
|
|
461
461
|
text: o.textContent,
|
|
462
462
|
styles: r
|
|
463
|
-
}) :
|
|
464
|
-
|
|
465
|
-
) === JSON.stringify(r) ?
|
|
463
|
+
}) : e.type === "link" && (i ? e.href === i.attrs.href ? JSON.stringify(
|
|
464
|
+
e.content[e.content.length - 1].styles
|
|
465
|
+
) === JSON.stringify(r) ? e.content[e.content.length - 1].text += o.textContent : e.content.push({
|
|
466
466
|
type: "text",
|
|
467
467
|
text: o.textContent,
|
|
468
468
|
styles: r
|
|
469
|
-
}) : (
|
|
469
|
+
}) : (t.push(e), e = {
|
|
470
470
|
type: "link",
|
|
471
471
|
href: i.attrs.href,
|
|
472
472
|
content: [
|
|
@@ -476,11 +476,11 @@ function Oe(n) {
|
|
|
476
476
|
styles: r
|
|
477
477
|
}
|
|
478
478
|
]
|
|
479
|
-
}) : (
|
|
479
|
+
}) : (t.push(e), e = {
|
|
480
480
|
type: "text",
|
|
481
481
|
text: o.textContent,
|
|
482
482
|
styles: r
|
|
483
|
-
})) : i ?
|
|
483
|
+
})) : i ? e = {
|
|
484
484
|
type: "link",
|
|
485
485
|
href: i.attrs.href,
|
|
486
486
|
content: [
|
|
@@ -490,19 +490,19 @@ function Oe(n) {
|
|
|
490
490
|
styles: r
|
|
491
491
|
}
|
|
492
492
|
]
|
|
493
|
-
} :
|
|
493
|
+
} : e = {
|
|
494
494
|
type: "text",
|
|
495
495
|
text: o.textContent,
|
|
496
496
|
styles: r
|
|
497
497
|
};
|
|
498
|
-
}),
|
|
498
|
+
}), e && t.push(e), t;
|
|
499
499
|
}
|
|
500
|
-
function x(n,
|
|
500
|
+
function x(n, t, e) {
|
|
501
501
|
if (n.type.name !== "blockContainer")
|
|
502
502
|
throw Error(
|
|
503
503
|
"Node must be of type blockContainer, but is of type" + n.type.name + "."
|
|
504
504
|
);
|
|
505
|
-
const o =
|
|
505
|
+
const o = e == null ? void 0 : e.get(n);
|
|
506
506
|
if (o)
|
|
507
507
|
return o;
|
|
508
508
|
const r = bt(n);
|
|
@@ -513,7 +513,7 @@ function x(n, e, t) {
|
|
|
513
513
|
...n.attrs,
|
|
514
514
|
...r.contentNode.attrs
|
|
515
515
|
})) {
|
|
516
|
-
const h =
|
|
516
|
+
const h = t[r.contentType.name];
|
|
517
517
|
if (!h)
|
|
518
518
|
throw Error(
|
|
519
519
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
@@ -521,10 +521,10 @@ function x(n, e, t) {
|
|
|
521
521
|
const p = h.propSchema;
|
|
522
522
|
c in p ? s[c] = m : c !== "id" && !(c in C) && console.warn("Block has an unrecognized attribute: " + c);
|
|
523
523
|
}
|
|
524
|
-
const l =
|
|
524
|
+
const l = t[r.contentType.name], a = [];
|
|
525
525
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
526
526
|
a.push(
|
|
527
|
-
x(n.lastChild.child(c),
|
|
527
|
+
x(n.lastChild.child(c), t, e)
|
|
528
528
|
);
|
|
529
529
|
const d = {
|
|
530
530
|
id: i,
|
|
@@ -533,9 +533,9 @@ function x(n, e, t) {
|
|
|
533
533
|
content: l.node.config.content === "inline*" ? Oe(r.contentNode) : void 0,
|
|
534
534
|
children: a
|
|
535
535
|
};
|
|
536
|
-
return
|
|
536
|
+
return e == null || e.set(n, d), d;
|
|
537
537
|
}
|
|
538
|
-
const lt = new
|
|
538
|
+
const lt = new M("previous-blocks"), Re = {
|
|
539
539
|
// Numbered List Items
|
|
540
540
|
index: "index",
|
|
541
541
|
// Headings
|
|
@@ -546,15 +546,15 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
546
546
|
"depth-change": "depth-change"
|
|
547
547
|
}, ze = () => {
|
|
548
548
|
let n;
|
|
549
|
-
return new
|
|
549
|
+
return new B({
|
|
550
550
|
key: lt,
|
|
551
|
-
view(
|
|
551
|
+
view(t) {
|
|
552
552
|
return {
|
|
553
|
-
update: async (
|
|
553
|
+
update: async (e, o) => {
|
|
554
554
|
var r;
|
|
555
|
-
((r = this.key) == null ? void 0 : r.getState(
|
|
556
|
-
|
|
557
|
-
|
|
555
|
+
((r = this.key) == null ? void 0 : r.getState(e.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
556
|
+
e.dispatch(
|
|
557
|
+
e.state.tr.setMeta(lt, { clearUpdate: !0 })
|
|
558
558
|
);
|
|
559
559
|
}, 0));
|
|
560
560
|
},
|
|
@@ -574,9 +574,9 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
574
574
|
updatedBlocks: /* @__PURE__ */ new Set()
|
|
575
575
|
};
|
|
576
576
|
},
|
|
577
|
-
apply(
|
|
578
|
-
if (
|
|
579
|
-
return
|
|
577
|
+
apply(t, e, o, r) {
|
|
578
|
+
if (e.currentTransactionOldBlockAttrs = {}, e.updatedBlocks.clear(), !t.docChanged || o.doc.eq(r.doc))
|
|
579
|
+
return e;
|
|
580
580
|
const i = {}, s = nt(o.doc, (d) => d.attrs.id), l = new Map(
|
|
581
581
|
s.map((d) => [d.node.attrs.id, d])
|
|
582
582
|
), a = nt(r.doc, (d) => d.attrs.id);
|
|
@@ -595,38 +595,38 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
595
595
|
type: m.type.name,
|
|
596
596
|
depth: o.doc.resolve(c.pos).depth
|
|
597
597
|
};
|
|
598
|
-
i[d.node.attrs.id] = f,
|
|
598
|
+
i[d.node.attrs.id] = f, t.getMeta("numberedListIndexing") && (d.node.attrs.id in e.prevTransactionOldBlockAttrs && (f = e.prevTransactionOldBlockAttrs[d.node.attrs.id]), p.type === "numberedListItem" && (f.index = p.index)), e.currentTransactionOldBlockAttrs[d.node.attrs.id] = f, JSON.stringify(f) !== JSON.stringify(p) && (f["depth-change"] = f.depth - p.depth, e.updatedBlocks.add(d.node.attrs.id));
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
-
return
|
|
601
|
+
return e.prevTransactionOldBlockAttrs = i, e;
|
|
602
602
|
}
|
|
603
603
|
},
|
|
604
604
|
props: {
|
|
605
|
-
decorations(
|
|
606
|
-
const
|
|
607
|
-
if (
|
|
605
|
+
decorations(t) {
|
|
606
|
+
const e = this.getState(t);
|
|
607
|
+
if (e.updatedBlocks.size === 0)
|
|
608
608
|
return;
|
|
609
609
|
const o = [];
|
|
610
|
-
return
|
|
611
|
-
if (!r.attrs.id || !
|
|
610
|
+
return t.doc.descendants((r, i) => {
|
|
611
|
+
if (!r.attrs.id || !e.updatedBlocks.has(r.attrs.id))
|
|
612
612
|
return;
|
|
613
|
-
const s =
|
|
613
|
+
const s = e.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
|
|
614
614
|
for (const [d, c] of Object.entries(s))
|
|
615
615
|
l["data-prev-" + Re[d]] = c || "none";
|
|
616
|
-
const a =
|
|
616
|
+
const a = $.node(i, i + r.nodeSize, {
|
|
617
617
|
...l
|
|
618
618
|
});
|
|
619
619
|
o.push(a);
|
|
620
|
-
}),
|
|
620
|
+
}), W.create(t.doc, o);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
});
|
|
624
|
-
}, Et = "_blockOuter_xo7pf_5", St = "_block_xo7pf_5",
|
|
624
|
+
}, Et = "_blockOuter_xo7pf_5", St = "_block_xo7pf_5", Bt = "_reactNodeViewRenderer_xo7pf_17", Tt = "_blockContent_xo7pf_22", Mt = "_blockGroup_xo7pf_42", xt = "_wrapper_xo7pf_226", It = "_addImageButton_xo7pf_234", At = "_addImageButtonIcon_xo7pf_250", _t = "_addImageButtonText_xo7pf_256", Ht = "_imageAndCaptionWrapper_xo7pf_260", Lt = "_imageWrapper_xo7pf_266", Nt = "_image_xo7pf_260", Pt = "_resizeHandle_xo7pf_279", Dt = "_caption_xo7pf_294", Ot = "_isEmpty_xo7pf_300", Rt = "_inlineContent_xo7pf_300", zt = "_isFilter_xo7pf_301", Vt = "_hasAnchor_xo7pf_313", g = {
|
|
625
625
|
blockOuter: Et,
|
|
626
626
|
block: St,
|
|
627
|
-
reactNodeViewRenderer:
|
|
628
|
-
blockContent:
|
|
629
|
-
blockGroup:
|
|
627
|
+
reactNodeViewRenderer: Bt,
|
|
628
|
+
blockContent: Tt,
|
|
629
|
+
blockGroup: Mt,
|
|
630
630
|
wrapper: xt,
|
|
631
631
|
addImageButton: It,
|
|
632
632
|
addImageButtonIcon: At,
|
|
@@ -640,14 +640,14 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
640
640
|
inlineContent: Rt,
|
|
641
641
|
isFilter: zt,
|
|
642
642
|
hasAnchor: Vt
|
|
643
|
-
},
|
|
643
|
+
}, Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
644
644
|
__proto__: null,
|
|
645
645
|
addImageButton: It,
|
|
646
646
|
addImageButtonIcon: At,
|
|
647
647
|
addImageButtonText: _t,
|
|
648
648
|
block: St,
|
|
649
|
-
blockContent:
|
|
650
|
-
blockGroup:
|
|
649
|
+
blockContent: Tt,
|
|
650
|
+
blockGroup: Mt,
|
|
651
651
|
blockOuter: Et,
|
|
652
652
|
caption: Dt,
|
|
653
653
|
default: g,
|
|
@@ -658,7 +658,7 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
658
658
|
inlineContent: Rt,
|
|
659
659
|
isEmpty: Ot,
|
|
660
660
|
isFilter: zt,
|
|
661
|
-
reactNodeViewRenderer:
|
|
661
|
+
reactNodeViewRenderer: Bt,
|
|
662
662
|
resizeHandle: Pt,
|
|
663
663
|
wrapper: xt
|
|
664
664
|
}, Symbol.toStringTag, { value: "Module" })), Ve = {
|
|
@@ -667,14 +667,14 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
667
667
|
id: "data-id",
|
|
668
668
|
depth: "data-depth",
|
|
669
669
|
depthChange: "data-depth-change"
|
|
670
|
-
}, Ue = new
|
|
670
|
+
}, Ue = new M("non-editable-block"), Fe = () => new B({
|
|
671
671
|
key: Ue,
|
|
672
672
|
props: {
|
|
673
|
-
handleKeyDown: (n,
|
|
674
|
-
"node" in n.state.selection &&
|
|
673
|
+
handleKeyDown: (n, t) => {
|
|
674
|
+
"node" in n.state.selection && t.preventDefault();
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
|
-
}),
|
|
677
|
+
}), $e = G.create({
|
|
678
678
|
name: "blockContainer",
|
|
679
679
|
group: "blockContainer",
|
|
680
680
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -689,17 +689,17 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
689
689
|
getAttrs: (n) => {
|
|
690
690
|
if (typeof n == "string")
|
|
691
691
|
return !1;
|
|
692
|
-
const
|
|
693
|
-
for (const [
|
|
694
|
-
n.getAttribute(o) && (e
|
|
695
|
-
return n.getAttribute("data-node-type") === "blockContainer" ?
|
|
692
|
+
const t = {};
|
|
693
|
+
for (const [e, o] of Object.entries(Ve))
|
|
694
|
+
n.getAttribute(o) && (t[e] = n.getAttribute(o));
|
|
695
|
+
return n.getAttribute("data-node-type") === "blockContainer" ? t : !1;
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
];
|
|
699
699
|
},
|
|
700
700
|
renderHTML({ HTMLAttributes: n }) {
|
|
701
|
-
var
|
|
702
|
-
const
|
|
701
|
+
var e;
|
|
702
|
+
const t = ((e = this.options.domAttributes) == null ? void 0 : e.blockContainer) || {};
|
|
703
703
|
return [
|
|
704
704
|
"div",
|
|
705
705
|
N(n, {
|
|
@@ -710,8 +710,8 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
710
710
|
"div",
|
|
711
711
|
N(
|
|
712
712
|
{
|
|
713
|
-
...
|
|
714
|
-
class: S(g.block,
|
|
713
|
+
...t,
|
|
714
|
+
class: S(g.block, t.class),
|
|
715
715
|
"data-node-type": this.name
|
|
716
716
|
},
|
|
717
717
|
n
|
|
@@ -723,66 +723,66 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
723
723
|
addCommands() {
|
|
724
724
|
return {
|
|
725
725
|
// Creates a new text block at a given position.
|
|
726
|
-
BNCreateBlock: (n) => ({ state:
|
|
727
|
-
const o =
|
|
728
|
-
return
|
|
726
|
+
BNCreateBlock: (n) => ({ state: t, dispatch: e }) => {
|
|
727
|
+
const o = t.schema.nodes.blockContainer.createAndFill();
|
|
728
|
+
return e && t.tr.insert(n, o), !0;
|
|
729
729
|
},
|
|
730
730
|
// Deletes a block at a given position.
|
|
731
|
-
BNDeleteBlock: (n) => ({ state:
|
|
732
|
-
const o = b(
|
|
731
|
+
BNDeleteBlock: (n) => ({ state: t, dispatch: e }) => {
|
|
732
|
+
const o = b(t.doc, n);
|
|
733
733
|
if (o === void 0)
|
|
734
734
|
return !1;
|
|
735
735
|
const { startPos: r, endPos: i } = o;
|
|
736
|
-
return
|
|
736
|
+
return e && t.tr.deleteRange(r, i), !0;
|
|
737
737
|
},
|
|
738
738
|
// Updates a block at a given position.
|
|
739
|
-
BNUpdateBlock: (n,
|
|
740
|
-
const r = b(
|
|
739
|
+
BNUpdateBlock: (n, t) => ({ state: e, dispatch: o }) => {
|
|
740
|
+
const r = b(e.doc, n);
|
|
741
741
|
if (r === void 0)
|
|
742
742
|
return !1;
|
|
743
743
|
const { startPos: i, endPos: s, node: l, contentNode: a } = r;
|
|
744
744
|
if (o) {
|
|
745
|
-
if (
|
|
745
|
+
if (t.children !== void 0) {
|
|
746
746
|
const p = [];
|
|
747
|
-
for (const f of
|
|
748
|
-
p.push(V(f,
|
|
749
|
-
l.childCount === 2 ?
|
|
747
|
+
for (const f of t.children)
|
|
748
|
+
p.push(V(f, e.schema));
|
|
749
|
+
l.childCount === 2 ? e.tr.replace(
|
|
750
750
|
i + a.nodeSize + 1,
|
|
751
751
|
s - 1,
|
|
752
752
|
new L(P.from(p), 0, 0)
|
|
753
|
-
) :
|
|
753
|
+
) : e.tr.insert(
|
|
754
754
|
i + a.nodeSize,
|
|
755
|
-
|
|
755
|
+
e.schema.nodes.blockGroup.create({}, p)
|
|
756
756
|
);
|
|
757
757
|
}
|
|
758
|
-
if (
|
|
758
|
+
if (t.content !== void 0) {
|
|
759
759
|
let p = [];
|
|
760
|
-
typeof
|
|
760
|
+
typeof t.content == "string" ? p.push(e.schema.text(t.content)) : p = Ct(t.content, e.schema), e.tr.replace(
|
|
761
761
|
i + 1,
|
|
762
762
|
i + a.nodeSize - 1,
|
|
763
763
|
new L(P.from(p), 0, 0)
|
|
764
764
|
);
|
|
765
765
|
}
|
|
766
|
-
const d = a.type.name, c =
|
|
767
|
-
m === "inline*" && h === "" ?
|
|
766
|
+
const d = a.type.name, c = t.type || d, m = e.schema.nodes[d].spec.content, h = e.schema.nodes[c].spec.content;
|
|
767
|
+
m === "inline*" && h === "" ? e.tr.replaceWith(
|
|
768
768
|
i,
|
|
769
769
|
s,
|
|
770
|
-
|
|
770
|
+
e.schema.nodes[c].create({
|
|
771
771
|
...a.attrs,
|
|
772
|
-
...
|
|
772
|
+
...t.props
|
|
773
773
|
})
|
|
774
774
|
).setSelection(
|
|
775
|
-
new mt(
|
|
776
|
-
) :
|
|
775
|
+
new mt(e.tr.doc.resolve(i))
|
|
776
|
+
) : e.tr.setNodeMarkup(
|
|
777
777
|
i,
|
|
778
|
-
|
|
778
|
+
t.type === void 0 ? void 0 : e.schema.nodes[t.type],
|
|
779
779
|
{
|
|
780
780
|
...a.attrs,
|
|
781
|
-
...
|
|
781
|
+
...t.props
|
|
782
782
|
}
|
|
783
|
-
),
|
|
783
|
+
), e.tr.setNodeMarkup(i - 1, void 0, {
|
|
784
784
|
...l.attrs,
|
|
785
|
-
...
|
|
785
|
+
...t.props
|
|
786
786
|
});
|
|
787
787
|
}
|
|
788
788
|
return !0;
|
|
@@ -804,42 +804,42 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
804
804
|
// Block2Block3
|
|
805
805
|
// Block4
|
|
806
806
|
// Block5
|
|
807
|
-
BNMergeBlocks: (n) => ({ state:
|
|
808
|
-
const o =
|
|
807
|
+
BNMergeBlocks: (n) => ({ state: t, dispatch: e }) => {
|
|
808
|
+
const o = t.doc.resolve(n + 1).node().type.name === "blockContainer", r = t.doc.resolve(n - 1).node().type.name === "blockContainer";
|
|
809
809
|
if (!o || !r)
|
|
810
810
|
return !1;
|
|
811
811
|
const i = b(
|
|
812
|
-
|
|
812
|
+
t.doc,
|
|
813
813
|
n + 1
|
|
814
814
|
), { node: s, contentNode: l, startPos: a, endPos: d, depth: c } = i;
|
|
815
815
|
if (s.childCount === 2) {
|
|
816
|
-
const p =
|
|
816
|
+
const p = t.doc.resolve(
|
|
817
817
|
a + l.nodeSize + 1
|
|
818
|
-
), f =
|
|
819
|
-
|
|
818
|
+
), f = t.doc.resolve(d - 1), k = p.blockRange(f);
|
|
819
|
+
e && t.tr.lift(k, c - 1);
|
|
820
820
|
}
|
|
821
|
-
let m = n - 1, h = b(
|
|
821
|
+
let m = n - 1, h = b(t.doc, m);
|
|
822
822
|
for (; h.numChildBlocks > 0; )
|
|
823
|
-
if (m--, h = b(
|
|
823
|
+
if (m--, h = b(t.doc, m), h === void 0)
|
|
824
824
|
return !1;
|
|
825
|
-
return
|
|
826
|
-
|
|
825
|
+
return e && (e(
|
|
826
|
+
t.tr.deleteRange(a, a + l.nodeSize).replace(
|
|
827
827
|
m - 1,
|
|
828
828
|
a,
|
|
829
829
|
new L(l.content, 0, 0)
|
|
830
830
|
).scrollIntoView()
|
|
831
|
-
),
|
|
832
|
-
new it(
|
|
831
|
+
), t.tr.setSelection(
|
|
832
|
+
new it(t.doc.resolve(m - 1))
|
|
833
833
|
)), !0;
|
|
834
834
|
},
|
|
835
835
|
// Splits a block at a given position. Content after the position is moved to a new block below, at the same
|
|
836
836
|
// nesting level.
|
|
837
|
-
BNSplitBlock: (n,
|
|
838
|
-
const r = b(
|
|
837
|
+
BNSplitBlock: (n, t) => ({ state: e, dispatch: o }) => {
|
|
838
|
+
const r = b(e.doc, n);
|
|
839
839
|
if (r === void 0)
|
|
840
840
|
return !1;
|
|
841
|
-
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c =
|
|
842
|
-
return o && (
|
|
841
|
+
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = e.doc.cut(l + 1, n), m = e.doc.cut(n, a - 1), h = e.schema.nodes.blockContainer.createAndFill(), p = a + 1, f = p + 2;
|
|
842
|
+
return o && (e.tr.insert(p, h), e.tr.replace(
|
|
843
843
|
f,
|
|
844
844
|
f + 1,
|
|
845
845
|
m.content.size > 0 ? new L(
|
|
@@ -847,14 +847,14 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
847
847
|
d + 2,
|
|
848
848
|
d + 2
|
|
849
849
|
) : void 0
|
|
850
|
-
),
|
|
850
|
+
), t && e.tr.setBlockType(
|
|
851
851
|
f,
|
|
852
852
|
f,
|
|
853
|
-
|
|
853
|
+
e.schema.node(s).type,
|
|
854
854
|
i.attrs
|
|
855
|
-
),
|
|
856
|
-
new it(
|
|
857
|
-
),
|
|
855
|
+
), e.tr.setSelection(
|
|
856
|
+
new it(e.doc.resolve(f))
|
|
857
|
+
), e.tr.replace(
|
|
858
858
|
l + 1,
|
|
859
859
|
a - 1,
|
|
860
860
|
c.content.size > 0 ? new L(
|
|
@@ -871,65 +871,85 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
871
871
|
},
|
|
872
872
|
addKeyboardShortcuts() {
|
|
873
873
|
return {
|
|
874
|
-
Backspace: () => this.editor.commands.first(({ commands:
|
|
874
|
+
Backspace: () => this.editor.commands.first(({ commands: o }) => [
|
|
875
875
|
// Deletes the selection if it's not empty.
|
|
876
|
-
() =>
|
|
876
|
+
() => o.deleteSelection(),
|
|
877
877
|
// Undoes an input rule if one was triggered in the last editor state change.
|
|
878
|
-
() =>
|
|
878
|
+
() => o.undoInputRule(),
|
|
879
879
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
880
|
-
() =>
|
|
881
|
-
const { contentType:
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
),
|
|
885
|
-
return
|
|
880
|
+
() => o.command(({ state: r }) => {
|
|
881
|
+
const { contentType: i } = b(
|
|
882
|
+
r.doc,
|
|
883
|
+
r.selection.from
|
|
884
|
+
), s = r.selection.$anchor.parentOffset === 0, l = i.name === "paragraph";
|
|
885
|
+
return s && !l ? o.BNUpdateBlock(r.selection.from, {
|
|
886
886
|
type: "paragraph",
|
|
887
887
|
props: {}
|
|
888
888
|
}) : !1;
|
|
889
889
|
}),
|
|
890
890
|
// Removes a level of nesting if the block is indented if the selection is at the start of the block.
|
|
891
|
-
() =>
|
|
891
|
+
() => o.command(({ state: r }) => r.selection.$anchor.parentOffset === 0 ? o.liftListItem("blockContainer") : !1),
|
|
892
892
|
// Merges block with the previous one if it isn't indented, isn't the first block in the doc, and the selection
|
|
893
893
|
// is at the start of the block.
|
|
894
|
-
() =>
|
|
895
|
-
const { depth:
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
),
|
|
899
|
-
return !
|
|
894
|
+
() => o.command(({ state: r }) => {
|
|
895
|
+
const { depth: i, startPos: s } = b(
|
|
896
|
+
r.doc,
|
|
897
|
+
r.selection.from
|
|
898
|
+
), l = r.selection.$anchor.parentOffset === 0, a = r.selection.anchor === r.selection.head, d = s === 2, c = s - 1;
|
|
899
|
+
return !d && l && a && i === 2 ? o.BNMergeBlocks(c) : !1;
|
|
900
900
|
})
|
|
901
901
|
]),
|
|
902
|
-
|
|
902
|
+
Delete: () => this.editor.commands.first(({ commands: o }) => [
|
|
903
|
+
// Deletes the selection if it's not empty.
|
|
904
|
+
() => o.deleteSelection(),
|
|
905
|
+
// Merges block with the next one (at the same nesting level or lower),
|
|
906
|
+
// if one exists, the block has no children, and the selection is at the
|
|
907
|
+
// end of the block.
|
|
908
|
+
() => o.command(({ state: r }) => {
|
|
909
|
+
const { node: i, contentNode: s, depth: l, endPos: a } = b(
|
|
910
|
+
r.doc,
|
|
911
|
+
r.selection.from
|
|
912
|
+
), d = r.selection.$anchor.parentOffset === s.firstChild.nodeSize, c = r.selection.anchor === r.selection.head, m = i.childCount === 2;
|
|
913
|
+
if (d && c && !m) {
|
|
914
|
+
let h = l, p = a + 2, f = r.doc.resolve(p).depth;
|
|
915
|
+
for (; f < h; )
|
|
916
|
+
h = f, p += 2, f = r.doc.resolve(p).depth;
|
|
917
|
+
return o.BNMergeBlocks(p - 1);
|
|
918
|
+
}
|
|
919
|
+
return !1;
|
|
920
|
+
})
|
|
921
|
+
]),
|
|
922
|
+
Enter: () => this.editor.commands.first(({ commands: o }) => [
|
|
903
923
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
904
924
|
// of the block.
|
|
905
|
-
() =>
|
|
906
|
-
const { node:
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
),
|
|
910
|
-
return
|
|
925
|
+
() => o.command(({ state: r }) => {
|
|
926
|
+
const { node: i, depth: s } = b(
|
|
927
|
+
r.doc,
|
|
928
|
+
r.selection.from
|
|
929
|
+
), l = r.selection.$anchor.parentOffset === 0, a = r.selection.anchor === r.selection.head, d = i.textContent.length === 0, c = s > 2;
|
|
930
|
+
return l && a && d && c ? o.liftListItem("blockContainer") : !1;
|
|
911
931
|
}),
|
|
912
932
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
913
933
|
// empty & at the start of the block.
|
|
914
|
-
() =>
|
|
915
|
-
const { node:
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
),
|
|
919
|
-
if (
|
|
920
|
-
const
|
|
921
|
-
return
|
|
934
|
+
() => o.command(({ state: r, chain: i }) => {
|
|
935
|
+
const { node: s, endPos: l } = b(
|
|
936
|
+
r.doc,
|
|
937
|
+
r.selection.from
|
|
938
|
+
), a = r.selection.$anchor.parentOffset === 0, d = r.selection.anchor === r.selection.head, c = s.textContent.length === 0;
|
|
939
|
+
if (a && d && c) {
|
|
940
|
+
const m = l + 1, h = m + 2;
|
|
941
|
+
return i().BNCreateBlock(m).setTextSelection(h).run(), !0;
|
|
922
942
|
}
|
|
923
943
|
return !1;
|
|
924
944
|
}),
|
|
925
945
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
926
946
|
// deletes the selection beforehand, if it's not empty.
|
|
927
|
-
() =>
|
|
928
|
-
const { node:
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
);
|
|
932
|
-
return
|
|
947
|
+
() => o.command(({ state: r, chain: i }) => {
|
|
948
|
+
const { node: s } = b(
|
|
949
|
+
r.doc,
|
|
950
|
+
r.selection.from
|
|
951
|
+
), l = r.selection.$anchor.parentOffset === 0;
|
|
952
|
+
return s.textContent.length === 0 ? !1 : (i().deleteSelection().BNSplitBlock(r.selection.from, l).run(), !0);
|
|
933
953
|
})
|
|
934
954
|
]),
|
|
935
955
|
// Always returning true for tab key presses ensures they're not captured by the browser. Otherwise, they blur the
|
|
@@ -941,7 +961,7 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
941
961
|
)
|
|
942
962
|
};
|
|
943
963
|
}
|
|
944
|
-
}),
|
|
964
|
+
}), We = G.create({
|
|
945
965
|
name: "blockGroup",
|
|
946
966
|
group: "blockGroup",
|
|
947
967
|
content: "blockContainer+",
|
|
@@ -954,16 +974,16 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
954
974
|
];
|
|
955
975
|
},
|
|
956
976
|
renderHTML({ HTMLAttributes: n }) {
|
|
957
|
-
var
|
|
958
|
-
const
|
|
977
|
+
var e;
|
|
978
|
+
const t = ((e = this.options.domAttributes) == null ? void 0 : e.blockGroup) || {};
|
|
959
979
|
return [
|
|
960
980
|
"div",
|
|
961
981
|
N(
|
|
962
982
|
{
|
|
963
|
-
...
|
|
983
|
+
...t,
|
|
964
984
|
class: S(
|
|
965
985
|
g.blockGroup,
|
|
966
|
-
|
|
986
|
+
t.class
|
|
967
987
|
),
|
|
968
988
|
"data-node-type": "blockGroup"
|
|
969
989
|
},
|
|
@@ -977,21 +997,21 @@ const lt = new B("previous-blocks"), Re = {
|
|
|
977
997
|
topNode: !0,
|
|
978
998
|
content: "blockGroup"
|
|
979
999
|
}), je = (n) => {
|
|
980
|
-
const
|
|
1000
|
+
const t = Y.fromSchema(n);
|
|
981
1001
|
return new Y(
|
|
982
1002
|
{
|
|
983
|
-
...
|
|
1003
|
+
...t.nodes
|
|
984
1004
|
// TODO: If a serializer is defined in the config for a custom block, it
|
|
985
1005
|
// should be added here. We still need to figure out how the serializer
|
|
986
1006
|
// should be defined in the custom blocks API though, and implement that,
|
|
987
1007
|
// before we can do this.
|
|
988
1008
|
},
|
|
989
|
-
|
|
1009
|
+
t.marks
|
|
990
1010
|
);
|
|
991
1011
|
}, qe = A.create({
|
|
992
1012
|
addProseMirrorPlugins() {
|
|
993
1013
|
return [
|
|
994
|
-
new
|
|
1014
|
+
new B({
|
|
995
1015
|
props: {
|
|
996
1016
|
clipboardSerializer: je(this.editor.schema)
|
|
997
1017
|
}
|
|
@@ -1004,16 +1024,16 @@ class U {
|
|
|
1004
1024
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1005
1025
|
u(this, "callbacks", {});
|
|
1006
1026
|
}
|
|
1007
|
-
on(
|
|
1008
|
-
return this.callbacks[
|
|
1027
|
+
on(t, e) {
|
|
1028
|
+
return this.callbacks[t] || (this.callbacks[t] = []), this.callbacks[t].push(e), () => this.off(t, e);
|
|
1009
1029
|
}
|
|
1010
|
-
emit(
|
|
1011
|
-
const o = this.callbacks[
|
|
1012
|
-
o && o.forEach((r) => r.apply(this,
|
|
1030
|
+
emit(t, ...e) {
|
|
1031
|
+
const o = this.callbacks[t];
|
|
1032
|
+
o && o.forEach((r) => r.apply(this, e));
|
|
1013
1033
|
}
|
|
1014
|
-
off(
|
|
1015
|
-
const o = this.callbacks[
|
|
1016
|
-
o && (
|
|
1034
|
+
off(t, e) {
|
|
1035
|
+
const o = this.callbacks[t];
|
|
1036
|
+
o && (e ? this.callbacks[t] = o.filter((r) => r !== e) : delete this.callbacks[t]);
|
|
1017
1037
|
}
|
|
1018
1038
|
removeAllListeners() {
|
|
1019
1039
|
this.callbacks = {};
|
|
@@ -1023,28 +1043,28 @@ const Xe = ee(
|
|
|
1023
1043
|
(n) => n.type.name === "blockContainer"
|
|
1024
1044
|
);
|
|
1025
1045
|
class Ke {
|
|
1026
|
-
constructor(
|
|
1046
|
+
constructor(t, e, o = () => {
|
|
1027
1047
|
}) {
|
|
1028
1048
|
u(this, "suggestionsMenuState");
|
|
1029
1049
|
u(this, "updateSuggestionsMenu");
|
|
1030
1050
|
u(this, "pluginState");
|
|
1031
1051
|
u(this, "handleScroll", () => {
|
|
1032
|
-
var
|
|
1033
|
-
if ((
|
|
1034
|
-
const
|
|
1052
|
+
var t;
|
|
1053
|
+
if ((t = this.suggestionsMenuState) != null && t.show) {
|
|
1054
|
+
const e = document.querySelector(
|
|
1035
1055
|
`[data-decoration-id="${this.pluginState.decorationId}"]`
|
|
1036
1056
|
);
|
|
1037
|
-
this.suggestionsMenuState.referencePos =
|
|
1057
|
+
this.suggestionsMenuState.referencePos = e.getBoundingClientRect(), this.updateSuggestionsMenu();
|
|
1038
1058
|
}
|
|
1039
1059
|
});
|
|
1040
|
-
this.editor =
|
|
1060
|
+
this.editor = t, this.pluginKey = e, this.pluginState = J(), this.updateSuggestionsMenu = () => {
|
|
1041
1061
|
if (!this.suggestionsMenuState)
|
|
1042
1062
|
throw new Error("Attempting to update uninitialized suggestions menu");
|
|
1043
1063
|
o(this.suggestionsMenuState);
|
|
1044
1064
|
}, document.addEventListener("scroll", this.handleScroll);
|
|
1045
1065
|
}
|
|
1046
|
-
update(
|
|
1047
|
-
const o = this.pluginKey.getState(
|
|
1066
|
+
update(t, e) {
|
|
1067
|
+
const o = this.pluginKey.getState(e), r = this.pluginKey.getState(t.state), i = !o.active && r.active, s = o.active && !r.active, l = o.active && r.active;
|
|
1048
1068
|
if (!i && !l && !s)
|
|
1049
1069
|
return;
|
|
1050
1070
|
if (this.pluginState = s ? o : r, s || !this.editor.isEditable) {
|
|
@@ -1076,21 +1096,21 @@ function J() {
|
|
|
1076
1096
|
decorationId: void 0
|
|
1077
1097
|
};
|
|
1078
1098
|
}
|
|
1079
|
-
const Ye = (n,
|
|
1099
|
+
const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
1080
1100
|
}) => {
|
|
1081
1101
|
if (o.length !== 1)
|
|
1082
1102
|
throw new Error("'char' should be a single character");
|
|
1083
1103
|
let s;
|
|
1084
1104
|
const l = (a) => {
|
|
1085
|
-
a.dispatch(a.state.tr.setMeta(
|
|
1105
|
+
a.dispatch(a.state.tr.setMeta(e, { deactivate: !0 }));
|
|
1086
1106
|
};
|
|
1087
1107
|
return {
|
|
1088
|
-
plugin: new
|
|
1089
|
-
key:
|
|
1108
|
+
plugin: new B({
|
|
1109
|
+
key: e,
|
|
1090
1110
|
view: () => (s = new Ke(
|
|
1091
1111
|
n,
|
|
1092
|
-
|
|
1093
|
-
|
|
1112
|
+
e,
|
|
1113
|
+
t
|
|
1094
1114
|
), s),
|
|
1095
1115
|
state: {
|
|
1096
1116
|
// Initialize the plugin's internal state.
|
|
@@ -1102,10 +1122,10 @@ const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
|
1102
1122
|
var p, f, k, v;
|
|
1103
1123
|
if (a.getMeta("orderedListIndexing") !== void 0)
|
|
1104
1124
|
return d;
|
|
1105
|
-
if ((p = a.getMeta(
|
|
1125
|
+
if ((p = a.getMeta(e)) != null && p.activate)
|
|
1106
1126
|
return {
|
|
1107
1127
|
active: !0,
|
|
1108
|
-
triggerCharacter: ((f = a.getMeta(
|
|
1128
|
+
triggerCharacter: ((f = a.getMeta(e)) == null ? void 0 : f.triggerCharacter) || "",
|
|
1109
1129
|
queryStartPos: m.selection.from,
|
|
1110
1130
|
items: r(""),
|
|
1111
1131
|
keyboardHoveredItemIndex: 0,
|
|
@@ -1127,15 +1147,15 @@ const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
|
1127
1147
|
d.notFoundCount + (m.selection.from - c.selection.from)
|
|
1128
1148
|
)), // Highlighting text should hide the menu.
|
|
1129
1149
|
m.selection.from !== m.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
|
|
1130
|
-
(k = a.getMeta(
|
|
1150
|
+
(k = a.getMeta(e)) != null && k.deactivate || // Certain mouse events should hide the menu.
|
|
1131
1151
|
// TODO: Change to global mousedown listener.
|
|
1132
1152
|
a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1133
1153
|
d.active && m.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
|
|
1134
1154
|
// the menu.
|
|
1135
1155
|
h.notFoundCount > 3)
|
|
1136
1156
|
return J();
|
|
1137
|
-
if (((v = a.getMeta(
|
|
1138
|
-
let w = a.getMeta(
|
|
1157
|
+
if (((v = a.getMeta(e)) == null ? void 0 : v.selectedItemIndexChanged) !== void 0) {
|
|
1158
|
+
let w = a.getMeta(e).selectedItemIndexChanged;
|
|
1139
1159
|
w < 0 ? w = d.items.length - 1 : w >= d.items.length && (w = 0), h.keyboardHoveredItemIndex = w;
|
|
1140
1160
|
} else
|
|
1141
1161
|
c.selection.from !== m.selection.from && (h.keyboardHoveredItemIndex = 0);
|
|
@@ -1147,7 +1167,7 @@ const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
|
1147
1167
|
const c = this.getState(a.state).active;
|
|
1148
1168
|
if (d.key === o && !c)
|
|
1149
1169
|
return a.dispatch(
|
|
1150
|
-
a.state.tr.insertText(o).scrollIntoView().setMeta(
|
|
1170
|
+
a.state.tr.insertText(o).scrollIntoView().setMeta(e, {
|
|
1151
1171
|
activate: !0,
|
|
1152
1172
|
triggerCharacter: o
|
|
1153
1173
|
})
|
|
@@ -1159,22 +1179,22 @@ const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
|
1159
1179
|
queryStartPos: h,
|
|
1160
1180
|
items: p,
|
|
1161
1181
|
keyboardHoveredItemIndex: f
|
|
1162
|
-
} =
|
|
1182
|
+
} = e.getState(a.state);
|
|
1163
1183
|
return d.key === "ArrowUp" ? (a.dispatch(
|
|
1164
|
-
a.state.tr.setMeta(
|
|
1184
|
+
a.state.tr.setMeta(e, {
|
|
1165
1185
|
selectedItemIndexChanged: f - 1
|
|
1166
1186
|
})
|
|
1167
1187
|
), !0) : d.key === "ArrowDown" ? (a.dispatch(
|
|
1168
|
-
a.state.tr.setMeta(
|
|
1188
|
+
a.state.tr.setMeta(e, {
|
|
1169
1189
|
selectedItemIndexChanged: f + 1
|
|
1170
1190
|
})
|
|
1171
|
-
), !0) : d.key === "Enter" ? (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1191
|
+
), !0) : d.key === "Enter" ? (p.length === 0 || (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1172
1192
|
from: h - m.length,
|
|
1173
1193
|
to: n._tiptapEditor.state.selection.from
|
|
1174
1194
|
}).run(), i({
|
|
1175
1195
|
item: p[f],
|
|
1176
1196
|
editor: n
|
|
1177
|
-
}), !0) : d.key === "Escape" ? (l(a), !0) : !1;
|
|
1197
|
+
})), !0) : d.key === "Escape" ? (l(a), !0) : !1;
|
|
1178
1198
|
},
|
|
1179
1199
|
// Setup decorator on the currently active suggestion.
|
|
1180
1200
|
decorations(a) {
|
|
@@ -1184,8 +1204,8 @@ const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
|
1184
1204
|
if (h === "") {
|
|
1185
1205
|
const p = Xe(a.selection);
|
|
1186
1206
|
if (p)
|
|
1187
|
-
return
|
|
1188
|
-
|
|
1207
|
+
return W.create(a.doc, [
|
|
1208
|
+
$.node(
|
|
1189
1209
|
p.pos,
|
|
1190
1210
|
p.pos + p.node.nodeSize,
|
|
1191
1211
|
{
|
|
@@ -1196,8 +1216,8 @@ const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
|
1196
1216
|
)
|
|
1197
1217
|
]);
|
|
1198
1218
|
}
|
|
1199
|
-
return
|
|
1200
|
-
|
|
1219
|
+
return W.create(a.doc, [
|
|
1220
|
+
$.inline(
|
|
1201
1221
|
m - h.length,
|
|
1202
1222
|
m,
|
|
1203
1223
|
{
|
|
@@ -1220,14 +1240,14 @@ const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
|
1220
1240
|
});
|
|
1221
1241
|
}
|
|
1222
1242
|
};
|
|
1223
|
-
}, tt = new
|
|
1243
|
+
}, tt = new M("SlashMenuPlugin");
|
|
1224
1244
|
class Je extends U {
|
|
1225
|
-
constructor(
|
|
1245
|
+
constructor(e, o) {
|
|
1226
1246
|
super();
|
|
1227
1247
|
u(this, "plugin");
|
|
1228
1248
|
u(this, "itemCallback");
|
|
1229
1249
|
const r = Ye(
|
|
1230
|
-
|
|
1250
|
+
e,
|
|
1231
1251
|
(i) => {
|
|
1232
1252
|
this.emit("update", i);
|
|
1233
1253
|
},
|
|
@@ -1242,11 +1262,11 @@ class Je extends U {
|
|
|
1242
1262
|
);
|
|
1243
1263
|
this.plugin = r.plugin, this.itemCallback = r.itemCallback;
|
|
1244
1264
|
}
|
|
1245
|
-
onUpdate(
|
|
1246
|
-
return this.on("update",
|
|
1265
|
+
onUpdate(e) {
|
|
1266
|
+
return this.on("update", e);
|
|
1247
1267
|
}
|
|
1248
1268
|
}
|
|
1249
|
-
const Ze = new
|
|
1269
|
+
const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
1250
1270
|
name: "placeholder",
|
|
1251
1271
|
addOptions() {
|
|
1252
1272
|
return {
|
|
@@ -1262,24 +1282,24 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1262
1282
|
},
|
|
1263
1283
|
addProseMirrorPlugins() {
|
|
1264
1284
|
return [
|
|
1265
|
-
new
|
|
1285
|
+
new B({
|
|
1266
1286
|
key: Ze,
|
|
1267
1287
|
props: {
|
|
1268
1288
|
decorations: (n) => {
|
|
1269
|
-
const { doc:
|
|
1289
|
+
const { doc: t, selection: e } = n, o = tt.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = e, s = [];
|
|
1270
1290
|
if (r)
|
|
1271
|
-
return
|
|
1291
|
+
return t.descendants((l, a) => {
|
|
1272
1292
|
const d = i >= a && i <= a + l.nodeSize, c = !l.isLeaf && !l.childCount;
|
|
1273
1293
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
1274
1294
|
const m = [this.options.emptyNodeClass];
|
|
1275
1295
|
this.editor.isEmpty && m.push(this.options.emptyEditorClass), d && m.push(this.options.hasAnchorClass), (o == null ? void 0 : o.triggerCharacter) === "" && (o != null && o.active) && m.push(this.options.isFilterClass);
|
|
1276
|
-
const h =
|
|
1296
|
+
const h = $.node(a, a + l.nodeSize, {
|
|
1277
1297
|
class: m.join(" ")
|
|
1278
1298
|
});
|
|
1279
1299
|
s.push(h);
|
|
1280
1300
|
}
|
|
1281
1301
|
return this.options.includeChildren;
|
|
1282
|
-
}),
|
|
1302
|
+
}), W.create(t, s);
|
|
1283
1303
|
}
|
|
1284
1304
|
}
|
|
1285
1305
|
})
|
|
@@ -1307,18 +1327,18 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1307
1327
|
},
|
|
1308
1328
|
addCommands() {
|
|
1309
1329
|
return {
|
|
1310
|
-
setTextAlignment: (n) => ({ state:
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1313
|
-
|
|
1330
|
+
setTextAlignment: (n) => ({ state: t }) => {
|
|
1331
|
+
const e = [], o = b(
|
|
1332
|
+
t.doc,
|
|
1333
|
+
t.selection.from
|
|
1314
1334
|
);
|
|
1315
1335
|
if (o === void 0)
|
|
1316
1336
|
return !1;
|
|
1317
1337
|
let r = o.startPos;
|
|
1318
|
-
for (; r <
|
|
1319
|
-
|
|
1320
|
-
for (const i of
|
|
1321
|
-
|
|
1338
|
+
for (; r < t.selection.to; )
|
|
1339
|
+
t.doc.resolve(r).node().type.spec.group === "blockContent" ? (e.push(r - 1), r += t.doc.resolve(r).node().nodeSize - 1) : r += 1;
|
|
1340
|
+
for (const i of e)
|
|
1341
|
+
t.tr.setNodeAttribute(i, "textAlignment", n);
|
|
1322
1342
|
return !0;
|
|
1323
1343
|
}
|
|
1324
1344
|
};
|
|
@@ -1343,9 +1363,9 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1343
1363
|
},
|
|
1344
1364
|
addCommands() {
|
|
1345
1365
|
return {
|
|
1346
|
-
setBlockTextColor: (n,
|
|
1347
|
-
const r = b(
|
|
1348
|
-
return r === void 0 ? !1 : (
|
|
1366
|
+
setBlockTextColor: (n, t) => ({ state: e, view: o }) => {
|
|
1367
|
+
const r = b(e.doc, n);
|
|
1368
|
+
return r === void 0 ? !1 : (e.tr.setNodeAttribute(r.startPos - 1, "textColor", t), o.focus(), !0);
|
|
1349
1369
|
}
|
|
1350
1370
|
};
|
|
1351
1371
|
}
|
|
@@ -1375,17 +1395,17 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1375
1395
|
},
|
|
1376
1396
|
addCommands() {
|
|
1377
1397
|
return {
|
|
1378
|
-
setTextColor: (n) => ({ commands:
|
|
1398
|
+
setTextColor: (n) => ({ commands: t }) => n !== C.textColor.default ? t.setMark(this.name, { color: n }) : t.unsetMark(this.name)
|
|
1379
1399
|
};
|
|
1380
1400
|
}
|
|
1381
1401
|
}), no = A.create({
|
|
1382
1402
|
name: "trailingNode",
|
|
1383
1403
|
addProseMirrorPlugins() {
|
|
1384
|
-
const n = new
|
|
1404
|
+
const n = new M(this.name);
|
|
1385
1405
|
return [
|
|
1386
|
-
new
|
|
1406
|
+
new B({
|
|
1387
1407
|
key: n,
|
|
1388
|
-
appendTransaction: (
|
|
1408
|
+
appendTransaction: (t, e, o) => {
|
|
1389
1409
|
const { doc: r, tr: i, schema: s } = o, l = n.getState(o), a = r.content.size - 2, d = s.nodes.blockContainer, c = s.nodes.paragraph;
|
|
1390
1410
|
if (l)
|
|
1391
1411
|
return i.insert(
|
|
@@ -1394,12 +1414,12 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1394
1414
|
);
|
|
1395
1415
|
},
|
|
1396
1416
|
state: {
|
|
1397
|
-
init: (
|
|
1417
|
+
init: (t, e) => {
|
|
1398
1418
|
},
|
|
1399
|
-
apply: (
|
|
1400
|
-
if (!
|
|
1401
|
-
return
|
|
1402
|
-
let o =
|
|
1419
|
+
apply: (t, e) => {
|
|
1420
|
+
if (!t.docChanged)
|
|
1421
|
+
return e;
|
|
1422
|
+
let o = t.doc.lastChild;
|
|
1403
1423
|
if (!o || o.type.name !== "blockGroup")
|
|
1404
1424
|
throw new Error("Expected blockGroup");
|
|
1405
1425
|
if (o = o.lastChild, !o || o.type.name !== "blockContainer")
|
|
@@ -1414,8 +1434,8 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1414
1434
|
];
|
|
1415
1435
|
}
|
|
1416
1436
|
}), ro = (n) => {
|
|
1417
|
-
var
|
|
1418
|
-
const
|
|
1437
|
+
var e;
|
|
1438
|
+
const t = [
|
|
1419
1439
|
R.ClipboardTextSerializer,
|
|
1420
1440
|
R.Commands,
|
|
1421
1441
|
R.Editable,
|
|
@@ -1452,10 +1472,10 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1452
1472
|
to,
|
|
1453
1473
|
// nodes
|
|
1454
1474
|
Ge,
|
|
1455
|
-
|
|
1475
|
+
$e.configure({
|
|
1456
1476
|
domAttributes: n.domAttributes
|
|
1457
1477
|
}),
|
|
1458
|
-
|
|
1478
|
+
We.configure({
|
|
1459
1479
|
domAttributes: n.domAttributes
|
|
1460
1480
|
}),
|
|
1461
1481
|
...Object.values(n.blockSchema).map(
|
|
@@ -1471,11 +1491,11 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1471
1491
|
no
|
|
1472
1492
|
];
|
|
1473
1493
|
if (n.collaboration) {
|
|
1474
|
-
if (
|
|
1494
|
+
if (t.push(
|
|
1475
1495
|
ae.configure({
|
|
1476
1496
|
fragment: n.collaboration.fragment
|
|
1477
1497
|
})
|
|
1478
|
-
), (
|
|
1498
|
+
), (e = n.collaboration.provider) != null && e.awareness) {
|
|
1479
1499
|
const o = (r) => {
|
|
1480
1500
|
const i = document.createElement("span");
|
|
1481
1501
|
i.classList.add(D["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
|
|
@@ -1484,7 +1504,7 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1484
1504
|
const l = document.createTextNode(""), a = document.createTextNode("");
|
|
1485
1505
|
return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
|
|
1486
1506
|
};
|
|
1487
|
-
|
|
1507
|
+
t.push(
|
|
1488
1508
|
le.configure({
|
|
1489
1509
|
user: n.collaboration.user,
|
|
1490
1510
|
render: n.collaboration.renderCursor || o,
|
|
@@ -1493,25 +1513,25 @@ const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
|
1493
1513
|
);
|
|
1494
1514
|
}
|
|
1495
1515
|
} else
|
|
1496
|
-
|
|
1497
|
-
return
|
|
1516
|
+
t.push(pe);
|
|
1517
|
+
return t;
|
|
1498
1518
|
};
|
|
1499
|
-
function et(n,
|
|
1500
|
-
let
|
|
1501
|
-
if (
|
|
1519
|
+
function et(n, t) {
|
|
1520
|
+
let e, o;
|
|
1521
|
+
if (t.firstChild.descendants((r, i) => e ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== n ? !0 : (e = r, o = i + 1, !1)), e === void 0 || o === void 0)
|
|
1502
1522
|
throw Error("Could not find block in the editor with matching ID.");
|
|
1503
1523
|
return {
|
|
1504
|
-
node:
|
|
1524
|
+
node: e,
|
|
1505
1525
|
posBeforeNode: o
|
|
1506
1526
|
};
|
|
1507
1527
|
}
|
|
1508
|
-
function Ut(n,
|
|
1509
|
-
const r = typeof
|
|
1528
|
+
function Ut(n, t, e = "before", o) {
|
|
1529
|
+
const r = typeof t == "string" ? t : t.id, i = [];
|
|
1510
1530
|
for (const d of n)
|
|
1511
1531
|
i.push(V(d, o.schema));
|
|
1512
1532
|
let s = -1;
|
|
1513
1533
|
const { node: l, posBeforeNode: a } = et(r, o.state.doc);
|
|
1514
|
-
if (
|
|
1534
|
+
if (e === "before" && (s = a), e === "after" && (s = a + l.nodeSize), e === "nested") {
|
|
1515
1535
|
if (l.childCount < 2) {
|
|
1516
1536
|
s = a + l.firstChild.nodeSize + 1;
|
|
1517
1537
|
const d = o.state.schema.nodes.blockGroup.create(
|
|
@@ -1527,67 +1547,67 @@ function Ut(n, e, t = "before", o) {
|
|
|
1527
1547
|
}
|
|
1528
1548
|
o.view.dispatch(o.state.tr.insert(s, i));
|
|
1529
1549
|
}
|
|
1530
|
-
function io(n,
|
|
1531
|
-
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = et(o,
|
|
1532
|
-
|
|
1550
|
+
function io(n, t, e) {
|
|
1551
|
+
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = et(o, e.state.doc);
|
|
1552
|
+
e.commands.BNUpdateBlock(r + 1, t);
|
|
1533
1553
|
}
|
|
1534
|
-
function Ft(n,
|
|
1535
|
-
const
|
|
1554
|
+
function Ft(n, t) {
|
|
1555
|
+
const e = new Set(
|
|
1536
1556
|
n.map(
|
|
1537
1557
|
(r) => typeof r == "string" ? r : r.id
|
|
1538
1558
|
)
|
|
1539
1559
|
);
|
|
1540
1560
|
let o = 0;
|
|
1541
|
-
if (
|
|
1542
|
-
if (
|
|
1561
|
+
if (t.state.doc.descendants((r, i) => {
|
|
1562
|
+
if (e.size === 0)
|
|
1543
1563
|
return !1;
|
|
1544
|
-
if (r.type.name !== "blockContainer" || !
|
|
1564
|
+
if (r.type.name !== "blockContainer" || !e.has(r.attrs.id))
|
|
1545
1565
|
return !0;
|
|
1546
|
-
|
|
1547
|
-
const s =
|
|
1548
|
-
|
|
1549
|
-
const l =
|
|
1566
|
+
e.delete(r.attrs.id);
|
|
1567
|
+
const s = t.state.doc.nodeSize;
|
|
1568
|
+
t.commands.BNDeleteBlock(i - o + 1);
|
|
1569
|
+
const l = t.state.doc.nodeSize;
|
|
1550
1570
|
return o += s - l, !1;
|
|
1551
|
-
}),
|
|
1552
|
-
const r = [...
|
|
1571
|
+
}), e.size > 0) {
|
|
1572
|
+
const r = [...e].join(`
|
|
1553
1573
|
`);
|
|
1554
1574
|
throw Error(
|
|
1555
1575
|
"Blocks with the following IDs could not be found in the editor: " + r
|
|
1556
1576
|
);
|
|
1557
1577
|
}
|
|
1558
1578
|
}
|
|
1559
|
-
function so(n,
|
|
1560
|
-
Ut(
|
|
1579
|
+
function so(n, t, e) {
|
|
1580
|
+
Ut(t, n[0], "before", e), Ft(n, e);
|
|
1561
1581
|
}
|
|
1562
1582
|
function ao() {
|
|
1563
|
-
const n = (
|
|
1564
|
-
let
|
|
1565
|
-
for (let o = 0; o <
|
|
1566
|
-
const r =
|
|
1583
|
+
const n = (t) => {
|
|
1584
|
+
let e = t.children.length;
|
|
1585
|
+
for (let o = 0; o < e; o++) {
|
|
1586
|
+
const r = t.children[o];
|
|
1567
1587
|
if (r.type === "element" && (n(r), r.tagName === "u"))
|
|
1568
1588
|
if (r.children.length > 0) {
|
|
1569
|
-
|
|
1589
|
+
t.children.splice(o, 1, ...r.children);
|
|
1570
1590
|
const i = r.children.length - 1;
|
|
1571
|
-
|
|
1591
|
+
e += i, o += i;
|
|
1572
1592
|
} else
|
|
1573
|
-
|
|
1593
|
+
t.children.splice(o, 1), e--, o--;
|
|
1574
1594
|
}
|
|
1575
1595
|
};
|
|
1576
1596
|
return n;
|
|
1577
1597
|
}
|
|
1578
1598
|
function lo(n) {
|
|
1579
|
-
const
|
|
1599
|
+
const t = /* @__PURE__ */ new Set([
|
|
1580
1600
|
...n.orderedListItemBlockTypes,
|
|
1581
1601
|
...n.unorderedListItemBlockTypes
|
|
1582
|
-
]),
|
|
1602
|
+
]), e = (o) => {
|
|
1583
1603
|
let r = o.children.length, i;
|
|
1584
1604
|
for (let s = 0; s < r; s++) {
|
|
1585
|
-
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, m =
|
|
1605
|
+
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, m = t.has(
|
|
1586
1606
|
d.properties.dataContentType
|
|
1587
1607
|
), h = m ? n.orderedListItemBlockTypes.has(
|
|
1588
1608
|
d.properties.dataContentType
|
|
1589
1609
|
) ? "ol" : "ul" : null;
|
|
1590
|
-
if (c !== null &&
|
|
1610
|
+
if (c !== null && e(c), i && i.tagName !== h) {
|
|
1591
1611
|
o.children.splice(
|
|
1592
1612
|
s - i.children.length,
|
|
1593
1613
|
i.children.length,
|
|
@@ -1617,74 +1637,85 @@ function lo(n) {
|
|
|
1617
1637
|
i
|
|
1618
1638
|
);
|
|
1619
1639
|
};
|
|
1620
|
-
return
|
|
1640
|
+
return e;
|
|
1621
1641
|
}
|
|
1622
|
-
async function
|
|
1623
|
-
const
|
|
1642
|
+
async function $t(n, t) {
|
|
1643
|
+
const e = document.createElement("div"), o = Y.fromSchema(t);
|
|
1624
1644
|
for (const i of n) {
|
|
1625
|
-
const s = V(i,
|
|
1626
|
-
|
|
1645
|
+
const s = V(i, t), l = o.serializeNode(s);
|
|
1646
|
+
e.appendChild(l);
|
|
1627
1647
|
}
|
|
1628
1648
|
return (await Q().use(ft, { fragment: !0 }).use(lo, {
|
|
1629
1649
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
1630
1650
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
1631
|
-
}).use(gt).process(
|
|
1651
|
+
}).use(gt).process(e.innerHTML)).value;
|
|
1632
1652
|
}
|
|
1633
|
-
async function
|
|
1653
|
+
async function Wt(n, t, e) {
|
|
1634
1654
|
const o = document.createElement("div");
|
|
1635
1655
|
o.innerHTML = n.trim();
|
|
1636
|
-
const i = be.fromSchema(
|
|
1656
|
+
const i = be.fromSchema(e).parse(o), s = [];
|
|
1637
1657
|
for (let l = 0; l < i.firstChild.childCount; l++)
|
|
1638
|
-
s.push(x(i.firstChild.child(l),
|
|
1658
|
+
s.push(x(i.firstChild.child(l), t));
|
|
1639
1659
|
return s;
|
|
1640
1660
|
}
|
|
1641
|
-
async function co(n,
|
|
1642
|
-
return (await Q().use(ft, { fragment: !0 }).use(ao).use(we).use(kt).use(
|
|
1661
|
+
async function co(n, t) {
|
|
1662
|
+
return (await Q().use(ft, { fragment: !0 }).use(ao).use(we).use(kt).use(Be).process(await $t(n, t))).value;
|
|
1643
1663
|
}
|
|
1644
|
-
function uo(n,
|
|
1645
|
-
const
|
|
1664
|
+
function uo(n, t) {
|
|
1665
|
+
const e = t.value ? t.value + `
|
|
1646
1666
|
` : "", o = {};
|
|
1647
|
-
|
|
1667
|
+
t.lang && (o["data-language"] = t.lang);
|
|
1648
1668
|
let r = {
|
|
1649
1669
|
type: "element",
|
|
1650
1670
|
tagName: "code",
|
|
1651
1671
|
properties: o,
|
|
1652
|
-
children: [{ type: "text", value:
|
|
1672
|
+
children: [{ type: "text", value: e }]
|
|
1653
1673
|
};
|
|
1654
|
-
return
|
|
1674
|
+
return t.meta && (r.data = { meta: t.meta }), n.patch(t, r), r = n.applyData(t, r), r = {
|
|
1655
1675
|
type: "element",
|
|
1656
1676
|
tagName: "pre",
|
|
1657
1677
|
properties: {},
|
|
1658
1678
|
children: [r]
|
|
1659
|
-
}, n.patch(
|
|
1679
|
+
}, n.patch(t, r), r;
|
|
1660
1680
|
}
|
|
1661
|
-
async function po(n,
|
|
1681
|
+
async function po(n, t, e) {
|
|
1662
1682
|
const o = await Q().use(Ce).use(kt).use(Ee, {
|
|
1663
1683
|
handlers: {
|
|
1664
1684
|
...Se,
|
|
1665
1685
|
code: uo
|
|
1666
1686
|
}
|
|
1667
1687
|
}).use(gt).process(n);
|
|
1668
|
-
return
|
|
1688
|
+
return Wt(o.value, t, e);
|
|
1669
1689
|
}
|
|
1670
1690
|
function dt(n) {
|
|
1671
1691
|
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1672
1692
|
}
|
|
1673
1693
|
function ho(n) {
|
|
1674
|
-
const
|
|
1675
|
-
return Object.entries(n.propSchema).forEach(([
|
|
1676
|
-
e
|
|
1694
|
+
const t = {};
|
|
1695
|
+
return Object.entries(n.propSchema).forEach(([e, o]) => {
|
|
1696
|
+
t[e] = {
|
|
1677
1697
|
default: o.default,
|
|
1678
1698
|
keepOnSplit: !0,
|
|
1679
1699
|
// Props are displayed in kebab-case as HTML attributes. If a prop's
|
|
1680
1700
|
// value is the same as its default, we don't display an HTML
|
|
1681
1701
|
// attribute for it.
|
|
1682
|
-
parseHTML: (r) =>
|
|
1683
|
-
|
|
1684
|
-
|
|
1702
|
+
parseHTML: (r) => {
|
|
1703
|
+
const i = r.getAttribute(dt(e));
|
|
1704
|
+
if (i === null)
|
|
1705
|
+
return null;
|
|
1706
|
+
if (typeof o.default == "boolean")
|
|
1707
|
+
return i === "true" ? !0 : i === "false" ? !1 : null;
|
|
1708
|
+
if (typeof o.default == "number") {
|
|
1709
|
+
const s = parseFloat(i);
|
|
1710
|
+
return !Number.isNaN(s) && Number.isFinite(s) ? s : null;
|
|
1711
|
+
}
|
|
1712
|
+
return i;
|
|
1713
|
+
},
|
|
1714
|
+
renderHTML: (r) => r[e] !== o.default ? {
|
|
1715
|
+
[dt(e)]: r[e]
|
|
1685
1716
|
} : {}
|
|
1686
1717
|
};
|
|
1687
|
-
}),
|
|
1718
|
+
}), t;
|
|
1688
1719
|
}
|
|
1689
1720
|
function mo(n) {
|
|
1690
1721
|
return [
|
|
@@ -1693,17 +1724,17 @@ function mo(n) {
|
|
|
1693
1724
|
}
|
|
1694
1725
|
];
|
|
1695
1726
|
}
|
|
1696
|
-
function fo(n,
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1699
|
-
for (const [r, i] of Object.entries(
|
|
1700
|
-
|
|
1727
|
+
function fo(n, t) {
|
|
1728
|
+
const e = document.createElement("div");
|
|
1729
|
+
e.setAttribute("data-content-type", n.type);
|
|
1730
|
+
for (const [r, i] of Object.entries(t))
|
|
1731
|
+
e.setAttribute(r, i);
|
|
1701
1732
|
let o;
|
|
1702
|
-
return n.containsInlineContent ? (o = document.createElement("div"),
|
|
1703
|
-
dom:
|
|
1733
|
+
return n.containsInlineContent ? (o = document.createElement("div"), e.appendChild(o)) : o = void 0, o !== void 0 ? {
|
|
1734
|
+
dom: e,
|
|
1704
1735
|
contentDOM: o
|
|
1705
1736
|
} : {
|
|
1706
|
-
dom:
|
|
1737
|
+
dom: e
|
|
1707
1738
|
};
|
|
1708
1739
|
}
|
|
1709
1740
|
function go(n) {
|
|
@@ -1718,11 +1749,11 @@ function go(n) {
|
|
|
1718
1749
|
parseHTML() {
|
|
1719
1750
|
return mo(n);
|
|
1720
1751
|
},
|
|
1721
|
-
renderHTML({ HTMLAttributes:
|
|
1722
|
-
return fo(n,
|
|
1752
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
1753
|
+
return fo(n, e);
|
|
1723
1754
|
},
|
|
1724
1755
|
addNodeView() {
|
|
1725
|
-
return ({ HTMLAttributes:
|
|
1756
|
+
return ({ HTMLAttributes: e, getPos: o }) => {
|
|
1726
1757
|
var p, f;
|
|
1727
1758
|
const r = document.createElement("div"), i = ((p = this.options.domAttributes) == null ? void 0 : p.blockContent) || {};
|
|
1728
1759
|
for (const [k, v] of Object.entries(
|
|
@@ -1733,7 +1764,7 @@ function go(n) {
|
|
|
1733
1764
|
g.blockContent,
|
|
1734
1765
|
i.class
|
|
1735
1766
|
), r.setAttribute("data-content-type", n.type);
|
|
1736
|
-
for (const [k, v] of Object.entries(
|
|
1767
|
+
for (const [k, v] of Object.entries(e))
|
|
1737
1768
|
r.setAttribute(k, v);
|
|
1738
1769
|
const s = this.options.editor;
|
|
1739
1770
|
if (typeof o == "boolean")
|
|
@@ -1799,8 +1830,8 @@ const ko = {
|
|
|
1799
1830
|
return [
|
|
1800
1831
|
...[1, 2, 3].map((n) => new Z({
|
|
1801
1832
|
find: new RegExp(`^(#{${n}})\\s$`),
|
|
1802
|
-
handler: ({ state:
|
|
1803
|
-
|
|
1833
|
+
handler: ({ state: t, chain: e, range: o }) => {
|
|
1834
|
+
e().BNUpdateBlock(t.selection.from, {
|
|
1804
1835
|
type: "heading",
|
|
1805
1836
|
props: {
|
|
1806
1837
|
level: n
|
|
@@ -1851,16 +1882,16 @@ const ko = {
|
|
|
1851
1882
|
}
|
|
1852
1883
|
];
|
|
1853
1884
|
},
|
|
1854
|
-
renderHTML({ node: n, HTMLAttributes:
|
|
1885
|
+
renderHTML({ node: n, HTMLAttributes: t }) {
|
|
1855
1886
|
var r, i;
|
|
1856
|
-
const
|
|
1887
|
+
const e = ((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {}, o = ((i = this.options.domAttributes) == null ? void 0 : i.inlineContent) || {};
|
|
1857
1888
|
return [
|
|
1858
1889
|
"div",
|
|
1859
|
-
N(
|
|
1860
|
-
...
|
|
1890
|
+
N(t, {
|
|
1891
|
+
...e,
|
|
1861
1892
|
class: S(
|
|
1862
1893
|
g.blockContent,
|
|
1863
|
-
|
|
1894
|
+
e.class
|
|
1864
1895
|
),
|
|
1865
1896
|
"data-content-type": this.name
|
|
1866
1897
|
}),
|
|
@@ -1881,14 +1912,14 @@ const ko = {
|
|
|
1881
1912
|
node: bo,
|
|
1882
1913
|
propSchema: ko
|
|
1883
1914
|
}, Gt = (n) => {
|
|
1884
|
-
const { node:
|
|
1915
|
+
const { node: t, contentType: e } = b(
|
|
1885
1916
|
n.state.doc,
|
|
1886
1917
|
n.state.selection.from
|
|
1887
1918
|
), o = n.state.selection.anchor === n.state.selection.head;
|
|
1888
|
-
return !
|
|
1919
|
+
return !e.name.endsWith("ListItem") || !o ? !1 : n.commands.first(({ state: r, chain: i, commands: s }) => [
|
|
1889
1920
|
() => (
|
|
1890
1921
|
// Changes list item block to a text block if the content is empty.
|
|
1891
|
-
s.command(() =>
|
|
1922
|
+
s.command(() => t.textContent.length === 0 ? s.BNUpdateBlock(r.selection.from, {
|
|
1892
1923
|
type: "paragraph",
|
|
1893
1924
|
props: {}
|
|
1894
1925
|
}) : !1)
|
|
@@ -1896,7 +1927,7 @@ const ko = {
|
|
|
1896
1927
|
() => (
|
|
1897
1928
|
// Splits the current block, moving content inside that's after the cursor to a new block of the same type
|
|
1898
1929
|
// below.
|
|
1899
|
-
s.command(() =>
|
|
1930
|
+
s.command(() => t.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
1900
1931
|
)
|
|
1901
1932
|
]);
|
|
1902
1933
|
}, vo = {
|
|
@@ -1909,11 +1940,11 @@ const ko = {
|
|
|
1909
1940
|
// Creates an unordered list when starting with "-", "+", or "*".
|
|
1910
1941
|
new Z({
|
|
1911
1942
|
find: new RegExp("^[-+*]\\s$"),
|
|
1912
|
-
handler: ({ state: n, chain:
|
|
1913
|
-
|
|
1943
|
+
handler: ({ state: n, chain: t, range: e }) => {
|
|
1944
|
+
t().BNUpdateBlock(n.selection.from, {
|
|
1914
1945
|
type: "bulletListItem",
|
|
1915
1946
|
props: {}
|
|
1916
|
-
}).deleteRange({ from:
|
|
1947
|
+
}).deleteRange({ from: e.from, to: e.to });
|
|
1917
1948
|
}
|
|
1918
1949
|
})
|
|
1919
1950
|
];
|
|
@@ -1935,8 +1966,8 @@ const ko = {
|
|
|
1935
1966
|
getAttrs: (n) => {
|
|
1936
1967
|
if (typeof n == "string")
|
|
1937
1968
|
return !1;
|
|
1938
|
-
const
|
|
1939
|
-
return
|
|
1969
|
+
const t = n.parentElement;
|
|
1970
|
+
return t === null ? !1 : t.tagName === "UL" ? {} : !1;
|
|
1940
1971
|
},
|
|
1941
1972
|
node: "bulletListItem"
|
|
1942
1973
|
},
|
|
@@ -1946,8 +1977,8 @@ const ko = {
|
|
|
1946
1977
|
getAttrs: (n) => {
|
|
1947
1978
|
if (typeof n == "string")
|
|
1948
1979
|
return !1;
|
|
1949
|
-
const
|
|
1950
|
-
return
|
|
1980
|
+
const t = n.parentElement;
|
|
1981
|
+
return t === null ? !1 : t.getAttribute("data-content-type") === "bulletListItem" ? {} : !1;
|
|
1951
1982
|
},
|
|
1952
1983
|
priority: 300,
|
|
1953
1984
|
node: "bulletListItem"
|
|
@@ -1956,24 +1987,24 @@ const ko = {
|
|
|
1956
1987
|
},
|
|
1957
1988
|
renderHTML({ HTMLAttributes: n }) {
|
|
1958
1989
|
var o, r;
|
|
1959
|
-
const
|
|
1990
|
+
const t = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, e = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
1960
1991
|
return [
|
|
1961
1992
|
"div",
|
|
1962
1993
|
N(n, {
|
|
1963
|
-
...
|
|
1994
|
+
...t,
|
|
1964
1995
|
class: S(
|
|
1965
1996
|
g.blockContent,
|
|
1966
|
-
|
|
1997
|
+
t.class
|
|
1967
1998
|
),
|
|
1968
1999
|
"data-content-type": this.name
|
|
1969
2000
|
}),
|
|
1970
2001
|
[
|
|
1971
2002
|
"p",
|
|
1972
2003
|
{
|
|
1973
|
-
...
|
|
2004
|
+
...e,
|
|
1974
2005
|
class: S(
|
|
1975
2006
|
g.inlineContent,
|
|
1976
|
-
|
|
2007
|
+
e.class
|
|
1977
2008
|
)
|
|
1978
2009
|
},
|
|
1979
2010
|
0
|
|
@@ -1983,13 +2014,13 @@ const ko = {
|
|
|
1983
2014
|
}), Co = {
|
|
1984
2015
|
node: wo,
|
|
1985
2016
|
propSchema: vo
|
|
1986
|
-
}, Eo = new
|
|
2017
|
+
}, Eo = new M("numbered-list-indexing"), So = () => new B({
|
|
1987
2018
|
key: Eo,
|
|
1988
|
-
appendTransaction: (n,
|
|
1989
|
-
const o =
|
|
2019
|
+
appendTransaction: (n, t, e) => {
|
|
2020
|
+
const o = e.tr;
|
|
1990
2021
|
o.setMeta("numberedListIndexing", !0);
|
|
1991
2022
|
let r = !1;
|
|
1992
|
-
return
|
|
2023
|
+
return e.doc.descendants((i, s) => {
|
|
1993
2024
|
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
1994
2025
|
let l = "1";
|
|
1995
2026
|
const a = s === 1, d = b(o.doc, s + 1);
|
|
@@ -2013,9 +2044,9 @@ const ko = {
|
|
|
2013
2044
|
}
|
|
2014
2045
|
}), r ? o : null;
|
|
2015
2046
|
}
|
|
2016
|
-
}),
|
|
2047
|
+
}), Bo = {
|
|
2017
2048
|
...C
|
|
2018
|
-
},
|
|
2049
|
+
}, To = F({
|
|
2019
2050
|
name: "numberedListItem",
|
|
2020
2051
|
content: "inline*",
|
|
2021
2052
|
addAttributes() {
|
|
@@ -2034,11 +2065,11 @@ const ko = {
|
|
|
2034
2065
|
// Creates an ordered list when starting with "1.".
|
|
2035
2066
|
new Z({
|
|
2036
2067
|
find: new RegExp("^1\\.\\s$"),
|
|
2037
|
-
handler: ({ state: n, chain:
|
|
2038
|
-
|
|
2068
|
+
handler: ({ state: n, chain: t, range: e }) => {
|
|
2069
|
+
t().BNUpdateBlock(n.selection.from, {
|
|
2039
2070
|
type: "numberedListItem",
|
|
2040
2071
|
props: {}
|
|
2041
|
-
}).deleteRange({ from:
|
|
2072
|
+
}).deleteRange({ from: e.from, to: e.to });
|
|
2042
2073
|
}
|
|
2043
2074
|
})
|
|
2044
2075
|
];
|
|
@@ -2064,8 +2095,8 @@ const ko = {
|
|
|
2064
2095
|
getAttrs: (n) => {
|
|
2065
2096
|
if (typeof n == "string")
|
|
2066
2097
|
return !1;
|
|
2067
|
-
const
|
|
2068
|
-
return
|
|
2098
|
+
const t = n.parentElement;
|
|
2099
|
+
return t === null ? !1 : t.tagName === "OL" ? {} : !1;
|
|
2069
2100
|
},
|
|
2070
2101
|
node: "numberedListItem"
|
|
2071
2102
|
},
|
|
@@ -2076,8 +2107,8 @@ const ko = {
|
|
|
2076
2107
|
getAttrs: (n) => {
|
|
2077
2108
|
if (typeof n == "string")
|
|
2078
2109
|
return !1;
|
|
2079
|
-
const
|
|
2080
|
-
return
|
|
2110
|
+
const t = n.parentElement;
|
|
2111
|
+
return t === null ? !1 : t.getAttribute("data-content-type") === "numberedListItem" ? {} : !1;
|
|
2081
2112
|
},
|
|
2082
2113
|
priority: 300,
|
|
2083
2114
|
node: "numberedListItem"
|
|
@@ -2086,14 +2117,14 @@ const ko = {
|
|
|
2086
2117
|
},
|
|
2087
2118
|
renderHTML({ HTMLAttributes: n }) {
|
|
2088
2119
|
var o, r;
|
|
2089
|
-
const
|
|
2120
|
+
const t = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, e = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
2090
2121
|
return [
|
|
2091
2122
|
"div",
|
|
2092
2123
|
N(n, {
|
|
2093
|
-
...
|
|
2124
|
+
...t,
|
|
2094
2125
|
class: S(
|
|
2095
2126
|
g.blockContent,
|
|
2096
|
-
|
|
2127
|
+
t.class
|
|
2097
2128
|
),
|
|
2098
2129
|
"data-content-type": this.name
|
|
2099
2130
|
}),
|
|
@@ -2102,19 +2133,19 @@ const ko = {
|
|
|
2102
2133
|
[
|
|
2103
2134
|
"p",
|
|
2104
2135
|
{
|
|
2105
|
-
...
|
|
2136
|
+
...e,
|
|
2106
2137
|
class: S(
|
|
2107
2138
|
g.inlineContent,
|
|
2108
|
-
|
|
2139
|
+
e.class
|
|
2109
2140
|
)
|
|
2110
2141
|
},
|
|
2111
2142
|
0
|
|
2112
2143
|
]
|
|
2113
2144
|
];
|
|
2114
2145
|
}
|
|
2115
|
-
}),
|
|
2116
|
-
node:
|
|
2117
|
-
propSchema:
|
|
2146
|
+
}), Mo = {
|
|
2147
|
+
node: To,
|
|
2148
|
+
propSchema: Bo
|
|
2118
2149
|
}, xo = {
|
|
2119
2150
|
...C
|
|
2120
2151
|
}, Io = F({
|
|
@@ -2131,15 +2162,15 @@ const ko = {
|
|
|
2131
2162
|
},
|
|
2132
2163
|
renderHTML({ HTMLAttributes: n }) {
|
|
2133
2164
|
var o, r;
|
|
2134
|
-
const
|
|
2165
|
+
const t = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, e = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
2135
2166
|
return [
|
|
2136
2167
|
"div",
|
|
2137
2168
|
N(
|
|
2138
2169
|
{
|
|
2139
|
-
...
|
|
2170
|
+
...t,
|
|
2140
2171
|
class: S(
|
|
2141
2172
|
g.blockContent,
|
|
2142
|
-
|
|
2173
|
+
t.class
|
|
2143
2174
|
),
|
|
2144
2175
|
"data-content-type": this.name
|
|
2145
2176
|
},
|
|
@@ -2148,10 +2179,10 @@ const ko = {
|
|
|
2148
2179
|
[
|
|
2149
2180
|
"p",
|
|
2150
2181
|
{
|
|
2151
|
-
...
|
|
2182
|
+
...e,
|
|
2152
2183
|
class: S(
|
|
2153
2184
|
g.inlineContent,
|
|
2154
|
-
|
|
2185
|
+
e.class
|
|
2155
2186
|
)
|
|
2156
2187
|
},
|
|
2157
2188
|
0
|
|
@@ -2163,45 +2194,45 @@ const ko = {
|
|
|
2163
2194
|
propSchema: xo
|
|
2164
2195
|
};
|
|
2165
2196
|
class _o {
|
|
2166
|
-
constructor(
|
|
2197
|
+
constructor(t, e, o) {
|
|
2167
2198
|
u(this, "imageToolbarState");
|
|
2168
2199
|
u(this, "updateImageToolbar");
|
|
2169
2200
|
u(this, "prevWasEditable", null);
|
|
2170
|
-
u(this, "shouldShow", (
|
|
2201
|
+
u(this, "shouldShow", (t) => "node" in t.selection && t.selection.node.type.name === "image" && t.selection.node.attrs.src === "");
|
|
2171
2202
|
u(this, "mouseDownHandler", () => {
|
|
2172
|
-
var
|
|
2173
|
-
(
|
|
2203
|
+
var t;
|
|
2204
|
+
(t = this.imageToolbarState) != null && t.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
2174
2205
|
});
|
|
2175
2206
|
// For dragging the whole editor.
|
|
2176
2207
|
u(this, "dragstartHandler", () => {
|
|
2177
|
-
var
|
|
2178
|
-
(
|
|
2208
|
+
var t;
|
|
2209
|
+
(t = this.imageToolbarState) != null && t.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
2179
2210
|
});
|
|
2180
|
-
u(this, "blurHandler", (
|
|
2211
|
+
u(this, "blurHandler", (t) => {
|
|
2181
2212
|
var o;
|
|
2182
|
-
const
|
|
2213
|
+
const e = this.pmView.dom.parentElement;
|
|
2183
2214
|
// An element is clicked.
|
|
2184
|
-
|
|
2185
|
-
(
|
|
2215
|
+
t && t.relatedTarget && // Element is inside the editor.
|
|
2216
|
+
(e === t.relatedTarget || e.contains(t.relatedTarget)) || (o = this.imageToolbarState) != null && o.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
2186
2217
|
});
|
|
2187
2218
|
u(this, "scrollHandler", () => {
|
|
2188
|
-
var
|
|
2189
|
-
if ((
|
|
2190
|
-
const
|
|
2219
|
+
var t;
|
|
2220
|
+
if ((t = this.imageToolbarState) != null && t.show) {
|
|
2221
|
+
const e = document.querySelector(
|
|
2191
2222
|
`[data-node-type="blockContainer"][data-id="${this.imageToolbarState.block.id}"]`
|
|
2192
2223
|
);
|
|
2193
|
-
this.imageToolbarState.referencePos =
|
|
2224
|
+
this.imageToolbarState.referencePos = e.getBoundingClientRect(), this.updateImageToolbar();
|
|
2194
2225
|
}
|
|
2195
2226
|
});
|
|
2196
|
-
this.pluginKey =
|
|
2227
|
+
this.pluginKey = t, this.pmView = e, this.updateImageToolbar = () => {
|
|
2197
2228
|
if (!this.imageToolbarState)
|
|
2198
2229
|
throw new Error("Attempting to update uninitialized image toolbar");
|
|
2199
2230
|
o(this.imageToolbarState);
|
|
2200
|
-
},
|
|
2231
|
+
}, e.dom.addEventListener("mousedown", this.mouseDownHandler), e.dom.addEventListener("dragstart", this.dragstartHandler), e.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2201
2232
|
}
|
|
2202
|
-
update(
|
|
2233
|
+
update(t, e) {
|
|
2203
2234
|
var r, i;
|
|
2204
|
-
const o = this.pluginKey.getState(
|
|
2235
|
+
const o = this.pluginKey.getState(t.state);
|
|
2205
2236
|
if (!((r = this.imageToolbarState) != null && r.show) && o.block) {
|
|
2206
2237
|
const s = document.querySelector(
|
|
2207
2238
|
`[data-node-type="blockContainer"][data-id="${o.block.id}"]`
|
|
@@ -2213,19 +2244,19 @@ class _o {
|
|
|
2213
2244
|
}, this.updateImageToolbar();
|
|
2214
2245
|
return;
|
|
2215
2246
|
}
|
|
2216
|
-
(!
|
|
2247
|
+
(!t.state.selection.eq(e.selection) || !t.state.doc.eq(e.doc)) && (i = this.imageToolbarState) != null && i.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
2217
2248
|
}
|
|
2218
2249
|
destroy() {
|
|
2219
2250
|
this.pmView.dom.removeEventListener("mousedown", this.mouseDownHandler), this.pmView.dom.removeEventListener("dragstart", this.dragstartHandler), this.pmView.dom.removeEventListener("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
|
|
2220
2251
|
}
|
|
2221
2252
|
}
|
|
2222
|
-
const z = new
|
|
2253
|
+
const z = new M("ImageToolbarPlugin");
|
|
2223
2254
|
class Ho extends U {
|
|
2224
|
-
constructor(
|
|
2255
|
+
constructor(e) {
|
|
2225
2256
|
super();
|
|
2226
2257
|
u(this, "view");
|
|
2227
2258
|
u(this, "plugin");
|
|
2228
|
-
this.plugin = new
|
|
2259
|
+
this.plugin = new B({
|
|
2229
2260
|
key: z,
|
|
2230
2261
|
view: (o) => (this.view = new _o(
|
|
2231
2262
|
// editor,
|
|
@@ -2248,8 +2279,8 @@ class Ho extends U {
|
|
|
2248
2279
|
}
|
|
2249
2280
|
});
|
|
2250
2281
|
}
|
|
2251
|
-
onUpdate(
|
|
2252
|
-
return this.on("update",
|
|
2282
|
+
onUpdate(e) {
|
|
2283
|
+
return this.on("update", e);
|
|
2253
2284
|
}
|
|
2254
2285
|
}
|
|
2255
2286
|
const Lo = {
|
|
@@ -2278,9 +2309,9 @@ const Lo = {
|
|
|
2278
2309
|
default:
|
|
2279
2310
|
return "flex-start";
|
|
2280
2311
|
}
|
|
2281
|
-
}, ut = 64, No = (n,
|
|
2282
|
-
const
|
|
2283
|
-
|
|
2312
|
+
}, ut = 64, No = (n, t) => {
|
|
2313
|
+
const e = document.createElement("div");
|
|
2314
|
+
e.className = g.wrapper, e.style.alignItems = ct(
|
|
2284
2315
|
n.props.textAlignment
|
|
2285
2316
|
);
|
|
2286
2317
|
const o = document.createElement("div");
|
|
@@ -2296,7 +2327,7 @@ const Lo = {
|
|
|
2296
2327
|
const a = document.createElement("img");
|
|
2297
2328
|
a.className = g.image, a.src = n.props.url, a.alt = "placeholder", a.contentEditable = "false", a.draggable = !1, a.style.width = `${Math.min(
|
|
2298
2329
|
n.props.width,
|
|
2299
|
-
|
|
2330
|
+
t.domElement.firstElementChild.clientWidth
|
|
2300
2331
|
)}px`;
|
|
2301
2332
|
const d = document.createElement("div");
|
|
2302
2333
|
d.className = g.resizeHandle, d.style.left = "4px";
|
|
@@ -2306,20 +2337,20 @@ const Lo = {
|
|
|
2306
2337
|
m.className = g.caption, m.innerText = n.props.caption, m.style.padding = n.props.caption ? "4px" : "";
|
|
2307
2338
|
const h = () => {
|
|
2308
2339
|
var q;
|
|
2309
|
-
const y = ((q =
|
|
2310
|
-
[
|
|
2340
|
+
const y = ((q = t.getSelection()) == null ? void 0 : q.blocks) || [];
|
|
2341
|
+
[t.getTextCursorPosition().block, ...y].find(
|
|
2311
2342
|
(Kt) => Kt.id === n.id
|
|
2312
2343
|
) !== void 0 ? (o.style.outline = "4px solid rgb(100, 160, 255)", s.style.outline = "4px solid rgb(100, 160, 255)") : (o.style.outline = "", s.style.outline = "");
|
|
2313
2344
|
};
|
|
2314
|
-
|
|
2345
|
+
t.onEditorContentChange(h), t.onEditorSelectionChange(h);
|
|
2315
2346
|
let p;
|
|
2316
2347
|
const f = (y) => {
|
|
2317
2348
|
if (!p)
|
|
2318
2349
|
return;
|
|
2319
|
-
let
|
|
2320
|
-
ct(n.props.textAlignment) === "center" ? p.handleUsed === "left" ?
|
|
2350
|
+
let T;
|
|
2351
|
+
ct(n.props.textAlignment) === "center" ? p.handleUsed === "left" ? T = p.initialWidth + (p.initialClientX - y.clientX) * 2 : T = p.initialWidth + (y.clientX - p.initialClientX) * 2 : p.handleUsed === "left" ? T = p.initialWidth + p.initialClientX - y.clientX : T = p.initialWidth + y.clientX - p.initialClientX, T < ut ? a.style.width = `${ut}px` : T > t.domElement.firstElementChild.clientWidth ? a.style.width = `${t.domElement.firstElementChild.clientWidth}px` : a.style.width = `${T}px`;
|
|
2321
2352
|
}, k = (y) => {
|
|
2322
|
-
p && ((!y.target || !l.contains(y.target)) && l.contains(d) && l.contains(c) && (d.style.display = "none", c.style.display = "none"), p = void 0,
|
|
2353
|
+
p && ((!y.target || !l.contains(y.target)) && l.contains(d) && l.contains(c) && (d.style.display = "none", c.style.display = "none"), p = void 0, t.updateBlock(n, {
|
|
2323
2354
|
type: "image",
|
|
2324
2355
|
props: {
|
|
2325
2356
|
// Removes "px" from the end of the width string and converts to float.
|
|
@@ -2329,8 +2360,8 @@ const Lo = {
|
|
|
2329
2360
|
}, v = (y) => {
|
|
2330
2361
|
y.preventDefault();
|
|
2331
2362
|
}, w = () => {
|
|
2332
|
-
|
|
2333
|
-
|
|
2363
|
+
t._tiptapEditor.view.dispatch(
|
|
2364
|
+
t._tiptapEditor.state.tr.setMeta(z, {
|
|
2334
2365
|
block: n
|
|
2335
2366
|
})
|
|
2336
2367
|
);
|
|
@@ -2347,14 +2378,14 @@ const Lo = {
|
|
|
2347
2378
|
initialClientX: y.clientX
|
|
2348
2379
|
};
|
|
2349
2380
|
};
|
|
2350
|
-
return
|
|
2381
|
+
return e.appendChild(o), o.appendChild(r), o.appendChild(i), e.appendChild(s), s.appendChild(l), l.appendChild(a), l.appendChild(d), l.appendChild(c), s.appendChild(m), window.addEventListener("mousemove", f), window.addEventListener("mouseup", k), o.addEventListener("mousedown", v), o.addEventListener("click", w), d.addEventListener(
|
|
2351
2382
|
"mousedown",
|
|
2352
2383
|
E
|
|
2353
2384
|
), c.addEventListener(
|
|
2354
2385
|
"mousedown",
|
|
2355
2386
|
_
|
|
2356
2387
|
), {
|
|
2357
|
-
dom:
|
|
2388
|
+
dom: e,
|
|
2358
2389
|
destroy: () => {
|
|
2359
2390
|
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", k), o.removeEventListener(
|
|
2360
2391
|
"mousedown",
|
|
@@ -2377,19 +2408,19 @@ const Lo = {
|
|
|
2377
2408
|
paragraph: Ao,
|
|
2378
2409
|
heading: yo,
|
|
2379
2410
|
bulletListItem: Co,
|
|
2380
|
-
numberedListItem:
|
|
2411
|
+
numberedListItem: Mo,
|
|
2381
2412
|
image: Po
|
|
2382
2413
|
};
|
|
2383
2414
|
class Do {
|
|
2384
|
-
constructor(
|
|
2415
|
+
constructor(t, e, o) {
|
|
2385
2416
|
u(this, "formattingToolbarState");
|
|
2386
2417
|
u(this, "updateFormattingToolbar");
|
|
2387
2418
|
u(this, "preventHide", !1);
|
|
2388
2419
|
u(this, "preventShow", !1);
|
|
2389
2420
|
u(this, "prevWasEditable", null);
|
|
2390
|
-
u(this, "shouldShow", ({ view:
|
|
2391
|
-
const { doc: i, selection: s } =
|
|
2392
|
-
return !(!
|
|
2421
|
+
u(this, "shouldShow", ({ view: t, state: e, from: o, to: r }) => {
|
|
2422
|
+
const { doc: i, selection: s } = e, { empty: l } = s, a = !i.textBetween(o, r).length && oe(e.selection);
|
|
2423
|
+
return !(!t.hasFocus() || l || a);
|
|
2393
2424
|
});
|
|
2394
2425
|
u(this, "viewMousedownHandler", () => {
|
|
2395
2426
|
this.preventShow = !0;
|
|
@@ -2399,43 +2430,43 @@ class Do {
|
|
|
2399
2430
|
});
|
|
2400
2431
|
// For dragging the whole editor.
|
|
2401
2432
|
u(this, "dragstartHandler", () => {
|
|
2402
|
-
var
|
|
2403
|
-
(
|
|
2433
|
+
var t;
|
|
2434
|
+
(t = this.formattingToolbarState) != null && t.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2404
2435
|
});
|
|
2405
2436
|
u(this, "focusHandler", () => {
|
|
2406
2437
|
setTimeout(() => this.update(this.pmView));
|
|
2407
2438
|
});
|
|
2408
|
-
u(this, "blurHandler", (
|
|
2439
|
+
u(this, "blurHandler", (t) => {
|
|
2409
2440
|
var o;
|
|
2410
2441
|
if (this.preventHide) {
|
|
2411
2442
|
this.preventHide = !1;
|
|
2412
2443
|
return;
|
|
2413
2444
|
}
|
|
2414
|
-
const
|
|
2445
|
+
const e = this.pmView.dom.parentElement;
|
|
2415
2446
|
// An element is clicked.
|
|
2416
|
-
|
|
2417
|
-
(
|
|
2447
|
+
t && t.relatedTarget && // Element is inside the editor.
|
|
2448
|
+
(e === t.relatedTarget || e.contains(t.relatedTarget)) || (o = this.formattingToolbarState) != null && o.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2418
2449
|
});
|
|
2419
2450
|
u(this, "scrollHandler", () => {
|
|
2420
|
-
var
|
|
2421
|
-
(
|
|
2451
|
+
var t;
|
|
2452
|
+
(t = this.formattingToolbarState) != null && t.show && (this.formattingToolbarState.referencePos = this.getSelectionBoundingBox(), this.updateFormattingToolbar());
|
|
2422
2453
|
});
|
|
2423
|
-
this.editor =
|
|
2454
|
+
this.editor = t, this.pmView = e, this.updateFormattingToolbar = () => {
|
|
2424
2455
|
if (!this.formattingToolbarState)
|
|
2425
2456
|
throw new Error(
|
|
2426
2457
|
"Attempting to update uninitialized formatting toolbar"
|
|
2427
2458
|
);
|
|
2428
2459
|
o(this.formattingToolbarState);
|
|
2429
|
-
},
|
|
2460
|
+
}, e.dom.addEventListener("mousedown", this.viewMousedownHandler), e.dom.addEventListener("mouseup", this.viewMouseupHandler), e.dom.addEventListener("dragstart", this.dragstartHandler), e.dom.addEventListener("focus", this.focusHandler), e.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2430
2461
|
}
|
|
2431
|
-
update(
|
|
2462
|
+
update(t, e) {
|
|
2432
2463
|
var h, p;
|
|
2433
|
-
const { state: o, composing: r } =
|
|
2464
|
+
const { state: o, composing: r } = t, { doc: i, selection: s } = o, l = e && e.doc.eq(i) && e.selection.eq(s);
|
|
2434
2465
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
|
|
2435
2466
|
return;
|
|
2436
2467
|
this.prevWasEditable = this.editor.isEditable;
|
|
2437
2468
|
const { ranges: a } = s, d = Math.min(...a.map((f) => f.$from.pos)), c = Math.max(...a.map((f) => f.$to.pos)), m = (h = this.shouldShow) == null ? void 0 : h.call(this, {
|
|
2438
|
-
view:
|
|
2469
|
+
view: t,
|
|
2439
2470
|
state: o,
|
|
2440
2471
|
from: d,
|
|
2441
2472
|
to: c
|
|
@@ -2456,8 +2487,8 @@ class Do {
|
|
|
2456
2487
|
this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.dom.removeEventListener("mouseup", this.viewMouseupHandler), this.pmView.dom.removeEventListener("dragstart", this.dragstartHandler), this.pmView.dom.removeEventListener("focus", this.focusHandler), this.pmView.dom.removeEventListener("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
|
|
2457
2488
|
}
|
|
2458
2489
|
getSelectionBoundingBox() {
|
|
2459
|
-
const { state:
|
|
2460
|
-
if (ne(
|
|
2490
|
+
const { state: t } = this.pmView, { selection: e } = t, { ranges: o } = e, r = Math.min(...o.map((s) => s.$from.pos)), i = Math.max(...o.map((s) => s.$to.pos));
|
|
2491
|
+
if (ne(e)) {
|
|
2461
2492
|
const s = this.pmView.nodeDOM(r);
|
|
2462
2493
|
if (s)
|
|
2463
2494
|
return s.getBoundingClientRect();
|
|
@@ -2465,27 +2496,27 @@ class Do {
|
|
|
2465
2496
|
return K(this.pmView, r, i);
|
|
2466
2497
|
}
|
|
2467
2498
|
}
|
|
2468
|
-
const Oo = new
|
|
2499
|
+
const Oo = new M(
|
|
2469
2500
|
"FormattingToolbarPlugin"
|
|
2470
2501
|
);
|
|
2471
2502
|
class Ro extends U {
|
|
2472
|
-
constructor(
|
|
2503
|
+
constructor(e) {
|
|
2473
2504
|
super();
|
|
2474
2505
|
u(this, "view");
|
|
2475
2506
|
u(this, "plugin");
|
|
2476
|
-
this.plugin = new
|
|
2507
|
+
this.plugin = new B({
|
|
2477
2508
|
key: Oo,
|
|
2478
|
-
view: (o) => (this.view = new Do(
|
|
2509
|
+
view: (o) => (this.view = new Do(e, o, (r) => {
|
|
2479
2510
|
this.emit("update", r);
|
|
2480
2511
|
}), this.view)
|
|
2481
2512
|
});
|
|
2482
2513
|
}
|
|
2483
|
-
onUpdate(
|
|
2484
|
-
return this.on("update",
|
|
2514
|
+
onUpdate(e) {
|
|
2515
|
+
return this.on("update", e);
|
|
2485
2516
|
}
|
|
2486
2517
|
}
|
|
2487
2518
|
class zo {
|
|
2488
|
-
constructor(
|
|
2519
|
+
constructor(t, e, o) {
|
|
2489
2520
|
u(this, "hyperlinkToolbarState");
|
|
2490
2521
|
u(this, "updateHyperlinkToolbar");
|
|
2491
2522
|
u(this, "menuUpdateTimer");
|
|
@@ -2497,9 +2528,9 @@ class zo {
|
|
|
2497
2528
|
u(this, "keyboardHoveredHyperlinkMarkRange");
|
|
2498
2529
|
u(this, "hyperlinkMark");
|
|
2499
2530
|
u(this, "hyperlinkMarkRange");
|
|
2500
|
-
u(this, "mouseOverHandler", (
|
|
2501
|
-
if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(),
|
|
2502
|
-
const
|
|
2531
|
+
u(this, "mouseOverHandler", (t) => {
|
|
2532
|
+
if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), t.target instanceof HTMLAnchorElement && t.target.nodeName === "A") {
|
|
2533
|
+
const e = t.target, o = this.pmView.posAtDOM(e, 0) + 1, r = this.pmView.state.doc.resolve(
|
|
2503
2534
|
o
|
|
2504
2535
|
), i = r.marks();
|
|
2505
2536
|
for (const s of i)
|
|
@@ -2514,23 +2545,23 @@ class zo {
|
|
|
2514
2545
|
}
|
|
2515
2546
|
return this.startMenuUpdateTimer(), !1;
|
|
2516
2547
|
});
|
|
2517
|
-
u(this, "clickHandler", (
|
|
2548
|
+
u(this, "clickHandler", (t) => {
|
|
2518
2549
|
var o;
|
|
2519
|
-
const
|
|
2550
|
+
const e = this.pmView.dom.parentElement;
|
|
2520
2551
|
// Toolbar is open.
|
|
2521
2552
|
this.hyperlinkMark && // An element is clicked.
|
|
2522
|
-
|
|
2523
|
-
!(
|
|
2553
|
+
t && t.target && // The clicked element is not the editor.
|
|
2554
|
+
!(e === t.target || e.contains(t.target)) && (o = this.hyperlinkToolbarState) != null && o.show && (this.hyperlinkToolbarState.show = !1, this.updateHyperlinkToolbar());
|
|
2524
2555
|
});
|
|
2525
2556
|
u(this, "scrollHandler", () => {
|
|
2526
|
-
var
|
|
2527
|
-
this.hyperlinkMark !== void 0 && (
|
|
2557
|
+
var t;
|
|
2558
|
+
this.hyperlinkMark !== void 0 && (t = this.hyperlinkToolbarState) != null && t.show && (this.hyperlinkToolbarState.referencePos = K(
|
|
2528
2559
|
this.pmView,
|
|
2529
2560
|
this.hyperlinkMarkRange.from,
|
|
2530
2561
|
this.hyperlinkMarkRange.to
|
|
2531
2562
|
), this.updateHyperlinkToolbar());
|
|
2532
2563
|
});
|
|
2533
|
-
this.editor =
|
|
2564
|
+
this.editor = t, this.pmView = e, this.updateHyperlinkToolbar = () => {
|
|
2534
2565
|
if (!this.hyperlinkToolbarState)
|
|
2535
2566
|
throw new Error("Attempting to update uninitialized hyperlink toolbar");
|
|
2536
2567
|
o(this.hyperlinkToolbarState);
|
|
@@ -2540,34 +2571,34 @@ class zo {
|
|
|
2540
2571
|
}, 250);
|
|
2541
2572
|
}, this.stopMenuUpdateTimer = () => (this.menuUpdateTimer && (clearTimeout(this.menuUpdateTimer), this.menuUpdateTimer = void 0), !1), this.pmView.dom.addEventListener("mouseover", this.mouseOverHandler), document.addEventListener("click", this.clickHandler, !0), document.addEventListener("scroll", this.scrollHandler);
|
|
2542
2573
|
}
|
|
2543
|
-
editHyperlink(
|
|
2574
|
+
editHyperlink(t, e) {
|
|
2544
2575
|
var r;
|
|
2545
2576
|
const o = this.pmView.state.tr.insertText(
|
|
2546
|
-
|
|
2577
|
+
e,
|
|
2547
2578
|
this.hyperlinkMarkRange.from,
|
|
2548
2579
|
this.hyperlinkMarkRange.to
|
|
2549
2580
|
);
|
|
2550
2581
|
o.addMark(
|
|
2551
2582
|
this.hyperlinkMarkRange.from,
|
|
2552
|
-
this.hyperlinkMarkRange.from +
|
|
2553
|
-
this.pmView.state.schema.mark("link", { href:
|
|
2583
|
+
this.hyperlinkMarkRange.from + e.length,
|
|
2584
|
+
this.pmView.state.schema.mark("link", { href: t })
|
|
2554
2585
|
), this.pmView.dispatch(o), this.pmView.focus(), (r = this.hyperlinkToolbarState) != null && r.show && (this.hyperlinkToolbarState.show = !1, this.updateHyperlinkToolbar());
|
|
2555
2586
|
}
|
|
2556
2587
|
deleteHyperlink() {
|
|
2557
|
-
var
|
|
2588
|
+
var t;
|
|
2558
2589
|
this.pmView.dispatch(
|
|
2559
2590
|
this.pmView.state.tr.removeMark(
|
|
2560
2591
|
this.hyperlinkMarkRange.from,
|
|
2561
2592
|
this.hyperlinkMarkRange.to,
|
|
2562
2593
|
this.hyperlinkMark.type
|
|
2563
2594
|
).setMeta("preventAutolink", !0)
|
|
2564
|
-
), this.pmView.focus(), (
|
|
2595
|
+
), this.pmView.focus(), (t = this.hyperlinkToolbarState) != null && t.show && (this.hyperlinkToolbarState.show = !1, this.updateHyperlinkToolbar());
|
|
2565
2596
|
}
|
|
2566
2597
|
update() {
|
|
2567
|
-
var
|
|
2598
|
+
var e;
|
|
2568
2599
|
if (!this.pmView.hasFocus())
|
|
2569
2600
|
return;
|
|
2570
|
-
const
|
|
2601
|
+
const t = this.hyperlinkMark;
|
|
2571
2602
|
if (this.hyperlinkMark = void 0, this.hyperlinkMarkRange = void 0, this.keyboardHoveredHyperlinkMark = void 0, this.keyboardHoveredHyperlinkMarkRange = void 0, this.pmView.state.selection.empty) {
|
|
2572
2603
|
const o = this.pmView.state.selection.$from.marks();
|
|
2573
2604
|
for (const r of o)
|
|
@@ -2596,7 +2627,7 @@ class zo {
|
|
|
2596
2627
|
}, this.updateHyperlinkToolbar();
|
|
2597
2628
|
return;
|
|
2598
2629
|
}
|
|
2599
|
-
if ((
|
|
2630
|
+
if ((e = this.hyperlinkToolbarState) != null && e.show && t && (!this.hyperlinkMark || !this.editor.isEditable)) {
|
|
2600
2631
|
this.hyperlinkToolbarState.show = !1, this.updateHyperlinkToolbar();
|
|
2601
2632
|
return;
|
|
2602
2633
|
}
|
|
@@ -2605,19 +2636,19 @@ class zo {
|
|
|
2605
2636
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2606
2637
|
}
|
|
2607
2638
|
}
|
|
2608
|
-
const Vo = new
|
|
2639
|
+
const Vo = new M(
|
|
2609
2640
|
"HyperlinkToolbarPlugin"
|
|
2610
2641
|
);
|
|
2611
2642
|
class Uo extends U {
|
|
2612
|
-
constructor(
|
|
2643
|
+
constructor(e) {
|
|
2613
2644
|
super();
|
|
2614
2645
|
u(this, "view");
|
|
2615
2646
|
u(this, "plugin");
|
|
2616
2647
|
/**
|
|
2617
2648
|
* Edit the currently hovered hyperlink.
|
|
2618
2649
|
*/
|
|
2619
|
-
u(this, "editHyperlink", (
|
|
2620
|
-
this.view.editHyperlink(
|
|
2650
|
+
u(this, "editHyperlink", (e, o) => {
|
|
2651
|
+
this.view.editHyperlink(e, o);
|
|
2621
2652
|
});
|
|
2622
2653
|
/**
|
|
2623
2654
|
* Delete the currently hovered hyperlink.
|
|
@@ -2643,46 +2674,46 @@ class Uo extends U {
|
|
|
2643
2674
|
u(this, "stopHideTimer", () => {
|
|
2644
2675
|
this.view.stopMenuUpdateTimer();
|
|
2645
2676
|
});
|
|
2646
|
-
this.plugin = new
|
|
2677
|
+
this.plugin = new B({
|
|
2647
2678
|
key: Vo,
|
|
2648
|
-
view: (o) => (this.view = new zo(
|
|
2679
|
+
view: (o) => (this.view = new zo(e, o, (r) => {
|
|
2649
2680
|
this.emit("update", r);
|
|
2650
2681
|
}), this.view)
|
|
2651
2682
|
});
|
|
2652
2683
|
}
|
|
2653
|
-
onUpdate(
|
|
2654
|
-
return this.on("update",
|
|
2684
|
+
onUpdate(e) {
|
|
2685
|
+
return this.on("update", e);
|
|
2655
2686
|
}
|
|
2656
2687
|
}
|
|
2657
2688
|
class O extends X {
|
|
2658
|
-
constructor(
|
|
2659
|
-
super(
|
|
2689
|
+
constructor(e, o) {
|
|
2690
|
+
super(e, o);
|
|
2660
2691
|
u(this, "nodes");
|
|
2661
|
-
const r =
|
|
2662
|
-
this.nodes = [],
|
|
2692
|
+
const r = e.node();
|
|
2693
|
+
this.nodes = [], e.doc.nodesBetween(e.pos, o.pos, (i, s, l) => {
|
|
2663
2694
|
if (l !== null && l.eq(r))
|
|
2664
2695
|
return this.nodes.push(i), !1;
|
|
2665
2696
|
});
|
|
2666
2697
|
}
|
|
2667
|
-
static create(
|
|
2668
|
-
return new O(
|
|
2698
|
+
static create(e, o, r = o) {
|
|
2699
|
+
return new O(e.resolve(o), e.resolve(r));
|
|
2669
2700
|
}
|
|
2670
2701
|
content() {
|
|
2671
2702
|
return new L(P.from(this.nodes), 0, 0);
|
|
2672
2703
|
}
|
|
2673
|
-
eq(
|
|
2674
|
-
if (!(
|
|
2704
|
+
eq(e) {
|
|
2705
|
+
if (!(e instanceof O) || this.nodes.length !== e.nodes.length || this.from !== e.from || this.to !== e.to)
|
|
2675
2706
|
return !1;
|
|
2676
2707
|
for (let o = 0; o < this.nodes.length; o++)
|
|
2677
|
-
if (!this.nodes[o].eq(
|
|
2708
|
+
if (!this.nodes[o].eq(e.nodes[o]))
|
|
2678
2709
|
return !1;
|
|
2679
2710
|
return !0;
|
|
2680
2711
|
}
|
|
2681
|
-
map(
|
|
2712
|
+
map(e, o) {
|
|
2682
2713
|
const r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2683
|
-
return i.deleted ? X.near(
|
|
2684
|
-
|
|
2685
|
-
|
|
2714
|
+
return i.deleted ? X.near(e.resolve(r.pos)) : r.deleted ? X.near(e.resolve(i.pos)) : new O(
|
|
2715
|
+
e.resolve(r.pos),
|
|
2716
|
+
e.resolve(i.pos)
|
|
2686
2717
|
);
|
|
2687
2718
|
}
|
|
2688
2719
|
toJSON() {
|
|
@@ -2691,49 +2722,49 @@ class O extends X {
|
|
|
2691
2722
|
}
|
|
2692
2723
|
const Fo = ve.__serializeForClipboard;
|
|
2693
2724
|
let I;
|
|
2694
|
-
function qt(n,
|
|
2725
|
+
function qt(n, t) {
|
|
2695
2726
|
var r;
|
|
2696
|
-
if (!
|
|
2727
|
+
if (!t.dom.isConnected)
|
|
2697
2728
|
return;
|
|
2698
|
-
const
|
|
2699
|
-
if (!
|
|
2729
|
+
const e = t.posAtCoords(n);
|
|
2730
|
+
if (!e)
|
|
2700
2731
|
return;
|
|
2701
|
-
let o =
|
|
2702
|
-
if (o !==
|
|
2703
|
-
for (; o && o.parentNode && o.parentNode !==
|
|
2732
|
+
let o = t.domAtPos(e.pos).node;
|
|
2733
|
+
if (o !== t.dom) {
|
|
2734
|
+
for (; o && o.parentNode && o.parentNode !== t.dom && !((r = o.hasAttribute) != null && r.call(o, "data-id")); )
|
|
2704
2735
|
o = o.parentNode;
|
|
2705
2736
|
if (o)
|
|
2706
2737
|
return { node: o, id: o.getAttribute("data-id") };
|
|
2707
2738
|
}
|
|
2708
2739
|
}
|
|
2709
|
-
function
|
|
2710
|
-
const
|
|
2711
|
-
if (
|
|
2712
|
-
const o =
|
|
2740
|
+
function $o(n, t) {
|
|
2741
|
+
const e = qt(n, t);
|
|
2742
|
+
if (e && e.node.nodeType === 1) {
|
|
2743
|
+
const o = t.docView, r = o.nearestDesc(e.node, !0);
|
|
2713
2744
|
return !r || r === o ? null : r.posBefore;
|
|
2714
2745
|
}
|
|
2715
2746
|
return null;
|
|
2716
2747
|
}
|
|
2717
|
-
function
|
|
2718
|
-
let
|
|
2719
|
-
const r =
|
|
2748
|
+
function Wo(n, t) {
|
|
2749
|
+
let e, o;
|
|
2750
|
+
const r = t.resolve(n.from).node().type.spec.group === "blockContent", i = t.resolve(n.to).node().type.spec.group === "blockContent", s = Math.min(n.$anchor.depth, n.$head.depth);
|
|
2720
2751
|
if (r && i) {
|
|
2721
2752
|
const l = n.$from.start(s - 1), a = n.$to.end(s - 1);
|
|
2722
|
-
|
|
2753
|
+
e = t.resolve(l - 1).pos, o = t.resolve(a + 1).pos;
|
|
2723
2754
|
} else
|
|
2724
|
-
|
|
2725
|
-
return { from:
|
|
2755
|
+
e = n.from, o = n.to;
|
|
2756
|
+
return { from: e, to: o };
|
|
2726
2757
|
}
|
|
2727
|
-
function pt(n,
|
|
2728
|
-
|
|
2729
|
-
const o = n.domAtPos(
|
|
2758
|
+
function pt(n, t, e = t) {
|
|
2759
|
+
t === e && (e += n.state.doc.resolve(t + 1).node().nodeSize);
|
|
2760
|
+
const o = n.domAtPos(t).node.cloneNode(!0), r = n.domAtPos(t).node, i = (c, m) => Array.prototype.indexOf.call(c.children, m), s = i(
|
|
2730
2761
|
r,
|
|
2731
2762
|
// Expects from position to be just before the first selected block.
|
|
2732
|
-
n.domAtPos(
|
|
2763
|
+
n.domAtPos(t + 1).node.parentElement
|
|
2733
2764
|
), l = i(
|
|
2734
2765
|
r,
|
|
2735
2766
|
// Expects to position to be just after the last selected block.
|
|
2736
|
-
n.domAtPos(
|
|
2767
|
+
n.domAtPos(e - 1).node.parentElement
|
|
2737
2768
|
);
|
|
2738
2769
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
2739
2770
|
(c > l || c < s) && o.removeChild(o.children[c]);
|
|
@@ -2746,27 +2777,27 @@ function pt(n, e, t = e) {
|
|
|
2746
2777
|
function Xt() {
|
|
2747
2778
|
I !== void 0 && (document.body.removeChild(I), I = void 0);
|
|
2748
2779
|
}
|
|
2749
|
-
function Go(n,
|
|
2780
|
+
function Go(n, t) {
|
|
2750
2781
|
if (!n.dataTransfer)
|
|
2751
2782
|
return;
|
|
2752
|
-
const
|
|
2753
|
-
left:
|
|
2783
|
+
const e = t.dom.getBoundingClientRect(), o = {
|
|
2784
|
+
left: e.left + e.width / 2,
|
|
2754
2785
|
// take middle of editor
|
|
2755
2786
|
top: n.clientY
|
|
2756
|
-
}, r =
|
|
2787
|
+
}, r = $o(o, t);
|
|
2757
2788
|
if (r != null) {
|
|
2758
|
-
const i =
|
|
2759
|
-
d && c ? (
|
|
2760
|
-
|
|
2761
|
-
), pt(
|
|
2762
|
-
|
|
2763
|
-
), pt(
|
|
2764
|
-
const m =
|
|
2765
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", h.innerHTML), n.dataTransfer.setData("text/plain", p), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(I, 0, 0),
|
|
2789
|
+
const i = t.state.selection, s = t.state.doc, { from: l, to: a } = Wo(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof O;
|
|
2790
|
+
d && c ? (t.dispatch(
|
|
2791
|
+
t.state.tr.setSelection(O.create(s, l, a))
|
|
2792
|
+
), pt(t, l, a)) : (t.dispatch(
|
|
2793
|
+
t.state.tr.setSelection(mt.create(t.state.doc, r))
|
|
2794
|
+
), pt(t, r));
|
|
2795
|
+
const m = t.state.selection.content(), { dom: h, text: p } = Fo(t, m);
|
|
2796
|
+
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", h.innerHTML), n.dataTransfer.setData("text/plain", p), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(I, 0, 0), t.dragging = { slice: m, move: !0 };
|
|
2766
2797
|
}
|
|
2767
2798
|
}
|
|
2768
2799
|
class jo {
|
|
2769
|
-
constructor(
|
|
2800
|
+
constructor(t, e, o) {
|
|
2770
2801
|
u(this, "sideMenuState");
|
|
2771
2802
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
2772
2803
|
// When false, the drag handle with be just to the left of the element
|
|
@@ -2788,16 +2819,16 @@ class jo {
|
|
|
2788
2819
|
* we dispatch a fake event, so that we can still drop the content
|
|
2789
2820
|
* when dragging / dropping to the side of the editor
|
|
2790
2821
|
*/
|
|
2791
|
-
u(this, "onDrop", (
|
|
2792
|
-
if (this.editor._tiptapEditor.commands.blur(),
|
|
2822
|
+
u(this, "onDrop", (t) => {
|
|
2823
|
+
if (this.editor._tiptapEditor.commands.blur(), t.synthetic || !this.isDragging)
|
|
2793
2824
|
return;
|
|
2794
|
-
const
|
|
2795
|
-
left:
|
|
2796
|
-
top:
|
|
2825
|
+
const e = this.pmView.posAtCoords({
|
|
2826
|
+
left: t.clientX,
|
|
2827
|
+
top: t.clientY
|
|
2797
2828
|
});
|
|
2798
|
-
if (this.isDragging = !1, !
|
|
2799
|
-
const o = new Event("drop",
|
|
2800
|
-
o.clientX = r.left + r.width / 2, o.clientY =
|
|
2829
|
+
if (this.isDragging = !1, !e || e.inside === -1) {
|
|
2830
|
+
const o = new Event("drop", t), r = this.pmView.dom.firstChild.getBoundingClientRect();
|
|
2831
|
+
o.clientX = r.left + r.width / 2, o.clientY = t.clientY, o.dataTransfer = t.dataTransfer, o.preventDefault = () => t.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
|
|
2801
2832
|
}
|
|
2802
2833
|
});
|
|
2803
2834
|
/**
|
|
@@ -2805,41 +2836,41 @@ class jo {
|
|
|
2805
2836
|
* we dispatch a fake event, so that we can still drop the content
|
|
2806
2837
|
* when dragging / dropping to the side of the editor
|
|
2807
2838
|
*/
|
|
2808
|
-
u(this, "onDragOver", (
|
|
2809
|
-
if (
|
|
2839
|
+
u(this, "onDragOver", (t) => {
|
|
2840
|
+
if (t.synthetic || !this.isDragging)
|
|
2810
2841
|
return;
|
|
2811
|
-
const
|
|
2812
|
-
left:
|
|
2813
|
-
top:
|
|
2842
|
+
const e = this.pmView.posAtCoords({
|
|
2843
|
+
left: t.clientX,
|
|
2844
|
+
top: t.clientY
|
|
2814
2845
|
});
|
|
2815
|
-
if (!
|
|
2816
|
-
const o = new Event("dragover",
|
|
2817
|
-
o.clientX = r.left + r.width / 2, o.clientY =
|
|
2846
|
+
if (!e || e.inside === -1) {
|
|
2847
|
+
const o = new Event("dragover", t), r = this.pmView.dom.firstChild.getBoundingClientRect();
|
|
2848
|
+
o.clientX = r.left + r.width / 2, o.clientY = t.clientY, o.dataTransfer = t.dataTransfer, o.preventDefault = () => t.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
|
|
2818
2849
|
}
|
|
2819
2850
|
});
|
|
2820
|
-
u(this, "onKeyDown", (
|
|
2821
|
-
var
|
|
2822
|
-
(
|
|
2851
|
+
u(this, "onKeyDown", (t) => {
|
|
2852
|
+
var e;
|
|
2853
|
+
(e = this.sideMenuState) != null && e.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2823
2854
|
});
|
|
2824
|
-
u(this, "onMouseMove", (
|
|
2855
|
+
u(this, "onMouseMove", (t) => {
|
|
2825
2856
|
var d, c, m, h, p;
|
|
2826
2857
|
if (this.menuFrozen)
|
|
2827
2858
|
return;
|
|
2828
|
-
const
|
|
2859
|
+
const e = this.pmView.dom.firstChild.getBoundingClientRect(), o = this.pmView.dom.getBoundingClientRect(), r = t.clientX >= o.left && t.clientX <= o.right && t.clientY >= o.top && t.clientY <= o.bottom, i = this.pmView.dom.parentElement;
|
|
2829
2860
|
if (
|
|
2830
2861
|
// Cursor is within the editor area
|
|
2831
2862
|
r && // An element is hovered
|
|
2832
|
-
|
|
2833
|
-
!(i ===
|
|
2863
|
+
t && t.target && // Element is outside the editor
|
|
2864
|
+
!(i === t.target || i.contains(t.target))
|
|
2834
2865
|
) {
|
|
2835
2866
|
(d = this.sideMenuState) != null && d.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2836
2867
|
return;
|
|
2837
2868
|
}
|
|
2838
|
-
this.horizontalPosAnchor =
|
|
2869
|
+
this.horizontalPosAnchor = e.x;
|
|
2839
2870
|
const s = {
|
|
2840
|
-
left:
|
|
2871
|
+
left: e.left + e.width / 2,
|
|
2841
2872
|
// take middle of editor
|
|
2842
|
-
top:
|
|
2873
|
+
top: t.clientY
|
|
2843
2874
|
}, l = qt(s, this.pmView);
|
|
2844
2875
|
if (!l || !this.editor.isEditable) {
|
|
2845
2876
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
@@ -2866,8 +2897,8 @@ class jo {
|
|
|
2866
2897
|
}
|
|
2867
2898
|
});
|
|
2868
2899
|
u(this, "onScroll", () => {
|
|
2869
|
-
var
|
|
2870
|
-
if ((
|
|
2900
|
+
var t;
|
|
2901
|
+
if ((t = this.sideMenuState) != null && t.show) {
|
|
2871
2902
|
const o = this.hoveredBlock.firstChild.getBoundingClientRect();
|
|
2872
2903
|
this.sideMenuState.referencePos = new DOMRect(
|
|
2873
2904
|
this.horizontalPosAnchoredAtRoot ? this.horizontalPosAnchor : o.x,
|
|
@@ -2877,18 +2908,18 @@ class jo {
|
|
|
2877
2908
|
), this.updateSideMenu(this.sideMenuState);
|
|
2878
2909
|
}
|
|
2879
2910
|
});
|
|
2880
|
-
this.editor =
|
|
2911
|
+
this.editor = t, this.pmView = e, this.updateSideMenu = o, this.horizontalPosAnchoredAtRoot = !0, this.horizontalPosAnchor = this.pmView.dom.firstChild.getBoundingClientRect().x, document.body.addEventListener("drop", this.onDrop, !0), document.body.addEventListener("dragover", this.onDragOver), this.pmView.dom.addEventListener("dragstart", this.onDragStart), document.body.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("scroll", this.onScroll), document.body.addEventListener("keydown", this.onKeyDown, !0);
|
|
2881
2912
|
}
|
|
2882
2913
|
destroy() {
|
|
2883
|
-
var
|
|
2884
|
-
(
|
|
2914
|
+
var t;
|
|
2915
|
+
(t = this.sideMenuState) != null && t.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), document.body.removeEventListener("mousemove", this.onMouseMove), document.body.removeEventListener("dragover", this.onDragOver), this.pmView.dom.removeEventListener("dragstart", this.onDragStart), document.body.removeEventListener("drop", this.onDrop, !0), document.removeEventListener("scroll", this.onScroll), document.body.removeEventListener("keydown", this.onKeyDown, !0);
|
|
2885
2916
|
}
|
|
2886
2917
|
addBlock() {
|
|
2887
2918
|
var l;
|
|
2888
2919
|
(l = this.sideMenuState) != null && l.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !0;
|
|
2889
|
-
const
|
|
2890
|
-
left:
|
|
2891
|
-
top:
|
|
2920
|
+
const e = this.hoveredBlock.firstChild.getBoundingClientRect(), o = this.pmView.posAtCoords({
|
|
2921
|
+
left: e.left + e.width / 2,
|
|
2922
|
+
top: e.top + e.height / 2
|
|
2892
2923
|
});
|
|
2893
2924
|
if (!o)
|
|
2894
2925
|
return;
|
|
@@ -2913,9 +2944,9 @@ class jo {
|
|
|
2913
2944
|
);
|
|
2914
2945
|
}
|
|
2915
2946
|
}
|
|
2916
|
-
const qo = new
|
|
2947
|
+
const qo = new M("SideMenuPlugin");
|
|
2917
2948
|
class Xo extends U {
|
|
2918
|
-
constructor(
|
|
2949
|
+
constructor(e) {
|
|
2919
2950
|
super();
|
|
2920
2951
|
u(this, "sideMenuView");
|
|
2921
2952
|
u(this, "plugin");
|
|
@@ -2927,8 +2958,8 @@ class Xo extends U {
|
|
|
2927
2958
|
/**
|
|
2928
2959
|
* Handles drag & drop events for blocks.
|
|
2929
2960
|
*/
|
|
2930
|
-
u(this, "blockDragStart", (
|
|
2931
|
-
this.sideMenuView.isDragging = !0, Go(
|
|
2961
|
+
u(this, "blockDragStart", (e) => {
|
|
2962
|
+
this.sideMenuView.isDragging = !0, Go(e, this.editor.prosemirrorView);
|
|
2932
2963
|
});
|
|
2933
2964
|
/**
|
|
2934
2965
|
* Handles drag & drop events for blocks.
|
|
@@ -2946,10 +2977,10 @@ class Xo extends U {
|
|
|
2946
2977
|
* mouse cursor.
|
|
2947
2978
|
*/
|
|
2948
2979
|
u(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2949
|
-
this.editor =
|
|
2980
|
+
this.editor = e, this.plugin = new B({
|
|
2950
2981
|
key: qo,
|
|
2951
2982
|
view: (o) => (this.sideMenuView = new jo(
|
|
2952
|
-
|
|
2983
|
+
e,
|
|
2953
2984
|
o,
|
|
2954
2985
|
(r) => {
|
|
2955
2986
|
this.emit("update", r);
|
|
@@ -2957,61 +2988,61 @@ class Xo extends U {
|
|
|
2957
2988
|
), this.sideMenuView)
|
|
2958
2989
|
});
|
|
2959
2990
|
}
|
|
2960
|
-
onUpdate(
|
|
2961
|
-
return this.on("update",
|
|
2991
|
+
onUpdate(e) {
|
|
2992
|
+
return this.on("update", e);
|
|
2962
2993
|
}
|
|
2963
2994
|
}
|
|
2964
|
-
function H(n,
|
|
2965
|
-
const
|
|
2966
|
-
if (
|
|
2995
|
+
function H(n, t) {
|
|
2996
|
+
const e = n.getTextCursorPosition().block;
|
|
2997
|
+
if (e.content === void 0)
|
|
2967
2998
|
throw new Error(
|
|
2968
2999
|
"Slash Menu open in a block that doesn't contain inline content."
|
|
2969
3000
|
);
|
|
2970
|
-
|
|
3001
|
+
e.content.length === 1 && e.content[0].type === "text" && e.content[0].text === "/" || e.content.length === 0 ? n.updateBlock(e, t) : (n.insertBlocks([t], e, "after"), n.setTextCursorPosition(n.getTextCursorPosition().nextBlock));
|
|
2971
3002
|
}
|
|
2972
3003
|
const Ko = (n = jt) => {
|
|
2973
|
-
var
|
|
2974
|
-
const
|
|
2975
|
-
return "heading" in n && "level" in n.heading.propSchema && ((
|
|
3004
|
+
var e, o, r;
|
|
3005
|
+
const t = [];
|
|
3006
|
+
return "heading" in n && "level" in n.heading.propSchema && ((e = n.heading.propSchema.level.values) != null && e.includes(1) && t.push({
|
|
2976
3007
|
name: "Heading",
|
|
2977
3008
|
aliases: ["h", "heading1", "h1"],
|
|
2978
3009
|
execute: (i) => H(i, {
|
|
2979
3010
|
type: "heading",
|
|
2980
3011
|
props: { level: 1 }
|
|
2981
3012
|
})
|
|
2982
|
-
}), (o = n.heading.propSchema.level.values) != null && o.includes(2) &&
|
|
3013
|
+
}), (o = n.heading.propSchema.level.values) != null && o.includes(2) && t.push({
|
|
2983
3014
|
name: "Heading 2",
|
|
2984
3015
|
aliases: ["h2", "heading2", "subheading"],
|
|
2985
3016
|
execute: (i) => H(i, {
|
|
2986
3017
|
type: "heading",
|
|
2987
3018
|
props: { level: 2 }
|
|
2988
3019
|
})
|
|
2989
|
-
}), (r = n.heading.propSchema.level.values) != null && r.includes(3) &&
|
|
3020
|
+
}), (r = n.heading.propSchema.level.values) != null && r.includes(3) && t.push({
|
|
2990
3021
|
name: "Heading 3",
|
|
2991
3022
|
aliases: ["h3", "heading3", "subheading"],
|
|
2992
3023
|
execute: (i) => H(i, {
|
|
2993
3024
|
type: "heading",
|
|
2994
3025
|
props: { level: 3 }
|
|
2995
3026
|
})
|
|
2996
|
-
})), "bulletListItem" in n &&
|
|
3027
|
+
})), "bulletListItem" in n && t.push({
|
|
2997
3028
|
name: "Bullet List",
|
|
2998
3029
|
aliases: ["ul", "list", "bulletlist", "bullet list"],
|
|
2999
3030
|
execute: (i) => H(i, {
|
|
3000
3031
|
type: "bulletListItem"
|
|
3001
3032
|
})
|
|
3002
|
-
}), "numberedListItem" in n &&
|
|
3033
|
+
}), "numberedListItem" in n && t.push({
|
|
3003
3034
|
name: "Numbered List",
|
|
3004
3035
|
aliases: ["li", "list", "numberedlist", "numbered list"],
|
|
3005
3036
|
execute: (i) => H(i, {
|
|
3006
3037
|
type: "numberedListItem"
|
|
3007
3038
|
})
|
|
3008
|
-
}), "paragraph" in n &&
|
|
3039
|
+
}), "paragraph" in n && t.push({
|
|
3009
3040
|
name: "Paragraph",
|
|
3010
3041
|
aliases: ["p"],
|
|
3011
3042
|
execute: (i) => H(i, {
|
|
3012
3043
|
type: "paragraph"
|
|
3013
3044
|
})
|
|
3014
|
-
}), "image" in n &&
|
|
3045
|
+
}), "image" in n && t.push({
|
|
3015
3046
|
name: "Image",
|
|
3016
3047
|
aliases: [
|
|
3017
3048
|
"image",
|
|
@@ -3036,14 +3067,14 @@ const Ko = (n = jt) => {
|
|
|
3036
3067
|
})
|
|
3037
3068
|
);
|
|
3038
3069
|
}
|
|
3039
|
-
}),
|
|
3070
|
+
}), t;
|
|
3040
3071
|
}, Yo = {
|
|
3041
3072
|
enableInputRules: !0,
|
|
3042
3073
|
enablePasteRules: !0,
|
|
3043
3074
|
enableCoreExtensions: !1
|
|
3044
3075
|
};
|
|
3045
3076
|
class xn {
|
|
3046
|
-
constructor(
|
|
3077
|
+
constructor(t = {}) {
|
|
3047
3078
|
u(this, "_tiptapEditor");
|
|
3048
3079
|
u(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
3049
3080
|
u(this, "schema");
|
|
@@ -3055,26 +3086,26 @@ class xn {
|
|
|
3055
3086
|
u(this, "imageToolbar");
|
|
3056
3087
|
u(this, "uploadFile");
|
|
3057
3088
|
var l, a, d, c, m;
|
|
3058
|
-
this.options =
|
|
3059
|
-
const
|
|
3089
|
+
this.options = t;
|
|
3090
|
+
const e = {
|
|
3060
3091
|
defaultStyles: !0,
|
|
3061
3092
|
// TODO: There's a lot of annoying typing stuff to deal with here. If
|
|
3062
3093
|
// BSchema is specified, then options.blockSchema should also be required.
|
|
3063
3094
|
// If BSchema is not specified, then options.blockSchema should also not
|
|
3064
3095
|
// be defined. Unfortunately, trying to implement these constraints seems
|
|
3065
3096
|
// to be a huge pain, hence the `as any` casts.
|
|
3066
|
-
blockSchema:
|
|
3067
|
-
...
|
|
3097
|
+
blockSchema: t.blockSchema || jt,
|
|
3098
|
+
...t
|
|
3068
3099
|
};
|
|
3069
3100
|
this.sideMenu = new Xo(this), this.formattingToolbar = new Ro(this), this.slashMenu = new Je(
|
|
3070
3101
|
this,
|
|
3071
|
-
|
|
3102
|
+
e.slashMenuItems || Ko(e.blockSchema)
|
|
3072
3103
|
), this.hyperlinkToolbar = new Uo(this), this.imageToolbar = new Ho(this);
|
|
3073
3104
|
const o = ro({
|
|
3074
3105
|
editor: this,
|
|
3075
|
-
domAttributes:
|
|
3076
|
-
blockSchema:
|
|
3077
|
-
collaboration:
|
|
3106
|
+
domAttributes: e.domAttributes || {},
|
|
3107
|
+
blockSchema: e.blockSchema,
|
|
3108
|
+
collaboration: e.collaboration
|
|
3078
3109
|
}), r = A.create({
|
|
3079
3110
|
name: "BlockNoteUIExtension",
|
|
3080
3111
|
addProseMirrorPlugins: () => [
|
|
@@ -3085,15 +3116,15 @@ class xn {
|
|
|
3085
3116
|
this.imageToolbar.plugin
|
|
3086
3117
|
]
|
|
3087
3118
|
});
|
|
3088
|
-
o.push(r), this.schema =
|
|
3089
|
-
const i =
|
|
3119
|
+
o.push(r), this.schema = e.blockSchema, this.uploadFile = e.uploadFile;
|
|
3120
|
+
const i = e.initialContent || (t.collaboration ? void 0 : [
|
|
3090
3121
|
{
|
|
3091
3122
|
type: "paragraph",
|
|
3092
3123
|
id: j.options.generateID()
|
|
3093
3124
|
}
|
|
3094
3125
|
]), s = {
|
|
3095
3126
|
...Yo,
|
|
3096
|
-
...
|
|
3127
|
+
...e._tiptapOptions,
|
|
3097
3128
|
onBeforeCreate(h) {
|
|
3098
3129
|
if (!i)
|
|
3099
3130
|
return;
|
|
@@ -3108,31 +3139,31 @@ class xn {
|
|
|
3108
3139
|
},
|
|
3109
3140
|
onCreate: () => {
|
|
3110
3141
|
var h;
|
|
3111
|
-
i !== void 0 && this.replaceBlocks(this.topLevelBlocks, i), (h =
|
|
3142
|
+
i !== void 0 && this.replaceBlocks(this.topLevelBlocks, i), (h = e.onEditorReady) == null || h.call(e, this), this.ready = !0;
|
|
3112
3143
|
},
|
|
3113
3144
|
onUpdate: () => {
|
|
3114
3145
|
var h;
|
|
3115
|
-
this.ready && ((h =
|
|
3146
|
+
this.ready && ((h = e.onEditorContentChange) == null || h.call(e, this));
|
|
3116
3147
|
},
|
|
3117
3148
|
onSelectionUpdate: () => {
|
|
3118
3149
|
var h;
|
|
3119
|
-
this.ready && ((h =
|
|
3150
|
+
this.ready && ((h = e.onTextCursorPositionChange) == null || h.call(e, this));
|
|
3120
3151
|
},
|
|
3121
|
-
editable:
|
|
3122
|
-
extensions:
|
|
3152
|
+
editable: t.editable === void 0 ? !0 : t.editable,
|
|
3153
|
+
extensions: e.enableBlockNoteExtensions === !1 ? (l = e._tiptapOptions) == null ? void 0 : l.extensions : [...((a = e._tiptapOptions) == null ? void 0 : a.extensions) || [], ...o],
|
|
3123
3154
|
editorProps: {
|
|
3124
3155
|
attributes: {
|
|
3125
|
-
...(d =
|
|
3156
|
+
...(d = e.domAttributes) == null ? void 0 : d.editor,
|
|
3126
3157
|
class: S(
|
|
3127
3158
|
D.bnEditor,
|
|
3128
3159
|
D.bnRoot,
|
|
3129
|
-
|
|
3130
|
-
((m = (c =
|
|
3160
|
+
e.defaultStyles ? D.defaultStyles : "",
|
|
3161
|
+
((m = (c = e.domAttributes) == null ? void 0 : c.editor) == null ? void 0 : m.class) || ""
|
|
3131
3162
|
)
|
|
3132
3163
|
}
|
|
3133
3164
|
}
|
|
3134
3165
|
};
|
|
3135
|
-
|
|
3166
|
+
e.parentElement && (s.element = e.parentElement), this._tiptapEditor = new re(s);
|
|
3136
3167
|
}
|
|
3137
3168
|
get prosemirrorView() {
|
|
3138
3169
|
return this._tiptapEditor.view;
|
|
@@ -3151,32 +3182,32 @@ class xn {
|
|
|
3151
3182
|
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
3152
3183
|
*/
|
|
3153
3184
|
get topLevelBlocks() {
|
|
3154
|
-
const
|
|
3155
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((
|
|
3185
|
+
const t = [];
|
|
3186
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((e) => (t.push(x(e, this.schema, this.blockCache)), !1)), t;
|
|
3156
3187
|
}
|
|
3157
3188
|
/**
|
|
3158
3189
|
* Gets a snapshot of an existing block from the editor.
|
|
3159
3190
|
* @param blockIdentifier The identifier of an existing block that should be retrieved.
|
|
3160
3191
|
* @returns The block that matches the identifier, or `undefined` if no matching block was found.
|
|
3161
3192
|
*/
|
|
3162
|
-
getBlock(
|
|
3163
|
-
const
|
|
3193
|
+
getBlock(t) {
|
|
3194
|
+
const e = typeof t == "string" ? t : t.id;
|
|
3164
3195
|
let o;
|
|
3165
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !==
|
|
3196
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== e ? !0 : (o = x(r, this.schema, this.blockCache), !1)), o;
|
|
3166
3197
|
}
|
|
3167
3198
|
/**
|
|
3168
3199
|
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
3169
3200
|
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
3170
3201
|
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
3171
3202
|
*/
|
|
3172
|
-
forEachBlock(
|
|
3203
|
+
forEachBlock(t, e = !1) {
|
|
3173
3204
|
const o = this.topLevelBlocks.slice();
|
|
3174
|
-
|
|
3205
|
+
e && o.reverse();
|
|
3175
3206
|
function r(i) {
|
|
3176
3207
|
for (const s of i) {
|
|
3177
|
-
if (!
|
|
3208
|
+
if (!t(s))
|
|
3178
3209
|
return !1;
|
|
3179
|
-
const l =
|
|
3210
|
+
const l = e ? s.children.slice().reverse() : s.children;
|
|
3180
3211
|
if (!r(l))
|
|
3181
3212
|
return !1;
|
|
3182
3213
|
}
|
|
@@ -3188,30 +3219,30 @@ class xn {
|
|
|
3188
3219
|
* Executes a callback whenever the editor's contents change.
|
|
3189
3220
|
* @param callback The callback to execute.
|
|
3190
3221
|
*/
|
|
3191
|
-
onEditorContentChange(
|
|
3192
|
-
this._tiptapEditor.on("update",
|
|
3222
|
+
onEditorContentChange(t) {
|
|
3223
|
+
this._tiptapEditor.on("update", t);
|
|
3193
3224
|
}
|
|
3194
3225
|
/**
|
|
3195
3226
|
* Executes a callback whenever the editor's selection changes.
|
|
3196
3227
|
* @param callback The callback to execute.
|
|
3197
3228
|
*/
|
|
3198
|
-
onEditorSelectionChange(
|
|
3199
|
-
this._tiptapEditor.on("selectionUpdate",
|
|
3229
|
+
onEditorSelectionChange(t) {
|
|
3230
|
+
this._tiptapEditor.on("selectionUpdate", t);
|
|
3200
3231
|
}
|
|
3201
3232
|
/**
|
|
3202
3233
|
* Gets a snapshot of the current text cursor position.
|
|
3203
3234
|
* @returns A snapshot of the current text cursor position.
|
|
3204
3235
|
*/
|
|
3205
3236
|
getTextCursorPosition() {
|
|
3206
|
-
const { node:
|
|
3237
|
+
const { node: t, depth: e, startPos: o, endPos: r } = b(
|
|
3207
3238
|
this._tiptapEditor.state.doc,
|
|
3208
3239
|
this._tiptapEditor.state.selection.from
|
|
3209
|
-
), i = this._tiptapEditor.state.doc.resolve(r).index(
|
|
3240
|
+
), i = this._tiptapEditor.state.doc.resolve(r).index(e - 1), s = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
|
|
3210
3241
|
let l;
|
|
3211
3242
|
i > 0 && (l = this._tiptapEditor.state.doc.resolve(o - 2).node());
|
|
3212
3243
|
let a;
|
|
3213
3244
|
return i < s - 1 && (a = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
|
|
3214
|
-
block: x(
|
|
3245
|
+
block: x(t, this.schema, this.blockCache),
|
|
3215
3246
|
prevBlock: l === void 0 ? void 0 : x(l, this.schema, this.blockCache),
|
|
3216
3247
|
nextBlock: a === void 0 ? void 0 : x(a, this.schema, this.blockCache)
|
|
3217
3248
|
};
|
|
@@ -3222,8 +3253,8 @@ class xn {
|
|
|
3222
3253
|
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
3223
3254
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
3224
3255
|
*/
|
|
3225
|
-
setTextCursorPosition(
|
|
3226
|
-
const o = typeof
|
|
3256
|
+
setTextCursorPosition(t, e = "start") {
|
|
3257
|
+
const o = typeof t == "string" ? t : t.id, { posBeforeNode: r } = et(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = b(
|
|
3227
3258
|
this._tiptapEditor.state.doc,
|
|
3228
3259
|
r + 2
|
|
3229
3260
|
);
|
|
@@ -3231,7 +3262,7 @@ class xn {
|
|
|
3231
3262
|
this._tiptapEditor.commands.setNodeSelection(i);
|
|
3232
3263
|
return;
|
|
3233
3264
|
}
|
|
3234
|
-
|
|
3265
|
+
e === "start" ? this._tiptapEditor.commands.setTextSelection(i + 1) : this._tiptapEditor.commands.setTextSelection(
|
|
3235
3266
|
i + s.nodeSize - 1
|
|
3236
3267
|
);
|
|
3237
3268
|
}
|
|
@@ -3241,14 +3272,14 @@ class xn {
|
|
|
3241
3272
|
getSelection() {
|
|
3242
3273
|
if (this._tiptapEditor.state.selection.from === this._tiptapEditor.state.selection.to || "node" in this._tiptapEditor.state.selection)
|
|
3243
3274
|
return;
|
|
3244
|
-
const
|
|
3245
|
-
return this._tiptapEditor.state.doc.descendants((
|
|
3275
|
+
const t = [];
|
|
3276
|
+
return this._tiptapEditor.state.doc.descendants((e, o) => e.type.spec.group !== "blockContent" || o + e.nodeSize < this._tiptapEditor.state.selection.from || o > this._tiptapEditor.state.selection.to ? !0 : (t.push(
|
|
3246
3277
|
x(
|
|
3247
3278
|
this._tiptapEditor.state.doc.resolve(o).node(),
|
|
3248
3279
|
this.schema,
|
|
3249
3280
|
this.blockCache
|
|
3250
3281
|
)
|
|
3251
|
-
), !1)), { blocks:
|
|
3282
|
+
), !1)), { blocks: t };
|
|
3252
3283
|
}
|
|
3253
3284
|
/**
|
|
3254
3285
|
* Checks if the editor is currently editable, or if it's locked.
|
|
@@ -3261,8 +3292,8 @@ class xn {
|
|
|
3261
3292
|
* Makes the editor editable or locks it, depending on the argument passed.
|
|
3262
3293
|
* @param editable True to make the editor editable, or false to lock it.
|
|
3263
3294
|
*/
|
|
3264
|
-
set isEditable(
|
|
3265
|
-
this._tiptapEditor.setEditable(
|
|
3295
|
+
set isEditable(t) {
|
|
3296
|
+
this._tiptapEditor.setEditable(t);
|
|
3266
3297
|
}
|
|
3267
3298
|
/**
|
|
3268
3299
|
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
@@ -3272,8 +3303,8 @@ class xn {
|
|
|
3272
3303
|
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
3273
3304
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
3274
3305
|
*/
|
|
3275
|
-
insertBlocks(
|
|
3276
|
-
Ut(
|
|
3306
|
+
insertBlocks(t, e, o = "before") {
|
|
3307
|
+
Ut(t, e, o, this._tiptapEditor);
|
|
3277
3308
|
}
|
|
3278
3309
|
/**
|
|
3279
3310
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -3282,15 +3313,15 @@ class xn {
|
|
|
3282
3313
|
* @param blockToUpdate The block that should be updated.
|
|
3283
3314
|
* @param update A partial block which defines how the existing block should be changed.
|
|
3284
3315
|
*/
|
|
3285
|
-
updateBlock(
|
|
3286
|
-
io(
|
|
3316
|
+
updateBlock(t, e) {
|
|
3317
|
+
io(t, e, this._tiptapEditor);
|
|
3287
3318
|
}
|
|
3288
3319
|
/**
|
|
3289
3320
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
3290
3321
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
3291
3322
|
*/
|
|
3292
|
-
removeBlocks(
|
|
3293
|
-
Ft(
|
|
3323
|
+
removeBlocks(t) {
|
|
3324
|
+
Ft(t, this._tiptapEditor);
|
|
3294
3325
|
}
|
|
3295
3326
|
/**
|
|
3296
3327
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -3299,30 +3330,30 @@ class xn {
|
|
|
3299
3330
|
* @param blocksToRemove An array of blocks that should be replaced.
|
|
3300
3331
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
3301
3332
|
*/
|
|
3302
|
-
replaceBlocks(
|
|
3303
|
-
so(
|
|
3333
|
+
replaceBlocks(t, e) {
|
|
3334
|
+
so(t, e, this._tiptapEditor);
|
|
3304
3335
|
}
|
|
3305
3336
|
/**
|
|
3306
3337
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
3307
3338
|
*/
|
|
3308
3339
|
getActiveStyles() {
|
|
3309
|
-
const
|
|
3340
|
+
const t = {}, e = this._tiptapEditor.state.selection.$to.marks(), o = /* @__PURE__ */ new Set([
|
|
3310
3341
|
"bold",
|
|
3311
3342
|
"italic",
|
|
3312
3343
|
"underline",
|
|
3313
3344
|
"strike",
|
|
3314
3345
|
"code"
|
|
3315
3346
|
]), r = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
3316
|
-
for (const i of
|
|
3317
|
-
o.has(i.type.name) ?
|
|
3318
|
-
return
|
|
3347
|
+
for (const i of e)
|
|
3348
|
+
o.has(i.type.name) ? t[i.type.name] = !0 : r.has(i.type.name) && (t[i.type.name] = i.attrs.color);
|
|
3349
|
+
return t;
|
|
3319
3350
|
}
|
|
3320
3351
|
/**
|
|
3321
3352
|
* Adds styles to the currently selected content.
|
|
3322
3353
|
* @param styles The styles to add.
|
|
3323
3354
|
*/
|
|
3324
|
-
addStyles(
|
|
3325
|
-
const
|
|
3355
|
+
addStyles(t) {
|
|
3356
|
+
const e = /* @__PURE__ */ new Set([
|
|
3326
3357
|
"bold",
|
|
3327
3358
|
"italic",
|
|
3328
3359
|
"underline",
|
|
@@ -3330,24 +3361,24 @@ class xn {
|
|
|
3330
3361
|
"code"
|
|
3331
3362
|
]), o = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
3332
3363
|
this._tiptapEditor.view.focus();
|
|
3333
|
-
for (const [r, i] of Object.entries(
|
|
3334
|
-
|
|
3364
|
+
for (const [r, i] of Object.entries(t))
|
|
3365
|
+
e.has(r) ? this._tiptapEditor.commands.setMark(r) : o.has(r) && this._tiptapEditor.commands.setMark(r, { color: i });
|
|
3335
3366
|
}
|
|
3336
3367
|
/**
|
|
3337
3368
|
* Removes styles from the currently selected content.
|
|
3338
3369
|
* @param styles The styles to remove.
|
|
3339
3370
|
*/
|
|
3340
|
-
removeStyles(
|
|
3371
|
+
removeStyles(t) {
|
|
3341
3372
|
this._tiptapEditor.view.focus();
|
|
3342
|
-
for (const
|
|
3343
|
-
this._tiptapEditor.commands.unsetMark(
|
|
3373
|
+
for (const e of Object.keys(t))
|
|
3374
|
+
this._tiptapEditor.commands.unsetMark(e);
|
|
3344
3375
|
}
|
|
3345
3376
|
/**
|
|
3346
3377
|
* Toggles styles on the currently selected content.
|
|
3347
3378
|
* @param styles The styles to toggle.
|
|
3348
3379
|
*/
|
|
3349
|
-
toggleStyles(
|
|
3350
|
-
const
|
|
3380
|
+
toggleStyles(t) {
|
|
3381
|
+
const e = /* @__PURE__ */ new Set([
|
|
3351
3382
|
"bold",
|
|
3352
3383
|
"italic",
|
|
3353
3384
|
"underline",
|
|
@@ -3355,8 +3386,8 @@ class xn {
|
|
|
3355
3386
|
"code"
|
|
3356
3387
|
]), o = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
3357
3388
|
this._tiptapEditor.view.focus();
|
|
3358
|
-
for (const [r, i] of Object.entries(
|
|
3359
|
-
|
|
3389
|
+
for (const [r, i] of Object.entries(t))
|
|
3390
|
+
e.has(r) ? this._tiptapEditor.commands.toggleMark(r) : o.has(r) && this._tiptapEditor.commands.toggleMark(r, { color: i });
|
|
3360
3391
|
}
|
|
3361
3392
|
/**
|
|
3362
3393
|
* Gets the currently selected text.
|
|
@@ -3378,25 +3409,25 @@ class xn {
|
|
|
3378
3409
|
* @param url The link URL.
|
|
3379
3410
|
* @param text The text to display the link with.
|
|
3380
3411
|
*/
|
|
3381
|
-
createLink(
|
|
3382
|
-
if (
|
|
3412
|
+
createLink(t, e) {
|
|
3413
|
+
if (t === "")
|
|
3383
3414
|
return;
|
|
3384
3415
|
const { from: o, to: r } = this._tiptapEditor.state.selection;
|
|
3385
|
-
|
|
3386
|
-
const i = this._tiptapEditor.schema.mark("link", { href:
|
|
3416
|
+
e || (e = this._tiptapEditor.state.doc.textBetween(o, r));
|
|
3417
|
+
const i = this._tiptapEditor.schema.mark("link", { href: t });
|
|
3387
3418
|
this._tiptapEditor.view.dispatch(
|
|
3388
|
-
this._tiptapEditor.view.state.tr.insertText(
|
|
3419
|
+
this._tiptapEditor.view.state.tr.insertText(e, o, r).addMark(o, o + e.length, i)
|
|
3389
3420
|
);
|
|
3390
3421
|
}
|
|
3391
3422
|
/**
|
|
3392
3423
|
* Checks if the block containing the text cursor can be nested.
|
|
3393
3424
|
*/
|
|
3394
3425
|
canNestBlock() {
|
|
3395
|
-
const { startPos:
|
|
3426
|
+
const { startPos: t, depth: e } = b(
|
|
3396
3427
|
this._tiptapEditor.state.doc,
|
|
3397
3428
|
this._tiptapEditor.state.selection.from
|
|
3398
3429
|
);
|
|
3399
|
-
return this._tiptapEditor.state.doc.resolve(
|
|
3430
|
+
return this._tiptapEditor.state.doc.resolve(t).index(e - 1) > 0;
|
|
3400
3431
|
}
|
|
3401
3432
|
/**
|
|
3402
3433
|
* Nests the block containing the text cursor into the block above it.
|
|
@@ -3408,11 +3439,11 @@ class xn {
|
|
|
3408
3439
|
* Checks if the block containing the text cursor is nested.
|
|
3409
3440
|
*/
|
|
3410
3441
|
canUnnestBlock() {
|
|
3411
|
-
const { depth:
|
|
3442
|
+
const { depth: t } = b(
|
|
3412
3443
|
this._tiptapEditor.state.doc,
|
|
3413
3444
|
this._tiptapEditor.state.selection.from
|
|
3414
3445
|
);
|
|
3415
|
-
return
|
|
3446
|
+
return t > 2;
|
|
3416
3447
|
}
|
|
3417
3448
|
/**
|
|
3418
3449
|
* Lifts the block containing the text cursor out of its parent.
|
|
@@ -3426,8 +3457,8 @@ class xn {
|
|
|
3426
3457
|
* @param blocks An array of blocks that should be serialized into HTML.
|
|
3427
3458
|
* @returns The blocks, serialized as an HTML string.
|
|
3428
3459
|
*/
|
|
3429
|
-
async blocksToHTML(
|
|
3430
|
-
return
|
|
3460
|
+
async blocksToHTML(t) {
|
|
3461
|
+
return $t(t, this._tiptapEditor.schema);
|
|
3431
3462
|
}
|
|
3432
3463
|
/**
|
|
3433
3464
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -3436,8 +3467,8 @@ class xn {
|
|
|
3436
3467
|
* @param html The HTML string to parse blocks from.
|
|
3437
3468
|
* @returns The blocks parsed from the HTML string.
|
|
3438
3469
|
*/
|
|
3439
|
-
async HTMLToBlocks(
|
|
3440
|
-
return
|
|
3470
|
+
async HTMLToBlocks(t) {
|
|
3471
|
+
return Wt(t, this.schema, this._tiptapEditor.schema);
|
|
3441
3472
|
}
|
|
3442
3473
|
/**
|
|
3443
3474
|
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
@@ -3445,8 +3476,8 @@ class xn {
|
|
|
3445
3476
|
* @param blocks An array of blocks that should be serialized into Markdown.
|
|
3446
3477
|
* @returns The blocks, serialized as a Markdown string.
|
|
3447
3478
|
*/
|
|
3448
|
-
async blocksToMarkdown(
|
|
3449
|
-
return co(
|
|
3479
|
+
async blocksToMarkdown(t) {
|
|
3480
|
+
return co(t, this._tiptapEditor.schema);
|
|
3450
3481
|
}
|
|
3451
3482
|
/**
|
|
3452
3483
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -3455,25 +3486,25 @@ class xn {
|
|
|
3455
3486
|
* @param markdown The Markdown string to parse blocks from.
|
|
3456
3487
|
* @returns The blocks parsed from the Markdown string.
|
|
3457
3488
|
*/
|
|
3458
|
-
async markdownToBlocks(
|
|
3459
|
-
return po(
|
|
3489
|
+
async markdownToBlocks(t) {
|
|
3490
|
+
return po(t, this.schema, this._tiptapEditor.schema);
|
|
3460
3491
|
}
|
|
3461
3492
|
/**
|
|
3462
3493
|
* Updates the user info for the current user that's shown to other collaborators.
|
|
3463
3494
|
*/
|
|
3464
|
-
updateCollaborationUserInfo(
|
|
3495
|
+
updateCollaborationUserInfo(t) {
|
|
3465
3496
|
if (!this.options.collaboration)
|
|
3466
3497
|
throw new Error(
|
|
3467
3498
|
"Cannot update collaboration user info when collaboration is disabled."
|
|
3468
3499
|
);
|
|
3469
|
-
this._tiptapEditor.commands.updateUser(
|
|
3500
|
+
this._tiptapEditor.commands.updateUser(t);
|
|
3470
3501
|
}
|
|
3471
3502
|
}
|
|
3472
3503
|
const In = async (n) => {
|
|
3473
|
-
const
|
|
3474
|
-
return
|
|
3504
|
+
const t = new FormData();
|
|
3505
|
+
return t.append("file", n), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
|
|
3475
3506
|
method: "POST",
|
|
3476
|
-
body:
|
|
3507
|
+
body: t
|
|
3477
3508
|
})).json()).data.url.replace(
|
|
3478
3509
|
"tmpfiles.org/",
|
|
3479
3510
|
"tmpfiles.org/dl/"
|
|
@@ -3491,13 +3522,13 @@ export {
|
|
|
3491
3522
|
jo as SideMenuView,
|
|
3492
3523
|
Je as SlashMenuProsemirrorPlugin,
|
|
3493
3524
|
Pe as UnreachableCaseError,
|
|
3494
|
-
|
|
3525
|
+
Mn as blockStyles,
|
|
3495
3526
|
dt as camelToDataKebab,
|
|
3496
3527
|
go as createBlockSpec,
|
|
3497
3528
|
F as createTipTapBlock,
|
|
3498
3529
|
jt as defaultBlockSchema,
|
|
3499
3530
|
C as defaultProps,
|
|
3500
|
-
|
|
3531
|
+
Tn as formatKeyboardShortcut,
|
|
3501
3532
|
Oo as formattingToolbarPluginKey,
|
|
3502
3533
|
ro as getBlockNoteExtensions,
|
|
3503
3534
|
Ko as getDefaultSlashMenuItems,
|