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