@blocknote/core 0.8.0 → 0.8.1
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 +479 -413
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -2
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +4 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +292 -0
- package/src/api/nodeConversions/nodeConversions.test.ts +236 -0
- package/src/api/nodeConversions/nodeConversions.ts +166 -35
- package/src/editor.module.css +5 -5
- package/src/extensions/Blocks/nodes/Block.module.css +4 -4
- package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +45 -3
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +8 -16
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +19 -0
- package/types/src/BlockNoteEditor.d.ts +1 -0
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +1 -1
- package/types/src/extensions/Placeholder/localisation/index.d.ts +2 -0
- package/types/src/extensions/Placeholder/localisation/translation.d.ts +51 -0
- package/types/src/extensions/Blocks/api/alertBlock.d.ts +0 -13
- package/types/src/extensions/Blocks/api/alertBlock2.d.ts +0 -13
package/dist/blocknote.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
var
|
|
2
|
-
var At = (o, e, t) => e in o ?
|
|
1
|
+
var Nt = Object.defineProperty;
|
|
2
|
+
var At = (o, e, t) => e in o ? Nt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
3
|
var h = (o, e, t) => (At(o, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { Node as R, InputRule as
|
|
5
|
-
import { PluginKey as E, Plugin as C, TextSelection as tt, Selection as G, NodeSelection as
|
|
6
|
-
import { Slice as I, Fragment as _, DOMSerializer as q, DOMParser as
|
|
7
|
-
import { v4 as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
4
|
+
import { Node as R, InputRule as Y, mergeAttributes as w, Extension as v, findChildren as j, combineTransactionSteps as Ht, getChangedRanges as Ot, findChildrenInRange as Dt, Mark as st, findParentNode as Ft, isTextSelection as Rt, isNodeSelection as zt, posToDOMRect as at, getMarkRange as Q, extensions as N, Editor as Ut } from "@tiptap/core";
|
|
5
|
+
import { PluginKey as E, Plugin as C, TextSelection as tt, Selection as G, NodeSelection as $t } from "prosemirror-state";
|
|
6
|
+
import { Slice as I, Fragment as _, DOMSerializer as q, DOMParser as Gt } from "prosemirror-model";
|
|
7
|
+
import { v4 as jt } from "uuid";
|
|
8
|
+
import lt from "rehype-parse";
|
|
9
|
+
import qt from "rehype-remark";
|
|
10
|
+
import dt from "rehype-stringify";
|
|
11
|
+
import ct from "remark-gfm";
|
|
12
|
+
import Wt from "remark-parse";
|
|
13
|
+
import Yt from "remark-rehype";
|
|
14
14
|
import Vt from "remark-stringify";
|
|
15
|
-
import { unified as
|
|
15
|
+
import { unified as V } from "unified";
|
|
16
16
|
import { fromDom as et } from "hast-util-from-dom";
|
|
17
|
-
import { Bold as
|
|
18
|
-
import { Code as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { Dropcursor as
|
|
22
|
-
import { Gapcursor as
|
|
23
|
-
import { HardBreak as
|
|
24
|
-
import { History as
|
|
25
|
-
import { Italic as
|
|
26
|
-
import { Link as
|
|
27
|
-
import { Strike as
|
|
28
|
-
import { Text as
|
|
29
|
-
import { Underline as
|
|
30
|
-
import * as
|
|
17
|
+
import { Bold as Kt } from "@tiptap/extension-bold";
|
|
18
|
+
import { Code as Jt } from "@tiptap/extension-code";
|
|
19
|
+
import Xt from "@tiptap/extension-collaboration";
|
|
20
|
+
import Zt from "@tiptap/extension-collaboration-cursor";
|
|
21
|
+
import { Dropcursor as Qt } from "@tiptap/extension-dropcursor";
|
|
22
|
+
import { Gapcursor as te } from "@tiptap/extension-gapcursor";
|
|
23
|
+
import { HardBreak as ee } from "@tiptap/extension-hard-break";
|
|
24
|
+
import { History as oe } from "@tiptap/extension-history";
|
|
25
|
+
import { Italic as ne } from "@tiptap/extension-italic";
|
|
26
|
+
import { Link as ut } from "@tiptap/extension-link";
|
|
27
|
+
import { Strike as re } from "@tiptap/extension-strike";
|
|
28
|
+
import { Text as ie } from "@tiptap/extension-text";
|
|
29
|
+
import { Underline as se } from "@tiptap/extension-underline";
|
|
30
|
+
import * as ae from "prosemirror-view";
|
|
31
31
|
import { Decoration as D, DecorationSet as F } from "prosemirror-view";
|
|
32
|
-
const
|
|
33
|
-
blockOuter:
|
|
34
|
-
block:
|
|
35
|
-
reactNodeViewRenderer:
|
|
32
|
+
const ht = "_blockOuter_xgzwr_5", pt = "_block_xgzwr_5", ft = "_reactNodeViewRenderer_xgzwr_17", mt = "_blockContent_xgzwr_22", gt = "_blockGroup_xgzwr_42", kt = "_isEmpty_xgzwr_240", yt = "_inlineContent_xgzwr_240", bt = "_isFilter_xgzwr_241", vt = "_hasAnchor_xgzwr_263", k = {
|
|
33
|
+
blockOuter: ht,
|
|
34
|
+
block: pt,
|
|
35
|
+
reactNodeViewRenderer: ft,
|
|
36
36
|
blockContent: mt,
|
|
37
|
-
blockGroup:
|
|
38
|
-
isEmpty:
|
|
39
|
-
inlineContent:
|
|
37
|
+
blockGroup: gt,
|
|
38
|
+
isEmpty: kt,
|
|
39
|
+
inlineContent: yt,
|
|
40
40
|
isFilter: bt,
|
|
41
|
-
hasAnchor:
|
|
42
|
-
},
|
|
41
|
+
hasAnchor: vt
|
|
42
|
+
}, Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
43
43
|
__proto__: null,
|
|
44
|
-
block:
|
|
44
|
+
block: pt,
|
|
45
45
|
blockContent: mt,
|
|
46
|
-
blockGroup:
|
|
47
|
-
blockOuter:
|
|
46
|
+
blockGroup: gt,
|
|
47
|
+
blockOuter: ht,
|
|
48
48
|
default: k,
|
|
49
|
-
hasAnchor:
|
|
50
|
-
inlineContent:
|
|
51
|
-
isEmpty:
|
|
49
|
+
hasAnchor: vt,
|
|
50
|
+
inlineContent: yt,
|
|
51
|
+
isEmpty: kt,
|
|
52
52
|
isFilter: bt,
|
|
53
|
-
reactNodeViewRenderer:
|
|
53
|
+
reactNodeViewRenderer: ft
|
|
54
54
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
55
55
|
function ot(o) {
|
|
56
56
|
return "data-" + o.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function le(o) {
|
|
59
59
|
const e = {};
|
|
60
60
|
return Object.entries(o.propSchema).forEach(([t, n]) => {
|
|
61
61
|
e[t] = {
|
|
@@ -71,14 +71,14 @@ function ae(o) {
|
|
|
71
71
|
};
|
|
72
72
|
}), e;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function de(o) {
|
|
75
75
|
return [
|
|
76
76
|
{
|
|
77
77
|
tag: "div[data-content-type=" + o.type + "]"
|
|
78
78
|
}
|
|
79
79
|
];
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function ce(o, e) {
|
|
82
82
|
const t = document.createElement("div");
|
|
83
83
|
t.setAttribute("data-content-type", o.type);
|
|
84
84
|
for (const [r, i] of Object.entries(e))
|
|
@@ -91,7 +91,7 @@ function de(o, e) {
|
|
|
91
91
|
dom: t
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function Vo(o) {
|
|
95
95
|
return {
|
|
96
96
|
node: H({
|
|
97
97
|
name: o.type,
|
|
@@ -103,26 +103,26 @@ function Yo(o) {
|
|
|
103
103
|
};
|
|
104
104
|
},
|
|
105
105
|
addAttributes() {
|
|
106
|
-
return
|
|
106
|
+
return le(o);
|
|
107
107
|
},
|
|
108
108
|
parseHTML() {
|
|
109
|
-
return
|
|
109
|
+
return de(o);
|
|
110
110
|
},
|
|
111
111
|
renderHTML({ HTMLAttributes: t }) {
|
|
112
|
-
return
|
|
112
|
+
return ce(o, t);
|
|
113
113
|
},
|
|
114
114
|
addNodeView() {
|
|
115
115
|
return ({ HTMLAttributes: t, getPos: n }) => {
|
|
116
116
|
const r = document.createElement("div");
|
|
117
117
|
r.className = k.blockContent, r.setAttribute("data-content-type", o.type);
|
|
118
|
-
for (const [p,
|
|
119
|
-
r.setAttribute(p,
|
|
118
|
+
for (const [p, f] of Object.entries(t))
|
|
119
|
+
r.setAttribute(p, f);
|
|
120
120
|
const i = this.options.editor;
|
|
121
121
|
if (typeof n == "boolean")
|
|
122
122
|
throw new Error(
|
|
123
123
|
"Cannot find node position as getPos is a boolean, not a function."
|
|
124
124
|
);
|
|
125
|
-
const
|
|
125
|
+
const s = n(), d = i._tiptapEditor.state.doc.resolve(s).node().attrs.id, c = i.getBlock(d);
|
|
126
126
|
if (c.type !== o.type)
|
|
127
127
|
throw new Error("Block type does not match");
|
|
128
128
|
const u = o.render(c, i);
|
|
@@ -144,7 +144,7 @@ function H(o) {
|
|
|
144
144
|
group: "blockContent"
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
const
|
|
147
|
+
const ue = H({
|
|
148
148
|
name: "heading",
|
|
149
149
|
content: "inline*",
|
|
150
150
|
addAttributes() {
|
|
@@ -161,7 +161,7 @@ const ce = H({
|
|
|
161
161
|
},
|
|
162
162
|
addInputRules() {
|
|
163
163
|
return [
|
|
164
|
-
...["1", "2", "3"].map((o) => new
|
|
164
|
+
...["1", "2", "3"].map((o) => new Y({
|
|
165
165
|
find: new RegExp(`^(#{${parseInt(o)}})\\s$`),
|
|
166
166
|
handler: ({ state: e, chain: t, range: n }) => {
|
|
167
167
|
t().BNUpdateBlock(e.selection.from, {
|
|
@@ -216,11 +216,11 @@ function g(o, e) {
|
|
|
216
216
|
break;
|
|
217
217
|
i -= 1, r = t.node(i);
|
|
218
218
|
}
|
|
219
|
-
const
|
|
219
|
+
const s = r.attrs.id, a = r.firstChild, l = a.type, d = r.childCount === 2 ? r.lastChild.childCount : 0, c = t.start(i), u = t.end(i);
|
|
220
220
|
return {
|
|
221
|
-
id:
|
|
221
|
+
id: s,
|
|
222
222
|
node: r,
|
|
223
|
-
contentNode:
|
|
223
|
+
contentNode: a,
|
|
224
224
|
contentType: l,
|
|
225
225
|
numChildBlocks: d,
|
|
226
226
|
startPos: c,
|
|
@@ -228,15 +228,15 @@ function g(o, e) {
|
|
|
228
228
|
depth: i
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
|
-
const
|
|
231
|
+
const Et = (o) => {
|
|
232
232
|
const { node: e, contentType: t } = g(
|
|
233
233
|
o.state.doc,
|
|
234
234
|
o.state.selection.from
|
|
235
235
|
), n = o.state.selection.anchor === o.state.selection.head;
|
|
236
|
-
return !t.name.endsWith("ListItem") || !n ? !1 : o.commands.first(({ state: r, chain: i, commands:
|
|
236
|
+
return !t.name.endsWith("ListItem") || !n ? !1 : o.commands.first(({ state: r, chain: i, commands: s }) => [
|
|
237
237
|
() => (
|
|
238
238
|
// Changes list item block to a text block if the content is empty.
|
|
239
|
-
|
|
239
|
+
s.command(() => e.textContent.length === 0 ? s.BNUpdateBlock(r.selection.from, {
|
|
240
240
|
type: "paragraph",
|
|
241
241
|
props: {}
|
|
242
242
|
}) : !1)
|
|
@@ -244,16 +244,16 @@ const vt = (o) => {
|
|
|
244
244
|
() => (
|
|
245
245
|
// Splits the current block, moving content inside that's after the cursor to a new block of the same type
|
|
246
246
|
// below.
|
|
247
|
-
|
|
247
|
+
s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
248
248
|
)
|
|
249
249
|
]);
|
|
250
|
-
},
|
|
250
|
+
}, he = H({
|
|
251
251
|
name: "bulletListItem",
|
|
252
252
|
content: "inline*",
|
|
253
253
|
addInputRules() {
|
|
254
254
|
return [
|
|
255
255
|
// Creates an unordered list when starting with "-", "+", or "*".
|
|
256
|
-
new
|
|
256
|
+
new Y({
|
|
257
257
|
find: new RegExp("^[-+*]\\s$"),
|
|
258
258
|
handler: ({ state: o, chain: e, range: t }) => {
|
|
259
259
|
e().BNUpdateBlock(o.selection.from, {
|
|
@@ -266,7 +266,7 @@ const vt = (o) => {
|
|
|
266
266
|
},
|
|
267
267
|
addKeyboardShortcuts() {
|
|
268
268
|
return {
|
|
269
|
-
Enter: () =>
|
|
269
|
+
Enter: () => Et(this.editor)
|
|
270
270
|
};
|
|
271
271
|
},
|
|
272
272
|
parseHTML() {
|
|
@@ -306,32 +306,32 @@ const vt = (o) => {
|
|
|
306
306
|
["p", { class: k.inlineContent }, 0]
|
|
307
307
|
];
|
|
308
308
|
}
|
|
309
|
-
}),
|
|
310
|
-
key:
|
|
309
|
+
}), pe = new E("numbered-list-indexing"), fe = () => new C({
|
|
310
|
+
key: pe,
|
|
311
311
|
appendTransaction: (o, e, t) => {
|
|
312
312
|
const n = t.tr;
|
|
313
313
|
n.setMeta("numberedListIndexing", !0);
|
|
314
314
|
let r = !1;
|
|
315
|
-
return t.doc.descendants((i,
|
|
315
|
+
return t.doc.descendants((i, s) => {
|
|
316
316
|
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
317
|
-
let
|
|
318
|
-
const l =
|
|
317
|
+
let a = "1";
|
|
318
|
+
const l = s === 1, d = g(n.doc, s + 1);
|
|
319
319
|
if (d === void 0)
|
|
320
320
|
return;
|
|
321
321
|
if (!l) {
|
|
322
|
-
const p = g(n.doc,
|
|
322
|
+
const p = g(n.doc, s - 2);
|
|
323
323
|
if (p === void 0)
|
|
324
324
|
return;
|
|
325
325
|
if (!(d.depth !== p.depth)) {
|
|
326
|
-
const
|
|
326
|
+
const m = p.contentNode;
|
|
327
327
|
if (p.contentType.name === "numberedListItem") {
|
|
328
|
-
const U =
|
|
329
|
-
|
|
328
|
+
const U = m.attrs.index;
|
|
329
|
+
a = (parseInt(U) + 1).toString();
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
d.contentNode.attrs.index !==
|
|
334
|
-
index:
|
|
333
|
+
d.contentNode.attrs.index !== a && (r = !0, n.setNodeMarkup(s + 1, void 0, {
|
|
334
|
+
index: a
|
|
335
335
|
}));
|
|
336
336
|
}
|
|
337
337
|
}), r ? n : null;
|
|
@@ -353,7 +353,7 @@ const vt = (o) => {
|
|
|
353
353
|
addInputRules() {
|
|
354
354
|
return [
|
|
355
355
|
// Creates an ordered list when starting with "1.".
|
|
356
|
-
new
|
|
356
|
+
new Y({
|
|
357
357
|
find: new RegExp("^1\\.\\s$"),
|
|
358
358
|
handler: ({ state: o, chain: e, range: t }) => {
|
|
359
359
|
e().BNUpdateBlock(o.selection.from, {
|
|
@@ -366,11 +366,11 @@ const vt = (o) => {
|
|
|
366
366
|
},
|
|
367
367
|
addKeyboardShortcuts() {
|
|
368
368
|
return {
|
|
369
|
-
Enter: () =>
|
|
369
|
+
Enter: () => Et(this.editor)
|
|
370
370
|
};
|
|
371
371
|
},
|
|
372
372
|
addProseMirrorPlugins() {
|
|
373
|
-
return [
|
|
373
|
+
return [fe()];
|
|
374
374
|
},
|
|
375
375
|
parseHTML() {
|
|
376
376
|
return [
|
|
@@ -413,7 +413,7 @@ const vt = (o) => {
|
|
|
413
413
|
["p", { class: k.inlineContent }, 0]
|
|
414
414
|
];
|
|
415
415
|
}
|
|
416
|
-
}),
|
|
416
|
+
}), ge = H({
|
|
417
417
|
name: "paragraph",
|
|
418
418
|
content: "inline*",
|
|
419
419
|
parseHTML() {
|
|
@@ -435,7 +435,7 @@ const vt = (o) => {
|
|
|
435
435
|
["p", { class: k.inlineContent }, 0]
|
|
436
436
|
];
|
|
437
437
|
}
|
|
438
|
-
}),
|
|
438
|
+
}), A = {
|
|
439
439
|
backgroundColor: {
|
|
440
440
|
default: "transparent"
|
|
441
441
|
},
|
|
@@ -447,28 +447,28 @@ const vt = (o) => {
|
|
|
447
447
|
default: "left",
|
|
448
448
|
values: ["left", "center", "right", "justify"]
|
|
449
449
|
}
|
|
450
|
-
},
|
|
450
|
+
}, ke = {
|
|
451
451
|
paragraph: {
|
|
452
|
-
propSchema:
|
|
453
|
-
node:
|
|
452
|
+
propSchema: A,
|
|
453
|
+
node: ge
|
|
454
454
|
},
|
|
455
455
|
heading: {
|
|
456
456
|
propSchema: {
|
|
457
|
-
...
|
|
457
|
+
...A,
|
|
458
458
|
level: { default: "1", values: ["1", "2", "3"] }
|
|
459
459
|
},
|
|
460
|
-
node:
|
|
460
|
+
node: ue
|
|
461
461
|
},
|
|
462
462
|
bulletListItem: {
|
|
463
|
-
propSchema:
|
|
464
|
-
node:
|
|
463
|
+
propSchema: A,
|
|
464
|
+
node: he
|
|
465
465
|
},
|
|
466
466
|
numberedListItem: {
|
|
467
|
-
propSchema:
|
|
467
|
+
propSchema: A,
|
|
468
468
|
node: me
|
|
469
469
|
}
|
|
470
470
|
};
|
|
471
|
-
function
|
|
471
|
+
function ye(o, e = JSON.stringify) {
|
|
472
472
|
const t = {};
|
|
473
473
|
return o.filter((n) => {
|
|
474
474
|
const r = e(n);
|
|
@@ -479,7 +479,7 @@ function be(o) {
|
|
|
479
479
|
const e = o.filter(
|
|
480
480
|
(n, r) => o.indexOf(n) !== r
|
|
481
481
|
);
|
|
482
|
-
return
|
|
482
|
+
return ye(e);
|
|
483
483
|
}
|
|
484
484
|
const K = v.create({
|
|
485
485
|
name: "uniqueID",
|
|
@@ -490,7 +490,7 @@ const K = v.create({
|
|
|
490
490
|
return {
|
|
491
491
|
attributeName: "id",
|
|
492
492
|
types: [],
|
|
493
|
-
generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) :
|
|
493
|
+
generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) : jt(),
|
|
494
494
|
filterTransaction: null
|
|
495
495
|
};
|
|
496
496
|
},
|
|
@@ -516,11 +516,11 @@ const K = v.create({
|
|
|
516
516
|
(l) => l.name === "collaboration"
|
|
517
517
|
))
|
|
518
518
|
return;
|
|
519
|
-
const { view: o, state: e } = this.editor, { tr: t, doc: n } = e, { types: r, attributeName: i, generateID:
|
|
519
|
+
const { view: o, state: e } = this.editor, { tr: t, doc: n } = e, { types: r, attributeName: i, generateID: s } = this.options;
|
|
520
520
|
j(n, (l) => r.includes(l.type.name) && l.attrs[i] === null).forEach(({ node: l, pos: d }) => {
|
|
521
521
|
t.setNodeMarkup(d, void 0, {
|
|
522
522
|
...l.attrs,
|
|
523
|
-
[i]:
|
|
523
|
+
[i]: s()
|
|
524
524
|
});
|
|
525
525
|
}), t.setMeta("addToHistory", !1), o.dispatch(t);
|
|
526
526
|
},
|
|
@@ -530,40 +530,40 @@ const K = v.create({
|
|
|
530
530
|
new C({
|
|
531
531
|
key: new E("uniqueID"),
|
|
532
532
|
appendTransaction: (t, n, r) => {
|
|
533
|
-
const i = t.some((
|
|
534
|
-
var
|
|
535
|
-
return !(!((
|
|
533
|
+
const i = t.some((m) => m.docChanged) && !n.doc.eq(r.doc), s = this.options.filterTransaction && t.some((m) => {
|
|
534
|
+
var b, y;
|
|
535
|
+
return !(!((y = (b = this.options).filterTransaction) === null || y === void 0) && y.call(b, m));
|
|
536
536
|
});
|
|
537
|
-
if (!i ||
|
|
537
|
+
if (!i || s)
|
|
538
538
|
return;
|
|
539
|
-
const { tr:
|
|
539
|
+
const { tr: a } = r, { types: l, attributeName: d, generateID: c } = this.options, u = Ht(
|
|
540
540
|
n.doc,
|
|
541
541
|
t
|
|
542
542
|
), { mapping: p } = u;
|
|
543
|
-
if (
|
|
544
|
-
const
|
|
543
|
+
if (Ot(u).forEach(({ newRange: m }) => {
|
|
544
|
+
const b = Dt(
|
|
545
545
|
r.doc,
|
|
546
|
-
|
|
546
|
+
m,
|
|
547
547
|
(M) => l.includes(M.type.name)
|
|
548
|
-
),
|
|
549
|
-
|
|
548
|
+
), y = b.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), U = be(y);
|
|
549
|
+
b.forEach(({ node: M, pos: O }) => {
|
|
550
550
|
var $;
|
|
551
|
-
const Z = ($ =
|
|
551
|
+
const Z = ($ = a.doc.nodeAt(O)) === null || $ === void 0 ? void 0 : $.attrs[d];
|
|
552
552
|
if (Z === null) {
|
|
553
|
-
|
|
553
|
+
a.setNodeMarkup(O, void 0, {
|
|
554
554
|
...M.attrs,
|
|
555
555
|
[d]: c()
|
|
556
556
|
});
|
|
557
557
|
return;
|
|
558
558
|
}
|
|
559
|
-
const { deleted:
|
|
560
|
-
|
|
559
|
+
const { deleted: Lt } = p.invert().mapResult(O);
|
|
560
|
+
Lt && U.includes(Z) && a.setNodeMarkup(O, void 0, {
|
|
561
561
|
...M.attrs,
|
|
562
562
|
[d]: c()
|
|
563
563
|
});
|
|
564
564
|
});
|
|
565
|
-
}), !!
|
|
566
|
-
return
|
|
565
|
+
}), !!a.steps.length)
|
|
566
|
+
return a;
|
|
567
567
|
},
|
|
568
568
|
// we register a global drag handler to track the current drag source element
|
|
569
569
|
view(t) {
|
|
@@ -595,15 +595,15 @@ const K = v.create({
|
|
|
595
595
|
transformPasted: (t) => {
|
|
596
596
|
if (!e)
|
|
597
597
|
return t;
|
|
598
|
-
const { types: n, attributeName: r } = this.options, i = (
|
|
599
|
-
const
|
|
600
|
-
return
|
|
598
|
+
const { types: n, attributeName: r } = this.options, i = (s) => {
|
|
599
|
+
const a = [];
|
|
600
|
+
return s.forEach((l) => {
|
|
601
601
|
if (l.isText) {
|
|
602
|
-
|
|
602
|
+
a.push(l);
|
|
603
603
|
return;
|
|
604
604
|
}
|
|
605
605
|
if (!n.includes(l.type.name)) {
|
|
606
|
-
|
|
606
|
+
a.push(l.copy(i(l.content)));
|
|
607
607
|
return;
|
|
608
608
|
}
|
|
609
609
|
const d = l.type.create(
|
|
@@ -614,8 +614,8 @@ const K = v.create({
|
|
|
614
614
|
i(l.content),
|
|
615
615
|
l.marks
|
|
616
616
|
);
|
|
617
|
-
|
|
618
|
-
}), _.from(
|
|
617
|
+
a.push(d);
|
|
618
|
+
}), _.from(a);
|
|
619
619
|
};
|
|
620
620
|
return e = !1, new I(
|
|
621
621
|
i(t.content),
|
|
@@ -628,47 +628,56 @@ const K = v.create({
|
|
|
628
628
|
];
|
|
629
629
|
}
|
|
630
630
|
});
|
|
631
|
-
class
|
|
631
|
+
class ve extends Error {
|
|
632
632
|
constructor(e) {
|
|
633
633
|
super(`Unreachable case: ${e}`);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
const
|
|
636
|
+
const Ct = /* @__PURE__ */ new Set([
|
|
637
637
|
"bold",
|
|
638
638
|
"italic",
|
|
639
639
|
"underline",
|
|
640
640
|
"strike",
|
|
641
641
|
"code"
|
|
642
|
-
]),
|
|
643
|
-
function
|
|
642
|
+
]), Mt = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
643
|
+
function nt(o, e) {
|
|
644
644
|
const t = [];
|
|
645
645
|
for (const [n, r] of Object.entries(o.styles))
|
|
646
|
-
|
|
647
|
-
return
|
|
646
|
+
Ct.has(n) ? t.push(e.mark(n)) : Mt.has(n) && t.push(e.mark(n, { color: r }));
|
|
647
|
+
return o.text.split(/(\n)/g).filter((n) => n.length > 0).map((n) => n === `
|
|
648
|
+
` ? e.nodes.hardBreak.create() : e.text(n, t));
|
|
648
649
|
}
|
|
649
650
|
function Ee(o, e) {
|
|
650
651
|
const t = e.marks.link.create({
|
|
651
652
|
href: o.href
|
|
652
653
|
});
|
|
653
|
-
return
|
|
654
|
+
return Bt(o.content, e).map((n) => {
|
|
655
|
+
if (n.type.name === "text")
|
|
656
|
+
return n.mark([...n.marks, t]);
|
|
657
|
+
if (n.type.name === "hardBreak")
|
|
658
|
+
return n;
|
|
659
|
+
throw new Error("unexpected node type");
|
|
660
|
+
});
|
|
654
661
|
}
|
|
655
|
-
function
|
|
662
|
+
function Bt(o, e) {
|
|
656
663
|
let t = [];
|
|
657
664
|
if (typeof o == "string")
|
|
658
|
-
return t.push(
|
|
665
|
+
return t.push(
|
|
666
|
+
...nt({ type: "text", text: o, styles: {} }, e)
|
|
667
|
+
), t;
|
|
659
668
|
for (const n of o)
|
|
660
|
-
t.push(
|
|
669
|
+
t.push(...nt(n, e));
|
|
661
670
|
return t;
|
|
662
671
|
}
|
|
663
|
-
function
|
|
672
|
+
function Tt(o, e) {
|
|
664
673
|
let t = [];
|
|
665
674
|
for (const n of o)
|
|
666
675
|
if (n.type === "link")
|
|
667
676
|
t.push(...Ee(n, e));
|
|
668
677
|
else if (n.type === "text")
|
|
669
|
-
t.push(...
|
|
678
|
+
t.push(...Bt([n], e));
|
|
670
679
|
else
|
|
671
|
-
throw new
|
|
680
|
+
throw new ve(n);
|
|
672
681
|
return t;
|
|
673
682
|
}
|
|
674
683
|
function z(o, e) {
|
|
@@ -685,42 +694,69 @@ function z(o, e) {
|
|
|
685
694
|
e.text(o.content)
|
|
686
695
|
);
|
|
687
696
|
else {
|
|
688
|
-
const
|
|
689
|
-
r = e.nodes[n].create(o.props,
|
|
697
|
+
const a = Tt(o.content, e);
|
|
698
|
+
r = e.nodes[n].create(o.props, a);
|
|
690
699
|
}
|
|
691
700
|
const i = [];
|
|
692
701
|
if (o.children)
|
|
693
|
-
for (const
|
|
694
|
-
i.push(z(
|
|
695
|
-
const
|
|
702
|
+
for (const a of o.children)
|
|
703
|
+
i.push(z(a, e));
|
|
704
|
+
const s = e.nodes.blockGroup.create({}, i);
|
|
696
705
|
return e.nodes.blockContainer.create(
|
|
697
706
|
{
|
|
698
707
|
id: t,
|
|
699
708
|
...o.props
|
|
700
709
|
},
|
|
701
|
-
i.length > 0 ? [r,
|
|
710
|
+
i.length > 0 ? [r, s] : r
|
|
702
711
|
);
|
|
703
712
|
}
|
|
704
713
|
function Ce(o) {
|
|
705
714
|
const e = [];
|
|
706
715
|
let t;
|
|
707
716
|
return o.content.forEach((n) => {
|
|
717
|
+
if (n.type.name === "hardBreak") {
|
|
718
|
+
t ? t.type === "text" ? t.text += `
|
|
719
|
+
` : t.type === "link" && (t.content[t.content.length - 1].text += `
|
|
720
|
+
`) : t = {
|
|
721
|
+
type: "text",
|
|
722
|
+
text: `
|
|
723
|
+
`,
|
|
724
|
+
styles: {}
|
|
725
|
+
};
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
708
728
|
const r = {};
|
|
709
729
|
let i;
|
|
710
|
-
for (const
|
|
711
|
-
if (
|
|
712
|
-
i =
|
|
713
|
-
else if (
|
|
714
|
-
r[
|
|
715
|
-
else if (
|
|
716
|
-
r[
|
|
730
|
+
for (const s of n.marks)
|
|
731
|
+
if (s.type.name === "link")
|
|
732
|
+
i = s;
|
|
733
|
+
else if (Ct.has(s.type.name))
|
|
734
|
+
r[s.type.name] = !0;
|
|
735
|
+
else if (Mt.has(s.type.name))
|
|
736
|
+
r[s.type.name] = s.attrs.color;
|
|
717
737
|
else
|
|
718
|
-
throw Error("Mark is of an unrecognized type: " +
|
|
719
|
-
|
|
738
|
+
throw Error("Mark is of an unrecognized type: " + s.type.name);
|
|
739
|
+
t ? t.type === "text" ? i ? (e.push(t), t = {
|
|
740
|
+
type: "link",
|
|
741
|
+
href: i.attrs.href,
|
|
742
|
+
content: [
|
|
743
|
+
{
|
|
744
|
+
type: "text",
|
|
745
|
+
text: n.textContent,
|
|
746
|
+
styles: r
|
|
747
|
+
}
|
|
748
|
+
]
|
|
749
|
+
}) : JSON.stringify(t.styles) === JSON.stringify(r) ? t.text += n.textContent : (e.push(t), t = {
|
|
750
|
+
type: "text",
|
|
751
|
+
text: n.textContent,
|
|
752
|
+
styles: r
|
|
753
|
+
}) : t.type === "link" && (i ? t.href === i.attrs.href ? JSON.stringify(
|
|
754
|
+
t.content[t.content.length - 1].styles
|
|
755
|
+
) === JSON.stringify(r) ? t.content[t.content.length - 1].text += n.textContent : t.content.push({
|
|
720
756
|
type: "text",
|
|
721
757
|
text: n.textContent,
|
|
722
758
|
styles: r
|
|
723
|
-
}) :
|
|
759
|
+
}) : (e.push(t), t = {
|
|
724
760
|
type: "link",
|
|
725
761
|
href: i.attrs.href,
|
|
726
762
|
content: [
|
|
@@ -730,12 +766,26 @@ function Ce(o) {
|
|
|
730
766
|
styles: r
|
|
731
767
|
}
|
|
732
768
|
]
|
|
733
|
-
}
|
|
769
|
+
}) : (e.push(t), t = {
|
|
734
770
|
type: "text",
|
|
735
771
|
text: n.textContent,
|
|
736
772
|
styles: r
|
|
737
|
-
})
|
|
738
|
-
|
|
773
|
+
})) : i ? t = {
|
|
774
|
+
type: "link",
|
|
775
|
+
href: i.attrs.href,
|
|
776
|
+
content: [
|
|
777
|
+
{
|
|
778
|
+
type: "text",
|
|
779
|
+
text: n.textContent,
|
|
780
|
+
styles: r
|
|
781
|
+
}
|
|
782
|
+
]
|
|
783
|
+
} : t = {
|
|
784
|
+
type: "text",
|
|
785
|
+
text: n.textContent,
|
|
786
|
+
styles: r
|
|
787
|
+
};
|
|
788
|
+
}), t && e.push(t), e;
|
|
739
789
|
}
|
|
740
790
|
function B(o, e, t) {
|
|
741
791
|
if (o.type.name !== "blockContainer")
|
|
@@ -748,7 +798,7 @@ function B(o, e, t) {
|
|
|
748
798
|
const r = g(o, 0);
|
|
749
799
|
let i = r.id;
|
|
750
800
|
i === null && (i = K.options.generateID());
|
|
751
|
-
const
|
|
801
|
+
const s = {};
|
|
752
802
|
for (const [c, u] of Object.entries({
|
|
753
803
|
...r.node.attrs,
|
|
754
804
|
...r.contentNode.attrs
|
|
@@ -758,10 +808,10 @@ function B(o, e, t) {
|
|
|
758
808
|
throw Error(
|
|
759
809
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
760
810
|
);
|
|
761
|
-
const
|
|
762
|
-
c in
|
|
811
|
+
const f = p.propSchema;
|
|
812
|
+
c in f ? s[c] = u : c !== "id" && !(c in A) && console.warn("Block has an unrecognized attribute: " + c);
|
|
763
813
|
}
|
|
764
|
-
const
|
|
814
|
+
const a = Ce(r.contentNode), l = [];
|
|
765
815
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
766
816
|
l.push(
|
|
767
817
|
B(r.node.lastChild.child(c), e, t)
|
|
@@ -769,8 +819,8 @@ function B(o, e, t) {
|
|
|
769
819
|
const d = {
|
|
770
820
|
id: i,
|
|
771
821
|
type: r.contentType.name,
|
|
772
|
-
props:
|
|
773
|
-
content:
|
|
822
|
+
props: s,
|
|
823
|
+
content: a,
|
|
774
824
|
children: l
|
|
775
825
|
};
|
|
776
826
|
return t == null || t.set(o, d), d;
|
|
@@ -784,33 +834,33 @@ function J(o, e) {
|
|
|
784
834
|
posBeforeNode: n
|
|
785
835
|
};
|
|
786
836
|
}
|
|
787
|
-
function
|
|
837
|
+
function wt(o, e, t = "before", n) {
|
|
788
838
|
const r = typeof e == "string" ? e : e.id, i = [];
|
|
789
839
|
for (const d of o)
|
|
790
840
|
i.push(z(d, n.schema));
|
|
791
|
-
let
|
|
792
|
-
const { node:
|
|
793
|
-
if (t === "before" && (
|
|
794
|
-
if (
|
|
795
|
-
|
|
841
|
+
let s = -1;
|
|
842
|
+
const { node: a, posBeforeNode: l } = J(r, n.state.doc);
|
|
843
|
+
if (t === "before" && (s = l), t === "after" && (s = l + a.nodeSize), t === "nested") {
|
|
844
|
+
if (a.childCount < 2) {
|
|
845
|
+
s = l + a.firstChild.nodeSize + 1;
|
|
796
846
|
const d = n.state.schema.nodes.blockGroup.create(
|
|
797
847
|
{},
|
|
798
848
|
i
|
|
799
849
|
);
|
|
800
850
|
n.view.dispatch(
|
|
801
|
-
n.state.tr.insert(
|
|
851
|
+
n.state.tr.insert(s, d)
|
|
802
852
|
);
|
|
803
853
|
return;
|
|
804
854
|
}
|
|
805
|
-
|
|
855
|
+
s = l + a.firstChild.nodeSize + 2;
|
|
806
856
|
}
|
|
807
|
-
n.view.dispatch(n.state.tr.insert(
|
|
857
|
+
n.view.dispatch(n.state.tr.insert(s, i));
|
|
808
858
|
}
|
|
809
859
|
function Me(o, e, t) {
|
|
810
860
|
const n = typeof o == "string" ? o : o.id, { posBeforeNode: r } = J(n, t.state.doc);
|
|
811
861
|
t.commands.BNUpdateBlock(r + 1, e);
|
|
812
862
|
}
|
|
813
|
-
function
|
|
863
|
+
function St(o, e) {
|
|
814
864
|
const t = new Set(
|
|
815
865
|
o.map(
|
|
816
866
|
(r) => typeof r == "string" ? r : r.id
|
|
@@ -823,10 +873,10 @@ function wt(o, e) {
|
|
|
823
873
|
if (r.type.name !== "blockContainer" || !t.has(r.attrs.id))
|
|
824
874
|
return !0;
|
|
825
875
|
t.delete(r.attrs.id);
|
|
826
|
-
const a = e.state.doc.nodeSize;
|
|
827
|
-
e.commands.BNDeleteBlock(i - n + 1);
|
|
828
876
|
const s = e.state.doc.nodeSize;
|
|
829
|
-
|
|
877
|
+
e.commands.BNDeleteBlock(i - n + 1);
|
|
878
|
+
const a = e.state.doc.nodeSize;
|
|
879
|
+
return n += s - a, !1;
|
|
830
880
|
}), t.size > 0) {
|
|
831
881
|
let r = [...t].join(`
|
|
832
882
|
`);
|
|
@@ -836,7 +886,7 @@ function wt(o, e) {
|
|
|
836
886
|
}
|
|
837
887
|
}
|
|
838
888
|
function Be(o, e, t) {
|
|
839
|
-
|
|
889
|
+
wt(e, o[0], "before", t), St(o, t);
|
|
840
890
|
}
|
|
841
891
|
function Te() {
|
|
842
892
|
const o = (e) => {
|
|
@@ -860,35 +910,35 @@ function we(o) {
|
|
|
860
910
|
...o.unorderedListItemBlockTypes
|
|
861
911
|
]), t = (n) => {
|
|
862
912
|
let r = n.children.length, i;
|
|
863
|
-
for (let
|
|
864
|
-
const l = n.children[
|
|
913
|
+
for (let s = 0; s < r; s++) {
|
|
914
|
+
const l = n.children[s].children[0], d = l.children[0], c = l.children.length === 2 ? l.children[1] : null, u = e.has(
|
|
865
915
|
d.properties.dataContentType
|
|
866
916
|
), p = u ? o.orderedListItemBlockTypes.has(
|
|
867
917
|
d.properties.dataContentType
|
|
868
918
|
) ? "ol" : "ul" : null;
|
|
869
919
|
if (c !== null && t(c), i && i.tagName !== p) {
|
|
870
920
|
n.children.splice(
|
|
871
|
-
|
|
921
|
+
s - i.children.length,
|
|
872
922
|
i.children.length,
|
|
873
923
|
i
|
|
874
924
|
);
|
|
875
|
-
const
|
|
876
|
-
|
|
925
|
+
const f = i.children.length - 1;
|
|
926
|
+
s -= f, r -= f, i = void 0;
|
|
877
927
|
}
|
|
878
928
|
if (u) {
|
|
879
929
|
i || (i = et(
|
|
880
930
|
document.createElement(p)
|
|
881
931
|
));
|
|
882
|
-
const
|
|
932
|
+
const f = et(
|
|
883
933
|
document.createElement("li")
|
|
884
934
|
);
|
|
885
|
-
|
|
935
|
+
f.children.push(d.children[0]), c !== null && f.children.push(...c.children), i.children.push(f);
|
|
886
936
|
} else if (c !== null) {
|
|
887
|
-
n.children.splice(
|
|
888
|
-
const
|
|
889
|
-
|
|
937
|
+
n.children.splice(s + 1, 0, ...c.children), n.children[s] = d.children[0];
|
|
938
|
+
const f = c.children.length;
|
|
939
|
+
s += f, r += f;
|
|
890
940
|
} else
|
|
891
|
-
n.children[
|
|
941
|
+
n.children[s] = d.children[0];
|
|
892
942
|
}
|
|
893
943
|
i && n.children.splice(
|
|
894
944
|
r - i.children.length,
|
|
@@ -898,40 +948,40 @@ function we(o) {
|
|
|
898
948
|
};
|
|
899
949
|
return t;
|
|
900
950
|
}
|
|
901
|
-
async function
|
|
951
|
+
async function xt(o, e) {
|
|
902
952
|
const t = document.createElement("div"), n = q.fromSchema(e);
|
|
903
953
|
for (const i of o) {
|
|
904
|
-
const
|
|
905
|
-
t.appendChild(
|
|
954
|
+
const s = z(i, e), a = n.serializeNode(s);
|
|
955
|
+
t.appendChild(a);
|
|
906
956
|
}
|
|
907
|
-
return (await
|
|
957
|
+
return (await V().use(lt, { fragment: !0 }).use(we, {
|
|
908
958
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
909
959
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
910
|
-
}).use(
|
|
960
|
+
}).use(dt).process(t.innerHTML)).value;
|
|
911
961
|
}
|
|
912
|
-
async function
|
|
962
|
+
async function It(o, e, t) {
|
|
913
963
|
const n = document.createElement("div");
|
|
914
964
|
n.innerHTML = o.trim();
|
|
915
|
-
const i =
|
|
916
|
-
for (let
|
|
917
|
-
|
|
918
|
-
return
|
|
965
|
+
const i = Gt.fromSchema(t).parse(n), s = [];
|
|
966
|
+
for (let a = 0; a < i.firstChild.childCount; a++)
|
|
967
|
+
s.push(B(i.firstChild.child(a), e));
|
|
968
|
+
return s;
|
|
919
969
|
}
|
|
920
970
|
async function Se(o, e) {
|
|
921
|
-
return (await
|
|
971
|
+
return (await V().use(lt, { fragment: !0 }).use(Te).use(qt).use(ct).use(Vt).process(await xt(o, e))).value;
|
|
922
972
|
}
|
|
923
973
|
async function xe(o, e, t) {
|
|
924
|
-
const n = await
|
|
925
|
-
return
|
|
974
|
+
const n = await V().use(Wt).use(ct).use(Yt).use(dt).process(o);
|
|
975
|
+
return It(n.value, e, t);
|
|
926
976
|
}
|
|
927
|
-
const Ie = "
|
|
977
|
+
const Ie = "_bnEditor_4vj2p_3", _e = "_bnRoot_4vj2p_20", Pe = "_defaultStyles_4vj2p_35", Le = "_dragPreview_4vj2p_68", P = {
|
|
928
978
|
bnEditor: Ie,
|
|
929
979
|
bnRoot: _e,
|
|
930
980
|
defaultStyles: Pe,
|
|
931
981
|
dragPreview: Le,
|
|
932
|
-
"collaboration-cursor__caret": "_collaboration-
|
|
933
|
-
"collaboration-cursor__label": "_collaboration-
|
|
934
|
-
},
|
|
982
|
+
"collaboration-cursor__caret": "_collaboration-cursor__caret_4vj2p_74",
|
|
983
|
+
"collaboration-cursor__label": "_collaboration-cursor__label_4vj2p_85"
|
|
984
|
+
}, Ne = v.create({
|
|
935
985
|
name: "blockBackgroundColor",
|
|
936
986
|
addGlobalAttributes() {
|
|
937
987
|
return [
|
|
@@ -961,7 +1011,7 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
961
1011
|
}
|
|
962
1012
|
};
|
|
963
1013
|
}
|
|
964
|
-
}),
|
|
1014
|
+
}), Ae = st.create({
|
|
965
1015
|
name: "backgroundColor",
|
|
966
1016
|
addAttributes() {
|
|
967
1017
|
return {
|
|
@@ -990,7 +1040,7 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
990
1040
|
setBackgroundColor: (o) => ({ commands: e }) => o !== "default" ? e.setMark(this.name, { color: o }) : e.unsetMark(this.name)
|
|
991
1041
|
};
|
|
992
1042
|
}
|
|
993
|
-
}),
|
|
1043
|
+
}), rt = new E("previous-blocks"), He = {
|
|
994
1044
|
// Numbered List Items
|
|
995
1045
|
index: "index",
|
|
996
1046
|
// Headings
|
|
@@ -1002,14 +1052,14 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1002
1052
|
}, Oe = () => {
|
|
1003
1053
|
let o;
|
|
1004
1054
|
return new C({
|
|
1005
|
-
key:
|
|
1055
|
+
key: rt,
|
|
1006
1056
|
view(e) {
|
|
1007
1057
|
return {
|
|
1008
1058
|
update: async (t, n) => {
|
|
1009
1059
|
var r;
|
|
1010
1060
|
((r = this.key) == null ? void 0 : r.getState(t.state).updatedBlocks.size) > 0 && (o = setTimeout(() => {
|
|
1011
1061
|
t.dispatch(
|
|
1012
|
-
t.state.tr.setMeta(
|
|
1062
|
+
t.state.tr.setMeta(rt, { clearUpdate: !0 })
|
|
1013
1063
|
);
|
|
1014
1064
|
}, 0));
|
|
1015
1065
|
},
|
|
@@ -1032,25 +1082,25 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1032
1082
|
apply(e, t, n, r) {
|
|
1033
1083
|
if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || n.doc.eq(r.doc))
|
|
1034
1084
|
return t;
|
|
1035
|
-
const i = {},
|
|
1036
|
-
|
|
1085
|
+
const i = {}, s = j(n.doc, (d) => d.attrs.id), a = new Map(
|
|
1086
|
+
s.map((d) => [d.node.attrs.id, d])
|
|
1037
1087
|
), l = j(r.doc, (d) => d.attrs.id);
|
|
1038
1088
|
for (let d of l) {
|
|
1039
|
-
const c =
|
|
1089
|
+
const c = a.get(d.node.attrs.id), u = c == null ? void 0 : c.node.firstChild, p = d.node.firstChild;
|
|
1040
1090
|
if (c && u && p) {
|
|
1041
|
-
const
|
|
1091
|
+
const f = {
|
|
1042
1092
|
index: p.attrs.index,
|
|
1043
1093
|
level: p.attrs.level,
|
|
1044
1094
|
type: p.type.name,
|
|
1045
1095
|
depth: r.doc.resolve(d.pos).depth
|
|
1046
1096
|
};
|
|
1047
|
-
let
|
|
1097
|
+
let m = {
|
|
1048
1098
|
index: u.attrs.index,
|
|
1049
1099
|
level: u.attrs.level,
|
|
1050
1100
|
type: u.type.name,
|
|
1051
1101
|
depth: n.doc.resolve(c.pos).depth
|
|
1052
1102
|
};
|
|
1053
|
-
i[d.node.attrs.id] =
|
|
1103
|
+
i[d.node.attrs.id] = m, e.getMeta("numberedListIndexing") && (d.node.attrs.id in t.prevTransactionOldBlockAttrs && (m = t.prevTransactionOldBlockAttrs[d.node.attrs.id]), f.type === "numberedListItem" && (m.index = f.index)), t.currentTransactionOldBlockAttrs[d.node.attrs.id] = m, JSON.stringify(m) !== JSON.stringify(f) && (m["depth-change"] = m.depth - f.depth, t.updatedBlocks.add(d.node.attrs.id));
|
|
1054
1104
|
}
|
|
1055
1105
|
}
|
|
1056
1106
|
return t.prevTransactionOldBlockAttrs = i, t;
|
|
@@ -1065,11 +1115,11 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1065
1115
|
return e.doc.descendants((r, i) => {
|
|
1066
1116
|
if (!r.attrs.id || !t.updatedBlocks.has(r.attrs.id))
|
|
1067
1117
|
return;
|
|
1068
|
-
const
|
|
1069
|
-
for (let [d, c] of Object.entries(
|
|
1070
|
-
|
|
1118
|
+
const s = t.currentTransactionOldBlockAttrs[r.attrs.id], a = {};
|
|
1119
|
+
for (let [d, c] of Object.entries(s))
|
|
1120
|
+
a["data-prev-" + He[d]] = c || "none";
|
|
1071
1121
|
const l = D.node(i, i + r.nodeSize, {
|
|
1072
|
-
...
|
|
1122
|
+
...a
|
|
1073
1123
|
});
|
|
1074
1124
|
n.push(l);
|
|
1075
1125
|
}), F.create(e.doc, n);
|
|
@@ -1148,15 +1198,15 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1148
1198
|
const r = g(t.doc, o);
|
|
1149
1199
|
if (r === void 0)
|
|
1150
1200
|
return !1;
|
|
1151
|
-
const { startPos: i, endPos:
|
|
1201
|
+
const { startPos: i, endPos: s, node: a, contentNode: l } = r;
|
|
1152
1202
|
if (n) {
|
|
1153
1203
|
if (e.children !== void 0) {
|
|
1154
1204
|
const d = [];
|
|
1155
1205
|
for (const c of e.children)
|
|
1156
1206
|
d.push(z(c, t.schema));
|
|
1157
|
-
|
|
1207
|
+
a.childCount === 2 ? t.tr.replace(
|
|
1158
1208
|
i + l.nodeSize + 1,
|
|
1159
|
-
|
|
1209
|
+
s - 1,
|
|
1160
1210
|
new I(_.from(d), 0, 0)
|
|
1161
1211
|
) : t.tr.insert(
|
|
1162
1212
|
i + l.nodeSize,
|
|
@@ -1165,7 +1215,7 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1165
1215
|
}
|
|
1166
1216
|
if (e.content !== void 0) {
|
|
1167
1217
|
let d = [];
|
|
1168
|
-
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d =
|
|
1218
|
+
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d = Tt(e.content, t.schema), t.tr.replace(
|
|
1169
1219
|
i + 1,
|
|
1170
1220
|
i + l.nodeSize - 1,
|
|
1171
1221
|
new I(_.from(d), 0, 0)
|
|
@@ -1179,7 +1229,7 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1179
1229
|
...e.props
|
|
1180
1230
|
}
|
|
1181
1231
|
), t.tr.setNodeMarkup(i - 1, void 0, {
|
|
1182
|
-
...
|
|
1232
|
+
...a.attrs,
|
|
1183
1233
|
...e.props
|
|
1184
1234
|
});
|
|
1185
1235
|
}
|
|
@@ -1209,18 +1259,18 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1209
1259
|
const i = g(
|
|
1210
1260
|
e.doc,
|
|
1211
1261
|
o + 1
|
|
1212
|
-
), { node:
|
|
1213
|
-
if (
|
|
1214
|
-
const
|
|
1215
|
-
l +
|
|
1216
|
-
),
|
|
1217
|
-
t && e.tr.lift(
|
|
1262
|
+
), { node: s, contentNode: a, startPos: l, endPos: d, depth: c } = i;
|
|
1263
|
+
if (s.childCount === 2) {
|
|
1264
|
+
const f = e.doc.resolve(
|
|
1265
|
+
l + a.nodeSize + 1
|
|
1266
|
+
), m = e.doc.resolve(d - 1), b = f.blockRange(m);
|
|
1267
|
+
t && e.tr.lift(b, c - 1);
|
|
1218
1268
|
}
|
|
1219
1269
|
let u = o - 1, p = g(e.doc, u);
|
|
1220
1270
|
for (; p.numChildBlocks > 0; )
|
|
1221
1271
|
if (u--, p = g(e.doc, u), p === void 0)
|
|
1222
1272
|
return !1;
|
|
1223
|
-
return t && (e.tr.deleteRange(l, l +
|
|
1273
|
+
return t && (e.tr.deleteRange(l, l + a.nodeSize), e.tr.insertText(a.textContent, u - 1), e.tr.setSelection(
|
|
1224
1274
|
new tt(e.doc.resolve(u - 1))
|
|
1225
1275
|
)), !0;
|
|
1226
1276
|
},
|
|
@@ -1230,24 +1280,24 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1230
1280
|
const r = g(t.doc, o);
|
|
1231
1281
|
if (r === void 0)
|
|
1232
1282
|
return !1;
|
|
1233
|
-
const { contentNode: i, contentType:
|
|
1234
|
-
return n && (t.tr.insert(
|
|
1235
|
-
|
|
1236
|
-
|
|
1283
|
+
const { contentNode: i, contentType: s, startPos: a, endPos: l, depth: d } = r, c = t.doc.cut(a + 1, o), u = t.doc.cut(o, l - 1), p = t.schema.nodes.blockContainer.createAndFill(), f = l + 1, m = f + 2;
|
|
1284
|
+
return n && (t.tr.insert(f, p), t.tr.replace(
|
|
1285
|
+
m,
|
|
1286
|
+
m + 1,
|
|
1237
1287
|
u.content.size > 0 ? new I(
|
|
1238
1288
|
_.from(u),
|
|
1239
1289
|
d + 2,
|
|
1240
1290
|
d + 2
|
|
1241
1291
|
) : void 0
|
|
1242
1292
|
), e && t.tr.setBlockType(
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
t.schema.node(
|
|
1293
|
+
m,
|
|
1294
|
+
m,
|
|
1295
|
+
t.schema.node(s).type,
|
|
1246
1296
|
i.attrs
|
|
1247
1297
|
), t.tr.setSelection(
|
|
1248
|
-
new tt(t.doc.resolve(
|
|
1298
|
+
new tt(t.doc.resolve(m))
|
|
1249
1299
|
), t.tr.replace(
|
|
1250
|
-
|
|
1300
|
+
a + 1,
|
|
1251
1301
|
l - 1,
|
|
1252
1302
|
c.content.size > 0 ? new I(
|
|
1253
1303
|
_.from(c),
|
|
@@ -1273,8 +1323,8 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1273
1323
|
const { contentType: r } = g(
|
|
1274
1324
|
n.doc,
|
|
1275
1325
|
n.selection.from
|
|
1276
|
-
), i = n.selection.$anchor.parentOffset === 0,
|
|
1277
|
-
return i && !
|
|
1326
|
+
), i = n.selection.$anchor.parentOffset === 0, s = r.name === "paragraph";
|
|
1327
|
+
return i && !s ? t.BNUpdateBlock(n.selection.from, {
|
|
1278
1328
|
type: "paragraph",
|
|
1279
1329
|
props: {}
|
|
1280
1330
|
}) : !1;
|
|
@@ -1287,8 +1337,8 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1287
1337
|
const { depth: r, startPos: i } = g(
|
|
1288
1338
|
n.doc,
|
|
1289
1339
|
n.selection.from
|
|
1290
|
-
),
|
|
1291
|
-
return !l &&
|
|
1340
|
+
), s = n.selection.$anchor.parentOffset === 0, a = n.selection.anchor === n.selection.head, l = i === 2, d = i - 1;
|
|
1341
|
+
return !l && s && a && r === 2 ? t.BNMergeBlocks(d) : !1;
|
|
1292
1342
|
})
|
|
1293
1343
|
]),
|
|
1294
1344
|
Enter: () => this.editor.commands.first(({ commands: t }) => [
|
|
@@ -1298,18 +1348,18 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1298
1348
|
const { node: r, depth: i } = g(
|
|
1299
1349
|
n.doc,
|
|
1300
1350
|
n.selection.from
|
|
1301
|
-
),
|
|
1302
|
-
return
|
|
1351
|
+
), s = n.selection.$anchor.parentOffset === 0, a = n.selection.anchor === n.selection.head, l = r.textContent.length === 0, d = i > 2;
|
|
1352
|
+
return s && a && l && d ? t.liftListItem("blockContainer") : !1;
|
|
1303
1353
|
}),
|
|
1304
1354
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1305
1355
|
// empty & at the start of the block.
|
|
1306
1356
|
() => t.command(({ state: n, chain: r }) => {
|
|
1307
|
-
const { node: i, endPos:
|
|
1357
|
+
const { node: i, endPos: s } = g(
|
|
1308
1358
|
n.doc,
|
|
1309
1359
|
n.selection.from
|
|
1310
|
-
),
|
|
1311
|
-
if (
|
|
1312
|
-
const c =
|
|
1360
|
+
), a = n.selection.$anchor.parentOffset === 0, l = n.selection.anchor === n.selection.head, d = i.textContent.length === 0;
|
|
1361
|
+
if (a && l && d) {
|
|
1362
|
+
const c = s + 1, u = c + 2;
|
|
1313
1363
|
return r().BNCreateBlock(c).setTextSelection(u).run(), !0;
|
|
1314
1364
|
}
|
|
1315
1365
|
return !1;
|
|
@@ -1416,7 +1466,7 @@ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14
|
|
|
1416
1466
|
})
|
|
1417
1467
|
];
|
|
1418
1468
|
}
|
|
1419
|
-
}), Ge =
|
|
1469
|
+
}), Ge = Ft(
|
|
1420
1470
|
(o) => o.type.name === "blockContainer"
|
|
1421
1471
|
);
|
|
1422
1472
|
function W() {
|
|
@@ -1457,11 +1507,11 @@ class je {
|
|
|
1457
1507
|
}, this.suggestionsMenu = r(this.getStaticParams()), document.addEventListener("scroll", this.handleScroll);
|
|
1458
1508
|
}
|
|
1459
1509
|
update(e, t) {
|
|
1460
|
-
const n = this.pluginKey.getState(t), r = this.pluginKey.getState(e.state), i = !n.active && r.active,
|
|
1461
|
-
!i && !
|
|
1510
|
+
const n = this.pluginKey.getState(t), r = this.pluginKey.getState(e.state), i = !n.active && r.active, s = n.active && !r.active, a = n.active && r.active;
|
|
1511
|
+
!i && !a && !s || (this.pluginState = s ? n : r, (s || !this.editor.isEditable) && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
|
|
1462
1512
|
"mousedown",
|
|
1463
1513
|
(l) => l.preventDefault()
|
|
1464
|
-
)),
|
|
1514
|
+
)), a && this.suggestionsMenu.render(this.getDynamicParams(), !1), i && this.editor.isEditable && (this.suggestionsMenu.render(this.getDynamicParams(), !0), this.suggestionsMenu.element.addEventListener(
|
|
1465
1515
|
"mousedown",
|
|
1466
1516
|
(l) => l.preventDefault()
|
|
1467
1517
|
)));
|
|
@@ -1496,16 +1546,16 @@ function qe({
|
|
|
1496
1546
|
}) {
|
|
1497
1547
|
if (t.length !== 1)
|
|
1498
1548
|
throw new Error("'char' should be a single character");
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1549
|
+
const s = (a) => {
|
|
1550
|
+
a.dispatch(a.state.tr.setMeta(o, { deactivate: !0 }));
|
|
1501
1551
|
};
|
|
1502
1552
|
return new C({
|
|
1503
1553
|
key: o,
|
|
1504
|
-
view: (
|
|
1554
|
+
view: (a) => new je({
|
|
1505
1555
|
editor: e,
|
|
1506
1556
|
pluginKey: o,
|
|
1507
1557
|
onSelectItem: (l) => {
|
|
1508
|
-
a
|
|
1558
|
+
s(a), r(l);
|
|
1509
1559
|
},
|
|
1510
1560
|
suggestionsMenuFactory: n
|
|
1511
1561
|
}),
|
|
@@ -1515,14 +1565,14 @@ function qe({
|
|
|
1515
1565
|
return W();
|
|
1516
1566
|
},
|
|
1517
1567
|
// Apply changes to the plugin state from an editor transaction.
|
|
1518
|
-
apply(
|
|
1519
|
-
var p,
|
|
1520
|
-
if (
|
|
1568
|
+
apply(a, l, d, c) {
|
|
1569
|
+
var p, f, m, b;
|
|
1570
|
+
if (a.getMeta("orderedListIndexing") !== void 0)
|
|
1521
1571
|
return l;
|
|
1522
|
-
if ((p =
|
|
1572
|
+
if ((p = a.getMeta(o)) != null && p.activate)
|
|
1523
1573
|
return {
|
|
1524
1574
|
active: !0,
|
|
1525
|
-
triggerCharacter: ((
|
|
1575
|
+
triggerCharacter: ((f = a.getMeta(o)) == null ? void 0 : f.triggerCharacter) || "",
|
|
1526
1576
|
queryStartPos: c.selection.from,
|
|
1527
1577
|
items: i(""),
|
|
1528
1578
|
keyboardHoveredItemIndex: 0,
|
|
@@ -1541,26 +1591,26 @@ function qe({
|
|
|
1541
1591
|
l.notFoundCount + (c.selection.from - d.selection.from)
|
|
1542
1592
|
)), // Highlighting text should hide the menu.
|
|
1543
1593
|
c.selection.from !== c.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
|
|
1544
|
-
(
|
|
1594
|
+
(m = a.getMeta(o)) != null && m.deactivate || // Certain mouse events should hide the menu.
|
|
1545
1595
|
// TODO: Change to global mousedown listener.
|
|
1546
|
-
|
|
1596
|
+
a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1547
1597
|
l.active && c.selection.from < l.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
|
|
1548
1598
|
// the menu.
|
|
1549
1599
|
u.notFoundCount > 3)
|
|
1550
1600
|
return W();
|
|
1551
|
-
if (((
|
|
1552
|
-
let
|
|
1553
|
-
|
|
1601
|
+
if (((b = a.getMeta(o)) == null ? void 0 : b.selectedItemIndexChanged) !== void 0) {
|
|
1602
|
+
let y = a.getMeta(o).selectedItemIndexChanged;
|
|
1603
|
+
y < 0 ? y = l.items.length - 1 : y >= l.items.length && (y = 0), u.keyboardHoveredItemIndex = y;
|
|
1554
1604
|
}
|
|
1555
1605
|
return u;
|
|
1556
1606
|
}
|
|
1557
1607
|
},
|
|
1558
1608
|
props: {
|
|
1559
|
-
handleKeyDown(
|
|
1560
|
-
const d = this.getState(
|
|
1609
|
+
handleKeyDown(a, l) {
|
|
1610
|
+
const d = this.getState(a.state).active;
|
|
1561
1611
|
if (l.key === t && !d)
|
|
1562
|
-
return
|
|
1563
|
-
|
|
1612
|
+
return a.dispatch(
|
|
1613
|
+
a.state.tr.insertText(t).scrollIntoView().setMeta(o, {
|
|
1564
1614
|
activate: !0,
|
|
1565
1615
|
triggerCharacter: t
|
|
1566
1616
|
})
|
|
@@ -1571,37 +1621,37 @@ function qe({
|
|
|
1571
1621
|
triggerCharacter: c,
|
|
1572
1622
|
queryStartPos: u,
|
|
1573
1623
|
items: p,
|
|
1574
|
-
keyboardHoveredItemIndex:
|
|
1575
|
-
} = o.getState(
|
|
1576
|
-
return l.key === "ArrowUp" ? (
|
|
1577
|
-
|
|
1578
|
-
selectedItemIndexChanged:
|
|
1624
|
+
keyboardHoveredItemIndex: f
|
|
1625
|
+
} = o.getState(a.state);
|
|
1626
|
+
return l.key === "ArrowUp" ? (a.dispatch(
|
|
1627
|
+
a.state.tr.setMeta(o, {
|
|
1628
|
+
selectedItemIndexChanged: f - 1
|
|
1579
1629
|
})
|
|
1580
|
-
), !0) : l.key === "ArrowDown" ? (
|
|
1581
|
-
|
|
1582
|
-
selectedItemIndexChanged:
|
|
1630
|
+
), !0) : l.key === "ArrowDown" ? (a.dispatch(
|
|
1631
|
+
a.state.tr.setMeta(o, {
|
|
1632
|
+
selectedItemIndexChanged: f + 1
|
|
1583
1633
|
})
|
|
1584
|
-
), !0) : l.key === "Enter" ? (a
|
|
1634
|
+
), !0) : l.key === "Enter" ? (s(a), e._tiptapEditor.chain().focus().deleteRange({
|
|
1585
1635
|
from: u - c.length,
|
|
1586
1636
|
to: e._tiptapEditor.state.selection.from
|
|
1587
1637
|
}).run(), r({
|
|
1588
|
-
item: p[
|
|
1638
|
+
item: p[f],
|
|
1589
1639
|
editor: e
|
|
1590
|
-
}), !0) : l.key === "Escape" ? (a
|
|
1640
|
+
}), !0) : l.key === "Escape" ? (s(a), !0) : !1;
|
|
1591
1641
|
},
|
|
1592
1642
|
// Hides menu in cases where mouse click does not cause an editor state change.
|
|
1593
|
-
handleClick(
|
|
1594
|
-
a
|
|
1643
|
+
handleClick(a) {
|
|
1644
|
+
s(a);
|
|
1595
1645
|
},
|
|
1596
1646
|
// Setup decorator on the currently active suggestion.
|
|
1597
|
-
decorations(
|
|
1598
|
-
const { active: l, decorationId: d, queryStartPos: c, triggerCharacter: u } = this.getState(
|
|
1647
|
+
decorations(a) {
|
|
1648
|
+
const { active: l, decorationId: d, queryStartPos: c, triggerCharacter: u } = this.getState(a);
|
|
1599
1649
|
if (!l)
|
|
1600
1650
|
return null;
|
|
1601
1651
|
if (u === "") {
|
|
1602
|
-
const p = Ge(
|
|
1652
|
+
const p = Ge(a.selection);
|
|
1603
1653
|
if (p)
|
|
1604
|
-
return F.create(
|
|
1654
|
+
return F.create(a.doc, [
|
|
1605
1655
|
D.node(
|
|
1606
1656
|
p.pos,
|
|
1607
1657
|
p.pos + p.node.nodeSize,
|
|
@@ -1613,7 +1663,7 @@ function qe({
|
|
|
1613
1663
|
)
|
|
1614
1664
|
]);
|
|
1615
1665
|
}
|
|
1616
|
-
return F.create(
|
|
1666
|
+
return F.create(a.doc, [
|
|
1617
1667
|
D.inline(
|
|
1618
1668
|
c - u.length,
|
|
1619
1669
|
c,
|
|
@@ -1662,8 +1712,8 @@ class L extends G {
|
|
|
1662
1712
|
super(t, n);
|
|
1663
1713
|
h(this, "nodes");
|
|
1664
1714
|
const r = t.node();
|
|
1665
|
-
this.nodes = [], t.doc.nodesBetween(t.pos, n.pos, (i,
|
|
1666
|
-
if (
|
|
1715
|
+
this.nodes = [], t.doc.nodesBetween(t.pos, n.pos, (i, s, a) => {
|
|
1716
|
+
if (a !== null && a.eq(r))
|
|
1667
1717
|
return this.nodes.push(i), !1;
|
|
1668
1718
|
});
|
|
1669
1719
|
}
|
|
@@ -1692,9 +1742,9 @@ class L extends G {
|
|
|
1692
1742
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
1693
1743
|
}
|
|
1694
1744
|
}
|
|
1695
|
-
const
|
|
1745
|
+
const Ye = ae.__serializeForClipboard;
|
|
1696
1746
|
let T;
|
|
1697
|
-
function
|
|
1747
|
+
function _t(o, e) {
|
|
1698
1748
|
var r;
|
|
1699
1749
|
if (!e.dom.isConnected)
|
|
1700
1750
|
return;
|
|
@@ -1709,8 +1759,8 @@ function It(o, e) {
|
|
|
1709
1759
|
return { node: n, id: n.getAttribute("data-id") };
|
|
1710
1760
|
}
|
|
1711
1761
|
}
|
|
1712
|
-
function
|
|
1713
|
-
let t =
|
|
1762
|
+
function Ve(o, e) {
|
|
1763
|
+
let t = _t(o, e);
|
|
1714
1764
|
if (t && t.node.nodeType === 1) {
|
|
1715
1765
|
const n = e.docView;
|
|
1716
1766
|
let r = n.nearestDesc(t.node, !0);
|
|
@@ -1720,34 +1770,34 @@ function Ye(o, e) {
|
|
|
1720
1770
|
}
|
|
1721
1771
|
function Ke(o, e) {
|
|
1722
1772
|
let t, n;
|
|
1723
|
-
const r = e.resolve(o.from).node().type.spec.group === "blockContent", i = e.resolve(o.to).node().type.spec.group === "blockContent",
|
|
1773
|
+
const r = e.resolve(o.from).node().type.spec.group === "blockContent", i = e.resolve(o.to).node().type.spec.group === "blockContent", s = Math.min(o.$anchor.depth, o.$head.depth);
|
|
1724
1774
|
if (r && i) {
|
|
1725
|
-
const
|
|
1726
|
-
t = e.resolve(
|
|
1775
|
+
const a = o.$from.start(s - 1), l = o.$to.end(s - 1);
|
|
1776
|
+
t = e.resolve(a - 1).pos, n = e.resolve(l + 1).pos;
|
|
1727
1777
|
} else
|
|
1728
1778
|
t = o.from, n = o.to;
|
|
1729
1779
|
return { from: t, to: n };
|
|
1730
1780
|
}
|
|
1731
|
-
function
|
|
1781
|
+
function it(o, e, t = e) {
|
|
1732
1782
|
e === t && (t += o.state.doc.resolve(e + 1).node().nodeSize);
|
|
1733
|
-
const n = o.domAtPos(e).node.cloneNode(!0), r = o.domAtPos(e).node, i = (c, u) => Array.prototype.indexOf.call(c.children, u),
|
|
1783
|
+
const n = o.domAtPos(e).node.cloneNode(!0), r = o.domAtPos(e).node, i = (c, u) => Array.prototype.indexOf.call(c.children, u), s = i(
|
|
1734
1784
|
r,
|
|
1735
1785
|
// Expects from position to be just before the first selected block.
|
|
1736
1786
|
o.domAtPos(e + 1).node.parentElement
|
|
1737
|
-
),
|
|
1787
|
+
), a = i(
|
|
1738
1788
|
r,
|
|
1739
1789
|
// Expects to position to be just after the last selected block.
|
|
1740
1790
|
o.domAtPos(t - 1).node.parentElement
|
|
1741
1791
|
);
|
|
1742
1792
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
1743
|
-
(c >
|
|
1744
|
-
|
|
1793
|
+
(c > a || c < s) && n.removeChild(n.children[c]);
|
|
1794
|
+
Pt(), T = n;
|
|
1745
1795
|
const d = o.dom.className.split(" ").filter(
|
|
1746
1796
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
1747
1797
|
).join(" ");
|
|
1748
1798
|
T.className = T.className + " " + P.dragPreview + " " + d, document.body.appendChild(T);
|
|
1749
1799
|
}
|
|
1750
|
-
function
|
|
1800
|
+
function Pt() {
|
|
1751
1801
|
T !== void 0 && (document.body.removeChild(T), T = void 0);
|
|
1752
1802
|
}
|
|
1753
1803
|
function Je(o, e) {
|
|
@@ -1758,16 +1808,16 @@ function Je(o, e) {
|
|
|
1758
1808
|
left: t.left + t.width / 2,
|
|
1759
1809
|
// take middle of editor
|
|
1760
1810
|
top: o.clientY
|
|
1761
|
-
}, r =
|
|
1811
|
+
}, r = Ve(n, e);
|
|
1762
1812
|
if (r != null) {
|
|
1763
|
-
const i = e.state.selection,
|
|
1813
|
+
const i = e.state.selection, s = e.state.doc, { from: a, to: l } = Ke(i, s), d = a <= r && r < l, c = i.$anchor.node() !== i.$head.node() || i instanceof L;
|
|
1764
1814
|
d && c ? (e.dispatch(
|
|
1765
|
-
e.state.tr.setSelection(L.create(
|
|
1766
|
-
),
|
|
1767
|
-
e.state.tr.setSelection(
|
|
1768
|
-
),
|
|
1769
|
-
let u = e.state.selection.content(), { dom: p, text:
|
|
1770
|
-
o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", p.innerHTML), o.dataTransfer.setData("text/plain",
|
|
1815
|
+
e.state.tr.setSelection(L.create(s, a, l))
|
|
1816
|
+
), it(e, a, l)) : (e.dispatch(
|
|
1817
|
+
e.state.tr.setSelection($t.create(e.state.doc, r))
|
|
1818
|
+
), it(e, r));
|
|
1819
|
+
let u = e.state.selection.content(), { dom: p, text: f } = Ye(e, u);
|
|
1820
|
+
o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", p.innerHTML), o.dataTransfer.setData("text/plain", f), o.dataTransfer.effectAllowed = "move", o.dataTransfer.setDragImage(T, 0, 0), e.dragging = { slice: u, move: !0 };
|
|
1771
1821
|
}
|
|
1772
1822
|
}
|
|
1773
1823
|
class Xe {
|
|
@@ -1813,7 +1863,7 @@ class Xe {
|
|
|
1813
1863
|
}
|
|
1814
1864
|
});
|
|
1815
1865
|
/**
|
|
1816
|
-
* If the event is outside
|
|
1866
|
+
* If the event is outside the editor contents,
|
|
1817
1867
|
* we dispatch a fake event, so that we can still drop the content
|
|
1818
1868
|
* when dragging / dropping to the side of the editor
|
|
1819
1869
|
*/
|
|
@@ -1837,24 +1887,35 @@ class Xe {
|
|
|
1837
1887
|
(t = this.blockMenu.element) != null && t.contains(e.target) || (this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide()), this.menuFrozen = !1);
|
|
1838
1888
|
});
|
|
1839
1889
|
h(this, "onMouseMove", (e) => {
|
|
1840
|
-
var
|
|
1890
|
+
var l, d, c;
|
|
1841
1891
|
if (this.menuFrozen)
|
|
1842
1892
|
return;
|
|
1843
|
-
const t = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
|
|
1893
|
+
const t = this.ttEditor.view.dom.firstChild.getBoundingClientRect(), n = this.ttEditor.view.dom.getBoundingClientRect();
|
|
1894
|
+
if (
|
|
1895
|
+
// Cursor is within the editor area
|
|
1896
|
+
e.clientX >= n.left && e.clientX <= n.right && e.clientY >= n.top && e.clientY <= n.bottom && // An element is hovered
|
|
1897
|
+
e && e.target && // Element is outside the editor
|
|
1898
|
+
this.ttEditor.view.dom !== e.target && !this.ttEditor.view.dom.contains(e.target) && // Element is outside the side menu
|
|
1899
|
+
this.blockMenu.element !== e.target && !((l = this.blockMenu.element) != null && l.contains(e.target))
|
|
1900
|
+
) {
|
|
1901
|
+
this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide());
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1844
1904
|
this.horizontalPosAnchor = t.x;
|
|
1845
|
-
const
|
|
1905
|
+
const i = {
|
|
1846
1906
|
left: t.left + t.width / 2,
|
|
1847
1907
|
// take middle of editor
|
|
1848
1908
|
top: e.clientY
|
|
1849
|
-
},
|
|
1850
|
-
if (!
|
|
1909
|
+
}, s = _t(i, this.ttEditor.view);
|
|
1910
|
+
if (!s || !this.editor.isEditable) {
|
|
1851
1911
|
this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide());
|
|
1852
1912
|
return;
|
|
1853
1913
|
}
|
|
1854
|
-
this.menuOpen && ((
|
|
1914
|
+
this.menuOpen && ((d = this.hoveredBlock) != null && d.hasAttribute("data-id")) && ((c = this.hoveredBlock) == null ? void 0 : c.getAttribute("data-id")) === s.id || (this.hoveredBlock = s.node, !s.node.firstChild) || this.editor.isEditable && (this.menuOpen ? this.blockMenu.render(this.getDynamicParams(), !1) : (this.menuOpen = !0, this.blockMenu.render(this.getDynamicParams(), !0)));
|
|
1855
1915
|
});
|
|
1856
1916
|
h(this, "onScroll", () => {
|
|
1857
|
-
|
|
1917
|
+
const e = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
|
|
1918
|
+
this.horizontalPosAnchor = e.x, this.menuOpen && this.blockMenu.render(this.getDynamicParams(), !1);
|
|
1858
1919
|
});
|
|
1859
1920
|
this.editor = t, this.ttEditor = e, this.horizontalPosAnchoredAtRoot = r, this.horizontalPosAnchor = this.ttEditor.view.dom.firstChild.getBoundingClientRect().x, this.blockMenu = n(this.getStaticParams()), document.body.addEventListener("drop", this.onDrop, !0), document.body.addEventListener("dragover", this.onDragOver), this.ttEditor.view.dom.addEventListener("dragstart", this.onDragStart), document.body.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("scroll", this.onScroll), document.body.addEventListener("mousedown", this.onMouseDown, !0), document.body.addEventListener("keydown", this.onKeyDown, !0);
|
|
1860
1921
|
}
|
|
@@ -1872,12 +1933,12 @@ class Xe {
|
|
|
1872
1933
|
const r = g(this.ttEditor.state.doc, n.pos);
|
|
1873
1934
|
if (r === void 0)
|
|
1874
1935
|
return;
|
|
1875
|
-
const { contentNode: i, endPos:
|
|
1936
|
+
const { contentNode: i, endPos: s } = r;
|
|
1876
1937
|
if (i.textContent.length !== 0) {
|
|
1877
|
-
const
|
|
1878
|
-
this.ttEditor.chain().BNCreateBlock(
|
|
1938
|
+
const a = s + 1, l = a + 2;
|
|
1939
|
+
this.ttEditor.chain().BNCreateBlock(a).BNUpdateBlock(l, { type: "paragraph", props: {} }).setTextSelection(l).run();
|
|
1879
1940
|
} else
|
|
1880
|
-
this.ttEditor.commands.setTextSelection(
|
|
1941
|
+
this.ttEditor.commands.setTextSelection(s);
|
|
1881
1942
|
this.ttEditor.view.focus(), this.ttEditor.view.dispatch(
|
|
1882
1943
|
this.ttEditor.view.state.tr.scrollIntoView().setMeta(X, {
|
|
1883
1944
|
// TODO import suggestion plugin key
|
|
@@ -1893,7 +1954,7 @@ class Xe {
|
|
|
1893
1954
|
blockDragStart: (e) => {
|
|
1894
1955
|
this.isDragging = !0, Je(e, this.ttEditor.view);
|
|
1895
1956
|
},
|
|
1896
|
-
blockDragEnd: () =>
|
|
1957
|
+
blockDragEnd: () => Pt(),
|
|
1897
1958
|
freezeMenu: () => {
|
|
1898
1959
|
this.menuFrozen = !0;
|
|
1899
1960
|
},
|
|
@@ -1957,8 +2018,8 @@ class to {
|
|
|
1957
2018
|
h(this, "toolbarIsOpen", !1);
|
|
1958
2019
|
h(this, "prevWasEditable", null);
|
|
1959
2020
|
h(this, "shouldShow", ({ view: e, state: t, from: n, to: r }) => {
|
|
1960
|
-
const { doc: i, selection:
|
|
1961
|
-
return !(!e.hasFocus() ||
|
|
2021
|
+
const { doc: i, selection: s } = t, { empty: a } = s, l = !i.textBetween(n, r).length && Rt(t.selection);
|
|
2022
|
+
return !(!e.hasFocus() || a || l);
|
|
1962
2023
|
});
|
|
1963
2024
|
h(this, "viewMousedownHandler", () => {
|
|
1964
2025
|
this.preventShow = !0;
|
|
@@ -1973,14 +2034,14 @@ class to {
|
|
|
1973
2034
|
setTimeout(() => this.update(this.ttEditor.view));
|
|
1974
2035
|
});
|
|
1975
2036
|
h(this, "blurHandler", ({ event: e }) => {
|
|
1976
|
-
var t
|
|
2037
|
+
var t;
|
|
1977
2038
|
if (this.preventHide) {
|
|
1978
2039
|
this.preventHide = !1;
|
|
1979
2040
|
return;
|
|
1980
2041
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
)) || this.toolbarIsOpen && (this.formattingToolbar.hide(), this.toolbarIsOpen = !1);
|
|
2042
|
+
// An element is clicked.
|
|
2043
|
+
e && e.relatedTarget && // Element is outside the toolbar.
|
|
2044
|
+
(this.formattingToolbar.element === e.relatedTarget || (t = this.formattingToolbar.element) != null && t.contains(e.relatedTarget)) || this.toolbarIsOpen && (this.formattingToolbar.hide(), this.toolbarIsOpen = !1);
|
|
1984
2045
|
});
|
|
1985
2046
|
h(this, "scrollHandler", () => {
|
|
1986
2047
|
this.toolbarIsOpen && this.formattingToolbar.render(this.getDynamicParams(), !1);
|
|
@@ -1989,21 +2050,18 @@ class to {
|
|
|
1989
2050
|
}
|
|
1990
2051
|
update(e, t) {
|
|
1991
2052
|
var p;
|
|
1992
|
-
const { state: n, composing: r } = e, { doc: i, selection:
|
|
1993
|
-
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r ||
|
|
2053
|
+
const { state: n, composing: r } = e, { doc: i, selection: s } = n, a = t && t.doc.eq(i) && t.selection.eq(s);
|
|
2054
|
+
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || a))
|
|
1994
2055
|
return;
|
|
1995
2056
|
this.prevWasEditable = this.editor.isEditable;
|
|
1996
|
-
const { ranges: l } =
|
|
2057
|
+
const { ranges: l } = s, d = Math.min(...l.map((f) => f.$from.pos)), c = Math.max(...l.map((f) => f.$to.pos)), u = (p = this.shouldShow) == null ? void 0 : p.call(this, {
|
|
1997
2058
|
view: e,
|
|
1998
2059
|
state: n,
|
|
1999
2060
|
from: d,
|
|
2000
2061
|
to: c
|
|
2001
2062
|
});
|
|
2002
2063
|
if (this.editor.isEditable && !this.toolbarIsOpen && !this.preventShow && (u || this.preventHide)) {
|
|
2003
|
-
this.formattingToolbar.render(this.getDynamicParams(), !0), this.toolbarIsOpen = !0
|
|
2004
|
-
"mousedown",
|
|
2005
|
-
(m) => m.preventDefault()
|
|
2006
|
-
);
|
|
2064
|
+
this.formattingToolbar.render(this.getDynamicParams(), !0), this.toolbarIsOpen = !0;
|
|
2007
2065
|
return;
|
|
2008
2066
|
}
|
|
2009
2067
|
if (this.toolbarIsOpen && !this.preventShow && (u || this.preventHide)) {
|
|
@@ -2011,10 +2069,7 @@ class to {
|
|
|
2011
2069
|
return;
|
|
2012
2070
|
}
|
|
2013
2071
|
if (this.toolbarIsOpen && !this.preventHide && (!u || this.preventShow || !this.editor.isEditable)) {
|
|
2014
|
-
this.formattingToolbar.hide(), this.toolbarIsOpen = !1
|
|
2015
|
-
"mousedown",
|
|
2016
|
-
(m) => m.preventDefault()
|
|
2017
|
-
);
|
|
2072
|
+
this.formattingToolbar.hide(), this.toolbarIsOpen = !1;
|
|
2018
2073
|
return;
|
|
2019
2074
|
}
|
|
2020
2075
|
}
|
|
@@ -2022,13 +2077,13 @@ class to {
|
|
|
2022
2077
|
this.view.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.view.dom.removeEventListener("mouseup", this.viewMouseupHandler), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), this.ttEditor.off("focus", this.focusHandler), this.ttEditor.off("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
|
|
2023
2078
|
}
|
|
2024
2079
|
getSelectionBoundingBox() {
|
|
2025
|
-
const { state: e } = this.ttEditor.view, { selection: t } = e, { ranges: n } = t, r = Math.min(...n.map((
|
|
2026
|
-
if (
|
|
2027
|
-
const
|
|
2028
|
-
if (
|
|
2029
|
-
return
|
|
2080
|
+
const { state: e } = this.ttEditor.view, { selection: t } = e, { ranges: n } = t, r = Math.min(...n.map((s) => s.$from.pos)), i = Math.max(...n.map((s) => s.$to.pos));
|
|
2081
|
+
if (zt(t)) {
|
|
2082
|
+
const s = this.ttEditor.view.nodeDOM(r);
|
|
2083
|
+
if (s)
|
|
2084
|
+
return s.getBoundingClientRect();
|
|
2030
2085
|
}
|
|
2031
|
-
return
|
|
2086
|
+
return at(this.ttEditor.view, r, i);
|
|
2032
2087
|
}
|
|
2033
2088
|
getStaticParams() {
|
|
2034
2089
|
return {
|
|
@@ -2079,18 +2134,26 @@ class ro {
|
|
|
2079
2134
|
const t = e.target, n = this.editor.view.posAtDOM(t, 0) + 1, r = this.editor.state.doc.resolve(
|
|
2080
2135
|
n
|
|
2081
2136
|
), i = r.marks();
|
|
2082
|
-
for (const
|
|
2083
|
-
if (
|
|
2084
|
-
this.mouseHoveredHyperlinkMark =
|
|
2137
|
+
for (const s of i)
|
|
2138
|
+
if (s.type.name === this.editor.schema.mark("link").type.name) {
|
|
2139
|
+
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = Q(
|
|
2085
2140
|
r,
|
|
2086
|
-
|
|
2087
|
-
|
|
2141
|
+
s.type,
|
|
2142
|
+
s.attrs
|
|
2088
2143
|
) || void 0;
|
|
2089
2144
|
break;
|
|
2090
2145
|
}
|
|
2091
2146
|
}
|
|
2092
2147
|
return this.startMenuUpdateTimer(), !1;
|
|
2093
2148
|
});
|
|
2149
|
+
h(this, "clickHandler", (e) => {
|
|
2150
|
+
var t;
|
|
2151
|
+
// Toolbar is open.
|
|
2152
|
+
this.hyperlinkMark && // An element is clicked.
|
|
2153
|
+
e && e.target && // Element is outside the editor.
|
|
2154
|
+
this.editor.view.dom !== e.target && !this.editor.view.dom.contains(e.target) && // Element is outside the toolbar.
|
|
2155
|
+
this.hyperlinkToolbar.element !== e.target && !((t = this.hyperlinkToolbar.element) != null && t.contains(e.target)) && this.hyperlinkToolbar.hide();
|
|
2156
|
+
});
|
|
2094
2157
|
h(this, "scrollHandler", () => {
|
|
2095
2158
|
this.hyperlinkMark !== void 0 && this.hyperlinkToolbar.render(this.getDynamicParams(), !1);
|
|
2096
2159
|
});
|
|
@@ -2098,7 +2161,7 @@ class ro {
|
|
|
2098
2161
|
this.menuUpdateTimer = setTimeout(() => {
|
|
2099
2162
|
this.update();
|
|
2100
2163
|
}, 250);
|
|
2101
|
-
}, this.stopMenuUpdateTimer = () => (this.menuUpdateTimer && (clearTimeout(this.menuUpdateTimer), this.menuUpdateTimer = void 0), !1), this.editor.view.dom.addEventListener("mouseover", this.mouseOverHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2164
|
+
}, this.stopMenuUpdateTimer = () => (this.menuUpdateTimer && (clearTimeout(this.menuUpdateTimer), this.menuUpdateTimer = void 0), !1), this.editor.view.dom.addEventListener("mouseover", this.mouseOverHandler), document.addEventListener("click", this.clickHandler, !0), document.addEventListener("scroll", this.scrollHandler);
|
|
2102
2165
|
}
|
|
2103
2166
|
update() {
|
|
2104
2167
|
var t, n, r, i;
|
|
@@ -2106,13 +2169,13 @@ class ro {
|
|
|
2106
2169
|
return;
|
|
2107
2170
|
const e = this.hyperlinkMark;
|
|
2108
2171
|
if (this.hyperlinkMark = void 0, this.hyperlinkMarkRange = void 0, this.keyboardHoveredHyperlinkMark = void 0, this.keyboardHoveredHyperlinkMarkRange = void 0, this.editor.state.selection.empty) {
|
|
2109
|
-
const
|
|
2110
|
-
for (const
|
|
2111
|
-
if (
|
|
2112
|
-
this.keyboardHoveredHyperlinkMark =
|
|
2172
|
+
const s = this.editor.state.selection.$from.marks();
|
|
2173
|
+
for (const a of s)
|
|
2174
|
+
if (a.type.name === this.editor.schema.mark("link").type.name) {
|
|
2175
|
+
this.keyboardHoveredHyperlinkMark = a, this.keyboardHoveredHyperlinkMarkRange = Q(
|
|
2113
2176
|
this.editor.state.selection.$from,
|
|
2114
|
-
|
|
2115
|
-
|
|
2177
|
+
a.type,
|
|
2178
|
+
a.attrs
|
|
2116
2179
|
) || void 0;
|
|
2117
2180
|
break;
|
|
2118
2181
|
}
|
|
@@ -2180,7 +2243,7 @@ class ro {
|
|
|
2180
2243
|
this.hyperlinkMarkRange.from,
|
|
2181
2244
|
this.hyperlinkMarkRange.to
|
|
2182
2245
|
),
|
|
2183
|
-
referenceRect:
|
|
2246
|
+
referenceRect: at(
|
|
2184
2247
|
this.editor.view,
|
|
2185
2248
|
this.hyperlinkMarkRange.from,
|
|
2186
2249
|
this.hyperlinkMarkRange.to
|
|
@@ -2194,7 +2257,7 @@ const io = (o, e) => new C({
|
|
|
2194
2257
|
editor: o,
|
|
2195
2258
|
hyperlinkToolbarFactory: e.hyperlinkToolbarFactory
|
|
2196
2259
|
})
|
|
2197
|
-
}), so =
|
|
2260
|
+
}), so = ut.extend({
|
|
2198
2261
|
priority: 500,
|
|
2199
2262
|
addProseMirrorPlugins() {
|
|
2200
2263
|
var o;
|
|
@@ -2227,20 +2290,20 @@ const io = (o, e) => new C({
|
|
|
2227
2290
|
key: ao,
|
|
2228
2291
|
props: {
|
|
2229
2292
|
decorations: (o) => {
|
|
2230
|
-
const { doc: e, selection: t } = o, n = X.getState(o), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t,
|
|
2293
|
+
const { doc: e, selection: t } = o, n = X.getState(o), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
|
|
2231
2294
|
if (r)
|
|
2232
|
-
return e.descendants((
|
|
2233
|
-
const d = i >= l && i <= l +
|
|
2295
|
+
return e.descendants((a, l) => {
|
|
2296
|
+
const d = i >= l && i <= l + a.nodeSize, c = !a.isLeaf && !a.childCount;
|
|
2234
2297
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
2235
2298
|
const u = [this.options.emptyNodeClass];
|
|
2236
2299
|
this.editor.isEmpty && u.push(this.options.emptyEditorClass), d && u.push(this.options.hasAnchorClass), (n == null ? void 0 : n.triggerCharacter) === "" && (n != null && n.active) && u.push(this.options.isFilterClass);
|
|
2237
|
-
const p = D.node(l, l +
|
|
2300
|
+
const p = D.node(l, l + a.nodeSize, {
|
|
2238
2301
|
class: u.join(" ")
|
|
2239
2302
|
});
|
|
2240
|
-
|
|
2303
|
+
s.push(p);
|
|
2241
2304
|
}
|
|
2242
2305
|
return this.options.includeChildren;
|
|
2243
|
-
}), F.create(e,
|
|
2306
|
+
}), F.create(e, s);
|
|
2244
2307
|
}
|
|
2245
2308
|
}
|
|
2246
2309
|
})
|
|
@@ -2477,7 +2540,7 @@ const uo = [
|
|
|
2477
2540
|
}
|
|
2478
2541
|
};
|
|
2479
2542
|
}
|
|
2480
|
-
}),
|
|
2543
|
+
}), fo = st.create({
|
|
2481
2544
|
name: "textColor",
|
|
2482
2545
|
addAttributes() {
|
|
2483
2546
|
return {
|
|
@@ -2506,7 +2569,7 @@ const uo = [
|
|
|
2506
2569
|
setTextColor: (o) => ({ commands: e }) => o !== "default" ? e.setMark(this.name, { color: o }) : e.unsetMark(this.name)
|
|
2507
2570
|
};
|
|
2508
2571
|
}
|
|
2509
|
-
}),
|
|
2572
|
+
}), mo = v.create({
|
|
2510
2573
|
name: "trailingNode",
|
|
2511
2574
|
addProseMirrorPlugins() {
|
|
2512
2575
|
const o = new E(this.name);
|
|
@@ -2514,8 +2577,8 @@ const uo = [
|
|
|
2514
2577
|
new C({
|
|
2515
2578
|
key: o,
|
|
2516
2579
|
appendTransaction: (e, t, n) => {
|
|
2517
|
-
const { doc: r, tr: i, schema:
|
|
2518
|
-
if (
|
|
2580
|
+
const { doc: r, tr: i, schema: s } = n, a = o.getState(n), l = r.content.size - 2, d = s.nodes.blockContainer, c = s.nodes.paragraph;
|
|
2581
|
+
if (a)
|
|
2519
2582
|
return i.insert(
|
|
2520
2583
|
l,
|
|
2521
2584
|
d.create(void 0, c.create())
|
|
@@ -2540,13 +2603,13 @@ const uo = [
|
|
|
2540
2603
|
}
|
|
2541
2604
|
}), go = (o) => {
|
|
2542
2605
|
const e = [
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2606
|
+
N.ClipboardTextSerializer,
|
|
2607
|
+
N.Commands,
|
|
2608
|
+
N.Editable,
|
|
2609
|
+
N.FocusEvents,
|
|
2610
|
+
N.Tabindex,
|
|
2548
2611
|
// DevTools,
|
|
2549
|
-
|
|
2612
|
+
te,
|
|
2550
2613
|
// DropCursor,
|
|
2551
2614
|
lo.configure({
|
|
2552
2615
|
emptyNodeClass: k.isEmpty,
|
|
@@ -2558,20 +2621,20 @@ const uo = [
|
|
|
2558
2621
|
K.configure({
|
|
2559
2622
|
types: ["blockContainer"]
|
|
2560
2623
|
}),
|
|
2561
|
-
|
|
2624
|
+
ee,
|
|
2562
2625
|
// Comments,
|
|
2563
2626
|
// basics:
|
|
2564
|
-
|
|
2627
|
+
ie,
|
|
2565
2628
|
// marks:
|
|
2566
|
-
Yt,
|
|
2567
2629
|
Kt,
|
|
2568
|
-
|
|
2630
|
+
Jt,
|
|
2569
2631
|
ne,
|
|
2570
|
-
|
|
2571
|
-
|
|
2632
|
+
re,
|
|
2633
|
+
se,
|
|
2634
|
+
fo,
|
|
2572
2635
|
po,
|
|
2573
|
-
Ne,
|
|
2574
2636
|
Ae,
|
|
2637
|
+
Ne,
|
|
2575
2638
|
ho,
|
|
2576
2639
|
// custom blocks:
|
|
2577
2640
|
...ze,
|
|
@@ -2579,14 +2642,14 @@ const uo = [
|
|
|
2579
2642
|
(t) => t.node.configure({ editor: o.editor })
|
|
2580
2643
|
),
|
|
2581
2644
|
$e,
|
|
2582
|
-
|
|
2645
|
+
Qt.configure({ width: 5, color: "#ddeeff" }),
|
|
2583
2646
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
2584
2647
|
// should be handled before Enter handlers in other components like splitListItem
|
|
2585
|
-
|
|
2648
|
+
mo
|
|
2586
2649
|
];
|
|
2587
2650
|
if (o.collaboration) {
|
|
2588
2651
|
e.push(
|
|
2589
|
-
|
|
2652
|
+
Xt.configure({
|
|
2590
2653
|
fragment: o.collaboration.fragment
|
|
2591
2654
|
})
|
|
2592
2655
|
);
|
|
@@ -2595,18 +2658,18 @@ const uo = [
|
|
|
2595
2658
|
r.classList.add(P["collaboration-cursor__caret"]), r.setAttribute("style", `border-color: ${n.color}`);
|
|
2596
2659
|
const i = document.createElement("span");
|
|
2597
2660
|
i.classList.add(P["collaboration-cursor__label"]), i.setAttribute("style", `background-color: ${n.color}`), i.insertBefore(document.createTextNode(n.name), null);
|
|
2598
|
-
const
|
|
2599
|
-
return r.insertBefore(
|
|
2661
|
+
const s = document.createTextNode(""), a = document.createTextNode("");
|
|
2662
|
+
return r.insertBefore(s, null), r.insertBefore(i, null), r.insertBefore(a, null), r;
|
|
2600
2663
|
};
|
|
2601
2664
|
e.push(
|
|
2602
|
-
|
|
2665
|
+
Zt.configure({
|
|
2603
2666
|
user: o.collaboration.user,
|
|
2604
2667
|
render: o.collaboration.renderCursor || t,
|
|
2605
2668
|
provider: o.collaboration.provider
|
|
2606
2669
|
})
|
|
2607
2670
|
);
|
|
2608
2671
|
} else
|
|
2609
|
-
e.push(
|
|
2672
|
+
e.push(oe);
|
|
2610
2673
|
return o.uiFactories.blockSideMenuFactory && e.push(
|
|
2611
2674
|
Qe().configure({
|
|
2612
2675
|
editor: o.editor,
|
|
@@ -2621,7 +2684,7 @@ const uo = [
|
|
|
2621
2684
|
so.configure({
|
|
2622
2685
|
hyperlinkToolbarFactory: o.uiFactories.hyperlinkToolbarFactory
|
|
2623
2686
|
})
|
|
2624
|
-
) : e.push(
|
|
2687
|
+
) : e.push(ut), o.uiFactories.slashMenuFactory && e.push(
|
|
2625
2688
|
We().configure({
|
|
2626
2689
|
editor: o.editor,
|
|
2627
2690
|
commands: o.slashCommands,
|
|
@@ -2638,7 +2701,7 @@ class Ko {
|
|
|
2638
2701
|
h(this, "_tiptapEditor");
|
|
2639
2702
|
h(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
2640
2703
|
h(this, "schema");
|
|
2641
|
-
var i,
|
|
2704
|
+
var i, s, a;
|
|
2642
2705
|
this.options = e;
|
|
2643
2706
|
const t = {
|
|
2644
2707
|
defaultStyles: !0,
|
|
@@ -2647,7 +2710,7 @@ class Ko {
|
|
|
2647
2710
|
// If BSchema is not specified, then options.blockSchema should also not
|
|
2648
2711
|
// be defined. Unfortunately, trying to implement these constraints seems
|
|
2649
2712
|
// to be a huge pain, hence the `as any` casts.
|
|
2650
|
-
blockSchema: e.blockSchema ||
|
|
2713
|
+
blockSchema: e.blockSchema || ke,
|
|
2651
2714
|
...e
|
|
2652
2715
|
}, n = go({
|
|
2653
2716
|
editor: this,
|
|
@@ -2680,7 +2743,7 @@ class Ko {
|
|
|
2680
2743
|
(l = t.onTextCursorPositionChange) == null || l.call(t, this);
|
|
2681
2744
|
},
|
|
2682
2745
|
editable: e.editable === void 0 ? !0 : e.editable,
|
|
2683
|
-
extensions: t.enableBlockNoteExtensions === !1 ? (i = t._tiptapOptions) == null ? void 0 : i.extensions : [...((
|
|
2746
|
+
extensions: t.enableBlockNoteExtensions === !1 ? (i = t._tiptapOptions) == null ? void 0 : i.extensions : [...((s = t._tiptapOptions) == null ? void 0 : s.extensions) || [], ...n],
|
|
2684
2747
|
editorProps: {
|
|
2685
2748
|
attributes: {
|
|
2686
2749
|
"data-theme": e.theme || "light",
|
|
@@ -2689,16 +2752,19 @@ class Ko {
|
|
|
2689
2752
|
P.bnEditor,
|
|
2690
2753
|
P.bnRoot,
|
|
2691
2754
|
t.defaultStyles ? P.defaultStyles : "",
|
|
2692
|
-
((
|
|
2755
|
+
((a = t.editorDOMAttributes) == null ? void 0 : a.class) || ""
|
|
2693
2756
|
].join(" ")
|
|
2694
2757
|
}
|
|
2695
2758
|
}
|
|
2696
2759
|
};
|
|
2697
|
-
t.parentElement && (r.element = t.parentElement), this._tiptapEditor = new
|
|
2760
|
+
t.parentElement && (r.element = t.parentElement), this._tiptapEditor = new Ut(r);
|
|
2698
2761
|
}
|
|
2699
2762
|
get domElement() {
|
|
2700
2763
|
return this._tiptapEditor.view.dom;
|
|
2701
2764
|
}
|
|
2765
|
+
isFocused() {
|
|
2766
|
+
return this._tiptapEditor.view.hasFocus();
|
|
2767
|
+
}
|
|
2702
2768
|
focus() {
|
|
2703
2769
|
this._tiptapEditor.view.focus();
|
|
2704
2770
|
}
|
|
@@ -2729,11 +2795,11 @@ class Ko {
|
|
|
2729
2795
|
const n = this.topLevelBlocks.slice();
|
|
2730
2796
|
t && n.reverse();
|
|
2731
2797
|
function r(i) {
|
|
2732
|
-
for (const
|
|
2733
|
-
if (!e(
|
|
2798
|
+
for (const s of i) {
|
|
2799
|
+
if (!e(s))
|
|
2734
2800
|
return !1;
|
|
2735
|
-
const
|
|
2736
|
-
if (!r(
|
|
2801
|
+
const a = t ? s.children.slice().reverse() : s.children;
|
|
2802
|
+
if (!r(a))
|
|
2737
2803
|
return !1;
|
|
2738
2804
|
}
|
|
2739
2805
|
return !0;
|
|
@@ -2755,13 +2821,13 @@ class Ko {
|
|
|
2755
2821
|
const { node: e, depth: t, startPos: n, endPos: r } = g(
|
|
2756
2822
|
this._tiptapEditor.state.doc,
|
|
2757
2823
|
this._tiptapEditor.state.selection.from
|
|
2758
|
-
), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1),
|
|
2759
|
-
let
|
|
2760
|
-
i > 0 && (
|
|
2824
|
+
), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), s = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
|
|
2825
|
+
let a;
|
|
2826
|
+
i > 0 && (a = this._tiptapEditor.state.doc.resolve(n - 2).node());
|
|
2761
2827
|
let l;
|
|
2762
|
-
return i <
|
|
2828
|
+
return i < s - 1 && (l = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
|
|
2763
2829
|
block: B(e, this.schema, this.blockCache),
|
|
2764
|
-
prevBlock:
|
|
2830
|
+
prevBlock: a === void 0 ? void 0 : B(a, this.schema, this.blockCache),
|
|
2765
2831
|
nextBlock: l === void 0 ? void 0 : B(l, this.schema, this.blockCache)
|
|
2766
2832
|
};
|
|
2767
2833
|
}
|
|
@@ -2772,12 +2838,12 @@ class Ko {
|
|
|
2772
2838
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
2773
2839
|
*/
|
|
2774
2840
|
setTextCursorPosition(e, t = "start") {
|
|
2775
|
-
const n = typeof e == "string" ? e : e.id, { posBeforeNode: r } = J(n, this._tiptapEditor.state.doc), { startPos: i, contentNode:
|
|
2841
|
+
const n = typeof e == "string" ? e : e.id, { posBeforeNode: r } = J(n, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = g(
|
|
2776
2842
|
this._tiptapEditor.state.doc,
|
|
2777
2843
|
r + 2
|
|
2778
2844
|
);
|
|
2779
2845
|
t === "start" ? this._tiptapEditor.commands.setTextSelection(i + 1) : this._tiptapEditor.commands.setTextSelection(
|
|
2780
|
-
i +
|
|
2846
|
+
i + s.nodeSize - 1
|
|
2781
2847
|
);
|
|
2782
2848
|
}
|
|
2783
2849
|
/**
|
|
@@ -2818,7 +2884,7 @@ class Ko {
|
|
|
2818
2884
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
2819
2885
|
*/
|
|
2820
2886
|
insertBlocks(e, t, n = "before") {
|
|
2821
|
-
|
|
2887
|
+
wt(e, t, n, this._tiptapEditor);
|
|
2822
2888
|
}
|
|
2823
2889
|
/**
|
|
2824
2890
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -2835,7 +2901,7 @@ class Ko {
|
|
|
2835
2901
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
2836
2902
|
*/
|
|
2837
2903
|
removeBlocks(e) {
|
|
2838
|
-
|
|
2904
|
+
St(e, this._tiptapEditor);
|
|
2839
2905
|
}
|
|
2840
2906
|
/**
|
|
2841
2907
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -2972,7 +3038,7 @@ class Ko {
|
|
|
2972
3038
|
* @returns The blocks, serialized as an HTML string.
|
|
2973
3039
|
*/
|
|
2974
3040
|
async blocksToHTML(e) {
|
|
2975
|
-
return
|
|
3041
|
+
return xt(e, this._tiptapEditor.schema);
|
|
2976
3042
|
}
|
|
2977
3043
|
/**
|
|
2978
3044
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -2982,7 +3048,7 @@ class Ko {
|
|
|
2982
3048
|
* @returns The blocks parsed from the HTML string.
|
|
2983
3049
|
*/
|
|
2984
3050
|
async HTMLToBlocks(e) {
|
|
2985
|
-
return
|
|
3051
|
+
return It(e, this.schema, this._tiptapEditor.schema);
|
|
2986
3052
|
}
|
|
2987
3053
|
/**
|
|
2988
3054
|
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
@@ -3018,16 +3084,16 @@ export {
|
|
|
3018
3084
|
S as BaseSlashMenuItem,
|
|
3019
3085
|
Ko as BlockNoteEditor,
|
|
3020
3086
|
$e as CustomBlockSerializerExtension,
|
|
3021
|
-
|
|
3087
|
+
Yo as blockStyles,
|
|
3022
3088
|
ot as camelToDataKebab,
|
|
3023
|
-
|
|
3089
|
+
Vo as createBlockSpec,
|
|
3024
3090
|
H as createTipTapBlock,
|
|
3025
|
-
|
|
3026
|
-
|
|
3091
|
+
ke as defaultBlockSchema,
|
|
3092
|
+
A as defaultProps,
|
|
3027
3093
|
uo as defaultSlashMenuItems,
|
|
3028
3094
|
go as getBlockNoteExtensions,
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3095
|
+
de as parse,
|
|
3096
|
+
le as propsToAttributes,
|
|
3097
|
+
ce as render
|
|
3032
3098
|
};
|
|
3033
3099
|
//# sourceMappingURL=blocknote.js.map
|