@blocknote/core 0.9.5 → 0.9.6
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 +684 -673
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -5
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +19 -7
- package/src/api/nodeConversions/nodeConversions.ts +0 -13
- package/src/extensions/Blocks/nodes/Block.module.css +1 -4
- package/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.ts +30 -0
- package/src/extensions/SideMenu/SideMenuPlugin.ts +11 -0
- package/types/src/BlockNoteEditor.d.ts +2 -1
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +1 -0
package/dist/blocknote.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (n, t, e) => (
|
|
4
|
-
import { Extension as
|
|
5
|
-
import { Bold as
|
|
6
|
-
import { Code as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { Dropcursor as
|
|
10
|
-
import { Gapcursor as
|
|
11
|
-
import { HardBreak as
|
|
12
|
-
import { History as
|
|
13
|
-
import { Italic as
|
|
14
|
-
import { Link as
|
|
15
|
-
import { Strike as
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Underline as
|
|
18
|
-
import { Slice as
|
|
19
|
-
import { Plugin as
|
|
20
|
-
import { v4 as
|
|
21
|
-
import * as
|
|
22
|
-
import { Decoration as
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import { unified as
|
|
31
|
-
import { fromDom as
|
|
32
|
-
const
|
|
33
|
-
bnEditor:
|
|
34
|
-
bnRoot:
|
|
35
|
-
defaultStyles:
|
|
36
|
-
dragPreview:
|
|
1
|
+
var Jt = Object.defineProperty;
|
|
2
|
+
var Zt = (n, t, e) => t in n ? Jt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var u = (n, t, e) => (Zt(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { Extension as L, Mark as mt, combineTransactionSteps as Qt, getChangedRanges as te, findChildrenInRange as ee, findChildren as rt, Node as q, mergeAttributes as D, findParentNode as oe, extensions as V, InputRule as Q, isTextSelection as ne, isNodeSelection as re, posToDOMRect as Y, getMarkRange as it, Editor as ie } from "@tiptap/core";
|
|
5
|
+
import { Bold as se } from "@tiptap/extension-bold";
|
|
6
|
+
import { Code as ae } from "@tiptap/extension-code";
|
|
7
|
+
import le from "@tiptap/extension-collaboration";
|
|
8
|
+
import de from "@tiptap/extension-collaboration-cursor";
|
|
9
|
+
import { Dropcursor as ce } from "@tiptap/extension-dropcursor";
|
|
10
|
+
import { Gapcursor as ue } from "@tiptap/extension-gapcursor";
|
|
11
|
+
import { HardBreak as pe } from "@tiptap/extension-hard-break";
|
|
12
|
+
import { History as he } from "@tiptap/extension-history";
|
|
13
|
+
import { Italic as me } from "@tiptap/extension-italic";
|
|
14
|
+
import { Link as fe } from "@tiptap/extension-link";
|
|
15
|
+
import { Strike as ge } from "@tiptap/extension-strike";
|
|
16
|
+
import { Text as ke } from "@tiptap/extension-text";
|
|
17
|
+
import { Underline as be } from "@tiptap/extension-underline";
|
|
18
|
+
import { Slice as P, Fragment as O, DOMSerializer as J, DOMParser as ye } from "prosemirror-model";
|
|
19
|
+
import { Plugin as I, PluginKey as _, NodeSelection as ft, TextSelection as st, Selection as K } from "prosemirror-state";
|
|
20
|
+
import { v4 as ve } from "uuid";
|
|
21
|
+
import * as we from "prosemirror-view";
|
|
22
|
+
import { Decoration as G, DecorationSet as j } from "prosemirror-view";
|
|
23
|
+
import gt from "rehype-parse";
|
|
24
|
+
import Ce from "rehype-remark";
|
|
25
|
+
import kt from "rehype-stringify";
|
|
26
|
+
import bt from "remark-gfm";
|
|
27
|
+
import Ee from "remark-parse";
|
|
28
|
+
import Se, { defaultHandlers as Me } from "remark-rehype";
|
|
29
|
+
import Te from "remark-stringify";
|
|
30
|
+
import { unified as tt } from "unified";
|
|
31
|
+
import { fromDom as at } from "hast-util-from-dom";
|
|
32
|
+
const Be = "_bnEditor_12je0_3", xe = "_bnRoot_12je0_19", Ie = "_defaultStyles_12je0_34", _e = "_dragPreview_12je0_57", R = {
|
|
33
|
+
bnEditor: Be,
|
|
34
|
+
bnRoot: xe,
|
|
35
|
+
defaultStyles: Ie,
|
|
36
|
+
dragPreview: _e,
|
|
37
37
|
"collaboration-cursor__caret": "_collaboration-cursor__caret_12je0_63",
|
|
38
38
|
"collaboration-cursor__label": "_collaboration-cursor__label_12je0_74"
|
|
39
39
|
};
|
|
40
|
-
function
|
|
40
|
+
function yt(n) {
|
|
41
41
|
const t = n.attrs.id, e = n.firstChild, o = e.type, r = n.childCount === 2 ? n.lastChild.childCount : 0;
|
|
42
42
|
return {
|
|
43
43
|
id: t,
|
|
@@ -47,7 +47,7 @@ function bt(n) {
|
|
|
47
47
|
numChildBlocks: r
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function v(n, t) {
|
|
51
51
|
const o = n.nodeSize - 2;
|
|
52
52
|
if (t <= 1)
|
|
53
53
|
for (t = 1 + 1; n.resolve(t).parent.type.name !== "blockContainer" && t < o; )
|
|
@@ -67,19 +67,19 @@ function b(n, t) {
|
|
|
67
67
|
break;
|
|
68
68
|
l -= 1, s = r.node(l);
|
|
69
69
|
}
|
|
70
|
-
const { id: a, contentNode: d, contentType: c, numChildBlocks:
|
|
70
|
+
const { id: a, contentNode: d, contentType: c, numChildBlocks: h } = yt(s), m = r.start(l), p = r.end(l);
|
|
71
71
|
return {
|
|
72
72
|
id: a,
|
|
73
73
|
node: s,
|
|
74
74
|
contentNode: d,
|
|
75
75
|
contentType: c,
|
|
76
|
-
numChildBlocks:
|
|
77
|
-
startPos:
|
|
76
|
+
numChildBlocks: h,
|
|
77
|
+
startPos: m,
|
|
78
78
|
endPos: p,
|
|
79
79
|
depth: l
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const T = {
|
|
83
83
|
backgroundColor: {
|
|
84
84
|
default: "default"
|
|
85
85
|
},
|
|
@@ -90,7 +90,7 @@ const C = {
|
|
|
90
90
|
default: "left",
|
|
91
91
|
values: ["left", "center", "right", "justify"]
|
|
92
92
|
}
|
|
93
|
-
}, Ae =
|
|
93
|
+
}, Ae = L.create({
|
|
94
94
|
name: "blockBackgroundColor",
|
|
95
95
|
addGlobalAttributes() {
|
|
96
96
|
return [
|
|
@@ -98,9 +98,9 @@ const C = {
|
|
|
98
98
|
types: ["blockContainer"],
|
|
99
99
|
attributes: {
|
|
100
100
|
backgroundColor: {
|
|
101
|
-
default:
|
|
102
|
-
parseHTML: (n) => n.hasAttribute("data-background-color") ? n.getAttribute("data-background-color") :
|
|
103
|
-
renderHTML: (n) => n.backgroundColor !==
|
|
101
|
+
default: T.backgroundColor.default,
|
|
102
|
+
parseHTML: (n) => n.hasAttribute("data-background-color") ? n.getAttribute("data-background-color") : T.backgroundColor.default,
|
|
103
|
+
renderHTML: (n) => n.backgroundColor !== T.backgroundColor.default && {
|
|
104
104
|
"data-background-color": n.backgroundColor
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -111,7 +111,7 @@ const C = {
|
|
|
111
111
|
addCommands() {
|
|
112
112
|
return {
|
|
113
113
|
setBlockBackgroundColor: (n, t) => ({ state: e, view: o }) => {
|
|
114
|
-
const r =
|
|
114
|
+
const r = v(e.doc, n);
|
|
115
115
|
return r === void 0 ? !1 : (e.tr.setNodeAttribute(
|
|
116
116
|
r.startPos - 1,
|
|
117
117
|
"backgroundColor",
|
|
@@ -120,7 +120,7 @@ const C = {
|
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
}),
|
|
123
|
+
}), He = mt.create({
|
|
124
124
|
name: "backgroundColor",
|
|
125
125
|
addAttributes() {
|
|
126
126
|
return {
|
|
@@ -146,24 +146,24 @@ const C = {
|
|
|
146
146
|
},
|
|
147
147
|
addCommands() {
|
|
148
148
|
return {
|
|
149
|
-
setBackgroundColor: (n) => ({ commands: t }) => n !==
|
|
149
|
+
setBackgroundColor: (n) => ({ commands: t }) => n !== T.backgroundColor.default ? t.setMark(this.name, { color: n }) : t.unsetMark(this.name)
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
function
|
|
153
|
+
function Le(n, t = JSON.stringify) {
|
|
154
154
|
const e = {};
|
|
155
155
|
return n.filter((o) => {
|
|
156
156
|
const r = t(o);
|
|
157
157
|
return Object.prototype.hasOwnProperty.call(e, r) ? !1 : e[r] = !0;
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function Ne(n) {
|
|
161
161
|
const t = n.filter(
|
|
162
162
|
(o, r) => n.indexOf(o) !== r
|
|
163
163
|
);
|
|
164
|
-
return
|
|
164
|
+
return Le(t);
|
|
165
165
|
}
|
|
166
|
-
const
|
|
166
|
+
const X = L.create({
|
|
167
167
|
name: "uniqueID",
|
|
168
168
|
// we’ll set a very high priority to make sure this runs first
|
|
169
169
|
// and is compatible with `appendTransaction` hooks of other extensions
|
|
@@ -177,7 +177,7 @@ const j = A.create({
|
|
|
177
177
|
const n = window.__TEST_OPTIONS;
|
|
178
178
|
return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
|
|
179
179
|
}
|
|
180
|
-
return
|
|
180
|
+
return ve();
|
|
181
181
|
},
|
|
182
182
|
filterTransaction: null
|
|
183
183
|
};
|
|
@@ -231,38 +231,38 @@ const j = A.create({
|
|
|
231
231
|
addProseMirrorPlugins() {
|
|
232
232
|
let n = null, t = !1;
|
|
233
233
|
return [
|
|
234
|
-
new
|
|
235
|
-
key: new
|
|
234
|
+
new I({
|
|
235
|
+
key: new _("uniqueID"),
|
|
236
236
|
appendTransaction: (e, o, r) => {
|
|
237
237
|
const i = e.some((f) => f.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && e.some((f) => {
|
|
238
|
-
let
|
|
239
|
-
return !(!((
|
|
238
|
+
let b, w;
|
|
239
|
+
return !(!((w = (b = this.options).filterTransaction) === null || w === void 0) && w.call(b, f));
|
|
240
240
|
});
|
|
241
241
|
if (!i || s)
|
|
242
242
|
return;
|
|
243
|
-
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options,
|
|
243
|
+
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h = Qt(
|
|
244
244
|
o.doc,
|
|
245
245
|
e
|
|
246
|
-
), { mapping:
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
246
|
+
), { mapping: m } = h;
|
|
247
|
+
if (te(h).forEach(({ newRange: f }) => {
|
|
248
|
+
const b = ee(
|
|
249
249
|
r.doc,
|
|
250
250
|
f,
|
|
251
|
-
(
|
|
252
|
-
),
|
|
253
|
-
|
|
251
|
+
(M) => a.includes(M.type.name)
|
|
252
|
+
), w = b.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C = Ne(w);
|
|
253
|
+
b.forEach(({ node: M, pos: E }) => {
|
|
254
254
|
let y;
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
l.setNodeMarkup(
|
|
258
|
-
...
|
|
255
|
+
const S = (y = l.doc.nodeAt(E)) === null || y === void 0 ? void 0 : y.attrs[d];
|
|
256
|
+
if (S === null) {
|
|
257
|
+
l.setNodeMarkup(E, void 0, {
|
|
258
|
+
...M.attrs,
|
|
259
259
|
[d]: c()
|
|
260
260
|
});
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
|
-
const { deleted:
|
|
264
|
-
|
|
265
|
-
...
|
|
263
|
+
const { deleted: g } = m.invert().mapResult(E);
|
|
264
|
+
g && C.includes(S) && l.setNodeMarkup(E, void 0, {
|
|
265
|
+
...M.attrs,
|
|
266
266
|
[d]: c()
|
|
267
267
|
});
|
|
268
268
|
});
|
|
@@ -319,9 +319,9 @@ const j = A.create({
|
|
|
319
319
|
a.marks
|
|
320
320
|
);
|
|
321
321
|
l.push(d);
|
|
322
|
-
}),
|
|
322
|
+
}), O.from(l);
|
|
323
323
|
};
|
|
324
|
-
return t = !1, new
|
|
324
|
+
return t = !1, new P(
|
|
325
325
|
i(e.content),
|
|
326
326
|
e.openStart,
|
|
327
327
|
e.openEnd
|
|
@@ -331,37 +331,37 @@ const j = A.create({
|
|
|
331
331
|
})
|
|
332
332
|
];
|
|
333
333
|
}
|
|
334
|
-
}),
|
|
335
|
-
function
|
|
336
|
-
return
|
|
334
|
+
}), Pe = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
|
335
|
+
function xn(n) {
|
|
336
|
+
return Pe() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function B(...n) {
|
|
339
339
|
return n.filter((t) => t).join(" ");
|
|
340
340
|
}
|
|
341
|
-
class
|
|
341
|
+
class De extends Error {
|
|
342
342
|
constructor(t) {
|
|
343
343
|
super(`Unreachable case: ${t}`);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
|
-
const
|
|
346
|
+
const vt = /* @__PURE__ */ new Set([
|
|
347
347
|
"bold",
|
|
348
348
|
"italic",
|
|
349
349
|
"underline",
|
|
350
350
|
"strike",
|
|
351
351
|
"code"
|
|
352
|
-
]),
|
|
353
|
-
function
|
|
352
|
+
]), wt = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
353
|
+
function lt(n, t) {
|
|
354
354
|
const e = [];
|
|
355
355
|
for (const [o, r] of Object.entries(n.styles))
|
|
356
|
-
|
|
356
|
+
vt.has(o) ? e.push(t.mark(o)) : wt.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
|
|
360
|
+
function Oe(n, t) {
|
|
361
361
|
const e = t.marks.link.create({
|
|
362
362
|
href: n.href
|
|
363
363
|
});
|
|
364
|
-
return
|
|
364
|
+
return Ct(n.content, t).map((o) => {
|
|
365
365
|
if (o.type.name === "text")
|
|
366
366
|
return o.mark([...o.marks, e]);
|
|
367
367
|
if (o.type.name === "hardBreak")
|
|
@@ -369,30 +369,30 @@ function De(n, t) {
|
|
|
369
369
|
throw new Error("unexpected node type");
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function Ct(n, t) {
|
|
373
373
|
const e = [];
|
|
374
374
|
if (typeof n == "string")
|
|
375
375
|
return e.push(
|
|
376
|
-
...
|
|
376
|
+
...lt({ type: "text", text: n, styles: {} }, t)
|
|
377
377
|
), e;
|
|
378
378
|
for (const o of n)
|
|
379
|
-
e.push(...
|
|
379
|
+
e.push(...lt(o, t));
|
|
380
380
|
return e;
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function Et(n, t) {
|
|
383
383
|
const e = [];
|
|
384
384
|
for (const o of n)
|
|
385
385
|
if (o.type === "link")
|
|
386
|
-
e.push(...
|
|
386
|
+
e.push(...Oe(o, t));
|
|
387
387
|
else if (o.type === "text")
|
|
388
|
-
e.push(...
|
|
388
|
+
e.push(...Ct([o], t));
|
|
389
389
|
else
|
|
390
|
-
throw new
|
|
390
|
+
throw new De(o);
|
|
391
391
|
return e;
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function F(n, t) {
|
|
394
394
|
let e = n.id;
|
|
395
|
-
e === void 0 && (e =
|
|
395
|
+
e === void 0 && (e = X.options.generateID());
|
|
396
396
|
let o = n.type;
|
|
397
397
|
o === void 0 && (o = "paragraph");
|
|
398
398
|
let r;
|
|
@@ -404,13 +404,13 @@ function V(n, t) {
|
|
|
404
404
|
t.text(n.content)
|
|
405
405
|
);
|
|
406
406
|
else {
|
|
407
|
-
const l =
|
|
407
|
+
const l = Et(n.content, t);
|
|
408
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(
|
|
413
|
+
i.push(F(l, t));
|
|
414
414
|
const s = t.nodes.blockGroup.create({}, i);
|
|
415
415
|
return t.nodes.blockContainer.create(
|
|
416
416
|
{
|
|
@@ -420,7 +420,7 @@ function V(n, t) {
|
|
|
420
420
|
i.length > 0 ? [r, s] : r
|
|
421
421
|
);
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function Re(n) {
|
|
424
424
|
const t = [];
|
|
425
425
|
let e;
|
|
426
426
|
return n.content.forEach((o) => {
|
|
@@ -440,9 +440,9 @@ function Oe(n) {
|
|
|
440
440
|
for (const s of o.marks)
|
|
441
441
|
if (s.type.name === "link")
|
|
442
442
|
i = s;
|
|
443
|
-
else if (yt.has(s.type.name))
|
|
444
|
-
r[s.type.name] = !0;
|
|
445
443
|
else if (vt.has(s.type.name))
|
|
444
|
+
r[s.type.name] = !0;
|
|
445
|
+
else if (wt.has(s.type.name))
|
|
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);
|
|
@@ -497,7 +497,7 @@ function Oe(n) {
|
|
|
497
497
|
};
|
|
498
498
|
}), e && t.push(e), t;
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function A(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 + "."
|
|
@@ -505,37 +505,37 @@ function x(n, t, e) {
|
|
|
505
505
|
const o = e == null ? void 0 : e.get(n);
|
|
506
506
|
if (o)
|
|
507
507
|
return o;
|
|
508
|
-
const r =
|
|
508
|
+
const r = yt(n);
|
|
509
509
|
let i = r.id;
|
|
510
|
-
i === null && (i =
|
|
510
|
+
i === null && (i = X.options.generateID());
|
|
511
511
|
const s = {};
|
|
512
|
-
for (const [c,
|
|
512
|
+
for (const [c, h] of Object.entries({
|
|
513
513
|
...n.attrs,
|
|
514
514
|
...r.contentNode.attrs
|
|
515
515
|
})) {
|
|
516
|
-
const
|
|
517
|
-
if (!
|
|
516
|
+
const m = t[r.contentType.name];
|
|
517
|
+
if (!m)
|
|
518
518
|
throw Error(
|
|
519
519
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
520
520
|
);
|
|
521
|
-
const p =
|
|
522
|
-
c in p
|
|
521
|
+
const p = m.propSchema;
|
|
522
|
+
c in p && (s[c] = h);
|
|
523
523
|
}
|
|
524
524
|
const l = t[r.contentType.name], a = [];
|
|
525
525
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
526
526
|
a.push(
|
|
527
|
-
|
|
527
|
+
A(n.lastChild.child(c), t, e)
|
|
528
528
|
);
|
|
529
529
|
const d = {
|
|
530
530
|
id: i,
|
|
531
531
|
type: l.node.name,
|
|
532
532
|
props: s,
|
|
533
|
-
content: l.node.config.content === "inline*" ?
|
|
533
|
+
content: l.node.config.content === "inline*" ? Re(r.contentNode) : void 0,
|
|
534
534
|
children: a
|
|
535
535
|
};
|
|
536
536
|
return e == null || e.set(n, d), d;
|
|
537
537
|
}
|
|
538
|
-
const
|
|
538
|
+
const dt = new _("previous-blocks"), ze = {
|
|
539
539
|
// Numbered List Items
|
|
540
540
|
index: "index",
|
|
541
541
|
// Headings
|
|
@@ -544,17 +544,17 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
544
544
|
type: "type",
|
|
545
545
|
depth: "depth",
|
|
546
546
|
"depth-change": "depth-change"
|
|
547
|
-
},
|
|
547
|
+
}, Ve = () => {
|
|
548
548
|
let n;
|
|
549
|
-
return new
|
|
550
|
-
key:
|
|
549
|
+
return new I({
|
|
550
|
+
key: dt,
|
|
551
551
|
view(t) {
|
|
552
552
|
return {
|
|
553
553
|
update: async (e, o) => {
|
|
554
554
|
var r;
|
|
555
555
|
((r = this.key) == null ? void 0 : r.getState(e.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
556
556
|
e.dispatch(
|
|
557
|
-
e.state.tr.setMeta(
|
|
557
|
+
e.state.tr.setMeta(dt, { clearUpdate: !0 })
|
|
558
558
|
);
|
|
559
559
|
}, 0));
|
|
560
560
|
},
|
|
@@ -577,22 +577,22 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
577
577
|
apply(t, e, o, r) {
|
|
578
578
|
if (e.currentTransactionOldBlockAttrs = {}, e.updatedBlocks.clear(), !t.docChanged || o.doc.eq(r.doc))
|
|
579
579
|
return e;
|
|
580
|
-
const i = {}, s =
|
|
580
|
+
const i = {}, s = rt(o.doc, (d) => d.attrs.id), l = new Map(
|
|
581
581
|
s.map((d) => [d.node.attrs.id, d])
|
|
582
|
-
), a =
|
|
582
|
+
), a = rt(r.doc, (d) => d.attrs.id);
|
|
583
583
|
for (const d of a) {
|
|
584
|
-
const c = l.get(d.node.attrs.id),
|
|
585
|
-
if (c &&
|
|
584
|
+
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, m = d.node.firstChild;
|
|
585
|
+
if (c && h && m) {
|
|
586
586
|
const p = {
|
|
587
|
-
index: h.attrs.index,
|
|
588
|
-
level: h.attrs.level,
|
|
589
|
-
type: h.type.name,
|
|
590
|
-
depth: r.doc.resolve(d.pos).depth
|
|
591
|
-
};
|
|
592
|
-
let f = {
|
|
593
587
|
index: m.attrs.index,
|
|
594
588
|
level: m.attrs.level,
|
|
595
589
|
type: m.type.name,
|
|
590
|
+
depth: r.doc.resolve(d.pos).depth
|
|
591
|
+
};
|
|
592
|
+
let f = {
|
|
593
|
+
index: h.attrs.index,
|
|
594
|
+
level: h.attrs.level,
|
|
595
|
+
type: h.type.name,
|
|
596
596
|
depth: o.doc.resolve(c.pos).depth
|
|
597
597
|
};
|
|
598
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));
|
|
@@ -612,69 +612,69 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
612
612
|
return;
|
|
613
613
|
const s = e.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
|
|
614
614
|
for (const [d, c] of Object.entries(s))
|
|
615
|
-
l["data-prev-" +
|
|
616
|
-
const a =
|
|
615
|
+
l["data-prev-" + ze[d]] = c || "none";
|
|
616
|
+
const a = G.node(i, i + r.nodeSize, {
|
|
617
617
|
...l
|
|
618
618
|
});
|
|
619
619
|
o.push(a);
|
|
620
|
-
}),
|
|
620
|
+
}), j.create(t.doc, o);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
});
|
|
624
|
-
},
|
|
625
|
-
blockOuter:
|
|
626
|
-
block:
|
|
627
|
-
reactNodeViewRenderer:
|
|
628
|
-
blockContent:
|
|
629
|
-
blockGroup:
|
|
630
|
-
wrapper:
|
|
631
|
-
addImageButton:
|
|
624
|
+
}, St = "_blockOuter_nstdf_5", Mt = "_block_nstdf_5", Tt = "_reactNodeViewRenderer_nstdf_17", Bt = "_blockContent_nstdf_22", xt = "_blockGroup_nstdf_43", It = "_wrapper_nstdf_227", _t = "_addImageButton_nstdf_235", At = "_addImageButtonIcon_nstdf_251", Ht = "_addImageButtonText_nstdf_257", Lt = "_imageAndCaptionWrapper_nstdf_261", Nt = "_imageWrapper_nstdf_267", Pt = "_image_nstdf_261", Dt = "_resizeHandle_nstdf_280", Ot = "_caption_nstdf_291", Rt = "_isEmpty_nstdf_297", zt = "_inlineContent_nstdf_297", Vt = "_isFilter_nstdf_298", Ut = "_hasAnchor_nstdf_310", k = {
|
|
625
|
+
blockOuter: St,
|
|
626
|
+
block: Mt,
|
|
627
|
+
reactNodeViewRenderer: Tt,
|
|
628
|
+
blockContent: Bt,
|
|
629
|
+
blockGroup: xt,
|
|
630
|
+
wrapper: It,
|
|
631
|
+
addImageButton: _t,
|
|
632
632
|
addImageButtonIcon: At,
|
|
633
|
-
addImageButtonText:
|
|
634
|
-
imageAndCaptionWrapper:
|
|
635
|
-
imageWrapper:
|
|
636
|
-
image:
|
|
637
|
-
resizeHandle:
|
|
638
|
-
caption:
|
|
639
|
-
isEmpty:
|
|
640
|
-
inlineContent:
|
|
641
|
-
isFilter:
|
|
642
|
-
hasAnchor:
|
|
643
|
-
},
|
|
633
|
+
addImageButtonText: Ht,
|
|
634
|
+
imageAndCaptionWrapper: Lt,
|
|
635
|
+
imageWrapper: Nt,
|
|
636
|
+
image: Pt,
|
|
637
|
+
resizeHandle: Dt,
|
|
638
|
+
caption: Ot,
|
|
639
|
+
isEmpty: Rt,
|
|
640
|
+
inlineContent: zt,
|
|
641
|
+
isFilter: Vt,
|
|
642
|
+
hasAnchor: Ut
|
|
643
|
+
}, In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
644
644
|
__proto__: null,
|
|
645
|
-
addImageButton:
|
|
645
|
+
addImageButton: _t,
|
|
646
646
|
addImageButtonIcon: At,
|
|
647
|
-
addImageButtonText:
|
|
648
|
-
block:
|
|
649
|
-
blockContent:
|
|
650
|
-
blockGroup:
|
|
651
|
-
blockOuter:
|
|
652
|
-
caption:
|
|
653
|
-
default:
|
|
654
|
-
hasAnchor:
|
|
655
|
-
image:
|
|
656
|
-
imageAndCaptionWrapper:
|
|
657
|
-
imageWrapper:
|
|
658
|
-
inlineContent:
|
|
659
|
-
isEmpty:
|
|
660
|
-
isFilter:
|
|
661
|
-
reactNodeViewRenderer:
|
|
662
|
-
resizeHandle:
|
|
663
|
-
wrapper:
|
|
664
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
647
|
+
addImageButtonText: Ht,
|
|
648
|
+
block: Mt,
|
|
649
|
+
blockContent: Bt,
|
|
650
|
+
blockGroup: xt,
|
|
651
|
+
blockOuter: St,
|
|
652
|
+
caption: Ot,
|
|
653
|
+
default: k,
|
|
654
|
+
hasAnchor: Ut,
|
|
655
|
+
image: Pt,
|
|
656
|
+
imageAndCaptionWrapper: Lt,
|
|
657
|
+
imageWrapper: Nt,
|
|
658
|
+
inlineContent: zt,
|
|
659
|
+
isEmpty: Rt,
|
|
660
|
+
isFilter: Vt,
|
|
661
|
+
reactNodeViewRenderer: Tt,
|
|
662
|
+
resizeHandle: Dt,
|
|
663
|
+
wrapper: It
|
|
664
|
+
}, Symbol.toStringTag, { value: "Module" })), Ue = {
|
|
665
665
|
blockColor: "data-block-color",
|
|
666
666
|
blockStyle: "data-block-style",
|
|
667
667
|
id: "data-id",
|
|
668
668
|
depth: "data-depth",
|
|
669
669
|
depthChange: "data-depth-change"
|
|
670
|
-
},
|
|
671
|
-
key:
|
|
670
|
+
}, Fe = new _("non-editable-block"), $e = () => new I({
|
|
671
|
+
key: Fe,
|
|
672
672
|
props: {
|
|
673
673
|
handleKeyDown: (n, t) => {
|
|
674
674
|
"node" in n.state.selection && t.preventDefault();
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
|
-
}),
|
|
677
|
+
}), We = q.create({
|
|
678
678
|
name: "blockContainer",
|
|
679
679
|
group: "blockContainer",
|
|
680
680
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -690,7 +690,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
690
690
|
if (typeof n == "string")
|
|
691
691
|
return !1;
|
|
692
692
|
const t = {};
|
|
693
|
-
for (const [e, o] of Object.entries(
|
|
693
|
+
for (const [e, o] of Object.entries(Ue))
|
|
694
694
|
n.getAttribute(o) && (t[e] = n.getAttribute(o));
|
|
695
695
|
return n.getAttribute("data-node-type") === "blockContainer" ? t : !1;
|
|
696
696
|
}
|
|
@@ -702,16 +702,16 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
702
702
|
const t = ((e = this.options.domAttributes) == null ? void 0 : e.blockContainer) || {};
|
|
703
703
|
return [
|
|
704
704
|
"div",
|
|
705
|
-
|
|
706
|
-
class:
|
|
705
|
+
D(n, {
|
|
706
|
+
class: k.blockOuter,
|
|
707
707
|
"data-node-type": "block-outer"
|
|
708
708
|
}),
|
|
709
709
|
[
|
|
710
710
|
"div",
|
|
711
|
-
|
|
711
|
+
D(
|
|
712
712
|
{
|
|
713
713
|
...t,
|
|
714
|
-
class:
|
|
714
|
+
class: B(k.block, t.class),
|
|
715
715
|
"data-node-type": this.name
|
|
716
716
|
},
|
|
717
717
|
n
|
|
@@ -729,7 +729,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
729
729
|
},
|
|
730
730
|
// Deletes a block at a given position.
|
|
731
731
|
BNDeleteBlock: (n) => ({ state: t, dispatch: e }) => {
|
|
732
|
-
const o =
|
|
732
|
+
const o = v(t.doc, n);
|
|
733
733
|
if (o === void 0)
|
|
734
734
|
return !1;
|
|
735
735
|
const { startPos: r, endPos: i } = o;
|
|
@@ -737,7 +737,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
737
737
|
},
|
|
738
738
|
// Updates a block at a given position.
|
|
739
739
|
BNUpdateBlock: (n, t) => ({ state: e, dispatch: o }) => {
|
|
740
|
-
const r =
|
|
740
|
+
const r = v(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;
|
|
@@ -745,11 +745,11 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
745
745
|
if (t.children !== void 0) {
|
|
746
746
|
const p = [];
|
|
747
747
|
for (const f of t.children)
|
|
748
|
-
p.push(
|
|
748
|
+
p.push(F(f, e.schema));
|
|
749
749
|
l.childCount === 2 ? e.tr.replace(
|
|
750
750
|
i + a.nodeSize + 1,
|
|
751
751
|
s - 1,
|
|
752
|
-
new
|
|
752
|
+
new P(O.from(p), 0, 0)
|
|
753
753
|
) : e.tr.insert(
|
|
754
754
|
i + a.nodeSize,
|
|
755
755
|
e.schema.nodes.blockGroup.create({}, p)
|
|
@@ -757,14 +757,14 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
757
757
|
}
|
|
758
758
|
if (t.content !== void 0) {
|
|
759
759
|
let p = [];
|
|
760
|
-
typeof t.content == "string" ? p.push(e.schema.text(t.content)) : p =
|
|
760
|
+
typeof t.content == "string" ? p.push(e.schema.text(t.content)) : p = Et(t.content, e.schema), e.tr.replace(
|
|
761
761
|
i + 1,
|
|
762
762
|
i + a.nodeSize - 1,
|
|
763
|
-
new
|
|
763
|
+
new P(O.from(p), 0, 0)
|
|
764
764
|
);
|
|
765
765
|
}
|
|
766
|
-
const d = a.type.name, c = t.type || d,
|
|
767
|
-
|
|
766
|
+
const d = a.type.name, c = t.type || d, h = e.schema.nodes[d].spec.content, m = e.schema.nodes[c].spec.content;
|
|
767
|
+
h === "inline*" && m === "" ? e.tr.replaceWith(
|
|
768
768
|
i,
|
|
769
769
|
s,
|
|
770
770
|
e.schema.nodes[c].create({
|
|
@@ -772,7 +772,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
772
772
|
...t.props
|
|
773
773
|
})
|
|
774
774
|
).setSelection(
|
|
775
|
-
new
|
|
775
|
+
new ft(e.tr.doc.resolve(i))
|
|
776
776
|
) : e.tr.setNodeMarkup(
|
|
777
777
|
i,
|
|
778
778
|
t.type === void 0 ? void 0 : e.schema.nodes[t.type],
|
|
@@ -808,42 +808,42 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
808
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
|
-
const i =
|
|
811
|
+
const i = v(
|
|
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
816
|
const p = t.doc.resolve(
|
|
817
817
|
a + l.nodeSize + 1
|
|
818
|
-
), f = t.doc.resolve(d - 1),
|
|
819
|
-
e && t.tr.lift(
|
|
818
|
+
), f = t.doc.resolve(d - 1), b = p.blockRange(f);
|
|
819
|
+
e && t.tr.lift(b, c - 1);
|
|
820
820
|
}
|
|
821
|
-
let
|
|
822
|
-
for (;
|
|
823
|
-
if (
|
|
821
|
+
let h = n - 1, m = v(t.doc, h);
|
|
822
|
+
for (; m.numChildBlocks > 0; )
|
|
823
|
+
if (h--, m = v(t.doc, h), m === void 0)
|
|
824
824
|
return !1;
|
|
825
825
|
return e && (e(
|
|
826
826
|
t.tr.deleteRange(a, a + l.nodeSize).replace(
|
|
827
|
-
|
|
827
|
+
h - 1,
|
|
828
828
|
a,
|
|
829
|
-
new
|
|
829
|
+
new P(l.content, 0, 0)
|
|
830
830
|
).scrollIntoView()
|
|
831
831
|
), t.tr.setSelection(
|
|
832
|
-
new
|
|
832
|
+
new st(t.doc.resolve(h - 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
837
|
BNSplitBlock: (n, t) => ({ state: e, dispatch: o }) => {
|
|
838
|
-
const r =
|
|
838
|
+
const r = v(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 = e.doc.cut(l + 1, n),
|
|
842
|
-
return o && (e.tr.insert(p,
|
|
841
|
+
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = e.doc.cut(l + 1, n), h = e.doc.cut(n, a - 1), m = e.schema.nodes.blockContainer.createAndFill(), p = a + 1, f = p + 2;
|
|
842
|
+
return o && (e.tr.insert(p, m), e.tr.replace(
|
|
843
843
|
f,
|
|
844
844
|
f + 1,
|
|
845
|
-
|
|
846
|
-
|
|
845
|
+
h.content.size > 0 ? new P(
|
|
846
|
+
O.from(h),
|
|
847
847
|
d + 2,
|
|
848
848
|
d + 2
|
|
849
849
|
) : void 0
|
|
@@ -853,12 +853,12 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
853
853
|
e.schema.node(s).type,
|
|
854
854
|
i.attrs
|
|
855
855
|
), e.tr.setSelection(
|
|
856
|
-
new
|
|
856
|
+
new st(e.doc.resolve(f))
|
|
857
857
|
), e.tr.replace(
|
|
858
858
|
l + 1,
|
|
859
859
|
a - 1,
|
|
860
|
-
c.content.size > 0 ? new
|
|
861
|
-
|
|
860
|
+
c.content.size > 0 ? new P(
|
|
861
|
+
O.from(c),
|
|
862
862
|
d + 2,
|
|
863
863
|
d + 2
|
|
864
864
|
) : void 0
|
|
@@ -867,7 +867,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
867
867
|
};
|
|
868
868
|
},
|
|
869
869
|
addProseMirrorPlugins() {
|
|
870
|
-
return [
|
|
870
|
+
return [Ve(), $e()];
|
|
871
871
|
},
|
|
872
872
|
addKeyboardShortcuts() {
|
|
873
873
|
return {
|
|
@@ -878,7 +878,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
878
878
|
() => o.undoInputRule(),
|
|
879
879
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
880
880
|
() => o.command(({ state: r }) => {
|
|
881
|
-
const { contentType: i } =
|
|
881
|
+
const { contentType: i } = v(
|
|
882
882
|
r.doc,
|
|
883
883
|
r.selection.from
|
|
884
884
|
), s = r.selection.$anchor.parentOffset === 0, l = i.name === "paragraph";
|
|
@@ -892,7 +892,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
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
894
|
() => o.command(({ state: r }) => {
|
|
895
|
-
const { depth: i, startPos: s } =
|
|
895
|
+
const { depth: i, startPos: s } = v(
|
|
896
896
|
r.doc,
|
|
897
897
|
r.selection.from
|
|
898
898
|
), l = r.selection.$anchor.parentOffset === 0, a = r.selection.anchor === r.selection.head, d = s === 2, c = s - 1;
|
|
@@ -906,14 +906,14 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
906
906
|
// if one exists, the block has no children, and the selection is at the
|
|
907
907
|
// end of the block.
|
|
908
908
|
() => o.command(({ state: r }) => {
|
|
909
|
-
const { node: i, contentNode: s, depth: l, endPos: a } =
|
|
909
|
+
const { node: i, contentNode: s, depth: l, endPos: a } = v(
|
|
910
910
|
r.doc,
|
|
911
911
|
r.selection.from
|
|
912
|
-
), d = r.selection.$anchor.parentOffset === s.firstChild.nodeSize, c = r.selection.anchor === r.selection.head,
|
|
913
|
-
if (d && c && !
|
|
914
|
-
let
|
|
915
|
-
for (; f <
|
|
916
|
-
|
|
912
|
+
), d = r.selection.$anchor.parentOffset === s.firstChild.nodeSize, c = r.selection.anchor === r.selection.head, h = i.childCount === 2;
|
|
913
|
+
if (d && c && !h) {
|
|
914
|
+
let m = l, p = a + 2, f = r.doc.resolve(p).depth;
|
|
915
|
+
for (; f < m; )
|
|
916
|
+
m = f, p += 2, f = r.doc.resolve(p).depth;
|
|
917
917
|
return o.BNMergeBlocks(p - 1);
|
|
918
918
|
}
|
|
919
919
|
return !1;
|
|
@@ -923,7 +923,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
923
923
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
924
924
|
// of the block.
|
|
925
925
|
() => o.command(({ state: r }) => {
|
|
926
|
-
const { node: i, depth: s } =
|
|
926
|
+
const { node: i, depth: s } = v(
|
|
927
927
|
r.doc,
|
|
928
928
|
r.selection.from
|
|
929
929
|
), l = r.selection.$anchor.parentOffset === 0, a = r.selection.anchor === r.selection.head, d = i.textContent.length === 0, c = s > 2;
|
|
@@ -932,20 +932,20 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
932
932
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
933
933
|
// empty & at the start of the block.
|
|
934
934
|
() => o.command(({ state: r, chain: i }) => {
|
|
935
|
-
const { node: s, endPos: l } =
|
|
935
|
+
const { node: s, endPos: l } = v(
|
|
936
936
|
r.doc,
|
|
937
937
|
r.selection.from
|
|
938
938
|
), a = r.selection.$anchor.parentOffset === 0, d = r.selection.anchor === r.selection.head, c = s.textContent.length === 0;
|
|
939
939
|
if (a && d && c) {
|
|
940
|
-
const
|
|
941
|
-
return i().BNCreateBlock(
|
|
940
|
+
const h = l + 1, m = h + 2;
|
|
941
|
+
return i().BNCreateBlock(h).setTextSelection(m).run(), !0;
|
|
942
942
|
}
|
|
943
943
|
return !1;
|
|
944
944
|
}),
|
|
945
945
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
946
946
|
// deletes the selection beforehand, if it's not empty.
|
|
947
947
|
() => o.command(({ state: r, chain: i }) => {
|
|
948
|
-
const { node: s } =
|
|
948
|
+
const { node: s } = v(
|
|
949
949
|
r.doc,
|
|
950
950
|
r.selection.from
|
|
951
951
|
), l = r.selection.$anchor.parentOffset === 0;
|
|
@@ -961,7 +961,7 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
961
961
|
)
|
|
962
962
|
};
|
|
963
963
|
}
|
|
964
|
-
}),
|
|
964
|
+
}), Ge = q.create({
|
|
965
965
|
name: "blockGroup",
|
|
966
966
|
group: "blockGroup",
|
|
967
967
|
content: "blockContainer+",
|
|
@@ -978,11 +978,11 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
978
978
|
const t = ((e = this.options.domAttributes) == null ? void 0 : e.blockGroup) || {};
|
|
979
979
|
return [
|
|
980
980
|
"div",
|
|
981
|
-
|
|
981
|
+
D(
|
|
982
982
|
{
|
|
983
983
|
...t,
|
|
984
|
-
class:
|
|
985
|
-
|
|
984
|
+
class: B(
|
|
985
|
+
k.blockGroup,
|
|
986
986
|
t.class
|
|
987
987
|
),
|
|
988
988
|
"data-node-type": "blockGroup"
|
|
@@ -992,13 +992,13 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
992
992
|
0
|
|
993
993
|
];
|
|
994
994
|
}
|
|
995
|
-
}),
|
|
995
|
+
}), je = q.create({
|
|
996
996
|
name: "doc",
|
|
997
997
|
topNode: !0,
|
|
998
998
|
content: "blockGroup"
|
|
999
|
-
}),
|
|
1000
|
-
const t =
|
|
1001
|
-
return new
|
|
999
|
+
}), qe = (n) => {
|
|
1000
|
+
const t = J.fromSchema(n);
|
|
1001
|
+
return new J(
|
|
1002
1002
|
{
|
|
1003
1003
|
...t.nodes
|
|
1004
1004
|
// TODO: If a serializer is defined in the config for a custom block, it
|
|
@@ -1008,18 +1008,18 @@ const lt = new M("previous-blocks"), Re = {
|
|
|
1008
1008
|
},
|
|
1009
1009
|
t.marks
|
|
1010
1010
|
);
|
|
1011
|
-
},
|
|
1011
|
+
}, Xe = L.create({
|
|
1012
1012
|
addProseMirrorPlugins() {
|
|
1013
1013
|
return [
|
|
1014
|
-
new
|
|
1014
|
+
new I({
|
|
1015
1015
|
props: {
|
|
1016
|
-
clipboardSerializer:
|
|
1016
|
+
clipboardSerializer: qe(this.editor.schema)
|
|
1017
1017
|
}
|
|
1018
1018
|
})
|
|
1019
1019
|
];
|
|
1020
1020
|
}
|
|
1021
1021
|
});
|
|
1022
|
-
class
|
|
1022
|
+
class $ {
|
|
1023
1023
|
constructor() {
|
|
1024
1024
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1025
1025
|
u(this, "callbacks", {});
|
|
@@ -1039,10 +1039,10 @@ class U {
|
|
|
1039
1039
|
this.callbacks = {};
|
|
1040
1040
|
}
|
|
1041
1041
|
}
|
|
1042
|
-
const
|
|
1042
|
+
const Ke = oe(
|
|
1043
1043
|
(n) => n.type.name === "blockContainer"
|
|
1044
1044
|
);
|
|
1045
|
-
class
|
|
1045
|
+
class Ye {
|
|
1046
1046
|
constructor(t, e, o = () => {
|
|
1047
1047
|
}) {
|
|
1048
1048
|
u(this, "suggestionsMenuState");
|
|
@@ -1057,7 +1057,7 @@ class Ke {
|
|
|
1057
1057
|
this.suggestionsMenuState.referencePos = e.getBoundingClientRect(), this.updateSuggestionsMenu();
|
|
1058
1058
|
}
|
|
1059
1059
|
});
|
|
1060
|
-
this.editor = t, this.pluginKey = e, this.pluginState =
|
|
1060
|
+
this.editor = t, this.pluginKey = e, this.pluginState = Z(), this.updateSuggestionsMenu = () => {
|
|
1061
1061
|
if (!this.suggestionsMenuState)
|
|
1062
1062
|
throw new Error("Attempting to update uninitialized suggestions menu");
|
|
1063
1063
|
o(this.suggestionsMenuState);
|
|
@@ -1085,7 +1085,7 @@ class Ke {
|
|
|
1085
1085
|
document.removeEventListener("scroll", this.handleScroll);
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
|
-
function
|
|
1088
|
+
function Z() {
|
|
1089
1089
|
return {
|
|
1090
1090
|
active: !1,
|
|
1091
1091
|
triggerCharacter: void 0,
|
|
@@ -1096,7 +1096,7 @@ function J() {
|
|
|
1096
1096
|
decorationId: void 0
|
|
1097
1097
|
};
|
|
1098
1098
|
}
|
|
1099
|
-
const
|
|
1099
|
+
const Je = (n, t, e, o, r = () => [], i = () => {
|
|
1100
1100
|
}) => {
|
|
1101
1101
|
if (o.length !== 1)
|
|
1102
1102
|
throw new Error("'char' should be a single character");
|
|
@@ -1105,9 +1105,9 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1105
1105
|
a.dispatch(a.state.tr.setMeta(e, { deactivate: !0 }));
|
|
1106
1106
|
};
|
|
1107
1107
|
return {
|
|
1108
|
-
plugin: new
|
|
1108
|
+
plugin: new I({
|
|
1109
1109
|
key: e,
|
|
1110
|
-
view: () => (s = new
|
|
1110
|
+
view: () => (s = new Ye(
|
|
1111
1111
|
n,
|
|
1112
1112
|
e,
|
|
1113
1113
|
t
|
|
@@ -1115,18 +1115,18 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1115
1115
|
state: {
|
|
1116
1116
|
// Initialize the plugin's internal state.
|
|
1117
1117
|
init() {
|
|
1118
|
-
return
|
|
1118
|
+
return Z();
|
|
1119
1119
|
},
|
|
1120
1120
|
// Apply changes to the plugin state from an editor transaction.
|
|
1121
|
-
apply(a, d, c,
|
|
1122
|
-
var p, f,
|
|
1121
|
+
apply(a, d, c, h) {
|
|
1122
|
+
var p, f, b, w;
|
|
1123
1123
|
if (a.getMeta("orderedListIndexing") !== void 0)
|
|
1124
1124
|
return d;
|
|
1125
1125
|
if ((p = a.getMeta(e)) != null && p.activate)
|
|
1126
1126
|
return {
|
|
1127
1127
|
active: !0,
|
|
1128
1128
|
triggerCharacter: ((f = a.getMeta(e)) == null ? void 0 : f.triggerCharacter) || "",
|
|
1129
|
-
queryStartPos:
|
|
1129
|
+
queryStartPos: h.selection.from,
|
|
1130
1130
|
items: r(""),
|
|
1131
1131
|
keyboardHoveredItemIndex: 0,
|
|
1132
1132
|
// TODO: Maybe should be 1 if the menu has no possible items? Probably redundant since a menu with no items
|
|
@@ -1136,30 +1136,30 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1136
1136
|
};
|
|
1137
1137
|
if (!d.active)
|
|
1138
1138
|
return d;
|
|
1139
|
-
const
|
|
1140
|
-
if (
|
|
1141
|
-
|
|
1139
|
+
const m = { ...d };
|
|
1140
|
+
if (m.items = r(
|
|
1141
|
+
h.doc.textBetween(
|
|
1142
1142
|
d.queryStartPos,
|
|
1143
|
-
|
|
1143
|
+
h.selection.from
|
|
1144
1144
|
)
|
|
1145
|
-
),
|
|
1145
|
+
), m.notFoundCount = 0, m.items.length === 0 && (m.notFoundCount = Math.max(
|
|
1146
1146
|
0,
|
|
1147
|
-
d.notFoundCount + (
|
|
1147
|
+
d.notFoundCount + (h.selection.from - c.selection.from)
|
|
1148
1148
|
)), // Highlighting text should hide the menu.
|
|
1149
|
-
|
|
1150
|
-
(
|
|
1149
|
+
h.selection.from !== h.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
|
|
1150
|
+
(b = a.getMeta(e)) != null && b.deactivate || // Certain mouse events should hide the menu.
|
|
1151
1151
|
// TODO: Change to global mousedown listener.
|
|
1152
1152
|
a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1153
|
-
d.active &&
|
|
1153
|
+
d.active && h.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
|
|
1154
1154
|
// the menu.
|
|
1155
|
-
|
|
1156
|
-
return
|
|
1157
|
-
if (((
|
|
1158
|
-
let
|
|
1159
|
-
|
|
1155
|
+
m.notFoundCount > 3)
|
|
1156
|
+
return Z();
|
|
1157
|
+
if (((w = a.getMeta(e)) == null ? void 0 : w.selectedItemIndexChanged) !== void 0) {
|
|
1158
|
+
let C = a.getMeta(e).selectedItemIndexChanged;
|
|
1159
|
+
C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0), m.keyboardHoveredItemIndex = C;
|
|
1160
1160
|
} else
|
|
1161
|
-
c.selection.from !==
|
|
1162
|
-
return
|
|
1161
|
+
c.selection.from !== h.selection.from && (m.keyboardHoveredItemIndex = 0);
|
|
1162
|
+
return m;
|
|
1163
1163
|
}
|
|
1164
1164
|
},
|
|
1165
1165
|
props: {
|
|
@@ -1175,8 +1175,8 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1175
1175
|
if (!c)
|
|
1176
1176
|
return !1;
|
|
1177
1177
|
const {
|
|
1178
|
-
triggerCharacter:
|
|
1179
|
-
queryStartPos:
|
|
1178
|
+
triggerCharacter: h,
|
|
1179
|
+
queryStartPos: m,
|
|
1180
1180
|
items: p,
|
|
1181
1181
|
keyboardHoveredItemIndex: f
|
|
1182
1182
|
} = e.getState(a.state);
|
|
@@ -1189,7 +1189,7 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1189
1189
|
selectedItemIndexChanged: f + 1
|
|
1190
1190
|
})
|
|
1191
1191
|
), !0) : d.key === "Enter" ? (p.length === 0 || (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1192
|
-
from:
|
|
1192
|
+
from: m - h.length,
|
|
1193
1193
|
to: n._tiptapEditor.state.selection.from
|
|
1194
1194
|
}).run(), i({
|
|
1195
1195
|
item: p[f],
|
|
@@ -1198,14 +1198,14 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1198
1198
|
},
|
|
1199
1199
|
// Setup decorator on the currently active suggestion.
|
|
1200
1200
|
decorations(a) {
|
|
1201
|
-
const { active: d, decorationId: c, queryStartPos:
|
|
1201
|
+
const { active: d, decorationId: c, queryStartPos: h, triggerCharacter: m } = this.getState(a);
|
|
1202
1202
|
if (!d)
|
|
1203
1203
|
return null;
|
|
1204
|
-
if (
|
|
1205
|
-
const p =
|
|
1204
|
+
if (m === "") {
|
|
1205
|
+
const p = Ke(a.selection);
|
|
1206
1206
|
if (p)
|
|
1207
|
-
return
|
|
1208
|
-
|
|
1207
|
+
return j.create(a.doc, [
|
|
1208
|
+
G.node(
|
|
1209
1209
|
p.pos,
|
|
1210
1210
|
p.pos + p.node.nodeSize,
|
|
1211
1211
|
{
|
|
@@ -1216,10 +1216,10 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1216
1216
|
)
|
|
1217
1217
|
]);
|
|
1218
1218
|
}
|
|
1219
|
-
return
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1219
|
+
return j.create(a.doc, [
|
|
1220
|
+
G.inline(
|
|
1221
|
+
h - m.length,
|
|
1222
|
+
h,
|
|
1223
1223
|
{
|
|
1224
1224
|
nodeName: "span",
|
|
1225
1225
|
class: "suggestion-decorator",
|
|
@@ -1240,18 +1240,18 @@ const Ye = (n, t, e, o, r = () => [], i = () => {
|
|
|
1240
1240
|
});
|
|
1241
1241
|
}
|
|
1242
1242
|
};
|
|
1243
|
-
},
|
|
1244
|
-
class
|
|
1243
|
+
}, et = new _("SlashMenuPlugin");
|
|
1244
|
+
class Ze extends $ {
|
|
1245
1245
|
constructor(e, o) {
|
|
1246
1246
|
super();
|
|
1247
1247
|
u(this, "plugin");
|
|
1248
1248
|
u(this, "itemCallback");
|
|
1249
|
-
const r =
|
|
1249
|
+
const r = Je(
|
|
1250
1250
|
e,
|
|
1251
1251
|
(i) => {
|
|
1252
1252
|
this.emit("update", i);
|
|
1253
1253
|
},
|
|
1254
|
-
|
|
1254
|
+
et,
|
|
1255
1255
|
"/",
|
|
1256
1256
|
(i) => o.filter(
|
|
1257
1257
|
({ name: s, aliases: l }) => s.toLowerCase().startsWith(i.toLowerCase()) || l && l.filter(
|
|
@@ -1266,7 +1266,7 @@ class Je extends U {
|
|
|
1266
1266
|
return this.on("update", e);
|
|
1267
1267
|
}
|
|
1268
1268
|
}
|
|
1269
|
-
const
|
|
1269
|
+
const Qe = new _("blocknote-placeholder"), to = L.create({
|
|
1270
1270
|
name: "placeholder",
|
|
1271
1271
|
addOptions() {
|
|
1272
1272
|
return {
|
|
@@ -1282,30 +1282,30 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1282
1282
|
},
|
|
1283
1283
|
addProseMirrorPlugins() {
|
|
1284
1284
|
return [
|
|
1285
|
-
new
|
|
1286
|
-
key:
|
|
1285
|
+
new I({
|
|
1286
|
+
key: Qe,
|
|
1287
1287
|
props: {
|
|
1288
1288
|
decorations: (n) => {
|
|
1289
|
-
const { doc: t, selection: e } = n, o =
|
|
1289
|
+
const { doc: t, selection: e } = n, o = et.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = e, s = [];
|
|
1290
1290
|
if (r)
|
|
1291
1291
|
return t.descendants((l, a) => {
|
|
1292
1292
|
const d = i >= a && i <= a + l.nodeSize, c = !l.isLeaf && !l.childCount;
|
|
1293
1293
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
1294
|
-
const
|
|
1295
|
-
this.editor.isEmpty &&
|
|
1296
|
-
const
|
|
1297
|
-
class:
|
|
1294
|
+
const h = [this.options.emptyNodeClass];
|
|
1295
|
+
this.editor.isEmpty && h.push(this.options.emptyEditorClass), d && h.push(this.options.hasAnchorClass), (o == null ? void 0 : o.triggerCharacter) === "" && (o != null && o.active) && h.push(this.options.isFilterClass);
|
|
1296
|
+
const m = G.node(a, a + l.nodeSize, {
|
|
1297
|
+
class: h.join(" ")
|
|
1298
1298
|
});
|
|
1299
|
-
s.push(
|
|
1299
|
+
s.push(m);
|
|
1300
1300
|
}
|
|
1301
1301
|
return this.options.includeChildren;
|
|
1302
|
-
}),
|
|
1302
|
+
}), j.create(t, s);
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
1305
|
})
|
|
1306
1306
|
];
|
|
1307
1307
|
}
|
|
1308
|
-
}),
|
|
1308
|
+
}), eo = L.create({
|
|
1309
1309
|
name: "textAlignment",
|
|
1310
1310
|
addGlobalAttributes() {
|
|
1311
1311
|
return [
|
|
@@ -1328,7 +1328,7 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1328
1328
|
addCommands() {
|
|
1329
1329
|
return {
|
|
1330
1330
|
setTextAlignment: (n) => ({ state: t }) => {
|
|
1331
|
-
const e = [], o =
|
|
1331
|
+
const e = [], o = v(
|
|
1332
1332
|
t.doc,
|
|
1333
1333
|
t.selection.from
|
|
1334
1334
|
);
|
|
@@ -1343,7 +1343,7 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1343
1343
|
}
|
|
1344
1344
|
};
|
|
1345
1345
|
}
|
|
1346
|
-
}),
|
|
1346
|
+
}), oo = L.create({
|
|
1347
1347
|
name: "blockTextColor",
|
|
1348
1348
|
addGlobalAttributes() {
|
|
1349
1349
|
return [
|
|
@@ -1351,9 +1351,9 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1351
1351
|
types: ["blockContainer"],
|
|
1352
1352
|
attributes: {
|
|
1353
1353
|
textColor: {
|
|
1354
|
-
default:
|
|
1355
|
-
parseHTML: (n) => n.hasAttribute("data-text-color") ? n.getAttribute("data-text-color") :
|
|
1356
|
-
renderHTML: (n) => n.textColor !==
|
|
1354
|
+
default: T.textColor.default,
|
|
1355
|
+
parseHTML: (n) => n.hasAttribute("data-text-color") ? n.getAttribute("data-text-color") : T.textColor.default,
|
|
1356
|
+
renderHTML: (n) => n.textColor !== T.textColor.default && {
|
|
1357
1357
|
"data-text-color": n.textColor
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
@@ -1364,12 +1364,12 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1364
1364
|
addCommands() {
|
|
1365
1365
|
return {
|
|
1366
1366
|
setBlockTextColor: (n, t) => ({ state: e, view: o }) => {
|
|
1367
|
-
const r =
|
|
1367
|
+
const r = v(e.doc, n);
|
|
1368
1368
|
return r === void 0 ? !1 : (e.tr.setNodeAttribute(r.startPos - 1, "textColor", t), o.focus(), !0);
|
|
1369
1369
|
}
|
|
1370
1370
|
};
|
|
1371
1371
|
}
|
|
1372
|
-
}),
|
|
1372
|
+
}), no = mt.create({
|
|
1373
1373
|
name: "textColor",
|
|
1374
1374
|
addAttributes() {
|
|
1375
1375
|
return {
|
|
@@ -1395,15 +1395,15 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1395
1395
|
},
|
|
1396
1396
|
addCommands() {
|
|
1397
1397
|
return {
|
|
1398
|
-
setTextColor: (n) => ({ commands: t }) => n !==
|
|
1398
|
+
setTextColor: (n) => ({ commands: t }) => n !== T.textColor.default ? t.setMark(this.name, { color: n }) : t.unsetMark(this.name)
|
|
1399
1399
|
};
|
|
1400
1400
|
}
|
|
1401
|
-
}),
|
|
1401
|
+
}), ro = L.create({
|
|
1402
1402
|
name: "trailingNode",
|
|
1403
1403
|
addProseMirrorPlugins() {
|
|
1404
|
-
const n = new
|
|
1404
|
+
const n = new _(this.name);
|
|
1405
1405
|
return [
|
|
1406
|
-
new
|
|
1406
|
+
new I({
|
|
1407
1407
|
key: n,
|
|
1408
1408
|
appendTransaction: (t, e, o) => {
|
|
1409
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;
|
|
@@ -1433,49 +1433,49 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1433
1433
|
})
|
|
1434
1434
|
];
|
|
1435
1435
|
}
|
|
1436
|
-
}),
|
|
1436
|
+
}), io = (n) => {
|
|
1437
1437
|
var e;
|
|
1438
1438
|
const t = [
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1439
|
+
V.ClipboardTextSerializer,
|
|
1440
|
+
V.Commands,
|
|
1441
|
+
V.Editable,
|
|
1442
|
+
V.FocusEvents,
|
|
1443
|
+
V.Tabindex,
|
|
1444
1444
|
// DevTools,
|
|
1445
|
-
|
|
1445
|
+
ue,
|
|
1446
1446
|
// DropCursor,
|
|
1447
|
-
|
|
1448
|
-
emptyNodeClass:
|
|
1449
|
-
hasAnchorClass:
|
|
1450
|
-
isFilterClass:
|
|
1447
|
+
to.configure({
|
|
1448
|
+
emptyNodeClass: k.isEmpty,
|
|
1449
|
+
hasAnchorClass: k.hasAnchor,
|
|
1450
|
+
isFilterClass: k.isFilter,
|
|
1451
1451
|
includeChildren: !0,
|
|
1452
1452
|
showOnlyCurrent: !1
|
|
1453
1453
|
}),
|
|
1454
|
-
|
|
1454
|
+
X.configure({
|
|
1455
1455
|
types: ["blockContainer"]
|
|
1456
1456
|
}),
|
|
1457
|
-
|
|
1457
|
+
pe,
|
|
1458
1458
|
// Comments,
|
|
1459
1459
|
// basics:
|
|
1460
|
-
|
|
1460
|
+
ke,
|
|
1461
1461
|
// marks:
|
|
1462
|
-
ie,
|
|
1463
1462
|
se,
|
|
1464
|
-
|
|
1465
|
-
fe,
|
|
1466
|
-
ke,
|
|
1463
|
+
ae,
|
|
1467
1464
|
me,
|
|
1465
|
+
ge,
|
|
1466
|
+
be,
|
|
1467
|
+
fe,
|
|
1468
|
+
no,
|
|
1468
1469
|
oo,
|
|
1469
|
-
|
|
1470
|
-
_e,
|
|
1470
|
+
He,
|
|
1471
1471
|
Ae,
|
|
1472
|
-
|
|
1472
|
+
eo,
|
|
1473
1473
|
// nodes
|
|
1474
|
-
|
|
1475
|
-
|
|
1474
|
+
je,
|
|
1475
|
+
We.configure({
|
|
1476
1476
|
domAttributes: n.domAttributes
|
|
1477
1477
|
}),
|
|
1478
|
-
|
|
1478
|
+
Ge.configure({
|
|
1479
1479
|
domAttributes: n.domAttributes
|
|
1480
1480
|
}),
|
|
1481
1481
|
...Object.values(n.blockSchema).map(
|
|
@@ -1484,28 +1484,28 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1484
1484
|
domAttributes: n.domAttributes
|
|
1485
1485
|
})
|
|
1486
1486
|
),
|
|
1487
|
-
|
|
1488
|
-
|
|
1487
|
+
Xe,
|
|
1488
|
+
ce.configure({ width: 5, color: "#ddeeff" }),
|
|
1489
1489
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
1490
1490
|
// should be handled before Enter handlers in other components like splitListItem
|
|
1491
|
-
|
|
1491
|
+
ro
|
|
1492
1492
|
];
|
|
1493
1493
|
if (n.collaboration) {
|
|
1494
1494
|
if (t.push(
|
|
1495
|
-
|
|
1495
|
+
le.configure({
|
|
1496
1496
|
fragment: n.collaboration.fragment
|
|
1497
1497
|
})
|
|
1498
1498
|
), (e = n.collaboration.provider) != null && e.awareness) {
|
|
1499
1499
|
const o = (r) => {
|
|
1500
1500
|
const i = document.createElement("span");
|
|
1501
|
-
i.classList.add(
|
|
1501
|
+
i.classList.add(R["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
|
|
1502
1502
|
const s = document.createElement("span");
|
|
1503
|
-
s.classList.add(
|
|
1503
|
+
s.classList.add(R["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
|
|
1504
1504
|
const l = document.createTextNode(""), a = document.createTextNode("");
|
|
1505
1505
|
return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
|
|
1506
1506
|
};
|
|
1507
1507
|
t.push(
|
|
1508
|
-
|
|
1508
|
+
de.configure({
|
|
1509
1509
|
user: n.collaboration.user,
|
|
1510
1510
|
render: n.collaboration.renderCursor || o,
|
|
1511
1511
|
provider: n.collaboration.provider
|
|
@@ -1513,10 +1513,10 @@ const Ze = new M("blocknote-placeholder"), Qe = A.create({
|
|
|
1513
1513
|
);
|
|
1514
1514
|
}
|
|
1515
1515
|
} else
|
|
1516
|
-
t.push(
|
|
1516
|
+
t.push(he);
|
|
1517
1517
|
return t;
|
|
1518
1518
|
};
|
|
1519
|
-
function
|
|
1519
|
+
function ot(n, t) {
|
|
1520
1520
|
let e, o;
|
|
1521
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)
|
|
1522
1522
|
throw Error("Could not find block in the editor with matching ID.");
|
|
@@ -1525,12 +1525,12 @@ function et(n, t) {
|
|
|
1525
1525
|
posBeforeNode: o
|
|
1526
1526
|
};
|
|
1527
1527
|
}
|
|
1528
|
-
function
|
|
1528
|
+
function Ft(n, t, e = "before", o) {
|
|
1529
1529
|
const r = typeof t == "string" ? t : t.id, i = [];
|
|
1530
1530
|
for (const d of n)
|
|
1531
|
-
i.push(
|
|
1531
|
+
i.push(F(d, o.schema));
|
|
1532
1532
|
let s = -1;
|
|
1533
|
-
const { node: l, posBeforeNode: a } =
|
|
1533
|
+
const { node: l, posBeforeNode: a } = ot(r, o.state.doc);
|
|
1534
1534
|
if (e === "before" && (s = a), e === "after" && (s = a + l.nodeSize), e === "nested") {
|
|
1535
1535
|
if (l.childCount < 2) {
|
|
1536
1536
|
s = a + l.firstChild.nodeSize + 1;
|
|
@@ -1547,11 +1547,11 @@ function Ut(n, t, e = "before", o) {
|
|
|
1547
1547
|
}
|
|
1548
1548
|
o.view.dispatch(o.state.tr.insert(s, i));
|
|
1549
1549
|
}
|
|
1550
|
-
function
|
|
1551
|
-
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } =
|
|
1550
|
+
function so(n, t, e) {
|
|
1551
|
+
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = ot(o, e.state.doc);
|
|
1552
1552
|
e.commands.BNUpdateBlock(r + 1, t);
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1554
|
+
function $t(n, t) {
|
|
1555
1555
|
const e = new Set(
|
|
1556
1556
|
n.map(
|
|
1557
1557
|
(r) => typeof r == "string" ? r : r.id
|
|
@@ -1576,10 +1576,10 @@ function Ft(n, t) {
|
|
|
1576
1576
|
);
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
|
-
function
|
|
1580
|
-
|
|
1579
|
+
function ao(n, t, e) {
|
|
1580
|
+
Ft(t, n[0], "before", e), $t(n, e);
|
|
1581
1581
|
}
|
|
1582
|
-
function
|
|
1582
|
+
function lo() {
|
|
1583
1583
|
const n = (t) => {
|
|
1584
1584
|
let e = t.children.length;
|
|
1585
1585
|
for (let o = 0; o < e; o++) {
|
|
@@ -1595,19 +1595,19 @@ function ao() {
|
|
|
1595
1595
|
};
|
|
1596
1596
|
return n;
|
|
1597
1597
|
}
|
|
1598
|
-
function
|
|
1598
|
+
function co(n) {
|
|
1599
1599
|
const t = /* @__PURE__ */ new Set([
|
|
1600
1600
|
...n.orderedListItemBlockTypes,
|
|
1601
1601
|
...n.unorderedListItemBlockTypes
|
|
1602
1602
|
]), e = (o) => {
|
|
1603
1603
|
let r = o.children.length, i;
|
|
1604
1604
|
for (let s = 0; s < r; s++) {
|
|
1605
|
-
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null,
|
|
1605
|
+
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, h = t.has(
|
|
1606
1606
|
d.properties.dataContentType
|
|
1607
|
-
),
|
|
1607
|
+
), m = h ? n.orderedListItemBlockTypes.has(
|
|
1608
1608
|
d.properties.dataContentType
|
|
1609
1609
|
) ? "ol" : "ul" : null;
|
|
1610
|
-
if (c !== null && e(c), i && i.tagName !==
|
|
1610
|
+
if (c !== null && e(c), i && i.tagName !== m) {
|
|
1611
1611
|
o.children.splice(
|
|
1612
1612
|
s - i.children.length,
|
|
1613
1613
|
i.children.length,
|
|
@@ -1616,11 +1616,11 @@ function lo(n) {
|
|
|
1616
1616
|
const p = i.children.length - 1;
|
|
1617
1617
|
s -= p, r -= p, i = void 0;
|
|
1618
1618
|
}
|
|
1619
|
-
if (
|
|
1620
|
-
i || (i =
|
|
1621
|
-
document.createElement(
|
|
1619
|
+
if (h) {
|
|
1620
|
+
i || (i = at(
|
|
1621
|
+
document.createElement(m)
|
|
1622
1622
|
));
|
|
1623
|
-
const p =
|
|
1623
|
+
const p = at(
|
|
1624
1624
|
document.createElement("li")
|
|
1625
1625
|
);
|
|
1626
1626
|
p.children.push(d.children[0]), c !== null && p.children.push(...c.children), i.children.push(p);
|
|
@@ -1639,29 +1639,29 @@ function lo(n) {
|
|
|
1639
1639
|
};
|
|
1640
1640
|
return e;
|
|
1641
1641
|
}
|
|
1642
|
-
async function
|
|
1643
|
-
const e = document.createElement("div"), o =
|
|
1642
|
+
async function Wt(n, t) {
|
|
1643
|
+
const e = document.createElement("div"), o = J.fromSchema(t);
|
|
1644
1644
|
for (const i of n) {
|
|
1645
|
-
const s =
|
|
1645
|
+
const s = F(i, t), l = o.serializeNode(s);
|
|
1646
1646
|
e.appendChild(l);
|
|
1647
1647
|
}
|
|
1648
|
-
return (await
|
|
1648
|
+
return (await tt().use(gt, { fragment: !0 }).use(co, {
|
|
1649
1649
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
1650
1650
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
1651
|
-
}).use(
|
|
1651
|
+
}).use(kt).process(e.innerHTML)).value;
|
|
1652
1652
|
}
|
|
1653
|
-
async function
|
|
1653
|
+
async function Gt(n, t, e) {
|
|
1654
1654
|
const o = document.createElement("div");
|
|
1655
1655
|
o.innerHTML = n.trim();
|
|
1656
|
-
const i =
|
|
1656
|
+
const i = ye.fromSchema(e).parse(o), s = [];
|
|
1657
1657
|
for (let l = 0; l < i.firstChild.childCount; l++)
|
|
1658
|
-
s.push(
|
|
1658
|
+
s.push(A(i.firstChild.child(l), t));
|
|
1659
1659
|
return s;
|
|
1660
1660
|
}
|
|
1661
|
-
async function
|
|
1662
|
-
return (await
|
|
1661
|
+
async function uo(n, t) {
|
|
1662
|
+
return (await tt().use(gt, { fragment: !0 }).use(lo).use(Ce).use(bt).use(Te).process(await Wt(n, t))).value;
|
|
1663
1663
|
}
|
|
1664
|
-
function
|
|
1664
|
+
function po(n, t) {
|
|
1665
1665
|
const e = t.value ? t.value + `
|
|
1666
1666
|
` : "", o = {};
|
|
1667
1667
|
t.lang && (o["data-language"] = t.lang);
|
|
@@ -1678,19 +1678,19 @@ function uo(n, t) {
|
|
|
1678
1678
|
children: [r]
|
|
1679
1679
|
}, n.patch(t, r), r;
|
|
1680
1680
|
}
|
|
1681
|
-
async function
|
|
1682
|
-
const o = await
|
|
1681
|
+
async function ho(n, t, e) {
|
|
1682
|
+
const o = await tt().use(Ee).use(bt).use(Se, {
|
|
1683
1683
|
handlers: {
|
|
1684
|
-
...
|
|
1685
|
-
code:
|
|
1684
|
+
...Me,
|
|
1685
|
+
code: po
|
|
1686
1686
|
}
|
|
1687
|
-
}).use(
|
|
1688
|
-
return
|
|
1687
|
+
}).use(kt).process(n);
|
|
1688
|
+
return Gt(o.value, t, e);
|
|
1689
1689
|
}
|
|
1690
|
-
function
|
|
1690
|
+
function ct(n) {
|
|
1691
1691
|
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1692
1692
|
}
|
|
1693
|
-
function
|
|
1693
|
+
function mo(n) {
|
|
1694
1694
|
const t = {};
|
|
1695
1695
|
return Object.entries(n.propSchema).forEach(([e, o]) => {
|
|
1696
1696
|
t[e] = {
|
|
@@ -1700,7 +1700,7 @@ function ho(n) {
|
|
|
1700
1700
|
// value is the same as its default, we don't display an HTML
|
|
1701
1701
|
// attribute for it.
|
|
1702
1702
|
parseHTML: (r) => {
|
|
1703
|
-
const i = r.getAttribute(
|
|
1703
|
+
const i = r.getAttribute(ct(e));
|
|
1704
1704
|
if (i === null)
|
|
1705
1705
|
return null;
|
|
1706
1706
|
if (typeof o.default == "boolean")
|
|
@@ -1712,19 +1712,19 @@ function ho(n) {
|
|
|
1712
1712
|
return i;
|
|
1713
1713
|
},
|
|
1714
1714
|
renderHTML: (r) => r[e] !== o.default ? {
|
|
1715
|
-
[
|
|
1715
|
+
[ct(e)]: r[e]
|
|
1716
1716
|
} : {}
|
|
1717
1717
|
};
|
|
1718
1718
|
}), t;
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function fo(n) {
|
|
1721
1721
|
return [
|
|
1722
1722
|
{
|
|
1723
1723
|
tag: "div[data-content-type=" + n.type + "]"
|
|
1724
1724
|
}
|
|
1725
1725
|
];
|
|
1726
1726
|
}
|
|
1727
|
-
function
|
|
1727
|
+
function go(n, t) {
|
|
1728
1728
|
const e = document.createElement("div");
|
|
1729
1729
|
e.setAttribute("data-content-type", n.type);
|
|
1730
1730
|
for (const [r, i] of Object.entries(t))
|
|
@@ -1737,63 +1737,63 @@ function fo(n, t) {
|
|
|
1737
1737
|
dom: e
|
|
1738
1738
|
};
|
|
1739
1739
|
}
|
|
1740
|
-
function
|
|
1740
|
+
function ko(n) {
|
|
1741
1741
|
return {
|
|
1742
|
-
node:
|
|
1742
|
+
node: W({
|
|
1743
1743
|
name: n.type,
|
|
1744
1744
|
content: n.containsInlineContent ? "inline*" : "",
|
|
1745
1745
|
selectable: !0,
|
|
1746
1746
|
addAttributes() {
|
|
1747
|
-
return
|
|
1747
|
+
return mo(n);
|
|
1748
1748
|
},
|
|
1749
1749
|
parseHTML() {
|
|
1750
|
-
return
|
|
1750
|
+
return fo(n);
|
|
1751
1751
|
},
|
|
1752
1752
|
renderHTML({ HTMLAttributes: e }) {
|
|
1753
|
-
return
|
|
1753
|
+
return go(n, e);
|
|
1754
1754
|
},
|
|
1755
1755
|
addNodeView() {
|
|
1756
1756
|
return ({ HTMLAttributes: e, getPos: o }) => {
|
|
1757
1757
|
var p, f;
|
|
1758
1758
|
const r = document.createElement("div"), i = ((p = this.options.domAttributes) == null ? void 0 : p.blockContent) || {};
|
|
1759
|
-
for (const [
|
|
1759
|
+
for (const [b, w] of Object.entries(
|
|
1760
1760
|
i
|
|
1761
1761
|
))
|
|
1762
|
-
|
|
1763
|
-
r.className =
|
|
1764
|
-
|
|
1762
|
+
b !== "class" && r.setAttribute(b, w);
|
|
1763
|
+
r.className = B(
|
|
1764
|
+
k.blockContent,
|
|
1765
1765
|
i.class
|
|
1766
1766
|
), r.setAttribute("data-content-type", n.type);
|
|
1767
|
-
for (const [
|
|
1768
|
-
r.setAttribute(
|
|
1767
|
+
for (const [b, w] of Object.entries(e))
|
|
1768
|
+
r.setAttribute(b, w);
|
|
1769
1769
|
const s = this.options.editor;
|
|
1770
1770
|
if (typeof o == "boolean")
|
|
1771
1771
|
throw new Error(
|
|
1772
1772
|
"Cannot find node position as getPos is a boolean, not a function."
|
|
1773
1773
|
);
|
|
1774
|
-
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id,
|
|
1775
|
-
if (
|
|
1774
|
+
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, h = s.getBlock(c);
|
|
1775
|
+
if (h.type !== n.type)
|
|
1776
1776
|
throw new Error("Block type does not match");
|
|
1777
|
-
const
|
|
1777
|
+
const m = n.render(h, s);
|
|
1778
1778
|
if (n.containsInlineContent) {
|
|
1779
|
-
const
|
|
1780
|
-
for (const [
|
|
1781
|
-
|
|
1779
|
+
const b = m.contentDOM, w = ((f = this.options.domAttributes) == null ? void 0 : f.inlineContent) || {};
|
|
1780
|
+
for (const [C, M] of Object.entries(
|
|
1781
|
+
w
|
|
1782
1782
|
))
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1783
|
+
C !== "class" && b.setAttribute(C, M);
|
|
1784
|
+
b.className = B(
|
|
1785
|
+
b.className,
|
|
1786
|
+
k.inlineContent,
|
|
1787
|
+
w.class
|
|
1788
1788
|
);
|
|
1789
1789
|
}
|
|
1790
|
-
return r.appendChild(
|
|
1790
|
+
return r.appendChild(m.dom), "contentDOM" in m ? {
|
|
1791
1791
|
dom: r,
|
|
1792
|
-
contentDOM:
|
|
1793
|
-
destroy:
|
|
1792
|
+
contentDOM: m.contentDOM,
|
|
1793
|
+
destroy: m.destroy
|
|
1794
1794
|
} : {
|
|
1795
1795
|
dom: r,
|
|
1796
|
-
destroy:
|
|
1796
|
+
destroy: m.destroy
|
|
1797
1797
|
};
|
|
1798
1798
|
};
|
|
1799
1799
|
}
|
|
@@ -1801,17 +1801,17 @@ function go(n) {
|
|
|
1801
1801
|
propSchema: n.propSchema
|
|
1802
1802
|
};
|
|
1803
1803
|
}
|
|
1804
|
-
function
|
|
1805
|
-
return
|
|
1804
|
+
function W(n) {
|
|
1805
|
+
return q.create({
|
|
1806
1806
|
...n,
|
|
1807
1807
|
group: "blockContent",
|
|
1808
1808
|
content: n.content
|
|
1809
1809
|
});
|
|
1810
1810
|
}
|
|
1811
|
-
const
|
|
1812
|
-
...
|
|
1811
|
+
const bo = {
|
|
1812
|
+
...T,
|
|
1813
1813
|
level: { default: 1, values: [1, 2, 3] }
|
|
1814
|
-
},
|
|
1814
|
+
}, yo = W({
|
|
1815
1815
|
name: "heading",
|
|
1816
1816
|
content: "inline*",
|
|
1817
1817
|
addAttributes() {
|
|
@@ -1828,7 +1828,7 @@ const ko = {
|
|
|
1828
1828
|
},
|
|
1829
1829
|
addInputRules() {
|
|
1830
1830
|
return [
|
|
1831
|
-
...[1, 2, 3].map((n) => new
|
|
1831
|
+
...[1, 2, 3].map((n) => new Q({
|
|
1832
1832
|
find: new RegExp(`^(#{${n}})\\s$`),
|
|
1833
1833
|
handler: ({ state: t, chain: e, range: o }) => {
|
|
1834
1834
|
e().BNUpdateBlock(t.selection.from, {
|
|
@@ -1887,10 +1887,10 @@ const ko = {
|
|
|
1887
1887
|
const e = ((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {}, o = ((i = this.options.domAttributes) == null ? void 0 : i.inlineContent) || {};
|
|
1888
1888
|
return [
|
|
1889
1889
|
"div",
|
|
1890
|
-
|
|
1890
|
+
D(t, {
|
|
1891
1891
|
...e,
|
|
1892
|
-
class:
|
|
1893
|
-
|
|
1892
|
+
class: B(
|
|
1893
|
+
k.blockContent,
|
|
1894
1894
|
e.class
|
|
1895
1895
|
),
|
|
1896
1896
|
"data-content-type": this.name
|
|
@@ -1899,8 +1899,8 @@ const ko = {
|
|
|
1899
1899
|
`h${n.attrs.level}`,
|
|
1900
1900
|
{
|
|
1901
1901
|
...o,
|
|
1902
|
-
class:
|
|
1903
|
-
|
|
1902
|
+
class: B(
|
|
1903
|
+
k.inlineContent,
|
|
1904
1904
|
o.class
|
|
1905
1905
|
)
|
|
1906
1906
|
},
|
|
@@ -1908,11 +1908,11 @@ const ko = {
|
|
|
1908
1908
|
]
|
|
1909
1909
|
];
|
|
1910
1910
|
}
|
|
1911
|
-
}),
|
|
1912
|
-
node:
|
|
1913
|
-
propSchema:
|
|
1914
|
-
},
|
|
1915
|
-
const { node: t, contentType: e } =
|
|
1911
|
+
}), vo = {
|
|
1912
|
+
node: yo,
|
|
1913
|
+
propSchema: bo
|
|
1914
|
+
}, jt = (n) => {
|
|
1915
|
+
const { node: t, contentType: e } = v(
|
|
1916
1916
|
n.state.doc,
|
|
1917
1917
|
n.state.selection.from
|
|
1918
1918
|
), o = n.state.selection.anchor === n.state.selection.head;
|
|
@@ -1930,15 +1930,15 @@ const ko = {
|
|
|
1930
1930
|
s.command(() => t.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
1931
1931
|
)
|
|
1932
1932
|
]);
|
|
1933
|
-
},
|
|
1934
|
-
...
|
|
1935
|
-
},
|
|
1933
|
+
}, wo = {
|
|
1934
|
+
...T
|
|
1935
|
+
}, Co = W({
|
|
1936
1936
|
name: "bulletListItem",
|
|
1937
1937
|
content: "inline*",
|
|
1938
1938
|
addInputRules() {
|
|
1939
1939
|
return [
|
|
1940
1940
|
// Creates an unordered list when starting with "-", "+", or "*".
|
|
1941
|
-
new
|
|
1941
|
+
new Q({
|
|
1942
1942
|
find: new RegExp("^[-+*]\\s$"),
|
|
1943
1943
|
handler: ({ state: n, chain: t, range: e }) => {
|
|
1944
1944
|
t().BNUpdateBlock(n.selection.from, {
|
|
@@ -1951,7 +1951,7 @@ const ko = {
|
|
|
1951
1951
|
},
|
|
1952
1952
|
addKeyboardShortcuts() {
|
|
1953
1953
|
return {
|
|
1954
|
-
Enter: () =>
|
|
1954
|
+
Enter: () => jt(this.editor),
|
|
1955
1955
|
"Mod-Shift-7": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1956
1956
|
type: "bulletListItem",
|
|
1957
1957
|
props: {}
|
|
@@ -1990,10 +1990,10 @@ const ko = {
|
|
|
1990
1990
|
const t = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, e = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
1991
1991
|
return [
|
|
1992
1992
|
"div",
|
|
1993
|
-
|
|
1993
|
+
D(n, {
|
|
1994
1994
|
...t,
|
|
1995
|
-
class:
|
|
1996
|
-
|
|
1995
|
+
class: B(
|
|
1996
|
+
k.blockContent,
|
|
1997
1997
|
t.class
|
|
1998
1998
|
),
|
|
1999
1999
|
"data-content-type": this.name
|
|
@@ -2002,8 +2002,8 @@ const ko = {
|
|
|
2002
2002
|
"p",
|
|
2003
2003
|
{
|
|
2004
2004
|
...e,
|
|
2005
|
-
class:
|
|
2006
|
-
|
|
2005
|
+
class: B(
|
|
2006
|
+
k.inlineContent,
|
|
2007
2007
|
e.class
|
|
2008
2008
|
)
|
|
2009
2009
|
},
|
|
@@ -2011,11 +2011,11 @@ const ko = {
|
|
|
2011
2011
|
]
|
|
2012
2012
|
];
|
|
2013
2013
|
}
|
|
2014
|
-
}),
|
|
2015
|
-
node:
|
|
2016
|
-
propSchema:
|
|
2017
|
-
},
|
|
2018
|
-
key:
|
|
2014
|
+
}), Eo = {
|
|
2015
|
+
node: Co,
|
|
2016
|
+
propSchema: wo
|
|
2017
|
+
}, So = new _("numbered-list-indexing"), Mo = () => new I({
|
|
2018
|
+
key: So,
|
|
2019
2019
|
appendTransaction: (n, t, e) => {
|
|
2020
2020
|
const o = e.tr;
|
|
2021
2021
|
o.setMeta("numberedListIndexing", !0);
|
|
@@ -2023,18 +2023,18 @@ const ko = {
|
|
|
2023
2023
|
return e.doc.descendants((i, s) => {
|
|
2024
2024
|
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
2025
2025
|
let l = "1";
|
|
2026
|
-
const a = s === 1, d =
|
|
2026
|
+
const a = s === 1, d = v(o.doc, s + 1);
|
|
2027
2027
|
if (d === void 0)
|
|
2028
2028
|
return;
|
|
2029
2029
|
if (!a) {
|
|
2030
|
-
const
|
|
2031
|
-
if (
|
|
2030
|
+
const m = v(o.doc, s - 2);
|
|
2031
|
+
if (m === void 0)
|
|
2032
2032
|
return;
|
|
2033
|
-
if (!(d.depth !==
|
|
2034
|
-
const f =
|
|
2035
|
-
if (
|
|
2036
|
-
const
|
|
2037
|
-
l = (parseInt(
|
|
2033
|
+
if (!(d.depth !== m.depth)) {
|
|
2034
|
+
const f = m.contentNode;
|
|
2035
|
+
if (m.contentType.name === "numberedListItem") {
|
|
2036
|
+
const C = f.attrs.index;
|
|
2037
|
+
l = (parseInt(C) + 1).toString();
|
|
2038
2038
|
}
|
|
2039
2039
|
}
|
|
2040
2040
|
}
|
|
@@ -2044,9 +2044,9 @@ const ko = {
|
|
|
2044
2044
|
}
|
|
2045
2045
|
}), r ? o : null;
|
|
2046
2046
|
}
|
|
2047
|
-
}),
|
|
2048
|
-
...
|
|
2049
|
-
},
|
|
2047
|
+
}), To = {
|
|
2048
|
+
...T
|
|
2049
|
+
}, Bo = W({
|
|
2050
2050
|
name: "numberedListItem",
|
|
2051
2051
|
content: "inline*",
|
|
2052
2052
|
addAttributes() {
|
|
@@ -2063,7 +2063,7 @@ const ko = {
|
|
|
2063
2063
|
addInputRules() {
|
|
2064
2064
|
return [
|
|
2065
2065
|
// Creates an ordered list when starting with "1.".
|
|
2066
|
-
new
|
|
2066
|
+
new Q({
|
|
2067
2067
|
find: new RegExp("^1\\.\\s$"),
|
|
2068
2068
|
handler: ({ state: n, chain: t, range: e }) => {
|
|
2069
2069
|
t().BNUpdateBlock(n.selection.from, {
|
|
@@ -2076,7 +2076,7 @@ const ko = {
|
|
|
2076
2076
|
},
|
|
2077
2077
|
addKeyboardShortcuts() {
|
|
2078
2078
|
return {
|
|
2079
|
-
Enter: () =>
|
|
2079
|
+
Enter: () => jt(this.editor),
|
|
2080
2080
|
"Mod-Shift-8": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
2081
2081
|
type: "numberedListItem",
|
|
2082
2082
|
props: {}
|
|
@@ -2084,7 +2084,7 @@ const ko = {
|
|
|
2084
2084
|
};
|
|
2085
2085
|
},
|
|
2086
2086
|
addProseMirrorPlugins() {
|
|
2087
|
-
return [
|
|
2087
|
+
return [Mo()];
|
|
2088
2088
|
},
|
|
2089
2089
|
parseHTML() {
|
|
2090
2090
|
return [
|
|
@@ -2120,10 +2120,10 @@ const ko = {
|
|
|
2120
2120
|
const t = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, e = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
2121
2121
|
return [
|
|
2122
2122
|
"div",
|
|
2123
|
-
|
|
2123
|
+
D(n, {
|
|
2124
2124
|
...t,
|
|
2125
|
-
class:
|
|
2126
|
-
|
|
2125
|
+
class: B(
|
|
2126
|
+
k.blockContent,
|
|
2127
2127
|
t.class
|
|
2128
2128
|
),
|
|
2129
2129
|
"data-content-type": this.name
|
|
@@ -2134,8 +2134,8 @@ const ko = {
|
|
|
2134
2134
|
"p",
|
|
2135
2135
|
{
|
|
2136
2136
|
...e,
|
|
2137
|
-
class:
|
|
2138
|
-
|
|
2137
|
+
class: B(
|
|
2138
|
+
k.inlineContent,
|
|
2139
2139
|
e.class
|
|
2140
2140
|
)
|
|
2141
2141
|
},
|
|
@@ -2143,12 +2143,12 @@ const ko = {
|
|
|
2143
2143
|
]
|
|
2144
2144
|
];
|
|
2145
2145
|
}
|
|
2146
|
-
}),
|
|
2147
|
-
node:
|
|
2148
|
-
propSchema:
|
|
2149
|
-
},
|
|
2150
|
-
...
|
|
2151
|
-
},
|
|
2146
|
+
}), xo = {
|
|
2147
|
+
node: Bo,
|
|
2148
|
+
propSchema: To
|
|
2149
|
+
}, Io = {
|
|
2150
|
+
...T
|
|
2151
|
+
}, _o = W({
|
|
2152
2152
|
name: "paragraph",
|
|
2153
2153
|
content: "inline*",
|
|
2154
2154
|
parseHTML() {
|
|
@@ -2165,11 +2165,11 @@ const ko = {
|
|
|
2165
2165
|
const t = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, e = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
2166
2166
|
return [
|
|
2167
2167
|
"div",
|
|
2168
|
-
|
|
2168
|
+
D(
|
|
2169
2169
|
{
|
|
2170
2170
|
...t,
|
|
2171
|
-
class:
|
|
2172
|
-
|
|
2171
|
+
class: B(
|
|
2172
|
+
k.blockContent,
|
|
2173
2173
|
t.class
|
|
2174
2174
|
),
|
|
2175
2175
|
"data-content-type": this.name
|
|
@@ -2180,8 +2180,8 @@ const ko = {
|
|
|
2180
2180
|
"p",
|
|
2181
2181
|
{
|
|
2182
2182
|
...e,
|
|
2183
|
-
class:
|
|
2184
|
-
|
|
2183
|
+
class: B(
|
|
2184
|
+
k.inlineContent,
|
|
2185
2185
|
e.class
|
|
2186
2186
|
)
|
|
2187
2187
|
},
|
|
@@ -2190,10 +2190,10 @@ const ko = {
|
|
|
2190
2190
|
];
|
|
2191
2191
|
}
|
|
2192
2192
|
}), Ao = {
|
|
2193
|
-
node:
|
|
2194
|
-
propSchema:
|
|
2193
|
+
node: _o,
|
|
2194
|
+
propSchema: Io
|
|
2195
2195
|
};
|
|
2196
|
-
class
|
|
2196
|
+
class Ho {
|
|
2197
2197
|
constructor(t, e, o) {
|
|
2198
2198
|
u(this, "imageToolbarState");
|
|
2199
2199
|
u(this, "updateImageToolbar");
|
|
@@ -2250,17 +2250,17 @@ class _o {
|
|
|
2250
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);
|
|
2251
2251
|
}
|
|
2252
2252
|
}
|
|
2253
|
-
const
|
|
2254
|
-
class
|
|
2253
|
+
const U = new _("ImageToolbarPlugin");
|
|
2254
|
+
class Lo extends $ {
|
|
2255
2255
|
constructor(e) {
|
|
2256
2256
|
super();
|
|
2257
2257
|
u(this, "view");
|
|
2258
2258
|
u(this, "plugin");
|
|
2259
|
-
this.plugin = new
|
|
2260
|
-
key:
|
|
2261
|
-
view: (o) => (this.view = new
|
|
2259
|
+
this.plugin = new I({
|
|
2260
|
+
key: U,
|
|
2261
|
+
view: (o) => (this.view = new Ho(
|
|
2262
2262
|
// editor,
|
|
2263
|
-
|
|
2263
|
+
U,
|
|
2264
2264
|
o,
|
|
2265
2265
|
(r) => {
|
|
2266
2266
|
this.emit("update", r);
|
|
@@ -2273,7 +2273,7 @@ class Ho extends U {
|
|
|
2273
2273
|
apply: (o) => {
|
|
2274
2274
|
var i;
|
|
2275
2275
|
return {
|
|
2276
|
-
block: (i = o.getMeta(
|
|
2276
|
+
block: (i = o.getMeta(U)) == null ? void 0 : i.block
|
|
2277
2277
|
};
|
|
2278
2278
|
}
|
|
2279
2279
|
}
|
|
@@ -2283,9 +2283,9 @@ class Ho extends U {
|
|
|
2283
2283
|
return this.on("update", e);
|
|
2284
2284
|
}
|
|
2285
2285
|
}
|
|
2286
|
-
const
|
|
2287
|
-
textAlignment:
|
|
2288
|
-
backgroundColor:
|
|
2286
|
+
const No = {
|
|
2287
|
+
textAlignment: T.textAlignment,
|
|
2288
|
+
backgroundColor: T.backgroundColor,
|
|
2289
2289
|
// Image url.
|
|
2290
2290
|
url: {
|
|
2291
2291
|
default: ""
|
|
@@ -2298,7 +2298,7 @@ const Lo = {
|
|
|
2298
2298
|
width: {
|
|
2299
2299
|
default: 512
|
|
2300
2300
|
}
|
|
2301
|
-
},
|
|
2301
|
+
}, ut = (n) => {
|
|
2302
2302
|
switch (n) {
|
|
2303
2303
|
case "left":
|
|
2304
2304
|
return "flex-start";
|
|
@@ -2309,109 +2309,113 @@ const Lo = {
|
|
|
2309
2309
|
default:
|
|
2310
2310
|
return "flex-start";
|
|
2311
2311
|
}
|
|
2312
|
-
},
|
|
2312
|
+
}, pt = 64, Po = (n, t) => {
|
|
2313
2313
|
const e = document.createElement("div");
|
|
2314
|
-
e.className =
|
|
2314
|
+
e.className = k.wrapper, e.style.alignItems = ut(
|
|
2315
2315
|
n.props.textAlignment
|
|
2316
2316
|
);
|
|
2317
2317
|
const o = document.createElement("div");
|
|
2318
|
-
o.className =
|
|
2318
|
+
o.className = k.addImageButton, o.style.display = n.props.url === "" ? "" : "none";
|
|
2319
2319
|
const r = document.createElement("div");
|
|
2320
|
-
r.className =
|
|
2320
|
+
r.className = k.addImageButtonIcon;
|
|
2321
2321
|
const i = document.createElement("p");
|
|
2322
|
-
i.className =
|
|
2322
|
+
i.className = k.addImageButtonText, i.innerText = "Add Image";
|
|
2323
2323
|
const s = document.createElement("div");
|
|
2324
|
-
s.className =
|
|
2324
|
+
s.className = k.imageAndCaptionWrapper, s.style.display = n.props.url !== "" ? "" : "none";
|
|
2325
2325
|
const l = document.createElement("div");
|
|
2326
|
-
l.className =
|
|
2326
|
+
l.className = k.imageWrapper, l.style.display = n.props.url !== "" ? "" : "none";
|
|
2327
2327
|
const a = document.createElement("img");
|
|
2328
|
-
a.className =
|
|
2328
|
+
a.className = k.image, a.src = n.props.url, a.alt = "placeholder", a.contentEditable = "false", a.draggable = !1, a.style.width = `${Math.min(
|
|
2329
2329
|
n.props.width,
|
|
2330
2330
|
t.domElement.firstElementChild.clientWidth
|
|
2331
2331
|
)}px`;
|
|
2332
2332
|
const d = document.createElement("div");
|
|
2333
|
-
d.className =
|
|
2333
|
+
d.className = k.resizeHandle, d.style.left = "4px";
|
|
2334
2334
|
const c = document.createElement("div");
|
|
2335
|
-
c.className =
|
|
2336
|
-
const
|
|
2337
|
-
|
|
2338
|
-
const
|
|
2339
|
-
var
|
|
2340
|
-
const
|
|
2341
|
-
[t.getTextCursorPosition().block, ...
|
|
2342
|
-
(
|
|
2335
|
+
c.className = k.resizeHandle, c.style.right = "4px";
|
|
2336
|
+
const h = document.createElement("p");
|
|
2337
|
+
h.className = k.caption, h.innerText = n.props.caption, h.style.padding = n.props.caption ? "4px" : "";
|
|
2338
|
+
const m = () => {
|
|
2339
|
+
var nt;
|
|
2340
|
+
const g = ((nt = t.getSelection()) == null ? void 0 : nt.blocks) || [];
|
|
2341
|
+
[t.getTextCursorPosition().block, ...g].find(
|
|
2342
|
+
(Yt) => Yt.id === n.id
|
|
2343
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 = "");
|
|
2344
2344
|
};
|
|
2345
|
-
t.onEditorContentChange(
|
|
2345
|
+
t.onEditorContentChange(m), t.onEditorSelectionChange(m);
|
|
2346
2346
|
let p;
|
|
2347
|
-
const f = (
|
|
2347
|
+
const f = (g) => {
|
|
2348
2348
|
if (!p)
|
|
2349
2349
|
return;
|
|
2350
|
-
let
|
|
2351
|
-
|
|
2352
|
-
},
|
|
2353
|
-
p && ((!
|
|
2350
|
+
let x;
|
|
2351
|
+
ut(n.props.textAlignment) === "center" ? p.handleUsed === "left" ? x = p.initialWidth + (p.initialClientX - g.clientX) * 2 : x = p.initialWidth + (g.clientX - p.initialClientX) * 2 : p.handleUsed === "left" ? x = p.initialWidth + p.initialClientX - g.clientX : x = p.initialWidth + g.clientX - p.initialClientX, x < pt ? a.style.width = `${pt}px` : x > t.domElement.firstElementChild.clientWidth ? a.style.width = `${t.domElement.firstElementChild.clientWidth}px` : a.style.width = `${x}px`;
|
|
2352
|
+
}, b = (g) => {
|
|
2353
|
+
p && ((!g.target || !l.contains(g.target)) && l.contains(d) && l.contains(c) && (d.style.display = "none", c.style.display = "none"), p = void 0, t.updateBlock(n, {
|
|
2354
2354
|
type: "image",
|
|
2355
2355
|
props: {
|
|
2356
2356
|
// Removes "px" from the end of the width string and converts to float.
|
|
2357
2357
|
width: parseFloat(a.style.width.slice(0, -2))
|
|
2358
2358
|
}
|
|
2359
2359
|
}));
|
|
2360
|
-
},
|
|
2361
|
-
|
|
2362
|
-
},
|
|
2360
|
+
}, w = (g) => {
|
|
2361
|
+
g.preventDefault();
|
|
2362
|
+
}, C = () => {
|
|
2363
2363
|
t._tiptapEditor.view.dispatch(
|
|
2364
|
-
t._tiptapEditor.state.tr.setMeta(
|
|
2364
|
+
t._tiptapEditor.state.tr.setMeta(U, {
|
|
2365
2365
|
block: n
|
|
2366
2366
|
})
|
|
2367
2367
|
);
|
|
2368
|
-
},
|
|
2369
|
-
|
|
2368
|
+
}, M = () => {
|
|
2369
|
+
t.isEditable ? (d.style.display = "block", c.style.display = "block") : (d.style.display = "none", c.style.display = "none");
|
|
2370
|
+
}, E = (g) => {
|
|
2371
|
+
g.relatedTarget === d || g.relatedTarget === c || p || (d.style.display = "none", c.style.display = "none");
|
|
2372
|
+
}, y = (g) => {
|
|
2373
|
+
g.preventDefault(), d.style.display = "block", c.style.display = "block", p = {
|
|
2370
2374
|
handleUsed: "left",
|
|
2371
2375
|
initialWidth: n.props.width,
|
|
2372
|
-
initialClientX:
|
|
2376
|
+
initialClientX: g.clientX
|
|
2373
2377
|
};
|
|
2374
|
-
},
|
|
2375
|
-
|
|
2378
|
+
}, S = (g) => {
|
|
2379
|
+
g.preventDefault(), d.style.display = "block", c.style.display = "block", p = {
|
|
2376
2380
|
handleUsed: "right",
|
|
2377
2381
|
initialWidth: n.props.width,
|
|
2378
|
-
initialClientX:
|
|
2382
|
+
initialClientX: g.clientX
|
|
2379
2383
|
};
|
|
2380
2384
|
};
|
|
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(
|
|
2385
|
+
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(h), window.addEventListener("mousemove", f), window.addEventListener("mouseup", b), o.addEventListener("mousedown", w), o.addEventListener("click", C), a.addEventListener("mouseenter", M), a.addEventListener("mouseleave", E), d.addEventListener(
|
|
2382
2386
|
"mousedown",
|
|
2383
|
-
|
|
2387
|
+
y
|
|
2384
2388
|
), c.addEventListener(
|
|
2385
2389
|
"mousedown",
|
|
2386
|
-
|
|
2390
|
+
S
|
|
2387
2391
|
), {
|
|
2388
2392
|
dom: e,
|
|
2389
2393
|
destroy: () => {
|
|
2390
|
-
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup",
|
|
2394
|
+
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", b), o.removeEventListener(
|
|
2391
2395
|
"mousedown",
|
|
2392
|
-
|
|
2393
|
-
), o.removeEventListener("click",
|
|
2396
|
+
w
|
|
2397
|
+
), o.removeEventListener("click", C), d.removeEventListener(
|
|
2394
2398
|
"mousedown",
|
|
2395
|
-
|
|
2399
|
+
y
|
|
2396
2400
|
), c.removeEventListener(
|
|
2397
2401
|
"mousedown",
|
|
2398
|
-
|
|
2402
|
+
S
|
|
2399
2403
|
);
|
|
2400
2404
|
}
|
|
2401
2405
|
};
|
|
2402
|
-
},
|
|
2406
|
+
}, Do = ko({
|
|
2403
2407
|
type: "image",
|
|
2404
|
-
propSchema:
|
|
2408
|
+
propSchema: No,
|
|
2405
2409
|
containsInlineContent: !1,
|
|
2406
|
-
render:
|
|
2407
|
-
}),
|
|
2410
|
+
render: Po
|
|
2411
|
+
}), qt = {
|
|
2408
2412
|
paragraph: Ao,
|
|
2409
|
-
heading:
|
|
2410
|
-
bulletListItem:
|
|
2411
|
-
numberedListItem:
|
|
2412
|
-
image:
|
|
2413
|
+
heading: vo,
|
|
2414
|
+
bulletListItem: Eo,
|
|
2415
|
+
numberedListItem: xo,
|
|
2416
|
+
image: Do
|
|
2413
2417
|
};
|
|
2414
|
-
class
|
|
2418
|
+
class Oo {
|
|
2415
2419
|
constructor(t, e, o) {
|
|
2416
2420
|
u(this, "formattingToolbarState");
|
|
2417
2421
|
u(this, "updateFormattingToolbar");
|
|
@@ -2419,7 +2423,7 @@ class Do {
|
|
|
2419
2423
|
u(this, "preventShow", !1);
|
|
2420
2424
|
u(this, "prevWasEditable", null);
|
|
2421
2425
|
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 &&
|
|
2426
|
+
const { doc: i, selection: s } = e, { empty: l } = s, a = !i.textBetween(o, r).length && ne(e.selection);
|
|
2423
2427
|
return !(!t.hasFocus() || l || a);
|
|
2424
2428
|
});
|
|
2425
2429
|
u(this, "viewMousedownHandler", () => {
|
|
@@ -2460,25 +2464,25 @@ class Do {
|
|
|
2460
2464
|
}, 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);
|
|
2461
2465
|
}
|
|
2462
2466
|
update(t, e) {
|
|
2463
|
-
var
|
|
2467
|
+
var m, p;
|
|
2464
2468
|
const { state: o, composing: r } = t, { doc: i, selection: s } = o, l = e && e.doc.eq(i) && e.selection.eq(s);
|
|
2465
2469
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
|
|
2466
2470
|
return;
|
|
2467
2471
|
this.prevWasEditable = this.editor.isEditable;
|
|
2468
|
-
const { ranges: a } = s, d = Math.min(...a.map((f) => f.$from.pos)), c = Math.max(...a.map((f) => f.$to.pos)),
|
|
2472
|
+
const { ranges: a } = s, d = Math.min(...a.map((f) => f.$from.pos)), c = Math.max(...a.map((f) => f.$to.pos)), h = (m = this.shouldShow) == null ? void 0 : m.call(this, {
|
|
2469
2473
|
view: t,
|
|
2470
2474
|
state: o,
|
|
2471
2475
|
from: d,
|
|
2472
2476
|
to: c
|
|
2473
2477
|
});
|
|
2474
|
-
if (this.editor.isEditable && !this.preventShow && (
|
|
2478
|
+
if (this.editor.isEditable && !this.preventShow && (h || this.preventHide)) {
|
|
2475
2479
|
this.formattingToolbarState = {
|
|
2476
2480
|
show: !0,
|
|
2477
2481
|
referencePos: this.getSelectionBoundingBox()
|
|
2478
2482
|
}, this.updateFormattingToolbar();
|
|
2479
2483
|
return;
|
|
2480
2484
|
}
|
|
2481
|
-
if ((p = this.formattingToolbarState) != null && p.show && !this.preventHide && (!
|
|
2485
|
+
if ((p = this.formattingToolbarState) != null && p.show && !this.preventHide && (!h || this.preventShow || !this.editor.isEditable)) {
|
|
2482
2486
|
this.formattingToolbarState.show = !1, this.updateFormattingToolbar();
|
|
2483
2487
|
return;
|
|
2484
2488
|
}
|
|
@@ -2488,25 +2492,25 @@ class Do {
|
|
|
2488
2492
|
}
|
|
2489
2493
|
getSelectionBoundingBox() {
|
|
2490
2494
|
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 (
|
|
2495
|
+
if (re(e)) {
|
|
2492
2496
|
const s = this.pmView.nodeDOM(r);
|
|
2493
2497
|
if (s)
|
|
2494
2498
|
return s.getBoundingClientRect();
|
|
2495
2499
|
}
|
|
2496
|
-
return
|
|
2500
|
+
return Y(this.pmView, r, i);
|
|
2497
2501
|
}
|
|
2498
2502
|
}
|
|
2499
|
-
const
|
|
2503
|
+
const Ro = new _(
|
|
2500
2504
|
"FormattingToolbarPlugin"
|
|
2501
2505
|
);
|
|
2502
|
-
class
|
|
2506
|
+
class zo extends $ {
|
|
2503
2507
|
constructor(e) {
|
|
2504
2508
|
super();
|
|
2505
2509
|
u(this, "view");
|
|
2506
2510
|
u(this, "plugin");
|
|
2507
|
-
this.plugin = new
|
|
2508
|
-
key:
|
|
2509
|
-
view: (o) => (this.view = new
|
|
2511
|
+
this.plugin = new I({
|
|
2512
|
+
key: Ro,
|
|
2513
|
+
view: (o) => (this.view = new Oo(e, o, (r) => {
|
|
2510
2514
|
this.emit("update", r);
|
|
2511
2515
|
}), this.view)
|
|
2512
2516
|
});
|
|
@@ -2515,7 +2519,7 @@ class Ro extends U {
|
|
|
2515
2519
|
return this.on("update", e);
|
|
2516
2520
|
}
|
|
2517
2521
|
}
|
|
2518
|
-
class
|
|
2522
|
+
class Vo {
|
|
2519
2523
|
constructor(t, e, o) {
|
|
2520
2524
|
u(this, "hyperlinkToolbarState");
|
|
2521
2525
|
u(this, "updateHyperlinkToolbar");
|
|
@@ -2535,7 +2539,7 @@ class zo {
|
|
|
2535
2539
|
), i = r.marks();
|
|
2536
2540
|
for (const s of i)
|
|
2537
2541
|
if (s.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2538
|
-
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange =
|
|
2542
|
+
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = it(
|
|
2539
2543
|
r,
|
|
2540
2544
|
s.type,
|
|
2541
2545
|
s.attrs
|
|
@@ -2555,7 +2559,7 @@ class zo {
|
|
|
2555
2559
|
});
|
|
2556
2560
|
u(this, "scrollHandler", () => {
|
|
2557
2561
|
var t;
|
|
2558
|
-
this.hyperlinkMark !== void 0 && (t = this.hyperlinkToolbarState) != null && t.show && (this.hyperlinkToolbarState.referencePos =
|
|
2562
|
+
this.hyperlinkMark !== void 0 && (t = this.hyperlinkToolbarState) != null && t.show && (this.hyperlinkToolbarState.referencePos = Y(
|
|
2559
2563
|
this.pmView,
|
|
2560
2564
|
this.hyperlinkMarkRange.from,
|
|
2561
2565
|
this.hyperlinkMarkRange.to
|
|
@@ -2603,7 +2607,7 @@ class zo {
|
|
|
2603
2607
|
const o = this.pmView.state.selection.$from.marks();
|
|
2604
2608
|
for (const r of o)
|
|
2605
2609
|
if (r.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2606
|
-
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange =
|
|
2610
|
+
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange = it(
|
|
2607
2611
|
this.pmView.state.selection.$from,
|
|
2608
2612
|
r.type,
|
|
2609
2613
|
r.attrs
|
|
@@ -2614,7 +2618,7 @@ class zo {
|
|
|
2614
2618
|
if (this.mouseHoveredHyperlinkMark && (this.hyperlinkMark = this.mouseHoveredHyperlinkMark, this.hyperlinkMarkRange = this.mouseHoveredHyperlinkMarkRange), this.keyboardHoveredHyperlinkMark && (this.hyperlinkMark = this.keyboardHoveredHyperlinkMark, this.hyperlinkMarkRange = this.keyboardHoveredHyperlinkMarkRange), this.hyperlinkMark && this.editor.isEditable) {
|
|
2615
2619
|
this.hyperlinkToolbarState = {
|
|
2616
2620
|
show: !0,
|
|
2617
|
-
referencePos:
|
|
2621
|
+
referencePos: Y(
|
|
2618
2622
|
this.pmView,
|
|
2619
2623
|
this.hyperlinkMarkRange.from,
|
|
2620
2624
|
this.hyperlinkMarkRange.to
|
|
@@ -2636,10 +2640,10 @@ class zo {
|
|
|
2636
2640
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2637
2641
|
}
|
|
2638
2642
|
}
|
|
2639
|
-
const
|
|
2643
|
+
const Uo = new _(
|
|
2640
2644
|
"HyperlinkToolbarPlugin"
|
|
2641
2645
|
);
|
|
2642
|
-
class
|
|
2646
|
+
class Fo extends $ {
|
|
2643
2647
|
constructor(e) {
|
|
2644
2648
|
super();
|
|
2645
2649
|
u(this, "view");
|
|
@@ -2674,9 +2678,9 @@ class Uo extends U {
|
|
|
2674
2678
|
u(this, "stopHideTimer", () => {
|
|
2675
2679
|
this.view.stopMenuUpdateTimer();
|
|
2676
2680
|
});
|
|
2677
|
-
this.plugin = new
|
|
2678
|
-
key:
|
|
2679
|
-
view: (o) => (this.view = new
|
|
2681
|
+
this.plugin = new I({
|
|
2682
|
+
key: Uo,
|
|
2683
|
+
view: (o) => (this.view = new Vo(e, o, (r) => {
|
|
2680
2684
|
this.emit("update", r);
|
|
2681
2685
|
}), this.view)
|
|
2682
2686
|
});
|
|
@@ -2685,7 +2689,7 @@ class Uo extends U {
|
|
|
2685
2689
|
return this.on("update", e);
|
|
2686
2690
|
}
|
|
2687
2691
|
}
|
|
2688
|
-
class
|
|
2692
|
+
class z extends K {
|
|
2689
2693
|
constructor(e, o) {
|
|
2690
2694
|
super(e, o);
|
|
2691
2695
|
u(this, "nodes");
|
|
@@ -2696,13 +2700,13 @@ class O extends X {
|
|
|
2696
2700
|
});
|
|
2697
2701
|
}
|
|
2698
2702
|
static create(e, o, r = o) {
|
|
2699
|
-
return new
|
|
2703
|
+
return new z(e.resolve(o), e.resolve(r));
|
|
2700
2704
|
}
|
|
2701
2705
|
content() {
|
|
2702
|
-
return new
|
|
2706
|
+
return new P(O.from(this.nodes), 0, 0);
|
|
2703
2707
|
}
|
|
2704
2708
|
eq(e) {
|
|
2705
|
-
if (!(e instanceof
|
|
2709
|
+
if (!(e instanceof z) || this.nodes.length !== e.nodes.length || this.from !== e.from || this.to !== e.to)
|
|
2706
2710
|
return !1;
|
|
2707
2711
|
for (let o = 0; o < this.nodes.length; o++)
|
|
2708
2712
|
if (!this.nodes[o].eq(e.nodes[o]))
|
|
@@ -2711,7 +2715,7 @@ class O extends X {
|
|
|
2711
2715
|
}
|
|
2712
2716
|
map(e, o) {
|
|
2713
2717
|
const r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2714
|
-
return i.deleted ?
|
|
2718
|
+
return i.deleted ? K.near(e.resolve(r.pos)) : r.deleted ? K.near(e.resolve(i.pos)) : new z(
|
|
2715
2719
|
e.resolve(r.pos),
|
|
2716
2720
|
e.resolve(i.pos)
|
|
2717
2721
|
);
|
|
@@ -2720,9 +2724,9 @@ class O extends X {
|
|
|
2720
2724
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
2721
2725
|
}
|
|
2722
2726
|
}
|
|
2723
|
-
const
|
|
2724
|
-
let
|
|
2725
|
-
function
|
|
2727
|
+
const $o = we.__serializeForClipboard;
|
|
2728
|
+
let H;
|
|
2729
|
+
function Xt(n, t) {
|
|
2726
2730
|
var r;
|
|
2727
2731
|
if (!t.dom.isConnected)
|
|
2728
2732
|
return;
|
|
@@ -2737,15 +2741,15 @@ function qt(n, t) {
|
|
|
2737
2741
|
return { node: o, id: o.getAttribute("data-id") };
|
|
2738
2742
|
}
|
|
2739
2743
|
}
|
|
2740
|
-
function
|
|
2741
|
-
const e =
|
|
2744
|
+
function Wo(n, t) {
|
|
2745
|
+
const e = Xt(n, t);
|
|
2742
2746
|
if (e && e.node.nodeType === 1) {
|
|
2743
2747
|
const o = t.docView, r = o.nearestDesc(e.node, !0);
|
|
2744
2748
|
return !r || r === o ? null : r.posBefore;
|
|
2745
2749
|
}
|
|
2746
2750
|
return null;
|
|
2747
2751
|
}
|
|
2748
|
-
function
|
|
2752
|
+
function Go(n, t) {
|
|
2749
2753
|
let e, o;
|
|
2750
2754
|
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);
|
|
2751
2755
|
if (r && i) {
|
|
@@ -2755,9 +2759,9 @@ function Wo(n, t) {
|
|
|
2755
2759
|
e = n.from, o = n.to;
|
|
2756
2760
|
return { from: e, to: o };
|
|
2757
2761
|
}
|
|
2758
|
-
function
|
|
2762
|
+
function ht(n, t, e = t) {
|
|
2759
2763
|
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,
|
|
2764
|
+
const o = n.domAtPos(t).node.cloneNode(!0), r = n.domAtPos(t).node, i = (c, h) => Array.prototype.indexOf.call(c.children, h), s = i(
|
|
2761
2765
|
r,
|
|
2762
2766
|
// Expects from position to be just before the first selected block.
|
|
2763
2767
|
n.domAtPos(t + 1).node.parentElement
|
|
@@ -2768,35 +2772,35 @@ function pt(n, t, e = t) {
|
|
|
2768
2772
|
);
|
|
2769
2773
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
2770
2774
|
(c > l || c < s) && o.removeChild(o.children[c]);
|
|
2771
|
-
|
|
2775
|
+
Kt(), H = o;
|
|
2772
2776
|
const d = n.dom.className.split(" ").filter(
|
|
2773
2777
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
2774
2778
|
).join(" ");
|
|
2775
|
-
|
|
2779
|
+
H.className = H.className + " " + R.dragPreview + " " + d, document.body.appendChild(H);
|
|
2776
2780
|
}
|
|
2777
|
-
function
|
|
2778
|
-
|
|
2781
|
+
function Kt() {
|
|
2782
|
+
H !== void 0 && (document.body.removeChild(H), H = void 0);
|
|
2779
2783
|
}
|
|
2780
|
-
function
|
|
2784
|
+
function jo(n, t) {
|
|
2781
2785
|
if (!n.dataTransfer)
|
|
2782
2786
|
return;
|
|
2783
2787
|
const e = t.dom.getBoundingClientRect(), o = {
|
|
2784
2788
|
left: e.left + e.width / 2,
|
|
2785
2789
|
// take middle of editor
|
|
2786
2790
|
top: n.clientY
|
|
2787
|
-
}, r =
|
|
2791
|
+
}, r = Wo(o, t);
|
|
2788
2792
|
if (r != null) {
|
|
2789
|
-
const i = t.state.selection, s = t.state.doc, { from: l, to: a } =
|
|
2793
|
+
const i = t.state.selection, s = t.state.doc, { from: l, to: a } = Go(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof z;
|
|
2790
2794
|
d && c ? (t.dispatch(
|
|
2791
|
-
t.state.tr.setSelection(
|
|
2792
|
-
),
|
|
2793
|
-
t.state.tr.setSelection(
|
|
2794
|
-
),
|
|
2795
|
-
const
|
|
2796
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html",
|
|
2795
|
+
t.state.tr.setSelection(z.create(s, l, a))
|
|
2796
|
+
), ht(t, l, a)) : (t.dispatch(
|
|
2797
|
+
t.state.tr.setSelection(ft.create(t.state.doc, r))
|
|
2798
|
+
), ht(t, r));
|
|
2799
|
+
const h = t.state.selection.content(), { dom: m, text: p } = $o(t, h);
|
|
2800
|
+
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", m.innerHTML), n.dataTransfer.setData("text/plain", p), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(H, 0, 0), t.dragging = { slice: h, move: !0 };
|
|
2797
2801
|
}
|
|
2798
2802
|
}
|
|
2799
|
-
class
|
|
2803
|
+
class qo {
|
|
2800
2804
|
constructor(t, e, o) {
|
|
2801
2805
|
u(this, "sideMenuState");
|
|
2802
2806
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
@@ -2852,8 +2856,11 @@ class jo {
|
|
|
2852
2856
|
var e;
|
|
2853
2857
|
(e = this.sideMenuState) != null && e.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2854
2858
|
});
|
|
2859
|
+
u(this, "onMouseDown", (t) => {
|
|
2860
|
+
this.sideMenuState && !this.sideMenuState.show && (this.sideMenuState.show = !0, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2861
|
+
});
|
|
2855
2862
|
u(this, "onMouseMove", (t) => {
|
|
2856
|
-
var d, c,
|
|
2863
|
+
var d, c, h, m, p;
|
|
2857
2864
|
if (this.menuFrozen)
|
|
2858
2865
|
return;
|
|
2859
2866
|
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;
|
|
@@ -2871,12 +2878,12 @@ class jo {
|
|
|
2871
2878
|
left: e.left + e.width / 2,
|
|
2872
2879
|
// take middle of editor
|
|
2873
2880
|
top: t.clientY
|
|
2874
|
-
}, l =
|
|
2881
|
+
}, l = Xt(s, this.pmView);
|
|
2875
2882
|
if (!l || !this.editor.isEditable) {
|
|
2876
2883
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2877
2884
|
return;
|
|
2878
2885
|
}
|
|
2879
|
-
if ((
|
|
2886
|
+
if ((h = this.sideMenuState) != null && h.show && ((m = this.hoveredBlock) != null && m.hasAttribute("data-id")) && ((p = this.hoveredBlock) == null ? void 0 : p.getAttribute("data-id")) === l.id)
|
|
2880
2887
|
return;
|
|
2881
2888
|
this.hoveredBlock = l.node;
|
|
2882
2889
|
const a = l.node.firstChild;
|
|
@@ -2908,11 +2915,11 @@ class jo {
|
|
|
2908
2915
|
), this.updateSideMenu(this.sideMenuState);
|
|
2909
2916
|
}
|
|
2910
2917
|
});
|
|
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);
|
|
2918
|
+
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("mousedown", this.onMouseDown, !0), document.body.addEventListener("keydown", this.onKeyDown, !0);
|
|
2912
2919
|
}
|
|
2913
2920
|
destroy() {
|
|
2914
2921
|
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);
|
|
2922
|
+
(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("mousedown", this.onMouseDown, !0), document.body.removeEventListener("keydown", this.onKeyDown, !0);
|
|
2916
2923
|
}
|
|
2917
2924
|
addBlock() {
|
|
2918
2925
|
var l;
|
|
@@ -2923,7 +2930,7 @@ class jo {
|
|
|
2923
2930
|
});
|
|
2924
2931
|
if (!o)
|
|
2925
2932
|
return;
|
|
2926
|
-
const r =
|
|
2933
|
+
const r = v(
|
|
2927
2934
|
this.editor._tiptapEditor.state.doc,
|
|
2928
2935
|
o.pos
|
|
2929
2936
|
);
|
|
@@ -2936,7 +2943,7 @@ class jo {
|
|
|
2936
2943
|
} else
|
|
2937
2944
|
this.editor._tiptapEditor.commands.setTextSelection(s);
|
|
2938
2945
|
this.pmView.focus(), this.pmView.dispatch(
|
|
2939
|
-
this.pmView.state.tr.scrollIntoView().setMeta(
|
|
2946
|
+
this.pmView.state.tr.scrollIntoView().setMeta(et, {
|
|
2940
2947
|
// TODO import suggestion plugin key
|
|
2941
2948
|
activate: !0,
|
|
2942
2949
|
type: "drag"
|
|
@@ -2944,8 +2951,8 @@ class jo {
|
|
|
2944
2951
|
);
|
|
2945
2952
|
}
|
|
2946
2953
|
}
|
|
2947
|
-
const
|
|
2948
|
-
class
|
|
2954
|
+
const Xo = new _("SideMenuPlugin");
|
|
2955
|
+
class Ko extends $ {
|
|
2949
2956
|
constructor(e) {
|
|
2950
2957
|
super();
|
|
2951
2958
|
u(this, "sideMenuView");
|
|
@@ -2959,12 +2966,12 @@ class Xo extends U {
|
|
|
2959
2966
|
* Handles drag & drop events for blocks.
|
|
2960
2967
|
*/
|
|
2961
2968
|
u(this, "blockDragStart", (e) => {
|
|
2962
|
-
this.sideMenuView.isDragging = !0,
|
|
2969
|
+
this.sideMenuView.isDragging = !0, jo(e, this.editor.prosemirrorView);
|
|
2963
2970
|
});
|
|
2964
2971
|
/**
|
|
2965
2972
|
* Handles drag & drop events for blocks.
|
|
2966
2973
|
*/
|
|
2967
|
-
u(this, "blockDragEnd", () =>
|
|
2974
|
+
u(this, "blockDragEnd", () => Kt());
|
|
2968
2975
|
/**
|
|
2969
2976
|
* Freezes the side menu. When frozen, the side menu will stay
|
|
2970
2977
|
* attached to the same block regardless of which block is hovered by the
|
|
@@ -2977,9 +2984,9 @@ class Xo extends U {
|
|
|
2977
2984
|
* mouse cursor.
|
|
2978
2985
|
*/
|
|
2979
2986
|
u(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2980
|
-
this.editor = e, this.plugin = new
|
|
2981
|
-
key:
|
|
2982
|
-
view: (o) => (this.sideMenuView = new
|
|
2987
|
+
this.editor = e, this.plugin = new I({
|
|
2988
|
+
key: Xo,
|
|
2989
|
+
view: (o) => (this.sideMenuView = new qo(
|
|
2983
2990
|
e,
|
|
2984
2991
|
o,
|
|
2985
2992
|
(r) => {
|
|
@@ -2992,7 +2999,7 @@ class Xo extends U {
|
|
|
2992
2999
|
return this.on("update", e);
|
|
2993
3000
|
}
|
|
2994
3001
|
}
|
|
2995
|
-
function
|
|
3002
|
+
function N(n, t) {
|
|
2996
3003
|
const e = n.getTextCursorPosition().block;
|
|
2997
3004
|
if (e.content === void 0)
|
|
2998
3005
|
throw new Error(
|
|
@@ -3000,46 +3007,46 @@ function H(n, t) {
|
|
|
3000
3007
|
);
|
|
3001
3008
|
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));
|
|
3002
3009
|
}
|
|
3003
|
-
const
|
|
3010
|
+
const Yo = (n = qt) => {
|
|
3004
3011
|
var e, o, r;
|
|
3005
3012
|
const t = [];
|
|
3006
3013
|
return "heading" in n && "level" in n.heading.propSchema && ((e = n.heading.propSchema.level.values) != null && e.includes(1) && t.push({
|
|
3007
3014
|
name: "Heading",
|
|
3008
3015
|
aliases: ["h", "heading1", "h1"],
|
|
3009
|
-
execute: (i) =>
|
|
3016
|
+
execute: (i) => N(i, {
|
|
3010
3017
|
type: "heading",
|
|
3011
3018
|
props: { level: 1 }
|
|
3012
3019
|
})
|
|
3013
3020
|
}), (o = n.heading.propSchema.level.values) != null && o.includes(2) && t.push({
|
|
3014
3021
|
name: "Heading 2",
|
|
3015
3022
|
aliases: ["h2", "heading2", "subheading"],
|
|
3016
|
-
execute: (i) =>
|
|
3023
|
+
execute: (i) => N(i, {
|
|
3017
3024
|
type: "heading",
|
|
3018
3025
|
props: { level: 2 }
|
|
3019
3026
|
})
|
|
3020
3027
|
}), (r = n.heading.propSchema.level.values) != null && r.includes(3) && t.push({
|
|
3021
3028
|
name: "Heading 3",
|
|
3022
3029
|
aliases: ["h3", "heading3", "subheading"],
|
|
3023
|
-
execute: (i) =>
|
|
3030
|
+
execute: (i) => N(i, {
|
|
3024
3031
|
type: "heading",
|
|
3025
3032
|
props: { level: 3 }
|
|
3026
3033
|
})
|
|
3027
3034
|
})), "bulletListItem" in n && t.push({
|
|
3028
3035
|
name: "Bullet List",
|
|
3029
3036
|
aliases: ["ul", "list", "bulletlist", "bullet list"],
|
|
3030
|
-
execute: (i) =>
|
|
3037
|
+
execute: (i) => N(i, {
|
|
3031
3038
|
type: "bulletListItem"
|
|
3032
3039
|
})
|
|
3033
3040
|
}), "numberedListItem" in n && t.push({
|
|
3034
3041
|
name: "Numbered List",
|
|
3035
3042
|
aliases: ["li", "list", "numberedlist", "numbered list"],
|
|
3036
|
-
execute: (i) =>
|
|
3043
|
+
execute: (i) => N(i, {
|
|
3037
3044
|
type: "numberedListItem"
|
|
3038
3045
|
})
|
|
3039
3046
|
}), "paragraph" in n && t.push({
|
|
3040
3047
|
name: "Paragraph",
|
|
3041
3048
|
aliases: ["p"],
|
|
3042
|
-
execute: (i) =>
|
|
3049
|
+
execute: (i) => N(i, {
|
|
3043
3050
|
type: "paragraph"
|
|
3044
3051
|
})
|
|
3045
3052
|
}), "image" in n && t.push({
|
|
@@ -3056,24 +3063,24 @@ const Ko = (n = jt) => {
|
|
|
3056
3063
|
"dropbox"
|
|
3057
3064
|
],
|
|
3058
3065
|
execute: (i) => {
|
|
3059
|
-
|
|
3066
|
+
N(i, {
|
|
3060
3067
|
type: "image"
|
|
3061
3068
|
}), i.setTextCursorPosition(
|
|
3062
3069
|
i.getTextCursorPosition().nextBlock,
|
|
3063
3070
|
"start"
|
|
3064
3071
|
), i._tiptapEditor.view.dispatch(
|
|
3065
|
-
i._tiptapEditor.state.tr.setMeta(
|
|
3072
|
+
i._tiptapEditor.state.tr.setMeta(U, {
|
|
3066
3073
|
block: i.getTextCursorPosition().prevBlock
|
|
3067
3074
|
})
|
|
3068
3075
|
);
|
|
3069
3076
|
}
|
|
3070
3077
|
}), t;
|
|
3071
|
-
},
|
|
3078
|
+
}, Jo = {
|
|
3072
3079
|
enableInputRules: !0,
|
|
3073
3080
|
enablePasteRules: !0,
|
|
3074
3081
|
enableCoreExtensions: !1
|
|
3075
3082
|
};
|
|
3076
|
-
class
|
|
3083
|
+
class _n {
|
|
3077
3084
|
constructor(t = {}) {
|
|
3078
3085
|
u(this, "_tiptapEditor");
|
|
3079
3086
|
u(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
@@ -3085,7 +3092,7 @@ class xn {
|
|
|
3085
3092
|
u(this, "hyperlinkToolbar");
|
|
3086
3093
|
u(this, "imageToolbar");
|
|
3087
3094
|
u(this, "uploadFile");
|
|
3088
|
-
var l, a, d, c, m;
|
|
3095
|
+
var l, a, d, c, h, m, p, f, b, w, C, M;
|
|
3089
3096
|
this.options = t;
|
|
3090
3097
|
const e = {
|
|
3091
3098
|
defaultStyles: !0,
|
|
@@ -3094,19 +3101,19 @@ class xn {
|
|
|
3094
3101
|
// If BSchema is not specified, then options.blockSchema should also not
|
|
3095
3102
|
// be defined. Unfortunately, trying to implement these constraints seems
|
|
3096
3103
|
// to be a huge pain, hence the `as any` casts.
|
|
3097
|
-
blockSchema: t.blockSchema ||
|
|
3104
|
+
blockSchema: t.blockSchema || qt,
|
|
3098
3105
|
...t
|
|
3099
3106
|
};
|
|
3100
|
-
this.sideMenu = new
|
|
3107
|
+
this.sideMenu = new Ko(this), this.formattingToolbar = new zo(this), this.slashMenu = new Ze(
|
|
3101
3108
|
this,
|
|
3102
|
-
e.slashMenuItems ||
|
|
3103
|
-
), this.hyperlinkToolbar = new
|
|
3104
|
-
const o =
|
|
3109
|
+
e.slashMenuItems || Yo(e.blockSchema)
|
|
3110
|
+
), this.hyperlinkToolbar = new Fo(this), this.imageToolbar = new Lo(this);
|
|
3111
|
+
const o = io({
|
|
3105
3112
|
editor: this,
|
|
3106
3113
|
domAttributes: e.domAttributes || {},
|
|
3107
3114
|
blockSchema: e.blockSchema,
|
|
3108
3115
|
collaboration: e.collaboration
|
|
3109
|
-
}), r =
|
|
3116
|
+
}), r = L.create({
|
|
3110
3117
|
name: "BlockNoteUIExtension",
|
|
3111
3118
|
addProseMirrorPlugins: () => [
|
|
3112
3119
|
this.sideMenu.plugin,
|
|
@@ -3120,50 +3127,54 @@ class xn {
|
|
|
3120
3127
|
const i = e.initialContent || (t.collaboration ? void 0 : [
|
|
3121
3128
|
{
|
|
3122
3129
|
type: "paragraph",
|
|
3123
|
-
id:
|
|
3130
|
+
id: X.options.generateID()
|
|
3124
3131
|
}
|
|
3125
3132
|
]), s = {
|
|
3126
|
-
...
|
|
3133
|
+
...Jo,
|
|
3127
3134
|
...e._tiptapOptions,
|
|
3128
|
-
onBeforeCreate(
|
|
3129
|
-
|
|
3135
|
+
onBeforeCreate(E) {
|
|
3136
|
+
var g, x;
|
|
3137
|
+
if ((x = (g = e._tiptapOptions) == null ? void 0 : g.onBeforeCreate) == null || x.call(g, E), !i)
|
|
3130
3138
|
return;
|
|
3131
|
-
const
|
|
3139
|
+
const y = E.editor.schema, S = y.node(
|
|
3132
3140
|
"doc",
|
|
3133
3141
|
void 0,
|
|
3134
|
-
|
|
3135
|
-
|
|
3142
|
+
y.node("blockGroup", void 0, [
|
|
3143
|
+
F({ id: "initialBlock", type: "paragraph" }, y)
|
|
3136
3144
|
])
|
|
3137
3145
|
);
|
|
3138
|
-
|
|
3146
|
+
E.editor.options.content = S.toJSON();
|
|
3139
3147
|
},
|
|
3140
|
-
onCreate: () => {
|
|
3141
|
-
var
|
|
3142
|
-
i !== void 0 && this.replaceBlocks(this.topLevelBlocks, i), (
|
|
3148
|
+
onCreate: (E) => {
|
|
3149
|
+
var y, S, g;
|
|
3150
|
+
(S = (y = e._tiptapOptions) == null ? void 0 : y.onCreate) == null || S.call(y, E), i !== void 0 && this.replaceBlocks(this.topLevelBlocks, i), (g = e.onEditorReady) == null || g.call(e, this), this.ready = !0;
|
|
3143
3151
|
},
|
|
3144
|
-
onUpdate: () => {
|
|
3145
|
-
var
|
|
3146
|
-
this.ready && ((
|
|
3152
|
+
onUpdate: (E) => {
|
|
3153
|
+
var y, S, g;
|
|
3154
|
+
(S = (y = e._tiptapOptions) == null ? void 0 : y.onUpdate) == null || S.call(y, E), this.ready && ((g = e.onEditorContentChange) == null || g.call(e, this));
|
|
3147
3155
|
},
|
|
3148
|
-
onSelectionUpdate: () => {
|
|
3149
|
-
var
|
|
3150
|
-
this.ready && ((
|
|
3156
|
+
onSelectionUpdate: (E) => {
|
|
3157
|
+
var y, S, g;
|
|
3158
|
+
(S = (y = e._tiptapOptions) == null ? void 0 : y.onSelectionUpdate) == null || S.call(y, E), this.ready && ((g = e.onTextCursorPositionChange) == null || g.call(e, this));
|
|
3151
3159
|
},
|
|
3152
|
-
editable: t.editable
|
|
3153
|
-
extensions: e.enableBlockNoteExtensions === !1 ? (
|
|
3160
|
+
editable: t.editable !== void 0 ? t.editable : ((l = e._tiptapOptions) == null ? void 0 : l.editable) !== void 0 ? (a = e._tiptapOptions) == null ? void 0 : a.editable : !0,
|
|
3161
|
+
extensions: e.enableBlockNoteExtensions === !1 ? ((d = e._tiptapOptions) == null ? void 0 : d.extensions) || [] : [...((c = e._tiptapOptions) == null ? void 0 : c.extensions) || [], ...o],
|
|
3154
3162
|
editorProps: {
|
|
3163
|
+
...(h = e._tiptapOptions) == null ? void 0 : h.editorProps,
|
|
3155
3164
|
attributes: {
|
|
3156
|
-
...(
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
((
|
|
3165
|
+
...(p = (m = e._tiptapOptions) == null ? void 0 : m.editorProps) == null ? void 0 : p.attributes,
|
|
3166
|
+
...(f = e.domAttributes) == null ? void 0 : f.editor,
|
|
3167
|
+
class: B(
|
|
3168
|
+
R.bnEditor,
|
|
3169
|
+
R.bnRoot,
|
|
3170
|
+
((w = (b = e.domAttributes) == null ? void 0 : b.editor) == null ? void 0 : w.class) || "",
|
|
3171
|
+
e.defaultStyles ? R.defaultStyles : "",
|
|
3172
|
+
((M = (C = e.domAttributes) == null ? void 0 : C.editor) == null ? void 0 : M.class) || ""
|
|
3162
3173
|
)
|
|
3163
3174
|
}
|
|
3164
3175
|
}
|
|
3165
3176
|
};
|
|
3166
|
-
e.parentElement && (s.element = e.parentElement), this._tiptapEditor = new
|
|
3177
|
+
e.parentElement && (s.element = e.parentElement), this._tiptapEditor = new ie(s);
|
|
3167
3178
|
}
|
|
3168
3179
|
get prosemirrorView() {
|
|
3169
3180
|
return this._tiptapEditor.view;
|
|
@@ -3183,7 +3194,7 @@ class xn {
|
|
|
3183
3194
|
*/
|
|
3184
3195
|
get topLevelBlocks() {
|
|
3185
3196
|
const t = [];
|
|
3186
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((e) => (t.push(
|
|
3197
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((e) => (t.push(A(e, this.schema, this.blockCache)), !1)), t;
|
|
3187
3198
|
}
|
|
3188
3199
|
/**
|
|
3189
3200
|
* Gets a snapshot of an existing block from the editor.
|
|
@@ -3193,7 +3204,7 @@ class xn {
|
|
|
3193
3204
|
getBlock(t) {
|
|
3194
3205
|
const e = typeof t == "string" ? t : t.id;
|
|
3195
3206
|
let o;
|
|
3196
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== e ? !0 : (o =
|
|
3207
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== e ? !0 : (o = A(r, this.schema, this.blockCache), !1)), o;
|
|
3197
3208
|
}
|
|
3198
3209
|
/**
|
|
3199
3210
|
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
@@ -3234,7 +3245,7 @@ class xn {
|
|
|
3234
3245
|
* @returns A snapshot of the current text cursor position.
|
|
3235
3246
|
*/
|
|
3236
3247
|
getTextCursorPosition() {
|
|
3237
|
-
const { node: t, depth: e, startPos: o, endPos: r } =
|
|
3248
|
+
const { node: t, depth: e, startPos: o, endPos: r } = v(
|
|
3238
3249
|
this._tiptapEditor.state.doc,
|
|
3239
3250
|
this._tiptapEditor.state.selection.from
|
|
3240
3251
|
), i = this._tiptapEditor.state.doc.resolve(r).index(e - 1), s = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
|
|
@@ -3242,9 +3253,9 @@ class xn {
|
|
|
3242
3253
|
i > 0 && (l = this._tiptapEditor.state.doc.resolve(o - 2).node());
|
|
3243
3254
|
let a;
|
|
3244
3255
|
return i < s - 1 && (a = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
|
|
3245
|
-
block:
|
|
3246
|
-
prevBlock: l === void 0 ? void 0 :
|
|
3247
|
-
nextBlock: a === void 0 ? void 0 :
|
|
3256
|
+
block: A(t, this.schema, this.blockCache),
|
|
3257
|
+
prevBlock: l === void 0 ? void 0 : A(l, this.schema, this.blockCache),
|
|
3258
|
+
nextBlock: a === void 0 ? void 0 : A(a, this.schema, this.blockCache)
|
|
3248
3259
|
};
|
|
3249
3260
|
}
|
|
3250
3261
|
/**
|
|
@@ -3254,7 +3265,7 @@ class xn {
|
|
|
3254
3265
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
3255
3266
|
*/
|
|
3256
3267
|
setTextCursorPosition(t, e = "start") {
|
|
3257
|
-
const o = typeof t == "string" ? t : t.id, { posBeforeNode: r } =
|
|
3268
|
+
const o = typeof t == "string" ? t : t.id, { posBeforeNode: r } = ot(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = v(
|
|
3258
3269
|
this._tiptapEditor.state.doc,
|
|
3259
3270
|
r + 2
|
|
3260
3271
|
);
|
|
@@ -3274,7 +3285,7 @@ class xn {
|
|
|
3274
3285
|
return;
|
|
3275
3286
|
const t = [];
|
|
3276
3287
|
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(
|
|
3277
|
-
|
|
3288
|
+
A(
|
|
3278
3289
|
this._tiptapEditor.state.doc.resolve(o).node(),
|
|
3279
3290
|
this.schema,
|
|
3280
3291
|
this.blockCache
|
|
@@ -3304,7 +3315,7 @@ class xn {
|
|
|
3304
3315
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
3305
3316
|
*/
|
|
3306
3317
|
insertBlocks(t, e, o = "before") {
|
|
3307
|
-
|
|
3318
|
+
Ft(t, e, o, this._tiptapEditor);
|
|
3308
3319
|
}
|
|
3309
3320
|
/**
|
|
3310
3321
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -3314,14 +3325,14 @@ class xn {
|
|
|
3314
3325
|
* @param update A partial block which defines how the existing block should be changed.
|
|
3315
3326
|
*/
|
|
3316
3327
|
updateBlock(t, e) {
|
|
3317
|
-
|
|
3328
|
+
so(t, e, this._tiptapEditor);
|
|
3318
3329
|
}
|
|
3319
3330
|
/**
|
|
3320
3331
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
3321
3332
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
3322
3333
|
*/
|
|
3323
3334
|
removeBlocks(t) {
|
|
3324
|
-
|
|
3335
|
+
$t(t, this._tiptapEditor);
|
|
3325
3336
|
}
|
|
3326
3337
|
/**
|
|
3327
3338
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -3331,7 +3342,7 @@ class xn {
|
|
|
3331
3342
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
3332
3343
|
*/
|
|
3333
3344
|
replaceBlocks(t, e) {
|
|
3334
|
-
|
|
3345
|
+
ao(t, e, this._tiptapEditor);
|
|
3335
3346
|
}
|
|
3336
3347
|
/**
|
|
3337
3348
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -3423,7 +3434,7 @@ class xn {
|
|
|
3423
3434
|
* Checks if the block containing the text cursor can be nested.
|
|
3424
3435
|
*/
|
|
3425
3436
|
canNestBlock() {
|
|
3426
|
-
const { startPos: t, depth: e } =
|
|
3437
|
+
const { startPos: t, depth: e } = v(
|
|
3427
3438
|
this._tiptapEditor.state.doc,
|
|
3428
3439
|
this._tiptapEditor.state.selection.from
|
|
3429
3440
|
);
|
|
@@ -3439,7 +3450,7 @@ class xn {
|
|
|
3439
3450
|
* Checks if the block containing the text cursor is nested.
|
|
3440
3451
|
*/
|
|
3441
3452
|
canUnnestBlock() {
|
|
3442
|
-
const { depth: t } =
|
|
3453
|
+
const { depth: t } = v(
|
|
3443
3454
|
this._tiptapEditor.state.doc,
|
|
3444
3455
|
this._tiptapEditor.state.selection.from
|
|
3445
3456
|
);
|
|
@@ -3458,7 +3469,7 @@ class xn {
|
|
|
3458
3469
|
* @returns The blocks, serialized as an HTML string.
|
|
3459
3470
|
*/
|
|
3460
3471
|
async blocksToHTML(t) {
|
|
3461
|
-
return
|
|
3472
|
+
return Wt(t, this._tiptapEditor.schema);
|
|
3462
3473
|
}
|
|
3463
3474
|
/**
|
|
3464
3475
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -3468,7 +3479,7 @@ class xn {
|
|
|
3468
3479
|
* @returns The blocks parsed from the HTML string.
|
|
3469
3480
|
*/
|
|
3470
3481
|
async HTMLToBlocks(t) {
|
|
3471
|
-
return
|
|
3482
|
+
return Gt(t, this.schema, this._tiptapEditor.schema);
|
|
3472
3483
|
}
|
|
3473
3484
|
/**
|
|
3474
3485
|
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
@@ -3477,7 +3488,7 @@ class xn {
|
|
|
3477
3488
|
* @returns The blocks, serialized as a Markdown string.
|
|
3478
3489
|
*/
|
|
3479
3490
|
async blocksToMarkdown(t) {
|
|
3480
|
-
return
|
|
3491
|
+
return uo(t, this._tiptapEditor.schema);
|
|
3481
3492
|
}
|
|
3482
3493
|
/**
|
|
3483
3494
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -3487,7 +3498,7 @@ class xn {
|
|
|
3487
3498
|
* @returns The blocks parsed from the Markdown string.
|
|
3488
3499
|
*/
|
|
3489
3500
|
async markdownToBlocks(t) {
|
|
3490
|
-
return
|
|
3501
|
+
return ho(t, this.schema, this._tiptapEditor.schema);
|
|
3491
3502
|
}
|
|
3492
3503
|
/**
|
|
3493
3504
|
* Updates the user info for the current user that's shown to other collaborators.
|
|
@@ -3500,7 +3511,7 @@ class xn {
|
|
|
3500
3511
|
this._tiptapEditor.commands.updateUser(t);
|
|
3501
3512
|
}
|
|
3502
3513
|
}
|
|
3503
|
-
const
|
|
3514
|
+
const An = async (n) => {
|
|
3504
3515
|
const t = new FormData();
|
|
3505
3516
|
return t.append("file", n), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
|
|
3506
3517
|
method: "POST",
|
|
@@ -3511,37 +3522,37 @@ const In = async (n) => {
|
|
|
3511
3522
|
);
|
|
3512
3523
|
};
|
|
3513
3524
|
export {
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3525
|
+
_n as BlockNoteEditor,
|
|
3526
|
+
Xe as CustomBlockSerializerExtension,
|
|
3527
|
+
zo as FormattingToolbarProsemirrorPlugin,
|
|
3528
|
+
Oo as FormattingToolbarView,
|
|
3529
|
+
Fo as HyperlinkToolbarProsemirrorPlugin,
|
|
3530
|
+
Lo as ImageToolbarProsemirrorPlugin,
|
|
3531
|
+
Ho as ImageToolbarView,
|
|
3532
|
+
Ko as SideMenuProsemirrorPlugin,
|
|
3533
|
+
qo as SideMenuView,
|
|
3534
|
+
Ze as SlashMenuProsemirrorPlugin,
|
|
3535
|
+
De as UnreachableCaseError,
|
|
3536
|
+
In as blockStyles,
|
|
3537
|
+
ct as camelToDataKebab,
|
|
3538
|
+
ko as createBlockSpec,
|
|
3539
|
+
W as createTipTapBlock,
|
|
3540
|
+
qt as defaultBlockSchema,
|
|
3541
|
+
T as defaultProps,
|
|
3542
|
+
xn as formatKeyboardShortcut,
|
|
3543
|
+
Ro as formattingToolbarPluginKey,
|
|
3544
|
+
io as getBlockNoteExtensions,
|
|
3545
|
+
Yo as getDefaultSlashMenuItems,
|
|
3546
|
+
Uo as hyperlinkToolbarPluginKey,
|
|
3547
|
+
U as imageToolbarPluginKey,
|
|
3548
|
+
Pe as isAppleOS,
|
|
3549
|
+
B as mergeCSSClasses,
|
|
3550
|
+
fo as parse,
|
|
3551
|
+
mo as propsToAttributes,
|
|
3552
|
+
go as render,
|
|
3553
|
+
Je as setupSuggestionsMenu,
|
|
3554
|
+
Xo as sideMenuPluginKey,
|
|
3555
|
+
et as slashMenuPluginKey,
|
|
3556
|
+
An as uploadToTmpFilesDotOrg_DEV_ONLY
|
|
3546
3557
|
};
|
|
3547
3558
|
//# sourceMappingURL=blocknote.js.map
|