@blocknote/core 0.8.5 → 0.9.0
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 +614 -520
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +4 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +11 -15
- package/src/BlockNoteExtensions.ts +18 -5
- package/src/editor.module.css +0 -11
- package/src/extensions/Blocks/api/block.ts +55 -22
- package/src/extensions/Blocks/api/blockTypes.ts +22 -3
- package/src/extensions/Blocks/index.ts +7 -12
- package/src/extensions/Blocks/nodes/Block.module.css +1 -1
- package/src/extensions/Blocks/nodes/BlockContainer.ts +19 -18
- package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +20 -2
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +20 -2
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +20 -2
- package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +29 -6
- package/src/extensions/Blocks/nodes/BlockGroup.ts +19 -11
- package/src/index.ts +1 -0
- package/src/shared/utils.ts +4 -0
- package/types/src/BlockNoteEditor.d.ts +4 -10
- package/types/src/BlockNoteExtensions.d.ts +2 -0
- package/types/src/extensions/Blocks/api/block.d.ts +6 -1
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +15 -3
- package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +36 -4
- package/types/src/extensions/Blocks/index.d.ts +4 -1
- package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +9 -4
- package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockGroup.d.ts +9 -1
- package/types/src/index.d.ts +1 -0
- package/types/src/shared/utils.d.ts +1 -0
- package/src/node_modules/.vitest/results.json +0 -1
package/dist/blocknote.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
var Lt = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var u = (n, e, t) => (
|
|
4
|
-
import { Extension as
|
|
5
|
-
import { Bold as
|
|
6
|
-
import { Code as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { Dropcursor as
|
|
10
|
-
import { Gapcursor as
|
|
11
|
-
import { HardBreak as
|
|
2
|
+
var Pt = (n, e, t) => e in n ? Lt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var u = (n, e, t) => (Pt(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 Ot, getChangedRanges as Dt, findChildrenInRange as Rt, findChildren as tt, findParentNode as Vt, extensions as L, isTextSelection as zt, isNodeSelection as Ut, posToDOMRect as q, getMarkRange as et, Editor as Ft } from "@tiptap/core";
|
|
5
|
+
import { Bold as Gt } from "@tiptap/extension-bold";
|
|
6
|
+
import { Code as $t } from "@tiptap/extension-code";
|
|
7
|
+
import jt from "@tiptap/extension-collaboration";
|
|
8
|
+
import qt from "@tiptap/extension-collaboration-cursor";
|
|
9
|
+
import { Dropcursor as Wt } from "@tiptap/extension-dropcursor";
|
|
10
|
+
import { Gapcursor as Yt } from "@tiptap/extension-gapcursor";
|
|
11
|
+
import { HardBreak as Kt } from "@tiptap/extension-hard-break";
|
|
12
12
|
import { History as Jt } from "@tiptap/extension-history";
|
|
13
|
-
import { Italic as
|
|
14
|
-
import { Link as
|
|
15
|
-
import { Strike as
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Underline as
|
|
18
|
-
import { Slice as
|
|
19
|
-
import { PluginKey as
|
|
20
|
-
import { v4 as
|
|
21
|
-
import * as
|
|
22
|
-
import { Decoration as
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
13
|
+
import { Italic as Xt } from "@tiptap/extension-italic";
|
|
14
|
+
import { Link as Zt } from "@tiptap/extension-link";
|
|
15
|
+
import { Strike as Qt } from "@tiptap/extension-strike";
|
|
16
|
+
import { Text as te } from "@tiptap/extension-text";
|
|
17
|
+
import { Underline as ee } from "@tiptap/extension-underline";
|
|
18
|
+
import { Slice as x, Fragment as I, DOMSerializer as W, DOMParser as oe } from "prosemirror-model";
|
|
19
|
+
import { PluginKey as w, Plugin as S, TextSelection as ot, Selection as j, NodeSelection as ne } from "prosemirror-state";
|
|
20
|
+
import { v4 as re } from "uuid";
|
|
21
|
+
import * as ie from "prosemirror-view";
|
|
22
|
+
import { Decoration as V, DecorationSet as z } from "prosemirror-view";
|
|
23
|
+
import dt from "rehype-parse";
|
|
24
|
+
import se from "rehype-remark";
|
|
25
|
+
import ct from "rehype-stringify";
|
|
26
|
+
import ut from "remark-gfm";
|
|
27
|
+
import ae from "remark-parse";
|
|
28
|
+
import le from "remark-rehype";
|
|
29
|
+
import de from "remark-stringify";
|
|
30
30
|
import { unified as J } from "unified";
|
|
31
|
-
import { fromDom as
|
|
32
|
-
const
|
|
33
|
-
bnEditor:
|
|
34
|
-
bnRoot:
|
|
35
|
-
defaultStyles:
|
|
36
|
-
dragPreview:
|
|
37
|
-
"collaboration-cursor__caret": "_collaboration-
|
|
38
|
-
"collaboration-cursor__label": "_collaboration-
|
|
31
|
+
import { fromDom as nt } from "hast-util-from-dom";
|
|
32
|
+
const ce = "_bnEditor_1pmoa_3", ue = "_bnRoot_1pmoa_19", pe = "_defaultStyles_1pmoa_34", he = "_dragPreview_1pmoa_57", H = {
|
|
33
|
+
bnEditor: ce,
|
|
34
|
+
bnRoot: ue,
|
|
35
|
+
defaultStyles: pe,
|
|
36
|
+
dragPreview: he,
|
|
37
|
+
"collaboration-cursor__caret": "_collaboration-cursor__caret_1pmoa_63",
|
|
38
|
+
"collaboration-cursor__label": "_collaboration-cursor__label_1pmoa_74"
|
|
39
39
|
};
|
|
40
|
-
function
|
|
40
|
+
function k(n, e) {
|
|
41
41
|
const o = n.nodeSize - 2;
|
|
42
42
|
if (e <= 1)
|
|
43
43
|
for (e = 1 + 1; n.resolve(e).parent.type.name !== "blockContainer" && e < o; )
|
|
@@ -57,19 +57,19 @@ function g(n, e) {
|
|
|
57
57
|
break;
|
|
58
58
|
l -= 1, s = r.node(l);
|
|
59
59
|
}
|
|
60
|
-
const a = s.attrs.id, d = s.firstChild, c = d.type,
|
|
60
|
+
const a = s.attrs.id, d = s.firstChild, c = d.type, h = s.childCount === 2 ? s.lastChild.childCount : 0, p = r.start(l), f = r.end(l);
|
|
61
61
|
return {
|
|
62
62
|
id: a,
|
|
63
63
|
node: s,
|
|
64
64
|
contentNode: d,
|
|
65
65
|
contentType: c,
|
|
66
|
-
numChildBlocks:
|
|
67
|
-
startPos:
|
|
66
|
+
numChildBlocks: h,
|
|
67
|
+
startPos: p,
|
|
68
68
|
endPos: f,
|
|
69
69
|
depth: l
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const fe = T.create({
|
|
73
73
|
name: "blockBackgroundColor",
|
|
74
74
|
addGlobalAttributes() {
|
|
75
75
|
return [
|
|
@@ -90,7 +90,7 @@ const he = B.create({
|
|
|
90
90
|
addCommands() {
|
|
91
91
|
return {
|
|
92
92
|
setBlockBackgroundColor: (n, e) => ({ state: t, view: o }) => {
|
|
93
|
-
const r =
|
|
93
|
+
const r = k(t.doc, n);
|
|
94
94
|
return r === void 0 ? !1 : (t.tr.setNodeAttribute(
|
|
95
95
|
r.startPos - 1,
|
|
96
96
|
"backgroundColor",
|
|
@@ -99,7 +99,7 @@ const he = B.create({
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
}),
|
|
102
|
+
}), me = lt.create({
|
|
103
103
|
name: "backgroundColor",
|
|
104
104
|
addAttributes() {
|
|
105
105
|
return {
|
|
@@ -128,33 +128,44 @@ const he = B.create({
|
|
|
128
128
|
setBackgroundColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
}),
|
|
132
|
-
blockOuter:
|
|
133
|
-
block:
|
|
134
|
-
reactNodeViewRenderer:
|
|
135
|
-
blockContent:
|
|
136
|
-
blockGroup:
|
|
131
|
+
}), pt = "_blockOuter_7sok8_5", ht = "_block_7sok8_5", ft = "_reactNodeViewRenderer_7sok8_17", mt = "_blockContent_7sok8_22", kt = "_blockGroup_7sok8_42", gt = "_isEmpty_7sok8_240", bt = "_inlineContent_7sok8_240", yt = "_isFilter_7sok8_241", vt = "_hasAnchor_7sok8_263", y = {
|
|
132
|
+
blockOuter: pt,
|
|
133
|
+
block: ht,
|
|
134
|
+
reactNodeViewRenderer: ft,
|
|
135
|
+
blockContent: mt,
|
|
136
|
+
blockGroup: kt,
|
|
137
137
|
isEmpty: gt,
|
|
138
|
-
inlineContent:
|
|
139
|
-
isFilter:
|
|
140
|
-
hasAnchor:
|
|
141
|
-
},
|
|
138
|
+
inlineContent: bt,
|
|
139
|
+
isFilter: yt,
|
|
140
|
+
hasAnchor: vt
|
|
141
|
+
}, Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
142
142
|
__proto__: null,
|
|
143
|
-
block:
|
|
144
|
-
blockContent:
|
|
145
|
-
blockGroup:
|
|
146
|
-
blockOuter:
|
|
147
|
-
default:
|
|
148
|
-
hasAnchor:
|
|
149
|
-
inlineContent:
|
|
143
|
+
block: ht,
|
|
144
|
+
blockContent: mt,
|
|
145
|
+
blockGroup: kt,
|
|
146
|
+
blockOuter: pt,
|
|
147
|
+
default: y,
|
|
148
|
+
hasAnchor: vt,
|
|
149
|
+
inlineContent: bt,
|
|
150
150
|
isEmpty: gt,
|
|
151
|
-
isFilter:
|
|
152
|
-
reactNodeViewRenderer:
|
|
153
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
154
|
-
function
|
|
151
|
+
isFilter: yt,
|
|
152
|
+
reactNodeViewRenderer: ft
|
|
153
|
+
}, Symbol.toStringTag, { value: "Module" })), ke = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
|
154
|
+
function Yo(n) {
|
|
155
|
+
return ke() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
|
|
156
|
+
}
|
|
157
|
+
function v(...n) {
|
|
158
|
+
return n.filter((e) => e).join(" ");
|
|
159
|
+
}
|
|
160
|
+
class ge extends Error {
|
|
161
|
+
constructor(e) {
|
|
162
|
+
super(`Unreachable case: ${e}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function rt(n) {
|
|
155
166
|
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
156
167
|
}
|
|
157
|
-
function
|
|
168
|
+
function be(n) {
|
|
158
169
|
const e = {};
|
|
159
170
|
return Object.entries(n.propSchema).forEach(([t, o]) => {
|
|
160
171
|
e[t] = {
|
|
@@ -163,21 +174,21 @@ function me(n) {
|
|
|
163
174
|
// Props are displayed in kebab-case as HTML attributes. If a prop's
|
|
164
175
|
// value is the same as its default, we don't display an HTML
|
|
165
176
|
// attribute for it.
|
|
166
|
-
parseHTML: (r) => r.getAttribute(
|
|
177
|
+
parseHTML: (r) => r.getAttribute(rt(t)),
|
|
167
178
|
renderHTML: (r) => r[t] !== o.default ? {
|
|
168
|
-
[
|
|
179
|
+
[rt(t)]: r[t]
|
|
169
180
|
} : {}
|
|
170
181
|
};
|
|
171
182
|
}), e;
|
|
172
183
|
}
|
|
173
|
-
function
|
|
184
|
+
function ye(n) {
|
|
174
185
|
return [
|
|
175
186
|
{
|
|
176
187
|
tag: "div[data-content-type=" + n.type + "]"
|
|
177
188
|
}
|
|
178
189
|
];
|
|
179
190
|
}
|
|
180
|
-
function
|
|
191
|
+
function ve(n, e) {
|
|
181
192
|
const t = document.createElement("div");
|
|
182
193
|
t.setAttribute("data-content-type", n.type);
|
|
183
194
|
for (const [r, i] of Object.entries(e))
|
|
@@ -190,42 +201,57 @@ function ke(n, e) {
|
|
|
190
201
|
dom: t
|
|
191
202
|
};
|
|
192
203
|
}
|
|
193
|
-
function
|
|
204
|
+
function Ko(n) {
|
|
194
205
|
return {
|
|
195
|
-
node:
|
|
206
|
+
node: O({
|
|
196
207
|
name: n.type,
|
|
197
208
|
content: n.containsInlineContent ? "inline*" : "",
|
|
198
209
|
selectable: n.containsInlineContent,
|
|
199
|
-
addOptions() {
|
|
200
|
-
return {
|
|
201
|
-
editor: void 0
|
|
202
|
-
};
|
|
203
|
-
},
|
|
204
210
|
addAttributes() {
|
|
205
|
-
return
|
|
211
|
+
return be(n);
|
|
206
212
|
},
|
|
207
213
|
parseHTML() {
|
|
208
|
-
return
|
|
214
|
+
return ye(n);
|
|
209
215
|
},
|
|
210
216
|
renderHTML({ HTMLAttributes: t }) {
|
|
211
|
-
return
|
|
217
|
+
return ve(n, t);
|
|
212
218
|
},
|
|
213
219
|
addNodeView() {
|
|
214
220
|
return ({ HTMLAttributes: t, getPos: o }) => {
|
|
215
|
-
|
|
216
|
-
r
|
|
217
|
-
for (const [
|
|
218
|
-
|
|
219
|
-
|
|
221
|
+
var f, m;
|
|
222
|
+
const r = document.createElement("div"), i = ((f = this.options.domAttributes) == null ? void 0 : f.blockContent) || {};
|
|
223
|
+
for (const [g, b] of Object.entries(
|
|
224
|
+
i
|
|
225
|
+
))
|
|
226
|
+
g !== "class" && r.setAttribute(g, b);
|
|
227
|
+
r.className = v(
|
|
228
|
+
y.blockContent,
|
|
229
|
+
i.class
|
|
230
|
+
), r.setAttribute("data-content-type", n.type);
|
|
231
|
+
for (const [g, b] of Object.entries(t))
|
|
232
|
+
r.setAttribute(g, b);
|
|
233
|
+
const s = this.options.editor;
|
|
220
234
|
if (typeof o == "boolean")
|
|
221
235
|
throw new Error(
|
|
222
236
|
"Cannot find node position as getPos is a boolean, not a function."
|
|
223
237
|
);
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
238
|
+
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, h = s.getBlock(c);
|
|
239
|
+
if (h.type !== n.type)
|
|
226
240
|
throw new Error("Block type does not match");
|
|
227
|
-
const p = n.render(
|
|
228
|
-
|
|
241
|
+
const p = n.render(h, s);
|
|
242
|
+
if ("contentDOM" in p) {
|
|
243
|
+
const g = ((m = this.options.domAttributes) == null ? void 0 : m.inlineContent) || {};
|
|
244
|
+
for (const [b, C] of Object.entries(
|
|
245
|
+
g
|
|
246
|
+
))
|
|
247
|
+
b !== "class" && p.contentDOM.setAttribute(b, C);
|
|
248
|
+
p.contentDOM.className = v(
|
|
249
|
+
p.contentDOM.className,
|
|
250
|
+
y.inlineContent,
|
|
251
|
+
g.class
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
return r.appendChild(p.dom), "contentDOM" in p ? {
|
|
229
255
|
dom: r,
|
|
230
256
|
contentDOM: p.contentDOM
|
|
231
257
|
} : {
|
|
@@ -237,13 +263,13 @@ function qo(n) {
|
|
|
237
263
|
propSchema: n.propSchema
|
|
238
264
|
};
|
|
239
265
|
}
|
|
240
|
-
function
|
|
241
|
-
return
|
|
266
|
+
function O(n) {
|
|
267
|
+
return U.create({
|
|
242
268
|
...n,
|
|
243
269
|
group: "blockContent"
|
|
244
270
|
});
|
|
245
271
|
}
|
|
246
|
-
const
|
|
272
|
+
const Ce = O({
|
|
247
273
|
name: "heading",
|
|
248
274
|
content: "inline*",
|
|
249
275
|
addAttributes() {
|
|
@@ -260,7 +286,7 @@ const be = P({
|
|
|
260
286
|
},
|
|
261
287
|
addInputRules() {
|
|
262
288
|
return [
|
|
263
|
-
...["1", "2", "3"].map((n) => new
|
|
289
|
+
...["1", "2", "3"].map((n) => new K({
|
|
264
290
|
find: new RegExp(`^(#{${parseInt(n)}})\\s$`),
|
|
265
291
|
handler: ({ state: e, chain: t, range: o }) => {
|
|
266
292
|
t().BNUpdateBlock(e.selection.from, {
|
|
@@ -293,17 +319,31 @@ const be = P({
|
|
|
293
319
|
];
|
|
294
320
|
},
|
|
295
321
|
renderHTML({ node: n, HTMLAttributes: e }) {
|
|
322
|
+
var r, i;
|
|
323
|
+
const t = ((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {}, o = ((i = this.options.domAttributes) == null ? void 0 : i.inlineContent) || {};
|
|
296
324
|
return [
|
|
297
325
|
"div",
|
|
298
|
-
|
|
299
|
-
class:
|
|
326
|
+
A(e, {
|
|
327
|
+
class: v(
|
|
328
|
+
y.blockContent,
|
|
329
|
+
t.class
|
|
330
|
+
),
|
|
300
331
|
"data-content-type": this.name
|
|
301
332
|
}),
|
|
302
|
-
[
|
|
333
|
+
[
|
|
334
|
+
"h" + n.attrs.level,
|
|
335
|
+
{
|
|
336
|
+
class: v(
|
|
337
|
+
y.inlineContent,
|
|
338
|
+
o.class
|
|
339
|
+
)
|
|
340
|
+
},
|
|
341
|
+
0
|
|
342
|
+
]
|
|
303
343
|
];
|
|
304
344
|
}
|
|
305
|
-
}),
|
|
306
|
-
const { node: e, contentType: t } =
|
|
345
|
+
}), Ct = (n) => {
|
|
346
|
+
const { node: e, contentType: t } = k(
|
|
307
347
|
n.state.doc,
|
|
308
348
|
n.state.selection.from
|
|
309
349
|
), o = n.state.selection.anchor === n.state.selection.head;
|
|
@@ -321,13 +361,13 @@ const be = P({
|
|
|
321
361
|
s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
322
362
|
)
|
|
323
363
|
]);
|
|
324
|
-
},
|
|
364
|
+
}, Se = O({
|
|
325
365
|
name: "bulletListItem",
|
|
326
366
|
content: "inline*",
|
|
327
367
|
addInputRules() {
|
|
328
368
|
return [
|
|
329
369
|
// Creates an unordered list when starting with "-", "+", or "*".
|
|
330
|
-
new
|
|
370
|
+
new K({
|
|
331
371
|
find: new RegExp("^[-+*]\\s$"),
|
|
332
372
|
handler: ({ state: n, chain: e, range: t }) => {
|
|
333
373
|
e().BNUpdateBlock(n.selection.from, {
|
|
@@ -340,7 +380,7 @@ const be = P({
|
|
|
340
380
|
},
|
|
341
381
|
addKeyboardShortcuts() {
|
|
342
382
|
return {
|
|
343
|
-
Enter: () =>
|
|
383
|
+
Enter: () => Ct(this.editor)
|
|
344
384
|
};
|
|
345
385
|
},
|
|
346
386
|
parseHTML() {
|
|
@@ -371,17 +411,31 @@ const be = P({
|
|
|
371
411
|
];
|
|
372
412
|
},
|
|
373
413
|
renderHTML({ HTMLAttributes: n }) {
|
|
414
|
+
var o, r;
|
|
415
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
374
416
|
return [
|
|
375
417
|
"div",
|
|
376
|
-
|
|
377
|
-
class:
|
|
418
|
+
A(n, {
|
|
419
|
+
class: v(
|
|
420
|
+
y.blockContent,
|
|
421
|
+
e.class
|
|
422
|
+
),
|
|
378
423
|
"data-content-type": this.name
|
|
379
424
|
}),
|
|
380
|
-
[
|
|
425
|
+
[
|
|
426
|
+
"p",
|
|
427
|
+
{
|
|
428
|
+
class: v(
|
|
429
|
+
y.inlineContent,
|
|
430
|
+
t.class
|
|
431
|
+
)
|
|
432
|
+
},
|
|
433
|
+
0
|
|
434
|
+
]
|
|
381
435
|
];
|
|
382
436
|
}
|
|
383
|
-
}),
|
|
384
|
-
key:
|
|
437
|
+
}), we = new w("numbered-list-indexing"), Me = () => new S({
|
|
438
|
+
key: we,
|
|
385
439
|
appendTransaction: (n, e, t) => {
|
|
386
440
|
const o = t.tr;
|
|
387
441
|
o.setMeta("numberedListIndexing", !0);
|
|
@@ -389,18 +443,18 @@ const be = P({
|
|
|
389
443
|
return t.doc.descendants((i, s) => {
|
|
390
444
|
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
391
445
|
let l = "1";
|
|
392
|
-
const a = s === 1, d =
|
|
446
|
+
const a = s === 1, d = k(o.doc, s + 1);
|
|
393
447
|
if (d === void 0)
|
|
394
448
|
return;
|
|
395
449
|
if (!a) {
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
450
|
+
const p = k(o.doc, s - 2);
|
|
451
|
+
if (p === void 0)
|
|
398
452
|
return;
|
|
399
|
-
if (!(d.depth !==
|
|
400
|
-
const m =
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
403
|
-
l = (parseInt(
|
|
453
|
+
if (!(d.depth !== p.depth)) {
|
|
454
|
+
const m = p.contentNode;
|
|
455
|
+
if (p.contentType.name === "numberedListItem") {
|
|
456
|
+
const C = m.attrs.index;
|
|
457
|
+
l = (parseInt(C) + 1).toString();
|
|
404
458
|
}
|
|
405
459
|
}
|
|
406
460
|
}
|
|
@@ -410,7 +464,7 @@ const be = P({
|
|
|
410
464
|
}
|
|
411
465
|
}), r ? o : null;
|
|
412
466
|
}
|
|
413
|
-
}),
|
|
467
|
+
}), Ee = O({
|
|
414
468
|
name: "numberedListItem",
|
|
415
469
|
content: "inline*",
|
|
416
470
|
addAttributes() {
|
|
@@ -427,7 +481,7 @@ const be = P({
|
|
|
427
481
|
addInputRules() {
|
|
428
482
|
return [
|
|
429
483
|
// Creates an ordered list when starting with "1.".
|
|
430
|
-
new
|
|
484
|
+
new K({
|
|
431
485
|
find: new RegExp("^1\\.\\s$"),
|
|
432
486
|
handler: ({ state: n, chain: e, range: t }) => {
|
|
433
487
|
e().BNUpdateBlock(n.selection.from, {
|
|
@@ -440,11 +494,11 @@ const be = P({
|
|
|
440
494
|
},
|
|
441
495
|
addKeyboardShortcuts() {
|
|
442
496
|
return {
|
|
443
|
-
Enter: () =>
|
|
497
|
+
Enter: () => Ct(this.editor)
|
|
444
498
|
};
|
|
445
499
|
},
|
|
446
500
|
addProseMirrorPlugins() {
|
|
447
|
-
return [
|
|
501
|
+
return [Me()];
|
|
448
502
|
},
|
|
449
503
|
parseHTML() {
|
|
450
504
|
return [
|
|
@@ -476,18 +530,32 @@ const be = P({
|
|
|
476
530
|
];
|
|
477
531
|
},
|
|
478
532
|
renderHTML({ HTMLAttributes: n }) {
|
|
533
|
+
var o, r;
|
|
534
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
479
535
|
return [
|
|
480
536
|
"div",
|
|
481
|
-
|
|
482
|
-
class:
|
|
537
|
+
A(n, {
|
|
538
|
+
class: v(
|
|
539
|
+
y.blockContent,
|
|
540
|
+
e.class
|
|
541
|
+
),
|
|
483
542
|
"data-content-type": this.name
|
|
484
543
|
}),
|
|
485
544
|
// we use a <p> tag, because for <li> tags we'd need to add a <ul> parent for around siblings to be semantically correct,
|
|
486
545
|
// which would be quite cumbersome
|
|
487
|
-
[
|
|
546
|
+
[
|
|
547
|
+
"p",
|
|
548
|
+
{
|
|
549
|
+
class: v(
|
|
550
|
+
y.inlineContent,
|
|
551
|
+
t.class
|
|
552
|
+
)
|
|
553
|
+
},
|
|
554
|
+
0
|
|
555
|
+
]
|
|
488
556
|
];
|
|
489
557
|
}
|
|
490
|
-
}),
|
|
558
|
+
}), Be = O({
|
|
491
559
|
name: "paragraph",
|
|
492
560
|
content: "inline*",
|
|
493
561
|
parseHTML() {
|
|
@@ -500,16 +568,35 @@ const be = P({
|
|
|
500
568
|
];
|
|
501
569
|
},
|
|
502
570
|
renderHTML({ HTMLAttributes: n }) {
|
|
571
|
+
var o, r;
|
|
572
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
503
573
|
return [
|
|
504
574
|
"div",
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
575
|
+
A(
|
|
576
|
+
{
|
|
577
|
+
...e,
|
|
578
|
+
class: v(
|
|
579
|
+
y.blockContent,
|
|
580
|
+
e.class
|
|
581
|
+
),
|
|
582
|
+
"data-content-type": this.name
|
|
583
|
+
},
|
|
584
|
+
n
|
|
585
|
+
),
|
|
586
|
+
[
|
|
587
|
+
"p",
|
|
588
|
+
{
|
|
589
|
+
...t,
|
|
590
|
+
class: v(
|
|
591
|
+
y.inlineContent,
|
|
592
|
+
t.class
|
|
593
|
+
)
|
|
594
|
+
},
|
|
595
|
+
0
|
|
596
|
+
]
|
|
510
597
|
];
|
|
511
598
|
}
|
|
512
|
-
}),
|
|
599
|
+
}), P = {
|
|
513
600
|
backgroundColor: {
|
|
514
601
|
default: "transparent"
|
|
515
602
|
},
|
|
@@ -521,41 +608,41 @@ const be = P({
|
|
|
521
608
|
default: "left",
|
|
522
609
|
values: ["left", "center", "right", "justify"]
|
|
523
610
|
}
|
|
524
|
-
},
|
|
611
|
+
}, St = {
|
|
525
612
|
paragraph: {
|
|
526
|
-
propSchema:
|
|
527
|
-
node:
|
|
613
|
+
propSchema: P,
|
|
614
|
+
node: Be
|
|
528
615
|
},
|
|
529
616
|
heading: {
|
|
530
617
|
propSchema: {
|
|
531
|
-
...
|
|
618
|
+
...P,
|
|
532
619
|
level: { default: "1", values: ["1", "2", "3"] }
|
|
533
620
|
},
|
|
534
|
-
node:
|
|
621
|
+
node: Ce
|
|
535
622
|
},
|
|
536
623
|
bulletListItem: {
|
|
537
|
-
propSchema:
|
|
538
|
-
node:
|
|
624
|
+
propSchema: P,
|
|
625
|
+
node: Se
|
|
539
626
|
},
|
|
540
627
|
numberedListItem: {
|
|
541
|
-
propSchema:
|
|
542
|
-
node:
|
|
628
|
+
propSchema: P,
|
|
629
|
+
node: Ee
|
|
543
630
|
}
|
|
544
631
|
};
|
|
545
|
-
function
|
|
632
|
+
function Te(n, e = JSON.stringify) {
|
|
546
633
|
const t = {};
|
|
547
634
|
return n.filter((o) => {
|
|
548
635
|
const r = e(o);
|
|
549
636
|
return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
|
|
550
637
|
});
|
|
551
638
|
}
|
|
552
|
-
function
|
|
639
|
+
function xe(n) {
|
|
553
640
|
const e = n.filter(
|
|
554
641
|
(o, r) => n.indexOf(o) !== r
|
|
555
642
|
);
|
|
556
|
-
return
|
|
643
|
+
return Te(e);
|
|
557
644
|
}
|
|
558
|
-
const
|
|
645
|
+
const F = T.create({
|
|
559
646
|
name: "uniqueID",
|
|
560
647
|
// we’ll set a very high priority to make sure this runs first
|
|
561
648
|
// and is compatible with `appendTransaction` hooks of other extensions
|
|
@@ -564,7 +651,7 @@ const U = B.create({
|
|
|
564
651
|
return {
|
|
565
652
|
attributeName: "id",
|
|
566
653
|
types: [],
|
|
567
|
-
generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) :
|
|
654
|
+
generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) : re(),
|
|
568
655
|
filterTransaction: null
|
|
569
656
|
};
|
|
570
657
|
},
|
|
@@ -617,38 +704,38 @@ const U = B.create({
|
|
|
617
704
|
addProseMirrorPlugins() {
|
|
618
705
|
let n = null, e = !1;
|
|
619
706
|
return [
|
|
620
|
-
new
|
|
621
|
-
key: new
|
|
707
|
+
new S({
|
|
708
|
+
key: new w("uniqueID"),
|
|
622
709
|
appendTransaction: (t, o, r) => {
|
|
623
710
|
const i = t.some((m) => m.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && t.some((m) => {
|
|
624
|
-
var
|
|
625
|
-
return !(!((
|
|
711
|
+
var g, b;
|
|
712
|
+
return !(!((b = (g = this.options).filterTransaction) === null || b === void 0) && b.call(g, m));
|
|
626
713
|
});
|
|
627
714
|
if (!i || s)
|
|
628
715
|
return;
|
|
629
|
-
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options,
|
|
716
|
+
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h = Ot(
|
|
630
717
|
o.doc,
|
|
631
718
|
t
|
|
632
|
-
), { mapping:
|
|
633
|
-
if (
|
|
634
|
-
const
|
|
719
|
+
), { mapping: p } = h;
|
|
720
|
+
if (Dt(h).forEach(({ newRange: m }) => {
|
|
721
|
+
const g = Rt(
|
|
635
722
|
r.doc,
|
|
636
723
|
m,
|
|
637
|
-
(
|
|
638
|
-
),
|
|
639
|
-
|
|
640
|
-
var
|
|
641
|
-
const
|
|
642
|
-
if (
|
|
643
|
-
l.setNodeMarkup(
|
|
644
|
-
...
|
|
724
|
+
(M) => a.includes(M.type.name)
|
|
725
|
+
), b = g.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C = xe(b);
|
|
726
|
+
g.forEach(({ node: M, pos: R }) => {
|
|
727
|
+
var $;
|
|
728
|
+
const Q = ($ = l.doc.nodeAt(R)) === null || $ === void 0 ? void 0 : $.attrs[d];
|
|
729
|
+
if (Q === null) {
|
|
730
|
+
l.setNodeMarkup(R, void 0, {
|
|
731
|
+
...M.attrs,
|
|
645
732
|
[d]: c()
|
|
646
733
|
});
|
|
647
734
|
return;
|
|
648
735
|
}
|
|
649
|
-
const { deleted:
|
|
650
|
-
|
|
651
|
-
...
|
|
736
|
+
const { deleted: Nt } = p.invert().mapResult(R);
|
|
737
|
+
Nt && C.includes(Q) && l.setNodeMarkup(R, void 0, {
|
|
738
|
+
...M.attrs,
|
|
652
739
|
[d]: c()
|
|
653
740
|
});
|
|
654
741
|
});
|
|
@@ -707,7 +794,7 @@ const U = B.create({
|
|
|
707
794
|
l.push(d);
|
|
708
795
|
}), I.from(l);
|
|
709
796
|
};
|
|
710
|
-
return e = !1, new
|
|
797
|
+
return e = !1, new x(
|
|
711
798
|
i(t.content),
|
|
712
799
|
t.openStart,
|
|
713
800
|
t.openEnd
|
|
@@ -717,31 +804,25 @@ const U = B.create({
|
|
|
717
804
|
})
|
|
718
805
|
];
|
|
719
806
|
}
|
|
720
|
-
})
|
|
721
|
-
class Be extends Error {
|
|
722
|
-
constructor(e) {
|
|
723
|
-
super(`Unreachable case: ${e}`);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
const St = /* @__PURE__ */ new Set([
|
|
807
|
+
}), wt = /* @__PURE__ */ new Set([
|
|
727
808
|
"bold",
|
|
728
809
|
"italic",
|
|
729
810
|
"underline",
|
|
730
811
|
"strike",
|
|
731
812
|
"code"
|
|
732
|
-
]),
|
|
733
|
-
function
|
|
813
|
+
]), Mt = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
814
|
+
function it(n, e) {
|
|
734
815
|
const t = [];
|
|
735
816
|
for (const [o, r] of Object.entries(n.styles))
|
|
736
|
-
|
|
817
|
+
wt.has(o) ? t.push(e.mark(o)) : Mt.has(o) && t.push(e.mark(o, { color: r }));
|
|
737
818
|
return n.text.split(/(\n)/g).filter((o) => o.length > 0).map((o) => o === `
|
|
738
819
|
` ? e.nodes.hardBreak.create() : e.text(o, t));
|
|
739
820
|
}
|
|
740
|
-
function
|
|
821
|
+
function Ae(n, e) {
|
|
741
822
|
const t = e.marks.link.create({
|
|
742
823
|
href: n.href
|
|
743
824
|
});
|
|
744
|
-
return
|
|
825
|
+
return Et(n.content, e).map((o) => {
|
|
745
826
|
if (o.type.name === "text")
|
|
746
827
|
return o.mark([...o.marks, t]);
|
|
747
828
|
if (o.type.name === "hardBreak")
|
|
@@ -749,30 +830,30 @@ function Te(n, e) {
|
|
|
749
830
|
throw new Error("unexpected node type");
|
|
750
831
|
});
|
|
751
832
|
}
|
|
752
|
-
function
|
|
833
|
+
function Et(n, e) {
|
|
753
834
|
let t = [];
|
|
754
835
|
if (typeof n == "string")
|
|
755
836
|
return t.push(
|
|
756
|
-
...
|
|
837
|
+
...it({ type: "text", text: n, styles: {} }, e)
|
|
757
838
|
), t;
|
|
758
839
|
for (const o of n)
|
|
759
|
-
t.push(...
|
|
840
|
+
t.push(...it(o, e));
|
|
760
841
|
return t;
|
|
761
842
|
}
|
|
762
|
-
function
|
|
843
|
+
function Bt(n, e) {
|
|
763
844
|
let t = [];
|
|
764
845
|
for (const o of n)
|
|
765
846
|
if (o.type === "link")
|
|
766
|
-
t.push(...
|
|
847
|
+
t.push(...Ae(o, e));
|
|
767
848
|
else if (o.type === "text")
|
|
768
|
-
t.push(...
|
|
849
|
+
t.push(...Et([o], e));
|
|
769
850
|
else
|
|
770
|
-
throw new
|
|
851
|
+
throw new ge(o);
|
|
771
852
|
return t;
|
|
772
853
|
}
|
|
773
|
-
function
|
|
854
|
+
function D(n, e) {
|
|
774
855
|
let t = n.id;
|
|
775
|
-
t === void 0 && (t =
|
|
856
|
+
t === void 0 && (t = F.options.generateID());
|
|
776
857
|
let o = n.type;
|
|
777
858
|
o === void 0 && (o = "paragraph");
|
|
778
859
|
let r;
|
|
@@ -784,13 +865,13 @@ function O(n, e) {
|
|
|
784
865
|
e.text(n.content)
|
|
785
866
|
);
|
|
786
867
|
else {
|
|
787
|
-
const l =
|
|
868
|
+
const l = Bt(n.content, e);
|
|
788
869
|
r = e.nodes[o].create(n.props, l);
|
|
789
870
|
}
|
|
790
871
|
const i = [];
|
|
791
872
|
if (n.children)
|
|
792
873
|
for (const l of n.children)
|
|
793
|
-
i.push(
|
|
874
|
+
i.push(D(l, e));
|
|
794
875
|
const s = e.nodes.blockGroup.create({}, i);
|
|
795
876
|
return e.nodes.blockContainer.create(
|
|
796
877
|
{
|
|
@@ -800,7 +881,7 @@ function O(n, e) {
|
|
|
800
881
|
i.length > 0 ? [r, s] : r
|
|
801
882
|
);
|
|
802
883
|
}
|
|
803
|
-
function
|
|
884
|
+
function _e(n) {
|
|
804
885
|
const e = [];
|
|
805
886
|
let t;
|
|
806
887
|
return n.content.forEach((o) => {
|
|
@@ -820,9 +901,9 @@ function xe(n) {
|
|
|
820
901
|
for (const s of o.marks)
|
|
821
902
|
if (s.type.name === "link")
|
|
822
903
|
i = s;
|
|
823
|
-
else if (
|
|
904
|
+
else if (wt.has(s.type.name))
|
|
824
905
|
r[s.type.name] = !0;
|
|
825
|
-
else if (
|
|
906
|
+
else if (Mt.has(s.type.name))
|
|
826
907
|
r[s.type.name] = s.attrs.color;
|
|
827
908
|
else
|
|
828
909
|
throw Error("Mark is of an unrecognized type: " + s.type.name);
|
|
@@ -877,7 +958,7 @@ function xe(n) {
|
|
|
877
958
|
};
|
|
878
959
|
}), t && e.push(t), e;
|
|
879
960
|
}
|
|
880
|
-
function
|
|
961
|
+
function E(n, e, t) {
|
|
881
962
|
if (n.type.name !== "blockContainer")
|
|
882
963
|
throw Error(
|
|
883
964
|
"Node must be of type blockContainer, but is of type" + n.type.name + "."
|
|
@@ -885,26 +966,26 @@ function M(n, e, t) {
|
|
|
885
966
|
const o = t == null ? void 0 : t.get(n);
|
|
886
967
|
if (o)
|
|
887
968
|
return o;
|
|
888
|
-
const r =
|
|
969
|
+
const r = k(n, 0);
|
|
889
970
|
let i = r.id;
|
|
890
|
-
i === null && (i =
|
|
971
|
+
i === null && (i = F.options.generateID());
|
|
891
972
|
const s = {};
|
|
892
|
-
for (const [c,
|
|
973
|
+
for (const [c, h] of Object.entries({
|
|
893
974
|
...r.node.attrs,
|
|
894
975
|
...r.contentNode.attrs
|
|
895
976
|
})) {
|
|
896
|
-
const
|
|
897
|
-
if (!
|
|
977
|
+
const p = e[r.contentType.name];
|
|
978
|
+
if (!p)
|
|
898
979
|
throw Error(
|
|
899
980
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
900
981
|
);
|
|
901
|
-
const f =
|
|
902
|
-
c in f ? s[c] =
|
|
982
|
+
const f = p.propSchema;
|
|
983
|
+
c in f ? s[c] = h : c !== "id" && !(c in P) && console.warn("Block has an unrecognized attribute: " + c);
|
|
903
984
|
}
|
|
904
|
-
const l =
|
|
985
|
+
const l = _e(r.contentNode), a = [];
|
|
905
986
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
906
987
|
a.push(
|
|
907
|
-
|
|
988
|
+
E(r.node.lastChild.child(c), e, t)
|
|
908
989
|
);
|
|
909
990
|
const d = {
|
|
910
991
|
id: i,
|
|
@@ -915,7 +996,7 @@ function M(n, e, t) {
|
|
|
915
996
|
};
|
|
916
997
|
return t == null || t.set(n, d), d;
|
|
917
998
|
}
|
|
918
|
-
const
|
|
999
|
+
const st = new w("previous-blocks"), Ie = {
|
|
919
1000
|
// Numbered List Items
|
|
920
1001
|
index: "index",
|
|
921
1002
|
// Headings
|
|
@@ -924,17 +1005,17 @@ const it = new S("previous-blocks"), _e = {
|
|
|
924
1005
|
type: "type",
|
|
925
1006
|
depth: "depth",
|
|
926
1007
|
"depth-change": "depth-change"
|
|
927
|
-
},
|
|
1008
|
+
}, He = () => {
|
|
928
1009
|
let n;
|
|
929
|
-
return new
|
|
930
|
-
key:
|
|
1010
|
+
return new S({
|
|
1011
|
+
key: st,
|
|
931
1012
|
view(e) {
|
|
932
1013
|
return {
|
|
933
1014
|
update: async (t, o) => {
|
|
934
1015
|
var r;
|
|
935
1016
|
((r = this.key) == null ? void 0 : r.getState(t.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
936
1017
|
t.dispatch(
|
|
937
|
-
t.state.tr.setMeta(
|
|
1018
|
+
t.state.tr.setMeta(st, { clearUpdate: !0 })
|
|
938
1019
|
);
|
|
939
1020
|
}, 0));
|
|
940
1021
|
},
|
|
@@ -957,22 +1038,22 @@ const it = new S("previous-blocks"), _e = {
|
|
|
957
1038
|
apply(e, t, o, r) {
|
|
958
1039
|
if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || o.doc.eq(r.doc))
|
|
959
1040
|
return t;
|
|
960
|
-
const i = {}, s =
|
|
1041
|
+
const i = {}, s = tt(o.doc, (d) => d.attrs.id), l = new Map(
|
|
961
1042
|
s.map((d) => [d.node.attrs.id, d])
|
|
962
|
-
), a =
|
|
1043
|
+
), a = tt(r.doc, (d) => d.attrs.id);
|
|
963
1044
|
for (let d of a) {
|
|
964
|
-
const c = l.get(d.node.attrs.id),
|
|
965
|
-
if (c &&
|
|
1045
|
+
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, p = d.node.firstChild;
|
|
1046
|
+
if (c && h && p) {
|
|
966
1047
|
const f = {
|
|
967
|
-
index: h.attrs.index,
|
|
968
|
-
level: h.attrs.level,
|
|
969
|
-
type: h.type.name,
|
|
970
|
-
depth: r.doc.resolve(d.pos).depth
|
|
971
|
-
};
|
|
972
|
-
let m = {
|
|
973
1048
|
index: p.attrs.index,
|
|
974
1049
|
level: p.attrs.level,
|
|
975
1050
|
type: p.type.name,
|
|
1051
|
+
depth: r.doc.resolve(d.pos).depth
|
|
1052
|
+
};
|
|
1053
|
+
let m = {
|
|
1054
|
+
index: h.attrs.index,
|
|
1055
|
+
level: h.attrs.level,
|
|
1056
|
+
type: h.type.name,
|
|
976
1057
|
depth: o.doc.resolve(c.pos).depth
|
|
977
1058
|
};
|
|
978
1059
|
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));
|
|
@@ -992,8 +1073,8 @@ const it = new S("previous-blocks"), _e = {
|
|
|
992
1073
|
return;
|
|
993
1074
|
const s = t.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
|
|
994
1075
|
for (let [d, c] of Object.entries(s))
|
|
995
|
-
l["data-prev-" +
|
|
996
|
-
const a =
|
|
1076
|
+
l["data-prev-" + Ie[d]] = c || "none";
|
|
1077
|
+
const a = V.node(i, i + r.nodeSize, {
|
|
997
1078
|
...l
|
|
998
1079
|
});
|
|
999
1080
|
o.push(a);
|
|
@@ -1001,13 +1082,13 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1001
1082
|
}
|
|
1002
1083
|
}
|
|
1003
1084
|
});
|
|
1004
|
-
},
|
|
1085
|
+
}, Ne = {
|
|
1005
1086
|
blockColor: "data-block-color",
|
|
1006
1087
|
blockStyle: "data-block-style",
|
|
1007
1088
|
id: "data-id",
|
|
1008
1089
|
depth: "data-depth",
|
|
1009
1090
|
depthChange: "data-depth-change"
|
|
1010
|
-
},
|
|
1091
|
+
}, Le = U.create({
|
|
1011
1092
|
name: "blockContainer",
|
|
1012
1093
|
group: "blockContainer",
|
|
1013
1094
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -1015,11 +1096,6 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1015
1096
|
// Ensures content-specific keyboard handlers trigger first.
|
|
1016
1097
|
priority: 50,
|
|
1017
1098
|
defining: !0,
|
|
1018
|
-
addOptions() {
|
|
1019
|
-
return {
|
|
1020
|
-
HTMLAttributes: {}
|
|
1021
|
-
};
|
|
1022
|
-
},
|
|
1023
1099
|
parseHTML() {
|
|
1024
1100
|
return [
|
|
1025
1101
|
{
|
|
@@ -1028,7 +1104,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1028
1104
|
if (typeof n == "string")
|
|
1029
1105
|
return !1;
|
|
1030
1106
|
const e = {};
|
|
1031
|
-
for (let [t, o] of Object.entries(
|
|
1107
|
+
for (let [t, o] of Object.entries(Ne))
|
|
1032
1108
|
n.getAttribute(o) && (e[t] = n.getAttribute(o));
|
|
1033
1109
|
return n.getAttribute("data-node-type") === "blockContainer" ? e : !1;
|
|
1034
1110
|
}
|
|
@@ -1036,19 +1112,24 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1036
1112
|
];
|
|
1037
1113
|
},
|
|
1038
1114
|
renderHTML({ HTMLAttributes: n }) {
|
|
1115
|
+
var t;
|
|
1116
|
+
const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockContainer) || {};
|
|
1039
1117
|
return [
|
|
1040
1118
|
"div",
|
|
1041
|
-
|
|
1042
|
-
class:
|
|
1119
|
+
A(n, {
|
|
1120
|
+
class: y.blockOuter,
|
|
1043
1121
|
"data-node-type": "block-outer"
|
|
1044
1122
|
}),
|
|
1045
1123
|
[
|
|
1046
1124
|
"div",
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1125
|
+
A(
|
|
1126
|
+
{
|
|
1127
|
+
...e,
|
|
1128
|
+
class: v(y.block, e.class),
|
|
1129
|
+
"data-node-type": this.name
|
|
1130
|
+
},
|
|
1131
|
+
n
|
|
1132
|
+
),
|
|
1052
1133
|
0
|
|
1053
1134
|
]
|
|
1054
1135
|
];
|
|
@@ -1062,7 +1143,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1062
1143
|
},
|
|
1063
1144
|
// Deletes a block at a given position.
|
|
1064
1145
|
BNDeleteBlock: (n) => ({ state: e, dispatch: t }) => {
|
|
1065
|
-
const o =
|
|
1146
|
+
const o = k(e.doc, n);
|
|
1066
1147
|
if (o === void 0)
|
|
1067
1148
|
return !1;
|
|
1068
1149
|
const { startPos: r, endPos: i } = o;
|
|
@@ -1070,7 +1151,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1070
1151
|
},
|
|
1071
1152
|
// Updates a block at a given position.
|
|
1072
1153
|
BNUpdateBlock: (n, e) => ({ state: t, dispatch: o }) => {
|
|
1073
|
-
const r =
|
|
1154
|
+
const r = k(t.doc, n);
|
|
1074
1155
|
if (r === void 0)
|
|
1075
1156
|
return !1;
|
|
1076
1157
|
const { startPos: i, endPos: s, node: l, contentNode: a } = r;
|
|
@@ -1078,11 +1159,11 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1078
1159
|
if (e.children !== void 0) {
|
|
1079
1160
|
const d = [];
|
|
1080
1161
|
for (const c of e.children)
|
|
1081
|
-
d.push(
|
|
1162
|
+
d.push(D(c, t.schema));
|
|
1082
1163
|
l.childCount === 2 ? t.tr.replace(
|
|
1083
1164
|
i + a.nodeSize + 1,
|
|
1084
1165
|
s - 1,
|
|
1085
|
-
new
|
|
1166
|
+
new x(I.from(d), 0, 0)
|
|
1086
1167
|
) : t.tr.insert(
|
|
1087
1168
|
i + a.nodeSize,
|
|
1088
1169
|
t.schema.nodes.blockGroup.create({}, d)
|
|
@@ -1090,10 +1171,10 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1090
1171
|
}
|
|
1091
1172
|
if (e.content !== void 0) {
|
|
1092
1173
|
let d = [];
|
|
1093
|
-
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d =
|
|
1174
|
+
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d = Bt(e.content, t.schema), t.tr.replace(
|
|
1094
1175
|
i + 1,
|
|
1095
1176
|
i + a.nodeSize - 1,
|
|
1096
|
-
new
|
|
1177
|
+
new x(I.from(d), 0, 0)
|
|
1097
1178
|
);
|
|
1098
1179
|
}
|
|
1099
1180
|
t.tr.setNodeMarkup(
|
|
@@ -1131,42 +1212,42 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1131
1212
|
const o = e.doc.resolve(n + 1).node().type.name === "blockContainer", r = e.doc.resolve(n - 1).node().type.name === "blockContainer";
|
|
1132
1213
|
if (!o || !r)
|
|
1133
1214
|
return !1;
|
|
1134
|
-
const i =
|
|
1215
|
+
const i = k(
|
|
1135
1216
|
e.doc,
|
|
1136
1217
|
n + 1
|
|
1137
1218
|
), { node: s, contentNode: l, startPos: a, endPos: d, depth: c } = i;
|
|
1138
1219
|
if (s.childCount === 2) {
|
|
1139
1220
|
const f = e.doc.resolve(
|
|
1140
1221
|
a + l.nodeSize + 1
|
|
1141
|
-
), m = e.doc.resolve(d - 1),
|
|
1142
|
-
t && e.tr.lift(
|
|
1222
|
+
), m = e.doc.resolve(d - 1), g = f.blockRange(m);
|
|
1223
|
+
t && e.tr.lift(g, c - 1);
|
|
1143
1224
|
}
|
|
1144
|
-
let
|
|
1145
|
-
for (;
|
|
1146
|
-
if (
|
|
1225
|
+
let h = n - 1, p = k(e.doc, h);
|
|
1226
|
+
for (; p.numChildBlocks > 0; )
|
|
1227
|
+
if (h--, p = k(e.doc, h), p === void 0)
|
|
1147
1228
|
return !1;
|
|
1148
1229
|
return t && (t(
|
|
1149
1230
|
e.tr.deleteRange(a, a + l.nodeSize).replace(
|
|
1150
|
-
|
|
1231
|
+
h - 1,
|
|
1151
1232
|
a,
|
|
1152
|
-
new
|
|
1233
|
+
new x(l.content, 0, 0)
|
|
1153
1234
|
).scrollIntoView()
|
|
1154
1235
|
), e.tr.setSelection(
|
|
1155
|
-
new
|
|
1236
|
+
new ot(e.doc.resolve(h - 1))
|
|
1156
1237
|
)), !0;
|
|
1157
1238
|
},
|
|
1158
1239
|
// Splits a block at a given position. Content after the position is moved to a new block below, at the same
|
|
1159
1240
|
// nesting level.
|
|
1160
1241
|
BNSplitBlock: (n, e) => ({ state: t, dispatch: o }) => {
|
|
1161
|
-
const r =
|
|
1242
|
+
const r = k(t.doc, n);
|
|
1162
1243
|
if (r === void 0)
|
|
1163
1244
|
return !1;
|
|
1164
|
-
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n),
|
|
1165
|
-
return o && (t.tr.insert(f,
|
|
1245
|
+
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), h = t.doc.cut(n, a - 1), p = t.schema.nodes.blockContainer.createAndFill(), f = a + 1, m = f + 2;
|
|
1246
|
+
return o && (t.tr.insert(f, p), t.tr.replace(
|
|
1166
1247
|
m,
|
|
1167
1248
|
m + 1,
|
|
1168
|
-
|
|
1169
|
-
I.from(
|
|
1249
|
+
h.content.size > 0 ? new x(
|
|
1250
|
+
I.from(h),
|
|
1170
1251
|
d + 2,
|
|
1171
1252
|
d + 2
|
|
1172
1253
|
) : void 0
|
|
@@ -1176,11 +1257,11 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1176
1257
|
t.schema.node(s).type,
|
|
1177
1258
|
i.attrs
|
|
1178
1259
|
), t.tr.setSelection(
|
|
1179
|
-
new
|
|
1260
|
+
new ot(t.doc.resolve(m))
|
|
1180
1261
|
), t.tr.replace(
|
|
1181
1262
|
l + 1,
|
|
1182
1263
|
a - 1,
|
|
1183
|
-
c.content.size > 0 ? new
|
|
1264
|
+
c.content.size > 0 ? new x(
|
|
1184
1265
|
I.from(c),
|
|
1185
1266
|
d + 2,
|
|
1186
1267
|
d + 2
|
|
@@ -1190,7 +1271,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1190
1271
|
};
|
|
1191
1272
|
},
|
|
1192
1273
|
addProseMirrorPlugins() {
|
|
1193
|
-
return [
|
|
1274
|
+
return [He()];
|
|
1194
1275
|
},
|
|
1195
1276
|
addKeyboardShortcuts() {
|
|
1196
1277
|
return {
|
|
@@ -1201,7 +1282,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1201
1282
|
() => t.undoInputRule(),
|
|
1202
1283
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
1203
1284
|
() => t.command(({ state: o }) => {
|
|
1204
|
-
const { contentType: r } =
|
|
1285
|
+
const { contentType: r } = k(
|
|
1205
1286
|
o.doc,
|
|
1206
1287
|
o.selection.from
|
|
1207
1288
|
), i = o.selection.$anchor.parentOffset === 0, s = r.name === "paragraph";
|
|
@@ -1215,7 +1296,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1215
1296
|
// Merges block with the previous one if it isn't indented, isn't the first block in the doc, and the selection
|
|
1216
1297
|
// is at the start of the block.
|
|
1217
1298
|
() => t.command(({ state: o }) => {
|
|
1218
|
-
const { depth: r, startPos: i } =
|
|
1299
|
+
const { depth: r, startPos: i } = k(
|
|
1219
1300
|
o.doc,
|
|
1220
1301
|
o.selection.from
|
|
1221
1302
|
), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = i === 2, d = i - 1;
|
|
@@ -1226,7 +1307,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1226
1307
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
1227
1308
|
// of the block.
|
|
1228
1309
|
() => t.command(({ state: o }) => {
|
|
1229
|
-
const { node: r, depth: i } =
|
|
1310
|
+
const { node: r, depth: i } = k(
|
|
1230
1311
|
o.doc,
|
|
1231
1312
|
o.selection.from
|
|
1232
1313
|
), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = r.textContent.length === 0, d = i > 2;
|
|
@@ -1235,20 +1316,20 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1235
1316
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1236
1317
|
// empty & at the start of the block.
|
|
1237
1318
|
() => t.command(({ state: o, chain: r }) => {
|
|
1238
|
-
const { node: i, endPos: s } =
|
|
1319
|
+
const { node: i, endPos: s } = k(
|
|
1239
1320
|
o.doc,
|
|
1240
1321
|
o.selection.from
|
|
1241
1322
|
), l = o.selection.$anchor.parentOffset === 0, a = o.selection.anchor === o.selection.head, d = i.textContent.length === 0;
|
|
1242
1323
|
if (l && a && d) {
|
|
1243
|
-
const c = s + 1,
|
|
1244
|
-
return r().BNCreateBlock(c).setTextSelection(
|
|
1324
|
+
const c = s + 1, h = c + 2;
|
|
1325
|
+
return r().BNCreateBlock(c).setTextSelection(h).run(), !0;
|
|
1245
1326
|
}
|
|
1246
1327
|
return !1;
|
|
1247
1328
|
}),
|
|
1248
1329
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
1249
1330
|
// deletes the selection beforehand, if it's not empty.
|
|
1250
1331
|
() => t.command(({ state: o, chain: r }) => {
|
|
1251
|
-
const { node: i } =
|
|
1332
|
+
const { node: i } = k(
|
|
1252
1333
|
o.doc,
|
|
1253
1334
|
o.selection.from
|
|
1254
1335
|
);
|
|
@@ -1290,15 +1371,10 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1290
1371
|
})
|
|
1291
1372
|
};
|
|
1292
1373
|
}
|
|
1293
|
-
}),
|
|
1374
|
+
}), Pe = U.create({
|
|
1294
1375
|
name: "blockGroup",
|
|
1295
1376
|
group: "blockGroup",
|
|
1296
1377
|
content: "blockContainer+",
|
|
1297
|
-
addOptions() {
|
|
1298
|
-
return {
|
|
1299
|
-
HTMLAttributes: {}
|
|
1300
|
-
};
|
|
1301
|
-
},
|
|
1302
1378
|
parseHTML() {
|
|
1303
1379
|
return [
|
|
1304
1380
|
{
|
|
@@ -1308,26 +1384,31 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1308
1384
|
];
|
|
1309
1385
|
},
|
|
1310
1386
|
renderHTML({ HTMLAttributes: n }) {
|
|
1387
|
+
var t;
|
|
1388
|
+
const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockGroup) || {};
|
|
1311
1389
|
return [
|
|
1312
1390
|
"div",
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1391
|
+
A(
|
|
1392
|
+
{
|
|
1393
|
+
...e,
|
|
1394
|
+
class: v(
|
|
1395
|
+
y.blockGroup,
|
|
1396
|
+
e.class
|
|
1397
|
+
),
|
|
1398
|
+
"data-node-type": "blockGroup"
|
|
1399
|
+
},
|
|
1400
|
+
n
|
|
1401
|
+
),
|
|
1317
1402
|
0
|
|
1318
1403
|
];
|
|
1319
1404
|
}
|
|
1320
|
-
}),
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
})
|
|
1328
|
-
], Pe = (n) => {
|
|
1329
|
-
const e = q.fromSchema(n);
|
|
1330
|
-
return new q(
|
|
1405
|
+
}), Oe = U.create({
|
|
1406
|
+
name: "doc",
|
|
1407
|
+
topNode: !0,
|
|
1408
|
+
content: "blockGroup"
|
|
1409
|
+
}), De = (n) => {
|
|
1410
|
+
const e = W.fromSchema(n);
|
|
1411
|
+
return new W(
|
|
1331
1412
|
{
|
|
1332
1413
|
...e.nodes
|
|
1333
1414
|
// TODO: If a serializer is defined in the config for a custom block, it
|
|
@@ -1337,18 +1418,18 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1337
1418
|
},
|
|
1338
1419
|
e.marks
|
|
1339
1420
|
);
|
|
1340
|
-
},
|
|
1421
|
+
}, Re = T.create({
|
|
1341
1422
|
addProseMirrorPlugins() {
|
|
1342
1423
|
return [
|
|
1343
|
-
new
|
|
1424
|
+
new S({
|
|
1344
1425
|
props: {
|
|
1345
|
-
clipboardSerializer:
|
|
1426
|
+
clipboardSerializer: De(this.editor.schema)
|
|
1346
1427
|
}
|
|
1347
1428
|
})
|
|
1348
1429
|
];
|
|
1349
1430
|
}
|
|
1350
1431
|
});
|
|
1351
|
-
class
|
|
1432
|
+
class G {
|
|
1352
1433
|
constructor() {
|
|
1353
1434
|
u(this, "callbacks", {});
|
|
1354
1435
|
}
|
|
@@ -1367,10 +1448,10 @@ class F {
|
|
|
1367
1448
|
this.callbacks = {};
|
|
1368
1449
|
}
|
|
1369
1450
|
}
|
|
1370
|
-
const
|
|
1451
|
+
const Ve = Vt(
|
|
1371
1452
|
(n) => n.type.name === "blockContainer"
|
|
1372
1453
|
);
|
|
1373
|
-
class
|
|
1454
|
+
class ze {
|
|
1374
1455
|
constructor(e, t, o = () => {
|
|
1375
1456
|
}) {
|
|
1376
1457
|
u(this, "suggestionsMenuState");
|
|
@@ -1385,7 +1466,7 @@ class Re {
|
|
|
1385
1466
|
this.suggestionsMenuState.referencePos = t.getBoundingClientRect(), this.updateSuggestionsMenu();
|
|
1386
1467
|
}
|
|
1387
1468
|
});
|
|
1388
|
-
this.editor = e, this.pluginKey = t, this.pluginState =
|
|
1469
|
+
this.editor = e, this.pluginKey = t, this.pluginState = Y(), this.updateSuggestionsMenu = () => {
|
|
1389
1470
|
if (!this.suggestionsMenuState)
|
|
1390
1471
|
throw new Error("Attempting to update uninitialized suggestions menu");
|
|
1391
1472
|
o(this.suggestionsMenuState);
|
|
@@ -1413,7 +1494,7 @@ class Re {
|
|
|
1413
1494
|
document.removeEventListener("scroll", this.handleScroll);
|
|
1414
1495
|
}
|
|
1415
1496
|
}
|
|
1416
|
-
function
|
|
1497
|
+
function Y() {
|
|
1417
1498
|
return {
|
|
1418
1499
|
active: !1,
|
|
1419
1500
|
triggerCharacter: void 0,
|
|
@@ -1424,7 +1505,7 @@ function W() {
|
|
|
1424
1505
|
decorationId: void 0
|
|
1425
1506
|
};
|
|
1426
1507
|
}
|
|
1427
|
-
const
|
|
1508
|
+
const Ue = (n, e, t, o, r = () => [], i = () => {
|
|
1428
1509
|
}) => {
|
|
1429
1510
|
if (o.length !== 1)
|
|
1430
1511
|
throw new Error("'char' should be a single character");
|
|
@@ -1433,9 +1514,9 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1433
1514
|
a.dispatch(a.state.tr.setMeta(t, { deactivate: !0 }));
|
|
1434
1515
|
};
|
|
1435
1516
|
return {
|
|
1436
|
-
plugin: new
|
|
1517
|
+
plugin: new S({
|
|
1437
1518
|
key: t,
|
|
1438
|
-
view: () => (s = new
|
|
1519
|
+
view: () => (s = new ze(
|
|
1439
1520
|
n,
|
|
1440
1521
|
t,
|
|
1441
1522
|
e
|
|
@@ -1443,18 +1524,18 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1443
1524
|
state: {
|
|
1444
1525
|
// Initialize the plugin's internal state.
|
|
1445
1526
|
init() {
|
|
1446
|
-
return
|
|
1527
|
+
return Y();
|
|
1447
1528
|
},
|
|
1448
1529
|
// Apply changes to the plugin state from an editor transaction.
|
|
1449
|
-
apply(a, d, c,
|
|
1450
|
-
var f, m,
|
|
1530
|
+
apply(a, d, c, h) {
|
|
1531
|
+
var f, m, g, b;
|
|
1451
1532
|
if (a.getMeta("orderedListIndexing") !== void 0)
|
|
1452
1533
|
return d;
|
|
1453
1534
|
if ((f = a.getMeta(t)) != null && f.activate)
|
|
1454
1535
|
return {
|
|
1455
1536
|
active: !0,
|
|
1456
1537
|
triggerCharacter: ((m = a.getMeta(t)) == null ? void 0 : m.triggerCharacter) || "",
|
|
1457
|
-
queryStartPos:
|
|
1538
|
+
queryStartPos: h.selection.from,
|
|
1458
1539
|
items: r(""),
|
|
1459
1540
|
keyboardHoveredItemIndex: 0,
|
|
1460
1541
|
// TODO: Maybe should be 1 if the menu has no possible items? Probably redundant since a menu with no items
|
|
@@ -1464,30 +1545,30 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1464
1545
|
};
|
|
1465
1546
|
if (!d.active)
|
|
1466
1547
|
return d;
|
|
1467
|
-
const
|
|
1468
|
-
if (
|
|
1469
|
-
|
|
1548
|
+
const p = { ...d };
|
|
1549
|
+
if (p.items = r(
|
|
1550
|
+
h.doc.textBetween(
|
|
1470
1551
|
d.queryStartPos,
|
|
1471
|
-
|
|
1552
|
+
h.selection.from
|
|
1472
1553
|
)
|
|
1473
|
-
),
|
|
1554
|
+
), p.notFoundCount = 0, p.items.length === 0 && (p.notFoundCount = Math.max(
|
|
1474
1555
|
0,
|
|
1475
|
-
d.notFoundCount + (
|
|
1556
|
+
d.notFoundCount + (h.selection.from - c.selection.from)
|
|
1476
1557
|
)), // Highlighting text should hide the menu.
|
|
1477
|
-
|
|
1478
|
-
(
|
|
1558
|
+
h.selection.from !== h.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
|
|
1559
|
+
(g = a.getMeta(t)) != null && g.deactivate || // Certain mouse events should hide the menu.
|
|
1479
1560
|
// TODO: Change to global mousedown listener.
|
|
1480
1561
|
a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1481
|
-
d.active &&
|
|
1562
|
+
d.active && h.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
|
|
1482
1563
|
// the menu.
|
|
1483
|
-
|
|
1484
|
-
return
|
|
1485
|
-
if (((
|
|
1486
|
-
let
|
|
1487
|
-
|
|
1564
|
+
p.notFoundCount > 3)
|
|
1565
|
+
return Y();
|
|
1566
|
+
if (((b = a.getMeta(t)) == null ? void 0 : b.selectedItemIndexChanged) !== void 0) {
|
|
1567
|
+
let C = a.getMeta(t).selectedItemIndexChanged;
|
|
1568
|
+
C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0), p.keyboardHoveredItemIndex = C;
|
|
1488
1569
|
} else
|
|
1489
|
-
c.selection.from !==
|
|
1490
|
-
return
|
|
1570
|
+
c.selection.from !== h.selection.from && (p.keyboardHoveredItemIndex = 0);
|
|
1571
|
+
return p;
|
|
1491
1572
|
}
|
|
1492
1573
|
},
|
|
1493
1574
|
props: {
|
|
@@ -1503,8 +1584,8 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1503
1584
|
if (!c)
|
|
1504
1585
|
return !1;
|
|
1505
1586
|
const {
|
|
1506
|
-
triggerCharacter:
|
|
1507
|
-
queryStartPos:
|
|
1587
|
+
triggerCharacter: h,
|
|
1588
|
+
queryStartPos: p,
|
|
1508
1589
|
items: f,
|
|
1509
1590
|
keyboardHoveredItemIndex: m
|
|
1510
1591
|
} = t.getState(a.state);
|
|
@@ -1517,7 +1598,7 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1517
1598
|
selectedItemIndexChanged: m + 1
|
|
1518
1599
|
})
|
|
1519
1600
|
), !0) : d.key === "Enter" ? (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1520
|
-
from:
|
|
1601
|
+
from: p - h.length,
|
|
1521
1602
|
to: n._tiptapEditor.state.selection.from
|
|
1522
1603
|
}).run(), i({
|
|
1523
1604
|
item: f[m],
|
|
@@ -1526,14 +1607,14 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1526
1607
|
},
|
|
1527
1608
|
// Setup decorator on the currently active suggestion.
|
|
1528
1609
|
decorations(a) {
|
|
1529
|
-
const { active: d, decorationId: c, queryStartPos:
|
|
1610
|
+
const { active: d, decorationId: c, queryStartPos: h, triggerCharacter: p } = this.getState(a);
|
|
1530
1611
|
if (!d)
|
|
1531
1612
|
return null;
|
|
1532
|
-
if (
|
|
1533
|
-
const f =
|
|
1613
|
+
if (p === "") {
|
|
1614
|
+
const f = Ve(a.selection);
|
|
1534
1615
|
if (f)
|
|
1535
1616
|
return z.create(a.doc, [
|
|
1536
|
-
|
|
1617
|
+
V.node(
|
|
1537
1618
|
f.pos,
|
|
1538
1619
|
f.pos + f.node.nodeSize,
|
|
1539
1620
|
{
|
|
@@ -1545,9 +1626,9 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1545
1626
|
]);
|
|
1546
1627
|
}
|
|
1547
1628
|
return z.create(a.doc, [
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1629
|
+
V.inline(
|
|
1630
|
+
h - p.length,
|
|
1631
|
+
h,
|
|
1551
1632
|
{
|
|
1552
1633
|
nodeName: "span",
|
|
1553
1634
|
class: "suggestion-decorator",
|
|
@@ -1568,18 +1649,18 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1568
1649
|
});
|
|
1569
1650
|
}
|
|
1570
1651
|
};
|
|
1571
|
-
},
|
|
1572
|
-
class
|
|
1652
|
+
}, X = new w("SlashMenuPlugin");
|
|
1653
|
+
class Fe extends G {
|
|
1573
1654
|
constructor(t, o) {
|
|
1574
1655
|
super();
|
|
1575
1656
|
u(this, "plugin");
|
|
1576
1657
|
u(this, "itemCallback");
|
|
1577
|
-
const r =
|
|
1658
|
+
const r = Ue(
|
|
1578
1659
|
t,
|
|
1579
1660
|
(i) => {
|
|
1580
1661
|
this.emit("update", i);
|
|
1581
1662
|
},
|
|
1582
|
-
|
|
1663
|
+
X,
|
|
1583
1664
|
"/",
|
|
1584
1665
|
(i) => o.filter(
|
|
1585
1666
|
({ name: s, aliases: l }) => s.toLowerCase().startsWith(i.toLowerCase()) || l && l.filter(
|
|
@@ -1594,7 +1675,7 @@ class Ve extends F {
|
|
|
1594
1675
|
return this.on("update", t);
|
|
1595
1676
|
}
|
|
1596
1677
|
}
|
|
1597
|
-
const
|
|
1678
|
+
const Ge = new w("blocknote-placeholder"), $e = T.create({
|
|
1598
1679
|
name: "placeholder",
|
|
1599
1680
|
addOptions() {
|
|
1600
1681
|
return {
|
|
@@ -1610,21 +1691,21 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1610
1691
|
},
|
|
1611
1692
|
addProseMirrorPlugins() {
|
|
1612
1693
|
return [
|
|
1613
|
-
new
|
|
1614
|
-
key:
|
|
1694
|
+
new S({
|
|
1695
|
+
key: Ge,
|
|
1615
1696
|
props: {
|
|
1616
1697
|
decorations: (n) => {
|
|
1617
|
-
const { doc: e, selection: t } = n, o =
|
|
1698
|
+
const { doc: e, selection: t } = n, o = X.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
|
|
1618
1699
|
if (r)
|
|
1619
1700
|
return e.descendants((l, a) => {
|
|
1620
1701
|
const d = i >= a && i <= a + l.nodeSize, c = !l.isLeaf && !l.childCount;
|
|
1621
1702
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
1622
|
-
const
|
|
1623
|
-
this.editor.isEmpty &&
|
|
1624
|
-
const
|
|
1625
|
-
class:
|
|
1703
|
+
const h = [this.options.emptyNodeClass];
|
|
1704
|
+
this.editor.isEmpty && h.push(this.options.emptyEditorClass), d && h.push(this.options.hasAnchorClass), (o == null ? void 0 : o.triggerCharacter) === "" && (o != null && o.active) && h.push(this.options.isFilterClass);
|
|
1705
|
+
const p = V.node(a, a + l.nodeSize, {
|
|
1706
|
+
class: h.join(" ")
|
|
1626
1707
|
});
|
|
1627
|
-
s.push(
|
|
1708
|
+
s.push(p);
|
|
1628
1709
|
}
|
|
1629
1710
|
return this.options.includeChildren;
|
|
1630
1711
|
}), z.create(e, s);
|
|
@@ -1633,7 +1714,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1633
1714
|
})
|
|
1634
1715
|
];
|
|
1635
1716
|
}
|
|
1636
|
-
}),
|
|
1717
|
+
}), je = T.create({
|
|
1637
1718
|
name: "textAlignment",
|
|
1638
1719
|
addGlobalAttributes() {
|
|
1639
1720
|
return [
|
|
@@ -1656,7 +1737,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1656
1737
|
addCommands() {
|
|
1657
1738
|
return {
|
|
1658
1739
|
setTextAlignment: (n) => ({ state: e }) => {
|
|
1659
|
-
const t = [], o =
|
|
1740
|
+
const t = [], o = k(
|
|
1660
1741
|
e.doc,
|
|
1661
1742
|
e.selection.from
|
|
1662
1743
|
);
|
|
@@ -1671,7 +1752,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1671
1752
|
}
|
|
1672
1753
|
};
|
|
1673
1754
|
}
|
|
1674
|
-
}),
|
|
1755
|
+
}), qe = T.create({
|
|
1675
1756
|
name: "blockTextColor",
|
|
1676
1757
|
addGlobalAttributes() {
|
|
1677
1758
|
return [
|
|
@@ -1692,12 +1773,12 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1692
1773
|
addCommands() {
|
|
1693
1774
|
return {
|
|
1694
1775
|
setBlockTextColor: (n, e) => ({ state: t, view: o }) => {
|
|
1695
|
-
const r =
|
|
1776
|
+
const r = k(t.doc, n);
|
|
1696
1777
|
return r === void 0 ? !1 : (t.tr.setNodeAttribute(r.startPos - 1, "textColor", e), o.focus(), !0);
|
|
1697
1778
|
}
|
|
1698
1779
|
};
|
|
1699
1780
|
}
|
|
1700
|
-
}),
|
|
1781
|
+
}), We = lt.create({
|
|
1701
1782
|
name: "textColor",
|
|
1702
1783
|
addAttributes() {
|
|
1703
1784
|
return {
|
|
@@ -1726,12 +1807,12 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1726
1807
|
setTextColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
1727
1808
|
};
|
|
1728
1809
|
}
|
|
1729
|
-
}),
|
|
1810
|
+
}), Ye = T.create({
|
|
1730
1811
|
name: "trailingNode",
|
|
1731
1812
|
addProseMirrorPlugins() {
|
|
1732
|
-
const n = new
|
|
1813
|
+
const n = new w(this.name);
|
|
1733
1814
|
return [
|
|
1734
|
-
new
|
|
1815
|
+
new S({
|
|
1735
1816
|
key: n,
|
|
1736
1817
|
appendTransaction: (e, t, o) => {
|
|
1737
1818
|
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;
|
|
@@ -1758,7 +1839,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1758
1839
|
})
|
|
1759
1840
|
];
|
|
1760
1841
|
}
|
|
1761
|
-
}),
|
|
1842
|
+
}), Ke = (n) => {
|
|
1762
1843
|
const e = [
|
|
1763
1844
|
L.ClipboardTextSerializer,
|
|
1764
1845
|
L.Commands,
|
|
@@ -1766,48 +1847,57 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1766
1847
|
L.FocusEvents,
|
|
1767
1848
|
L.Tabindex,
|
|
1768
1849
|
// DevTools,
|
|
1769
|
-
|
|
1850
|
+
Yt,
|
|
1770
1851
|
// DropCursor,
|
|
1771
|
-
|
|
1772
|
-
emptyNodeClass:
|
|
1773
|
-
hasAnchorClass:
|
|
1774
|
-
isFilterClass:
|
|
1852
|
+
$e.configure({
|
|
1853
|
+
emptyNodeClass: y.isEmpty,
|
|
1854
|
+
hasAnchorClass: y.hasAnchor,
|
|
1855
|
+
isFilterClass: y.isFilter,
|
|
1775
1856
|
includeChildren: !0,
|
|
1776
1857
|
showOnlyCurrent: !1
|
|
1777
1858
|
}),
|
|
1778
|
-
|
|
1859
|
+
F.configure({
|
|
1779
1860
|
types: ["blockContainer"]
|
|
1780
1861
|
}),
|
|
1781
|
-
|
|
1862
|
+
Kt,
|
|
1782
1863
|
// Comments,
|
|
1783
1864
|
// basics:
|
|
1784
|
-
|
|
1865
|
+
te,
|
|
1785
1866
|
// marks:
|
|
1786
|
-
Ft,
|
|
1787
1867
|
Gt,
|
|
1788
|
-
|
|
1789
|
-
Zt,
|
|
1790
|
-
te,
|
|
1868
|
+
$t,
|
|
1791
1869
|
Xt,
|
|
1792
|
-
|
|
1793
|
-
|
|
1870
|
+
Qt,
|
|
1871
|
+
ee,
|
|
1872
|
+
Zt,
|
|
1873
|
+
We,
|
|
1874
|
+
qe,
|
|
1875
|
+
me,
|
|
1794
1876
|
fe,
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1877
|
+
je,
|
|
1878
|
+
// nodes
|
|
1879
|
+
Oe,
|
|
1880
|
+
Le.configure({
|
|
1881
|
+
domAttributes: n.domAttributes
|
|
1882
|
+
}),
|
|
1883
|
+
Pe.configure({
|
|
1884
|
+
domAttributes: n.domAttributes
|
|
1885
|
+
}),
|
|
1799
1886
|
...Object.values(n.blockSchema).map(
|
|
1800
|
-
(t) => t.node.configure({
|
|
1887
|
+
(t) => t.node.configure({
|
|
1888
|
+
editor: n.editor,
|
|
1889
|
+
domAttributes: n.domAttributes
|
|
1890
|
+
})
|
|
1801
1891
|
),
|
|
1802
|
-
|
|
1803
|
-
|
|
1892
|
+
Re,
|
|
1893
|
+
Wt.configure({ width: 5, color: "#ddeeff" }),
|
|
1804
1894
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
1805
1895
|
// should be handled before Enter handlers in other components like splitListItem
|
|
1806
|
-
|
|
1896
|
+
Ye
|
|
1807
1897
|
];
|
|
1808
1898
|
if (n.collaboration) {
|
|
1809
1899
|
e.push(
|
|
1810
|
-
|
|
1900
|
+
jt.configure({
|
|
1811
1901
|
fragment: n.collaboration.fragment
|
|
1812
1902
|
})
|
|
1813
1903
|
);
|
|
@@ -1820,7 +1910,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1820
1910
|
return r.insertBefore(s, null), r.insertBefore(i, null), r.insertBefore(l, null), r;
|
|
1821
1911
|
};
|
|
1822
1912
|
e.push(
|
|
1823
|
-
|
|
1913
|
+
qt.configure({
|
|
1824
1914
|
user: n.collaboration.user,
|
|
1825
1915
|
render: n.collaboration.renderCursor || t,
|
|
1826
1916
|
provider: n.collaboration.provider
|
|
@@ -1830,7 +1920,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1830
1920
|
e.push(Jt);
|
|
1831
1921
|
return e;
|
|
1832
1922
|
};
|
|
1833
|
-
function
|
|
1923
|
+
function Z(n, e) {
|
|
1834
1924
|
let t, o;
|
|
1835
1925
|
if (e.firstChild.descendants((r, i) => t ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== n ? !0 : (t = r, o = i + 1, !1)), t === void 0 || o === void 0)
|
|
1836
1926
|
throw Error("Could not find block in the editor with matching ID.");
|
|
@@ -1839,12 +1929,12 @@ function X(n, e) {
|
|
|
1839
1929
|
posBeforeNode: o
|
|
1840
1930
|
};
|
|
1841
1931
|
}
|
|
1842
|
-
function
|
|
1932
|
+
function Tt(n, e, t = "before", o) {
|
|
1843
1933
|
const r = typeof e == "string" ? e : e.id, i = [];
|
|
1844
1934
|
for (const d of n)
|
|
1845
|
-
i.push(
|
|
1935
|
+
i.push(D(d, o.schema));
|
|
1846
1936
|
let s = -1;
|
|
1847
|
-
const { node: l, posBeforeNode: a } =
|
|
1937
|
+
const { node: l, posBeforeNode: a } = Z(r, o.state.doc);
|
|
1848
1938
|
if (t === "before" && (s = a), t === "after" && (s = a + l.nodeSize), t === "nested") {
|
|
1849
1939
|
if (l.childCount < 2) {
|
|
1850
1940
|
s = a + l.firstChild.nodeSize + 1;
|
|
@@ -1861,11 +1951,11 @@ function Bt(n, e, t = "before", o) {
|
|
|
1861
1951
|
}
|
|
1862
1952
|
o.view.dispatch(o.state.tr.insert(s, i));
|
|
1863
1953
|
}
|
|
1864
|
-
function
|
|
1865
|
-
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } =
|
|
1954
|
+
function Je(n, e, t) {
|
|
1955
|
+
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = Z(o, t.state.doc);
|
|
1866
1956
|
t.commands.BNUpdateBlock(r + 1, e);
|
|
1867
1957
|
}
|
|
1868
|
-
function
|
|
1958
|
+
function xt(n, e) {
|
|
1869
1959
|
const t = new Set(
|
|
1870
1960
|
n.map(
|
|
1871
1961
|
(r) => typeof r == "string" ? r : r.id
|
|
@@ -1890,10 +1980,10 @@ function Tt(n, e) {
|
|
|
1890
1980
|
);
|
|
1891
1981
|
}
|
|
1892
1982
|
}
|
|
1893
|
-
function
|
|
1894
|
-
|
|
1983
|
+
function Xe(n, e, t) {
|
|
1984
|
+
Tt(e, n[0], "before", t), xt(n, t);
|
|
1895
1985
|
}
|
|
1896
|
-
function
|
|
1986
|
+
function Ze() {
|
|
1897
1987
|
const n = (e) => {
|
|
1898
1988
|
let t = e.children.length;
|
|
1899
1989
|
for (let o = 0; o < t; o++) {
|
|
@@ -1909,19 +1999,19 @@ function Ke() {
|
|
|
1909
1999
|
};
|
|
1910
2000
|
return n;
|
|
1911
2001
|
}
|
|
1912
|
-
function
|
|
2002
|
+
function Qe(n) {
|
|
1913
2003
|
const e = /* @__PURE__ */ new Set([
|
|
1914
2004
|
...n.orderedListItemBlockTypes,
|
|
1915
2005
|
...n.unorderedListItemBlockTypes
|
|
1916
2006
|
]), t = (o) => {
|
|
1917
2007
|
let r = o.children.length, i;
|
|
1918
2008
|
for (let s = 0; s < r; s++) {
|
|
1919
|
-
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null,
|
|
2009
|
+
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, h = e.has(
|
|
1920
2010
|
d.properties.dataContentType
|
|
1921
|
-
),
|
|
2011
|
+
), p = h ? n.orderedListItemBlockTypes.has(
|
|
1922
2012
|
d.properties.dataContentType
|
|
1923
2013
|
) ? "ol" : "ul" : null;
|
|
1924
|
-
if (c !== null && t(c), i && i.tagName !==
|
|
2014
|
+
if (c !== null && t(c), i && i.tagName !== p) {
|
|
1925
2015
|
o.children.splice(
|
|
1926
2016
|
s - i.children.length,
|
|
1927
2017
|
i.children.length,
|
|
@@ -1930,11 +2020,11 @@ function Xe(n) {
|
|
|
1930
2020
|
const f = i.children.length - 1;
|
|
1931
2021
|
s -= f, r -= f, i = void 0;
|
|
1932
2022
|
}
|
|
1933
|
-
if (
|
|
1934
|
-
i || (i =
|
|
1935
|
-
document.createElement(
|
|
2023
|
+
if (h) {
|
|
2024
|
+
i || (i = nt(
|
|
2025
|
+
document.createElement(p)
|
|
1936
2026
|
));
|
|
1937
|
-
const f =
|
|
2027
|
+
const f = nt(
|
|
1938
2028
|
document.createElement("li")
|
|
1939
2029
|
);
|
|
1940
2030
|
f.children.push(d.children[0]), c !== null && f.children.push(...c.children), i.children.push(f);
|
|
@@ -1953,33 +2043,33 @@ function Xe(n) {
|
|
|
1953
2043
|
};
|
|
1954
2044
|
return t;
|
|
1955
2045
|
}
|
|
1956
|
-
async function
|
|
1957
|
-
const t = document.createElement("div"), o =
|
|
2046
|
+
async function At(n, e) {
|
|
2047
|
+
const t = document.createElement("div"), o = W.fromSchema(e);
|
|
1958
2048
|
for (const i of n) {
|
|
1959
|
-
const s =
|
|
2049
|
+
const s = D(i, e), l = o.serializeNode(s);
|
|
1960
2050
|
t.appendChild(l);
|
|
1961
2051
|
}
|
|
1962
|
-
return (await J().use(
|
|
2052
|
+
return (await J().use(dt, { fragment: !0 }).use(Qe, {
|
|
1963
2053
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
1964
2054
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
1965
|
-
}).use(
|
|
2055
|
+
}).use(ct).process(t.innerHTML)).value;
|
|
1966
2056
|
}
|
|
1967
2057
|
async function _t(n, e, t) {
|
|
1968
2058
|
const o = document.createElement("div");
|
|
1969
2059
|
o.innerHTML = n.trim();
|
|
1970
|
-
const i =
|
|
2060
|
+
const i = oe.fromSchema(t).parse(o), s = [];
|
|
1971
2061
|
for (let l = 0; l < i.firstChild.childCount; l++)
|
|
1972
|
-
s.push(
|
|
2062
|
+
s.push(E(i.firstChild.child(l), e));
|
|
1973
2063
|
return s;
|
|
1974
2064
|
}
|
|
1975
|
-
async function
|
|
1976
|
-
return (await J().use(
|
|
2065
|
+
async function to(n, e) {
|
|
2066
|
+
return (await J().use(dt, { fragment: !0 }).use(Ze).use(se).use(ut).use(de).process(await At(n, e))).value;
|
|
1977
2067
|
}
|
|
1978
|
-
async function
|
|
1979
|
-
const o = await J().use(
|
|
2068
|
+
async function eo(n, e, t) {
|
|
2069
|
+
const o = await J().use(ae).use(ut).use(le).use(ct).process(n);
|
|
1980
2070
|
return _t(o.value, e, t);
|
|
1981
2071
|
}
|
|
1982
|
-
class
|
|
2072
|
+
class oo {
|
|
1983
2073
|
constructor(e, t, o) {
|
|
1984
2074
|
u(this, "formattingToolbarState");
|
|
1985
2075
|
u(this, "updateFormattingToolbar");
|
|
@@ -2028,25 +2118,25 @@ class to {
|
|
|
2028
2118
|
}, t.dom.addEventListener("mousedown", this.viewMousedownHandler), t.dom.addEventListener("mouseup", this.viewMouseupHandler), t.dom.addEventListener("dragstart", this.dragstartHandler), t.dom.addEventListener("focus", this.focusHandler), t.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2029
2119
|
}
|
|
2030
2120
|
update(e, t) {
|
|
2031
|
-
var
|
|
2121
|
+
var p, f;
|
|
2032
2122
|
const { state: o, composing: r } = e, { doc: i, selection: s } = o, l = t && t.doc.eq(i) && t.selection.eq(s);
|
|
2033
2123
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
|
|
2034
2124
|
return;
|
|
2035
2125
|
this.prevWasEditable = this.editor.isEditable;
|
|
2036
|
-
const { ranges: a } = s, d = Math.min(...a.map((m) => m.$from.pos)), c = Math.max(...a.map((m) => m.$to.pos)),
|
|
2126
|
+
const { ranges: a } = s, d = Math.min(...a.map((m) => m.$from.pos)), c = Math.max(...a.map((m) => m.$to.pos)), h = (p = this.shouldShow) == null ? void 0 : p.call(this, {
|
|
2037
2127
|
view: e,
|
|
2038
2128
|
state: o,
|
|
2039
2129
|
from: d,
|
|
2040
2130
|
to: c
|
|
2041
2131
|
});
|
|
2042
|
-
if (this.editor.isEditable && !this.preventShow && (
|
|
2132
|
+
if (this.editor.isEditable && !this.preventShow && (h || this.preventHide)) {
|
|
2043
2133
|
this.formattingToolbarState = {
|
|
2044
2134
|
show: !0,
|
|
2045
2135
|
referencePos: this.getSelectionBoundingBox()
|
|
2046
2136
|
}, this.updateFormattingToolbar();
|
|
2047
2137
|
return;
|
|
2048
2138
|
}
|
|
2049
|
-
if ((f = this.formattingToolbarState) != null && f.show && !this.preventHide && (!
|
|
2139
|
+
if ((f = this.formattingToolbarState) != null && f.show && !this.preventHide && (!h || this.preventShow || !this.editor.isEditable)) {
|
|
2050
2140
|
this.formattingToolbarState.show = !1, this.updateFormattingToolbar();
|
|
2051
2141
|
return;
|
|
2052
2142
|
}
|
|
@@ -2056,25 +2146,25 @@ class to {
|
|
|
2056
2146
|
}
|
|
2057
2147
|
getSelectionBoundingBox() {
|
|
2058
2148
|
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));
|
|
2059
|
-
if (
|
|
2149
|
+
if (Ut(t)) {
|
|
2060
2150
|
const s = this.pmView.nodeDOM(r);
|
|
2061
2151
|
if (s)
|
|
2062
2152
|
return s.getBoundingClientRect();
|
|
2063
2153
|
}
|
|
2064
|
-
return
|
|
2154
|
+
return q(this.pmView, r, i);
|
|
2065
2155
|
}
|
|
2066
2156
|
}
|
|
2067
|
-
const
|
|
2157
|
+
const no = new w(
|
|
2068
2158
|
"FormattingToolbarPlugin"
|
|
2069
2159
|
);
|
|
2070
|
-
class
|
|
2160
|
+
class ro extends G {
|
|
2071
2161
|
constructor(t) {
|
|
2072
2162
|
super();
|
|
2073
2163
|
u(this, "view");
|
|
2074
2164
|
u(this, "plugin");
|
|
2075
|
-
this.plugin = new
|
|
2076
|
-
key:
|
|
2077
|
-
view: (o) => (this.view = new
|
|
2165
|
+
this.plugin = new S({
|
|
2166
|
+
key: no,
|
|
2167
|
+
view: (o) => (this.view = new oo(t, o, (r) => {
|
|
2078
2168
|
this.emit("update", r);
|
|
2079
2169
|
}), this.view)
|
|
2080
2170
|
});
|
|
@@ -2083,7 +2173,7 @@ class oo extends F {
|
|
|
2083
2173
|
return this.on("update", t);
|
|
2084
2174
|
}
|
|
2085
2175
|
}
|
|
2086
|
-
class
|
|
2176
|
+
class io {
|
|
2087
2177
|
constructor(e, t, o) {
|
|
2088
2178
|
u(this, "hyperlinkToolbarState");
|
|
2089
2179
|
u(this, "updateHyperlinkToolbar");
|
|
@@ -2103,7 +2193,7 @@ class no {
|
|
|
2103
2193
|
), i = r.marks();
|
|
2104
2194
|
for (const s of i)
|
|
2105
2195
|
if (s.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2106
|
-
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange =
|
|
2196
|
+
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = et(
|
|
2107
2197
|
r,
|
|
2108
2198
|
s.type,
|
|
2109
2199
|
s.attrs
|
|
@@ -2123,7 +2213,7 @@ class no {
|
|
|
2123
2213
|
});
|
|
2124
2214
|
u(this, "scrollHandler", () => {
|
|
2125
2215
|
var e;
|
|
2126
|
-
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos =
|
|
2216
|
+
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos = q(
|
|
2127
2217
|
this.pmView,
|
|
2128
2218
|
this.hyperlinkMarkRange.from,
|
|
2129
2219
|
this.hyperlinkMarkRange.to
|
|
@@ -2171,7 +2261,7 @@ class no {
|
|
|
2171
2261
|
const o = this.pmView.state.selection.$from.marks();
|
|
2172
2262
|
for (const r of o)
|
|
2173
2263
|
if (r.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2174
|
-
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange =
|
|
2264
|
+
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange = et(
|
|
2175
2265
|
this.pmView.state.selection.$from,
|
|
2176
2266
|
r.type,
|
|
2177
2267
|
r.attrs
|
|
@@ -2182,7 +2272,7 @@ class no {
|
|
|
2182
2272
|
if (this.mouseHoveredHyperlinkMark && (this.hyperlinkMark = this.mouseHoveredHyperlinkMark, this.hyperlinkMarkRange = this.mouseHoveredHyperlinkMarkRange), this.keyboardHoveredHyperlinkMark && (this.hyperlinkMark = this.keyboardHoveredHyperlinkMark, this.hyperlinkMarkRange = this.keyboardHoveredHyperlinkMarkRange), this.hyperlinkMark && this.editor.isEditable) {
|
|
2183
2273
|
this.hyperlinkToolbarState = {
|
|
2184
2274
|
show: !0,
|
|
2185
|
-
referencePos:
|
|
2275
|
+
referencePos: q(
|
|
2186
2276
|
this.pmView,
|
|
2187
2277
|
this.hyperlinkMarkRange.from,
|
|
2188
2278
|
this.hyperlinkMarkRange.to
|
|
@@ -2204,10 +2294,10 @@ class no {
|
|
|
2204
2294
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2205
2295
|
}
|
|
2206
2296
|
}
|
|
2207
|
-
const
|
|
2297
|
+
const so = new w(
|
|
2208
2298
|
"HyperlinkToolbarPlugin"
|
|
2209
2299
|
);
|
|
2210
|
-
class
|
|
2300
|
+
class ao extends G {
|
|
2211
2301
|
constructor(t) {
|
|
2212
2302
|
super();
|
|
2213
2303
|
u(this, "view");
|
|
@@ -2242,9 +2332,9 @@ class io extends F {
|
|
|
2242
2332
|
u(this, "stopHideTimer", () => {
|
|
2243
2333
|
this.view.stopMenuUpdateTimer();
|
|
2244
2334
|
});
|
|
2245
|
-
this.plugin = new
|
|
2246
|
-
key:
|
|
2247
|
-
view: (o) => (this.view = new
|
|
2335
|
+
this.plugin = new S({
|
|
2336
|
+
key: so,
|
|
2337
|
+
view: (o) => (this.view = new io(t, o, (r) => {
|
|
2248
2338
|
this.emit("update", r);
|
|
2249
2339
|
}), this.view)
|
|
2250
2340
|
});
|
|
@@ -2253,7 +2343,7 @@ class io extends F {
|
|
|
2253
2343
|
return this.on("update", t);
|
|
2254
2344
|
}
|
|
2255
2345
|
}
|
|
2256
|
-
class
|
|
2346
|
+
class N extends j {
|
|
2257
2347
|
constructor(t, o) {
|
|
2258
2348
|
super(t, o);
|
|
2259
2349
|
u(this, "nodes");
|
|
@@ -2264,13 +2354,13 @@ class A extends $ {
|
|
|
2264
2354
|
});
|
|
2265
2355
|
}
|
|
2266
2356
|
static create(t, o, r = o) {
|
|
2267
|
-
return new
|
|
2357
|
+
return new N(t.resolve(o), t.resolve(r));
|
|
2268
2358
|
}
|
|
2269
2359
|
content() {
|
|
2270
|
-
return new
|
|
2360
|
+
return new x(I.from(this.nodes), 0, 0);
|
|
2271
2361
|
}
|
|
2272
2362
|
eq(t) {
|
|
2273
|
-
if (!(t instanceof
|
|
2363
|
+
if (!(t instanceof N) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
|
|
2274
2364
|
return !1;
|
|
2275
2365
|
for (let o = 0; o < this.nodes.length; o++)
|
|
2276
2366
|
if (!this.nodes[o].eq(t.nodes[o]))
|
|
@@ -2279,7 +2369,7 @@ class A extends $ {
|
|
|
2279
2369
|
}
|
|
2280
2370
|
map(t, o) {
|
|
2281
2371
|
let r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2282
|
-
return i.deleted ?
|
|
2372
|
+
return i.deleted ? j.near(t.resolve(r.pos)) : r.deleted ? j.near(t.resolve(i.pos)) : new N(
|
|
2283
2373
|
t.resolve(r.pos),
|
|
2284
2374
|
t.resolve(i.pos)
|
|
2285
2375
|
);
|
|
@@ -2288,8 +2378,8 @@ class A extends $ {
|
|
|
2288
2378
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
2289
2379
|
}
|
|
2290
2380
|
}
|
|
2291
|
-
const
|
|
2292
|
-
let
|
|
2381
|
+
const lo = ie.__serializeForClipboard;
|
|
2382
|
+
let B;
|
|
2293
2383
|
function It(n, e) {
|
|
2294
2384
|
var r;
|
|
2295
2385
|
if (!e.dom.isConnected)
|
|
@@ -2305,7 +2395,7 @@ function It(n, e) {
|
|
|
2305
2395
|
return { node: o, id: o.getAttribute("data-id") };
|
|
2306
2396
|
}
|
|
2307
2397
|
}
|
|
2308
|
-
function
|
|
2398
|
+
function co(n, e) {
|
|
2309
2399
|
let t = It(n, e);
|
|
2310
2400
|
if (t && t.node.nodeType === 1) {
|
|
2311
2401
|
const o = e.docView;
|
|
@@ -2314,7 +2404,7 @@ function ao(n, e) {
|
|
|
2314
2404
|
}
|
|
2315
2405
|
return null;
|
|
2316
2406
|
}
|
|
2317
|
-
function
|
|
2407
|
+
function uo(n, e) {
|
|
2318
2408
|
let t, o;
|
|
2319
2409
|
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);
|
|
2320
2410
|
if (r && i) {
|
|
@@ -2324,9 +2414,9 @@ function lo(n, e) {
|
|
|
2324
2414
|
t = n.from, o = n.to;
|
|
2325
2415
|
return { from: t, to: o };
|
|
2326
2416
|
}
|
|
2327
|
-
function
|
|
2417
|
+
function at(n, e, t = e) {
|
|
2328
2418
|
e === t && (t += n.state.doc.resolve(e + 1).node().nodeSize);
|
|
2329
|
-
const o = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, i = (c,
|
|
2419
|
+
const o = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, i = (c, h) => Array.prototype.indexOf.call(c.children, h), s = i(
|
|
2330
2420
|
r,
|
|
2331
2421
|
// Expects from position to be just before the first selected block.
|
|
2332
2422
|
n.domAtPos(e + 1).node.parentElement
|
|
@@ -2337,16 +2427,16 @@ function st(n, e, t = e) {
|
|
|
2337
2427
|
);
|
|
2338
2428
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
2339
2429
|
(c > l || c < s) && o.removeChild(o.children[c]);
|
|
2340
|
-
Ht(),
|
|
2430
|
+
Ht(), B = o;
|
|
2341
2431
|
const d = n.dom.className.split(" ").filter(
|
|
2342
2432
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
2343
2433
|
).join(" ");
|
|
2344
|
-
|
|
2434
|
+
B.className = B.className + " " + H.dragPreview + " " + d, document.body.appendChild(B);
|
|
2345
2435
|
}
|
|
2346
2436
|
function Ht() {
|
|
2347
|
-
|
|
2437
|
+
B !== void 0 && (document.body.removeChild(B), B = void 0);
|
|
2348
2438
|
}
|
|
2349
|
-
function
|
|
2439
|
+
function po(n, e) {
|
|
2350
2440
|
if (!n.dataTransfer)
|
|
2351
2441
|
return;
|
|
2352
2442
|
const t = e.dom.getBoundingClientRect();
|
|
@@ -2354,19 +2444,19 @@ function co(n, e) {
|
|
|
2354
2444
|
left: t.left + t.width / 2,
|
|
2355
2445
|
// take middle of editor
|
|
2356
2446
|
top: n.clientY
|
|
2357
|
-
}, r =
|
|
2447
|
+
}, r = co(o, e);
|
|
2358
2448
|
if (r != null) {
|
|
2359
|
-
const i = e.state.selection, s = e.state.doc, { from: l, to: a } =
|
|
2449
|
+
const i = e.state.selection, s = e.state.doc, { from: l, to: a } = uo(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof N;
|
|
2360
2450
|
d && c ? (e.dispatch(
|
|
2361
|
-
e.state.tr.setSelection(
|
|
2362
|
-
),
|
|
2363
|
-
e.state.tr.setSelection(
|
|
2364
|
-
),
|
|
2365
|
-
let
|
|
2366
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html",
|
|
2451
|
+
e.state.tr.setSelection(N.create(s, l, a))
|
|
2452
|
+
), at(e, l, a)) : (e.dispatch(
|
|
2453
|
+
e.state.tr.setSelection(ne.create(e.state.doc, r))
|
|
2454
|
+
), at(e, r));
|
|
2455
|
+
let h = e.state.selection.content(), { dom: p, text: f } = lo(e, h);
|
|
2456
|
+
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 };
|
|
2367
2457
|
}
|
|
2368
2458
|
}
|
|
2369
|
-
class
|
|
2459
|
+
class ho {
|
|
2370
2460
|
constructor(e, t, o) {
|
|
2371
2461
|
u(this, "sideMenuState");
|
|
2372
2462
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
@@ -2423,7 +2513,7 @@ class uo {
|
|
|
2423
2513
|
(t = this.sideMenuState) != null && t.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2424
2514
|
});
|
|
2425
2515
|
u(this, "onMouseMove", (e) => {
|
|
2426
|
-
var d, c,
|
|
2516
|
+
var d, c, h, p, f;
|
|
2427
2517
|
if (this.menuFrozen)
|
|
2428
2518
|
return;
|
|
2429
2519
|
const t = this.pmView.dom.firstChild.getBoundingClientRect(), o = this.pmView.dom.getBoundingClientRect(), r = e.clientX >= o.left && e.clientX <= o.right && e.clientY >= o.top && e.clientY <= o.bottom, i = this.pmView.dom.parentElement;
|
|
@@ -2446,7 +2536,7 @@ class uo {
|
|
|
2446
2536
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2447
2537
|
return;
|
|
2448
2538
|
}
|
|
2449
|
-
if ((
|
|
2539
|
+
if ((h = this.sideMenuState) != null && h.show && ((p = this.hoveredBlock) != null && p.hasAttribute("data-id")) && ((f = this.hoveredBlock) == null ? void 0 : f.getAttribute("data-id")) === l.id)
|
|
2450
2540
|
return;
|
|
2451
2541
|
this.hoveredBlock = l.node;
|
|
2452
2542
|
const a = l.node.firstChild;
|
|
@@ -2493,7 +2583,7 @@ class uo {
|
|
|
2493
2583
|
});
|
|
2494
2584
|
if (!o)
|
|
2495
2585
|
return;
|
|
2496
|
-
const r =
|
|
2586
|
+
const r = k(
|
|
2497
2587
|
this.editor._tiptapEditor.state.doc,
|
|
2498
2588
|
o.pos
|
|
2499
2589
|
);
|
|
@@ -2506,7 +2596,7 @@ class uo {
|
|
|
2506
2596
|
} else
|
|
2507
2597
|
this.editor._tiptapEditor.commands.setTextSelection(s);
|
|
2508
2598
|
this.pmView.focus(), this.pmView.dispatch(
|
|
2509
|
-
this.pmView.state.tr.scrollIntoView().setMeta(
|
|
2599
|
+
this.pmView.state.tr.scrollIntoView().setMeta(X, {
|
|
2510
2600
|
// TODO import suggestion plugin key
|
|
2511
2601
|
activate: !0,
|
|
2512
2602
|
type: "drag"
|
|
@@ -2514,8 +2604,8 @@ class uo {
|
|
|
2514
2604
|
);
|
|
2515
2605
|
}
|
|
2516
2606
|
}
|
|
2517
|
-
const
|
|
2518
|
-
class
|
|
2607
|
+
const fo = new w("SideMenuPlugin");
|
|
2608
|
+
class mo extends G {
|
|
2519
2609
|
constructor(t) {
|
|
2520
2610
|
super();
|
|
2521
2611
|
u(this, "sideMenuView");
|
|
@@ -2529,7 +2619,7 @@ class ho extends F {
|
|
|
2529
2619
|
* Handles drag & drop events for blocks.
|
|
2530
2620
|
*/
|
|
2531
2621
|
u(this, "blockDragStart", (t) => {
|
|
2532
|
-
this.sideMenuView.isDragging = !0,
|
|
2622
|
+
this.sideMenuView.isDragging = !0, po(t, this.editor.prosemirrorView);
|
|
2533
2623
|
});
|
|
2534
2624
|
/**
|
|
2535
2625
|
* Handles drag & drop events for blocks.
|
|
@@ -2547,9 +2637,9 @@ class ho extends F {
|
|
|
2547
2637
|
* mouse cursor.
|
|
2548
2638
|
*/
|
|
2549
2639
|
u(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2550
|
-
this.editor = t, this.plugin = new
|
|
2551
|
-
key:
|
|
2552
|
-
view: (o) => (this.sideMenuView = new
|
|
2640
|
+
this.editor = t, this.plugin = new S({
|
|
2641
|
+
key: fo,
|
|
2642
|
+
view: (o) => (this.sideMenuView = new ho(
|
|
2553
2643
|
t,
|
|
2554
2644
|
o,
|
|
2555
2645
|
(r) => {
|
|
@@ -2566,7 +2656,7 @@ function _(n, e) {
|
|
|
2566
2656
|
const t = n.getTextCursorPosition().block;
|
|
2567
2657
|
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));
|
|
2568
2658
|
}
|
|
2569
|
-
const
|
|
2659
|
+
const ko = (n = St) => {
|
|
2570
2660
|
var t, o, r;
|
|
2571
2661
|
const e = [];
|
|
2572
2662
|
return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes("1") && e.push({
|
|
@@ -2609,12 +2699,12 @@ const fo = (n = wt) => {
|
|
|
2609
2699
|
type: "paragraph"
|
|
2610
2700
|
})
|
|
2611
2701
|
}), e;
|
|
2612
|
-
},
|
|
2702
|
+
}, go = {
|
|
2613
2703
|
enableInputRules: !0,
|
|
2614
2704
|
enablePasteRules: !0,
|
|
2615
2705
|
enableCoreExtensions: !1
|
|
2616
2706
|
};
|
|
2617
|
-
class
|
|
2707
|
+
class Jo {
|
|
2618
2708
|
constructor(e = {}) {
|
|
2619
2709
|
u(this, "_tiptapEditor");
|
|
2620
2710
|
u(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
@@ -2624,7 +2714,7 @@ class Wo {
|
|
|
2624
2714
|
u(this, "formattingToolbar");
|
|
2625
2715
|
u(this, "slashMenu");
|
|
2626
2716
|
u(this, "hyperlinkToolbar");
|
|
2627
|
-
var l, a, d;
|
|
2717
|
+
var l, a, d, c, h;
|
|
2628
2718
|
this.options = e;
|
|
2629
2719
|
const t = {
|
|
2630
2720
|
defaultStyles: !0,
|
|
@@ -2633,18 +2723,19 @@ class Wo {
|
|
|
2633
2723
|
// If BSchema is not specified, then options.blockSchema should also not
|
|
2634
2724
|
// be defined. Unfortunately, trying to implement these constraints seems
|
|
2635
2725
|
// to be a huge pain, hence the `as any` casts.
|
|
2636
|
-
blockSchema: e.blockSchema ||
|
|
2726
|
+
blockSchema: e.blockSchema || St,
|
|
2637
2727
|
...e
|
|
2638
2728
|
};
|
|
2639
|
-
this.sideMenu = new
|
|
2729
|
+
this.sideMenu = new mo(this), this.formattingToolbar = new ro(this), this.slashMenu = new Fe(
|
|
2640
2730
|
this,
|
|
2641
|
-
t.slashMenuItems ||
|
|
2642
|
-
), this.hyperlinkToolbar = new
|
|
2643
|
-
const o =
|
|
2731
|
+
t.slashMenuItems || ko(t.blockSchema)
|
|
2732
|
+
), this.hyperlinkToolbar = new ao(this);
|
|
2733
|
+
const o = Ke({
|
|
2644
2734
|
editor: this,
|
|
2735
|
+
domAttributes: t.domAttributes || {},
|
|
2645
2736
|
blockSchema: t.blockSchema,
|
|
2646
2737
|
collaboration: t.collaboration
|
|
2647
|
-
}), r =
|
|
2738
|
+
}), r = T.create({
|
|
2648
2739
|
name: "BlockNoteUIExtension",
|
|
2649
2740
|
addProseMirrorPlugins: () => [
|
|
2650
2741
|
this.sideMenu.plugin,
|
|
@@ -2657,49 +2748,48 @@ class Wo {
|
|
|
2657
2748
|
const i = t.initialContent || (e.collaboration ? void 0 : [
|
|
2658
2749
|
{
|
|
2659
2750
|
type: "paragraph",
|
|
2660
|
-
id:
|
|
2751
|
+
id: F.options.generateID()
|
|
2661
2752
|
}
|
|
2662
2753
|
]), s = {
|
|
2663
|
-
...
|
|
2754
|
+
...go,
|
|
2664
2755
|
...t._tiptapOptions,
|
|
2665
2756
|
onCreate: () => {
|
|
2666
|
-
var
|
|
2667
|
-
(
|
|
2757
|
+
var p;
|
|
2758
|
+
(p = t.onEditorReady) == null || p.call(t, this), this.ready = !0;
|
|
2668
2759
|
},
|
|
2669
|
-
onBeforeCreate(
|
|
2760
|
+
onBeforeCreate(p) {
|
|
2670
2761
|
if (!i)
|
|
2671
2762
|
return;
|
|
2672
|
-
const
|
|
2763
|
+
const f = p.editor.schema, m = i.map((b) => D(b, f)), g = f.node(
|
|
2673
2764
|
"doc",
|
|
2674
2765
|
void 0,
|
|
2675
|
-
|
|
2766
|
+
f.node("blockGroup", void 0, m)
|
|
2676
2767
|
);
|
|
2677
|
-
|
|
2768
|
+
p.editor.options.content = g.toJSON();
|
|
2678
2769
|
},
|
|
2679
2770
|
onUpdate: () => {
|
|
2680
|
-
var
|
|
2681
|
-
this.ready && ((
|
|
2771
|
+
var p;
|
|
2772
|
+
this.ready && ((p = t.onEditorContentChange) == null || p.call(t, this));
|
|
2682
2773
|
},
|
|
2683
2774
|
onSelectionUpdate: () => {
|
|
2684
|
-
var
|
|
2685
|
-
this.ready && ((
|
|
2775
|
+
var p;
|
|
2776
|
+
this.ready && ((p = t.onTextCursorPositionChange) == null || p.call(t, this));
|
|
2686
2777
|
},
|
|
2687
2778
|
editable: e.editable === void 0 ? !0 : e.editable,
|
|
2688
2779
|
extensions: t.enableBlockNoteExtensions === !1 ? (l = t._tiptapOptions) == null ? void 0 : l.extensions : [...((a = t._tiptapOptions) == null ? void 0 : a.extensions) || [], ...o],
|
|
2689
2780
|
editorProps: {
|
|
2690
2781
|
attributes: {
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
class: [
|
|
2782
|
+
...(d = t.domAttributes) == null ? void 0 : d.editor,
|
|
2783
|
+
class: v(
|
|
2694
2784
|
H.bnEditor,
|
|
2695
2785
|
H.bnRoot,
|
|
2696
2786
|
t.defaultStyles ? H.defaultStyles : "",
|
|
2697
|
-
((
|
|
2698
|
-
|
|
2787
|
+
((h = (c = t.domAttributes) == null ? void 0 : c.editor) == null ? void 0 : h.class) || ""
|
|
2788
|
+
)
|
|
2699
2789
|
}
|
|
2700
2790
|
}
|
|
2701
2791
|
};
|
|
2702
|
-
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new
|
|
2792
|
+
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new Ft(s);
|
|
2703
2793
|
}
|
|
2704
2794
|
get prosemirrorView() {
|
|
2705
2795
|
return this._tiptapEditor.view;
|
|
@@ -2719,7 +2809,7 @@ class Wo {
|
|
|
2719
2809
|
*/
|
|
2720
2810
|
get topLevelBlocks() {
|
|
2721
2811
|
const e = [];
|
|
2722
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(
|
|
2812
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(E(t, this.schema, this.blockCache)), !1)), e;
|
|
2723
2813
|
}
|
|
2724
2814
|
/**
|
|
2725
2815
|
* Gets a snapshot of an existing block from the editor.
|
|
@@ -2729,7 +2819,7 @@ class Wo {
|
|
|
2729
2819
|
getBlock(e) {
|
|
2730
2820
|
const t = typeof e == "string" ? e : e.id;
|
|
2731
2821
|
let o;
|
|
2732
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (o =
|
|
2822
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (o = E(r, this.schema, this.blockCache), !1)), o;
|
|
2733
2823
|
}
|
|
2734
2824
|
/**
|
|
2735
2825
|
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
@@ -2770,7 +2860,7 @@ class Wo {
|
|
|
2770
2860
|
* @returns A snapshot of the current text cursor position.
|
|
2771
2861
|
*/
|
|
2772
2862
|
getTextCursorPosition() {
|
|
2773
|
-
const { node: e, depth: t, startPos: o, endPos: r } =
|
|
2863
|
+
const { node: e, depth: t, startPos: o, endPos: r } = k(
|
|
2774
2864
|
this._tiptapEditor.state.doc,
|
|
2775
2865
|
this._tiptapEditor.state.selection.from
|
|
2776
2866
|
), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), s = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
|
|
@@ -2778,9 +2868,9 @@ class Wo {
|
|
|
2778
2868
|
i > 0 && (l = this._tiptapEditor.state.doc.resolve(o - 2).node());
|
|
2779
2869
|
let a;
|
|
2780
2870
|
return i < s - 1 && (a = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
|
|
2781
|
-
block:
|
|
2782
|
-
prevBlock: l === void 0 ? void 0 :
|
|
2783
|
-
nextBlock: a === void 0 ? void 0 :
|
|
2871
|
+
block: E(e, this.schema, this.blockCache),
|
|
2872
|
+
prevBlock: l === void 0 ? void 0 : E(l, this.schema, this.blockCache),
|
|
2873
|
+
nextBlock: a === void 0 ? void 0 : E(a, this.schema, this.blockCache)
|
|
2784
2874
|
};
|
|
2785
2875
|
}
|
|
2786
2876
|
/**
|
|
@@ -2790,7 +2880,7 @@ class Wo {
|
|
|
2790
2880
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
2791
2881
|
*/
|
|
2792
2882
|
setTextCursorPosition(e, t = "start") {
|
|
2793
|
-
const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } =
|
|
2883
|
+
const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } = Z(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = k(
|
|
2794
2884
|
this._tiptapEditor.state.doc,
|
|
2795
2885
|
r + 2
|
|
2796
2886
|
);
|
|
@@ -2806,7 +2896,7 @@ class Wo {
|
|
|
2806
2896
|
return;
|
|
2807
2897
|
const e = [];
|
|
2808
2898
|
return this._tiptapEditor.state.doc.descendants((t, o) => t.type.spec.group !== "blockContent" || o + t.nodeSize < this._tiptapEditor.state.selection.from || o > this._tiptapEditor.state.selection.to ? !0 : (e.push(
|
|
2809
|
-
|
|
2899
|
+
E(
|
|
2810
2900
|
this._tiptapEditor.state.doc.resolve(o).node(),
|
|
2811
2901
|
this.schema,
|
|
2812
2902
|
this.blockCache
|
|
@@ -2836,7 +2926,7 @@ class Wo {
|
|
|
2836
2926
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
2837
2927
|
*/
|
|
2838
2928
|
insertBlocks(e, t, o = "before") {
|
|
2839
|
-
|
|
2929
|
+
Tt(e, t, o, this._tiptapEditor);
|
|
2840
2930
|
}
|
|
2841
2931
|
/**
|
|
2842
2932
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -2846,14 +2936,14 @@ class Wo {
|
|
|
2846
2936
|
* @param update A partial block which defines how the existing block should be changed.
|
|
2847
2937
|
*/
|
|
2848
2938
|
updateBlock(e, t) {
|
|
2849
|
-
|
|
2939
|
+
Je(e, t, this._tiptapEditor);
|
|
2850
2940
|
}
|
|
2851
2941
|
/**
|
|
2852
2942
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
2853
2943
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
2854
2944
|
*/
|
|
2855
2945
|
removeBlocks(e) {
|
|
2856
|
-
|
|
2946
|
+
xt(e, this._tiptapEditor);
|
|
2857
2947
|
}
|
|
2858
2948
|
/**
|
|
2859
2949
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -2863,7 +2953,7 @@ class Wo {
|
|
|
2863
2953
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
2864
2954
|
*/
|
|
2865
2955
|
replaceBlocks(e, t) {
|
|
2866
|
-
|
|
2956
|
+
Xe(e, t, this._tiptapEditor);
|
|
2867
2957
|
}
|
|
2868
2958
|
/**
|
|
2869
2959
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -2955,7 +3045,7 @@ class Wo {
|
|
|
2955
3045
|
* Checks if the block containing the text cursor can be nested.
|
|
2956
3046
|
*/
|
|
2957
3047
|
canNestBlock() {
|
|
2958
|
-
const { startPos: e, depth: t } =
|
|
3048
|
+
const { startPos: e, depth: t } = k(
|
|
2959
3049
|
this._tiptapEditor.state.doc,
|
|
2960
3050
|
this._tiptapEditor.state.selection.from
|
|
2961
3051
|
);
|
|
@@ -2971,7 +3061,7 @@ class Wo {
|
|
|
2971
3061
|
* Checks if the block containing the text cursor is nested.
|
|
2972
3062
|
*/
|
|
2973
3063
|
canUnnestBlock() {
|
|
2974
|
-
const { depth: e } =
|
|
3064
|
+
const { depth: e } = k(
|
|
2975
3065
|
this._tiptapEditor.state.doc,
|
|
2976
3066
|
this._tiptapEditor.state.selection.from
|
|
2977
3067
|
);
|
|
@@ -2990,7 +3080,7 @@ class Wo {
|
|
|
2990
3080
|
* @returns The blocks, serialized as an HTML string.
|
|
2991
3081
|
*/
|
|
2992
3082
|
async blocksToHTML(e) {
|
|
2993
|
-
return
|
|
3083
|
+
return At(e, this._tiptapEditor.schema);
|
|
2994
3084
|
}
|
|
2995
3085
|
/**
|
|
2996
3086
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -3009,7 +3099,7 @@ class Wo {
|
|
|
3009
3099
|
* @returns The blocks, serialized as a Markdown string.
|
|
3010
3100
|
*/
|
|
3011
3101
|
async blocksToMarkdown(e) {
|
|
3012
|
-
return
|
|
3102
|
+
return to(e, this._tiptapEditor.schema);
|
|
3013
3103
|
}
|
|
3014
3104
|
/**
|
|
3015
3105
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -3019,7 +3109,7 @@ class Wo {
|
|
|
3019
3109
|
* @returns The blocks parsed from the Markdown string.
|
|
3020
3110
|
*/
|
|
3021
3111
|
async markdownToBlocks(e) {
|
|
3022
|
-
return
|
|
3112
|
+
return eo(e, this.schema, this._tiptapEditor.schema);
|
|
3023
3113
|
}
|
|
3024
3114
|
/**
|
|
3025
3115
|
* Updates the user info for the current user that's shown to other collaborators.
|
|
@@ -3033,29 +3123,33 @@ class Wo {
|
|
|
3033
3123
|
}
|
|
3034
3124
|
}
|
|
3035
3125
|
export {
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
ke as
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3126
|
+
Jo as BlockNoteEditor,
|
|
3127
|
+
Re as CustomBlockSerializerExtension,
|
|
3128
|
+
ro as FormattingToolbarProsemirrorPlugin,
|
|
3129
|
+
oo as FormattingToolbarView,
|
|
3130
|
+
ao as HyperlinkToolbarProsemirrorPlugin,
|
|
3131
|
+
mo as SideMenuProsemirrorPlugin,
|
|
3132
|
+
ho as SideMenuView,
|
|
3133
|
+
Fe as SlashMenuProsemirrorPlugin,
|
|
3134
|
+
ge as UnreachableCaseError,
|
|
3135
|
+
Wo as blockStyles,
|
|
3136
|
+
rt as camelToDataKebab,
|
|
3137
|
+
Ko as createBlockSpec,
|
|
3138
|
+
O as createTipTapBlock,
|
|
3139
|
+
St as defaultBlockSchema,
|
|
3140
|
+
P as defaultProps,
|
|
3141
|
+
Yo as formatKeyboardShortcut,
|
|
3142
|
+
no as formattingToolbarPluginKey,
|
|
3143
|
+
Ke as getBlockNoteExtensions,
|
|
3144
|
+
ko as getDefaultSlashMenuItems,
|
|
3145
|
+
so as hyperlinkToolbarPluginKey,
|
|
3146
|
+
ke as isAppleOS,
|
|
3147
|
+
v as mergeCSSClasses,
|
|
3148
|
+
ye as parse,
|
|
3149
|
+
be as propsToAttributes,
|
|
3150
|
+
ve as render,
|
|
3151
|
+
Ue as setupSuggestionsMenu,
|
|
3152
|
+
fo as sideMenuPluginKey,
|
|
3153
|
+
X as slashMenuPluginKey
|
|
3060
3154
|
};
|
|
3061
3155
|
//# sourceMappingURL=blocknote.js.map
|