@blocknote/core 0.8.5 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +705 -572
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +13 -17
- package/src/BlockNoteExtensions.ts +42 -27
- package/src/api/blockManipulation/blockManipulation.test.ts +2 -2
- package/src/api/blockManipulation/blockManipulation.ts +1 -1
- package/src/api/formatConversions/formatConversions.test.ts +2 -2
- package/src/api/formatConversions/formatConversions.ts +47 -3
- package/src/api/nodeConversions/nodeConversions.test.ts +6 -6
- package/src/api/nodeConversions/nodeConversions.ts +6 -6
- package/src/editor.module.css +0 -11
- package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +2 -2
- package/src/extensions/Blocks/api/block.ts +55 -22
- package/src/extensions/Blocks/api/blockTypes.ts +22 -3
- package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +27 -5
- 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 +20 -19
- 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/extensions/SideMenu/MultipleNodeSelection.ts +3 -3
- package/src/extensions/SideMenu/SideMenuPlugin.ts +9 -9
- package/src/extensions/UniqueID/UniqueID.ts +10 -9
- package/src/index.ts +1 -0
- package/src/shared/EventEmitter.ts +1 -0
- package/src/shared/plugins/suggestion/SuggestionPlugin.ts +6 -2
- 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/helpers/getBlockInfoFromPos.d.ts +9 -1
- 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/extensions/Blocks/nodes/TableCell.d.ts +5 -0
- package/types/src/extensions/Blocks/nodes/TableRow.d.ts +5 -0
- package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +1 -1
- package/types/src/index.d.ts +1 -0
- package/types/src/shared/utils.d.ts +1 -0
- package/src/node_modules/.vitest/results.json +0 -1
- package/types/src/EventEmitter.d.ts +0 -11
- package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +0 -0
- package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +0 -16
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +0 -55
- package/types/src/extensions/DraggableBlocks/MultipleNodeSelection.d.ts +0 -24
- package/types/src/extensions/FormattingToolbar/FormattingToolbarExtension.d.ts +0 -11
- package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +0 -10
- package/types/src/extensions/HyperlinkToolbar/HyperlinkMark.d.ts +0 -8
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +0 -0
- package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +0 -13
- package/types/src/extensions/SlashMenu/index.d.ts +0 -3
- package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +0 -12
package/dist/blocknote.js
CHANGED
|
@@ -1,43 +1,53 @@
|
|
|
1
|
-
var
|
|
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
|
|
12
|
-
import { History as
|
|
13
|
-
import { Italic as
|
|
14
|
-
import { Link as
|
|
15
|
-
import { Strike as
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Underline as
|
|
18
|
-
import { Slice as
|
|
19
|
-
import { PluginKey as S, Plugin as
|
|
20
|
-
import { v4 as
|
|
21
|
-
import * as
|
|
22
|
-
import { Decoration as
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
1
|
+
var Pt = Object.defineProperty;
|
|
2
|
+
var Ot = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var u = (n, e, t) => (Ot(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { Extension as T, Mark as lt, Node as U, InputRule as K, mergeAttributes as A, combineTransactionSteps as Dt, getChangedRanges as Rt, findChildrenInRange as Vt, findChildren as tt, findParentNode as zt, extensions as L, isTextSelection as Ut, isNodeSelection as Ft, posToDOMRect as q, getMarkRange as et, Editor as Gt } from "@tiptap/core";
|
|
5
|
+
import { Bold as $t } from "@tiptap/extension-bold";
|
|
6
|
+
import { Code as jt } from "@tiptap/extension-code";
|
|
7
|
+
import qt from "@tiptap/extension-collaboration";
|
|
8
|
+
import Wt from "@tiptap/extension-collaboration-cursor";
|
|
9
|
+
import { Dropcursor as Yt } from "@tiptap/extension-dropcursor";
|
|
10
|
+
import { Gapcursor as Kt } from "@tiptap/extension-gapcursor";
|
|
11
|
+
import { HardBreak as Jt } from "@tiptap/extension-hard-break";
|
|
12
|
+
import { History as Xt } from "@tiptap/extension-history";
|
|
13
|
+
import { Italic as Zt } from "@tiptap/extension-italic";
|
|
14
|
+
import { Link as Qt } from "@tiptap/extension-link";
|
|
15
|
+
import { Strike as te } from "@tiptap/extension-strike";
|
|
16
|
+
import { Text as ee } from "@tiptap/extension-text";
|
|
17
|
+
import { Underline as oe } from "@tiptap/extension-underline";
|
|
18
|
+
import { Slice as x, Fragment as _, DOMSerializer as W, DOMParser as ne } from "prosemirror-model";
|
|
19
|
+
import { PluginKey as S, Plugin as w, TextSelection as ot, Selection as j, NodeSelection as re } from "prosemirror-state";
|
|
20
|
+
import { v4 as ie } from "uuid";
|
|
21
|
+
import * as se from "prosemirror-view";
|
|
22
|
+
import { Decoration as V, DecorationSet as z } from "prosemirror-view";
|
|
23
|
+
import dt from "rehype-parse";
|
|
24
|
+
import ae from "rehype-remark";
|
|
25
|
+
import ct from "rehype-stringify";
|
|
26
|
+
import ut from "remark-gfm";
|
|
27
|
+
import le from "remark-parse";
|
|
28
|
+
import de, { defaultHandlers as ce } from "remark-rehype";
|
|
29
|
+
import ue from "remark-stringify";
|
|
30
30
|
import { unified as J } from "unified";
|
|
31
|
-
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 pe = "_bnEditor_1pmoa_3", he = "_bnRoot_1pmoa_19", fe = "_defaultStyles_1pmoa_34", me = "_dragPreview_1pmoa_57", H = {
|
|
33
|
+
bnEditor: pe,
|
|
34
|
+
bnRoot: he,
|
|
35
|
+
defaultStyles: fe,
|
|
36
|
+
dragPreview: me,
|
|
37
|
+
"collaboration-cursor__caret": "_collaboration-cursor__caret_1pmoa_63",
|
|
38
|
+
"collaboration-cursor__label": "_collaboration-cursor__label_1pmoa_74"
|
|
39
39
|
};
|
|
40
|
-
function
|
|
40
|
+
function pt(n) {
|
|
41
|
+
const e = n.attrs.id, t = n.firstChild, o = t.type, r = n.childCount === 2 ? n.lastChild.childCount : 0;
|
|
42
|
+
return {
|
|
43
|
+
id: e,
|
|
44
|
+
node: n,
|
|
45
|
+
contentNode: t,
|
|
46
|
+
contentType: o,
|
|
47
|
+
numChildBlocks: r
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function k(n, e) {
|
|
41
51
|
const o = n.nodeSize - 2;
|
|
42
52
|
if (e <= 1)
|
|
43
53
|
for (e = 1 + 1; n.resolve(e).parent.type.name !== "blockContainer" && e < o; )
|
|
@@ -57,19 +67,19 @@ function g(n, e) {
|
|
|
57
67
|
break;
|
|
58
68
|
l -= 1, s = r.node(l);
|
|
59
69
|
}
|
|
60
|
-
const
|
|
70
|
+
const { id: a, contentNode: d, contentType: c, numChildBlocks: h } = pt(s), p = r.start(l), f = r.end(l);
|
|
61
71
|
return {
|
|
62
72
|
id: a,
|
|
63
73
|
node: s,
|
|
64
74
|
contentNode: d,
|
|
65
75
|
contentType: c,
|
|
66
|
-
numChildBlocks:
|
|
67
|
-
startPos:
|
|
76
|
+
numChildBlocks: h,
|
|
77
|
+
startPos: p,
|
|
68
78
|
endPos: f,
|
|
69
79
|
depth: l
|
|
70
80
|
};
|
|
71
81
|
}
|
|
72
|
-
const
|
|
82
|
+
const ke = T.create({
|
|
73
83
|
name: "blockBackgroundColor",
|
|
74
84
|
addGlobalAttributes() {
|
|
75
85
|
return [
|
|
@@ -90,7 +100,7 @@ const he = B.create({
|
|
|
90
100
|
addCommands() {
|
|
91
101
|
return {
|
|
92
102
|
setBlockBackgroundColor: (n, e) => ({ state: t, view: o }) => {
|
|
93
|
-
const r =
|
|
103
|
+
const r = k(t.doc, n);
|
|
94
104
|
return r === void 0 ? !1 : (t.tr.setNodeAttribute(
|
|
95
105
|
r.startPos - 1,
|
|
96
106
|
"backgroundColor",
|
|
@@ -99,7 +109,7 @@ const he = B.create({
|
|
|
99
109
|
}
|
|
100
110
|
};
|
|
101
111
|
}
|
|
102
|
-
}),
|
|
112
|
+
}), ge = lt.create({
|
|
103
113
|
name: "backgroundColor",
|
|
104
114
|
addAttributes() {
|
|
105
115
|
return {
|
|
@@ -128,33 +138,44 @@ const he = B.create({
|
|
|
128
138
|
setBackgroundColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
129
139
|
};
|
|
130
140
|
}
|
|
131
|
-
}),
|
|
132
|
-
blockOuter:
|
|
133
|
-
block:
|
|
134
|
-
reactNodeViewRenderer:
|
|
135
|
-
blockContent:
|
|
136
|
-
blockGroup:
|
|
137
|
-
isEmpty:
|
|
138
|
-
inlineContent:
|
|
139
|
-
isFilter:
|
|
140
|
-
hasAnchor:
|
|
141
|
-
},
|
|
141
|
+
}), ht = "_blockOuter_7sok8_5", ft = "_block_7sok8_5", mt = "_reactNodeViewRenderer_7sok8_17", kt = "_blockContent_7sok8_22", gt = "_blockGroup_7sok8_42", bt = "_isEmpty_7sok8_240", yt = "_inlineContent_7sok8_240", vt = "_isFilter_7sok8_241", Ct = "_hasAnchor_7sok8_263", y = {
|
|
142
|
+
blockOuter: ht,
|
|
143
|
+
block: ft,
|
|
144
|
+
reactNodeViewRenderer: mt,
|
|
145
|
+
blockContent: kt,
|
|
146
|
+
blockGroup: gt,
|
|
147
|
+
isEmpty: bt,
|
|
148
|
+
inlineContent: yt,
|
|
149
|
+
isFilter: vt,
|
|
150
|
+
hasAnchor: Ct
|
|
151
|
+
}, Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
142
152
|
__proto__: null,
|
|
143
|
-
block:
|
|
144
|
-
blockContent:
|
|
145
|
-
blockGroup:
|
|
146
|
-
blockOuter:
|
|
147
|
-
default:
|
|
148
|
-
hasAnchor:
|
|
149
|
-
inlineContent:
|
|
150
|
-
isEmpty:
|
|
151
|
-
isFilter:
|
|
152
|
-
reactNodeViewRenderer:
|
|
153
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
154
|
-
function
|
|
153
|
+
block: ft,
|
|
154
|
+
blockContent: kt,
|
|
155
|
+
blockGroup: gt,
|
|
156
|
+
blockOuter: ht,
|
|
157
|
+
default: y,
|
|
158
|
+
hasAnchor: Ct,
|
|
159
|
+
inlineContent: yt,
|
|
160
|
+
isEmpty: bt,
|
|
161
|
+
isFilter: vt,
|
|
162
|
+
reactNodeViewRenderer: mt
|
|
163
|
+
}, Symbol.toStringTag, { value: "Module" })), be = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
|
164
|
+
function Xo(n) {
|
|
165
|
+
return be() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
|
|
166
|
+
}
|
|
167
|
+
function v(...n) {
|
|
168
|
+
return n.filter((e) => e).join(" ");
|
|
169
|
+
}
|
|
170
|
+
class ye extends Error {
|
|
171
|
+
constructor(e) {
|
|
172
|
+
super(`Unreachable case: ${e}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function rt(n) {
|
|
155
176
|
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
156
177
|
}
|
|
157
|
-
function
|
|
178
|
+
function ve(n) {
|
|
158
179
|
const e = {};
|
|
159
180
|
return Object.entries(n.propSchema).forEach(([t, o]) => {
|
|
160
181
|
e[t] = {
|
|
@@ -163,21 +184,21 @@ function me(n) {
|
|
|
163
184
|
// Props are displayed in kebab-case as HTML attributes. If a prop's
|
|
164
185
|
// value is the same as its default, we don't display an HTML
|
|
165
186
|
// attribute for it.
|
|
166
|
-
parseHTML: (r) => r.getAttribute(
|
|
187
|
+
parseHTML: (r) => r.getAttribute(rt(t)),
|
|
167
188
|
renderHTML: (r) => r[t] !== o.default ? {
|
|
168
|
-
[
|
|
189
|
+
[rt(t)]: r[t]
|
|
169
190
|
} : {}
|
|
170
191
|
};
|
|
171
192
|
}), e;
|
|
172
193
|
}
|
|
173
|
-
function
|
|
194
|
+
function Ce(n) {
|
|
174
195
|
return [
|
|
175
196
|
{
|
|
176
197
|
tag: "div[data-content-type=" + n.type + "]"
|
|
177
198
|
}
|
|
178
199
|
];
|
|
179
200
|
}
|
|
180
|
-
function
|
|
201
|
+
function we(n, e) {
|
|
181
202
|
const t = document.createElement("div");
|
|
182
203
|
t.setAttribute("data-content-type", n.type);
|
|
183
204
|
for (const [r, i] of Object.entries(e))
|
|
@@ -190,42 +211,57 @@ function ke(n, e) {
|
|
|
190
211
|
dom: t
|
|
191
212
|
};
|
|
192
213
|
}
|
|
193
|
-
function
|
|
214
|
+
function Zo(n) {
|
|
194
215
|
return {
|
|
195
|
-
node:
|
|
216
|
+
node: O({
|
|
196
217
|
name: n.type,
|
|
197
218
|
content: n.containsInlineContent ? "inline*" : "",
|
|
198
219
|
selectable: n.containsInlineContent,
|
|
199
|
-
addOptions() {
|
|
200
|
-
return {
|
|
201
|
-
editor: void 0
|
|
202
|
-
};
|
|
203
|
-
},
|
|
204
220
|
addAttributes() {
|
|
205
|
-
return
|
|
221
|
+
return ve(n);
|
|
206
222
|
},
|
|
207
223
|
parseHTML() {
|
|
208
|
-
return
|
|
224
|
+
return Ce(n);
|
|
209
225
|
},
|
|
210
226
|
renderHTML({ HTMLAttributes: t }) {
|
|
211
|
-
return
|
|
227
|
+
return we(n, t);
|
|
212
228
|
},
|
|
213
229
|
addNodeView() {
|
|
214
230
|
return ({ HTMLAttributes: t, getPos: o }) => {
|
|
215
|
-
|
|
216
|
-
r
|
|
217
|
-
for (const [
|
|
218
|
-
|
|
219
|
-
|
|
231
|
+
var f, m;
|
|
232
|
+
const r = document.createElement("div"), i = ((f = this.options.domAttributes) == null ? void 0 : f.blockContent) || {};
|
|
233
|
+
for (const [g, b] of Object.entries(
|
|
234
|
+
i
|
|
235
|
+
))
|
|
236
|
+
g !== "class" && r.setAttribute(g, b);
|
|
237
|
+
r.className = v(
|
|
238
|
+
y.blockContent,
|
|
239
|
+
i.class
|
|
240
|
+
), r.setAttribute("data-content-type", n.type);
|
|
241
|
+
for (const [g, b] of Object.entries(t))
|
|
242
|
+
r.setAttribute(g, b);
|
|
243
|
+
const s = this.options.editor;
|
|
220
244
|
if (typeof o == "boolean")
|
|
221
245
|
throw new Error(
|
|
222
246
|
"Cannot find node position as getPos is a boolean, not a function."
|
|
223
247
|
);
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
248
|
+
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, h = s.getBlock(c);
|
|
249
|
+
if (h.type !== n.type)
|
|
226
250
|
throw new Error("Block type does not match");
|
|
227
|
-
const p = n.render(
|
|
228
|
-
|
|
251
|
+
const p = n.render(h, s);
|
|
252
|
+
if ("contentDOM" in p) {
|
|
253
|
+
const g = ((m = this.options.domAttributes) == null ? void 0 : m.inlineContent) || {};
|
|
254
|
+
for (const [b, C] of Object.entries(
|
|
255
|
+
g
|
|
256
|
+
))
|
|
257
|
+
b !== "class" && p.contentDOM.setAttribute(b, C);
|
|
258
|
+
p.contentDOM.className = v(
|
|
259
|
+
p.contentDOM.className,
|
|
260
|
+
y.inlineContent,
|
|
261
|
+
g.class
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
return r.appendChild(p.dom), "contentDOM" in p ? {
|
|
229
265
|
dom: r,
|
|
230
266
|
contentDOM: p.contentDOM
|
|
231
267
|
} : {
|
|
@@ -237,13 +273,13 @@ function qo(n) {
|
|
|
237
273
|
propSchema: n.propSchema
|
|
238
274
|
};
|
|
239
275
|
}
|
|
240
|
-
function
|
|
241
|
-
return
|
|
276
|
+
function O(n) {
|
|
277
|
+
return U.create({
|
|
242
278
|
...n,
|
|
243
279
|
group: "blockContent"
|
|
244
280
|
});
|
|
245
281
|
}
|
|
246
|
-
const
|
|
282
|
+
const Se = O({
|
|
247
283
|
name: "heading",
|
|
248
284
|
content: "inline*",
|
|
249
285
|
addAttributes() {
|
|
@@ -260,7 +296,7 @@ const be = P({
|
|
|
260
296
|
},
|
|
261
297
|
addInputRules() {
|
|
262
298
|
return [
|
|
263
|
-
...["1", "2", "3"].map((n) => new
|
|
299
|
+
...["1", "2", "3"].map((n) => new K({
|
|
264
300
|
find: new RegExp(`^(#{${parseInt(n)}})\\s$`),
|
|
265
301
|
handler: ({ state: e, chain: t, range: o }) => {
|
|
266
302
|
t().BNUpdateBlock(e.selection.from, {
|
|
@@ -293,17 +329,31 @@ const be = P({
|
|
|
293
329
|
];
|
|
294
330
|
},
|
|
295
331
|
renderHTML({ node: n, HTMLAttributes: e }) {
|
|
332
|
+
var r, i;
|
|
333
|
+
const t = ((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {}, o = ((i = this.options.domAttributes) == null ? void 0 : i.inlineContent) || {};
|
|
296
334
|
return [
|
|
297
335
|
"div",
|
|
298
|
-
|
|
299
|
-
class:
|
|
336
|
+
A(e, {
|
|
337
|
+
class: v(
|
|
338
|
+
y.blockContent,
|
|
339
|
+
t.class
|
|
340
|
+
),
|
|
300
341
|
"data-content-type": this.name
|
|
301
342
|
}),
|
|
302
|
-
[
|
|
343
|
+
[
|
|
344
|
+
"h" + n.attrs.level,
|
|
345
|
+
{
|
|
346
|
+
class: v(
|
|
347
|
+
y.inlineContent,
|
|
348
|
+
o.class
|
|
349
|
+
)
|
|
350
|
+
},
|
|
351
|
+
0
|
|
352
|
+
]
|
|
303
353
|
];
|
|
304
354
|
}
|
|
305
|
-
}),
|
|
306
|
-
const { node: e, contentType: t } =
|
|
355
|
+
}), wt = (n) => {
|
|
356
|
+
const { node: e, contentType: t } = k(
|
|
307
357
|
n.state.doc,
|
|
308
358
|
n.state.selection.from
|
|
309
359
|
), o = n.state.selection.anchor === n.state.selection.head;
|
|
@@ -321,13 +371,13 @@ const be = P({
|
|
|
321
371
|
s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
322
372
|
)
|
|
323
373
|
]);
|
|
324
|
-
},
|
|
374
|
+
}, Me = O({
|
|
325
375
|
name: "bulletListItem",
|
|
326
376
|
content: "inline*",
|
|
327
377
|
addInputRules() {
|
|
328
378
|
return [
|
|
329
379
|
// Creates an unordered list when starting with "-", "+", or "*".
|
|
330
|
-
new
|
|
380
|
+
new K({
|
|
331
381
|
find: new RegExp("^[-+*]\\s$"),
|
|
332
382
|
handler: ({ state: n, chain: e, range: t }) => {
|
|
333
383
|
e().BNUpdateBlock(n.selection.from, {
|
|
@@ -340,7 +390,7 @@ const be = P({
|
|
|
340
390
|
},
|
|
341
391
|
addKeyboardShortcuts() {
|
|
342
392
|
return {
|
|
343
|
-
Enter: () =>
|
|
393
|
+
Enter: () => wt(this.editor)
|
|
344
394
|
};
|
|
345
395
|
},
|
|
346
396
|
parseHTML() {
|
|
@@ -371,17 +421,31 @@ const be = P({
|
|
|
371
421
|
];
|
|
372
422
|
},
|
|
373
423
|
renderHTML({ HTMLAttributes: n }) {
|
|
424
|
+
var o, r;
|
|
425
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
374
426
|
return [
|
|
375
427
|
"div",
|
|
376
|
-
|
|
377
|
-
class:
|
|
428
|
+
A(n, {
|
|
429
|
+
class: v(
|
|
430
|
+
y.blockContent,
|
|
431
|
+
e.class
|
|
432
|
+
),
|
|
378
433
|
"data-content-type": this.name
|
|
379
434
|
}),
|
|
380
|
-
[
|
|
435
|
+
[
|
|
436
|
+
"p",
|
|
437
|
+
{
|
|
438
|
+
class: v(
|
|
439
|
+
y.inlineContent,
|
|
440
|
+
t.class
|
|
441
|
+
)
|
|
442
|
+
},
|
|
443
|
+
0
|
|
444
|
+
]
|
|
381
445
|
];
|
|
382
446
|
}
|
|
383
|
-
}),
|
|
384
|
-
key:
|
|
447
|
+
}), Ee = new S("numbered-list-indexing"), Be = () => new w({
|
|
448
|
+
key: Ee,
|
|
385
449
|
appendTransaction: (n, e, t) => {
|
|
386
450
|
const o = t.tr;
|
|
387
451
|
o.setMeta("numberedListIndexing", !0);
|
|
@@ -389,18 +453,18 @@ const be = P({
|
|
|
389
453
|
return t.doc.descendants((i, s) => {
|
|
390
454
|
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
391
455
|
let l = "1";
|
|
392
|
-
const a = s === 1, d =
|
|
456
|
+
const a = s === 1, d = k(o.doc, s + 1);
|
|
393
457
|
if (d === void 0)
|
|
394
458
|
return;
|
|
395
459
|
if (!a) {
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
460
|
+
const p = k(o.doc, s - 2);
|
|
461
|
+
if (p === void 0)
|
|
398
462
|
return;
|
|
399
|
-
if (!(d.depth !==
|
|
400
|
-
const m =
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
403
|
-
l = (parseInt(
|
|
463
|
+
if (!(d.depth !== p.depth)) {
|
|
464
|
+
const m = p.contentNode;
|
|
465
|
+
if (p.contentType.name === "numberedListItem") {
|
|
466
|
+
const C = m.attrs.index;
|
|
467
|
+
l = (parseInt(C) + 1).toString();
|
|
404
468
|
}
|
|
405
469
|
}
|
|
406
470
|
}
|
|
@@ -410,7 +474,7 @@ const be = P({
|
|
|
410
474
|
}
|
|
411
475
|
}), r ? o : null;
|
|
412
476
|
}
|
|
413
|
-
}),
|
|
477
|
+
}), Te = O({
|
|
414
478
|
name: "numberedListItem",
|
|
415
479
|
content: "inline*",
|
|
416
480
|
addAttributes() {
|
|
@@ -427,7 +491,7 @@ const be = P({
|
|
|
427
491
|
addInputRules() {
|
|
428
492
|
return [
|
|
429
493
|
// Creates an ordered list when starting with "1.".
|
|
430
|
-
new
|
|
494
|
+
new K({
|
|
431
495
|
find: new RegExp("^1\\.\\s$"),
|
|
432
496
|
handler: ({ state: n, chain: e, range: t }) => {
|
|
433
497
|
e().BNUpdateBlock(n.selection.from, {
|
|
@@ -440,11 +504,11 @@ const be = P({
|
|
|
440
504
|
},
|
|
441
505
|
addKeyboardShortcuts() {
|
|
442
506
|
return {
|
|
443
|
-
Enter: () =>
|
|
507
|
+
Enter: () => wt(this.editor)
|
|
444
508
|
};
|
|
445
509
|
},
|
|
446
510
|
addProseMirrorPlugins() {
|
|
447
|
-
return [
|
|
511
|
+
return [Be()];
|
|
448
512
|
},
|
|
449
513
|
parseHTML() {
|
|
450
514
|
return [
|
|
@@ -476,18 +540,32 @@ const be = P({
|
|
|
476
540
|
];
|
|
477
541
|
},
|
|
478
542
|
renderHTML({ HTMLAttributes: n }) {
|
|
543
|
+
var o, r;
|
|
544
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
479
545
|
return [
|
|
480
546
|
"div",
|
|
481
|
-
|
|
482
|
-
class:
|
|
547
|
+
A(n, {
|
|
548
|
+
class: v(
|
|
549
|
+
y.blockContent,
|
|
550
|
+
e.class
|
|
551
|
+
),
|
|
483
552
|
"data-content-type": this.name
|
|
484
553
|
}),
|
|
485
554
|
// 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
555
|
// which would be quite cumbersome
|
|
487
|
-
[
|
|
556
|
+
[
|
|
557
|
+
"p",
|
|
558
|
+
{
|
|
559
|
+
class: v(
|
|
560
|
+
y.inlineContent,
|
|
561
|
+
t.class
|
|
562
|
+
)
|
|
563
|
+
},
|
|
564
|
+
0
|
|
565
|
+
]
|
|
488
566
|
];
|
|
489
567
|
}
|
|
490
|
-
}),
|
|
568
|
+
}), xe = O({
|
|
491
569
|
name: "paragraph",
|
|
492
570
|
content: "inline*",
|
|
493
571
|
parseHTML() {
|
|
@@ -500,16 +578,35 @@ const be = P({
|
|
|
500
578
|
];
|
|
501
579
|
},
|
|
502
580
|
renderHTML({ HTMLAttributes: n }) {
|
|
581
|
+
var o, r;
|
|
582
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
503
583
|
return [
|
|
504
584
|
"div",
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
585
|
+
A(
|
|
586
|
+
{
|
|
587
|
+
...e,
|
|
588
|
+
class: v(
|
|
589
|
+
y.blockContent,
|
|
590
|
+
e.class
|
|
591
|
+
),
|
|
592
|
+
"data-content-type": this.name
|
|
593
|
+
},
|
|
594
|
+
n
|
|
595
|
+
),
|
|
596
|
+
[
|
|
597
|
+
"p",
|
|
598
|
+
{
|
|
599
|
+
...t,
|
|
600
|
+
class: v(
|
|
601
|
+
y.inlineContent,
|
|
602
|
+
t.class
|
|
603
|
+
)
|
|
604
|
+
},
|
|
605
|
+
0
|
|
606
|
+
]
|
|
510
607
|
];
|
|
511
608
|
}
|
|
512
|
-
}),
|
|
609
|
+
}), P = {
|
|
513
610
|
backgroundColor: {
|
|
514
611
|
default: "transparent"
|
|
515
612
|
},
|
|
@@ -521,41 +618,41 @@ const be = P({
|
|
|
521
618
|
default: "left",
|
|
522
619
|
values: ["left", "center", "right", "justify"]
|
|
523
620
|
}
|
|
524
|
-
},
|
|
621
|
+
}, St = {
|
|
525
622
|
paragraph: {
|
|
526
|
-
propSchema:
|
|
527
|
-
node:
|
|
623
|
+
propSchema: P,
|
|
624
|
+
node: xe
|
|
528
625
|
},
|
|
529
626
|
heading: {
|
|
530
627
|
propSchema: {
|
|
531
|
-
...
|
|
628
|
+
...P,
|
|
532
629
|
level: { default: "1", values: ["1", "2", "3"] }
|
|
533
630
|
},
|
|
534
|
-
node:
|
|
631
|
+
node: Se
|
|
535
632
|
},
|
|
536
633
|
bulletListItem: {
|
|
537
|
-
propSchema:
|
|
538
|
-
node:
|
|
634
|
+
propSchema: P,
|
|
635
|
+
node: Me
|
|
539
636
|
},
|
|
540
637
|
numberedListItem: {
|
|
541
|
-
propSchema:
|
|
542
|
-
node:
|
|
638
|
+
propSchema: P,
|
|
639
|
+
node: Te
|
|
543
640
|
}
|
|
544
641
|
};
|
|
545
|
-
function
|
|
642
|
+
function Ae(n, e = JSON.stringify) {
|
|
546
643
|
const t = {};
|
|
547
644
|
return n.filter((o) => {
|
|
548
645
|
const r = e(o);
|
|
549
646
|
return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
|
|
550
647
|
});
|
|
551
648
|
}
|
|
552
|
-
function
|
|
649
|
+
function Ie(n) {
|
|
553
650
|
const e = n.filter(
|
|
554
651
|
(o, r) => n.indexOf(o) !== r
|
|
555
652
|
);
|
|
556
|
-
return
|
|
653
|
+
return Ae(e);
|
|
557
654
|
}
|
|
558
|
-
const
|
|
655
|
+
const F = T.create({
|
|
559
656
|
name: "uniqueID",
|
|
560
657
|
// we’ll set a very high priority to make sure this runs first
|
|
561
658
|
// and is compatible with `appendTransaction` hooks of other extensions
|
|
@@ -564,7 +661,13 @@ const U = B.create({
|
|
|
564
661
|
return {
|
|
565
662
|
attributeName: "id",
|
|
566
663
|
types: [],
|
|
567
|
-
generateID: () =>
|
|
664
|
+
generateID: () => {
|
|
665
|
+
if (typeof window < "u" && window.__TEST_OPTIONS) {
|
|
666
|
+
const n = window.__TEST_OPTIONS;
|
|
667
|
+
return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
|
|
668
|
+
}
|
|
669
|
+
return ie();
|
|
670
|
+
},
|
|
568
671
|
filterTransaction: null
|
|
569
672
|
};
|
|
570
673
|
},
|
|
@@ -617,38 +720,38 @@ const U = B.create({
|
|
|
617
720
|
addProseMirrorPlugins() {
|
|
618
721
|
let n = null, e = !1;
|
|
619
722
|
return [
|
|
620
|
-
new
|
|
723
|
+
new w({
|
|
621
724
|
key: new S("uniqueID"),
|
|
622
725
|
appendTransaction: (t, o, r) => {
|
|
623
726
|
const i = t.some((m) => m.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && t.some((m) => {
|
|
624
|
-
|
|
625
|
-
return !(!((
|
|
727
|
+
let g, b;
|
|
728
|
+
return !(!((b = (g = this.options).filterTransaction) === null || b === void 0) && b.call(g, m));
|
|
626
729
|
});
|
|
627
730
|
if (!i || s)
|
|
628
731
|
return;
|
|
629
|
-
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options,
|
|
732
|
+
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h = Dt(
|
|
630
733
|
o.doc,
|
|
631
734
|
t
|
|
632
|
-
), { mapping:
|
|
633
|
-
if (
|
|
634
|
-
const
|
|
735
|
+
), { mapping: p } = h;
|
|
736
|
+
if (Rt(h).forEach(({ newRange: m }) => {
|
|
737
|
+
const g = Vt(
|
|
635
738
|
r.doc,
|
|
636
739
|
m,
|
|
637
|
-
(
|
|
638
|
-
),
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
if (
|
|
643
|
-
l.setNodeMarkup(
|
|
644
|
-
...
|
|
740
|
+
(M) => a.includes(M.type.name)
|
|
741
|
+
), b = g.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C = Ie(b);
|
|
742
|
+
g.forEach(({ node: M, pos: R }) => {
|
|
743
|
+
let $;
|
|
744
|
+
const Q = ($ = l.doc.nodeAt(R)) === null || $ === void 0 ? void 0 : $.attrs[d];
|
|
745
|
+
if (Q === null) {
|
|
746
|
+
l.setNodeMarkup(R, void 0, {
|
|
747
|
+
...M.attrs,
|
|
645
748
|
[d]: c()
|
|
646
749
|
});
|
|
647
750
|
return;
|
|
648
751
|
}
|
|
649
|
-
const { deleted:
|
|
650
|
-
|
|
651
|
-
...
|
|
752
|
+
const { deleted: Lt } = p.invert().mapResult(R);
|
|
753
|
+
Lt && C.includes(Q) && l.setNodeMarkup(R, void 0, {
|
|
754
|
+
...M.attrs,
|
|
652
755
|
[d]: c()
|
|
653
756
|
});
|
|
654
757
|
});
|
|
@@ -658,7 +761,7 @@ const U = B.create({
|
|
|
658
761
|
// we register a global drag handler to track the current drag source element
|
|
659
762
|
view(t) {
|
|
660
763
|
const o = (r) => {
|
|
661
|
-
|
|
764
|
+
let i;
|
|
662
765
|
n = !((i = t.dom.parentElement) === null || i === void 0) && i.contains(r.target) ? t.dom.parentElement : null;
|
|
663
766
|
};
|
|
664
767
|
return window.addEventListener("dragstart", o), {
|
|
@@ -674,7 +777,7 @@ const U = B.create({
|
|
|
674
777
|
// only create new ids for dropped content while holding `alt`
|
|
675
778
|
// or content is dragged from another editor
|
|
676
779
|
drop: (t, o) => {
|
|
677
|
-
|
|
780
|
+
let r;
|
|
678
781
|
return (n !== t.dom.parentElement || ((r = o.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy") && (n = null, e = !0), !1;
|
|
679
782
|
},
|
|
680
783
|
// always create new ids on pasted content
|
|
@@ -705,9 +808,9 @@ const U = B.create({
|
|
|
705
808
|
a.marks
|
|
706
809
|
);
|
|
707
810
|
l.push(d);
|
|
708
|
-
}),
|
|
811
|
+
}), _.from(l);
|
|
709
812
|
};
|
|
710
|
-
return e = !1, new
|
|
813
|
+
return e = !1, new x(
|
|
711
814
|
i(t.content),
|
|
712
815
|
t.openStart,
|
|
713
816
|
t.openEnd
|
|
@@ -717,31 +820,25 @@ const U = B.create({
|
|
|
717
820
|
})
|
|
718
821
|
];
|
|
719
822
|
}
|
|
720
|
-
})
|
|
721
|
-
class Be extends Error {
|
|
722
|
-
constructor(e) {
|
|
723
|
-
super(`Unreachable case: ${e}`);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
const St = /* @__PURE__ */ new Set([
|
|
823
|
+
}), Mt = /* @__PURE__ */ new Set([
|
|
727
824
|
"bold",
|
|
728
825
|
"italic",
|
|
729
826
|
"underline",
|
|
730
827
|
"strike",
|
|
731
828
|
"code"
|
|
732
|
-
]),
|
|
733
|
-
function
|
|
829
|
+
]), Et = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
830
|
+
function it(n, e) {
|
|
734
831
|
const t = [];
|
|
735
832
|
for (const [o, r] of Object.entries(n.styles))
|
|
736
|
-
|
|
833
|
+
Mt.has(o) ? t.push(e.mark(o)) : Et.has(o) && t.push(e.mark(o, { color: r }));
|
|
737
834
|
return n.text.split(/(\n)/g).filter((o) => o.length > 0).map((o) => o === `
|
|
738
835
|
` ? e.nodes.hardBreak.create() : e.text(o, t));
|
|
739
836
|
}
|
|
740
|
-
function
|
|
837
|
+
function _e(n, e) {
|
|
741
838
|
const t = e.marks.link.create({
|
|
742
839
|
href: n.href
|
|
743
840
|
});
|
|
744
|
-
return
|
|
841
|
+
return Bt(n.content, e).map((o) => {
|
|
745
842
|
if (o.type.name === "text")
|
|
746
843
|
return o.mark([...o.marks, t]);
|
|
747
844
|
if (o.type.name === "hardBreak")
|
|
@@ -749,30 +846,30 @@ function Te(n, e) {
|
|
|
749
846
|
throw new Error("unexpected node type");
|
|
750
847
|
});
|
|
751
848
|
}
|
|
752
|
-
function
|
|
753
|
-
|
|
849
|
+
function Bt(n, e) {
|
|
850
|
+
const t = [];
|
|
754
851
|
if (typeof n == "string")
|
|
755
852
|
return t.push(
|
|
756
|
-
...
|
|
853
|
+
...it({ type: "text", text: n, styles: {} }, e)
|
|
757
854
|
), t;
|
|
758
855
|
for (const o of n)
|
|
759
|
-
t.push(...
|
|
856
|
+
t.push(...it(o, e));
|
|
760
857
|
return t;
|
|
761
858
|
}
|
|
762
|
-
function
|
|
763
|
-
|
|
859
|
+
function Tt(n, e) {
|
|
860
|
+
const t = [];
|
|
764
861
|
for (const o of n)
|
|
765
862
|
if (o.type === "link")
|
|
766
|
-
t.push(...
|
|
863
|
+
t.push(..._e(o, e));
|
|
767
864
|
else if (o.type === "text")
|
|
768
|
-
t.push(...
|
|
865
|
+
t.push(...Bt([o], e));
|
|
769
866
|
else
|
|
770
|
-
throw new
|
|
867
|
+
throw new ye(o);
|
|
771
868
|
return t;
|
|
772
869
|
}
|
|
773
|
-
function
|
|
870
|
+
function D(n, e) {
|
|
774
871
|
let t = n.id;
|
|
775
|
-
t === void 0 && (t =
|
|
872
|
+
t === void 0 && (t = F.options.generateID());
|
|
776
873
|
let o = n.type;
|
|
777
874
|
o === void 0 && (o = "paragraph");
|
|
778
875
|
let r;
|
|
@@ -784,13 +881,13 @@ function O(n, e) {
|
|
|
784
881
|
e.text(n.content)
|
|
785
882
|
);
|
|
786
883
|
else {
|
|
787
|
-
const l =
|
|
884
|
+
const l = Tt(n.content, e);
|
|
788
885
|
r = e.nodes[o].create(n.props, l);
|
|
789
886
|
}
|
|
790
887
|
const i = [];
|
|
791
888
|
if (n.children)
|
|
792
889
|
for (const l of n.children)
|
|
793
|
-
i.push(
|
|
890
|
+
i.push(D(l, e));
|
|
794
891
|
const s = e.nodes.blockGroup.create({}, i);
|
|
795
892
|
return e.nodes.blockContainer.create(
|
|
796
893
|
{
|
|
@@ -800,7 +897,7 @@ function O(n, e) {
|
|
|
800
897
|
i.length > 0 ? [r, s] : r
|
|
801
898
|
);
|
|
802
899
|
}
|
|
803
|
-
function
|
|
900
|
+
function He(n) {
|
|
804
901
|
const e = [];
|
|
805
902
|
let t;
|
|
806
903
|
return n.content.forEach((o) => {
|
|
@@ -820,9 +917,9 @@ function xe(n) {
|
|
|
820
917
|
for (const s of o.marks)
|
|
821
918
|
if (s.type.name === "link")
|
|
822
919
|
i = s;
|
|
823
|
-
else if (
|
|
920
|
+
else if (Mt.has(s.type.name))
|
|
824
921
|
r[s.type.name] = !0;
|
|
825
|
-
else if (
|
|
922
|
+
else if (Et.has(s.type.name))
|
|
826
923
|
r[s.type.name] = s.attrs.color;
|
|
827
924
|
else
|
|
828
925
|
throw Error("Mark is of an unrecognized type: " + s.type.name);
|
|
@@ -877,7 +974,7 @@ function xe(n) {
|
|
|
877
974
|
};
|
|
878
975
|
}), t && e.push(t), e;
|
|
879
976
|
}
|
|
880
|
-
function
|
|
977
|
+
function E(n, e, t) {
|
|
881
978
|
if (n.type.name !== "blockContainer")
|
|
882
979
|
throw Error(
|
|
883
980
|
"Node must be of type blockContainer, but is of type" + n.type.name + "."
|
|
@@ -885,26 +982,26 @@ function M(n, e, t) {
|
|
|
885
982
|
const o = t == null ? void 0 : t.get(n);
|
|
886
983
|
if (o)
|
|
887
984
|
return o;
|
|
888
|
-
const r =
|
|
985
|
+
const r = pt(n);
|
|
889
986
|
let i = r.id;
|
|
890
|
-
i === null && (i =
|
|
987
|
+
i === null && (i = F.options.generateID());
|
|
891
988
|
const s = {};
|
|
892
|
-
for (const [c,
|
|
893
|
-
...
|
|
989
|
+
for (const [c, h] of Object.entries({
|
|
990
|
+
...n.attrs,
|
|
894
991
|
...r.contentNode.attrs
|
|
895
992
|
})) {
|
|
896
|
-
const
|
|
897
|
-
if (!
|
|
993
|
+
const p = e[r.contentType.name];
|
|
994
|
+
if (!p)
|
|
898
995
|
throw Error(
|
|
899
996
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
900
997
|
);
|
|
901
|
-
const f =
|
|
902
|
-
c in f ? s[c] =
|
|
998
|
+
const f = p.propSchema;
|
|
999
|
+
c in f ? s[c] = h : c !== "id" && !(c in P) && console.warn("Block has an unrecognized attribute: " + c);
|
|
903
1000
|
}
|
|
904
|
-
const l =
|
|
1001
|
+
const l = He(r.contentNode), a = [];
|
|
905
1002
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
906
1003
|
a.push(
|
|
907
|
-
|
|
1004
|
+
E(n.lastChild.child(c), e, t)
|
|
908
1005
|
);
|
|
909
1006
|
const d = {
|
|
910
1007
|
id: i,
|
|
@@ -915,7 +1012,7 @@ function M(n, e, t) {
|
|
|
915
1012
|
};
|
|
916
1013
|
return t == null || t.set(n, d), d;
|
|
917
1014
|
}
|
|
918
|
-
const
|
|
1015
|
+
const st = new S("previous-blocks"), Ne = {
|
|
919
1016
|
// Numbered List Items
|
|
920
1017
|
index: "index",
|
|
921
1018
|
// Headings
|
|
@@ -924,17 +1021,17 @@ const it = new S("previous-blocks"), _e = {
|
|
|
924
1021
|
type: "type",
|
|
925
1022
|
depth: "depth",
|
|
926
1023
|
"depth-change": "depth-change"
|
|
927
|
-
},
|
|
1024
|
+
}, Le = () => {
|
|
928
1025
|
let n;
|
|
929
|
-
return new
|
|
930
|
-
key:
|
|
1026
|
+
return new w({
|
|
1027
|
+
key: st,
|
|
931
1028
|
view(e) {
|
|
932
1029
|
return {
|
|
933
1030
|
update: async (t, o) => {
|
|
934
1031
|
var r;
|
|
935
1032
|
((r = this.key) == null ? void 0 : r.getState(t.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
936
1033
|
t.dispatch(
|
|
937
|
-
t.state.tr.setMeta(
|
|
1034
|
+
t.state.tr.setMeta(st, { clearUpdate: !0 })
|
|
938
1035
|
);
|
|
939
1036
|
}, 0));
|
|
940
1037
|
},
|
|
@@ -957,22 +1054,22 @@ const it = new S("previous-blocks"), _e = {
|
|
|
957
1054
|
apply(e, t, o, r) {
|
|
958
1055
|
if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || o.doc.eq(r.doc))
|
|
959
1056
|
return t;
|
|
960
|
-
const i = {}, s =
|
|
1057
|
+
const i = {}, s = tt(o.doc, (d) => d.attrs.id), l = new Map(
|
|
961
1058
|
s.map((d) => [d.node.attrs.id, d])
|
|
962
|
-
), a =
|
|
963
|
-
for (
|
|
964
|
-
const c = l.get(d.node.attrs.id),
|
|
965
|
-
if (c &&
|
|
1059
|
+
), a = tt(r.doc, (d) => d.attrs.id);
|
|
1060
|
+
for (const d of a) {
|
|
1061
|
+
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, p = d.node.firstChild;
|
|
1062
|
+
if (c && h && p) {
|
|
966
1063
|
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
1064
|
index: p.attrs.index,
|
|
974
1065
|
level: p.attrs.level,
|
|
975
1066
|
type: p.type.name,
|
|
1067
|
+
depth: r.doc.resolve(d.pos).depth
|
|
1068
|
+
};
|
|
1069
|
+
let m = {
|
|
1070
|
+
index: h.attrs.index,
|
|
1071
|
+
level: h.attrs.level,
|
|
1072
|
+
type: h.type.name,
|
|
976
1073
|
depth: o.doc.resolve(c.pos).depth
|
|
977
1074
|
};
|
|
978
1075
|
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));
|
|
@@ -991,9 +1088,9 @@ const it = new S("previous-blocks"), _e = {
|
|
|
991
1088
|
if (!r.attrs.id || !t.updatedBlocks.has(r.attrs.id))
|
|
992
1089
|
return;
|
|
993
1090
|
const s = t.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
|
|
994
|
-
for (
|
|
995
|
-
l["data-prev-" +
|
|
996
|
-
const a =
|
|
1091
|
+
for (const [d, c] of Object.entries(s))
|
|
1092
|
+
l["data-prev-" + Ne[d]] = c || "none";
|
|
1093
|
+
const a = V.node(i, i + r.nodeSize, {
|
|
997
1094
|
...l
|
|
998
1095
|
});
|
|
999
1096
|
o.push(a);
|
|
@@ -1001,13 +1098,13 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1001
1098
|
}
|
|
1002
1099
|
}
|
|
1003
1100
|
});
|
|
1004
|
-
},
|
|
1101
|
+
}, Pe = {
|
|
1005
1102
|
blockColor: "data-block-color",
|
|
1006
1103
|
blockStyle: "data-block-style",
|
|
1007
1104
|
id: "data-id",
|
|
1008
1105
|
depth: "data-depth",
|
|
1009
1106
|
depthChange: "data-depth-change"
|
|
1010
|
-
},
|
|
1107
|
+
}, Oe = U.create({
|
|
1011
1108
|
name: "blockContainer",
|
|
1012
1109
|
group: "blockContainer",
|
|
1013
1110
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -1015,11 +1112,6 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1015
1112
|
// Ensures content-specific keyboard handlers trigger first.
|
|
1016
1113
|
priority: 50,
|
|
1017
1114
|
defining: !0,
|
|
1018
|
-
addOptions() {
|
|
1019
|
-
return {
|
|
1020
|
-
HTMLAttributes: {}
|
|
1021
|
-
};
|
|
1022
|
-
},
|
|
1023
1115
|
parseHTML() {
|
|
1024
1116
|
return [
|
|
1025
1117
|
{
|
|
@@ -1028,7 +1120,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1028
1120
|
if (typeof n == "string")
|
|
1029
1121
|
return !1;
|
|
1030
1122
|
const e = {};
|
|
1031
|
-
for (
|
|
1123
|
+
for (const [t, o] of Object.entries(Pe))
|
|
1032
1124
|
n.getAttribute(o) && (e[t] = n.getAttribute(o));
|
|
1033
1125
|
return n.getAttribute("data-node-type") === "blockContainer" ? e : !1;
|
|
1034
1126
|
}
|
|
@@ -1036,19 +1128,24 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1036
1128
|
];
|
|
1037
1129
|
},
|
|
1038
1130
|
renderHTML({ HTMLAttributes: n }) {
|
|
1131
|
+
var t;
|
|
1132
|
+
const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockContainer) || {};
|
|
1039
1133
|
return [
|
|
1040
1134
|
"div",
|
|
1041
|
-
|
|
1042
|
-
class:
|
|
1135
|
+
A(n, {
|
|
1136
|
+
class: y.blockOuter,
|
|
1043
1137
|
"data-node-type": "block-outer"
|
|
1044
1138
|
}),
|
|
1045
1139
|
[
|
|
1046
1140
|
"div",
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1141
|
+
A(
|
|
1142
|
+
{
|
|
1143
|
+
...e,
|
|
1144
|
+
class: v(y.block, e.class),
|
|
1145
|
+
"data-node-type": this.name
|
|
1146
|
+
},
|
|
1147
|
+
n
|
|
1148
|
+
),
|
|
1052
1149
|
0
|
|
1053
1150
|
]
|
|
1054
1151
|
];
|
|
@@ -1062,7 +1159,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1062
1159
|
},
|
|
1063
1160
|
// Deletes a block at a given position.
|
|
1064
1161
|
BNDeleteBlock: (n) => ({ state: e, dispatch: t }) => {
|
|
1065
|
-
const o =
|
|
1162
|
+
const o = k(e.doc, n);
|
|
1066
1163
|
if (o === void 0)
|
|
1067
1164
|
return !1;
|
|
1068
1165
|
const { startPos: r, endPos: i } = o;
|
|
@@ -1070,7 +1167,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1070
1167
|
},
|
|
1071
1168
|
// Updates a block at a given position.
|
|
1072
1169
|
BNUpdateBlock: (n, e) => ({ state: t, dispatch: o }) => {
|
|
1073
|
-
const r =
|
|
1170
|
+
const r = k(t.doc, n);
|
|
1074
1171
|
if (r === void 0)
|
|
1075
1172
|
return !1;
|
|
1076
1173
|
const { startPos: i, endPos: s, node: l, contentNode: a } = r;
|
|
@@ -1078,11 +1175,11 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1078
1175
|
if (e.children !== void 0) {
|
|
1079
1176
|
const d = [];
|
|
1080
1177
|
for (const c of e.children)
|
|
1081
|
-
d.push(
|
|
1178
|
+
d.push(D(c, t.schema));
|
|
1082
1179
|
l.childCount === 2 ? t.tr.replace(
|
|
1083
1180
|
i + a.nodeSize + 1,
|
|
1084
1181
|
s - 1,
|
|
1085
|
-
new
|
|
1182
|
+
new x(_.from(d), 0, 0)
|
|
1086
1183
|
) : t.tr.insert(
|
|
1087
1184
|
i + a.nodeSize,
|
|
1088
1185
|
t.schema.nodes.blockGroup.create({}, d)
|
|
@@ -1090,10 +1187,10 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1090
1187
|
}
|
|
1091
1188
|
if (e.content !== void 0) {
|
|
1092
1189
|
let d = [];
|
|
1093
|
-
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d =
|
|
1190
|
+
typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d = Tt(e.content, t.schema), t.tr.replace(
|
|
1094
1191
|
i + 1,
|
|
1095
1192
|
i + a.nodeSize - 1,
|
|
1096
|
-
new
|
|
1193
|
+
new x(_.from(d), 0, 0)
|
|
1097
1194
|
);
|
|
1098
1195
|
}
|
|
1099
1196
|
t.tr.setNodeMarkup(
|
|
@@ -1131,42 +1228,42 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1131
1228
|
const o = e.doc.resolve(n + 1).node().type.name === "blockContainer", r = e.doc.resolve(n - 1).node().type.name === "blockContainer";
|
|
1132
1229
|
if (!o || !r)
|
|
1133
1230
|
return !1;
|
|
1134
|
-
const i =
|
|
1231
|
+
const i = k(
|
|
1135
1232
|
e.doc,
|
|
1136
1233
|
n + 1
|
|
1137
1234
|
), { node: s, contentNode: l, startPos: a, endPos: d, depth: c } = i;
|
|
1138
1235
|
if (s.childCount === 2) {
|
|
1139
1236
|
const f = e.doc.resolve(
|
|
1140
1237
|
a + l.nodeSize + 1
|
|
1141
|
-
), m = e.doc.resolve(d - 1),
|
|
1142
|
-
t && e.tr.lift(
|
|
1238
|
+
), m = e.doc.resolve(d - 1), g = f.blockRange(m);
|
|
1239
|
+
t && e.tr.lift(g, c - 1);
|
|
1143
1240
|
}
|
|
1144
|
-
let
|
|
1145
|
-
for (;
|
|
1146
|
-
if (
|
|
1241
|
+
let h = n - 1, p = k(e.doc, h);
|
|
1242
|
+
for (; p.numChildBlocks > 0; )
|
|
1243
|
+
if (h--, p = k(e.doc, h), p === void 0)
|
|
1147
1244
|
return !1;
|
|
1148
1245
|
return t && (t(
|
|
1149
1246
|
e.tr.deleteRange(a, a + l.nodeSize).replace(
|
|
1150
|
-
|
|
1247
|
+
h - 1,
|
|
1151
1248
|
a,
|
|
1152
|
-
new
|
|
1249
|
+
new x(l.content, 0, 0)
|
|
1153
1250
|
).scrollIntoView()
|
|
1154
1251
|
), e.tr.setSelection(
|
|
1155
|
-
new
|
|
1252
|
+
new ot(e.doc.resolve(h - 1))
|
|
1156
1253
|
)), !0;
|
|
1157
1254
|
},
|
|
1158
1255
|
// Splits a block at a given position. Content after the position is moved to a new block below, at the same
|
|
1159
1256
|
// nesting level.
|
|
1160
1257
|
BNSplitBlock: (n, e) => ({ state: t, dispatch: o }) => {
|
|
1161
|
-
const r =
|
|
1258
|
+
const r = k(t.doc, n);
|
|
1162
1259
|
if (r === void 0)
|
|
1163
1260
|
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,
|
|
1261
|
+
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;
|
|
1262
|
+
return o && (t.tr.insert(f, p), t.tr.replace(
|
|
1166
1263
|
m,
|
|
1167
1264
|
m + 1,
|
|
1168
|
-
|
|
1169
|
-
|
|
1265
|
+
h.content.size > 0 ? new x(
|
|
1266
|
+
_.from(h),
|
|
1170
1267
|
d + 2,
|
|
1171
1268
|
d + 2
|
|
1172
1269
|
) : void 0
|
|
@@ -1176,12 +1273,12 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1176
1273
|
t.schema.node(s).type,
|
|
1177
1274
|
i.attrs
|
|
1178
1275
|
), t.tr.setSelection(
|
|
1179
|
-
new
|
|
1276
|
+
new ot(t.doc.resolve(m))
|
|
1180
1277
|
), t.tr.replace(
|
|
1181
1278
|
l + 1,
|
|
1182
1279
|
a - 1,
|
|
1183
|
-
c.content.size > 0 ? new
|
|
1184
|
-
|
|
1280
|
+
c.content.size > 0 ? new x(
|
|
1281
|
+
_.from(c),
|
|
1185
1282
|
d + 2,
|
|
1186
1283
|
d + 2
|
|
1187
1284
|
) : void 0
|
|
@@ -1190,7 +1287,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1190
1287
|
};
|
|
1191
1288
|
},
|
|
1192
1289
|
addProseMirrorPlugins() {
|
|
1193
|
-
return [
|
|
1290
|
+
return [Le()];
|
|
1194
1291
|
},
|
|
1195
1292
|
addKeyboardShortcuts() {
|
|
1196
1293
|
return {
|
|
@@ -1201,7 +1298,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1201
1298
|
() => t.undoInputRule(),
|
|
1202
1299
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
1203
1300
|
() => t.command(({ state: o }) => {
|
|
1204
|
-
const { contentType: r } =
|
|
1301
|
+
const { contentType: r } = k(
|
|
1205
1302
|
o.doc,
|
|
1206
1303
|
o.selection.from
|
|
1207
1304
|
), i = o.selection.$anchor.parentOffset === 0, s = r.name === "paragraph";
|
|
@@ -1215,7 +1312,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1215
1312
|
// Merges block with the previous one if it isn't indented, isn't the first block in the doc, and the selection
|
|
1216
1313
|
// is at the start of the block.
|
|
1217
1314
|
() => t.command(({ state: o }) => {
|
|
1218
|
-
const { depth: r, startPos: i } =
|
|
1315
|
+
const { depth: r, startPos: i } = k(
|
|
1219
1316
|
o.doc,
|
|
1220
1317
|
o.selection.from
|
|
1221
1318
|
), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = i === 2, d = i - 1;
|
|
@@ -1226,7 +1323,7 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1226
1323
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
1227
1324
|
// of the block.
|
|
1228
1325
|
() => t.command(({ state: o }) => {
|
|
1229
|
-
const { node: r, depth: i } =
|
|
1326
|
+
const { node: r, depth: i } = k(
|
|
1230
1327
|
o.doc,
|
|
1231
1328
|
o.selection.from
|
|
1232
1329
|
), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = r.textContent.length === 0, d = i > 2;
|
|
@@ -1235,20 +1332,20 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1235
1332
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1236
1333
|
// empty & at the start of the block.
|
|
1237
1334
|
() => t.command(({ state: o, chain: r }) => {
|
|
1238
|
-
const { node: i, endPos: s } =
|
|
1335
|
+
const { node: i, endPos: s } = k(
|
|
1239
1336
|
o.doc,
|
|
1240
1337
|
o.selection.from
|
|
1241
1338
|
), l = o.selection.$anchor.parentOffset === 0, a = o.selection.anchor === o.selection.head, d = i.textContent.length === 0;
|
|
1242
1339
|
if (l && a && d) {
|
|
1243
|
-
const c = s + 1,
|
|
1244
|
-
return r().BNCreateBlock(c).setTextSelection(
|
|
1340
|
+
const c = s + 1, h = c + 2;
|
|
1341
|
+
return r().BNCreateBlock(c).setTextSelection(h).run(), !0;
|
|
1245
1342
|
}
|
|
1246
1343
|
return !1;
|
|
1247
1344
|
}),
|
|
1248
1345
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
1249
1346
|
// deletes the selection beforehand, if it's not empty.
|
|
1250
1347
|
() => t.command(({ state: o, chain: r }) => {
|
|
1251
|
-
const { node: i } =
|
|
1348
|
+
const { node: i } = k(
|
|
1252
1349
|
o.doc,
|
|
1253
1350
|
o.selection.from
|
|
1254
1351
|
);
|
|
@@ -1290,15 +1387,10 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1290
1387
|
})
|
|
1291
1388
|
};
|
|
1292
1389
|
}
|
|
1293
|
-
}),
|
|
1390
|
+
}), De = U.create({
|
|
1294
1391
|
name: "blockGroup",
|
|
1295
1392
|
group: "blockGroup",
|
|
1296
1393
|
content: "blockContainer+",
|
|
1297
|
-
addOptions() {
|
|
1298
|
-
return {
|
|
1299
|
-
HTMLAttributes: {}
|
|
1300
|
-
};
|
|
1301
|
-
},
|
|
1302
1394
|
parseHTML() {
|
|
1303
1395
|
return [
|
|
1304
1396
|
{
|
|
@@ -1308,26 +1400,31 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1308
1400
|
];
|
|
1309
1401
|
},
|
|
1310
1402
|
renderHTML({ HTMLAttributes: n }) {
|
|
1403
|
+
var t;
|
|
1404
|
+
const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockGroup) || {};
|
|
1311
1405
|
return [
|
|
1312
1406
|
"div",
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1407
|
+
A(
|
|
1408
|
+
{
|
|
1409
|
+
...e,
|
|
1410
|
+
class: v(
|
|
1411
|
+
y.blockGroup,
|
|
1412
|
+
e.class
|
|
1413
|
+
),
|
|
1414
|
+
"data-node-type": "blockGroup"
|
|
1415
|
+
},
|
|
1416
|
+
n
|
|
1417
|
+
),
|
|
1317
1418
|
0
|
|
1318
1419
|
];
|
|
1319
1420
|
}
|
|
1320
|
-
}),
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
})
|
|
1328
|
-
], Pe = (n) => {
|
|
1329
|
-
const e = q.fromSchema(n);
|
|
1330
|
-
return new q(
|
|
1421
|
+
}), Re = U.create({
|
|
1422
|
+
name: "doc",
|
|
1423
|
+
topNode: !0,
|
|
1424
|
+
content: "blockGroup"
|
|
1425
|
+
}), Ve = (n) => {
|
|
1426
|
+
const e = W.fromSchema(n);
|
|
1427
|
+
return new W(
|
|
1331
1428
|
{
|
|
1332
1429
|
...e.nodes
|
|
1333
1430
|
// TODO: If a serializer is defined in the config for a custom block, it
|
|
@@ -1337,19 +1434,20 @@ const it = new S("previous-blocks"), _e = {
|
|
|
1337
1434
|
},
|
|
1338
1435
|
e.marks
|
|
1339
1436
|
);
|
|
1340
|
-
},
|
|
1437
|
+
}, ze = T.create({
|
|
1341
1438
|
addProseMirrorPlugins() {
|
|
1342
1439
|
return [
|
|
1343
|
-
new
|
|
1440
|
+
new w({
|
|
1344
1441
|
props: {
|
|
1345
|
-
clipboardSerializer:
|
|
1442
|
+
clipboardSerializer: Ve(this.editor.schema)
|
|
1346
1443
|
}
|
|
1347
1444
|
})
|
|
1348
1445
|
];
|
|
1349
1446
|
}
|
|
1350
1447
|
});
|
|
1351
|
-
class
|
|
1448
|
+
class G {
|
|
1352
1449
|
constructor() {
|
|
1450
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1353
1451
|
u(this, "callbacks", {});
|
|
1354
1452
|
}
|
|
1355
1453
|
on(e, t) {
|
|
@@ -1367,10 +1465,10 @@ class F {
|
|
|
1367
1465
|
this.callbacks = {};
|
|
1368
1466
|
}
|
|
1369
1467
|
}
|
|
1370
|
-
const
|
|
1468
|
+
const Ue = zt(
|
|
1371
1469
|
(n) => n.type.name === "blockContainer"
|
|
1372
1470
|
);
|
|
1373
|
-
class
|
|
1471
|
+
class Fe {
|
|
1374
1472
|
constructor(e, t, o = () => {
|
|
1375
1473
|
}) {
|
|
1376
1474
|
u(this, "suggestionsMenuState");
|
|
@@ -1385,7 +1483,7 @@ class Re {
|
|
|
1385
1483
|
this.suggestionsMenuState.referencePos = t.getBoundingClientRect(), this.updateSuggestionsMenu();
|
|
1386
1484
|
}
|
|
1387
1485
|
});
|
|
1388
|
-
this.editor = e, this.pluginKey = t, this.pluginState =
|
|
1486
|
+
this.editor = e, this.pluginKey = t, this.pluginState = Y(), this.updateSuggestionsMenu = () => {
|
|
1389
1487
|
if (!this.suggestionsMenuState)
|
|
1390
1488
|
throw new Error("Attempting to update uninitialized suggestions menu");
|
|
1391
1489
|
o(this.suggestionsMenuState);
|
|
@@ -1413,7 +1511,7 @@ class Re {
|
|
|
1413
1511
|
document.removeEventListener("scroll", this.handleScroll);
|
|
1414
1512
|
}
|
|
1415
1513
|
}
|
|
1416
|
-
function
|
|
1514
|
+
function Y() {
|
|
1417
1515
|
return {
|
|
1418
1516
|
active: !1,
|
|
1419
1517
|
triggerCharacter: void 0,
|
|
@@ -1424,7 +1522,7 @@ function W() {
|
|
|
1424
1522
|
decorationId: void 0
|
|
1425
1523
|
};
|
|
1426
1524
|
}
|
|
1427
|
-
const
|
|
1525
|
+
const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
1428
1526
|
}) => {
|
|
1429
1527
|
if (o.length !== 1)
|
|
1430
1528
|
throw new Error("'char' should be a single character");
|
|
@@ -1433,9 +1531,9 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1433
1531
|
a.dispatch(a.state.tr.setMeta(t, { deactivate: !0 }));
|
|
1434
1532
|
};
|
|
1435
1533
|
return {
|
|
1436
|
-
plugin: new
|
|
1534
|
+
plugin: new w({
|
|
1437
1535
|
key: t,
|
|
1438
|
-
view: () => (s = new
|
|
1536
|
+
view: () => (s = new Fe(
|
|
1439
1537
|
n,
|
|
1440
1538
|
t,
|
|
1441
1539
|
e
|
|
@@ -1443,18 +1541,18 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1443
1541
|
state: {
|
|
1444
1542
|
// Initialize the plugin's internal state.
|
|
1445
1543
|
init() {
|
|
1446
|
-
return
|
|
1544
|
+
return Y();
|
|
1447
1545
|
},
|
|
1448
1546
|
// Apply changes to the plugin state from an editor transaction.
|
|
1449
|
-
apply(a, d, c,
|
|
1450
|
-
var f, m,
|
|
1547
|
+
apply(a, d, c, h) {
|
|
1548
|
+
var f, m, g, b;
|
|
1451
1549
|
if (a.getMeta("orderedListIndexing") !== void 0)
|
|
1452
1550
|
return d;
|
|
1453
1551
|
if ((f = a.getMeta(t)) != null && f.activate)
|
|
1454
1552
|
return {
|
|
1455
1553
|
active: !0,
|
|
1456
1554
|
triggerCharacter: ((m = a.getMeta(t)) == null ? void 0 : m.triggerCharacter) || "",
|
|
1457
|
-
queryStartPos:
|
|
1555
|
+
queryStartPos: h.selection.from,
|
|
1458
1556
|
items: r(""),
|
|
1459
1557
|
keyboardHoveredItemIndex: 0,
|
|
1460
1558
|
// TODO: Maybe should be 1 if the menu has no possible items? Probably redundant since a menu with no items
|
|
@@ -1464,30 +1562,30 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1464
1562
|
};
|
|
1465
1563
|
if (!d.active)
|
|
1466
1564
|
return d;
|
|
1467
|
-
const
|
|
1468
|
-
if (
|
|
1469
|
-
|
|
1565
|
+
const p = { ...d };
|
|
1566
|
+
if (p.items = r(
|
|
1567
|
+
h.doc.textBetween(
|
|
1470
1568
|
d.queryStartPos,
|
|
1471
|
-
|
|
1569
|
+
h.selection.from
|
|
1472
1570
|
)
|
|
1473
|
-
),
|
|
1571
|
+
), p.notFoundCount = 0, p.items.length === 0 && (p.notFoundCount = Math.max(
|
|
1474
1572
|
0,
|
|
1475
|
-
d.notFoundCount + (
|
|
1573
|
+
d.notFoundCount + (h.selection.from - c.selection.from)
|
|
1476
1574
|
)), // Highlighting text should hide the menu.
|
|
1477
|
-
|
|
1478
|
-
(
|
|
1575
|
+
h.selection.from !== h.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
|
|
1576
|
+
(g = a.getMeta(t)) != null && g.deactivate || // Certain mouse events should hide the menu.
|
|
1479
1577
|
// TODO: Change to global mousedown listener.
|
|
1480
1578
|
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 &&
|
|
1579
|
+
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
1580
|
// the menu.
|
|
1483
|
-
|
|
1484
|
-
return
|
|
1485
|
-
if (((
|
|
1486
|
-
let
|
|
1487
|
-
|
|
1581
|
+
p.notFoundCount > 3)
|
|
1582
|
+
return Y();
|
|
1583
|
+
if (((b = a.getMeta(t)) == null ? void 0 : b.selectedItemIndexChanged) !== void 0) {
|
|
1584
|
+
let C = a.getMeta(t).selectedItemIndexChanged;
|
|
1585
|
+
C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0), p.keyboardHoveredItemIndex = C;
|
|
1488
1586
|
} else
|
|
1489
|
-
c.selection.from !==
|
|
1490
|
-
return
|
|
1587
|
+
c.selection.from !== h.selection.from && (p.keyboardHoveredItemIndex = 0);
|
|
1588
|
+
return p;
|
|
1491
1589
|
}
|
|
1492
1590
|
},
|
|
1493
1591
|
props: {
|
|
@@ -1503,8 +1601,8 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1503
1601
|
if (!c)
|
|
1504
1602
|
return !1;
|
|
1505
1603
|
const {
|
|
1506
|
-
triggerCharacter:
|
|
1507
|
-
queryStartPos:
|
|
1604
|
+
triggerCharacter: h,
|
|
1605
|
+
queryStartPos: p,
|
|
1508
1606
|
items: f,
|
|
1509
1607
|
keyboardHoveredItemIndex: m
|
|
1510
1608
|
} = t.getState(a.state);
|
|
@@ -1517,7 +1615,7 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1517
1615
|
selectedItemIndexChanged: m + 1
|
|
1518
1616
|
})
|
|
1519
1617
|
), !0) : d.key === "Enter" ? (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1520
|
-
from:
|
|
1618
|
+
from: p - h.length,
|
|
1521
1619
|
to: n._tiptapEditor.state.selection.from
|
|
1522
1620
|
}).run(), i({
|
|
1523
1621
|
item: f[m],
|
|
@@ -1526,14 +1624,14 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1526
1624
|
},
|
|
1527
1625
|
// Setup decorator on the currently active suggestion.
|
|
1528
1626
|
decorations(a) {
|
|
1529
|
-
const { active: d, decorationId: c, queryStartPos:
|
|
1627
|
+
const { active: d, decorationId: c, queryStartPos: h, triggerCharacter: p } = this.getState(a);
|
|
1530
1628
|
if (!d)
|
|
1531
1629
|
return null;
|
|
1532
|
-
if (
|
|
1533
|
-
const f =
|
|
1630
|
+
if (p === "") {
|
|
1631
|
+
const f = Ue(a.selection);
|
|
1534
1632
|
if (f)
|
|
1535
1633
|
return z.create(a.doc, [
|
|
1536
|
-
|
|
1634
|
+
V.node(
|
|
1537
1635
|
f.pos,
|
|
1538
1636
|
f.pos + f.node.nodeSize,
|
|
1539
1637
|
{
|
|
@@ -1545,9 +1643,9 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1545
1643
|
]);
|
|
1546
1644
|
}
|
|
1547
1645
|
return z.create(a.doc, [
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1646
|
+
V.inline(
|
|
1647
|
+
h - p.length,
|
|
1648
|
+
h,
|
|
1551
1649
|
{
|
|
1552
1650
|
nodeName: "span",
|
|
1553
1651
|
class: "suggestion-decorator",
|
|
@@ -1568,18 +1666,18 @@ const ze = (n, e, t, o, r = () => [], i = () => {
|
|
|
1568
1666
|
});
|
|
1569
1667
|
}
|
|
1570
1668
|
};
|
|
1571
|
-
},
|
|
1572
|
-
class
|
|
1669
|
+
}, X = new S("SlashMenuPlugin");
|
|
1670
|
+
class $e extends G {
|
|
1573
1671
|
constructor(t, o) {
|
|
1574
1672
|
super();
|
|
1575
1673
|
u(this, "plugin");
|
|
1576
1674
|
u(this, "itemCallback");
|
|
1577
|
-
const r =
|
|
1675
|
+
const r = Ge(
|
|
1578
1676
|
t,
|
|
1579
1677
|
(i) => {
|
|
1580
1678
|
this.emit("update", i);
|
|
1581
1679
|
},
|
|
1582
|
-
|
|
1680
|
+
X,
|
|
1583
1681
|
"/",
|
|
1584
1682
|
(i) => o.filter(
|
|
1585
1683
|
({ name: s, aliases: l }) => s.toLowerCase().startsWith(i.toLowerCase()) || l && l.filter(
|
|
@@ -1594,7 +1692,7 @@ class Ve extends F {
|
|
|
1594
1692
|
return this.on("update", t);
|
|
1595
1693
|
}
|
|
1596
1694
|
}
|
|
1597
|
-
const
|
|
1695
|
+
const je = new S("blocknote-placeholder"), qe = T.create({
|
|
1598
1696
|
name: "placeholder",
|
|
1599
1697
|
addOptions() {
|
|
1600
1698
|
return {
|
|
@@ -1610,21 +1708,21 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1610
1708
|
},
|
|
1611
1709
|
addProseMirrorPlugins() {
|
|
1612
1710
|
return [
|
|
1613
|
-
new
|
|
1614
|
-
key:
|
|
1711
|
+
new w({
|
|
1712
|
+
key: je,
|
|
1615
1713
|
props: {
|
|
1616
1714
|
decorations: (n) => {
|
|
1617
|
-
const { doc: e, selection: t } = n, o =
|
|
1715
|
+
const { doc: e, selection: t } = n, o = X.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
|
|
1618
1716
|
if (r)
|
|
1619
1717
|
return e.descendants((l, a) => {
|
|
1620
1718
|
const d = i >= a && i <= a + l.nodeSize, c = !l.isLeaf && !l.childCount;
|
|
1621
1719
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
1622
|
-
const
|
|
1623
|
-
this.editor.isEmpty &&
|
|
1624
|
-
const
|
|
1625
|
-
class:
|
|
1720
|
+
const h = [this.options.emptyNodeClass];
|
|
1721
|
+
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);
|
|
1722
|
+
const p = V.node(a, a + l.nodeSize, {
|
|
1723
|
+
class: h.join(" ")
|
|
1626
1724
|
});
|
|
1627
|
-
s.push(
|
|
1725
|
+
s.push(p);
|
|
1628
1726
|
}
|
|
1629
1727
|
return this.options.includeChildren;
|
|
1630
1728
|
}), z.create(e, s);
|
|
@@ -1633,7 +1731,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1633
1731
|
})
|
|
1634
1732
|
];
|
|
1635
1733
|
}
|
|
1636
|
-
}),
|
|
1734
|
+
}), We = T.create({
|
|
1637
1735
|
name: "textAlignment",
|
|
1638
1736
|
addGlobalAttributes() {
|
|
1639
1737
|
return [
|
|
@@ -1656,7 +1754,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1656
1754
|
addCommands() {
|
|
1657
1755
|
return {
|
|
1658
1756
|
setTextAlignment: (n) => ({ state: e }) => {
|
|
1659
|
-
const t = [], o =
|
|
1757
|
+
const t = [], o = k(
|
|
1660
1758
|
e.doc,
|
|
1661
1759
|
e.selection.from
|
|
1662
1760
|
);
|
|
@@ -1671,7 +1769,7 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1671
1769
|
}
|
|
1672
1770
|
};
|
|
1673
1771
|
}
|
|
1674
|
-
}),
|
|
1772
|
+
}), Ye = T.create({
|
|
1675
1773
|
name: "blockTextColor",
|
|
1676
1774
|
addGlobalAttributes() {
|
|
1677
1775
|
return [
|
|
@@ -1692,12 +1790,12 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1692
1790
|
addCommands() {
|
|
1693
1791
|
return {
|
|
1694
1792
|
setBlockTextColor: (n, e) => ({ state: t, view: o }) => {
|
|
1695
|
-
const r =
|
|
1793
|
+
const r = k(t.doc, n);
|
|
1696
1794
|
return r === void 0 ? !1 : (t.tr.setNodeAttribute(r.startPos - 1, "textColor", e), o.focus(), !0);
|
|
1697
1795
|
}
|
|
1698
1796
|
};
|
|
1699
1797
|
}
|
|
1700
|
-
}),
|
|
1798
|
+
}), Ke = lt.create({
|
|
1701
1799
|
name: "textColor",
|
|
1702
1800
|
addAttributes() {
|
|
1703
1801
|
return {
|
|
@@ -1726,12 +1824,12 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1726
1824
|
setTextColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
1727
1825
|
};
|
|
1728
1826
|
}
|
|
1729
|
-
}),
|
|
1827
|
+
}), Je = T.create({
|
|
1730
1828
|
name: "trailingNode",
|
|
1731
1829
|
addProseMirrorPlugins() {
|
|
1732
1830
|
const n = new S(this.name);
|
|
1733
1831
|
return [
|
|
1734
|
-
new
|
|
1832
|
+
new w({
|
|
1735
1833
|
key: n,
|
|
1736
1834
|
appendTransaction: (e, t, o) => {
|
|
1737
1835
|
const { doc: r, tr: i, schema: s } = o, l = n.getState(o), a = r.content.size - 2, d = s.nodes.blockContainer, c = s.nodes.paragraph;
|
|
@@ -1758,7 +1856,8 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1758
1856
|
})
|
|
1759
1857
|
];
|
|
1760
1858
|
}
|
|
1761
|
-
}),
|
|
1859
|
+
}), Xe = (n) => {
|
|
1860
|
+
var t;
|
|
1762
1861
|
const e = [
|
|
1763
1862
|
L.ClipboardTextSerializer,
|
|
1764
1863
|
L.Commands,
|
|
@@ -1766,71 +1865,81 @@ const Ue = new S("blocknote-placeholder"), Fe = B.create({
|
|
|
1766
1865
|
L.FocusEvents,
|
|
1767
1866
|
L.Tabindex,
|
|
1768
1867
|
// DevTools,
|
|
1769
|
-
|
|
1868
|
+
Kt,
|
|
1770
1869
|
// DropCursor,
|
|
1771
|
-
|
|
1772
|
-
emptyNodeClass:
|
|
1773
|
-
hasAnchorClass:
|
|
1774
|
-
isFilterClass:
|
|
1870
|
+
qe.configure({
|
|
1871
|
+
emptyNodeClass: y.isEmpty,
|
|
1872
|
+
hasAnchorClass: y.hasAnchor,
|
|
1873
|
+
isFilterClass: y.isFilter,
|
|
1775
1874
|
includeChildren: !0,
|
|
1776
1875
|
showOnlyCurrent: !1
|
|
1777
1876
|
}),
|
|
1778
|
-
|
|
1877
|
+
F.configure({
|
|
1779
1878
|
types: ["blockContainer"]
|
|
1780
1879
|
}),
|
|
1781
|
-
|
|
1880
|
+
Jt,
|
|
1782
1881
|
// Comments,
|
|
1783
1882
|
// basics:
|
|
1784
|
-
|
|
1883
|
+
ee,
|
|
1785
1884
|
// marks:
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
Kt,
|
|
1885
|
+
$t,
|
|
1886
|
+
jt,
|
|
1789
1887
|
Zt,
|
|
1790
1888
|
te,
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1889
|
+
oe,
|
|
1890
|
+
Qt,
|
|
1891
|
+
Ke,
|
|
1892
|
+
Ye,
|
|
1893
|
+
ge,
|
|
1894
|
+
ke,
|
|
1895
|
+
We,
|
|
1896
|
+
// nodes
|
|
1897
|
+
Re,
|
|
1898
|
+
Oe.configure({
|
|
1899
|
+
domAttributes: n.domAttributes
|
|
1900
|
+
}),
|
|
1901
|
+
De.configure({
|
|
1902
|
+
domAttributes: n.domAttributes
|
|
1903
|
+
}),
|
|
1799
1904
|
...Object.values(n.blockSchema).map(
|
|
1800
|
-
(
|
|
1905
|
+
(o) => o.node.configure({
|
|
1906
|
+
editor: n.editor,
|
|
1907
|
+
domAttributes: n.domAttributes
|
|
1908
|
+
})
|
|
1801
1909
|
),
|
|
1802
|
-
|
|
1803
|
-
|
|
1910
|
+
ze,
|
|
1911
|
+
Yt.configure({ width: 5, color: "#ddeeff" }),
|
|
1804
1912
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
1805
1913
|
// should be handled before Enter handlers in other components like splitListItem
|
|
1806
|
-
|
|
1914
|
+
Je
|
|
1807
1915
|
];
|
|
1808
1916
|
if (n.collaboration) {
|
|
1809
|
-
e.push(
|
|
1810
|
-
|
|
1917
|
+
if (e.push(
|
|
1918
|
+
qt.configure({
|
|
1811
1919
|
fragment: n.collaboration.fragment
|
|
1812
1920
|
})
|
|
1813
|
-
)
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1921
|
+
), (t = n.collaboration.provider) != null && t.awareness) {
|
|
1922
|
+
const o = (r) => {
|
|
1923
|
+
const i = document.createElement("span");
|
|
1924
|
+
i.classList.add(H["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
|
|
1925
|
+
const s = document.createElement("span");
|
|
1926
|
+
s.classList.add(H["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
|
|
1927
|
+
const l = document.createTextNode(""), a = document.createTextNode("");
|
|
1928
|
+
return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
|
|
1929
|
+
};
|
|
1930
|
+
e.push(
|
|
1931
|
+
Wt.configure({
|
|
1932
|
+
user: n.collaboration.user,
|
|
1933
|
+
render: n.collaboration.renderCursor || o,
|
|
1934
|
+
provider: n.collaboration.provider
|
|
1935
|
+
})
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1829
1938
|
} else
|
|
1830
|
-
e.push(
|
|
1939
|
+
e.push(Xt);
|
|
1831
1940
|
return e;
|
|
1832
1941
|
};
|
|
1833
|
-
function
|
|
1942
|
+
function Z(n, e) {
|
|
1834
1943
|
let t, o;
|
|
1835
1944
|
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
1945
|
throw Error("Could not find block in the editor with matching ID.");
|
|
@@ -1839,12 +1948,12 @@ function X(n, e) {
|
|
|
1839
1948
|
posBeforeNode: o
|
|
1840
1949
|
};
|
|
1841
1950
|
}
|
|
1842
|
-
function
|
|
1951
|
+
function xt(n, e, t = "before", o) {
|
|
1843
1952
|
const r = typeof e == "string" ? e : e.id, i = [];
|
|
1844
1953
|
for (const d of n)
|
|
1845
|
-
i.push(
|
|
1954
|
+
i.push(D(d, o.schema));
|
|
1846
1955
|
let s = -1;
|
|
1847
|
-
const { node: l, posBeforeNode: a } =
|
|
1956
|
+
const { node: l, posBeforeNode: a } = Z(r, o.state.doc);
|
|
1848
1957
|
if (t === "before" && (s = a), t === "after" && (s = a + l.nodeSize), t === "nested") {
|
|
1849
1958
|
if (l.childCount < 2) {
|
|
1850
1959
|
s = a + l.firstChild.nodeSize + 1;
|
|
@@ -1861,11 +1970,11 @@ function Bt(n, e, t = "before", o) {
|
|
|
1861
1970
|
}
|
|
1862
1971
|
o.view.dispatch(o.state.tr.insert(s, i));
|
|
1863
1972
|
}
|
|
1864
|
-
function
|
|
1865
|
-
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } =
|
|
1973
|
+
function Ze(n, e, t) {
|
|
1974
|
+
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = Z(o, t.state.doc);
|
|
1866
1975
|
t.commands.BNUpdateBlock(r + 1, e);
|
|
1867
1976
|
}
|
|
1868
|
-
function
|
|
1977
|
+
function At(n, e) {
|
|
1869
1978
|
const t = new Set(
|
|
1870
1979
|
n.map(
|
|
1871
1980
|
(r) => typeof r == "string" ? r : r.id
|
|
@@ -1883,17 +1992,17 @@ function Tt(n, e) {
|
|
|
1883
1992
|
const l = e.state.doc.nodeSize;
|
|
1884
1993
|
return o += s - l, !1;
|
|
1885
1994
|
}), t.size > 0) {
|
|
1886
|
-
|
|
1995
|
+
const r = [...t].join(`
|
|
1887
1996
|
`);
|
|
1888
1997
|
throw Error(
|
|
1889
1998
|
"Blocks with the following IDs could not be found in the editor: " + r
|
|
1890
1999
|
);
|
|
1891
2000
|
}
|
|
1892
2001
|
}
|
|
1893
|
-
function
|
|
1894
|
-
|
|
2002
|
+
function Qe(n, e, t) {
|
|
2003
|
+
xt(e, n[0], "before", t), At(n, t);
|
|
1895
2004
|
}
|
|
1896
|
-
function
|
|
2005
|
+
function to() {
|
|
1897
2006
|
const n = (e) => {
|
|
1898
2007
|
let t = e.children.length;
|
|
1899
2008
|
for (let o = 0; o < t; o++) {
|
|
@@ -1909,19 +2018,19 @@ function Ke() {
|
|
|
1909
2018
|
};
|
|
1910
2019
|
return n;
|
|
1911
2020
|
}
|
|
1912
|
-
function
|
|
2021
|
+
function eo(n) {
|
|
1913
2022
|
const e = /* @__PURE__ */ new Set([
|
|
1914
2023
|
...n.orderedListItemBlockTypes,
|
|
1915
2024
|
...n.unorderedListItemBlockTypes
|
|
1916
2025
|
]), t = (o) => {
|
|
1917
2026
|
let r = o.children.length, i;
|
|
1918
2027
|
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,
|
|
2028
|
+
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, h = e.has(
|
|
1920
2029
|
d.properties.dataContentType
|
|
1921
|
-
),
|
|
2030
|
+
), p = h ? n.orderedListItemBlockTypes.has(
|
|
1922
2031
|
d.properties.dataContentType
|
|
1923
2032
|
) ? "ol" : "ul" : null;
|
|
1924
|
-
if (c !== null && t(c), i && i.tagName !==
|
|
2033
|
+
if (c !== null && t(c), i && i.tagName !== p) {
|
|
1925
2034
|
o.children.splice(
|
|
1926
2035
|
s - i.children.length,
|
|
1927
2036
|
i.children.length,
|
|
@@ -1930,11 +2039,11 @@ function Xe(n) {
|
|
|
1930
2039
|
const f = i.children.length - 1;
|
|
1931
2040
|
s -= f, r -= f, i = void 0;
|
|
1932
2041
|
}
|
|
1933
|
-
if (
|
|
1934
|
-
i || (i =
|
|
1935
|
-
document.createElement(
|
|
2042
|
+
if (h) {
|
|
2043
|
+
i || (i = nt(
|
|
2044
|
+
document.createElement(p)
|
|
1936
2045
|
));
|
|
1937
|
-
const f =
|
|
2046
|
+
const f = nt(
|
|
1938
2047
|
document.createElement("li")
|
|
1939
2048
|
);
|
|
1940
2049
|
f.children.push(d.children[0]), c !== null && f.children.push(...c.children), i.children.push(f);
|
|
@@ -1953,33 +2062,55 @@ function Xe(n) {
|
|
|
1953
2062
|
};
|
|
1954
2063
|
return t;
|
|
1955
2064
|
}
|
|
1956
|
-
async function
|
|
1957
|
-
const t = document.createElement("div"), o =
|
|
2065
|
+
async function It(n, e) {
|
|
2066
|
+
const t = document.createElement("div"), o = W.fromSchema(e);
|
|
1958
2067
|
for (const i of n) {
|
|
1959
|
-
const s =
|
|
2068
|
+
const s = D(i, e), l = o.serializeNode(s);
|
|
1960
2069
|
t.appendChild(l);
|
|
1961
2070
|
}
|
|
1962
|
-
return (await J().use(
|
|
2071
|
+
return (await J().use(dt, { fragment: !0 }).use(eo, {
|
|
1963
2072
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
1964
2073
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
1965
|
-
}).use(
|
|
2074
|
+
}).use(ct).process(t.innerHTML)).value;
|
|
1966
2075
|
}
|
|
1967
2076
|
async function _t(n, e, t) {
|
|
1968
2077
|
const o = document.createElement("div");
|
|
1969
2078
|
o.innerHTML = n.trim();
|
|
1970
|
-
const i =
|
|
2079
|
+
const i = ne.fromSchema(t).parse(o), s = [];
|
|
1971
2080
|
for (let l = 0; l < i.firstChild.childCount; l++)
|
|
1972
|
-
s.push(
|
|
2081
|
+
s.push(E(i.firstChild.child(l), e));
|
|
1973
2082
|
return s;
|
|
1974
2083
|
}
|
|
1975
|
-
async function
|
|
1976
|
-
return (await J().use(
|
|
2084
|
+
async function oo(n, e) {
|
|
2085
|
+
return (await J().use(dt, { fragment: !0 }).use(to).use(ae).use(ut).use(ue).process(await It(n, e))).value;
|
|
2086
|
+
}
|
|
2087
|
+
function no(n, e) {
|
|
2088
|
+
const t = e.value ? e.value + `
|
|
2089
|
+
` : "", o = {};
|
|
2090
|
+
e.lang && (o["data-language"] = e.lang);
|
|
2091
|
+
let r = {
|
|
2092
|
+
type: "element",
|
|
2093
|
+
tagName: "code",
|
|
2094
|
+
properties: o,
|
|
2095
|
+
children: [{ type: "text", value: t }]
|
|
2096
|
+
};
|
|
2097
|
+
return e.meta && (r.data = { meta: e.meta }), n.patch(e, r), r = n.applyData(e, r), r = {
|
|
2098
|
+
type: "element",
|
|
2099
|
+
tagName: "pre",
|
|
2100
|
+
properties: {},
|
|
2101
|
+
children: [r]
|
|
2102
|
+
}, n.patch(e, r), r;
|
|
1977
2103
|
}
|
|
1978
|
-
async function
|
|
1979
|
-
const o = await J().use(
|
|
2104
|
+
async function ro(n, e, t) {
|
|
2105
|
+
const o = await J().use(le).use(ut).use(de, {
|
|
2106
|
+
handlers: {
|
|
2107
|
+
...ce,
|
|
2108
|
+
code: no
|
|
2109
|
+
}
|
|
2110
|
+
}).use(ct).process(n);
|
|
1980
2111
|
return _t(o.value, e, t);
|
|
1981
2112
|
}
|
|
1982
|
-
class
|
|
2113
|
+
class io {
|
|
1983
2114
|
constructor(e, t, o) {
|
|
1984
2115
|
u(this, "formattingToolbarState");
|
|
1985
2116
|
u(this, "updateFormattingToolbar");
|
|
@@ -1987,7 +2118,7 @@ class to {
|
|
|
1987
2118
|
u(this, "preventShow", !1);
|
|
1988
2119
|
u(this, "prevWasEditable", null);
|
|
1989
2120
|
u(this, "shouldShow", ({ view: e, state: t, from: o, to: r }) => {
|
|
1990
|
-
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length &&
|
|
2121
|
+
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length && Ut(t.selection);
|
|
1991
2122
|
return !(!e.hasFocus() || l || a);
|
|
1992
2123
|
});
|
|
1993
2124
|
u(this, "viewMousedownHandler", () => {
|
|
@@ -2028,25 +2159,25 @@ class to {
|
|
|
2028
2159
|
}, 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
2160
|
}
|
|
2030
2161
|
update(e, t) {
|
|
2031
|
-
var
|
|
2162
|
+
var p, f;
|
|
2032
2163
|
const { state: o, composing: r } = e, { doc: i, selection: s } = o, l = t && t.doc.eq(i) && t.selection.eq(s);
|
|
2033
2164
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
|
|
2034
2165
|
return;
|
|
2035
2166
|
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)),
|
|
2167
|
+
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
2168
|
view: e,
|
|
2038
2169
|
state: o,
|
|
2039
2170
|
from: d,
|
|
2040
2171
|
to: c
|
|
2041
2172
|
});
|
|
2042
|
-
if (this.editor.isEditable && !this.preventShow && (
|
|
2173
|
+
if (this.editor.isEditable && !this.preventShow && (h || this.preventHide)) {
|
|
2043
2174
|
this.formattingToolbarState = {
|
|
2044
2175
|
show: !0,
|
|
2045
2176
|
referencePos: this.getSelectionBoundingBox()
|
|
2046
2177
|
}, this.updateFormattingToolbar();
|
|
2047
2178
|
return;
|
|
2048
2179
|
}
|
|
2049
|
-
if ((f = this.formattingToolbarState) != null && f.show && !this.preventHide && (!
|
|
2180
|
+
if ((f = this.formattingToolbarState) != null && f.show && !this.preventHide && (!h || this.preventShow || !this.editor.isEditable)) {
|
|
2050
2181
|
this.formattingToolbarState.show = !1, this.updateFormattingToolbar();
|
|
2051
2182
|
return;
|
|
2052
2183
|
}
|
|
@@ -2056,25 +2187,25 @@ class to {
|
|
|
2056
2187
|
}
|
|
2057
2188
|
getSelectionBoundingBox() {
|
|
2058
2189
|
const { state: e } = this.pmView, { selection: t } = e, { ranges: o } = t, r = Math.min(...o.map((s) => s.$from.pos)), i = Math.max(...o.map((s) => s.$to.pos));
|
|
2059
|
-
if (
|
|
2190
|
+
if (Ft(t)) {
|
|
2060
2191
|
const s = this.pmView.nodeDOM(r);
|
|
2061
2192
|
if (s)
|
|
2062
2193
|
return s.getBoundingClientRect();
|
|
2063
2194
|
}
|
|
2064
|
-
return
|
|
2195
|
+
return q(this.pmView, r, i);
|
|
2065
2196
|
}
|
|
2066
2197
|
}
|
|
2067
|
-
const
|
|
2198
|
+
const so = new S(
|
|
2068
2199
|
"FormattingToolbarPlugin"
|
|
2069
2200
|
);
|
|
2070
|
-
class
|
|
2201
|
+
class ao extends G {
|
|
2071
2202
|
constructor(t) {
|
|
2072
2203
|
super();
|
|
2073
2204
|
u(this, "view");
|
|
2074
2205
|
u(this, "plugin");
|
|
2075
|
-
this.plugin = new
|
|
2076
|
-
key:
|
|
2077
|
-
view: (o) => (this.view = new
|
|
2206
|
+
this.plugin = new w({
|
|
2207
|
+
key: so,
|
|
2208
|
+
view: (o) => (this.view = new io(t, o, (r) => {
|
|
2078
2209
|
this.emit("update", r);
|
|
2079
2210
|
}), this.view)
|
|
2080
2211
|
});
|
|
@@ -2083,7 +2214,7 @@ class oo extends F {
|
|
|
2083
2214
|
return this.on("update", t);
|
|
2084
2215
|
}
|
|
2085
2216
|
}
|
|
2086
|
-
class
|
|
2217
|
+
class lo {
|
|
2087
2218
|
constructor(e, t, o) {
|
|
2088
2219
|
u(this, "hyperlinkToolbarState");
|
|
2089
2220
|
u(this, "updateHyperlinkToolbar");
|
|
@@ -2103,7 +2234,7 @@ class no {
|
|
|
2103
2234
|
), i = r.marks();
|
|
2104
2235
|
for (const s of i)
|
|
2105
2236
|
if (s.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2106
|
-
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange =
|
|
2237
|
+
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = et(
|
|
2107
2238
|
r,
|
|
2108
2239
|
s.type,
|
|
2109
2240
|
s.attrs
|
|
@@ -2123,7 +2254,7 @@ class no {
|
|
|
2123
2254
|
});
|
|
2124
2255
|
u(this, "scrollHandler", () => {
|
|
2125
2256
|
var e;
|
|
2126
|
-
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos =
|
|
2257
|
+
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos = q(
|
|
2127
2258
|
this.pmView,
|
|
2128
2259
|
this.hyperlinkMarkRange.from,
|
|
2129
2260
|
this.hyperlinkMarkRange.to
|
|
@@ -2171,7 +2302,7 @@ class no {
|
|
|
2171
2302
|
const o = this.pmView.state.selection.$from.marks();
|
|
2172
2303
|
for (const r of o)
|
|
2173
2304
|
if (r.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2174
|
-
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange =
|
|
2305
|
+
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange = et(
|
|
2175
2306
|
this.pmView.state.selection.$from,
|
|
2176
2307
|
r.type,
|
|
2177
2308
|
r.attrs
|
|
@@ -2182,7 +2313,7 @@ class no {
|
|
|
2182
2313
|
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
2314
|
this.hyperlinkToolbarState = {
|
|
2184
2315
|
show: !0,
|
|
2185
|
-
referencePos:
|
|
2316
|
+
referencePos: q(
|
|
2186
2317
|
this.pmView,
|
|
2187
2318
|
this.hyperlinkMarkRange.from,
|
|
2188
2319
|
this.hyperlinkMarkRange.to
|
|
@@ -2204,10 +2335,10 @@ class no {
|
|
|
2204
2335
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2205
2336
|
}
|
|
2206
2337
|
}
|
|
2207
|
-
const
|
|
2338
|
+
const co = new S(
|
|
2208
2339
|
"HyperlinkToolbarPlugin"
|
|
2209
2340
|
);
|
|
2210
|
-
class
|
|
2341
|
+
class uo extends G {
|
|
2211
2342
|
constructor(t) {
|
|
2212
2343
|
super();
|
|
2213
2344
|
u(this, "view");
|
|
@@ -2242,9 +2373,9 @@ class io extends F {
|
|
|
2242
2373
|
u(this, "stopHideTimer", () => {
|
|
2243
2374
|
this.view.stopMenuUpdateTimer();
|
|
2244
2375
|
});
|
|
2245
|
-
this.plugin = new
|
|
2246
|
-
key:
|
|
2247
|
-
view: (o) => (this.view = new
|
|
2376
|
+
this.plugin = new w({
|
|
2377
|
+
key: co,
|
|
2378
|
+
view: (o) => (this.view = new lo(t, o, (r) => {
|
|
2248
2379
|
this.emit("update", r);
|
|
2249
2380
|
}), this.view)
|
|
2250
2381
|
});
|
|
@@ -2253,7 +2384,7 @@ class io extends F {
|
|
|
2253
2384
|
return this.on("update", t);
|
|
2254
2385
|
}
|
|
2255
2386
|
}
|
|
2256
|
-
class
|
|
2387
|
+
class N extends j {
|
|
2257
2388
|
constructor(t, o) {
|
|
2258
2389
|
super(t, o);
|
|
2259
2390
|
u(this, "nodes");
|
|
@@ -2264,13 +2395,13 @@ class A extends $ {
|
|
|
2264
2395
|
});
|
|
2265
2396
|
}
|
|
2266
2397
|
static create(t, o, r = o) {
|
|
2267
|
-
return new
|
|
2398
|
+
return new N(t.resolve(o), t.resolve(r));
|
|
2268
2399
|
}
|
|
2269
2400
|
content() {
|
|
2270
|
-
return new
|
|
2401
|
+
return new x(_.from(this.nodes), 0, 0);
|
|
2271
2402
|
}
|
|
2272
2403
|
eq(t) {
|
|
2273
|
-
if (!(t instanceof
|
|
2404
|
+
if (!(t instanceof N) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
|
|
2274
2405
|
return !1;
|
|
2275
2406
|
for (let o = 0; o < this.nodes.length; o++)
|
|
2276
2407
|
if (!this.nodes[o].eq(t.nodes[o]))
|
|
@@ -2278,8 +2409,8 @@ class A extends $ {
|
|
|
2278
2409
|
return !0;
|
|
2279
2410
|
}
|
|
2280
2411
|
map(t, o) {
|
|
2281
|
-
|
|
2282
|
-
return i.deleted ?
|
|
2412
|
+
const r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2413
|
+
return i.deleted ? j.near(t.resolve(r.pos)) : r.deleted ? j.near(t.resolve(i.pos)) : new N(
|
|
2283
2414
|
t.resolve(r.pos),
|
|
2284
2415
|
t.resolve(i.pos)
|
|
2285
2416
|
);
|
|
@@ -2288,13 +2419,13 @@ class A extends $ {
|
|
|
2288
2419
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
2289
2420
|
}
|
|
2290
2421
|
}
|
|
2291
|
-
const
|
|
2292
|
-
let
|
|
2293
|
-
function
|
|
2422
|
+
const po = se.__serializeForClipboard;
|
|
2423
|
+
let B;
|
|
2424
|
+
function Ht(n, e) {
|
|
2294
2425
|
var r;
|
|
2295
2426
|
if (!e.dom.isConnected)
|
|
2296
2427
|
return;
|
|
2297
|
-
|
|
2428
|
+
const t = e.posAtCoords(n);
|
|
2298
2429
|
if (!t)
|
|
2299
2430
|
return;
|
|
2300
2431
|
let o = e.domAtPos(t.pos).node;
|
|
@@ -2305,16 +2436,15 @@ function It(n, e) {
|
|
|
2305
2436
|
return { node: o, id: o.getAttribute("data-id") };
|
|
2306
2437
|
}
|
|
2307
2438
|
}
|
|
2308
|
-
function
|
|
2309
|
-
|
|
2439
|
+
function ho(n, e) {
|
|
2440
|
+
const t = Ht(n, e);
|
|
2310
2441
|
if (t && t.node.nodeType === 1) {
|
|
2311
|
-
const o = e.docView;
|
|
2312
|
-
let r = o.nearestDesc(t.node, !0);
|
|
2442
|
+
const o = e.docView, r = o.nearestDesc(t.node, !0);
|
|
2313
2443
|
return !r || r === o ? null : r.posBefore;
|
|
2314
2444
|
}
|
|
2315
2445
|
return null;
|
|
2316
2446
|
}
|
|
2317
|
-
function
|
|
2447
|
+
function fo(n, e) {
|
|
2318
2448
|
let t, o;
|
|
2319
2449
|
const r = e.resolve(n.from).node().type.spec.group === "blockContent", i = e.resolve(n.to).node().type.spec.group === "blockContent", s = Math.min(n.$anchor.depth, n.$head.depth);
|
|
2320
2450
|
if (r && i) {
|
|
@@ -2324,9 +2454,9 @@ function lo(n, e) {
|
|
|
2324
2454
|
t = n.from, o = n.to;
|
|
2325
2455
|
return { from: t, to: o };
|
|
2326
2456
|
}
|
|
2327
|
-
function
|
|
2457
|
+
function at(n, e, t = e) {
|
|
2328
2458
|
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,
|
|
2459
|
+
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
2460
|
r,
|
|
2331
2461
|
// Expects from position to be just before the first selected block.
|
|
2332
2462
|
n.domAtPos(e + 1).node.parentElement
|
|
@@ -2337,36 +2467,35 @@ function st(n, e, t = e) {
|
|
|
2337
2467
|
);
|
|
2338
2468
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
2339
2469
|
(c > l || c < s) && o.removeChild(o.children[c]);
|
|
2340
|
-
|
|
2470
|
+
Nt(), B = o;
|
|
2341
2471
|
const d = n.dom.className.split(" ").filter(
|
|
2342
2472
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
2343
2473
|
).join(" ");
|
|
2344
|
-
|
|
2474
|
+
B.className = B.className + " " + H.dragPreview + " " + d, document.body.appendChild(B);
|
|
2345
2475
|
}
|
|
2346
|
-
function
|
|
2347
|
-
|
|
2476
|
+
function Nt() {
|
|
2477
|
+
B !== void 0 && (document.body.removeChild(B), B = void 0);
|
|
2348
2478
|
}
|
|
2349
|
-
function
|
|
2479
|
+
function mo(n, e) {
|
|
2350
2480
|
if (!n.dataTransfer)
|
|
2351
2481
|
return;
|
|
2352
|
-
const t = e.dom.getBoundingClientRect()
|
|
2353
|
-
let o = {
|
|
2482
|
+
const t = e.dom.getBoundingClientRect(), o = {
|
|
2354
2483
|
left: t.left + t.width / 2,
|
|
2355
2484
|
// take middle of editor
|
|
2356
2485
|
top: n.clientY
|
|
2357
|
-
}, r =
|
|
2486
|
+
}, r = ho(o, e);
|
|
2358
2487
|
if (r != null) {
|
|
2359
|
-
const i = e.state.selection, s = e.state.doc, { from: l, to: a } =
|
|
2488
|
+
const i = e.state.selection, s = e.state.doc, { from: l, to: a } = fo(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof N;
|
|
2360
2489
|
d && c ? (e.dispatch(
|
|
2361
|
-
e.state.tr.setSelection(
|
|
2362
|
-
),
|
|
2363
|
-
e.state.tr.setSelection(
|
|
2364
|
-
),
|
|
2365
|
-
|
|
2366
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html",
|
|
2490
|
+
e.state.tr.setSelection(N.create(s, l, a))
|
|
2491
|
+
), at(e, l, a)) : (e.dispatch(
|
|
2492
|
+
e.state.tr.setSelection(re.create(e.state.doc, r))
|
|
2493
|
+
), at(e, r));
|
|
2494
|
+
const h = e.state.selection.content(), { dom: p, text: f } = po(e, h);
|
|
2495
|
+
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", p.innerHTML), n.dataTransfer.setData("text/plain", f), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(B, 0, 0), e.dragging = { slice: h, move: !0 };
|
|
2367
2496
|
}
|
|
2368
2497
|
}
|
|
2369
|
-
class
|
|
2498
|
+
class ko {
|
|
2370
2499
|
constructor(e, t, o) {
|
|
2371
2500
|
u(this, "sideMenuState");
|
|
2372
2501
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
@@ -2392,7 +2521,7 @@ class uo {
|
|
|
2392
2521
|
u(this, "onDrop", (e) => {
|
|
2393
2522
|
if (this.editor._tiptapEditor.commands.blur(), e.synthetic || !this.isDragging)
|
|
2394
2523
|
return;
|
|
2395
|
-
|
|
2524
|
+
const t = this.pmView.posAtCoords({
|
|
2396
2525
|
left: e.clientX,
|
|
2397
2526
|
top: e.clientY
|
|
2398
2527
|
});
|
|
@@ -2409,7 +2538,7 @@ class uo {
|
|
|
2409
2538
|
u(this, "onDragOver", (e) => {
|
|
2410
2539
|
if (e.synthetic || !this.isDragging)
|
|
2411
2540
|
return;
|
|
2412
|
-
|
|
2541
|
+
const t = this.pmView.posAtCoords({
|
|
2413
2542
|
left: e.clientX,
|
|
2414
2543
|
top: e.clientY
|
|
2415
2544
|
});
|
|
@@ -2423,7 +2552,7 @@ class uo {
|
|
|
2423
2552
|
(t = this.sideMenuState) != null && t.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2424
2553
|
});
|
|
2425
2554
|
u(this, "onMouseMove", (e) => {
|
|
2426
|
-
var d, c,
|
|
2555
|
+
var d, c, h, p, f;
|
|
2427
2556
|
if (this.menuFrozen)
|
|
2428
2557
|
return;
|
|
2429
2558
|
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;
|
|
@@ -2441,12 +2570,12 @@ class uo {
|
|
|
2441
2570
|
left: t.left + t.width / 2,
|
|
2442
2571
|
// take middle of editor
|
|
2443
2572
|
top: e.clientY
|
|
2444
|
-
}, l =
|
|
2573
|
+
}, l = Ht(s, this.pmView);
|
|
2445
2574
|
if (!l || !this.editor.isEditable) {
|
|
2446
2575
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2447
2576
|
return;
|
|
2448
2577
|
}
|
|
2449
|
-
if ((
|
|
2578
|
+
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
2579
|
return;
|
|
2451
2580
|
this.hoveredBlock = l.node;
|
|
2452
2581
|
const a = l.node.firstChild;
|
|
@@ -2493,7 +2622,7 @@ class uo {
|
|
|
2493
2622
|
});
|
|
2494
2623
|
if (!o)
|
|
2495
2624
|
return;
|
|
2496
|
-
const r =
|
|
2625
|
+
const r = k(
|
|
2497
2626
|
this.editor._tiptapEditor.state.doc,
|
|
2498
2627
|
o.pos
|
|
2499
2628
|
);
|
|
@@ -2506,7 +2635,7 @@ class uo {
|
|
|
2506
2635
|
} else
|
|
2507
2636
|
this.editor._tiptapEditor.commands.setTextSelection(s);
|
|
2508
2637
|
this.pmView.focus(), this.pmView.dispatch(
|
|
2509
|
-
this.pmView.state.tr.scrollIntoView().setMeta(
|
|
2638
|
+
this.pmView.state.tr.scrollIntoView().setMeta(X, {
|
|
2510
2639
|
// TODO import suggestion plugin key
|
|
2511
2640
|
activate: !0,
|
|
2512
2641
|
type: "drag"
|
|
@@ -2514,8 +2643,8 @@ class uo {
|
|
|
2514
2643
|
);
|
|
2515
2644
|
}
|
|
2516
2645
|
}
|
|
2517
|
-
const
|
|
2518
|
-
class
|
|
2646
|
+
const go = new S("SideMenuPlugin");
|
|
2647
|
+
class bo extends G {
|
|
2519
2648
|
constructor(t) {
|
|
2520
2649
|
super();
|
|
2521
2650
|
u(this, "sideMenuView");
|
|
@@ -2529,12 +2658,12 @@ class ho extends F {
|
|
|
2529
2658
|
* Handles drag & drop events for blocks.
|
|
2530
2659
|
*/
|
|
2531
2660
|
u(this, "blockDragStart", (t) => {
|
|
2532
|
-
this.sideMenuView.isDragging = !0,
|
|
2661
|
+
this.sideMenuView.isDragging = !0, mo(t, this.editor.prosemirrorView);
|
|
2533
2662
|
});
|
|
2534
2663
|
/**
|
|
2535
2664
|
* Handles drag & drop events for blocks.
|
|
2536
2665
|
*/
|
|
2537
|
-
u(this, "blockDragEnd", () =>
|
|
2666
|
+
u(this, "blockDragEnd", () => Nt());
|
|
2538
2667
|
/**
|
|
2539
2668
|
* Freezes the side menu. When frozen, the side menu will stay
|
|
2540
2669
|
* attached to the same block regardless of which block is hovered by the
|
|
@@ -2547,9 +2676,9 @@ class ho extends F {
|
|
|
2547
2676
|
* mouse cursor.
|
|
2548
2677
|
*/
|
|
2549
2678
|
u(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2550
|
-
this.editor = t, this.plugin = new
|
|
2551
|
-
key:
|
|
2552
|
-
view: (o) => (this.sideMenuView = new
|
|
2679
|
+
this.editor = t, this.plugin = new w({
|
|
2680
|
+
key: go,
|
|
2681
|
+
view: (o) => (this.sideMenuView = new ko(
|
|
2553
2682
|
t,
|
|
2554
2683
|
o,
|
|
2555
2684
|
(r) => {
|
|
@@ -2562,59 +2691,59 @@ class ho extends F {
|
|
|
2562
2691
|
return this.on("update", t);
|
|
2563
2692
|
}
|
|
2564
2693
|
}
|
|
2565
|
-
function
|
|
2694
|
+
function I(n, e) {
|
|
2566
2695
|
const t = n.getTextCursorPosition().block;
|
|
2567
2696
|
t.content.length === 1 && t.content[0].type === "text" && t.content[0].text === "/" || t.content.length === 0 ? n.updateBlock(t, e) : (n.insertBlocks([e], t, "after"), n.setTextCursorPosition(n.getTextCursorPosition().nextBlock));
|
|
2568
2697
|
}
|
|
2569
|
-
const
|
|
2698
|
+
const yo = (n = St) => {
|
|
2570
2699
|
var t, o, r;
|
|
2571
2700
|
const e = [];
|
|
2572
2701
|
return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes("1") && e.push({
|
|
2573
2702
|
name: "Heading",
|
|
2574
2703
|
aliases: ["h", "heading1", "h1"],
|
|
2575
|
-
execute: (i) =>
|
|
2704
|
+
execute: (i) => I(i, {
|
|
2576
2705
|
type: "heading",
|
|
2577
2706
|
props: { level: "1" }
|
|
2578
2707
|
})
|
|
2579
2708
|
}), (o = n.heading.propSchema.level.values) != null && o.includes("2") && e.push({
|
|
2580
2709
|
name: "Heading 2",
|
|
2581
2710
|
aliases: ["h2", "heading2", "subheading"],
|
|
2582
|
-
execute: (i) =>
|
|
2711
|
+
execute: (i) => I(i, {
|
|
2583
2712
|
type: "heading",
|
|
2584
2713
|
props: { level: "2" }
|
|
2585
2714
|
})
|
|
2586
2715
|
}), (r = n.heading.propSchema.level.values) != null && r.includes("3") && e.push({
|
|
2587
2716
|
name: "Heading 3",
|
|
2588
2717
|
aliases: ["h3", "heading3", "subheading"],
|
|
2589
|
-
execute: (i) =>
|
|
2718
|
+
execute: (i) => I(i, {
|
|
2590
2719
|
type: "heading",
|
|
2591
2720
|
props: { level: "3" }
|
|
2592
2721
|
})
|
|
2593
2722
|
})), "bulletListItem" in n && e.push({
|
|
2594
2723
|
name: "Bullet List",
|
|
2595
2724
|
aliases: ["ul", "list", "bulletlist", "bullet list"],
|
|
2596
|
-
execute: (i) =>
|
|
2725
|
+
execute: (i) => I(i, {
|
|
2597
2726
|
type: "bulletListItem"
|
|
2598
2727
|
})
|
|
2599
2728
|
}), "numberedListItem" in n && e.push({
|
|
2600
2729
|
name: "Numbered List",
|
|
2601
2730
|
aliases: ["li", "list", "numberedlist", "numbered list"],
|
|
2602
|
-
execute: (i) =>
|
|
2731
|
+
execute: (i) => I(i, {
|
|
2603
2732
|
type: "numberedListItem"
|
|
2604
2733
|
})
|
|
2605
2734
|
}), "paragraph" in n && e.push({
|
|
2606
2735
|
name: "Paragraph",
|
|
2607
2736
|
aliases: ["p"],
|
|
2608
|
-
execute: (i) =>
|
|
2737
|
+
execute: (i) => I(i, {
|
|
2609
2738
|
type: "paragraph"
|
|
2610
2739
|
})
|
|
2611
2740
|
}), e;
|
|
2612
|
-
},
|
|
2741
|
+
}, vo = {
|
|
2613
2742
|
enableInputRules: !0,
|
|
2614
2743
|
enablePasteRules: !0,
|
|
2615
2744
|
enableCoreExtensions: !1
|
|
2616
2745
|
};
|
|
2617
|
-
class
|
|
2746
|
+
class Qo {
|
|
2618
2747
|
constructor(e = {}) {
|
|
2619
2748
|
u(this, "_tiptapEditor");
|
|
2620
2749
|
u(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
@@ -2624,7 +2753,7 @@ class Wo {
|
|
|
2624
2753
|
u(this, "formattingToolbar");
|
|
2625
2754
|
u(this, "slashMenu");
|
|
2626
2755
|
u(this, "hyperlinkToolbar");
|
|
2627
|
-
var l, a, d;
|
|
2756
|
+
var l, a, d, c, h;
|
|
2628
2757
|
this.options = e;
|
|
2629
2758
|
const t = {
|
|
2630
2759
|
defaultStyles: !0,
|
|
@@ -2633,18 +2762,19 @@ class Wo {
|
|
|
2633
2762
|
// If BSchema is not specified, then options.blockSchema should also not
|
|
2634
2763
|
// be defined. Unfortunately, trying to implement these constraints seems
|
|
2635
2764
|
// to be a huge pain, hence the `as any` casts.
|
|
2636
|
-
blockSchema: e.blockSchema ||
|
|
2765
|
+
blockSchema: e.blockSchema || St,
|
|
2637
2766
|
...e
|
|
2638
2767
|
};
|
|
2639
|
-
this.sideMenu = new
|
|
2768
|
+
this.sideMenu = new bo(this), this.formattingToolbar = new ao(this), this.slashMenu = new $e(
|
|
2640
2769
|
this,
|
|
2641
|
-
t.slashMenuItems ||
|
|
2642
|
-
), this.hyperlinkToolbar = new
|
|
2643
|
-
const o =
|
|
2770
|
+
t.slashMenuItems || yo(t.blockSchema)
|
|
2771
|
+
), this.hyperlinkToolbar = new uo(this);
|
|
2772
|
+
const o = Xe({
|
|
2644
2773
|
editor: this,
|
|
2774
|
+
domAttributes: t.domAttributes || {},
|
|
2645
2775
|
blockSchema: t.blockSchema,
|
|
2646
2776
|
collaboration: t.collaboration
|
|
2647
|
-
}), r =
|
|
2777
|
+
}), r = T.create({
|
|
2648
2778
|
name: "BlockNoteUIExtension",
|
|
2649
2779
|
addProseMirrorPlugins: () => [
|
|
2650
2780
|
this.sideMenu.plugin,
|
|
@@ -2657,49 +2787,48 @@ class Wo {
|
|
|
2657
2787
|
const i = t.initialContent || (e.collaboration ? void 0 : [
|
|
2658
2788
|
{
|
|
2659
2789
|
type: "paragraph",
|
|
2660
|
-
id:
|
|
2790
|
+
id: F.options.generateID()
|
|
2661
2791
|
}
|
|
2662
2792
|
]), s = {
|
|
2663
|
-
...
|
|
2793
|
+
...vo,
|
|
2664
2794
|
...t._tiptapOptions,
|
|
2665
2795
|
onCreate: () => {
|
|
2666
|
-
var
|
|
2667
|
-
(
|
|
2796
|
+
var p;
|
|
2797
|
+
(p = t.onEditorReady) == null || p.call(t, this), this.ready = !0;
|
|
2668
2798
|
},
|
|
2669
|
-
onBeforeCreate(
|
|
2799
|
+
onBeforeCreate(p) {
|
|
2670
2800
|
if (!i)
|
|
2671
2801
|
return;
|
|
2672
|
-
const
|
|
2802
|
+
const f = p.editor.schema, m = i.map((b) => D(b, f)), g = f.node(
|
|
2673
2803
|
"doc",
|
|
2674
2804
|
void 0,
|
|
2675
|
-
|
|
2805
|
+
f.node("blockGroup", void 0, m)
|
|
2676
2806
|
);
|
|
2677
|
-
|
|
2807
|
+
p.editor.options.content = g.toJSON();
|
|
2678
2808
|
},
|
|
2679
2809
|
onUpdate: () => {
|
|
2680
|
-
var
|
|
2681
|
-
this.ready && ((
|
|
2810
|
+
var p;
|
|
2811
|
+
this.ready && ((p = t.onEditorContentChange) == null || p.call(t, this));
|
|
2682
2812
|
},
|
|
2683
2813
|
onSelectionUpdate: () => {
|
|
2684
|
-
var
|
|
2685
|
-
this.ready && ((
|
|
2814
|
+
var p;
|
|
2815
|
+
this.ready && ((p = t.onTextCursorPositionChange) == null || p.call(t, this));
|
|
2686
2816
|
},
|
|
2687
2817
|
editable: e.editable === void 0 ? !0 : e.editable,
|
|
2688
2818
|
extensions: t.enableBlockNoteExtensions === !1 ? (l = t._tiptapOptions) == null ? void 0 : l.extensions : [...((a = t._tiptapOptions) == null ? void 0 : a.extensions) || [], ...o],
|
|
2689
2819
|
editorProps: {
|
|
2690
2820
|
attributes: {
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
class: [
|
|
2821
|
+
...(d = t.domAttributes) == null ? void 0 : d.editor,
|
|
2822
|
+
class: v(
|
|
2694
2823
|
H.bnEditor,
|
|
2695
2824
|
H.bnRoot,
|
|
2696
2825
|
t.defaultStyles ? H.defaultStyles : "",
|
|
2697
|
-
((
|
|
2698
|
-
|
|
2826
|
+
((h = (c = t.domAttributes) == null ? void 0 : c.editor) == null ? void 0 : h.class) || ""
|
|
2827
|
+
)
|
|
2699
2828
|
}
|
|
2700
2829
|
}
|
|
2701
2830
|
};
|
|
2702
|
-
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new
|
|
2831
|
+
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new Gt(s);
|
|
2703
2832
|
}
|
|
2704
2833
|
get prosemirrorView() {
|
|
2705
2834
|
return this._tiptapEditor.view;
|
|
@@ -2719,7 +2848,7 @@ class Wo {
|
|
|
2719
2848
|
*/
|
|
2720
2849
|
get topLevelBlocks() {
|
|
2721
2850
|
const e = [];
|
|
2722
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(
|
|
2851
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(E(t, this.schema, this.blockCache)), !1)), e;
|
|
2723
2852
|
}
|
|
2724
2853
|
/**
|
|
2725
2854
|
* Gets a snapshot of an existing block from the editor.
|
|
@@ -2729,7 +2858,7 @@ class Wo {
|
|
|
2729
2858
|
getBlock(e) {
|
|
2730
2859
|
const t = typeof e == "string" ? e : e.id;
|
|
2731
2860
|
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 =
|
|
2861
|
+
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
2862
|
}
|
|
2734
2863
|
/**
|
|
2735
2864
|
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
@@ -2770,7 +2899,7 @@ class Wo {
|
|
|
2770
2899
|
* @returns A snapshot of the current text cursor position.
|
|
2771
2900
|
*/
|
|
2772
2901
|
getTextCursorPosition() {
|
|
2773
|
-
const { node: e, depth: t, startPos: o, endPos: r } =
|
|
2902
|
+
const { node: e, depth: t, startPos: o, endPos: r } = k(
|
|
2774
2903
|
this._tiptapEditor.state.doc,
|
|
2775
2904
|
this._tiptapEditor.state.selection.from
|
|
2776
2905
|
), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), s = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
|
|
@@ -2778,9 +2907,9 @@ class Wo {
|
|
|
2778
2907
|
i > 0 && (l = this._tiptapEditor.state.doc.resolve(o - 2).node());
|
|
2779
2908
|
let a;
|
|
2780
2909
|
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 :
|
|
2910
|
+
block: E(e, this.schema, this.blockCache),
|
|
2911
|
+
prevBlock: l === void 0 ? void 0 : E(l, this.schema, this.blockCache),
|
|
2912
|
+
nextBlock: a === void 0 ? void 0 : E(a, this.schema, this.blockCache)
|
|
2784
2913
|
};
|
|
2785
2914
|
}
|
|
2786
2915
|
/**
|
|
@@ -2790,7 +2919,7 @@ class Wo {
|
|
|
2790
2919
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
2791
2920
|
*/
|
|
2792
2921
|
setTextCursorPosition(e, t = "start") {
|
|
2793
|
-
const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } =
|
|
2922
|
+
const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } = Z(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = k(
|
|
2794
2923
|
this._tiptapEditor.state.doc,
|
|
2795
2924
|
r + 2
|
|
2796
2925
|
);
|
|
@@ -2806,7 +2935,7 @@ class Wo {
|
|
|
2806
2935
|
return;
|
|
2807
2936
|
const e = [];
|
|
2808
2937
|
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
|
-
|
|
2938
|
+
E(
|
|
2810
2939
|
this._tiptapEditor.state.doc.resolve(o).node(),
|
|
2811
2940
|
this.schema,
|
|
2812
2941
|
this.blockCache
|
|
@@ -2836,7 +2965,7 @@ class Wo {
|
|
|
2836
2965
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
2837
2966
|
*/
|
|
2838
2967
|
insertBlocks(e, t, o = "before") {
|
|
2839
|
-
|
|
2968
|
+
xt(e, t, o, this._tiptapEditor);
|
|
2840
2969
|
}
|
|
2841
2970
|
/**
|
|
2842
2971
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -2846,14 +2975,14 @@ class Wo {
|
|
|
2846
2975
|
* @param update A partial block which defines how the existing block should be changed.
|
|
2847
2976
|
*/
|
|
2848
2977
|
updateBlock(e, t) {
|
|
2849
|
-
|
|
2978
|
+
Ze(e, t, this._tiptapEditor);
|
|
2850
2979
|
}
|
|
2851
2980
|
/**
|
|
2852
2981
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
2853
2982
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
2854
2983
|
*/
|
|
2855
2984
|
removeBlocks(e) {
|
|
2856
|
-
|
|
2985
|
+
At(e, this._tiptapEditor);
|
|
2857
2986
|
}
|
|
2858
2987
|
/**
|
|
2859
2988
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -2863,7 +2992,7 @@ class Wo {
|
|
|
2863
2992
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
2864
2993
|
*/
|
|
2865
2994
|
replaceBlocks(e, t) {
|
|
2866
|
-
|
|
2995
|
+
Qe(e, t, this._tiptapEditor);
|
|
2867
2996
|
}
|
|
2868
2997
|
/**
|
|
2869
2998
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -2944,7 +3073,7 @@ class Wo {
|
|
|
2944
3073
|
createLink(e, t) {
|
|
2945
3074
|
if (e === "")
|
|
2946
3075
|
return;
|
|
2947
|
-
|
|
3076
|
+
const { from: o, to: r } = this._tiptapEditor.state.selection;
|
|
2948
3077
|
t || (t = this._tiptapEditor.state.doc.textBetween(o, r));
|
|
2949
3078
|
const i = this._tiptapEditor.schema.mark("link", { href: e });
|
|
2950
3079
|
this._tiptapEditor.view.dispatch(
|
|
@@ -2955,7 +3084,7 @@ class Wo {
|
|
|
2955
3084
|
* Checks if the block containing the text cursor can be nested.
|
|
2956
3085
|
*/
|
|
2957
3086
|
canNestBlock() {
|
|
2958
|
-
const { startPos: e, depth: t } =
|
|
3087
|
+
const { startPos: e, depth: t } = k(
|
|
2959
3088
|
this._tiptapEditor.state.doc,
|
|
2960
3089
|
this._tiptapEditor.state.selection.from
|
|
2961
3090
|
);
|
|
@@ -2971,7 +3100,7 @@ class Wo {
|
|
|
2971
3100
|
* Checks if the block containing the text cursor is nested.
|
|
2972
3101
|
*/
|
|
2973
3102
|
canUnnestBlock() {
|
|
2974
|
-
const { depth: e } =
|
|
3103
|
+
const { depth: e } = k(
|
|
2975
3104
|
this._tiptapEditor.state.doc,
|
|
2976
3105
|
this._tiptapEditor.state.selection.from
|
|
2977
3106
|
);
|
|
@@ -2990,7 +3119,7 @@ class Wo {
|
|
|
2990
3119
|
* @returns The blocks, serialized as an HTML string.
|
|
2991
3120
|
*/
|
|
2992
3121
|
async blocksToHTML(e) {
|
|
2993
|
-
return
|
|
3122
|
+
return It(e, this._tiptapEditor.schema);
|
|
2994
3123
|
}
|
|
2995
3124
|
/**
|
|
2996
3125
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -3009,7 +3138,7 @@ class Wo {
|
|
|
3009
3138
|
* @returns The blocks, serialized as a Markdown string.
|
|
3010
3139
|
*/
|
|
3011
3140
|
async blocksToMarkdown(e) {
|
|
3012
|
-
return
|
|
3141
|
+
return oo(e, this._tiptapEditor.schema);
|
|
3013
3142
|
}
|
|
3014
3143
|
/**
|
|
3015
3144
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -3019,7 +3148,7 @@ class Wo {
|
|
|
3019
3148
|
* @returns The blocks parsed from the Markdown string.
|
|
3020
3149
|
*/
|
|
3021
3150
|
async markdownToBlocks(e) {
|
|
3022
|
-
return
|
|
3151
|
+
return ro(e, this.schema, this._tiptapEditor.schema);
|
|
3023
3152
|
}
|
|
3024
3153
|
/**
|
|
3025
3154
|
* Updates the user info for the current user that's shown to other collaborators.
|
|
@@ -3033,29 +3162,33 @@ class Wo {
|
|
|
3033
3162
|
}
|
|
3034
3163
|
}
|
|
3035
3164
|
export {
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3165
|
+
Qo as BlockNoteEditor,
|
|
3166
|
+
ze as CustomBlockSerializerExtension,
|
|
3167
|
+
ao as FormattingToolbarProsemirrorPlugin,
|
|
3168
|
+
io as FormattingToolbarView,
|
|
3169
|
+
uo as HyperlinkToolbarProsemirrorPlugin,
|
|
3170
|
+
bo as SideMenuProsemirrorPlugin,
|
|
3171
|
+
ko as SideMenuView,
|
|
3172
|
+
$e as SlashMenuProsemirrorPlugin,
|
|
3173
|
+
ye as UnreachableCaseError,
|
|
3174
|
+
Jo as blockStyles,
|
|
3175
|
+
rt as camelToDataKebab,
|
|
3176
|
+
Zo as createBlockSpec,
|
|
3177
|
+
O as createTipTapBlock,
|
|
3178
|
+
St as defaultBlockSchema,
|
|
3179
|
+
P as defaultProps,
|
|
3180
|
+
Xo as formatKeyboardShortcut,
|
|
3181
|
+
so as formattingToolbarPluginKey,
|
|
3182
|
+
Xe as getBlockNoteExtensions,
|
|
3183
|
+
yo as getDefaultSlashMenuItems,
|
|
3184
|
+
co as hyperlinkToolbarPluginKey,
|
|
3185
|
+
be as isAppleOS,
|
|
3186
|
+
v as mergeCSSClasses,
|
|
3187
|
+
Ce as parse,
|
|
3188
|
+
ve as propsToAttributes,
|
|
3189
|
+
we as render,
|
|
3190
|
+
Ge as setupSuggestionsMenu,
|
|
3191
|
+
go as sideMenuPluginKey,
|
|
3192
|
+
X as slashMenuPluginKey
|
|
3060
3193
|
};
|
|
3061
3194
|
//# sourceMappingURL=blocknote.js.map
|