@blocknote/core 0.9.0 → 0.9.2
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 +337 -298
- 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 +5 -5
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +3 -3
- package/src/extensions/SideMenu/SideMenuPlugin.ts +9 -9
- 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/helpers/getBlockInfoFromPos.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/TableCell.d.ts +5 -0
- package/types/src/extensions/Blocks/nodes/TableRow.d.ts +5 -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 u = (n, e, t) => (
|
|
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 u = (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,7 +67,7 @@ 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), p = r.start(l), f = r.end(l);
|
|
61
71
|
return {
|
|
62
72
|
id: a,
|
|
63
73
|
node: s,
|
|
@@ -69,7 +79,7 @@ function k(n, e) {
|
|
|
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 }) => {
|
|
@@ -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() {
|
|
@@ -342,7 +352,7 @@ const Ce = O({
|
|
|
342
352
|
]
|
|
343
353
|
];
|
|
344
354
|
}
|
|
345
|
-
}),
|
|
355
|
+
}), wt = (n) => {
|
|
346
356
|
const { node: e, contentType: t } = k(
|
|
347
357
|
n.state.doc,
|
|
348
358
|
n.state.selection.from
|
|
@@ -361,7 +371,7 @@ const Ce = O({
|
|
|
361
371
|
s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
362
372
|
)
|
|
363
373
|
]);
|
|
364
|
-
},
|
|
374
|
+
}, Me = O({
|
|
365
375
|
name: "bulletListItem",
|
|
366
376
|
content: "inline*",
|
|
367
377
|
addInputRules() {
|
|
@@ -380,7 +390,7 @@ const Ce = O({
|
|
|
380
390
|
},
|
|
381
391
|
addKeyboardShortcuts() {
|
|
382
392
|
return {
|
|
383
|
-
Enter: () =>
|
|
393
|
+
Enter: () => wt(this.editor)
|
|
384
394
|
};
|
|
385
395
|
},
|
|
386
396
|
parseHTML() {
|
|
@@ -434,8 +444,8 @@ const Ce = O({
|
|
|
434
444
|
]
|
|
435
445
|
];
|
|
436
446
|
}
|
|
437
|
-
}),
|
|
438
|
-
key:
|
|
447
|
+
}), Ee = new S("numbered-list-indexing"), Be = () => new w({
|
|
448
|
+
key: Ee,
|
|
439
449
|
appendTransaction: (n, e, t) => {
|
|
440
450
|
const o = t.tr;
|
|
441
451
|
o.setMeta("numberedListIndexing", !0);
|
|
@@ -464,7 +474,7 @@ const Ce = O({
|
|
|
464
474
|
}
|
|
465
475
|
}), r ? o : null;
|
|
466
476
|
}
|
|
467
|
-
}),
|
|
477
|
+
}), Te = O({
|
|
468
478
|
name: "numberedListItem",
|
|
469
479
|
content: "inline*",
|
|
470
480
|
addAttributes() {
|
|
@@ -494,11 +504,11 @@ const Ce = O({
|
|
|
494
504
|
},
|
|
495
505
|
addKeyboardShortcuts() {
|
|
496
506
|
return {
|
|
497
|
-
Enter: () =>
|
|
507
|
+
Enter: () => wt(this.editor)
|
|
498
508
|
};
|
|
499
509
|
},
|
|
500
510
|
addProseMirrorPlugins() {
|
|
501
|
-
return [
|
|
511
|
+
return [Be()];
|
|
502
512
|
},
|
|
503
513
|
parseHTML() {
|
|
504
514
|
return [
|
|
@@ -555,7 +565,7 @@ const Ce = O({
|
|
|
555
565
|
]
|
|
556
566
|
];
|
|
557
567
|
}
|
|
558
|
-
}),
|
|
568
|
+
}), xe = O({
|
|
559
569
|
name: "paragraph",
|
|
560
570
|
content: "inline*",
|
|
561
571
|
parseHTML() {
|
|
@@ -611,36 +621,36 @@ const Ce = O({
|
|
|
611
621
|
}, St = {
|
|
612
622
|
paragraph: {
|
|
613
623
|
propSchema: P,
|
|
614
|
-
node:
|
|
624
|
+
node: xe
|
|
615
625
|
},
|
|
616
626
|
heading: {
|
|
617
627
|
propSchema: {
|
|
618
628
|
...P,
|
|
619
629
|
level: { default: "1", values: ["1", "2", "3"] }
|
|
620
630
|
},
|
|
621
|
-
node:
|
|
631
|
+
node: Se
|
|
622
632
|
},
|
|
623
633
|
bulletListItem: {
|
|
624
634
|
propSchema: P,
|
|
625
|
-
node:
|
|
635
|
+
node: Me
|
|
626
636
|
},
|
|
627
637
|
numberedListItem: {
|
|
628
638
|
propSchema: P,
|
|
629
|
-
node:
|
|
639
|
+
node: Te
|
|
630
640
|
}
|
|
631
641
|
};
|
|
632
|
-
function
|
|
642
|
+
function Ae(n, e = JSON.stringify) {
|
|
633
643
|
const t = {};
|
|
634
644
|
return n.filter((o) => {
|
|
635
645
|
const r = e(o);
|
|
636
646
|
return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
|
|
637
647
|
});
|
|
638
648
|
}
|
|
639
|
-
function
|
|
649
|
+
function Ie(n) {
|
|
640
650
|
const e = n.filter(
|
|
641
651
|
(o, r) => n.indexOf(o) !== r
|
|
642
652
|
);
|
|
643
|
-
return
|
|
653
|
+
return Ae(e);
|
|
644
654
|
}
|
|
645
655
|
const F = T.create({
|
|
646
656
|
name: "uniqueID",
|
|
@@ -651,7 +661,13 @@ const F = T.create({
|
|
|
651
661
|
return {
|
|
652
662
|
attributeName: "id",
|
|
653
663
|
types: [],
|
|
654
|
-
generateID: () =>
|
|
664
|
+
generateID: () => {
|
|
665
|
+
if (typeof window < "u" && window.__TEST_OPTIONS) {
|
|
666
|
+
const n = window.__TEST_OPTIONS;
|
|
667
|
+
return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
|
|
668
|
+
}
|
|
669
|
+
return ie();
|
|
670
|
+
},
|
|
655
671
|
filterTransaction: null
|
|
656
672
|
};
|
|
657
673
|
},
|
|
@@ -704,27 +720,27 @@ const F = T.create({
|
|
|
704
720
|
addProseMirrorPlugins() {
|
|
705
721
|
let n = null, e = !1;
|
|
706
722
|
return [
|
|
707
|
-
new
|
|
708
|
-
key: new
|
|
723
|
+
new w({
|
|
724
|
+
key: new S("uniqueID"),
|
|
709
725
|
appendTransaction: (t, o, r) => {
|
|
710
726
|
const i = t.some((m) => m.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && t.some((m) => {
|
|
711
|
-
|
|
727
|
+
let g, b;
|
|
712
728
|
return !(!((b = (g = this.options).filterTransaction) === null || b === void 0) && b.call(g, m));
|
|
713
729
|
});
|
|
714
730
|
if (!i || s)
|
|
715
731
|
return;
|
|
716
|
-
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h =
|
|
732
|
+
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h = Dt(
|
|
717
733
|
o.doc,
|
|
718
734
|
t
|
|
719
735
|
), { mapping: p } = h;
|
|
720
|
-
if (
|
|
721
|
-
const g =
|
|
736
|
+
if (Rt(h).forEach(({ newRange: m }) => {
|
|
737
|
+
const g = Vt(
|
|
722
738
|
r.doc,
|
|
723
739
|
m,
|
|
724
740
|
(M) => a.includes(M.type.name)
|
|
725
|
-
), b = g.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C =
|
|
741
|
+
), b = g.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C = Ie(b);
|
|
726
742
|
g.forEach(({ node: M, pos: R }) => {
|
|
727
|
-
|
|
743
|
+
let $;
|
|
728
744
|
const Q = ($ = l.doc.nodeAt(R)) === null || $ === void 0 ? void 0 : $.attrs[d];
|
|
729
745
|
if (Q === null) {
|
|
730
746
|
l.setNodeMarkup(R, void 0, {
|
|
@@ -733,8 +749,8 @@ const F = T.create({
|
|
|
733
749
|
});
|
|
734
750
|
return;
|
|
735
751
|
}
|
|
736
|
-
const { deleted:
|
|
737
|
-
|
|
752
|
+
const { deleted: Lt } = p.invert().mapResult(R);
|
|
753
|
+
Lt && C.includes(Q) && l.setNodeMarkup(R, void 0, {
|
|
738
754
|
...M.attrs,
|
|
739
755
|
[d]: c()
|
|
740
756
|
});
|
|
@@ -745,7 +761,7 @@ const F = T.create({
|
|
|
745
761
|
// we register a global drag handler to track the current drag source element
|
|
746
762
|
view(t) {
|
|
747
763
|
const o = (r) => {
|
|
748
|
-
|
|
764
|
+
let i;
|
|
749
765
|
n = !((i = t.dom.parentElement) === null || i === void 0) && i.contains(r.target) ? t.dom.parentElement : null;
|
|
750
766
|
};
|
|
751
767
|
return window.addEventListener("dragstart", o), {
|
|
@@ -761,7 +777,7 @@ const F = T.create({
|
|
|
761
777
|
// only create new ids for dropped content while holding `alt`
|
|
762
778
|
// or content is dragged from another editor
|
|
763
779
|
drop: (t, o) => {
|
|
764
|
-
|
|
780
|
+
let r;
|
|
765
781
|
return (n !== t.dom.parentElement || ((r = o.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy") && (n = null, e = !0), !1;
|
|
766
782
|
},
|
|
767
783
|
// always create new ids on pasted content
|
|
@@ -792,7 +808,7 @@ const F = T.create({
|
|
|
792
808
|
a.marks
|
|
793
809
|
);
|
|
794
810
|
l.push(d);
|
|
795
|
-
}),
|
|
811
|
+
}), _.from(l);
|
|
796
812
|
};
|
|
797
813
|
return e = !1, new x(
|
|
798
814
|
i(t.content),
|
|
@@ -804,25 +820,25 @@ const F = T.create({
|
|
|
804
820
|
})
|
|
805
821
|
];
|
|
806
822
|
}
|
|
807
|
-
}),
|
|
823
|
+
}), Mt = /* @__PURE__ */ new Set([
|
|
808
824
|
"bold",
|
|
809
825
|
"italic",
|
|
810
826
|
"underline",
|
|
811
827
|
"strike",
|
|
812
828
|
"code"
|
|
813
|
-
]),
|
|
829
|
+
]), Et = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
814
830
|
function it(n, e) {
|
|
815
831
|
const t = [];
|
|
816
832
|
for (const [o, r] of Object.entries(n.styles))
|
|
817
|
-
|
|
833
|
+
Mt.has(o) ? t.push(e.mark(o)) : Et.has(o) && t.push(e.mark(o, { color: r }));
|
|
818
834
|
return n.text.split(/(\n)/g).filter((o) => o.length > 0).map((o) => o === `
|
|
819
835
|
` ? e.nodes.hardBreak.create() : e.text(o, t));
|
|
820
836
|
}
|
|
821
|
-
function
|
|
837
|
+
function _e(n, e) {
|
|
822
838
|
const t = e.marks.link.create({
|
|
823
839
|
href: n.href
|
|
824
840
|
});
|
|
825
|
-
return
|
|
841
|
+
return Bt(n.content, e).map((o) => {
|
|
826
842
|
if (o.type.name === "text")
|
|
827
843
|
return o.mark([...o.marks, t]);
|
|
828
844
|
if (o.type.name === "hardBreak")
|
|
@@ -830,8 +846,8 @@ function Ae(n, e) {
|
|
|
830
846
|
throw new Error("unexpected node type");
|
|
831
847
|
});
|
|
832
848
|
}
|
|
833
|
-
function
|
|
834
|
-
|
|
849
|
+
function Bt(n, e) {
|
|
850
|
+
const t = [];
|
|
835
851
|
if (typeof n == "string")
|
|
836
852
|
return t.push(
|
|
837
853
|
...it({ type: "text", text: n, styles: {} }, e)
|
|
@@ -840,15 +856,15 @@ function Et(n, e) {
|
|
|
840
856
|
t.push(...it(o, e));
|
|
841
857
|
return t;
|
|
842
858
|
}
|
|
843
|
-
function
|
|
844
|
-
|
|
859
|
+
function Tt(n, e) {
|
|
860
|
+
const t = [];
|
|
845
861
|
for (const o of n)
|
|
846
862
|
if (o.type === "link")
|
|
847
|
-
t.push(...
|
|
863
|
+
t.push(..._e(o, e));
|
|
848
864
|
else if (o.type === "text")
|
|
849
|
-
t.push(...
|
|
865
|
+
t.push(...Bt([o], e));
|
|
850
866
|
else
|
|
851
|
-
throw new
|
|
867
|
+
throw new ye(o);
|
|
852
868
|
return t;
|
|
853
869
|
}
|
|
854
870
|
function D(n, e) {
|
|
@@ -865,7 +881,7 @@ function D(n, e) {
|
|
|
865
881
|
e.text(n.content)
|
|
866
882
|
);
|
|
867
883
|
else {
|
|
868
|
-
const l =
|
|
884
|
+
const l = Tt(n.content, e);
|
|
869
885
|
r = e.nodes[o].create(n.props, l);
|
|
870
886
|
}
|
|
871
887
|
const i = [];
|
|
@@ -881,7 +897,7 @@ function D(n, e) {
|
|
|
881
897
|
i.length > 0 ? [r, s] : r
|
|
882
898
|
);
|
|
883
899
|
}
|
|
884
|
-
function
|
|
900
|
+
function He(n) {
|
|
885
901
|
const e = [];
|
|
886
902
|
let t;
|
|
887
903
|
return n.content.forEach((o) => {
|
|
@@ -901,9 +917,9 @@ function _e(n) {
|
|
|
901
917
|
for (const s of o.marks)
|
|
902
918
|
if (s.type.name === "link")
|
|
903
919
|
i = s;
|
|
904
|
-
else if (wt.has(s.type.name))
|
|
905
|
-
r[s.type.name] = !0;
|
|
906
920
|
else if (Mt.has(s.type.name))
|
|
921
|
+
r[s.type.name] = !0;
|
|
922
|
+
else if (Et.has(s.type.name))
|
|
907
923
|
r[s.type.name] = s.attrs.color;
|
|
908
924
|
else
|
|
909
925
|
throw Error("Mark is of an unrecognized type: " + s.type.name);
|
|
@@ -966,12 +982,12 @@ function E(n, e, t) {
|
|
|
966
982
|
const o = t == null ? void 0 : t.get(n);
|
|
967
983
|
if (o)
|
|
968
984
|
return o;
|
|
969
|
-
const r =
|
|
985
|
+
const r = pt(n);
|
|
970
986
|
let i = r.id;
|
|
971
987
|
i === null && (i = F.options.generateID());
|
|
972
988
|
const s = {};
|
|
973
989
|
for (const [c, h] of Object.entries({
|
|
974
|
-
...
|
|
990
|
+
...n.attrs,
|
|
975
991
|
...r.contentNode.attrs
|
|
976
992
|
})) {
|
|
977
993
|
const p = e[r.contentType.name];
|
|
@@ -982,10 +998,10 @@ function E(n, e, t) {
|
|
|
982
998
|
const f = p.propSchema;
|
|
983
999
|
c in f ? s[c] = h : c !== "id" && !(c in P) && console.warn("Block has an unrecognized attribute: " + c);
|
|
984
1000
|
}
|
|
985
|
-
const l =
|
|
1001
|
+
const l = He(r.contentNode), a = [];
|
|
986
1002
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
987
1003
|
a.push(
|
|
988
|
-
E(
|
|
1004
|
+
E(n.lastChild.child(c), e, t)
|
|
989
1005
|
);
|
|
990
1006
|
const d = {
|
|
991
1007
|
id: i,
|
|
@@ -996,7 +1012,7 @@ function E(n, e, t) {
|
|
|
996
1012
|
};
|
|
997
1013
|
return t == null || t.set(n, d), d;
|
|
998
1014
|
}
|
|
999
|
-
const st = new
|
|
1015
|
+
const st = new S("previous-blocks"), Ne = {
|
|
1000
1016
|
// Numbered List Items
|
|
1001
1017
|
index: "index",
|
|
1002
1018
|
// Headings
|
|
@@ -1005,9 +1021,9 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1005
1021
|
type: "type",
|
|
1006
1022
|
depth: "depth",
|
|
1007
1023
|
"depth-change": "depth-change"
|
|
1008
|
-
},
|
|
1024
|
+
}, Le = () => {
|
|
1009
1025
|
let n;
|
|
1010
|
-
return new
|
|
1026
|
+
return new w({
|
|
1011
1027
|
key: st,
|
|
1012
1028
|
view(e) {
|
|
1013
1029
|
return {
|
|
@@ -1041,7 +1057,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1041
1057
|
const i = {}, s = tt(o.doc, (d) => d.attrs.id), l = new Map(
|
|
1042
1058
|
s.map((d) => [d.node.attrs.id, d])
|
|
1043
1059
|
), a = tt(r.doc, (d) => d.attrs.id);
|
|
1044
|
-
for (
|
|
1060
|
+
for (const d of a) {
|
|
1045
1061
|
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, p = d.node.firstChild;
|
|
1046
1062
|
if (c && h && p) {
|
|
1047
1063
|
const f = {
|
|
@@ -1072,8 +1088,8 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1072
1088
|
if (!r.attrs.id || !t.updatedBlocks.has(r.attrs.id))
|
|
1073
1089
|
return;
|
|
1074
1090
|
const s = t.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
|
|
1075
|
-
for (
|
|
1076
|
-
l["data-prev-" +
|
|
1091
|
+
for (const [d, c] of Object.entries(s))
|
|
1092
|
+
l["data-prev-" + Ne[d]] = c || "none";
|
|
1077
1093
|
const a = V.node(i, i + r.nodeSize, {
|
|
1078
1094
|
...l
|
|
1079
1095
|
});
|
|
@@ -1082,13 +1098,13 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1082
1098
|
}
|
|
1083
1099
|
}
|
|
1084
1100
|
});
|
|
1085
|
-
},
|
|
1101
|
+
}, Pe = {
|
|
1086
1102
|
blockColor: "data-block-color",
|
|
1087
1103
|
blockStyle: "data-block-style",
|
|
1088
1104
|
id: "data-id",
|
|
1089
1105
|
depth: "data-depth",
|
|
1090
1106
|
depthChange: "data-depth-change"
|
|
1091
|
-
},
|
|
1107
|
+
}, Oe = U.create({
|
|
1092
1108
|
name: "blockContainer",
|
|
1093
1109
|
group: "blockContainer",
|
|
1094
1110
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -1104,7 +1120,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1104
1120
|
if (typeof n == "string")
|
|
1105
1121
|
return !1;
|
|
1106
1122
|
const e = {};
|
|
1107
|
-
for (
|
|
1123
|
+
for (const [t, o] of Object.entries(Pe))
|
|
1108
1124
|
n.getAttribute(o) && (e[t] = n.getAttribute(o));
|
|
1109
1125
|
return n.getAttribute("data-node-type") === "blockContainer" ? e : !1;
|
|
1110
1126
|
}
|
|
@@ -1163,7 +1179,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1163
1179
|
l.childCount === 2 ? t.tr.replace(
|
|
1164
1180
|
i + a.nodeSize + 1,
|
|
1165
1181
|
s - 1,
|
|
1166
|
-
new x(
|
|
1182
|
+
new x(_.from(d), 0, 0)
|
|
1167
1183
|
) : t.tr.insert(
|
|
1168
1184
|
i + a.nodeSize,
|
|
1169
1185
|
t.schema.nodes.blockGroup.create({}, d)
|
|
@@ -1171,10 +1187,10 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1171
1187
|
}
|
|
1172
1188
|
if (e.content !== void 0) {
|
|
1173
1189
|
let d = [];
|
|
1174
|
-
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d =
|
|
1190
|
+
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d = Tt(e.content, t.schema), t.tr.replace(
|
|
1175
1191
|
i + 1,
|
|
1176
1192
|
i + a.nodeSize - 1,
|
|
1177
|
-
new x(
|
|
1193
|
+
new x(_.from(d), 0, 0)
|
|
1178
1194
|
);
|
|
1179
1195
|
}
|
|
1180
1196
|
t.tr.setNodeMarkup(
|
|
@@ -1247,7 +1263,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1247
1263
|
m,
|
|
1248
1264
|
m + 1,
|
|
1249
1265
|
h.content.size > 0 ? new x(
|
|
1250
|
-
|
|
1266
|
+
_.from(h),
|
|
1251
1267
|
d + 2,
|
|
1252
1268
|
d + 2
|
|
1253
1269
|
) : void 0
|
|
@@ -1262,7 +1278,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1262
1278
|
l + 1,
|
|
1263
1279
|
a - 1,
|
|
1264
1280
|
c.content.size > 0 ? new x(
|
|
1265
|
-
|
|
1281
|
+
_.from(c),
|
|
1266
1282
|
d + 2,
|
|
1267
1283
|
d + 2
|
|
1268
1284
|
) : void 0
|
|
@@ -1271,7 +1287,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1271
1287
|
};
|
|
1272
1288
|
},
|
|
1273
1289
|
addProseMirrorPlugins() {
|
|
1274
|
-
return [
|
|
1290
|
+
return [Le()];
|
|
1275
1291
|
},
|
|
1276
1292
|
addKeyboardShortcuts() {
|
|
1277
1293
|
return {
|
|
@@ -1371,7 +1387,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1371
1387
|
})
|
|
1372
1388
|
};
|
|
1373
1389
|
}
|
|
1374
|
-
}),
|
|
1390
|
+
}), De = U.create({
|
|
1375
1391
|
name: "blockGroup",
|
|
1376
1392
|
group: "blockGroup",
|
|
1377
1393
|
content: "blockContainer+",
|
|
@@ -1402,11 +1418,11 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1402
1418
|
0
|
|
1403
1419
|
];
|
|
1404
1420
|
}
|
|
1405
|
-
}),
|
|
1421
|
+
}), Re = U.create({
|
|
1406
1422
|
name: "doc",
|
|
1407
1423
|
topNode: !0,
|
|
1408
1424
|
content: "blockGroup"
|
|
1409
|
-
}),
|
|
1425
|
+
}), Ve = (n) => {
|
|
1410
1426
|
const e = W.fromSchema(n);
|
|
1411
1427
|
return new W(
|
|
1412
1428
|
{
|
|
@@ -1418,12 +1434,12 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1418
1434
|
},
|
|
1419
1435
|
e.marks
|
|
1420
1436
|
);
|
|
1421
|
-
},
|
|
1437
|
+
}, ze = T.create({
|
|
1422
1438
|
addProseMirrorPlugins() {
|
|
1423
1439
|
return [
|
|
1424
|
-
new
|
|
1440
|
+
new w({
|
|
1425
1441
|
props: {
|
|
1426
|
-
clipboardSerializer:
|
|
1442
|
+
clipboardSerializer: Ve(this.editor.schema)
|
|
1427
1443
|
}
|
|
1428
1444
|
})
|
|
1429
1445
|
];
|
|
@@ -1431,6 +1447,7 @@ const st = new w("previous-blocks"), Ie = {
|
|
|
1431
1447
|
});
|
|
1432
1448
|
class G {
|
|
1433
1449
|
constructor() {
|
|
1450
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1434
1451
|
u(this, "callbacks", {});
|
|
1435
1452
|
}
|
|
1436
1453
|
on(e, t) {
|
|
@@ -1448,10 +1465,10 @@ class G {
|
|
|
1448
1465
|
this.callbacks = {};
|
|
1449
1466
|
}
|
|
1450
1467
|
}
|
|
1451
|
-
const
|
|
1468
|
+
const Ue = zt(
|
|
1452
1469
|
(n) => n.type.name === "blockContainer"
|
|
1453
1470
|
);
|
|
1454
|
-
class
|
|
1471
|
+
class Fe {
|
|
1455
1472
|
constructor(e, t, o = () => {
|
|
1456
1473
|
}) {
|
|
1457
1474
|
u(this, "suggestionsMenuState");
|
|
@@ -1505,7 +1522,7 @@ function Y() {
|
|
|
1505
1522
|
decorationId: void 0
|
|
1506
1523
|
};
|
|
1507
1524
|
}
|
|
1508
|
-
const
|
|
1525
|
+
const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
1509
1526
|
}) => {
|
|
1510
1527
|
if (o.length !== 1)
|
|
1511
1528
|
throw new Error("'char' should be a single character");
|
|
@@ -1514,9 +1531,9 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1514
1531
|
a.dispatch(a.state.tr.setMeta(t, { deactivate: !0 }));
|
|
1515
1532
|
};
|
|
1516
1533
|
return {
|
|
1517
|
-
plugin: new
|
|
1534
|
+
plugin: new w({
|
|
1518
1535
|
key: t,
|
|
1519
|
-
view: () => (s = new
|
|
1536
|
+
view: () => (s = new Fe(
|
|
1520
1537
|
n,
|
|
1521
1538
|
t,
|
|
1522
1539
|
e
|
|
@@ -1611,7 +1628,7 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1611
1628
|
if (!d)
|
|
1612
1629
|
return null;
|
|
1613
1630
|
if (p === "") {
|
|
1614
|
-
const f =
|
|
1631
|
+
const f = Ue(a.selection);
|
|
1615
1632
|
if (f)
|
|
1616
1633
|
return z.create(a.doc, [
|
|
1617
1634
|
V.node(
|
|
@@ -1649,13 +1666,13 @@ const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
|
1649
1666
|
});
|
|
1650
1667
|
}
|
|
1651
1668
|
};
|
|
1652
|
-
}, X = new
|
|
1653
|
-
class
|
|
1669
|
+
}, X = new S("SlashMenuPlugin");
|
|
1670
|
+
class $e extends G {
|
|
1654
1671
|
constructor(t, o) {
|
|
1655
1672
|
super();
|
|
1656
1673
|
u(this, "plugin");
|
|
1657
1674
|
u(this, "itemCallback");
|
|
1658
|
-
const r =
|
|
1675
|
+
const r = Ge(
|
|
1659
1676
|
t,
|
|
1660
1677
|
(i) => {
|
|
1661
1678
|
this.emit("update", i);
|
|
@@ -1675,7 +1692,7 @@ class Fe extends G {
|
|
|
1675
1692
|
return this.on("update", t);
|
|
1676
1693
|
}
|
|
1677
1694
|
}
|
|
1678
|
-
const
|
|
1695
|
+
const je = new S("blocknote-placeholder"), qe = T.create({
|
|
1679
1696
|
name: "placeholder",
|
|
1680
1697
|
addOptions() {
|
|
1681
1698
|
return {
|
|
@@ -1691,8 +1708,8 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1691
1708
|
},
|
|
1692
1709
|
addProseMirrorPlugins() {
|
|
1693
1710
|
return [
|
|
1694
|
-
new
|
|
1695
|
-
key:
|
|
1711
|
+
new w({
|
|
1712
|
+
key: je,
|
|
1696
1713
|
props: {
|
|
1697
1714
|
decorations: (n) => {
|
|
1698
1715
|
const { doc: e, selection: t } = n, o = X.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
|
|
@@ -1714,7 +1731,7 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1714
1731
|
})
|
|
1715
1732
|
];
|
|
1716
1733
|
}
|
|
1717
|
-
}),
|
|
1734
|
+
}), We = T.create({
|
|
1718
1735
|
name: "textAlignment",
|
|
1719
1736
|
addGlobalAttributes() {
|
|
1720
1737
|
return [
|
|
@@ -1752,7 +1769,7 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1752
1769
|
}
|
|
1753
1770
|
};
|
|
1754
1771
|
}
|
|
1755
|
-
}),
|
|
1772
|
+
}), Ye = T.create({
|
|
1756
1773
|
name: "blockTextColor",
|
|
1757
1774
|
addGlobalAttributes() {
|
|
1758
1775
|
return [
|
|
@@ -1778,7 +1795,7 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1778
1795
|
}
|
|
1779
1796
|
};
|
|
1780
1797
|
}
|
|
1781
|
-
}),
|
|
1798
|
+
}), Ke = lt.create({
|
|
1782
1799
|
name: "textColor",
|
|
1783
1800
|
addAttributes() {
|
|
1784
1801
|
return {
|
|
@@ -1807,12 +1824,12 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1807
1824
|
setTextColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
1808
1825
|
};
|
|
1809
1826
|
}
|
|
1810
|
-
}),
|
|
1827
|
+
}), Je = T.create({
|
|
1811
1828
|
name: "trailingNode",
|
|
1812
1829
|
addProseMirrorPlugins() {
|
|
1813
|
-
const n = new
|
|
1830
|
+
const n = new S(this.name);
|
|
1814
1831
|
return [
|
|
1815
|
-
new
|
|
1832
|
+
new w({
|
|
1816
1833
|
key: n,
|
|
1817
1834
|
appendTransaction: (e, t, o) => {
|
|
1818
1835
|
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;
|
|
@@ -1839,7 +1856,8 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1839
1856
|
})
|
|
1840
1857
|
];
|
|
1841
1858
|
}
|
|
1842
|
-
}),
|
|
1859
|
+
}), Xe = (n) => {
|
|
1860
|
+
var t;
|
|
1843
1861
|
const e = [
|
|
1844
1862
|
L.ClipboardTextSerializer,
|
|
1845
1863
|
L.Commands,
|
|
@@ -1847,9 +1865,9 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1847
1865
|
L.FocusEvents,
|
|
1848
1866
|
L.Tabindex,
|
|
1849
1867
|
// DevTools,
|
|
1850
|
-
|
|
1868
|
+
Kt,
|
|
1851
1869
|
// DropCursor,
|
|
1852
|
-
|
|
1870
|
+
qe.configure({
|
|
1853
1871
|
emptyNodeClass: y.isEmpty,
|
|
1854
1872
|
hasAnchorClass: y.hasAnchor,
|
|
1855
1873
|
isFilterClass: y.isFilter,
|
|
@@ -1859,65 +1877,66 @@ const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
|
1859
1877
|
F.configure({
|
|
1860
1878
|
types: ["blockContainer"]
|
|
1861
1879
|
}),
|
|
1862
|
-
|
|
1880
|
+
Jt,
|
|
1863
1881
|
// Comments,
|
|
1864
1882
|
// basics:
|
|
1865
|
-
|
|
1883
|
+
ee,
|
|
1866
1884
|
// marks:
|
|
1867
|
-
Gt,
|
|
1868
1885
|
$t,
|
|
1869
|
-
|
|
1870
|
-
Qt,
|
|
1871
|
-
ee,
|
|
1886
|
+
jt,
|
|
1872
1887
|
Zt,
|
|
1888
|
+
te,
|
|
1889
|
+
oe,
|
|
1890
|
+
Qt,
|
|
1891
|
+
Ke,
|
|
1892
|
+
Ye,
|
|
1893
|
+
ge,
|
|
1894
|
+
ke,
|
|
1873
1895
|
We,
|
|
1874
|
-
qe,
|
|
1875
|
-
me,
|
|
1876
|
-
fe,
|
|
1877
|
-
je,
|
|
1878
1896
|
// nodes
|
|
1879
|
-
|
|
1880
|
-
|
|
1897
|
+
Re,
|
|
1898
|
+
Oe.configure({
|
|
1881
1899
|
domAttributes: n.domAttributes
|
|
1882
1900
|
}),
|
|
1883
|
-
|
|
1901
|
+
De.configure({
|
|
1884
1902
|
domAttributes: n.domAttributes
|
|
1885
1903
|
}),
|
|
1886
1904
|
...Object.values(n.blockSchema).map(
|
|
1887
|
-
(
|
|
1905
|
+
(o) => o.node.configure({
|
|
1888
1906
|
editor: n.editor,
|
|
1889
1907
|
domAttributes: n.domAttributes
|
|
1890
1908
|
})
|
|
1891
1909
|
),
|
|
1892
|
-
|
|
1893
|
-
|
|
1910
|
+
ze,
|
|
1911
|
+
Yt.configure({ width: 5, color: "#ddeeff" }),
|
|
1894
1912
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
1895
1913
|
// should be handled before Enter handlers in other components like splitListItem
|
|
1896
|
-
|
|
1914
|
+
Je
|
|
1897
1915
|
];
|
|
1898
1916
|
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(
|
|
1917
|
+
if (e.push(
|
|
1913
1918
|
qt.configure({
|
|
1914
|
-
|
|
1915
|
-
render: n.collaboration.renderCursor || t,
|
|
1916
|
-
provider: n.collaboration.provider
|
|
1919
|
+
fragment: n.collaboration.fragment
|
|
1917
1920
|
})
|
|
1918
|
-
)
|
|
1921
|
+
), (t = n.collaboration.provider) != null && t.awareness) {
|
|
1922
|
+
const o = (r) => {
|
|
1923
|
+
const i = document.createElement("span");
|
|
1924
|
+
i.classList.add(H["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
|
|
1925
|
+
const s = document.createElement("span");
|
|
1926
|
+
s.classList.add(H["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
|
|
1927
|
+
const l = document.createTextNode(""), a = document.createTextNode("");
|
|
1928
|
+
return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
|
|
1929
|
+
};
|
|
1930
|
+
e.push(
|
|
1931
|
+
Wt.configure({
|
|
1932
|
+
user: n.collaboration.user,
|
|
1933
|
+
render: n.collaboration.renderCursor || o,
|
|
1934
|
+
provider: n.collaboration.provider
|
|
1935
|
+
})
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1919
1938
|
} else
|
|
1920
|
-
e.push(
|
|
1939
|
+
e.push(Xt);
|
|
1921
1940
|
return e;
|
|
1922
1941
|
};
|
|
1923
1942
|
function Z(n, e) {
|
|
@@ -1929,7 +1948,7 @@ function Z(n, e) {
|
|
|
1929
1948
|
posBeforeNode: o
|
|
1930
1949
|
};
|
|
1931
1950
|
}
|
|
1932
|
-
function
|
|
1951
|
+
function xt(n, e, t = "before", o) {
|
|
1933
1952
|
const r = typeof e == "string" ? e : e.id, i = [];
|
|
1934
1953
|
for (const d of n)
|
|
1935
1954
|
i.push(D(d, o.schema));
|
|
@@ -1951,11 +1970,11 @@ function Tt(n, e, t = "before", o) {
|
|
|
1951
1970
|
}
|
|
1952
1971
|
o.view.dispatch(o.state.tr.insert(s, i));
|
|
1953
1972
|
}
|
|
1954
|
-
function
|
|
1973
|
+
function Ze(n, e, t) {
|
|
1955
1974
|
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = Z(o, t.state.doc);
|
|
1956
1975
|
t.commands.BNUpdateBlock(r + 1, e);
|
|
1957
1976
|
}
|
|
1958
|
-
function
|
|
1977
|
+
function At(n, e) {
|
|
1959
1978
|
const t = new Set(
|
|
1960
1979
|
n.map(
|
|
1961
1980
|
(r) => typeof r == "string" ? r : r.id
|
|
@@ -1973,17 +1992,17 @@ function xt(n, e) {
|
|
|
1973
1992
|
const l = e.state.doc.nodeSize;
|
|
1974
1993
|
return o += s - l, !1;
|
|
1975
1994
|
}), t.size > 0) {
|
|
1976
|
-
|
|
1995
|
+
const r = [...t].join(`
|
|
1977
1996
|
`);
|
|
1978
1997
|
throw Error(
|
|
1979
1998
|
"Blocks with the following IDs could not be found in the editor: " + r
|
|
1980
1999
|
);
|
|
1981
2000
|
}
|
|
1982
2001
|
}
|
|
1983
|
-
function
|
|
1984
|
-
|
|
2002
|
+
function Qe(n, e, t) {
|
|
2003
|
+
xt(e, n[0], "before", t), At(n, t);
|
|
1985
2004
|
}
|
|
1986
|
-
function
|
|
2005
|
+
function to() {
|
|
1987
2006
|
const n = (e) => {
|
|
1988
2007
|
let t = e.children.length;
|
|
1989
2008
|
for (let o = 0; o < t; o++) {
|
|
@@ -1999,7 +2018,7 @@ function Ze() {
|
|
|
1999
2018
|
};
|
|
2000
2019
|
return n;
|
|
2001
2020
|
}
|
|
2002
|
-
function
|
|
2021
|
+
function eo(n) {
|
|
2003
2022
|
const e = /* @__PURE__ */ new Set([
|
|
2004
2023
|
...n.orderedListItemBlockTypes,
|
|
2005
2024
|
...n.unorderedListItemBlockTypes
|
|
@@ -2043,13 +2062,13 @@ function Qe(n) {
|
|
|
2043
2062
|
};
|
|
2044
2063
|
return t;
|
|
2045
2064
|
}
|
|
2046
|
-
async function
|
|
2065
|
+
async function It(n, e) {
|
|
2047
2066
|
const t = document.createElement("div"), o = W.fromSchema(e);
|
|
2048
2067
|
for (const i of n) {
|
|
2049
2068
|
const s = D(i, e), l = o.serializeNode(s);
|
|
2050
2069
|
t.appendChild(l);
|
|
2051
2070
|
}
|
|
2052
|
-
return (await J().use(dt, { fragment: !0 }).use(
|
|
2071
|
+
return (await J().use(dt, { fragment: !0 }).use(eo, {
|
|
2053
2072
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
2054
2073
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
2055
2074
|
}).use(ct).process(t.innerHTML)).value;
|
|
@@ -2057,19 +2076,41 @@ async function At(n, e) {
|
|
|
2057
2076
|
async function _t(n, e, t) {
|
|
2058
2077
|
const o = document.createElement("div");
|
|
2059
2078
|
o.innerHTML = n.trim();
|
|
2060
|
-
const i =
|
|
2079
|
+
const i = ne.fromSchema(t).parse(o), s = [];
|
|
2061
2080
|
for (let l = 0; l < i.firstChild.childCount; l++)
|
|
2062
2081
|
s.push(E(i.firstChild.child(l), e));
|
|
2063
2082
|
return s;
|
|
2064
2083
|
}
|
|
2065
|
-
async function
|
|
2066
|
-
return (await J().use(dt, { fragment: !0 }).use(
|
|
2084
|
+
async function oo(n, e) {
|
|
2085
|
+
return (await J().use(dt, { fragment: !0 }).use(to).use(ae).use(ut).use(ue).process(await It(n, e))).value;
|
|
2067
2086
|
}
|
|
2068
|
-
|
|
2069
|
-
const
|
|
2087
|
+
function no(n, e) {
|
|
2088
|
+
const t = e.value ? e.value + `
|
|
2089
|
+
` : "", o = {};
|
|
2090
|
+
e.lang && (o["data-language"] = e.lang);
|
|
2091
|
+
let r = {
|
|
2092
|
+
type: "element",
|
|
2093
|
+
tagName: "code",
|
|
2094
|
+
properties: o,
|
|
2095
|
+
children: [{ type: "text", value: t }]
|
|
2096
|
+
};
|
|
2097
|
+
return e.meta && (r.data = { meta: e.meta }), n.patch(e, r), r = n.applyData(e, r), r = {
|
|
2098
|
+
type: "element",
|
|
2099
|
+
tagName: "pre",
|
|
2100
|
+
properties: {},
|
|
2101
|
+
children: [r]
|
|
2102
|
+
}, n.patch(e, r), r;
|
|
2103
|
+
}
|
|
2104
|
+
async function ro(n, e, t) {
|
|
2105
|
+
const o = await J().use(le).use(ut).use(de, {
|
|
2106
|
+
handlers: {
|
|
2107
|
+
...ce,
|
|
2108
|
+
code: no
|
|
2109
|
+
}
|
|
2110
|
+
}).use(ct).process(n);
|
|
2070
2111
|
return _t(o.value, e, t);
|
|
2071
2112
|
}
|
|
2072
|
-
class
|
|
2113
|
+
class io {
|
|
2073
2114
|
constructor(e, t, o) {
|
|
2074
2115
|
u(this, "formattingToolbarState");
|
|
2075
2116
|
u(this, "updateFormattingToolbar");
|
|
@@ -2077,7 +2118,7 @@ class oo {
|
|
|
2077
2118
|
u(this, "preventShow", !1);
|
|
2078
2119
|
u(this, "prevWasEditable", null);
|
|
2079
2120
|
u(this, "shouldShow", ({ view: e, state: t, from: o, to: r }) => {
|
|
2080
|
-
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length &&
|
|
2121
|
+
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length && Ut(t.selection);
|
|
2081
2122
|
return !(!e.hasFocus() || l || a);
|
|
2082
2123
|
});
|
|
2083
2124
|
u(this, "viewMousedownHandler", () => {
|
|
@@ -2146,7 +2187,7 @@ class oo {
|
|
|
2146
2187
|
}
|
|
2147
2188
|
getSelectionBoundingBox() {
|
|
2148
2189
|
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 (
|
|
2190
|
+
if (Ft(t)) {
|
|
2150
2191
|
const s = this.pmView.nodeDOM(r);
|
|
2151
2192
|
if (s)
|
|
2152
2193
|
return s.getBoundingClientRect();
|
|
@@ -2154,17 +2195,17 @@ class oo {
|
|
|
2154
2195
|
return q(this.pmView, r, i);
|
|
2155
2196
|
}
|
|
2156
2197
|
}
|
|
2157
|
-
const
|
|
2198
|
+
const so = new S(
|
|
2158
2199
|
"FormattingToolbarPlugin"
|
|
2159
2200
|
);
|
|
2160
|
-
class
|
|
2201
|
+
class ao extends G {
|
|
2161
2202
|
constructor(t) {
|
|
2162
2203
|
super();
|
|
2163
2204
|
u(this, "view");
|
|
2164
2205
|
u(this, "plugin");
|
|
2165
|
-
this.plugin = new
|
|
2166
|
-
key:
|
|
2167
|
-
view: (o) => (this.view = new
|
|
2206
|
+
this.plugin = new w({
|
|
2207
|
+
key: so,
|
|
2208
|
+
view: (o) => (this.view = new io(t, o, (r) => {
|
|
2168
2209
|
this.emit("update", r);
|
|
2169
2210
|
}), this.view)
|
|
2170
2211
|
});
|
|
@@ -2173,7 +2214,7 @@ class ro extends G {
|
|
|
2173
2214
|
return this.on("update", t);
|
|
2174
2215
|
}
|
|
2175
2216
|
}
|
|
2176
|
-
class
|
|
2217
|
+
class lo {
|
|
2177
2218
|
constructor(e, t, o) {
|
|
2178
2219
|
u(this, "hyperlinkToolbarState");
|
|
2179
2220
|
u(this, "updateHyperlinkToolbar");
|
|
@@ -2294,10 +2335,10 @@ class io {
|
|
|
2294
2335
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2295
2336
|
}
|
|
2296
2337
|
}
|
|
2297
|
-
const
|
|
2338
|
+
const co = new S(
|
|
2298
2339
|
"HyperlinkToolbarPlugin"
|
|
2299
2340
|
);
|
|
2300
|
-
class
|
|
2341
|
+
class uo extends G {
|
|
2301
2342
|
constructor(t) {
|
|
2302
2343
|
super();
|
|
2303
2344
|
u(this, "view");
|
|
@@ -2332,9 +2373,9 @@ class ao extends G {
|
|
|
2332
2373
|
u(this, "stopHideTimer", () => {
|
|
2333
2374
|
this.view.stopMenuUpdateTimer();
|
|
2334
2375
|
});
|
|
2335
|
-
this.plugin = new
|
|
2336
|
-
key:
|
|
2337
|
-
view: (o) => (this.view = new
|
|
2376
|
+
this.plugin = new w({
|
|
2377
|
+
key: co,
|
|
2378
|
+
view: (o) => (this.view = new lo(t, o, (r) => {
|
|
2338
2379
|
this.emit("update", r);
|
|
2339
2380
|
}), this.view)
|
|
2340
2381
|
});
|
|
@@ -2357,7 +2398,7 @@ class N extends j {
|
|
|
2357
2398
|
return new N(t.resolve(o), t.resolve(r));
|
|
2358
2399
|
}
|
|
2359
2400
|
content() {
|
|
2360
|
-
return new x(
|
|
2401
|
+
return new x(_.from(this.nodes), 0, 0);
|
|
2361
2402
|
}
|
|
2362
2403
|
eq(t) {
|
|
2363
2404
|
if (!(t instanceof N) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
|
|
@@ -2368,7 +2409,7 @@ class N extends j {
|
|
|
2368
2409
|
return !0;
|
|
2369
2410
|
}
|
|
2370
2411
|
map(t, o) {
|
|
2371
|
-
|
|
2412
|
+
const r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2372
2413
|
return i.deleted ? j.near(t.resolve(r.pos)) : r.deleted ? j.near(t.resolve(i.pos)) : new N(
|
|
2373
2414
|
t.resolve(r.pos),
|
|
2374
2415
|
t.resolve(i.pos)
|
|
@@ -2378,13 +2419,13 @@ class N extends j {
|
|
|
2378
2419
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
2379
2420
|
}
|
|
2380
2421
|
}
|
|
2381
|
-
const
|
|
2422
|
+
const po = se.__serializeForClipboard;
|
|
2382
2423
|
let B;
|
|
2383
|
-
function
|
|
2424
|
+
function Ht(n, e) {
|
|
2384
2425
|
var r;
|
|
2385
2426
|
if (!e.dom.isConnected)
|
|
2386
2427
|
return;
|
|
2387
|
-
|
|
2428
|
+
const t = e.posAtCoords(n);
|
|
2388
2429
|
if (!t)
|
|
2389
2430
|
return;
|
|
2390
2431
|
let o = e.domAtPos(t.pos).node;
|
|
@@ -2395,16 +2436,15 @@ function It(n, e) {
|
|
|
2395
2436
|
return { node: o, id: o.getAttribute("data-id") };
|
|
2396
2437
|
}
|
|
2397
2438
|
}
|
|
2398
|
-
function
|
|
2399
|
-
|
|
2439
|
+
function ho(n, e) {
|
|
2440
|
+
const t = Ht(n, e);
|
|
2400
2441
|
if (t && t.node.nodeType === 1) {
|
|
2401
|
-
const o = e.docView;
|
|
2402
|
-
let r = o.nearestDesc(t.node, !0);
|
|
2442
|
+
const o = e.docView, r = o.nearestDesc(t.node, !0);
|
|
2403
2443
|
return !r || r === o ? null : r.posBefore;
|
|
2404
2444
|
}
|
|
2405
2445
|
return null;
|
|
2406
2446
|
}
|
|
2407
|
-
function
|
|
2447
|
+
function fo(n, e) {
|
|
2408
2448
|
let t, o;
|
|
2409
2449
|
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
2450
|
if (r && i) {
|
|
@@ -2427,36 +2467,35 @@ function at(n, e, t = e) {
|
|
|
2427
2467
|
);
|
|
2428
2468
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
2429
2469
|
(c > l || c < s) && o.removeChild(o.children[c]);
|
|
2430
|
-
|
|
2470
|
+
Nt(), B = o;
|
|
2431
2471
|
const d = n.dom.className.split(" ").filter(
|
|
2432
2472
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
2433
2473
|
).join(" ");
|
|
2434
2474
|
B.className = B.className + " " + H.dragPreview + " " + d, document.body.appendChild(B);
|
|
2435
2475
|
}
|
|
2436
|
-
function
|
|
2476
|
+
function Nt() {
|
|
2437
2477
|
B !== void 0 && (document.body.removeChild(B), B = void 0);
|
|
2438
2478
|
}
|
|
2439
|
-
function
|
|
2479
|
+
function mo(n, e) {
|
|
2440
2480
|
if (!n.dataTransfer)
|
|
2441
2481
|
return;
|
|
2442
|
-
const t = e.dom.getBoundingClientRect()
|
|
2443
|
-
let o = {
|
|
2482
|
+
const t = e.dom.getBoundingClientRect(), o = {
|
|
2444
2483
|
left: t.left + t.width / 2,
|
|
2445
2484
|
// take middle of editor
|
|
2446
2485
|
top: n.clientY
|
|
2447
|
-
}, r =
|
|
2486
|
+
}, r = ho(o, e);
|
|
2448
2487
|
if (r != null) {
|
|
2449
|
-
const i = e.state.selection, s = e.state.doc, { from: l, to: a } =
|
|
2488
|
+
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
2489
|
d && c ? (e.dispatch(
|
|
2451
2490
|
e.state.tr.setSelection(N.create(s, l, a))
|
|
2452
2491
|
), at(e, l, a)) : (e.dispatch(
|
|
2453
|
-
e.state.tr.setSelection(
|
|
2492
|
+
e.state.tr.setSelection(re.create(e.state.doc, r))
|
|
2454
2493
|
), at(e, r));
|
|
2455
|
-
|
|
2494
|
+
const h = e.state.selection.content(), { dom: p, text: f } = po(e, h);
|
|
2456
2495
|
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", p.innerHTML), n.dataTransfer.setData("text/plain", f), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(B, 0, 0), e.dragging = { slice: h, move: !0 };
|
|
2457
2496
|
}
|
|
2458
2497
|
}
|
|
2459
|
-
class
|
|
2498
|
+
class ko {
|
|
2460
2499
|
constructor(e, t, o) {
|
|
2461
2500
|
u(this, "sideMenuState");
|
|
2462
2501
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
@@ -2482,7 +2521,7 @@ class ho {
|
|
|
2482
2521
|
u(this, "onDrop", (e) => {
|
|
2483
2522
|
if (this.editor._tiptapEditor.commands.blur(), e.synthetic || !this.isDragging)
|
|
2484
2523
|
return;
|
|
2485
|
-
|
|
2524
|
+
const t = this.pmView.posAtCoords({
|
|
2486
2525
|
left: e.clientX,
|
|
2487
2526
|
top: e.clientY
|
|
2488
2527
|
});
|
|
@@ -2499,7 +2538,7 @@ class ho {
|
|
|
2499
2538
|
u(this, "onDragOver", (e) => {
|
|
2500
2539
|
if (e.synthetic || !this.isDragging)
|
|
2501
2540
|
return;
|
|
2502
|
-
|
|
2541
|
+
const t = this.pmView.posAtCoords({
|
|
2503
2542
|
left: e.clientX,
|
|
2504
2543
|
top: e.clientY
|
|
2505
2544
|
});
|
|
@@ -2531,7 +2570,7 @@ class ho {
|
|
|
2531
2570
|
left: t.left + t.width / 2,
|
|
2532
2571
|
// take middle of editor
|
|
2533
2572
|
top: e.clientY
|
|
2534
|
-
}, l =
|
|
2573
|
+
}, l = Ht(s, this.pmView);
|
|
2535
2574
|
if (!l || !this.editor.isEditable) {
|
|
2536
2575
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2537
2576
|
return;
|
|
@@ -2604,8 +2643,8 @@ class ho {
|
|
|
2604
2643
|
);
|
|
2605
2644
|
}
|
|
2606
2645
|
}
|
|
2607
|
-
const
|
|
2608
|
-
class
|
|
2646
|
+
const go = new S("SideMenuPlugin");
|
|
2647
|
+
class bo extends G {
|
|
2609
2648
|
constructor(t) {
|
|
2610
2649
|
super();
|
|
2611
2650
|
u(this, "sideMenuView");
|
|
@@ -2619,12 +2658,12 @@ class mo extends G {
|
|
|
2619
2658
|
* Handles drag & drop events for blocks.
|
|
2620
2659
|
*/
|
|
2621
2660
|
u(this, "blockDragStart", (t) => {
|
|
2622
|
-
this.sideMenuView.isDragging = !0,
|
|
2661
|
+
this.sideMenuView.isDragging = !0, mo(t, this.editor.prosemirrorView);
|
|
2623
2662
|
});
|
|
2624
2663
|
/**
|
|
2625
2664
|
* Handles drag & drop events for blocks.
|
|
2626
2665
|
*/
|
|
2627
|
-
u(this, "blockDragEnd", () =>
|
|
2666
|
+
u(this, "blockDragEnd", () => Nt());
|
|
2628
2667
|
/**
|
|
2629
2668
|
* Freezes the side menu. When frozen, the side menu will stay
|
|
2630
2669
|
* attached to the same block regardless of which block is hovered by the
|
|
@@ -2637,9 +2676,9 @@ class mo extends G {
|
|
|
2637
2676
|
* mouse cursor.
|
|
2638
2677
|
*/
|
|
2639
2678
|
u(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2640
|
-
this.editor = t, this.plugin = new
|
|
2641
|
-
key:
|
|
2642
|
-
view: (o) => (this.sideMenuView = new
|
|
2679
|
+
this.editor = t, this.plugin = new w({
|
|
2680
|
+
key: go,
|
|
2681
|
+
view: (o) => (this.sideMenuView = new ko(
|
|
2643
2682
|
t,
|
|
2644
2683
|
o,
|
|
2645
2684
|
(r) => {
|
|
@@ -2652,59 +2691,59 @@ class mo extends G {
|
|
|
2652
2691
|
return this.on("update", t);
|
|
2653
2692
|
}
|
|
2654
2693
|
}
|
|
2655
|
-
function
|
|
2694
|
+
function I(n, e) {
|
|
2656
2695
|
const t = n.getTextCursorPosition().block;
|
|
2657
2696
|
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
2697
|
}
|
|
2659
|
-
const
|
|
2698
|
+
const yo = (n = St) => {
|
|
2660
2699
|
var t, o, r;
|
|
2661
2700
|
const e = [];
|
|
2662
2701
|
return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes("1") && e.push({
|
|
2663
2702
|
name: "Heading",
|
|
2664
2703
|
aliases: ["h", "heading1", "h1"],
|
|
2665
|
-
execute: (i) =>
|
|
2704
|
+
execute: (i) => I(i, {
|
|
2666
2705
|
type: "heading",
|
|
2667
2706
|
props: { level: "1" }
|
|
2668
2707
|
})
|
|
2669
2708
|
}), (o = n.heading.propSchema.level.values) != null && o.includes("2") && e.push({
|
|
2670
2709
|
name: "Heading 2",
|
|
2671
2710
|
aliases: ["h2", "heading2", "subheading"],
|
|
2672
|
-
execute: (i) =>
|
|
2711
|
+
execute: (i) => I(i, {
|
|
2673
2712
|
type: "heading",
|
|
2674
2713
|
props: { level: "2" }
|
|
2675
2714
|
})
|
|
2676
2715
|
}), (r = n.heading.propSchema.level.values) != null && r.includes("3") && e.push({
|
|
2677
2716
|
name: "Heading 3",
|
|
2678
2717
|
aliases: ["h3", "heading3", "subheading"],
|
|
2679
|
-
execute: (i) =>
|
|
2718
|
+
execute: (i) => I(i, {
|
|
2680
2719
|
type: "heading",
|
|
2681
2720
|
props: { level: "3" }
|
|
2682
2721
|
})
|
|
2683
2722
|
})), "bulletListItem" in n && e.push({
|
|
2684
2723
|
name: "Bullet List",
|
|
2685
2724
|
aliases: ["ul", "list", "bulletlist", "bullet list"],
|
|
2686
|
-
execute: (i) =>
|
|
2725
|
+
execute: (i) => I(i, {
|
|
2687
2726
|
type: "bulletListItem"
|
|
2688
2727
|
})
|
|
2689
2728
|
}), "numberedListItem" in n && e.push({
|
|
2690
2729
|
name: "Numbered List",
|
|
2691
2730
|
aliases: ["li", "list", "numberedlist", "numbered list"],
|
|
2692
|
-
execute: (i) =>
|
|
2731
|
+
execute: (i) => I(i, {
|
|
2693
2732
|
type: "numberedListItem"
|
|
2694
2733
|
})
|
|
2695
2734
|
}), "paragraph" in n && e.push({
|
|
2696
2735
|
name: "Paragraph",
|
|
2697
2736
|
aliases: ["p"],
|
|
2698
|
-
execute: (i) =>
|
|
2737
|
+
execute: (i) => I(i, {
|
|
2699
2738
|
type: "paragraph"
|
|
2700
2739
|
})
|
|
2701
2740
|
}), e;
|
|
2702
|
-
},
|
|
2741
|
+
}, vo = {
|
|
2703
2742
|
enableInputRules: !0,
|
|
2704
2743
|
enablePasteRules: !0,
|
|
2705
2744
|
enableCoreExtensions: !1
|
|
2706
2745
|
};
|
|
2707
|
-
class
|
|
2746
|
+
class Qo {
|
|
2708
2747
|
constructor(e = {}) {
|
|
2709
2748
|
u(this, "_tiptapEditor");
|
|
2710
2749
|
u(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
@@ -2726,11 +2765,11 @@ class Jo {
|
|
|
2726
2765
|
blockSchema: e.blockSchema || St,
|
|
2727
2766
|
...e
|
|
2728
2767
|
};
|
|
2729
|
-
this.sideMenu = new
|
|
2768
|
+
this.sideMenu = new bo(this), this.formattingToolbar = new ao(this), this.slashMenu = new $e(
|
|
2730
2769
|
this,
|
|
2731
|
-
t.slashMenuItems ||
|
|
2732
|
-
), this.hyperlinkToolbar = new
|
|
2733
|
-
const o =
|
|
2770
|
+
t.slashMenuItems || yo(t.blockSchema)
|
|
2771
|
+
), this.hyperlinkToolbar = new uo(this);
|
|
2772
|
+
const o = Xe({
|
|
2734
2773
|
editor: this,
|
|
2735
2774
|
domAttributes: t.domAttributes || {},
|
|
2736
2775
|
blockSchema: t.blockSchema,
|
|
@@ -2751,7 +2790,7 @@ class Jo {
|
|
|
2751
2790
|
id: F.options.generateID()
|
|
2752
2791
|
}
|
|
2753
2792
|
]), s = {
|
|
2754
|
-
...
|
|
2793
|
+
...vo,
|
|
2755
2794
|
...t._tiptapOptions,
|
|
2756
2795
|
onCreate: () => {
|
|
2757
2796
|
var p;
|
|
@@ -2789,7 +2828,7 @@ class Jo {
|
|
|
2789
2828
|
}
|
|
2790
2829
|
}
|
|
2791
2830
|
};
|
|
2792
|
-
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new
|
|
2831
|
+
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new Gt(s);
|
|
2793
2832
|
}
|
|
2794
2833
|
get prosemirrorView() {
|
|
2795
2834
|
return this._tiptapEditor.view;
|
|
@@ -2926,7 +2965,7 @@ class Jo {
|
|
|
2926
2965
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
2927
2966
|
*/
|
|
2928
2967
|
insertBlocks(e, t, o = "before") {
|
|
2929
|
-
|
|
2968
|
+
xt(e, t, o, this._tiptapEditor);
|
|
2930
2969
|
}
|
|
2931
2970
|
/**
|
|
2932
2971
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -2936,14 +2975,14 @@ class Jo {
|
|
|
2936
2975
|
* @param update A partial block which defines how the existing block should be changed.
|
|
2937
2976
|
*/
|
|
2938
2977
|
updateBlock(e, t) {
|
|
2939
|
-
|
|
2978
|
+
Ze(e, t, this._tiptapEditor);
|
|
2940
2979
|
}
|
|
2941
2980
|
/**
|
|
2942
2981
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
2943
2982
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
2944
2983
|
*/
|
|
2945
2984
|
removeBlocks(e) {
|
|
2946
|
-
|
|
2985
|
+
At(e, this._tiptapEditor);
|
|
2947
2986
|
}
|
|
2948
2987
|
/**
|
|
2949
2988
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -2953,7 +2992,7 @@ class Jo {
|
|
|
2953
2992
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
2954
2993
|
*/
|
|
2955
2994
|
replaceBlocks(e, t) {
|
|
2956
|
-
|
|
2995
|
+
Qe(e, t, this._tiptapEditor);
|
|
2957
2996
|
}
|
|
2958
2997
|
/**
|
|
2959
2998
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -3034,7 +3073,7 @@ class Jo {
|
|
|
3034
3073
|
createLink(e, t) {
|
|
3035
3074
|
if (e === "")
|
|
3036
3075
|
return;
|
|
3037
|
-
|
|
3076
|
+
const { from: o, to: r } = this._tiptapEditor.state.selection;
|
|
3038
3077
|
t || (t = this._tiptapEditor.state.doc.textBetween(o, r));
|
|
3039
3078
|
const i = this._tiptapEditor.schema.mark("link", { href: e });
|
|
3040
3079
|
this._tiptapEditor.view.dispatch(
|
|
@@ -3080,7 +3119,7 @@ class Jo {
|
|
|
3080
3119
|
* @returns The blocks, serialized as an HTML string.
|
|
3081
3120
|
*/
|
|
3082
3121
|
async blocksToHTML(e) {
|
|
3083
|
-
return
|
|
3122
|
+
return It(e, this._tiptapEditor.schema);
|
|
3084
3123
|
}
|
|
3085
3124
|
/**
|
|
3086
3125
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -3099,7 +3138,7 @@ class Jo {
|
|
|
3099
3138
|
* @returns The blocks, serialized as a Markdown string.
|
|
3100
3139
|
*/
|
|
3101
3140
|
async blocksToMarkdown(e) {
|
|
3102
|
-
return
|
|
3141
|
+
return oo(e, this._tiptapEditor.schema);
|
|
3103
3142
|
}
|
|
3104
3143
|
/**
|
|
3105
3144
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -3109,7 +3148,7 @@ class Jo {
|
|
|
3109
3148
|
* @returns The blocks parsed from the Markdown string.
|
|
3110
3149
|
*/
|
|
3111
3150
|
async markdownToBlocks(e) {
|
|
3112
|
-
return
|
|
3151
|
+
return ro(e, this.schema, this._tiptapEditor.schema);
|
|
3113
3152
|
}
|
|
3114
3153
|
/**
|
|
3115
3154
|
* Updates the user info for the current user that's shown to other collaborators.
|
|
@@ -3123,33 +3162,33 @@ class Jo {
|
|
|
3123
3162
|
}
|
|
3124
3163
|
}
|
|
3125
3164
|
export {
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3165
|
+
Qo as BlockNoteEditor,
|
|
3166
|
+
ze as CustomBlockSerializerExtension,
|
|
3167
|
+
ao as FormattingToolbarProsemirrorPlugin,
|
|
3168
|
+
io as FormattingToolbarView,
|
|
3169
|
+
uo as HyperlinkToolbarProsemirrorPlugin,
|
|
3170
|
+
bo as SideMenuProsemirrorPlugin,
|
|
3171
|
+
ko as SideMenuView,
|
|
3172
|
+
$e as SlashMenuProsemirrorPlugin,
|
|
3173
|
+
ye as UnreachableCaseError,
|
|
3174
|
+
Jo as blockStyles,
|
|
3136
3175
|
rt as camelToDataKebab,
|
|
3137
|
-
|
|
3176
|
+
Zo as createBlockSpec,
|
|
3138
3177
|
O as createTipTapBlock,
|
|
3139
3178
|
St as defaultBlockSchema,
|
|
3140
3179
|
P as defaultProps,
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3180
|
+
Xo as formatKeyboardShortcut,
|
|
3181
|
+
so as formattingToolbarPluginKey,
|
|
3182
|
+
Xe as getBlockNoteExtensions,
|
|
3183
|
+
yo as getDefaultSlashMenuItems,
|
|
3184
|
+
co as hyperlinkToolbarPluginKey,
|
|
3185
|
+
be as isAppleOS,
|
|
3147
3186
|
v as mergeCSSClasses,
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3187
|
+
Ce as parse,
|
|
3188
|
+
ve as propsToAttributes,
|
|
3189
|
+
we as render,
|
|
3190
|
+
Ge as setupSuggestionsMenu,
|
|
3191
|
+
go as sideMenuPluginKey,
|
|
3153
3192
|
X as slashMenuPluginKey
|
|
3154
3193
|
};
|
|
3155
3194
|
//# sourceMappingURL=blocknote.js.map
|