@blocknote/core 0.9.0 → 0.9.3
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 +487 -431
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +2 -2
- package/src/BlockNoteExtensions.ts +24 -22
- package/src/api/blockManipulation/blockManipulation.test.ts +2 -2
- package/src/api/blockManipulation/blockManipulation.ts +1 -1
- package/src/api/formatConversions/formatConversions.test.ts +2 -2
- package/src/api/formatConversions/formatConversions.ts +47 -3
- package/src/api/nodeConversions/nodeConversions.test.ts +6 -6
- package/src/api/nodeConversions/nodeConversions.ts +6 -6
- package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +2 -2
- package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +27 -5
- package/src/extensions/Blocks/nodes/BlockContainer.ts +41 -17
- package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +2 -0
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +2 -0
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +2 -0
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +3 -3
- package/src/extensions/SideMenu/SideMenuPlugin.ts +9 -9
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +13 -1
- package/src/extensions/UniqueID/UniqueID.ts +10 -9
- package/src/shared/EventEmitter.ts +1 -0
- package/src/shared/plugins/suggestion/SuggestionPlugin.ts +6 -2
- package/types/src/extensions/Blocks/NonEditableBlockPlugin.d.ts +2 -0
- package/types/src/extensions/Blocks/api/defaultProps.d.ts +14 -0
- package/types/src/extensions/Blocks/helpers/getBlockInfoFromPos.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/Image.d.ts +6 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.d.ts +37 -0
- package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +36 -0
- package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +1 -1
- package/types/src/EventEmitter.d.ts +0 -11
- package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +0 -0
- package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +0 -16
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +0 -55
- package/types/src/extensions/DraggableBlocks/MultipleNodeSelection.d.ts +0 -24
- package/types/src/extensions/FormattingToolbar/FormattingToolbarExtension.d.ts +0 -11
- package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +0 -10
- package/types/src/extensions/HyperlinkToolbar/HyperlinkMark.d.ts +0 -8
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +0 -0
- package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +0 -13
- package/types/src/extensions/SlashMenu/index.d.ts +0 -3
- package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +0 -12
package/dist/blocknote.js
CHANGED
|
@@ -1,42 +1,52 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Extension as T, Mark as lt, Node as U, InputRule as K, mergeAttributes as A, combineTransactionSteps 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 x, Fragment as
|
|
19
|
-
import { PluginKey as
|
|
20
|
-
import { v4 as
|
|
21
|
-
import * as
|
|
1
|
+
var Pt = Object.defineProperty;
|
|
2
|
+
var Ot = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var p = (n, e, t) => (Ot(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { Extension as T, Mark as lt, Node as U, InputRule as K, mergeAttributes as A, combineTransactionSteps as Dt, getChangedRanges as Rt, findChildrenInRange as Vt, findChildren as tt, findParentNode as zt, extensions as L, isTextSelection as Ut, isNodeSelection as Ft, posToDOMRect as q, getMarkRange as et, Editor as Gt } from "@tiptap/core";
|
|
5
|
+
import { Bold as $t } from "@tiptap/extension-bold";
|
|
6
|
+
import { Code as jt } from "@tiptap/extension-code";
|
|
7
|
+
import qt from "@tiptap/extension-collaboration";
|
|
8
|
+
import Wt from "@tiptap/extension-collaboration-cursor";
|
|
9
|
+
import { Dropcursor as Yt } from "@tiptap/extension-dropcursor";
|
|
10
|
+
import { Gapcursor as Kt } from "@tiptap/extension-gapcursor";
|
|
11
|
+
import { HardBreak as Jt } from "@tiptap/extension-hard-break";
|
|
12
|
+
import { History as Xt } from "@tiptap/extension-history";
|
|
13
|
+
import { Italic as Zt } from "@tiptap/extension-italic";
|
|
14
|
+
import { Link as Qt } from "@tiptap/extension-link";
|
|
15
|
+
import { Strike as te } from "@tiptap/extension-strike";
|
|
16
|
+
import { Text as ee } from "@tiptap/extension-text";
|
|
17
|
+
import { Underline as oe } from "@tiptap/extension-underline";
|
|
18
|
+
import { Slice as x, Fragment as _, DOMSerializer as W, DOMParser as ne } from "prosemirror-model";
|
|
19
|
+
import { PluginKey as S, Plugin as w, TextSelection as ot, Selection as j, NodeSelection as re } from "prosemirror-state";
|
|
20
|
+
import { v4 as ie } from "uuid";
|
|
21
|
+
import * as se from "prosemirror-view";
|
|
22
22
|
import { Decoration as V, DecorationSet as z } from "prosemirror-view";
|
|
23
23
|
import dt from "rehype-parse";
|
|
24
|
-
import
|
|
24
|
+
import ae from "rehype-remark";
|
|
25
25
|
import ct from "rehype-stringify";
|
|
26
26
|
import ut from "remark-gfm";
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
27
|
+
import le from "remark-parse";
|
|
28
|
+
import de, { defaultHandlers as ce } from "remark-rehype";
|
|
29
|
+
import ue from "remark-stringify";
|
|
30
30
|
import { unified as J } from "unified";
|
|
31
31
|
import { fromDom as nt } from "hast-util-from-dom";
|
|
32
|
-
const
|
|
33
|
-
bnEditor:
|
|
34
|
-
bnRoot:
|
|
35
|
-
defaultStyles:
|
|
36
|
-
dragPreview:
|
|
32
|
+
const pe = "_bnEditor_1pmoa_3", he = "_bnRoot_1pmoa_19", fe = "_defaultStyles_1pmoa_34", me = "_dragPreview_1pmoa_57", H = {
|
|
33
|
+
bnEditor: pe,
|
|
34
|
+
bnRoot: he,
|
|
35
|
+
defaultStyles: fe,
|
|
36
|
+
dragPreview: me,
|
|
37
37
|
"collaboration-cursor__caret": "_collaboration-cursor__caret_1pmoa_63",
|
|
38
38
|
"collaboration-cursor__label": "_collaboration-cursor__label_1pmoa_74"
|
|
39
39
|
};
|
|
40
|
+
function pt(n) {
|
|
41
|
+
const e = n.attrs.id, t = n.firstChild, o = t.type, r = n.childCount === 2 ? n.lastChild.childCount : 0;
|
|
42
|
+
return {
|
|
43
|
+
id: e,
|
|
44
|
+
node: n,
|
|
45
|
+
contentNode: t,
|
|
46
|
+
contentType: o,
|
|
47
|
+
numChildBlocks: r
|
|
48
|
+
};
|
|
49
|
+
}
|
|
40
50
|
function k(n, e) {
|
|
41
51
|
const o = n.nodeSize - 2;
|
|
42
52
|
if (e <= 1)
|
|
@@ -57,19 +67,19 @@ function k(n, e) {
|
|
|
57
67
|
break;
|
|
58
68
|
l -= 1, s = r.node(l);
|
|
59
69
|
}
|
|
60
|
-
const
|
|
70
|
+
const { id: a, contentNode: d, contentType: c, numChildBlocks: h } = pt(s), u = r.start(l), f = r.end(l);
|
|
61
71
|
return {
|
|
62
72
|
id: a,
|
|
63
73
|
node: s,
|
|
64
74
|
contentNode: d,
|
|
65
75
|
contentType: c,
|
|
66
76
|
numChildBlocks: h,
|
|
67
|
-
startPos:
|
|
77
|
+
startPos: u,
|
|
68
78
|
endPos: f,
|
|
69
79
|
depth: l
|
|
70
80
|
};
|
|
71
81
|
}
|
|
72
|
-
const
|
|
82
|
+
const ke = T.create({
|
|
73
83
|
name: "blockBackgroundColor",
|
|
74
84
|
addGlobalAttributes() {
|
|
75
85
|
return [
|
|
@@ -99,7 +109,7 @@ const fe = T.create({
|
|
|
99
109
|
}
|
|
100
110
|
};
|
|
101
111
|
}
|
|
102
|
-
}),
|
|
112
|
+
}), ge = lt.create({
|
|
103
113
|
name: "backgroundColor",
|
|
104
114
|
addAttributes() {
|
|
105
115
|
return {
|
|
@@ -128,36 +138,36 @@ const fe = T.create({
|
|
|
128
138
|
setBackgroundColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
129
139
|
};
|
|
130
140
|
}
|
|
131
|
-
}),
|
|
132
|
-
blockOuter:
|
|
133
|
-
block:
|
|
134
|
-
reactNodeViewRenderer:
|
|
135
|
-
blockContent:
|
|
136
|
-
blockGroup:
|
|
137
|
-
isEmpty:
|
|
138
|
-
inlineContent:
|
|
139
|
-
isFilter:
|
|
140
|
-
hasAnchor:
|
|
141
|
-
},
|
|
141
|
+
}), ht = "_blockOuter_7sok8_5", ft = "_block_7sok8_5", mt = "_reactNodeViewRenderer_7sok8_17", kt = "_blockContent_7sok8_22", gt = "_blockGroup_7sok8_42", bt = "_isEmpty_7sok8_240", yt = "_inlineContent_7sok8_240", vt = "_isFilter_7sok8_241", Ct = "_hasAnchor_7sok8_263", y = {
|
|
142
|
+
blockOuter: ht,
|
|
143
|
+
block: ft,
|
|
144
|
+
reactNodeViewRenderer: mt,
|
|
145
|
+
blockContent: kt,
|
|
146
|
+
blockGroup: gt,
|
|
147
|
+
isEmpty: bt,
|
|
148
|
+
inlineContent: yt,
|
|
149
|
+
isFilter: vt,
|
|
150
|
+
hasAnchor: Ct
|
|
151
|
+
}, Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
142
152
|
__proto__: null,
|
|
143
|
-
block:
|
|
144
|
-
blockContent:
|
|
145
|
-
blockGroup:
|
|
146
|
-
blockOuter:
|
|
153
|
+
block: ft,
|
|
154
|
+
blockContent: kt,
|
|
155
|
+
blockGroup: gt,
|
|
156
|
+
blockOuter: ht,
|
|
147
157
|
default: y,
|
|
148
|
-
hasAnchor:
|
|
149
|
-
inlineContent:
|
|
150
|
-
isEmpty:
|
|
151
|
-
isFilter:
|
|
152
|
-
reactNodeViewRenderer:
|
|
153
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
154
|
-
function
|
|
155
|
-
return
|
|
158
|
+
hasAnchor: Ct,
|
|
159
|
+
inlineContent: yt,
|
|
160
|
+
isEmpty: bt,
|
|
161
|
+
isFilter: vt,
|
|
162
|
+
reactNodeViewRenderer: mt
|
|
163
|
+
}, Symbol.toStringTag, { value: "Module" })), be = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
|
164
|
+
function Xo(n) {
|
|
165
|
+
return be() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
|
|
156
166
|
}
|
|
157
167
|
function v(...n) {
|
|
158
168
|
return n.filter((e) => e).join(" ");
|
|
159
169
|
}
|
|
160
|
-
class
|
|
170
|
+
class ye extends Error {
|
|
161
171
|
constructor(e) {
|
|
162
172
|
super(`Unreachable case: ${e}`);
|
|
163
173
|
}
|
|
@@ -165,7 +175,7 @@ class ge extends Error {
|
|
|
165
175
|
function rt(n) {
|
|
166
176
|
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
167
177
|
}
|
|
168
|
-
function
|
|
178
|
+
function ve(n) {
|
|
169
179
|
const e = {};
|
|
170
180
|
return Object.entries(n.propSchema).forEach(([t, o]) => {
|
|
171
181
|
e[t] = {
|
|
@@ -181,14 +191,14 @@ function be(n) {
|
|
|
181
191
|
};
|
|
182
192
|
}), e;
|
|
183
193
|
}
|
|
184
|
-
function
|
|
194
|
+
function Ce(n) {
|
|
185
195
|
return [
|
|
186
196
|
{
|
|
187
197
|
tag: "div[data-content-type=" + n.type + "]"
|
|
188
198
|
}
|
|
189
199
|
];
|
|
190
200
|
}
|
|
191
|
-
function
|
|
201
|
+
function we(n, e) {
|
|
192
202
|
const t = document.createElement("div");
|
|
193
203
|
t.setAttribute("data-content-type", n.type);
|
|
194
204
|
for (const [r, i] of Object.entries(e))
|
|
@@ -201,20 +211,20 @@ function ve(n, e) {
|
|
|
201
211
|
dom: t
|
|
202
212
|
};
|
|
203
213
|
}
|
|
204
|
-
function
|
|
214
|
+
function Zo(n) {
|
|
205
215
|
return {
|
|
206
216
|
node: O({
|
|
207
217
|
name: n.type,
|
|
208
218
|
content: n.containsInlineContent ? "inline*" : "",
|
|
209
219
|
selectable: n.containsInlineContent,
|
|
210
220
|
addAttributes() {
|
|
211
|
-
return
|
|
221
|
+
return ve(n);
|
|
212
222
|
},
|
|
213
223
|
parseHTML() {
|
|
214
|
-
return
|
|
224
|
+
return Ce(n);
|
|
215
225
|
},
|
|
216
226
|
renderHTML({ HTMLAttributes: t }) {
|
|
217
|
-
return
|
|
227
|
+
return we(n, t);
|
|
218
228
|
},
|
|
219
229
|
addNodeView() {
|
|
220
230
|
return ({ HTMLAttributes: t, getPos: o }) => {
|
|
@@ -238,22 +248,22 @@ function Ko(n) {
|
|
|
238
248
|
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, h = s.getBlock(c);
|
|
239
249
|
if (h.type !== n.type)
|
|
240
250
|
throw new Error("Block type does not match");
|
|
241
|
-
const
|
|
242
|
-
if ("contentDOM" in
|
|
251
|
+
const u = n.render(h, s);
|
|
252
|
+
if ("contentDOM" in u) {
|
|
243
253
|
const g = ((m = this.options.domAttributes) == null ? void 0 : m.inlineContent) || {};
|
|
244
254
|
for (const [b, C] of Object.entries(
|
|
245
255
|
g
|
|
246
256
|
))
|
|
247
|
-
b !== "class" &&
|
|
248
|
-
|
|
249
|
-
|
|
257
|
+
b !== "class" && u.contentDOM.setAttribute(b, C);
|
|
258
|
+
u.contentDOM.className = v(
|
|
259
|
+
u.contentDOM.className,
|
|
250
260
|
y.inlineContent,
|
|
251
261
|
g.class
|
|
252
262
|
);
|
|
253
263
|
}
|
|
254
|
-
return r.appendChild(
|
|
264
|
+
return r.appendChild(u.dom), "contentDOM" in u ? {
|
|
255
265
|
dom: r,
|
|
256
|
-
contentDOM:
|
|
266
|
+
contentDOM: u.contentDOM
|
|
257
267
|
} : {
|
|
258
268
|
dom: r
|
|
259
269
|
};
|
|
@@ -269,7 +279,7 @@ function O(n) {
|
|
|
269
279
|
group: "blockContent"
|
|
270
280
|
});
|
|
271
281
|
}
|
|
272
|
-
const
|
|
282
|
+
const Se = O({
|
|
273
283
|
name: "heading",
|
|
274
284
|
content: "inline*",
|
|
275
285
|
addAttributes() {
|
|
@@ -324,6 +334,7 @@ const Ce = O({
|
|
|
324
334
|
return [
|
|
325
335
|
"div",
|
|
326
336
|
A(e, {
|
|
337
|
+
...t,
|
|
327
338
|
class: v(
|
|
328
339
|
y.blockContent,
|
|
329
340
|
t.class
|
|
@@ -333,6 +344,7 @@ const Ce = O({
|
|
|
333
344
|
[
|
|
334
345
|
"h" + n.attrs.level,
|
|
335
346
|
{
|
|
347
|
+
...o,
|
|
336
348
|
class: v(
|
|
337
349
|
y.inlineContent,
|
|
338
350
|
o.class
|
|
@@ -342,7 +354,7 @@ const Ce = O({
|
|
|
342
354
|
]
|
|
343
355
|
];
|
|
344
356
|
}
|
|
345
|
-
}),
|
|
357
|
+
}), wt = (n) => {
|
|
346
358
|
const { node: e, contentType: t } = k(
|
|
347
359
|
n.state.doc,
|
|
348
360
|
n.state.selection.from
|
|
@@ -361,7 +373,7 @@ const Ce = O({
|
|
|
361
373
|
s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
362
374
|
)
|
|
363
375
|
]);
|
|
364
|
-
},
|
|
376
|
+
}, Me = O({
|
|
365
377
|
name: "bulletListItem",
|
|
366
378
|
content: "inline*",
|
|
367
379
|
addInputRules() {
|
|
@@ -380,7 +392,7 @@ const Ce = O({
|
|
|
380
392
|
},
|
|
381
393
|
addKeyboardShortcuts() {
|
|
382
394
|
return {
|
|
383
|
-
Enter: () =>
|
|
395
|
+
Enter: () => wt(this.editor)
|
|
384
396
|
};
|
|
385
397
|
},
|
|
386
398
|
parseHTML() {
|
|
@@ -416,6 +428,7 @@ const Ce = O({
|
|
|
416
428
|
return [
|
|
417
429
|
"div",
|
|
418
430
|
A(n, {
|
|
431
|
+
...e,
|
|
419
432
|
class: v(
|
|
420
433
|
y.blockContent,
|
|
421
434
|
e.class
|
|
@@ -425,6 +438,7 @@ const Ce = O({
|
|
|
425
438
|
[
|
|
426
439
|
"p",
|
|
427
440
|
{
|
|
441
|
+
...t,
|
|
428
442
|
class: v(
|
|
429
443
|
y.inlineContent,
|
|
430
444
|
t.class
|
|
@@ -434,8 +448,8 @@ const Ce = O({
|
|
|
434
448
|
]
|
|
435
449
|
];
|
|
436
450
|
}
|
|
437
|
-
}),
|
|
438
|
-
key:
|
|
451
|
+
}), Ee = new S("numbered-list-indexing"), Be = () => new w({
|
|
452
|
+
key: Ee,
|
|
439
453
|
appendTransaction: (n, e, t) => {
|
|
440
454
|
const o = t.tr;
|
|
441
455
|
o.setMeta("numberedListIndexing", !0);
|
|
@@ -447,12 +461,12 @@ const Ce = O({
|
|
|
447
461
|
if (d === void 0)
|
|
448
462
|
return;
|
|
449
463
|
if (!a) {
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
464
|
+
const u = k(o.doc, s - 2);
|
|
465
|
+
if (u === void 0)
|
|
452
466
|
return;
|
|
453
|
-
if (!(d.depth !==
|
|
454
|
-
const m =
|
|
455
|
-
if (
|
|
467
|
+
if (!(d.depth !== u.depth)) {
|
|
468
|
+
const m = u.contentNode;
|
|
469
|
+
if (u.contentType.name === "numberedListItem") {
|
|
456
470
|
const C = m.attrs.index;
|
|
457
471
|
l = (parseInt(C) + 1).toString();
|
|
458
472
|
}
|
|
@@ -464,7 +478,7 @@ const Ce = O({
|
|
|
464
478
|
}
|
|
465
479
|
}), r ? o : null;
|
|
466
480
|
}
|
|
467
|
-
}),
|
|
481
|
+
}), Te = O({
|
|
468
482
|
name: "numberedListItem",
|
|
469
483
|
content: "inline*",
|
|
470
484
|
addAttributes() {
|
|
@@ -494,11 +508,11 @@ const Ce = O({
|
|
|
494
508
|
},
|
|
495
509
|
addKeyboardShortcuts() {
|
|
496
510
|
return {
|
|
497
|
-
Enter: () =>
|
|
511
|
+
Enter: () => wt(this.editor)
|
|
498
512
|
};
|
|
499
513
|
},
|
|
500
514
|
addProseMirrorPlugins() {
|
|
501
|
-
return [
|
|
515
|
+
return [Be()];
|
|
502
516
|
},
|
|
503
517
|
parseHTML() {
|
|
504
518
|
return [
|
|
@@ -535,6 +549,7 @@ const Ce = O({
|
|
|
535
549
|
return [
|
|
536
550
|
"div",
|
|
537
551
|
A(n, {
|
|
552
|
+
...e,
|
|
538
553
|
class: v(
|
|
539
554
|
y.blockContent,
|
|
540
555
|
e.class
|
|
@@ -546,6 +561,7 @@ const Ce = O({
|
|
|
546
561
|
[
|
|
547
562
|
"p",
|
|
548
563
|
{
|
|
564
|
+
...t,
|
|
549
565
|
class: v(
|
|
550
566
|
y.inlineContent,
|
|
551
567
|
t.class
|
|
@@ -555,7 +571,7 @@ const Ce = O({
|
|
|
555
571
|
]
|
|
556
572
|
];
|
|
557
573
|
}
|
|
558
|
-
}),
|
|
574
|
+
}), xe = O({
|
|
559
575
|
name: "paragraph",
|
|
560
576
|
content: "inline*",
|
|
561
577
|
parseHTML() {
|
|
@@ -611,36 +627,36 @@ const Ce = O({
|
|
|
611
627
|
}, St = {
|
|
612
628
|
paragraph: {
|
|
613
629
|
propSchema: P,
|
|
614
|
-
node:
|
|
630
|
+
node: xe
|
|
615
631
|
},
|
|
616
632
|
heading: {
|
|
617
633
|
propSchema: {
|
|
618
634
|
...P,
|
|
619
635
|
level: { default: "1", values: ["1", "2", "3"] }
|
|
620
636
|
},
|
|
621
|
-
node:
|
|
637
|
+
node: Se
|
|
622
638
|
},
|
|
623
639
|
bulletListItem: {
|
|
624
640
|
propSchema: P,
|
|
625
|
-
node:
|
|
641
|
+
node: Me
|
|
626
642
|
},
|
|
627
643
|
numberedListItem: {
|
|
628
644
|
propSchema: P,
|
|
629
|
-
node:
|
|
645
|
+
node: Te
|
|
630
646
|
}
|
|
631
647
|
};
|
|
632
|
-
function
|
|
648
|
+
function Ae(n, e = JSON.stringify) {
|
|
633
649
|
const t = {};
|
|
634
650
|
return n.filter((o) => {
|
|
635
651
|
const r = e(o);
|
|
636
652
|
return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
|
|
637
653
|
});
|
|
638
654
|
}
|
|
639
|
-
function
|
|
655
|
+
function Ie(n) {
|
|
640
656
|
const e = n.filter(
|
|
641
657
|
(o, r) => n.indexOf(o) !== r
|
|
642
658
|
);
|
|
643
|
-
return
|
|
659
|
+
return Ae(e);
|
|
644
660
|
}
|
|
645
661
|
const F = T.create({
|
|
646
662
|
name: "uniqueID",
|
|
@@ -651,7 +667,13 @@ const F = T.create({
|
|
|
651
667
|
return {
|
|
652
668
|
attributeName: "id",
|
|
653
669
|
types: [],
|
|
654
|
-
generateID: () =>
|
|
670
|
+
generateID: () => {
|
|
671
|
+
if (typeof window < "u" && window.__TEST_OPTIONS) {
|
|
672
|
+
const n = window.__TEST_OPTIONS;
|
|
673
|
+
return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
|
|
674
|
+
}
|
|
675
|
+
return ie();
|
|
676
|
+
},
|
|
655
677
|
filterTransaction: null
|
|
656
678
|
};
|
|
657
679
|
},
|
|
@@ -704,27 +726,27 @@ const F = T.create({
|
|
|
704
726
|
addProseMirrorPlugins() {
|
|
705
727
|
let n = null, e = !1;
|
|
706
728
|
return [
|
|
707
|
-
new
|
|
708
|
-
key: new
|
|
729
|
+
new w({
|
|
730
|
+
key: new S("uniqueID"),
|
|
709
731
|
appendTransaction: (t, o, r) => {
|
|
710
732
|
const i = t.some((m) => m.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && t.some((m) => {
|
|
711
|
-
|
|
733
|
+
let g, b;
|
|
712
734
|
return !(!((b = (g = this.options).filterTransaction) === null || b === void 0) && b.call(g, m));
|
|
713
735
|
});
|
|
714
736
|
if (!i || s)
|
|
715
737
|
return;
|
|
716
|
-
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h =
|
|
738
|
+
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h = Dt(
|
|
717
739
|
o.doc,
|
|
718
740
|
t
|
|
719
|
-
), { mapping:
|
|
720
|
-
if (
|
|
721
|
-
const g =
|
|
741
|
+
), { mapping: u } = h;
|
|
742
|
+
if (Rt(h).forEach(({ newRange: m }) => {
|
|
743
|
+
const g = Vt(
|
|
722
744
|
r.doc,
|
|
723
745
|
m,
|
|
724
746
|
(M) => a.includes(M.type.name)
|
|
725
|
-
), b = g.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C =
|
|
747
|
+
), b = g.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C = Ie(b);
|
|
726
748
|
g.forEach(({ node: M, pos: R }) => {
|
|
727
|
-
|
|
749
|
+
let $;
|
|
728
750
|
const Q = ($ = l.doc.nodeAt(R)) === null || $ === void 0 ? void 0 : $.attrs[d];
|
|
729
751
|
if (Q === null) {
|
|
730
752
|
l.setNodeMarkup(R, void 0, {
|
|
@@ -733,8 +755,8 @@ const F = T.create({
|
|
|
733
755
|
});
|
|
734
756
|
return;
|
|
735
757
|
}
|
|
736
|
-
const { deleted:
|
|
737
|
-
|
|
758
|
+
const { deleted: Lt } = u.invert().mapResult(R);
|
|
759
|
+
Lt && C.includes(Q) && l.setNodeMarkup(R, void 0, {
|
|
738
760
|
...M.attrs,
|
|
739
761
|
[d]: c()
|
|
740
762
|
});
|
|
@@ -745,7 +767,7 @@ const F = T.create({
|
|
|
745
767
|
// we register a global drag handler to track the current drag source element
|
|
746
768
|
view(t) {
|
|
747
769
|
const o = (r) => {
|
|
748
|
-
|
|
770
|
+
let i;
|
|
749
771
|
n = !((i = t.dom.parentElement) === null || i === void 0) && i.contains(r.target) ? t.dom.parentElement : null;
|
|
750
772
|
};
|
|
751
773
|
return window.addEventListener("dragstart", o), {
|
|
@@ -761,7 +783,7 @@ const F = T.create({
|
|
|
761
783
|
// only create new ids for dropped content while holding `alt`
|
|
762
784
|
// or content is dragged from another editor
|
|
763
785
|
drop: (t, o) => {
|
|
764
|
-
|
|
786
|
+
let r;
|
|
765
787
|
return (n !== t.dom.parentElement || ((r = o.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy") && (n = null, e = !0), !1;
|
|
766
788
|
},
|
|
767
789
|
// always create new ids on pasted content
|
|
@@ -792,7 +814,7 @@ const F = T.create({
|
|
|
792
814
|
a.marks
|
|
793
815
|
);
|
|
794
816
|
l.push(d);
|
|
795
|
-
}),
|
|
817
|
+
}), _.from(l);
|
|
796
818
|
};
|
|
797
819
|
return e = !1, new x(
|
|
798
820
|
i(t.content),
|
|
@@ -804,25 +826,25 @@ const F = T.create({
|
|
|
804
826
|
})
|
|
805
827
|
];
|
|
806
828
|
}
|
|
807
|
-
}),
|
|
829
|
+
}), Mt = /* @__PURE__ */ new Set([
|
|
808
830
|
"bold",
|
|
809
831
|
"italic",
|
|
810
832
|
"underline",
|
|
811
833
|
"strike",
|
|
812
834
|
"code"
|
|
813
|
-
]),
|
|
835
|
+
]), Et = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
814
836
|
function it(n, e) {
|
|
815
837
|
const t = [];
|
|
816
838
|
for (const [o, r] of Object.entries(n.styles))
|
|
817
|
-
|
|
839
|
+
Mt.has(o) ? t.push(e.mark(o)) : Et.has(o) && t.push(e.mark(o, { color: r }));
|
|
818
840
|
return n.text.split(/(\n)/g).filter((o) => o.length > 0).map((o) => o === `
|
|
819
841
|
` ? e.nodes.hardBreak.create() : e.text(o, t));
|
|
820
842
|
}
|
|
821
|
-
function
|
|
843
|
+
function _e(n, e) {
|
|
822
844
|
const t = e.marks.link.create({
|
|
823
845
|
href: n.href
|
|
824
846
|
});
|
|
825
|
-
return
|
|
847
|
+
return Bt(n.content, e).map((o) => {
|
|
826
848
|
if (o.type.name === "text")
|
|
827
849
|
return o.mark([...o.marks, t]);
|
|
828
850
|
if (o.type.name === "hardBreak")
|
|
@@ -830,8 +852,8 @@ function Ae(n, e) {
|
|
|
830
852
|
throw new Error("unexpected node type");
|
|
831
853
|
});
|
|
832
854
|
}
|
|
833
|
-
function
|
|
834
|
-
|
|
855
|
+
function Bt(n, e) {
|
|
856
|
+
const t = [];
|
|
835
857
|
if (typeof n == "string")
|
|
836
858
|
return t.push(
|
|
837
859
|
...it({ type: "text", text: n, styles: {} }, e)
|
|
@@ -840,15 +862,15 @@ function Et(n, e) {
|
|
|
840
862
|
t.push(...it(o, e));
|
|
841
863
|
return t;
|
|
842
864
|
}
|
|
843
|
-
function
|
|
844
|
-
|
|
865
|
+
function Tt(n, e) {
|
|
866
|
+
const t = [];
|
|
845
867
|
for (const o of n)
|
|
846
868
|
if (o.type === "link")
|
|
847
|
-
t.push(...
|
|
869
|
+
t.push(..._e(o, e));
|
|
848
870
|
else if (o.type === "text")
|
|
849
|
-
t.push(...
|
|
871
|
+
t.push(...Bt([o], e));
|
|
850
872
|
else
|
|
851
|
-
throw new
|
|
873
|
+
throw new ye(o);
|
|
852
874
|
return t;
|
|
853
875
|
}
|
|
854
876
|
function D(n, e) {
|
|
@@ -865,7 +887,7 @@ function D(n, e) {
|
|
|
865
887
|
e.text(n.content)
|
|
866
888
|
);
|
|
867
889
|
else {
|
|
868
|
-
const l =
|
|
890
|
+
const l = Tt(n.content, e);
|
|
869
891
|
r = e.nodes[o].create(n.props, l);
|
|
870
892
|
}
|
|
871
893
|
const i = [];
|
|
@@ -881,7 +903,7 @@ function D(n, e) {
|
|
|
881
903
|
i.length > 0 ? [r, s] : r
|
|
882
904
|
);
|
|
883
905
|
}
|
|
884
|
-
function
|
|
906
|
+
function He(n) {
|
|
885
907
|
const e = [];
|
|
886
908
|
let t;
|
|
887
909
|
return n.content.forEach((o) => {
|
|
@@ -901,9 +923,9 @@ function _e(n) {
|
|
|
901
923
|
for (const s of o.marks)
|
|
902
924
|
if (s.type.name === "link")
|
|
903
925
|
i = s;
|
|
904
|
-
else if (wt.has(s.type.name))
|
|
905
|
-
r[s.type.name] = !0;
|
|
906
926
|
else if (Mt.has(s.type.name))
|
|
927
|
+
r[s.type.name] = !0;
|
|
928
|
+
else if (Et.has(s.type.name))
|
|
907
929
|
r[s.type.name] = s.attrs.color;
|
|
908
930
|
else
|
|
909
931
|
throw Error("Mark is of an unrecognized type: " + s.type.name);
|
|
@@ -966,26 +988,26 @@ function E(n, e, t) {
|
|
|
966
988
|
const o = t == null ? void 0 : t.get(n);
|
|
967
989
|
if (o)
|
|
968
990
|
return o;
|
|
969
|
-
const r =
|
|
991
|
+
const r = pt(n);
|
|
970
992
|
let i = r.id;
|
|
971
993
|
i === null && (i = F.options.generateID());
|
|
972
994
|
const s = {};
|
|
973
995
|
for (const [c, h] of Object.entries({
|
|
974
|
-
...
|
|
996
|
+
...n.attrs,
|
|
975
997
|
...r.contentNode.attrs
|
|
976
998
|
})) {
|
|
977
|
-
const
|
|
978
|
-
if (!
|
|
999
|
+
const u = e[r.contentType.name];
|
|
1000
|
+
if (!u)
|
|
979
1001
|
throw Error(
|
|
980
1002
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
981
1003
|
);
|
|
982
|
-
const f =
|
|
1004
|
+
const f = u.propSchema;
|
|
983
1005
|
c in f ? s[c] = h : c !== "id" && !(c in P) && console.warn("Block has an unrecognized attribute: " + c);
|
|
984
1006
|
}
|
|
985
|
-
const l =
|
|
1007
|
+
const l = He(r.contentNode), a = [];
|
|
986
1008
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
987
1009
|
a.push(
|
|
988
|
-
E(
|
|
1010
|
+
E(n.lastChild.child(c), e, t)
|
|
989
1011
|
);
|
|
990
1012
|
const d = {
|
|
991
1013
|
id: i,
|
|
@@ -996,7 +1018,7 @@ function E(n, e, t) {
|
|
|
996
1018
|
};
|
|
997
1019
|
return t == null || t.set(n, d), d;
|
|
998
1020
|
}
|
|
999
|
-
const st = new
|
|
1021
|
+
const st = new S("previous-blocks"), Ne = {
|
|
1000
1022
|
// Numbered List Items
|
|
1001
1023
|
index: "index",
|
|
1002
1024
|
// Headings
|
|
@@ -1005,9 +1027,9 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1005
1027
|
type: "type",
|
|
1006
1028
|
depth: "depth",
|
|
1007
1029
|
"depth-change": "depth-change"
|
|
1008
|
-
},
|
|
1030
|
+
}, Le = () => {
|
|
1009
1031
|
let n;
|
|
1010
|
-
return new
|
|
1032
|
+
return new w({
|
|
1011
1033
|
key: st,
|
|
1012
1034
|
view(e) {
|
|
1013
1035
|
return {
|
|
@@ -1041,13 +1063,13 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1041
1063
|
const i = {}, s = tt(o.doc, (d) => d.attrs.id), l = new Map(
|
|
1042
1064
|
s.map((d) => [d.node.attrs.id, d])
|
|
1043
1065
|
), a = tt(r.doc, (d) => d.attrs.id);
|
|
1044
|
-
for (
|
|
1045
|
-
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild,
|
|
1046
|
-
if (c && h &&
|
|
1066
|
+
for (const d of a) {
|
|
1067
|
+
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, u = d.node.firstChild;
|
|
1068
|
+
if (c && h && u) {
|
|
1047
1069
|
const f = {
|
|
1048
|
-
index:
|
|
1049
|
-
level:
|
|
1050
|
-
type:
|
|
1070
|
+
index: u.attrs.index,
|
|
1071
|
+
level: u.attrs.level,
|
|
1072
|
+
type: u.type.name,
|
|
1051
1073
|
depth: r.doc.resolve(d.pos).depth
|
|
1052
1074
|
};
|
|
1053
1075
|
let m = {
|
|
@@ -1072,8 +1094,8 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1072
1094
|
if (!r.attrs.id || !t.updatedBlocks.has(r.attrs.id))
|
|
1073
1095
|
return;
|
|
1074
1096
|
const s = t.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
|
|
1075
|
-
for (
|
|
1076
|
-
l["data-prev-" +
|
|
1097
|
+
for (const [d, c] of Object.entries(s))
|
|
1098
|
+
l["data-prev-" + Ne[d]] = c || "none";
|
|
1077
1099
|
const a = V.node(i, i + r.nodeSize, {
|
|
1078
1100
|
...l
|
|
1079
1101
|
});
|
|
@@ -1082,13 +1104,13 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1082
1104
|
}
|
|
1083
1105
|
}
|
|
1084
1106
|
});
|
|
1085
|
-
},
|
|
1107
|
+
}, Pe = {
|
|
1086
1108
|
blockColor: "data-block-color",
|
|
1087
1109
|
blockStyle: "data-block-style",
|
|
1088
1110
|
id: "data-id",
|
|
1089
1111
|
depth: "data-depth",
|
|
1090
1112
|
depthChange: "data-depth-change"
|
|
1091
|
-
},
|
|
1113
|
+
}, Oe = U.create({
|
|
1092
1114
|
name: "blockContainer",
|
|
1093
1115
|
group: "blockContainer",
|
|
1094
1116
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -1104,7 +1126,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1104
1126
|
if (typeof n == "string")
|
|
1105
1127
|
return !1;
|
|
1106
1128
|
const e = {};
|
|
1107
|
-
for (
|
|
1129
|
+
for (const [t, o] of Object.entries(Pe))
|
|
1108
1130
|
n.getAttribute(o) && (e[t] = n.getAttribute(o));
|
|
1109
1131
|
return n.getAttribute("data-node-type") === "blockContainer" ? e : !1;
|
|
1110
1132
|
}
|
|
@@ -1157,27 +1179,35 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1157
1179
|
const { startPos: i, endPos: s, node: l, contentNode: a } = r;
|
|
1158
1180
|
if (o) {
|
|
1159
1181
|
if (e.children !== void 0) {
|
|
1160
|
-
const
|
|
1161
|
-
for (const
|
|
1162
|
-
|
|
1182
|
+
const f = [];
|
|
1183
|
+
for (const m of e.children)
|
|
1184
|
+
f.push(D(m, t.schema));
|
|
1163
1185
|
l.childCount === 2 ? t.tr.replace(
|
|
1164
1186
|
i + a.nodeSize + 1,
|
|
1165
1187
|
s - 1,
|
|
1166
|
-
new x(
|
|
1188
|
+
new x(_.from(f), 0, 0)
|
|
1167
1189
|
) : t.tr.insert(
|
|
1168
1190
|
i + a.nodeSize,
|
|
1169
|
-
t.schema.nodes.blockGroup.create({},
|
|
1191
|
+
t.schema.nodes.blockGroup.create({}, f)
|
|
1170
1192
|
);
|
|
1171
1193
|
}
|
|
1172
1194
|
if (e.content !== void 0) {
|
|
1173
|
-
let
|
|
1174
|
-
typeof e.content == "string" ?
|
|
1195
|
+
let f = [];
|
|
1196
|
+
typeof e.content == "string" ? f.push(t.schema.text(e.content)) : f = Tt(e.content, t.schema), t.tr.replace(
|
|
1175
1197
|
i + 1,
|
|
1176
1198
|
i + a.nodeSize - 1,
|
|
1177
|
-
new x(
|
|
1199
|
+
new x(_.from(f), 0, 0)
|
|
1178
1200
|
);
|
|
1179
1201
|
}
|
|
1180
|
-
t.
|
|
1202
|
+
const d = a.type.name, c = e.type || d, h = t.schema.nodes[d].spec.content, u = t.schema.nodes[c].spec.content;
|
|
1203
|
+
h === "inline*" && u === "" ? t.tr.replaceWith(
|
|
1204
|
+
i,
|
|
1205
|
+
s,
|
|
1206
|
+
t.schema.nodes[c].create({
|
|
1207
|
+
...a.attrs,
|
|
1208
|
+
...e.props
|
|
1209
|
+
})
|
|
1210
|
+
) : t.tr.setNodeMarkup(
|
|
1181
1211
|
i,
|
|
1182
1212
|
e.type === void 0 ? void 0 : t.schema.nodes[e.type],
|
|
1183
1213
|
{
|
|
@@ -1222,9 +1252,9 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1222
1252
|
), m = e.doc.resolve(d - 1), g = f.blockRange(m);
|
|
1223
1253
|
t && e.tr.lift(g, c - 1);
|
|
1224
1254
|
}
|
|
1225
|
-
let h = n - 1,
|
|
1226
|
-
for (;
|
|
1227
|
-
if (h--,
|
|
1255
|
+
let h = n - 1, u = k(e.doc, h);
|
|
1256
|
+
for (; u.numChildBlocks > 0; )
|
|
1257
|
+
if (h--, u = k(e.doc, h), u === void 0)
|
|
1228
1258
|
return !1;
|
|
1229
1259
|
return t && (t(
|
|
1230
1260
|
e.tr.deleteRange(a, a + l.nodeSize).replace(
|
|
@@ -1242,12 +1272,12 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1242
1272
|
const r = k(t.doc, n);
|
|
1243
1273
|
if (r === void 0)
|
|
1244
1274
|
return !1;
|
|
1245
|
-
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), h = t.doc.cut(n, a - 1),
|
|
1246
|
-
return o && (t.tr.insert(f,
|
|
1275
|
+
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), h = t.doc.cut(n, a - 1), u = t.schema.nodes.blockContainer.createAndFill(), f = a + 1, m = f + 2;
|
|
1276
|
+
return o && (t.tr.insert(f, u), t.tr.replace(
|
|
1247
1277
|
m,
|
|
1248
1278
|
m + 1,
|
|
1249
1279
|
h.content.size > 0 ? new x(
|
|
1250
|
-
|
|
1280
|
+
_.from(h),
|
|
1251
1281
|
d + 2,
|
|
1252
1282
|
d + 2
|
|
1253
1283
|
) : void 0
|
|
@@ -1262,7 +1292,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1262
1292
|
l + 1,
|
|
1263
1293
|
a - 1,
|
|
1264
1294
|
c.content.size > 0 ? new x(
|
|
1265
|
-
|
|
1295
|
+
_.from(c),
|
|
1266
1296
|
d + 2,
|
|
1267
1297
|
d + 2
|
|
1268
1298
|
) : void 0
|
|
@@ -1271,7 +1301,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1271
1301
|
};
|
|
1272
1302
|
},
|
|
1273
1303
|
addProseMirrorPlugins() {
|
|
1274
|
-
return [
|
|
1304
|
+
return [Le()];
|
|
1275
1305
|
},
|
|
1276
1306
|
addKeyboardShortcuts() {
|
|
1277
1307
|
return {
|
|
@@ -1371,7 +1401,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1371
1401
|
})
|
|
1372
1402
|
};
|
|
1373
1403
|
}
|
|
1374
|
-
}),
|
|
1404
|
+
}), De = U.create({
|
|
1375
1405
|
name: "blockGroup",
|
|
1376
1406
|
group: "blockGroup",
|
|
1377
1407
|
content: "blockContainer+",
|
|
@@ -1402,11 +1432,11 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1402
1432
|
0
|
|
1403
1433
|
];
|
|
1404
1434
|
}
|
|
1405
|
-
}),
|
|
1435
|
+
}), Re = U.create({
|
|
1406
1436
|
name: "doc",
|
|
1407
1437
|
topNode: !0,
|
|
1408
1438
|
content: "blockGroup"
|
|
1409
|
-
}),
|
|
1439
|
+
}), Ve = (n) => {
|
|
1410
1440
|
const e = W.fromSchema(n);
|
|
1411
1441
|
return new W(
|
|
1412
1442
|
{
|
|
@@ -1418,12 +1448,12 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1418
1448
|
},
|
|
1419
1449
|
e.marks
|
|
1420
1450
|
);
|
|
1421
|
-
},
|
|
1451
|
+
}, ze = T.create({
|
|
1422
1452
|
addProseMirrorPlugins() {
|
|
1423
1453
|
return [
|
|
1424
|
-
new
|
|
1454
|
+
new w({
|
|
1425
1455
|
props: {
|
|
1426
|
-
clipboardSerializer:
|
|
1456
|
+
clipboardSerializer: Ve(this.editor.schema)
|
|
1427
1457
|
}
|
|
1428
1458
|
})
|
|
1429
1459
|
];
|
|
@@ -1431,7 +1461,8 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1431
1461
|
});
|
|
1432
1462
|
class G {
|
|
1433
1463
|
constructor() {
|
|
1434
|
-
|
|
1464
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1465
|
+
p(this, "callbacks", {});
|
|
1435
1466
|
}
|
|
1436
1467
|
on(e, t) {
|
|
1437
1468
|
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
@@ -1448,16 +1479,16 @@ class G {
|
|
|
1448
1479
|
this.callbacks = {};
|
|
1449
1480
|
}
|
|
1450
1481
|
}
|
|
1451
|
-
const
|
|
1482
|
+
const Ue = zt(
|
|
1452
1483
|
(n) => n.type.name === "blockContainer"
|
|
1453
1484
|
);
|
|
1454
|
-
class
|
|
1485
|
+
class Fe {
|
|
1455
1486
|
constructor(e, t, o = () => {
|
|
1456
1487
|
}) {
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1488
|
+
p(this, "suggestionsMenuState");
|
|
1489
|
+
p(this, "updateSuggestionsMenu");
|
|
1490
|
+
p(this, "pluginState");
|
|
1491
|
+
p(this, "handleScroll", () => {
|
|
1461
1492
|
var e;
|
|
1462
1493
|
if ((e = this.suggestionsMenuState) != null && e.show) {
|
|
1463
1494
|
const t = document.querySelector(
|
|
@@ -1505,7 +1536,7 @@ function Y() {
|
|
|
1505
1536
|
decorationId: void 0
|
|
1506
1537
|
};
|
|
1507
1538
|
}
|
|
1508
|
-
const
|
|
1539
|
+
const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
1509
1540
|
}) => {
|
|
1510
1541
|
if (o.length !== 1)
|
|
1511
1542
|
throw new Error("'char' should be a single character");
|
|
@@ -1514,9 +1545,9 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1514
1545
|
a.dispatch(a.state.tr.setMeta(t, { deactivate: !0 }));
|
|
1515
1546
|
};
|
|
1516
1547
|
return {
|
|
1517
|
-
plugin: new
|
|
1548
|
+
plugin: new w({
|
|
1518
1549
|
key: t,
|
|
1519
|
-
view: () => (s = new
|
|
1550
|
+
view: () => (s = new Fe(
|
|
1520
1551
|
n,
|
|
1521
1552
|
t,
|
|
1522
1553
|
e
|
|
@@ -1545,13 +1576,13 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1545
1576
|
};
|
|
1546
1577
|
if (!d.active)
|
|
1547
1578
|
return d;
|
|
1548
|
-
const
|
|
1549
|
-
if (
|
|
1579
|
+
const u = { ...d };
|
|
1580
|
+
if (u.items = r(
|
|
1550
1581
|
h.doc.textBetween(
|
|
1551
1582
|
d.queryStartPos,
|
|
1552
1583
|
h.selection.from
|
|
1553
1584
|
)
|
|
1554
|
-
),
|
|
1585
|
+
), u.notFoundCount = 0, u.items.length === 0 && (u.notFoundCount = Math.max(
|
|
1555
1586
|
0,
|
|
1556
1587
|
d.notFoundCount + (h.selection.from - c.selection.from)
|
|
1557
1588
|
)), // Highlighting text should hide the menu.
|
|
@@ -1561,14 +1592,14 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1561
1592
|
a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1562
1593
|
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
|
|
1563
1594
|
// the menu.
|
|
1564
|
-
|
|
1595
|
+
u.notFoundCount > 3)
|
|
1565
1596
|
return Y();
|
|
1566
1597
|
if (((b = a.getMeta(t)) == null ? void 0 : b.selectedItemIndexChanged) !== void 0) {
|
|
1567
1598
|
let C = a.getMeta(t).selectedItemIndexChanged;
|
|
1568
|
-
C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0),
|
|
1599
|
+
C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0), u.keyboardHoveredItemIndex = C;
|
|
1569
1600
|
} else
|
|
1570
|
-
c.selection.from !== h.selection.from && (
|
|
1571
|
-
return
|
|
1601
|
+
c.selection.from !== h.selection.from && (u.keyboardHoveredItemIndex = 0);
|
|
1602
|
+
return u;
|
|
1572
1603
|
}
|
|
1573
1604
|
},
|
|
1574
1605
|
props: {
|
|
@@ -1585,7 +1616,7 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1585
1616
|
return !1;
|
|
1586
1617
|
const {
|
|
1587
1618
|
triggerCharacter: h,
|
|
1588
|
-
queryStartPos:
|
|
1619
|
+
queryStartPos: u,
|
|
1589
1620
|
items: f,
|
|
1590
1621
|
keyboardHoveredItemIndex: m
|
|
1591
1622
|
} = t.getState(a.state);
|
|
@@ -1598,7 +1629,7 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1598
1629
|
selectedItemIndexChanged: m + 1
|
|
1599
1630
|
})
|
|
1600
1631
|
), !0) : d.key === "Enter" ? (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1601
|
-
from:
|
|
1632
|
+
from: u - h.length,
|
|
1602
1633
|
to: n._tiptapEditor.state.selection.from
|
|
1603
1634
|
}).run(), i({
|
|
1604
1635
|
item: f[m],
|
|
@@ -1607,11 +1638,11 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1607
1638
|
},
|
|
1608
1639
|
// Setup decorator on the currently active suggestion.
|
|
1609
1640
|
decorations(a) {
|
|
1610
|
-
const { active: d, decorationId: c, queryStartPos: h, triggerCharacter:
|
|
1641
|
+
const { active: d, decorationId: c, queryStartPos: h, triggerCharacter: u } = this.getState(a);
|
|
1611
1642
|
if (!d)
|
|
1612
1643
|
return null;
|
|
1613
|
-
if (
|
|
1614
|
-
const f =
|
|
1644
|
+
if (u === "") {
|
|
1645
|
+
const f = Ue(a.selection);
|
|
1615
1646
|
if (f)
|
|
1616
1647
|
return z.create(a.doc, [
|
|
1617
1648
|
V.node(
|
|
@@ -1627,7 +1658,7 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1627
1658
|
}
|
|
1628
1659
|
return z.create(a.doc, [
|
|
1629
1660
|
V.inline(
|
|
1630
|
-
h -
|
|
1661
|
+
h - u.length,
|
|
1631
1662
|
h,
|
|
1632
1663
|
{
|
|
1633
1664
|
nodeName: "span",
|
|
@@ -1649,13 +1680,13 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1649
1680
|
});
|
|
1650
1681
|
}
|
|
1651
1682
|
};
|
|
1652
|
-
}, X = new
|
|
1653
|
-
class
|
|
1683
|
+
}, X = new S("SlashMenuPlugin");
|
|
1684
|
+
class $e extends G {
|
|
1654
1685
|
constructor(t, o) {
|
|
1655
1686
|
super();
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
const r =
|
|
1687
|
+
p(this, "plugin");
|
|
1688
|
+
p(this, "itemCallback");
|
|
1689
|
+
const r = Ge(
|
|
1659
1690
|
t,
|
|
1660
1691
|
(i) => {
|
|
1661
1692
|
this.emit("update", i);
|
|
@@ -1675,7 +1706,7 @@ class Fe extends G {
|
|
|
1675
1706
|
return this.on("update", t);
|
|
1676
1707
|
}
|
|
1677
1708
|
}
|
|
1678
|
-
const
|
|
1709
|
+
const je = new S("blocknote-placeholder"), qe = T.create({
|
|
1679
1710
|
name: "placeholder",
|
|
1680
1711
|
addOptions() {
|
|
1681
1712
|
return {
|
|
@@ -1691,8 +1722,8 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1691
1722
|
},
|
|
1692
1723
|
addProseMirrorPlugins() {
|
|
1693
1724
|
return [
|
|
1694
|
-
new
|
|
1695
|
-
key:
|
|
1725
|
+
new w({
|
|
1726
|
+
key: je,
|
|
1696
1727
|
props: {
|
|
1697
1728
|
decorations: (n) => {
|
|
1698
1729
|
const { doc: e, selection: t } = n, o = X.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
|
|
@@ -1702,10 +1733,10 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1702
1733
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
1703
1734
|
const h = [this.options.emptyNodeClass];
|
|
1704
1735
|
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);
|
|
1705
|
-
const
|
|
1736
|
+
const u = V.node(a, a + l.nodeSize, {
|
|
1706
1737
|
class: h.join(" ")
|
|
1707
1738
|
});
|
|
1708
|
-
s.push(
|
|
1739
|
+
s.push(u);
|
|
1709
1740
|
}
|
|
1710
1741
|
return this.options.includeChildren;
|
|
1711
1742
|
}), z.create(e, s);
|
|
@@ -1714,7 +1745,7 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1714
1745
|
})
|
|
1715
1746
|
];
|
|
1716
1747
|
}
|
|
1717
|
-
}),
|
|
1748
|
+
}), We = T.create({
|
|
1718
1749
|
name: "textAlignment",
|
|
1719
1750
|
addGlobalAttributes() {
|
|
1720
1751
|
return [
|
|
@@ -1752,7 +1783,7 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1752
1783
|
}
|
|
1753
1784
|
};
|
|
1754
1785
|
}
|
|
1755
|
-
}),
|
|
1786
|
+
}), Ye = T.create({
|
|
1756
1787
|
name: "blockTextColor",
|
|
1757
1788
|
addGlobalAttributes() {
|
|
1758
1789
|
return [
|
|
@@ -1778,7 +1809,7 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1778
1809
|
}
|
|
1779
1810
|
};
|
|
1780
1811
|
}
|
|
1781
|
-
}),
|
|
1812
|
+
}), Ke = lt.create({
|
|
1782
1813
|
name: "textColor",
|
|
1783
1814
|
addAttributes() {
|
|
1784
1815
|
return {
|
|
@@ -1807,12 +1838,12 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1807
1838
|
setTextColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
1808
1839
|
};
|
|
1809
1840
|
}
|
|
1810
|
-
}),
|
|
1841
|
+
}), Je = T.create({
|
|
1811
1842
|
name: "trailingNode",
|
|
1812
1843
|
addProseMirrorPlugins() {
|
|
1813
|
-
const n = new
|
|
1844
|
+
const n = new S(this.name);
|
|
1814
1845
|
return [
|
|
1815
|
-
new
|
|
1846
|
+
new w({
|
|
1816
1847
|
key: n,
|
|
1817
1848
|
appendTransaction: (e, t, o) => {
|
|
1818
1849
|
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;
|
|
@@ -1833,13 +1864,17 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1833
1864
|
throw new Error("Expected blockGroup");
|
|
1834
1865
|
if (o = o.lastChild, !o || o.type.name !== "blockContainer")
|
|
1835
1866
|
throw new Error("Expected blockContainer");
|
|
1836
|
-
|
|
1867
|
+
const r = o.firstChild;
|
|
1868
|
+
if (!r)
|
|
1869
|
+
throw new Error("Expected blockContent");
|
|
1870
|
+
return o.nodeSize > 4 || r.type.spec.content !== "inline*";
|
|
1837
1871
|
}
|
|
1838
1872
|
}
|
|
1839
1873
|
})
|
|
1840
1874
|
];
|
|
1841
1875
|
}
|
|
1842
|
-
}),
|
|
1876
|
+
}), Xe = (n) => {
|
|
1877
|
+
var t;
|
|
1843
1878
|
const e = [
|
|
1844
1879
|
L.ClipboardTextSerializer,
|
|
1845
1880
|
L.Commands,
|
|
@@ -1847,9 +1882,9 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1847
1882
|
L.FocusEvents,
|
|
1848
1883
|
L.Tabindex,
|
|
1849
1884
|
// DevTools,
|
|
1850
|
-
|
|
1885
|
+
Kt,
|
|
1851
1886
|
// DropCursor,
|
|
1852
|
-
|
|
1887
|
+
qe.configure({
|
|
1853
1888
|
emptyNodeClass: y.isEmpty,
|
|
1854
1889
|
hasAnchorClass: y.hasAnchor,
|
|
1855
1890
|
isFilterClass: y.isFilter,
|
|
@@ -1859,65 +1894,66 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1859
1894
|
F.configure({
|
|
1860
1895
|
types: ["blockContainer"]
|
|
1861
1896
|
}),
|
|
1862
|
-
|
|
1897
|
+
Jt,
|
|
1863
1898
|
// Comments,
|
|
1864
1899
|
// basics:
|
|
1865
|
-
|
|
1900
|
+
ee,
|
|
1866
1901
|
// marks:
|
|
1867
|
-
Gt,
|
|
1868
1902
|
$t,
|
|
1869
|
-
|
|
1870
|
-
Qt,
|
|
1871
|
-
ee,
|
|
1903
|
+
jt,
|
|
1872
1904
|
Zt,
|
|
1905
|
+
te,
|
|
1906
|
+
oe,
|
|
1907
|
+
Qt,
|
|
1908
|
+
Ke,
|
|
1909
|
+
Ye,
|
|
1910
|
+
ge,
|
|
1911
|
+
ke,
|
|
1873
1912
|
We,
|
|
1874
|
-
qe,
|
|
1875
|
-
me,
|
|
1876
|
-
fe,
|
|
1877
|
-
je,
|
|
1878
1913
|
// nodes
|
|
1879
|
-
|
|
1880
|
-
|
|
1914
|
+
Re,
|
|
1915
|
+
Oe.configure({
|
|
1881
1916
|
domAttributes: n.domAttributes
|
|
1882
1917
|
}),
|
|
1883
|
-
|
|
1918
|
+
De.configure({
|
|
1884
1919
|
domAttributes: n.domAttributes
|
|
1885
1920
|
}),
|
|
1886
1921
|
...Object.values(n.blockSchema).map(
|
|
1887
|
-
(
|
|
1922
|
+
(o) => o.node.configure({
|
|
1888
1923
|
editor: n.editor,
|
|
1889
1924
|
domAttributes: n.domAttributes
|
|
1890
1925
|
})
|
|
1891
1926
|
),
|
|
1892
|
-
|
|
1893
|
-
|
|
1927
|
+
ze,
|
|
1928
|
+
Yt.configure({ width: 5, color: "#ddeeff" }),
|
|
1894
1929
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
1895
1930
|
// should be handled before Enter handlers in other components like splitListItem
|
|
1896
|
-
|
|
1931
|
+
Je
|
|
1897
1932
|
];
|
|
1898
1933
|
if (n.collaboration) {
|
|
1899
|
-
e.push(
|
|
1900
|
-
jt.configure({
|
|
1901
|
-
fragment: n.collaboration.fragment
|
|
1902
|
-
})
|
|
1903
|
-
);
|
|
1904
|
-
const t = (o) => {
|
|
1905
|
-
const r = document.createElement("span");
|
|
1906
|
-
r.classList.add(H["collaboration-cursor__caret"]), r.setAttribute("style", `border-color: ${o.color}`);
|
|
1907
|
-
const i = document.createElement("span");
|
|
1908
|
-
i.classList.add(H["collaboration-cursor__label"]), i.setAttribute("style", `background-color: ${o.color}`), i.insertBefore(document.createTextNode(o.name), null);
|
|
1909
|
-
const s = document.createTextNode(""), l = document.createTextNode("");
|
|
1910
|
-
return r.insertBefore(s, null), r.insertBefore(i, null), r.insertBefore(l, null), r;
|
|
1911
|
-
};
|
|
1912
|
-
e.push(
|
|
1934
|
+
if (e.push(
|
|
1913
1935
|
qt.configure({
|
|
1914
|
-
|
|
1915
|
-
render: n.collaboration.renderCursor || t,
|
|
1916
|
-
provider: n.collaboration.provider
|
|
1936
|
+
fragment: n.collaboration.fragment
|
|
1917
1937
|
})
|
|
1918
|
-
)
|
|
1938
|
+
), (t = n.collaboration.provider) != null && t.awareness) {
|
|
1939
|
+
const o = (r) => {
|
|
1940
|
+
const i = document.createElement("span");
|
|
1941
|
+
i.classList.add(H["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
|
|
1942
|
+
const s = document.createElement("span");
|
|
1943
|
+
s.classList.add(H["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
|
|
1944
|
+
const l = document.createTextNode(""), a = document.createTextNode("");
|
|
1945
|
+
return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
|
|
1946
|
+
};
|
|
1947
|
+
e.push(
|
|
1948
|
+
Wt.configure({
|
|
1949
|
+
user: n.collaboration.user,
|
|
1950
|
+
render: n.collaboration.renderCursor || o,
|
|
1951
|
+
provider: n.collaboration.provider
|
|
1952
|
+
})
|
|
1953
|
+
);
|
|
1954
|
+
}
|
|
1919
1955
|
} else
|
|
1920
|
-
e.push(
|
|
1956
|
+
e.push(Xt);
|
|
1921
1957
|
return e;
|
|
1922
1958
|
};
|
|
1923
1959
|
function Z(n, e) {
|
|
@@ -1929,7 +1965,7 @@ function Z(n, e) {
|
|
|
1929
1965
|
posBeforeNode: o
|
|
1930
1966
|
};
|
|
1931
1967
|
}
|
|
1932
|
-
function
|
|
1968
|
+
function xt(n, e, t = "before", o) {
|
|
1933
1969
|
const r = typeof e == "string" ? e : e.id, i = [];
|
|
1934
1970
|
for (const d of n)
|
|
1935
1971
|
i.push(D(d, o.schema));
|
|
@@ -1951,11 +1987,11 @@ function Tt(n, e, t = "before", o) {
|
|
|
1951
1987
|
}
|
|
1952
1988
|
o.view.dispatch(o.state.tr.insert(s, i));
|
|
1953
1989
|
}
|
|
1954
|
-
function
|
|
1990
|
+
function Ze(n, e, t) {
|
|
1955
1991
|
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = Z(o, t.state.doc);
|
|
1956
1992
|
t.commands.BNUpdateBlock(r + 1, e);
|
|
1957
1993
|
}
|
|
1958
|
-
function
|
|
1994
|
+
function At(n, e) {
|
|
1959
1995
|
const t = new Set(
|
|
1960
1996
|
n.map(
|
|
1961
1997
|
(r) => typeof r == "string" ? r : r.id
|
|
@@ -1973,17 +2009,17 @@ function xt(n, e) {
|
|
|
1973
2009
|
const l = e.state.doc.nodeSize;
|
|
1974
2010
|
return o += s - l, !1;
|
|
1975
2011
|
}), t.size > 0) {
|
|
1976
|
-
|
|
2012
|
+
const r = [...t].join(`
|
|
1977
2013
|
`);
|
|
1978
2014
|
throw Error(
|
|
1979
2015
|
"Blocks with the following IDs could not be found in the editor: " + r
|
|
1980
2016
|
);
|
|
1981
2017
|
}
|
|
1982
2018
|
}
|
|
1983
|
-
function
|
|
1984
|
-
|
|
2019
|
+
function Qe(n, e, t) {
|
|
2020
|
+
xt(e, n[0], "before", t), At(n, t);
|
|
1985
2021
|
}
|
|
1986
|
-
function
|
|
2022
|
+
function to() {
|
|
1987
2023
|
const n = (e) => {
|
|
1988
2024
|
let t = e.children.length;
|
|
1989
2025
|
for (let o = 0; o < t; o++) {
|
|
@@ -1999,7 +2035,7 @@ function Ze() {
|
|
|
1999
2035
|
};
|
|
2000
2036
|
return n;
|
|
2001
2037
|
}
|
|
2002
|
-
function
|
|
2038
|
+
function eo(n) {
|
|
2003
2039
|
const e = /* @__PURE__ */ new Set([
|
|
2004
2040
|
...n.orderedListItemBlockTypes,
|
|
2005
2041
|
...n.unorderedListItemBlockTypes
|
|
@@ -2008,10 +2044,10 @@ function Qe(n) {
|
|
|
2008
2044
|
for (let s = 0; s < r; s++) {
|
|
2009
2045
|
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, h = e.has(
|
|
2010
2046
|
d.properties.dataContentType
|
|
2011
|
-
),
|
|
2047
|
+
), u = h ? n.orderedListItemBlockTypes.has(
|
|
2012
2048
|
d.properties.dataContentType
|
|
2013
2049
|
) ? "ol" : "ul" : null;
|
|
2014
|
-
if (c !== null && t(c), i && i.tagName !==
|
|
2050
|
+
if (c !== null && t(c), i && i.tagName !== u) {
|
|
2015
2051
|
o.children.splice(
|
|
2016
2052
|
s - i.children.length,
|
|
2017
2053
|
i.children.length,
|
|
@@ -2022,7 +2058,7 @@ function Qe(n) {
|
|
|
2022
2058
|
}
|
|
2023
2059
|
if (h) {
|
|
2024
2060
|
i || (i = nt(
|
|
2025
|
-
document.createElement(
|
|
2061
|
+
document.createElement(u)
|
|
2026
2062
|
));
|
|
2027
2063
|
const f = nt(
|
|
2028
2064
|
document.createElement("li")
|
|
@@ -2043,13 +2079,13 @@ function Qe(n) {
|
|
|
2043
2079
|
};
|
|
2044
2080
|
return t;
|
|
2045
2081
|
}
|
|
2046
|
-
async function
|
|
2082
|
+
async function It(n, e) {
|
|
2047
2083
|
const t = document.createElement("div"), o = W.fromSchema(e);
|
|
2048
2084
|
for (const i of n) {
|
|
2049
2085
|
const s = D(i, e), l = o.serializeNode(s);
|
|
2050
2086
|
t.appendChild(l);
|
|
2051
2087
|
}
|
|
2052
|
-
return (await J().use(dt, { fragment: !0 }).use(
|
|
2088
|
+
return (await J().use(dt, { fragment: !0 }).use(eo, {
|
|
2053
2089
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
2054
2090
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
2055
2091
|
}).use(ct).process(t.innerHTML)).value;
|
|
@@ -2057,44 +2093,66 @@ async function At(n, e) {
|
|
|
2057
2093
|
async function _t(n, e, t) {
|
|
2058
2094
|
const o = document.createElement("div");
|
|
2059
2095
|
o.innerHTML = n.trim();
|
|
2060
|
-
const i =
|
|
2096
|
+
const i = ne.fromSchema(t).parse(o), s = [];
|
|
2061
2097
|
for (let l = 0; l < i.firstChild.childCount; l++)
|
|
2062
2098
|
s.push(E(i.firstChild.child(l), e));
|
|
2063
2099
|
return s;
|
|
2064
2100
|
}
|
|
2065
|
-
async function
|
|
2066
|
-
return (await J().use(dt, { fragment: !0 }).use(
|
|
2101
|
+
async function oo(n, e) {
|
|
2102
|
+
return (await J().use(dt, { fragment: !0 }).use(to).use(ae).use(ut).use(ue).process(await It(n, e))).value;
|
|
2103
|
+
}
|
|
2104
|
+
function no(n, e) {
|
|
2105
|
+
const t = e.value ? e.value + `
|
|
2106
|
+
` : "", o = {};
|
|
2107
|
+
e.lang && (o["data-language"] = e.lang);
|
|
2108
|
+
let r = {
|
|
2109
|
+
type: "element",
|
|
2110
|
+
tagName: "code",
|
|
2111
|
+
properties: o,
|
|
2112
|
+
children: [{ type: "text", value: t }]
|
|
2113
|
+
};
|
|
2114
|
+
return e.meta && (r.data = { meta: e.meta }), n.patch(e, r), r = n.applyData(e, r), r = {
|
|
2115
|
+
type: "element",
|
|
2116
|
+
tagName: "pre",
|
|
2117
|
+
properties: {},
|
|
2118
|
+
children: [r]
|
|
2119
|
+
}, n.patch(e, r), r;
|
|
2067
2120
|
}
|
|
2068
|
-
async function
|
|
2069
|
-
const o = await J().use(
|
|
2121
|
+
async function ro(n, e, t) {
|
|
2122
|
+
const o = await J().use(le).use(ut).use(de, {
|
|
2123
|
+
handlers: {
|
|
2124
|
+
...ce,
|
|
2125
|
+
code: no
|
|
2126
|
+
}
|
|
2127
|
+
}).use(ct).process(n);
|
|
2070
2128
|
return _t(o.value, e, t);
|
|
2071
2129
|
}
|
|
2072
|
-
class
|
|
2130
|
+
class io {
|
|
2073
2131
|
constructor(e, t, o) {
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length &&
|
|
2132
|
+
p(this, "formattingToolbarState");
|
|
2133
|
+
p(this, "updateFormattingToolbar");
|
|
2134
|
+
p(this, "preventHide", !1);
|
|
2135
|
+
p(this, "preventShow", !1);
|
|
2136
|
+
p(this, "prevWasEditable", null);
|
|
2137
|
+
p(this, "shouldShow", ({ view: e, state: t, from: o, to: r }) => {
|
|
2138
|
+
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length && Ut(t.selection);
|
|
2081
2139
|
return !(!e.hasFocus() || l || a);
|
|
2082
2140
|
});
|
|
2083
|
-
|
|
2141
|
+
p(this, "viewMousedownHandler", () => {
|
|
2084
2142
|
this.preventShow = !0;
|
|
2085
2143
|
});
|
|
2086
|
-
|
|
2144
|
+
p(this, "viewMouseupHandler", () => {
|
|
2087
2145
|
this.preventShow = !1, setTimeout(() => this.update(this.pmView));
|
|
2088
2146
|
});
|
|
2089
2147
|
// For dragging the whole editor.
|
|
2090
|
-
|
|
2148
|
+
p(this, "dragstartHandler", () => {
|
|
2091
2149
|
var e;
|
|
2092
2150
|
(e = this.formattingToolbarState) != null && e.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2093
2151
|
});
|
|
2094
|
-
|
|
2152
|
+
p(this, "focusHandler", () => {
|
|
2095
2153
|
setTimeout(() => this.update(this.pmView));
|
|
2096
2154
|
});
|
|
2097
|
-
|
|
2155
|
+
p(this, "blurHandler", (e) => {
|
|
2098
2156
|
var o;
|
|
2099
2157
|
if (this.preventHide) {
|
|
2100
2158
|
this.preventHide = !1;
|
|
@@ -2105,7 +2163,7 @@ class oo {
|
|
|
2105
2163
|
e && e.relatedTarget && // Element is inside the editor.
|
|
2106
2164
|
(t === e.relatedTarget || t.contains(e.relatedTarget)) || (o = this.formattingToolbarState) != null && o.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2107
2165
|
});
|
|
2108
|
-
|
|
2166
|
+
p(this, "scrollHandler", () => {
|
|
2109
2167
|
var e;
|
|
2110
2168
|
(e = this.formattingToolbarState) != null && e.show && (this.formattingToolbarState.referencePos = this.getSelectionBoundingBox(), this.updateFormattingToolbar());
|
|
2111
2169
|
});
|
|
@@ -2118,12 +2176,12 @@ class oo {
|
|
|
2118
2176
|
}, t.dom.addEventListener("mousedown", this.viewMousedownHandler), t.dom.addEventListener("mouseup", this.viewMouseupHandler), t.dom.addEventListener("dragstart", this.dragstartHandler), t.dom.addEventListener("focus", this.focusHandler), t.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2119
2177
|
}
|
|
2120
2178
|
update(e, t) {
|
|
2121
|
-
var
|
|
2179
|
+
var u, f;
|
|
2122
2180
|
const { state: o, composing: r } = e, { doc: i, selection: s } = o, l = t && t.doc.eq(i) && t.selection.eq(s);
|
|
2123
2181
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
|
|
2124
2182
|
return;
|
|
2125
2183
|
this.prevWasEditable = this.editor.isEditable;
|
|
2126
|
-
const { ranges: a } = s, d = Math.min(...a.map((m) => m.$from.pos)), c = Math.max(...a.map((m) => m.$to.pos)), h = (
|
|
2184
|
+
const { ranges: a } = s, d = Math.min(...a.map((m) => m.$from.pos)), c = Math.max(...a.map((m) => m.$to.pos)), h = (u = this.shouldShow) == null ? void 0 : u.call(this, {
|
|
2127
2185
|
view: e,
|
|
2128
2186
|
state: o,
|
|
2129
2187
|
from: d,
|
|
@@ -2146,7 +2204,7 @@ class oo {
|
|
|
2146
2204
|
}
|
|
2147
2205
|
getSelectionBoundingBox() {
|
|
2148
2206
|
const { state: e } = this.pmView, { selection: t } = e, { ranges: o } = t, r = Math.min(...o.map((s) => s.$from.pos)), i = Math.max(...o.map((s) => s.$to.pos));
|
|
2149
|
-
if (
|
|
2207
|
+
if (Ft(t)) {
|
|
2150
2208
|
const s = this.pmView.nodeDOM(r);
|
|
2151
2209
|
if (s)
|
|
2152
2210
|
return s.getBoundingClientRect();
|
|
@@ -2154,17 +2212,17 @@ class oo {
|
|
|
2154
2212
|
return q(this.pmView, r, i);
|
|
2155
2213
|
}
|
|
2156
2214
|
}
|
|
2157
|
-
const
|
|
2215
|
+
const so = new S(
|
|
2158
2216
|
"FormattingToolbarPlugin"
|
|
2159
2217
|
);
|
|
2160
|
-
class
|
|
2218
|
+
class ao extends G {
|
|
2161
2219
|
constructor(t) {
|
|
2162
2220
|
super();
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
this.plugin = new
|
|
2166
|
-
key:
|
|
2167
|
-
view: (o) => (this.view = new
|
|
2221
|
+
p(this, "view");
|
|
2222
|
+
p(this, "plugin");
|
|
2223
|
+
this.plugin = new w({
|
|
2224
|
+
key: so,
|
|
2225
|
+
view: (o) => (this.view = new io(t, o, (r) => {
|
|
2168
2226
|
this.emit("update", r);
|
|
2169
2227
|
}), this.view)
|
|
2170
2228
|
});
|
|
@@ -2173,20 +2231,20 @@ class ro extends G {
|
|
|
2173
2231
|
return this.on("update", t);
|
|
2174
2232
|
}
|
|
2175
2233
|
}
|
|
2176
|
-
class
|
|
2234
|
+
class lo {
|
|
2177
2235
|
constructor(e, t, o) {
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2236
|
+
p(this, "hyperlinkToolbarState");
|
|
2237
|
+
p(this, "updateHyperlinkToolbar");
|
|
2238
|
+
p(this, "menuUpdateTimer");
|
|
2239
|
+
p(this, "startMenuUpdateTimer");
|
|
2240
|
+
p(this, "stopMenuUpdateTimer");
|
|
2241
|
+
p(this, "mouseHoveredHyperlinkMark");
|
|
2242
|
+
p(this, "mouseHoveredHyperlinkMarkRange");
|
|
2243
|
+
p(this, "keyboardHoveredHyperlinkMark");
|
|
2244
|
+
p(this, "keyboardHoveredHyperlinkMarkRange");
|
|
2245
|
+
p(this, "hyperlinkMark");
|
|
2246
|
+
p(this, "hyperlinkMarkRange");
|
|
2247
|
+
p(this, "mouseOverHandler", (e) => {
|
|
2190
2248
|
if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), e.target instanceof HTMLAnchorElement && e.target.nodeName === "A") {
|
|
2191
2249
|
const t = e.target, o = this.pmView.posAtDOM(t, 0) + 1, r = this.pmView.state.doc.resolve(
|
|
2192
2250
|
o
|
|
@@ -2203,7 +2261,7 @@ class io {
|
|
|
2203
2261
|
}
|
|
2204
2262
|
return this.startMenuUpdateTimer(), !1;
|
|
2205
2263
|
});
|
|
2206
|
-
|
|
2264
|
+
p(this, "clickHandler", (e) => {
|
|
2207
2265
|
var o;
|
|
2208
2266
|
const t = this.pmView.dom.parentElement;
|
|
2209
2267
|
// Toolbar is open.
|
|
@@ -2211,7 +2269,7 @@ class io {
|
|
|
2211
2269
|
e && e.target && // The clicked element is not the editor.
|
|
2212
2270
|
!(t === e.target || t.contains(e.target)) && (o = this.hyperlinkToolbarState) != null && o.show && (this.hyperlinkToolbarState.show = !1, this.updateHyperlinkToolbar());
|
|
2213
2271
|
});
|
|
2214
|
-
|
|
2272
|
+
p(this, "scrollHandler", () => {
|
|
2215
2273
|
var e;
|
|
2216
2274
|
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos = q(
|
|
2217
2275
|
this.pmView,
|
|
@@ -2294,24 +2352,24 @@ class io {
|
|
|
2294
2352
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2295
2353
|
}
|
|
2296
2354
|
}
|
|
2297
|
-
const
|
|
2355
|
+
const co = new S(
|
|
2298
2356
|
"HyperlinkToolbarPlugin"
|
|
2299
2357
|
);
|
|
2300
|
-
class
|
|
2358
|
+
class uo extends G {
|
|
2301
2359
|
constructor(t) {
|
|
2302
2360
|
super();
|
|
2303
|
-
|
|
2304
|
-
|
|
2361
|
+
p(this, "view");
|
|
2362
|
+
p(this, "plugin");
|
|
2305
2363
|
/**
|
|
2306
2364
|
* Edit the currently hovered hyperlink.
|
|
2307
2365
|
*/
|
|
2308
|
-
|
|
2366
|
+
p(this, "editHyperlink", (t, o) => {
|
|
2309
2367
|
this.view.editHyperlink(t, o);
|
|
2310
2368
|
});
|
|
2311
2369
|
/**
|
|
2312
2370
|
* Delete the currently hovered hyperlink.
|
|
2313
2371
|
*/
|
|
2314
|
-
|
|
2372
|
+
p(this, "deleteHyperlink", () => {
|
|
2315
2373
|
this.view.deleteHyperlink();
|
|
2316
2374
|
});
|
|
2317
2375
|
/**
|
|
@@ -2320,7 +2378,7 @@ class ao extends G {
|
|
|
2320
2378
|
*
|
|
2321
2379
|
* This function starts the delay timer, and should be used for when the mouse cursor enters the hyperlink toolbar.
|
|
2322
2380
|
*/
|
|
2323
|
-
|
|
2381
|
+
p(this, "startHideTimer", () => {
|
|
2324
2382
|
this.view.startMenuUpdateTimer();
|
|
2325
2383
|
});
|
|
2326
2384
|
/**
|
|
@@ -2329,12 +2387,12 @@ class ao extends G {
|
|
|
2329
2387
|
*
|
|
2330
2388
|
* This function stops the delay timer, and should be used for when the mouse cursor exits the hyperlink toolbar.
|
|
2331
2389
|
*/
|
|
2332
|
-
|
|
2390
|
+
p(this, "stopHideTimer", () => {
|
|
2333
2391
|
this.view.stopMenuUpdateTimer();
|
|
2334
2392
|
});
|
|
2335
|
-
this.plugin = new
|
|
2336
|
-
key:
|
|
2337
|
-
view: (o) => (this.view = new
|
|
2393
|
+
this.plugin = new w({
|
|
2394
|
+
key: co,
|
|
2395
|
+
view: (o) => (this.view = new lo(t, o, (r) => {
|
|
2338
2396
|
this.emit("update", r);
|
|
2339
2397
|
}), this.view)
|
|
2340
2398
|
});
|
|
@@ -2346,7 +2404,7 @@ class ao extends G {
|
|
|
2346
2404
|
class N extends j {
|
|
2347
2405
|
constructor(t, o) {
|
|
2348
2406
|
super(t, o);
|
|
2349
|
-
|
|
2407
|
+
p(this, "nodes");
|
|
2350
2408
|
const r = t.node();
|
|
2351
2409
|
this.nodes = [], t.doc.nodesBetween(t.pos, o.pos, (i, s, l) => {
|
|
2352
2410
|
if (l !== null && l.eq(r))
|
|
@@ -2357,7 +2415,7 @@ class N extends j {
|
|
|
2357
2415
|
return new N(t.resolve(o), t.resolve(r));
|
|
2358
2416
|
}
|
|
2359
2417
|
content() {
|
|
2360
|
-
return new x(
|
|
2418
|
+
return new x(_.from(this.nodes), 0, 0);
|
|
2361
2419
|
}
|
|
2362
2420
|
eq(t) {
|
|
2363
2421
|
if (!(t instanceof N) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
|
|
@@ -2368,7 +2426,7 @@ class N extends j {
|
|
|
2368
2426
|
return !0;
|
|
2369
2427
|
}
|
|
2370
2428
|
map(t, o) {
|
|
2371
|
-
|
|
2429
|
+
const r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2372
2430
|
return i.deleted ? j.near(t.resolve(r.pos)) : r.deleted ? j.near(t.resolve(i.pos)) : new N(
|
|
2373
2431
|
t.resolve(r.pos),
|
|
2374
2432
|
t.resolve(i.pos)
|
|
@@ -2378,13 +2436,13 @@ class N extends j {
|
|
|
2378
2436
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
2379
2437
|
}
|
|
2380
2438
|
}
|
|
2381
|
-
const
|
|
2439
|
+
const po = se.__serializeForClipboard;
|
|
2382
2440
|
let B;
|
|
2383
|
-
function
|
|
2441
|
+
function Ht(n, e) {
|
|
2384
2442
|
var r;
|
|
2385
2443
|
if (!e.dom.isConnected)
|
|
2386
2444
|
return;
|
|
2387
|
-
|
|
2445
|
+
const t = e.posAtCoords(n);
|
|
2388
2446
|
if (!t)
|
|
2389
2447
|
return;
|
|
2390
2448
|
let o = e.domAtPos(t.pos).node;
|
|
@@ -2395,16 +2453,15 @@ function It(n, e) {
|
|
|
2395
2453
|
return { node: o, id: o.getAttribute("data-id") };
|
|
2396
2454
|
}
|
|
2397
2455
|
}
|
|
2398
|
-
function
|
|
2399
|
-
|
|
2456
|
+
function ho(n, e) {
|
|
2457
|
+
const t = Ht(n, e);
|
|
2400
2458
|
if (t && t.node.nodeType === 1) {
|
|
2401
|
-
const o = e.docView;
|
|
2402
|
-
let r = o.nearestDesc(t.node, !0);
|
|
2459
|
+
const o = e.docView, r = o.nearestDesc(t.node, !0);
|
|
2403
2460
|
return !r || r === o ? null : r.posBefore;
|
|
2404
2461
|
}
|
|
2405
2462
|
return null;
|
|
2406
2463
|
}
|
|
2407
|
-
function
|
|
2464
|
+
function fo(n, e) {
|
|
2408
2465
|
let t, o;
|
|
2409
2466
|
const r = e.resolve(n.from).node().type.spec.group === "blockContent", i = e.resolve(n.to).node().type.spec.group === "blockContent", s = Math.min(n.$anchor.depth, n.$head.depth);
|
|
2410
2467
|
if (r && i) {
|
|
@@ -2427,51 +2484,50 @@ function at(n, e, t = e) {
|
|
|
2427
2484
|
);
|
|
2428
2485
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
2429
2486
|
(c > l || c < s) && o.removeChild(o.children[c]);
|
|
2430
|
-
|
|
2487
|
+
Nt(), B = o;
|
|
2431
2488
|
const d = n.dom.className.split(" ").filter(
|
|
2432
2489
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
2433
2490
|
).join(" ");
|
|
2434
2491
|
B.className = B.className + " " + H.dragPreview + " " + d, document.body.appendChild(B);
|
|
2435
2492
|
}
|
|
2436
|
-
function
|
|
2493
|
+
function Nt() {
|
|
2437
2494
|
B !== void 0 && (document.body.removeChild(B), B = void 0);
|
|
2438
2495
|
}
|
|
2439
|
-
function
|
|
2496
|
+
function mo(n, e) {
|
|
2440
2497
|
if (!n.dataTransfer)
|
|
2441
2498
|
return;
|
|
2442
|
-
const t = e.dom.getBoundingClientRect()
|
|
2443
|
-
let o = {
|
|
2499
|
+
const t = e.dom.getBoundingClientRect(), o = {
|
|
2444
2500
|
left: t.left + t.width / 2,
|
|
2445
2501
|
// take middle of editor
|
|
2446
2502
|
top: n.clientY
|
|
2447
|
-
}, r =
|
|
2503
|
+
}, r = ho(o, e);
|
|
2448
2504
|
if (r != null) {
|
|
2449
|
-
const i = e.state.selection, s = e.state.doc, { from: l, to: a } =
|
|
2505
|
+
const i = e.state.selection, s = e.state.doc, { from: l, to: a } = fo(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof N;
|
|
2450
2506
|
d && c ? (e.dispatch(
|
|
2451
2507
|
e.state.tr.setSelection(N.create(s, l, a))
|
|
2452
2508
|
), at(e, l, a)) : (e.dispatch(
|
|
2453
|
-
e.state.tr.setSelection(
|
|
2509
|
+
e.state.tr.setSelection(re.create(e.state.doc, r))
|
|
2454
2510
|
), at(e, r));
|
|
2455
|
-
|
|
2456
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html",
|
|
2511
|
+
const h = e.state.selection.content(), { dom: u, text: f } = po(e, h);
|
|
2512
|
+
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", u.innerHTML), n.dataTransfer.setData("text/plain", f), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(B, 0, 0), e.dragging = { slice: h, move: !0 };
|
|
2457
2513
|
}
|
|
2458
2514
|
}
|
|
2459
|
-
class
|
|
2515
|
+
class ko {
|
|
2460
2516
|
constructor(e, t, o) {
|
|
2461
|
-
|
|
2517
|
+
p(this, "sideMenuState");
|
|
2462
2518
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
2463
2519
|
// When false, the drag handle with be just to the left of the element
|
|
2464
2520
|
// TODO: Is there any case where we want this to be false?
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2521
|
+
p(this, "horizontalPosAnchoredAtRoot");
|
|
2522
|
+
p(this, "horizontalPosAnchor");
|
|
2523
|
+
p(this, "hoveredBlock");
|
|
2468
2524
|
// Used to check if currently dragged content comes from this editor instance.
|
|
2469
|
-
|
|
2470
|
-
|
|
2525
|
+
p(this, "isDragging", !1);
|
|
2526
|
+
p(this, "menuFrozen", !1);
|
|
2471
2527
|
/**
|
|
2472
2528
|
* Sets isDragging when dragging text.
|
|
2473
2529
|
*/
|
|
2474
|
-
|
|
2530
|
+
p(this, "onDragStart", () => {
|
|
2475
2531
|
this.isDragging = !0;
|
|
2476
2532
|
});
|
|
2477
2533
|
/**
|
|
@@ -2479,10 +2535,10 @@ class ho {
|
|
|
2479
2535
|
* we dispatch a fake event, so that we can still drop the content
|
|
2480
2536
|
* when dragging / dropping to the side of the editor
|
|
2481
2537
|
*/
|
|
2482
|
-
|
|
2538
|
+
p(this, "onDrop", (e) => {
|
|
2483
2539
|
if (this.editor._tiptapEditor.commands.blur(), e.synthetic || !this.isDragging)
|
|
2484
2540
|
return;
|
|
2485
|
-
|
|
2541
|
+
const t = this.pmView.posAtCoords({
|
|
2486
2542
|
left: e.clientX,
|
|
2487
2543
|
top: e.clientY
|
|
2488
2544
|
});
|
|
@@ -2496,10 +2552,10 @@ class ho {
|
|
|
2496
2552
|
* we dispatch a fake event, so that we can still drop the content
|
|
2497
2553
|
* when dragging / dropping to the side of the editor
|
|
2498
2554
|
*/
|
|
2499
|
-
|
|
2555
|
+
p(this, "onDragOver", (e) => {
|
|
2500
2556
|
if (e.synthetic || !this.isDragging)
|
|
2501
2557
|
return;
|
|
2502
|
-
|
|
2558
|
+
const t = this.pmView.posAtCoords({
|
|
2503
2559
|
left: e.clientX,
|
|
2504
2560
|
top: e.clientY
|
|
2505
2561
|
});
|
|
@@ -2508,12 +2564,12 @@ class ho {
|
|
|
2508
2564
|
o.clientX = r.left + r.width / 2, o.clientY = e.clientY, o.dataTransfer = e.dataTransfer, o.preventDefault = () => e.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
|
|
2509
2565
|
}
|
|
2510
2566
|
});
|
|
2511
|
-
|
|
2567
|
+
p(this, "onKeyDown", (e) => {
|
|
2512
2568
|
var t;
|
|
2513
2569
|
(t = this.sideMenuState) != null && t.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2514
2570
|
});
|
|
2515
|
-
|
|
2516
|
-
var d, c, h,
|
|
2571
|
+
p(this, "onMouseMove", (e) => {
|
|
2572
|
+
var d, c, h, u, f;
|
|
2517
2573
|
if (this.menuFrozen)
|
|
2518
2574
|
return;
|
|
2519
2575
|
const t = this.pmView.dom.firstChild.getBoundingClientRect(), o = this.pmView.dom.getBoundingClientRect(), r = e.clientX >= o.left && e.clientX <= o.right && e.clientY >= o.top && e.clientY <= o.bottom, i = this.pmView.dom.parentElement;
|
|
@@ -2531,12 +2587,12 @@ class ho {
|
|
|
2531
2587
|
left: t.left + t.width / 2,
|
|
2532
2588
|
// take middle of editor
|
|
2533
2589
|
top: e.clientY
|
|
2534
|
-
}, l =
|
|
2590
|
+
}, l = Ht(s, this.pmView);
|
|
2535
2591
|
if (!l || !this.editor.isEditable) {
|
|
2536
2592
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2537
2593
|
return;
|
|
2538
2594
|
}
|
|
2539
|
-
if ((h = this.sideMenuState) != null && h.show && ((
|
|
2595
|
+
if ((h = this.sideMenuState) != null && h.show && ((u = this.hoveredBlock) != null && u.hasAttribute("data-id")) && ((f = this.hoveredBlock) == null ? void 0 : f.getAttribute("data-id")) === l.id)
|
|
2540
2596
|
return;
|
|
2541
2597
|
this.hoveredBlock = l.node;
|
|
2542
2598
|
const a = l.node.firstChild;
|
|
@@ -2556,7 +2612,7 @@ class ho {
|
|
|
2556
2612
|
}, this.updateSideMenu(this.sideMenuState);
|
|
2557
2613
|
}
|
|
2558
2614
|
});
|
|
2559
|
-
|
|
2615
|
+
p(this, "onScroll", () => {
|
|
2560
2616
|
var e;
|
|
2561
2617
|
if ((e = this.sideMenuState) != null && e.show) {
|
|
2562
2618
|
const o = this.hoveredBlock.firstChild.getBoundingClientRect();
|
|
@@ -2604,42 +2660,42 @@ class ho {
|
|
|
2604
2660
|
);
|
|
2605
2661
|
}
|
|
2606
2662
|
}
|
|
2607
|
-
const
|
|
2608
|
-
class
|
|
2663
|
+
const go = new S("SideMenuPlugin");
|
|
2664
|
+
class bo extends G {
|
|
2609
2665
|
constructor(t) {
|
|
2610
2666
|
super();
|
|
2611
|
-
|
|
2612
|
-
|
|
2667
|
+
p(this, "sideMenuView");
|
|
2668
|
+
p(this, "plugin");
|
|
2613
2669
|
/**
|
|
2614
2670
|
* If the block is empty, opens the slash menu. If the block has content,
|
|
2615
2671
|
* creates a new block below and opens the slash menu in it.
|
|
2616
2672
|
*/
|
|
2617
|
-
|
|
2673
|
+
p(this, "addBlock", () => this.sideMenuView.addBlock());
|
|
2618
2674
|
/**
|
|
2619
2675
|
* Handles drag & drop events for blocks.
|
|
2620
2676
|
*/
|
|
2621
|
-
|
|
2622
|
-
this.sideMenuView.isDragging = !0,
|
|
2677
|
+
p(this, "blockDragStart", (t) => {
|
|
2678
|
+
this.sideMenuView.isDragging = !0, mo(t, this.editor.prosemirrorView);
|
|
2623
2679
|
});
|
|
2624
2680
|
/**
|
|
2625
2681
|
* Handles drag & drop events for blocks.
|
|
2626
2682
|
*/
|
|
2627
|
-
|
|
2683
|
+
p(this, "blockDragEnd", () => Nt());
|
|
2628
2684
|
/**
|
|
2629
2685
|
* Freezes the side menu. When frozen, the side menu will stay
|
|
2630
2686
|
* attached to the same block regardless of which block is hovered by the
|
|
2631
2687
|
* mouse cursor.
|
|
2632
2688
|
*/
|
|
2633
|
-
|
|
2689
|
+
p(this, "freezeMenu", () => this.sideMenuView.menuFrozen = !0);
|
|
2634
2690
|
/**
|
|
2635
2691
|
* Unfreezes the side menu. When frozen, the side menu will stay
|
|
2636
2692
|
* attached to the same block regardless of which block is hovered by the
|
|
2637
2693
|
* mouse cursor.
|
|
2638
2694
|
*/
|
|
2639
|
-
|
|
2640
|
-
this.editor = t, this.plugin = new
|
|
2641
|
-
key:
|
|
2642
|
-
view: (o) => (this.sideMenuView = new
|
|
2695
|
+
p(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2696
|
+
this.editor = t, this.plugin = new w({
|
|
2697
|
+
key: go,
|
|
2698
|
+
view: (o) => (this.sideMenuView = new ko(
|
|
2643
2699
|
t,
|
|
2644
2700
|
o,
|
|
2645
2701
|
(r) => {
|
|
@@ -2652,68 +2708,68 @@ class mo extends G {
|
|
|
2652
2708
|
return this.on("update", t);
|
|
2653
2709
|
}
|
|
2654
2710
|
}
|
|
2655
|
-
function
|
|
2711
|
+
function I(n, e) {
|
|
2656
2712
|
const t = n.getTextCursorPosition().block;
|
|
2657
2713
|
t.content.length === 1 && t.content[0].type === "text" && t.content[0].text === "/" || t.content.length === 0 ? n.updateBlock(t, e) : (n.insertBlocks([e], t, "after"), n.setTextCursorPosition(n.getTextCursorPosition().nextBlock));
|
|
2658
2714
|
}
|
|
2659
|
-
const
|
|
2715
|
+
const yo = (n = St) => {
|
|
2660
2716
|
var t, o, r;
|
|
2661
2717
|
const e = [];
|
|
2662
2718
|
return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes("1") && e.push({
|
|
2663
2719
|
name: "Heading",
|
|
2664
2720
|
aliases: ["h", "heading1", "h1"],
|
|
2665
|
-
execute: (i) =>
|
|
2721
|
+
execute: (i) => I(i, {
|
|
2666
2722
|
type: "heading",
|
|
2667
2723
|
props: { level: "1" }
|
|
2668
2724
|
})
|
|
2669
2725
|
}), (o = n.heading.propSchema.level.values) != null && o.includes("2") && e.push({
|
|
2670
2726
|
name: "Heading 2",
|
|
2671
2727
|
aliases: ["h2", "heading2", "subheading"],
|
|
2672
|
-
execute: (i) =>
|
|
2728
|
+
execute: (i) => I(i, {
|
|
2673
2729
|
type: "heading",
|
|
2674
2730
|
props: { level: "2" }
|
|
2675
2731
|
})
|
|
2676
2732
|
}), (r = n.heading.propSchema.level.values) != null && r.includes("3") && e.push({
|
|
2677
2733
|
name: "Heading 3",
|
|
2678
2734
|
aliases: ["h3", "heading3", "subheading"],
|
|
2679
|
-
execute: (i) =>
|
|
2735
|
+
execute: (i) => I(i, {
|
|
2680
2736
|
type: "heading",
|
|
2681
2737
|
props: { level: "3" }
|
|
2682
2738
|
})
|
|
2683
2739
|
})), "bulletListItem" in n && e.push({
|
|
2684
2740
|
name: "Bullet List",
|
|
2685
2741
|
aliases: ["ul", "list", "bulletlist", "bullet list"],
|
|
2686
|
-
execute: (i) =>
|
|
2742
|
+
execute: (i) => I(i, {
|
|
2687
2743
|
type: "bulletListItem"
|
|
2688
2744
|
})
|
|
2689
2745
|
}), "numberedListItem" in n && e.push({
|
|
2690
2746
|
name: "Numbered List",
|
|
2691
2747
|
aliases: ["li", "list", "numberedlist", "numbered list"],
|
|
2692
|
-
execute: (i) =>
|
|
2748
|
+
execute: (i) => I(i, {
|
|
2693
2749
|
type: "numberedListItem"
|
|
2694
2750
|
})
|
|
2695
2751
|
}), "paragraph" in n && e.push({
|
|
2696
2752
|
name: "Paragraph",
|
|
2697
2753
|
aliases: ["p"],
|
|
2698
|
-
execute: (i) =>
|
|
2754
|
+
execute: (i) => I(i, {
|
|
2699
2755
|
type: "paragraph"
|
|
2700
2756
|
})
|
|
2701
2757
|
}), e;
|
|
2702
|
-
},
|
|
2758
|
+
}, vo = {
|
|
2703
2759
|
enableInputRules: !0,
|
|
2704
2760
|
enablePasteRules: !0,
|
|
2705
2761
|
enableCoreExtensions: !1
|
|
2706
2762
|
};
|
|
2707
|
-
class
|
|
2763
|
+
class Qo {
|
|
2708
2764
|
constructor(e = {}) {
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2765
|
+
p(this, "_tiptapEditor");
|
|
2766
|
+
p(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
2767
|
+
p(this, "schema");
|
|
2768
|
+
p(this, "ready", !1);
|
|
2769
|
+
p(this, "sideMenu");
|
|
2770
|
+
p(this, "formattingToolbar");
|
|
2771
|
+
p(this, "slashMenu");
|
|
2772
|
+
p(this, "hyperlinkToolbar");
|
|
2717
2773
|
var l, a, d, c, h;
|
|
2718
2774
|
this.options = e;
|
|
2719
2775
|
const t = {
|
|
@@ -2726,11 +2782,11 @@ class Jo {
|
|
|
2726
2782
|
blockSchema: e.blockSchema || St,
|
|
2727
2783
|
...e
|
|
2728
2784
|
};
|
|
2729
|
-
this.sideMenu = new
|
|
2785
|
+
this.sideMenu = new bo(this), this.formattingToolbar = new ao(this), this.slashMenu = new $e(
|
|
2730
2786
|
this,
|
|
2731
|
-
t.slashMenuItems ||
|
|
2732
|
-
), this.hyperlinkToolbar = new
|
|
2733
|
-
const o =
|
|
2787
|
+
t.slashMenuItems || yo(t.blockSchema)
|
|
2788
|
+
), this.hyperlinkToolbar = new uo(this);
|
|
2789
|
+
const o = Xe({
|
|
2734
2790
|
editor: this,
|
|
2735
2791
|
domAttributes: t.domAttributes || {},
|
|
2736
2792
|
blockSchema: t.blockSchema,
|
|
@@ -2751,29 +2807,29 @@ class Jo {
|
|
|
2751
2807
|
id: F.options.generateID()
|
|
2752
2808
|
}
|
|
2753
2809
|
]), s = {
|
|
2754
|
-
...
|
|
2810
|
+
...vo,
|
|
2755
2811
|
...t._tiptapOptions,
|
|
2756
2812
|
onCreate: () => {
|
|
2757
|
-
var
|
|
2758
|
-
(
|
|
2813
|
+
var u;
|
|
2814
|
+
(u = t.onEditorReady) == null || u.call(t, this), this.ready = !0;
|
|
2759
2815
|
},
|
|
2760
|
-
onBeforeCreate(
|
|
2816
|
+
onBeforeCreate(u) {
|
|
2761
2817
|
if (!i)
|
|
2762
2818
|
return;
|
|
2763
|
-
const f =
|
|
2819
|
+
const f = u.editor.schema, m = i.map((b) => D(b, f)), g = f.node(
|
|
2764
2820
|
"doc",
|
|
2765
2821
|
void 0,
|
|
2766
2822
|
f.node("blockGroup", void 0, m)
|
|
2767
2823
|
);
|
|
2768
|
-
|
|
2824
|
+
u.editor.options.content = g.toJSON();
|
|
2769
2825
|
},
|
|
2770
2826
|
onUpdate: () => {
|
|
2771
|
-
var
|
|
2772
|
-
this.ready && ((
|
|
2827
|
+
var u;
|
|
2828
|
+
this.ready && ((u = t.onEditorContentChange) == null || u.call(t, this));
|
|
2773
2829
|
},
|
|
2774
2830
|
onSelectionUpdate: () => {
|
|
2775
|
-
var
|
|
2776
|
-
this.ready && ((
|
|
2831
|
+
var u;
|
|
2832
|
+
this.ready && ((u = t.onTextCursorPositionChange) == null || u.call(t, this));
|
|
2777
2833
|
},
|
|
2778
2834
|
editable: e.editable === void 0 ? !0 : e.editable,
|
|
2779
2835
|
extensions: t.enableBlockNoteExtensions === !1 ? (l = t._tiptapOptions) == null ? void 0 : l.extensions : [...((a = t._tiptapOptions) == null ? void 0 : a.extensions) || [], ...o],
|
|
@@ -2789,7 +2845,7 @@ class Jo {
|
|
|
2789
2845
|
}
|
|
2790
2846
|
}
|
|
2791
2847
|
};
|
|
2792
|
-
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new
|
|
2848
|
+
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new Gt(s);
|
|
2793
2849
|
}
|
|
2794
2850
|
get prosemirrorView() {
|
|
2795
2851
|
return this._tiptapEditor.view;
|
|
@@ -2926,7 +2982,7 @@ class Jo {
|
|
|
2926
2982
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
2927
2983
|
*/
|
|
2928
2984
|
insertBlocks(e, t, o = "before") {
|
|
2929
|
-
|
|
2985
|
+
xt(e, t, o, this._tiptapEditor);
|
|
2930
2986
|
}
|
|
2931
2987
|
/**
|
|
2932
2988
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -2936,14 +2992,14 @@ class Jo {
|
|
|
2936
2992
|
* @param update A partial block which defines how the existing block should be changed.
|
|
2937
2993
|
*/
|
|
2938
2994
|
updateBlock(e, t) {
|
|
2939
|
-
|
|
2995
|
+
Ze(e, t, this._tiptapEditor);
|
|
2940
2996
|
}
|
|
2941
2997
|
/**
|
|
2942
2998
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
2943
2999
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
2944
3000
|
*/
|
|
2945
3001
|
removeBlocks(e) {
|
|
2946
|
-
|
|
3002
|
+
At(e, this._tiptapEditor);
|
|
2947
3003
|
}
|
|
2948
3004
|
/**
|
|
2949
3005
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -2953,7 +3009,7 @@ class Jo {
|
|
|
2953
3009
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
2954
3010
|
*/
|
|
2955
3011
|
replaceBlocks(e, t) {
|
|
2956
|
-
|
|
3012
|
+
Qe(e, t, this._tiptapEditor);
|
|
2957
3013
|
}
|
|
2958
3014
|
/**
|
|
2959
3015
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -3034,7 +3090,7 @@ class Jo {
|
|
|
3034
3090
|
createLink(e, t) {
|
|
3035
3091
|
if (e === "")
|
|
3036
3092
|
return;
|
|
3037
|
-
|
|
3093
|
+
const { from: o, to: r } = this._tiptapEditor.state.selection;
|
|
3038
3094
|
t || (t = this._tiptapEditor.state.doc.textBetween(o, r));
|
|
3039
3095
|
const i = this._tiptapEditor.schema.mark("link", { href: e });
|
|
3040
3096
|
this._tiptapEditor.view.dispatch(
|
|
@@ -3080,7 +3136,7 @@ class Jo {
|
|
|
3080
3136
|
* @returns The blocks, serialized as an HTML string.
|
|
3081
3137
|
*/
|
|
3082
3138
|
async blocksToHTML(e) {
|
|
3083
|
-
return
|
|
3139
|
+
return It(e, this._tiptapEditor.schema);
|
|
3084
3140
|
}
|
|
3085
3141
|
/**
|
|
3086
3142
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -3099,7 +3155,7 @@ class Jo {
|
|
|
3099
3155
|
* @returns The blocks, serialized as a Markdown string.
|
|
3100
3156
|
*/
|
|
3101
3157
|
async blocksToMarkdown(e) {
|
|
3102
|
-
return
|
|
3158
|
+
return oo(e, this._tiptapEditor.schema);
|
|
3103
3159
|
}
|
|
3104
3160
|
/**
|
|
3105
3161
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -3109,7 +3165,7 @@ class Jo {
|
|
|
3109
3165
|
* @returns The blocks parsed from the Markdown string.
|
|
3110
3166
|
*/
|
|
3111
3167
|
async markdownToBlocks(e) {
|
|
3112
|
-
return
|
|
3168
|
+
return ro(e, this.schema, this._tiptapEditor.schema);
|
|
3113
3169
|
}
|
|
3114
3170
|
/**
|
|
3115
3171
|
* Updates the user info for the current user that's shown to other collaborators.
|
|
@@ -3123,33 +3179,33 @@ class Jo {
|
|
|
3123
3179
|
}
|
|
3124
3180
|
}
|
|
3125
3181
|
export {
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3182
|
+
Qo as BlockNoteEditor,
|
|
3183
|
+
ze as CustomBlockSerializerExtension,
|
|
3184
|
+
ao as FormattingToolbarProsemirrorPlugin,
|
|
3185
|
+
io as FormattingToolbarView,
|
|
3186
|
+
uo as HyperlinkToolbarProsemirrorPlugin,
|
|
3187
|
+
bo as SideMenuProsemirrorPlugin,
|
|
3188
|
+
ko as SideMenuView,
|
|
3189
|
+
$e as SlashMenuProsemirrorPlugin,
|
|
3190
|
+
ye as UnreachableCaseError,
|
|
3191
|
+
Jo as blockStyles,
|
|
3136
3192
|
rt as camelToDataKebab,
|
|
3137
|
-
|
|
3193
|
+
Zo as createBlockSpec,
|
|
3138
3194
|
O as createTipTapBlock,
|
|
3139
3195
|
St as defaultBlockSchema,
|
|
3140
3196
|
P as defaultProps,
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3197
|
+
Xo as formatKeyboardShortcut,
|
|
3198
|
+
so as formattingToolbarPluginKey,
|
|
3199
|
+
Xe as getBlockNoteExtensions,
|
|
3200
|
+
yo as getDefaultSlashMenuItems,
|
|
3201
|
+
co as hyperlinkToolbarPluginKey,
|
|
3202
|
+
be as isAppleOS,
|
|
3147
3203
|
v as mergeCSSClasses,
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3204
|
+
Ce as parse,
|
|
3205
|
+
ve as propsToAttributes,
|
|
3206
|
+
we as render,
|
|
3207
|
+
Ge as setupSuggestionsMenu,
|
|
3208
|
+
go as sideMenuPluginKey,
|
|
3153
3209
|
X as slashMenuPluginKey
|
|
3154
3210
|
};
|
|
3155
3211
|
//# sourceMappingURL=blocknote.js.map
|