@blocknote/core 0.9.3 → 0.9.4
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 +1623 -1318
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -5
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +44 -12
- package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +21 -21
- package/src/api/blockManipulation/blockManipulation.test.ts +8 -11
- package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +3 -3
- package/src/api/formatConversions/formatConversions.test.ts +5 -5
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +3 -3
- package/src/api/nodeConversions/nodeConversions.test.ts +10 -4
- package/src/api/nodeConversions/nodeConversions.ts +9 -7
- package/src/api/nodeConversions/testUtil.ts +3 -3
- package/src/editor.module.css +1 -1
- package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +5 -3
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +2 -1
- package/src/extensions/Blocks/NonEditableBlockPlugin.ts +17 -0
- package/src/extensions/Blocks/api/block.ts +29 -16
- package/src/extensions/Blocks/api/blockTypes.ts +79 -27
- package/src/extensions/Blocks/api/defaultBlocks.ts +13 -41
- package/src/extensions/Blocks/api/defaultProps.ts +16 -0
- package/src/extensions/Blocks/nodes/Block.module.css +78 -24
- package/src/extensions/Blocks/nodes/BlockContainer.ts +17 -41
- package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +59 -13
- package/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.ts +305 -0
- package/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +13 -0
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +24 -2
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +146 -120
- package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +12 -2
- package/src/extensions/ImageToolbar/ImageToolbarPlugin.ts +239 -0
- package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +47 -6
- package/src/extensions/TextColor/TextColorExtension.ts +4 -3
- package/src/extensions/TextColor/TextColorMark.ts +2 -1
- package/src/index.ts +4 -0
- package/types/src/BlockNoteEditor.d.ts +9 -0
- package/types/src/BlockNoteExtensions.d.ts +1 -1
- package/types/src/extensions/Blocks/api/block.d.ts +7 -8
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +29 -20
- package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +55 -51
- package/types/src/extensions/Blocks/api/defaultProps.d.ts +2 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +43 -9
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.d.ts +2 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +1 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/uploadToTmpFilesOrg_DEV_ONLY.d.ts +1 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +35 -9
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +35 -9
- package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +36 -1
- package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +1 -1
- package/types/src/index.d.ts +4 -0
- package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +1 -1
package/dist/blocknote.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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 {
|
|
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
|
|
30
|
-
import { unified as
|
|
31
|
-
import { fromDom as
|
|
32
|
-
const
|
|
33
|
-
bnEditor:
|
|
34
|
-
bnRoot:
|
|
35
|
-
defaultStyles:
|
|
36
|
-
dragPreview:
|
|
37
|
-
"collaboration-cursor__caret": "_collaboration-
|
|
38
|
-
"collaboration-cursor__label": "_collaboration-
|
|
1
|
+
var Yt = Object.defineProperty;
|
|
2
|
+
var Jt = (n, e, t) => e in n ? Yt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var u = (n, e, t) => (Jt(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { Extension as A, Mark as ht, combineTransactionSteps as Zt, getChangedRanges as Qt, findChildrenInRange as te, findChildren as nt, Node as G, mergeAttributes as N, findParentNode as ee, extensions as R, InputRule as Z, isTextSelection as oe, isNodeSelection as ne, posToDOMRect as K, getMarkRange as rt, Editor as re } from "@tiptap/core";
|
|
5
|
+
import { Bold as ie } from "@tiptap/extension-bold";
|
|
6
|
+
import { Code as se } from "@tiptap/extension-code";
|
|
7
|
+
import ae from "@tiptap/extension-collaboration";
|
|
8
|
+
import le from "@tiptap/extension-collaboration-cursor";
|
|
9
|
+
import { Dropcursor as de } from "@tiptap/extension-dropcursor";
|
|
10
|
+
import { Gapcursor as ce } from "@tiptap/extension-gapcursor";
|
|
11
|
+
import { HardBreak as ue } from "@tiptap/extension-hard-break";
|
|
12
|
+
import { History as pe } from "@tiptap/extension-history";
|
|
13
|
+
import { Italic as he } from "@tiptap/extension-italic";
|
|
14
|
+
import { Link as me } from "@tiptap/extension-link";
|
|
15
|
+
import { Strike as fe } from "@tiptap/extension-strike";
|
|
16
|
+
import { Text as ge } from "@tiptap/extension-text";
|
|
17
|
+
import { Underline as ke } from "@tiptap/extension-underline";
|
|
18
|
+
import { Slice as L, Fragment as P, DOMSerializer as Y, DOMParser as be } from "prosemirror-model";
|
|
19
|
+
import { Plugin as T, PluginKey as B, NodeSelection as mt, TextSelection as it, Selection as X } from "prosemirror-state";
|
|
20
|
+
import { v4 as ye } from "uuid";
|
|
21
|
+
import * as ve from "prosemirror-view";
|
|
22
|
+
import { Decoration as W, DecorationSet as $ } from "prosemirror-view";
|
|
23
|
+
import ft from "rehype-parse";
|
|
24
|
+
import we from "rehype-remark";
|
|
25
|
+
import gt from "rehype-stringify";
|
|
26
|
+
import kt from "remark-gfm";
|
|
27
|
+
import Ce from "remark-parse";
|
|
28
|
+
import Ee, { defaultHandlers as Se } from "remark-rehype";
|
|
29
|
+
import Te from "remark-stringify";
|
|
30
|
+
import { unified as Q } from "unified";
|
|
31
|
+
import { fromDom as st } from "hast-util-from-dom";
|
|
32
|
+
const Me = "_bnEditor_12je0_3", Be = "_bnRoot_12je0_19", xe = "_defaultStyles_12je0_34", Ie = "_dragPreview_12je0_57", D = {
|
|
33
|
+
bnEditor: Me,
|
|
34
|
+
bnRoot: Be,
|
|
35
|
+
defaultStyles: xe,
|
|
36
|
+
dragPreview: Ie,
|
|
37
|
+
"collaboration-cursor__caret": "_collaboration-cursor__caret_12je0_63",
|
|
38
|
+
"collaboration-cursor__label": "_collaboration-cursor__label_12je0_74"
|
|
39
39
|
};
|
|
40
|
-
function
|
|
40
|
+
function bt(n) {
|
|
41
41
|
const e = n.attrs.id, t = n.firstChild, o = t.type, r = n.childCount === 2 ? n.lastChild.childCount : 0;
|
|
42
42
|
return {
|
|
43
43
|
id: e,
|
|
@@ -47,7 +47,7 @@ function pt(n) {
|
|
|
47
47
|
numChildBlocks: r
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function b(n, e) {
|
|
51
51
|
const o = n.nodeSize - 2;
|
|
52
52
|
if (e <= 1)
|
|
53
53
|
for (e = 1 + 1; n.resolve(e).parent.type.name !== "blockContainer" && e < o; )
|
|
@@ -67,19 +67,30 @@ function k(n, e) {
|
|
|
67
67
|
break;
|
|
68
68
|
l -= 1, s = r.node(l);
|
|
69
69
|
}
|
|
70
|
-
const { id: a, contentNode: d, contentType: c, numChildBlocks:
|
|
70
|
+
const { id: a, contentNode: d, contentType: c, numChildBlocks: m } = bt(s), h = r.start(l), p = r.end(l);
|
|
71
71
|
return {
|
|
72
72
|
id: a,
|
|
73
73
|
node: s,
|
|
74
74
|
contentNode: d,
|
|
75
75
|
contentType: c,
|
|
76
|
-
numChildBlocks:
|
|
77
|
-
startPos:
|
|
78
|
-
endPos:
|
|
76
|
+
numChildBlocks: m,
|
|
77
|
+
startPos: h,
|
|
78
|
+
endPos: p,
|
|
79
79
|
depth: l
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const C = {
|
|
83
|
+
backgroundColor: {
|
|
84
|
+
default: "default"
|
|
85
|
+
},
|
|
86
|
+
textColor: {
|
|
87
|
+
default: "default"
|
|
88
|
+
},
|
|
89
|
+
textAlignment: {
|
|
90
|
+
default: "left",
|
|
91
|
+
values: ["left", "center", "right", "justify"]
|
|
92
|
+
}
|
|
93
|
+
}, Ae = A.create({
|
|
83
94
|
name: "blockBackgroundColor",
|
|
84
95
|
addGlobalAttributes() {
|
|
85
96
|
return [
|
|
@@ -87,9 +98,9 @@ const ke = T.create({
|
|
|
87
98
|
types: ["blockContainer"],
|
|
88
99
|
attributes: {
|
|
89
100
|
backgroundColor: {
|
|
90
|
-
default:
|
|
91
|
-
parseHTML: (n) => n.hasAttribute("data-background-color") ? n.getAttribute("data-background-color") :
|
|
92
|
-
renderHTML: (n) => n.backgroundColor !==
|
|
101
|
+
default: C.backgroundColor.default,
|
|
102
|
+
parseHTML: (n) => n.hasAttribute("data-background-color") ? n.getAttribute("data-background-color") : C.backgroundColor.default,
|
|
103
|
+
renderHTML: (n) => n.backgroundColor !== C.backgroundColor.default && {
|
|
93
104
|
"data-background-color": n.backgroundColor
|
|
94
105
|
}
|
|
95
106
|
}
|
|
@@ -100,7 +111,7 @@ const ke = T.create({
|
|
|
100
111
|
addCommands() {
|
|
101
112
|
return {
|
|
102
113
|
setBlockBackgroundColor: (n, e) => ({ state: t, view: o }) => {
|
|
103
|
-
const r =
|
|
114
|
+
const r = b(t.doc, n);
|
|
104
115
|
return r === void 0 ? !1 : (t.tr.setNodeAttribute(
|
|
105
116
|
r.startPos - 1,
|
|
106
117
|
"backgroundColor",
|
|
@@ -109,7 +120,7 @@ const ke = T.create({
|
|
|
109
120
|
}
|
|
110
121
|
};
|
|
111
122
|
}
|
|
112
|
-
}),
|
|
123
|
+
}), _e = ht.create({
|
|
113
124
|
name: "backgroundColor",
|
|
114
125
|
addAttributes() {
|
|
115
126
|
return {
|
|
@@ -135,561 +146,55 @@ const ke = T.create({
|
|
|
135
146
|
},
|
|
136
147
|
addCommands() {
|
|
137
148
|
return {
|
|
138
|
-
setBackgroundColor: (n) => ({ commands: e }) => n !==
|
|
149
|
+
setBackgroundColor: (n) => ({ commands: e }) => n !== C.backgroundColor.default ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
139
150
|
};
|
|
140
151
|
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
isEmpty: bt,
|
|
148
|
-
inlineContent: yt,
|
|
149
|
-
isFilter: vt,
|
|
150
|
-
hasAnchor: Ct
|
|
151
|
-
}, Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
152
|
-
__proto__: null,
|
|
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) {
|
|
176
|
-
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
177
|
-
}
|
|
178
|
-
function ve(n) {
|
|
179
|
-
const e = {};
|
|
180
|
-
return Object.entries(n.propSchema).forEach(([t, o]) => {
|
|
181
|
-
e[t] = {
|
|
182
|
-
default: o.default,
|
|
183
|
-
keepOnSplit: !0,
|
|
184
|
-
// Props are displayed in kebab-case as HTML attributes. If a prop's
|
|
185
|
-
// value is the same as its default, we don't display an HTML
|
|
186
|
-
// attribute for it.
|
|
187
|
-
parseHTML: (r) => r.getAttribute(rt(t)),
|
|
188
|
-
renderHTML: (r) => r[t] !== o.default ? {
|
|
189
|
-
[rt(t)]: r[t]
|
|
190
|
-
} : {}
|
|
191
|
-
};
|
|
192
|
-
}), e;
|
|
193
|
-
}
|
|
194
|
-
function Ce(n) {
|
|
195
|
-
return [
|
|
196
|
-
{
|
|
197
|
-
tag: "div[data-content-type=" + n.type + "]"
|
|
198
|
-
}
|
|
199
|
-
];
|
|
200
|
-
}
|
|
201
|
-
function we(n, e) {
|
|
202
|
-
const t = document.createElement("div");
|
|
203
|
-
t.setAttribute("data-content-type", n.type);
|
|
204
|
-
for (const [r, i] of Object.entries(e))
|
|
205
|
-
t.setAttribute(r, i);
|
|
206
|
-
let o;
|
|
207
|
-
return n.containsInlineContent ? (o = document.createElement("div"), t.appendChild(o)) : o = void 0, o !== void 0 ? {
|
|
208
|
-
dom: t,
|
|
209
|
-
contentDOM: o
|
|
210
|
-
} : {
|
|
211
|
-
dom: t
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
function Zo(n) {
|
|
215
|
-
return {
|
|
216
|
-
node: O({
|
|
217
|
-
name: n.type,
|
|
218
|
-
content: n.containsInlineContent ? "inline*" : "",
|
|
219
|
-
selectable: n.containsInlineContent,
|
|
220
|
-
addAttributes() {
|
|
221
|
-
return ve(n);
|
|
222
|
-
},
|
|
223
|
-
parseHTML() {
|
|
224
|
-
return Ce(n);
|
|
225
|
-
},
|
|
226
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
227
|
-
return we(n, t);
|
|
228
|
-
},
|
|
229
|
-
addNodeView() {
|
|
230
|
-
return ({ HTMLAttributes: t, getPos: o }) => {
|
|
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;
|
|
244
|
-
if (typeof o == "boolean")
|
|
245
|
-
throw new Error(
|
|
246
|
-
"Cannot find node position as getPos is a boolean, not a function."
|
|
247
|
-
);
|
|
248
|
-
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, h = s.getBlock(c);
|
|
249
|
-
if (h.type !== n.type)
|
|
250
|
-
throw new Error("Block type does not match");
|
|
251
|
-
const u = n.render(h, s);
|
|
252
|
-
if ("contentDOM" in u) {
|
|
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" && u.contentDOM.setAttribute(b, C);
|
|
258
|
-
u.contentDOM.className = v(
|
|
259
|
-
u.contentDOM.className,
|
|
260
|
-
y.inlineContent,
|
|
261
|
-
g.class
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
return r.appendChild(u.dom), "contentDOM" in u ? {
|
|
265
|
-
dom: r,
|
|
266
|
-
contentDOM: u.contentDOM
|
|
267
|
-
} : {
|
|
268
|
-
dom: r
|
|
269
|
-
};
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
}),
|
|
273
|
-
propSchema: n.propSchema
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function O(n) {
|
|
277
|
-
return U.create({
|
|
278
|
-
...n,
|
|
279
|
-
group: "blockContent"
|
|
152
|
+
});
|
|
153
|
+
function He(n, e = JSON.stringify) {
|
|
154
|
+
const t = {};
|
|
155
|
+
return n.filter((o) => {
|
|
156
|
+
const r = e(o);
|
|
157
|
+
return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
|
|
280
158
|
});
|
|
281
159
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
160
|
+
function Le(n) {
|
|
161
|
+
const e = n.filter(
|
|
162
|
+
(o, r) => n.indexOf(o) !== r
|
|
163
|
+
);
|
|
164
|
+
return He(e);
|
|
165
|
+
}
|
|
166
|
+
const j = A.create({
|
|
167
|
+
name: "uniqueID",
|
|
168
|
+
// we’ll set a very high priority to make sure this runs first
|
|
169
|
+
// and is compatible with `appendTransaction` hooks of other extensions
|
|
170
|
+
priority: 1e4,
|
|
171
|
+
addOptions() {
|
|
286
172
|
return {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
})
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
addInputRules() {
|
|
298
|
-
return [
|
|
299
|
-
...["1", "2", "3"].map((n) => new K({
|
|
300
|
-
find: new RegExp(`^(#{${parseInt(n)}})\\s$`),
|
|
301
|
-
handler: ({ state: e, chain: t, range: o }) => {
|
|
302
|
-
t().BNUpdateBlock(e.selection.from, {
|
|
303
|
-
type: "heading",
|
|
304
|
-
props: {
|
|
305
|
-
level: n
|
|
306
|
-
}
|
|
307
|
-
}).deleteRange({ from: o.from, to: o.to });
|
|
173
|
+
attributeName: "id",
|
|
174
|
+
types: [],
|
|
175
|
+
generateID: () => {
|
|
176
|
+
if (typeof window < "u" && window.__TEST_OPTIONS) {
|
|
177
|
+
const n = window.__TEST_OPTIONS;
|
|
178
|
+
return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
|
|
308
179
|
}
|
|
309
|
-
|
|
310
|
-
];
|
|
311
|
-
},
|
|
312
|
-
parseHTML() {
|
|
313
|
-
return [
|
|
314
|
-
{
|
|
315
|
-
tag: "h1",
|
|
316
|
-
attrs: { level: "1" },
|
|
317
|
-
node: "heading"
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
tag: "h2",
|
|
321
|
-
attrs: { level: "2" },
|
|
322
|
-
node: "heading"
|
|
180
|
+
return ye();
|
|
323
181
|
},
|
|
324
|
-
|
|
325
|
-
tag: "h3",
|
|
326
|
-
attrs: { level: "3" },
|
|
327
|
-
node: "heading"
|
|
328
|
-
}
|
|
329
|
-
];
|
|
330
|
-
},
|
|
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) || {};
|
|
334
|
-
return [
|
|
335
|
-
"div",
|
|
336
|
-
A(e, {
|
|
337
|
-
...t,
|
|
338
|
-
class: v(
|
|
339
|
-
y.blockContent,
|
|
340
|
-
t.class
|
|
341
|
-
),
|
|
342
|
-
"data-content-type": this.name
|
|
343
|
-
}),
|
|
344
|
-
[
|
|
345
|
-
"h" + n.attrs.level,
|
|
346
|
-
{
|
|
347
|
-
...o,
|
|
348
|
-
class: v(
|
|
349
|
-
y.inlineContent,
|
|
350
|
-
o.class
|
|
351
|
-
)
|
|
352
|
-
},
|
|
353
|
-
0
|
|
354
|
-
]
|
|
355
|
-
];
|
|
356
|
-
}
|
|
357
|
-
}), wt = (n) => {
|
|
358
|
-
const { node: e, contentType: t } = k(
|
|
359
|
-
n.state.doc,
|
|
360
|
-
n.state.selection.from
|
|
361
|
-
), o = n.state.selection.anchor === n.state.selection.head;
|
|
362
|
-
return !t.name.endsWith("ListItem") || !o ? !1 : n.commands.first(({ state: r, chain: i, commands: s }) => [
|
|
363
|
-
() => (
|
|
364
|
-
// Changes list item block to a text block if the content is empty.
|
|
365
|
-
s.command(() => e.textContent.length === 0 ? s.BNUpdateBlock(r.selection.from, {
|
|
366
|
-
type: "paragraph",
|
|
367
|
-
props: {}
|
|
368
|
-
}) : !1)
|
|
369
|
-
),
|
|
370
|
-
() => (
|
|
371
|
-
// Splits the current block, moving content inside that's after the cursor to a new block of the same type
|
|
372
|
-
// below.
|
|
373
|
-
s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
374
|
-
)
|
|
375
|
-
]);
|
|
376
|
-
}, Me = O({
|
|
377
|
-
name: "bulletListItem",
|
|
378
|
-
content: "inline*",
|
|
379
|
-
addInputRules() {
|
|
380
|
-
return [
|
|
381
|
-
// Creates an unordered list when starting with "-", "+", or "*".
|
|
382
|
-
new K({
|
|
383
|
-
find: new RegExp("^[-+*]\\s$"),
|
|
384
|
-
handler: ({ state: n, chain: e, range: t }) => {
|
|
385
|
-
e().BNUpdateBlock(n.selection.from, {
|
|
386
|
-
type: "bulletListItem",
|
|
387
|
-
props: {}
|
|
388
|
-
}).deleteRange({ from: t.from, to: t.to });
|
|
389
|
-
}
|
|
390
|
-
})
|
|
391
|
-
];
|
|
392
|
-
},
|
|
393
|
-
addKeyboardShortcuts() {
|
|
394
|
-
return {
|
|
395
|
-
Enter: () => wt(this.editor)
|
|
182
|
+
filterTransaction: null
|
|
396
183
|
};
|
|
397
184
|
},
|
|
398
|
-
|
|
185
|
+
addGlobalAttributes() {
|
|
399
186
|
return [
|
|
400
|
-
// Case for regular HTML list structure.
|
|
401
|
-
{
|
|
402
|
-
tag: "li",
|
|
403
|
-
getAttrs: (n) => {
|
|
404
|
-
if (typeof n == "string")
|
|
405
|
-
return !1;
|
|
406
|
-
const e = n.parentElement;
|
|
407
|
-
return e === null ? !1 : e.tagName === "UL" ? {} : !1;
|
|
408
|
-
},
|
|
409
|
-
node: "bulletListItem"
|
|
410
|
-
},
|
|
411
|
-
// Case for BlockNote list structure.
|
|
412
187
|
{
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
];
|
|
424
|
-
},
|
|
425
|
-
renderHTML({ HTMLAttributes: n }) {
|
|
426
|
-
var o, r;
|
|
427
|
-
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
428
|
-
return [
|
|
429
|
-
"div",
|
|
430
|
-
A(n, {
|
|
431
|
-
...e,
|
|
432
|
-
class: v(
|
|
433
|
-
y.blockContent,
|
|
434
|
-
e.class
|
|
435
|
-
),
|
|
436
|
-
"data-content-type": this.name
|
|
437
|
-
}),
|
|
438
|
-
[
|
|
439
|
-
"p",
|
|
440
|
-
{
|
|
441
|
-
...t,
|
|
442
|
-
class: v(
|
|
443
|
-
y.inlineContent,
|
|
444
|
-
t.class
|
|
445
|
-
)
|
|
446
|
-
},
|
|
447
|
-
0
|
|
448
|
-
]
|
|
449
|
-
];
|
|
450
|
-
}
|
|
451
|
-
}), Ee = new S("numbered-list-indexing"), Be = () => new w({
|
|
452
|
-
key: Ee,
|
|
453
|
-
appendTransaction: (n, e, t) => {
|
|
454
|
-
const o = t.tr;
|
|
455
|
-
o.setMeta("numberedListIndexing", !0);
|
|
456
|
-
let r = !1;
|
|
457
|
-
return t.doc.descendants((i, s) => {
|
|
458
|
-
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
459
|
-
let l = "1";
|
|
460
|
-
const a = s === 1, d = k(o.doc, s + 1);
|
|
461
|
-
if (d === void 0)
|
|
462
|
-
return;
|
|
463
|
-
if (!a) {
|
|
464
|
-
const u = k(o.doc, s - 2);
|
|
465
|
-
if (u === void 0)
|
|
466
|
-
return;
|
|
467
|
-
if (!(d.depth !== u.depth)) {
|
|
468
|
-
const m = u.contentNode;
|
|
469
|
-
if (u.contentType.name === "numberedListItem") {
|
|
470
|
-
const C = m.attrs.index;
|
|
471
|
-
l = (parseInt(C) + 1).toString();
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
d.contentNode.attrs.index !== l && (r = !0, o.setNodeMarkup(s + 1, void 0, {
|
|
476
|
-
index: l
|
|
477
|
-
}));
|
|
478
|
-
}
|
|
479
|
-
}), r ? o : null;
|
|
480
|
-
}
|
|
481
|
-
}), Te = O({
|
|
482
|
-
name: "numberedListItem",
|
|
483
|
-
content: "inline*",
|
|
484
|
-
addAttributes() {
|
|
485
|
-
return {
|
|
486
|
-
index: {
|
|
487
|
-
default: null,
|
|
488
|
-
parseHTML: (n) => n.getAttribute("data-index"),
|
|
489
|
-
renderHTML: (n) => ({
|
|
490
|
-
"data-index": n.index
|
|
491
|
-
})
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
},
|
|
495
|
-
addInputRules() {
|
|
496
|
-
return [
|
|
497
|
-
// Creates an ordered list when starting with "1.".
|
|
498
|
-
new K({
|
|
499
|
-
find: new RegExp("^1\\.\\s$"),
|
|
500
|
-
handler: ({ state: n, chain: e, range: t }) => {
|
|
501
|
-
e().BNUpdateBlock(n.selection.from, {
|
|
502
|
-
type: "numberedListItem",
|
|
503
|
-
props: {}
|
|
504
|
-
}).deleteRange({ from: t.from, to: t.to });
|
|
505
|
-
}
|
|
506
|
-
})
|
|
507
|
-
];
|
|
508
|
-
},
|
|
509
|
-
addKeyboardShortcuts() {
|
|
510
|
-
return {
|
|
511
|
-
Enter: () => wt(this.editor)
|
|
512
|
-
};
|
|
513
|
-
},
|
|
514
|
-
addProseMirrorPlugins() {
|
|
515
|
-
return [Be()];
|
|
516
|
-
},
|
|
517
|
-
parseHTML() {
|
|
518
|
-
return [
|
|
519
|
-
// Case for regular HTML list structure.
|
|
520
|
-
// (e.g.: when pasting from other apps)
|
|
521
|
-
{
|
|
522
|
-
tag: "li",
|
|
523
|
-
getAttrs: (n) => {
|
|
524
|
-
if (typeof n == "string")
|
|
525
|
-
return !1;
|
|
526
|
-
const e = n.parentElement;
|
|
527
|
-
return e === null ? !1 : e.tagName === "OL" ? {} : !1;
|
|
528
|
-
},
|
|
529
|
-
node: "numberedListItem"
|
|
530
|
-
},
|
|
531
|
-
// Case for BlockNote list structure.
|
|
532
|
-
// (e.g.: when pasting from blocknote)
|
|
533
|
-
{
|
|
534
|
-
tag: "p",
|
|
535
|
-
getAttrs: (n) => {
|
|
536
|
-
if (typeof n == "string")
|
|
537
|
-
return !1;
|
|
538
|
-
const e = n.parentElement;
|
|
539
|
-
return e === null ? !1 : e.getAttribute("data-content-type") === "numberedListItem" ? {} : !1;
|
|
540
|
-
},
|
|
541
|
-
priority: 300,
|
|
542
|
-
node: "numberedListItem"
|
|
543
|
-
}
|
|
544
|
-
];
|
|
545
|
-
},
|
|
546
|
-
renderHTML({ HTMLAttributes: n }) {
|
|
547
|
-
var o, r;
|
|
548
|
-
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
549
|
-
return [
|
|
550
|
-
"div",
|
|
551
|
-
A(n, {
|
|
552
|
-
...e,
|
|
553
|
-
class: v(
|
|
554
|
-
y.blockContent,
|
|
555
|
-
e.class
|
|
556
|
-
),
|
|
557
|
-
"data-content-type": this.name
|
|
558
|
-
}),
|
|
559
|
-
// we use a <p> tag, because for <li> tags we'd need to add a <ul> parent for around siblings to be semantically correct,
|
|
560
|
-
// which would be quite cumbersome
|
|
561
|
-
[
|
|
562
|
-
"p",
|
|
563
|
-
{
|
|
564
|
-
...t,
|
|
565
|
-
class: v(
|
|
566
|
-
y.inlineContent,
|
|
567
|
-
t.class
|
|
568
|
-
)
|
|
569
|
-
},
|
|
570
|
-
0
|
|
571
|
-
]
|
|
572
|
-
];
|
|
573
|
-
}
|
|
574
|
-
}), xe = O({
|
|
575
|
-
name: "paragraph",
|
|
576
|
-
content: "inline*",
|
|
577
|
-
parseHTML() {
|
|
578
|
-
return [
|
|
579
|
-
{
|
|
580
|
-
tag: "p",
|
|
581
|
-
priority: 200,
|
|
582
|
-
node: "paragraph"
|
|
583
|
-
}
|
|
584
|
-
];
|
|
585
|
-
},
|
|
586
|
-
renderHTML({ HTMLAttributes: n }) {
|
|
587
|
-
var o, r;
|
|
588
|
-
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
589
|
-
return [
|
|
590
|
-
"div",
|
|
591
|
-
A(
|
|
592
|
-
{
|
|
593
|
-
...e,
|
|
594
|
-
class: v(
|
|
595
|
-
y.blockContent,
|
|
596
|
-
e.class
|
|
597
|
-
),
|
|
598
|
-
"data-content-type": this.name
|
|
599
|
-
},
|
|
600
|
-
n
|
|
601
|
-
),
|
|
602
|
-
[
|
|
603
|
-
"p",
|
|
604
|
-
{
|
|
605
|
-
...t,
|
|
606
|
-
class: v(
|
|
607
|
-
y.inlineContent,
|
|
608
|
-
t.class
|
|
609
|
-
)
|
|
610
|
-
},
|
|
611
|
-
0
|
|
612
|
-
]
|
|
613
|
-
];
|
|
614
|
-
}
|
|
615
|
-
}), P = {
|
|
616
|
-
backgroundColor: {
|
|
617
|
-
default: "transparent"
|
|
618
|
-
},
|
|
619
|
-
textColor: {
|
|
620
|
-
default: "black"
|
|
621
|
-
// TODO
|
|
622
|
-
},
|
|
623
|
-
textAlignment: {
|
|
624
|
-
default: "left",
|
|
625
|
-
values: ["left", "center", "right", "justify"]
|
|
626
|
-
}
|
|
627
|
-
}, St = {
|
|
628
|
-
paragraph: {
|
|
629
|
-
propSchema: P,
|
|
630
|
-
node: xe
|
|
631
|
-
},
|
|
632
|
-
heading: {
|
|
633
|
-
propSchema: {
|
|
634
|
-
...P,
|
|
635
|
-
level: { default: "1", values: ["1", "2", "3"] }
|
|
636
|
-
},
|
|
637
|
-
node: Se
|
|
638
|
-
},
|
|
639
|
-
bulletListItem: {
|
|
640
|
-
propSchema: P,
|
|
641
|
-
node: Me
|
|
642
|
-
},
|
|
643
|
-
numberedListItem: {
|
|
644
|
-
propSchema: P,
|
|
645
|
-
node: Te
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
function Ae(n, e = JSON.stringify) {
|
|
649
|
-
const t = {};
|
|
650
|
-
return n.filter((o) => {
|
|
651
|
-
const r = e(o);
|
|
652
|
-
return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
function Ie(n) {
|
|
656
|
-
const e = n.filter(
|
|
657
|
-
(o, r) => n.indexOf(o) !== r
|
|
658
|
-
);
|
|
659
|
-
return Ae(e);
|
|
660
|
-
}
|
|
661
|
-
const F = T.create({
|
|
662
|
-
name: "uniqueID",
|
|
663
|
-
// we’ll set a very high priority to make sure this runs first
|
|
664
|
-
// and is compatible with `appendTransaction` hooks of other extensions
|
|
665
|
-
priority: 1e4,
|
|
666
|
-
addOptions() {
|
|
667
|
-
return {
|
|
668
|
-
attributeName: "id",
|
|
669
|
-
types: [],
|
|
670
|
-
generateID: () => {
|
|
671
|
-
if (typeof window < "u" && window.__TEST_OPTIONS) {
|
|
672
|
-
const n = window.__TEST_OPTIONS;
|
|
673
|
-
return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
|
|
674
|
-
}
|
|
675
|
-
return ie();
|
|
676
|
-
},
|
|
677
|
-
filterTransaction: null
|
|
678
|
-
};
|
|
679
|
-
},
|
|
680
|
-
addGlobalAttributes() {
|
|
681
|
-
return [
|
|
682
|
-
{
|
|
683
|
-
types: this.options.types,
|
|
684
|
-
attributes: {
|
|
685
|
-
[this.options.attributeName]: {
|
|
686
|
-
default: null,
|
|
687
|
-
parseHTML: (n) => n.getAttribute(`data-${this.options.attributeName}`),
|
|
688
|
-
renderHTML: (n) => ({
|
|
689
|
-
[`data-${this.options.attributeName}`]: n[this.options.attributeName]
|
|
690
|
-
})
|
|
691
|
-
}
|
|
692
|
-
}
|
|
188
|
+
types: this.options.types,
|
|
189
|
+
attributes: {
|
|
190
|
+
[this.options.attributeName]: {
|
|
191
|
+
default: null,
|
|
192
|
+
parseHTML: (n) => n.getAttribute(`data-${this.options.attributeName}`),
|
|
193
|
+
renderHTML: (n) => ({
|
|
194
|
+
[`data-${this.options.attributeName}`]: n[this.options.attributeName]
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
}
|
|
693
198
|
}
|
|
694
199
|
];
|
|
695
200
|
},
|
|
@@ -726,38 +231,38 @@ const F = T.create({
|
|
|
726
231
|
addProseMirrorPlugins() {
|
|
727
232
|
let n = null, e = !1;
|
|
728
233
|
return [
|
|
729
|
-
new
|
|
730
|
-
key: new
|
|
234
|
+
new T({
|
|
235
|
+
key: new B("uniqueID"),
|
|
731
236
|
appendTransaction: (t, o, r) => {
|
|
732
|
-
const i = t.some((
|
|
733
|
-
let
|
|
734
|
-
return !(!((
|
|
237
|
+
const i = t.some((f) => f.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && t.some((f) => {
|
|
238
|
+
let k, v;
|
|
239
|
+
return !(!((v = (k = this.options).filterTransaction) === null || v === void 0) && v.call(k, f));
|
|
735
240
|
});
|
|
736
241
|
if (!i || s)
|
|
737
242
|
return;
|
|
738
|
-
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options,
|
|
243
|
+
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, m = Zt(
|
|
739
244
|
o.doc,
|
|
740
245
|
t
|
|
741
|
-
), { mapping:
|
|
742
|
-
if (
|
|
743
|
-
const
|
|
246
|
+
), { mapping: h } = m;
|
|
247
|
+
if (Qt(m).forEach(({ newRange: f }) => {
|
|
248
|
+
const k = te(
|
|
744
249
|
r.doc,
|
|
745
|
-
|
|
746
|
-
(
|
|
747
|
-
),
|
|
748
|
-
|
|
749
|
-
let
|
|
750
|
-
const
|
|
751
|
-
if (
|
|
752
|
-
l.setNodeMarkup(
|
|
753
|
-
...
|
|
250
|
+
f,
|
|
251
|
+
(E) => a.includes(E.type.name)
|
|
252
|
+
), v = k.map(({ node: E }) => E.attrs[d]).filter((E) => E !== null), w = Le(v);
|
|
253
|
+
k.forEach(({ node: E, pos: _ }) => {
|
|
254
|
+
let y;
|
|
255
|
+
const M = (y = l.doc.nodeAt(_)) === null || y === void 0 ? void 0 : y.attrs[d];
|
|
256
|
+
if (M === null) {
|
|
257
|
+
l.setNodeMarkup(_, void 0, {
|
|
258
|
+
...E.attrs,
|
|
754
259
|
[d]: c()
|
|
755
260
|
});
|
|
756
261
|
return;
|
|
757
262
|
}
|
|
758
|
-
const { deleted:
|
|
759
|
-
|
|
760
|
-
...
|
|
263
|
+
const { deleted: ot } = h.invert().mapResult(_);
|
|
264
|
+
ot && w.includes(M) && l.setNodeMarkup(_, void 0, {
|
|
265
|
+
...E.attrs,
|
|
761
266
|
[d]: c()
|
|
762
267
|
});
|
|
763
268
|
});
|
|
@@ -814,9 +319,9 @@ const F = T.create({
|
|
|
814
319
|
a.marks
|
|
815
320
|
);
|
|
816
321
|
l.push(d);
|
|
817
|
-
}),
|
|
322
|
+
}), P.from(l);
|
|
818
323
|
};
|
|
819
|
-
return e = !1, new
|
|
324
|
+
return e = !1, new L(
|
|
820
325
|
i(t.content),
|
|
821
326
|
t.openStart,
|
|
822
327
|
t.openEnd
|
|
@@ -826,25 +331,37 @@ const F = T.create({
|
|
|
826
331
|
})
|
|
827
332
|
];
|
|
828
333
|
}
|
|
829
|
-
}),
|
|
334
|
+
}), Ne = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
|
335
|
+
function Mn(n) {
|
|
336
|
+
return Ne() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
|
|
337
|
+
}
|
|
338
|
+
function S(...n) {
|
|
339
|
+
return n.filter((e) => e).join(" ");
|
|
340
|
+
}
|
|
341
|
+
class Pe extends Error {
|
|
342
|
+
constructor(e) {
|
|
343
|
+
super(`Unreachable case: ${e}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const yt = /* @__PURE__ */ new Set([
|
|
830
347
|
"bold",
|
|
831
348
|
"italic",
|
|
832
349
|
"underline",
|
|
833
350
|
"strike",
|
|
834
351
|
"code"
|
|
835
|
-
]),
|
|
836
|
-
function
|
|
352
|
+
]), vt = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
|
|
353
|
+
function at(n, e) {
|
|
837
354
|
const t = [];
|
|
838
355
|
for (const [o, r] of Object.entries(n.styles))
|
|
839
|
-
|
|
356
|
+
yt.has(o) ? t.push(e.mark(o)) : vt.has(o) && t.push(e.mark(o, { color: r }));
|
|
840
357
|
return n.text.split(/(\n)/g).filter((o) => o.length > 0).map((o) => o === `
|
|
841
358
|
` ? e.nodes.hardBreak.create() : e.text(o, t));
|
|
842
359
|
}
|
|
843
|
-
function
|
|
360
|
+
function De(n, e) {
|
|
844
361
|
const t = e.marks.link.create({
|
|
845
362
|
href: n.href
|
|
846
363
|
});
|
|
847
|
-
return
|
|
364
|
+
return wt(n.content, e).map((o) => {
|
|
848
365
|
if (o.type.name === "text")
|
|
849
366
|
return o.mark([...o.marks, t]);
|
|
850
367
|
if (o.type.name === "hardBreak")
|
|
@@ -852,30 +369,30 @@ function _e(n, e) {
|
|
|
852
369
|
throw new Error("unexpected node type");
|
|
853
370
|
});
|
|
854
371
|
}
|
|
855
|
-
function
|
|
372
|
+
function wt(n, e) {
|
|
856
373
|
const t = [];
|
|
857
374
|
if (typeof n == "string")
|
|
858
375
|
return t.push(
|
|
859
|
-
...
|
|
376
|
+
...at({ type: "text", text: n, styles: {} }, e)
|
|
860
377
|
), t;
|
|
861
378
|
for (const o of n)
|
|
862
|
-
t.push(...
|
|
379
|
+
t.push(...at(o, e));
|
|
863
380
|
return t;
|
|
864
381
|
}
|
|
865
|
-
function
|
|
382
|
+
function Ct(n, e) {
|
|
866
383
|
const t = [];
|
|
867
384
|
for (const o of n)
|
|
868
385
|
if (o.type === "link")
|
|
869
|
-
t.push(...
|
|
386
|
+
t.push(...De(o, e));
|
|
870
387
|
else if (o.type === "text")
|
|
871
|
-
t.push(...
|
|
388
|
+
t.push(...wt([o], e));
|
|
872
389
|
else
|
|
873
|
-
throw new
|
|
390
|
+
throw new Pe(o);
|
|
874
391
|
return t;
|
|
875
392
|
}
|
|
876
|
-
function
|
|
393
|
+
function V(n, e) {
|
|
877
394
|
let t = n.id;
|
|
878
|
-
t === void 0 && (t =
|
|
395
|
+
t === void 0 && (t = j.options.generateID());
|
|
879
396
|
let o = n.type;
|
|
880
397
|
o === void 0 && (o = "paragraph");
|
|
881
398
|
let r;
|
|
@@ -887,13 +404,13 @@ function D(n, e) {
|
|
|
887
404
|
e.text(n.content)
|
|
888
405
|
);
|
|
889
406
|
else {
|
|
890
|
-
const l =
|
|
407
|
+
const l = Ct(n.content, e);
|
|
891
408
|
r = e.nodes[o].create(n.props, l);
|
|
892
409
|
}
|
|
893
410
|
const i = [];
|
|
894
411
|
if (n.children)
|
|
895
412
|
for (const l of n.children)
|
|
896
|
-
i.push(
|
|
413
|
+
i.push(V(l, e));
|
|
897
414
|
const s = e.nodes.blockGroup.create({}, i);
|
|
898
415
|
return e.nodes.blockContainer.create(
|
|
899
416
|
{
|
|
@@ -903,7 +420,7 @@ function D(n, e) {
|
|
|
903
420
|
i.length > 0 ? [r, s] : r
|
|
904
421
|
);
|
|
905
422
|
}
|
|
906
|
-
function
|
|
423
|
+
function Oe(n) {
|
|
907
424
|
const e = [];
|
|
908
425
|
let t;
|
|
909
426
|
return n.content.forEach((o) => {
|
|
@@ -923,9 +440,9 @@ function He(n) {
|
|
|
923
440
|
for (const s of o.marks)
|
|
924
441
|
if (s.type.name === "link")
|
|
925
442
|
i = s;
|
|
926
|
-
else if (
|
|
443
|
+
else if (yt.has(s.type.name))
|
|
927
444
|
r[s.type.name] = !0;
|
|
928
|
-
else if (
|
|
445
|
+
else if (vt.has(s.type.name))
|
|
929
446
|
r[s.type.name] = s.attrs.color;
|
|
930
447
|
else
|
|
931
448
|
throw Error("Mark is of an unrecognized type: " + s.type.name);
|
|
@@ -980,7 +497,7 @@ function He(n) {
|
|
|
980
497
|
};
|
|
981
498
|
}), t && e.push(t), e;
|
|
982
499
|
}
|
|
983
|
-
function
|
|
500
|
+
function x(n, e, t) {
|
|
984
501
|
if (n.type.name !== "blockContainer")
|
|
985
502
|
throw Error(
|
|
986
503
|
"Node must be of type blockContainer, but is of type" + n.type.name + "."
|
|
@@ -988,37 +505,37 @@ function E(n, e, t) {
|
|
|
988
505
|
const o = t == null ? void 0 : t.get(n);
|
|
989
506
|
if (o)
|
|
990
507
|
return o;
|
|
991
|
-
const r =
|
|
508
|
+
const r = bt(n);
|
|
992
509
|
let i = r.id;
|
|
993
|
-
i === null && (i =
|
|
510
|
+
i === null && (i = j.options.generateID());
|
|
994
511
|
const s = {};
|
|
995
|
-
for (const [c,
|
|
512
|
+
for (const [c, m] of Object.entries({
|
|
996
513
|
...n.attrs,
|
|
997
514
|
...r.contentNode.attrs
|
|
998
515
|
})) {
|
|
999
|
-
const
|
|
1000
|
-
if (!
|
|
516
|
+
const h = e[r.contentType.name];
|
|
517
|
+
if (!h)
|
|
1001
518
|
throw Error(
|
|
1002
519
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
1003
520
|
);
|
|
1004
|
-
const
|
|
1005
|
-
c in
|
|
521
|
+
const p = h.propSchema;
|
|
522
|
+
c in p ? s[c] = m : c !== "id" && !(c in C) && console.warn("Block has an unrecognized attribute: " + c);
|
|
1006
523
|
}
|
|
1007
|
-
const l =
|
|
524
|
+
const l = e[r.contentType.name], a = [];
|
|
1008
525
|
for (let c = 0; c < r.numChildBlocks; c++)
|
|
1009
526
|
a.push(
|
|
1010
|
-
|
|
527
|
+
x(n.lastChild.child(c), e, t)
|
|
1011
528
|
);
|
|
1012
529
|
const d = {
|
|
1013
530
|
id: i,
|
|
1014
|
-
type:
|
|
531
|
+
type: l.node.name,
|
|
1015
532
|
props: s,
|
|
1016
|
-
content: l,
|
|
533
|
+
content: l.node.config.content === "inline*" ? Oe(r.contentNode) : void 0,
|
|
1017
534
|
children: a
|
|
1018
535
|
};
|
|
1019
536
|
return t == null || t.set(n, d), d;
|
|
1020
537
|
}
|
|
1021
|
-
const
|
|
538
|
+
const lt = new B("previous-blocks"), Re = {
|
|
1022
539
|
// Numbered List Items
|
|
1023
540
|
index: "index",
|
|
1024
541
|
// Headings
|
|
@@ -1027,17 +544,17 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1027
544
|
type: "type",
|
|
1028
545
|
depth: "depth",
|
|
1029
546
|
"depth-change": "depth-change"
|
|
1030
|
-
},
|
|
547
|
+
}, ze = () => {
|
|
1031
548
|
let n;
|
|
1032
|
-
return new
|
|
1033
|
-
key:
|
|
549
|
+
return new T({
|
|
550
|
+
key: lt,
|
|
1034
551
|
view(e) {
|
|
1035
552
|
return {
|
|
1036
553
|
update: async (t, o) => {
|
|
1037
554
|
var r;
|
|
1038
555
|
((r = this.key) == null ? void 0 : r.getState(t.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
1039
556
|
t.dispatch(
|
|
1040
|
-
t.state.tr.setMeta(
|
|
557
|
+
t.state.tr.setMeta(lt, { clearUpdate: !0 })
|
|
1041
558
|
);
|
|
1042
559
|
}, 0));
|
|
1043
560
|
},
|
|
@@ -1060,25 +577,25 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1060
577
|
apply(e, t, o, r) {
|
|
1061
578
|
if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || o.doc.eq(r.doc))
|
|
1062
579
|
return t;
|
|
1063
|
-
const i = {}, s =
|
|
580
|
+
const i = {}, s = nt(o.doc, (d) => d.attrs.id), l = new Map(
|
|
1064
581
|
s.map((d) => [d.node.attrs.id, d])
|
|
1065
|
-
), a =
|
|
582
|
+
), a = nt(r.doc, (d) => d.attrs.id);
|
|
1066
583
|
for (const d of a) {
|
|
1067
|
-
const c = l.get(d.node.attrs.id),
|
|
1068
|
-
if (c &&
|
|
1069
|
-
const
|
|
1070
|
-
index: u.attrs.index,
|
|
1071
|
-
level: u.attrs.level,
|
|
1072
|
-
type: u.type.name,
|
|
1073
|
-
depth: r.doc.resolve(d.pos).depth
|
|
1074
|
-
};
|
|
1075
|
-
let m = {
|
|
584
|
+
const c = l.get(d.node.attrs.id), m = c == null ? void 0 : c.node.firstChild, h = d.node.firstChild;
|
|
585
|
+
if (c && m && h) {
|
|
586
|
+
const p = {
|
|
1076
587
|
index: h.attrs.index,
|
|
1077
588
|
level: h.attrs.level,
|
|
1078
589
|
type: h.type.name,
|
|
590
|
+
depth: r.doc.resolve(d.pos).depth
|
|
591
|
+
};
|
|
592
|
+
let f = {
|
|
593
|
+
index: m.attrs.index,
|
|
594
|
+
level: m.attrs.level,
|
|
595
|
+
type: m.type.name,
|
|
1079
596
|
depth: o.doc.resolve(c.pos).depth
|
|
1080
597
|
};
|
|
1081
|
-
i[d.node.attrs.id] =
|
|
598
|
+
i[d.node.attrs.id] = f, e.getMeta("numberedListIndexing") && (d.node.attrs.id in t.prevTransactionOldBlockAttrs && (f = t.prevTransactionOldBlockAttrs[d.node.attrs.id]), p.type === "numberedListItem" && (f.index = p.index)), t.currentTransactionOldBlockAttrs[d.node.attrs.id] = f, JSON.stringify(f) !== JSON.stringify(p) && (f["depth-change"] = f.depth - p.depth, t.updatedBlocks.add(d.node.attrs.id));
|
|
1082
599
|
}
|
|
1083
600
|
}
|
|
1084
601
|
return t.prevTransactionOldBlockAttrs = i, t;
|
|
@@ -1095,22 +612,69 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1095
612
|
return;
|
|
1096
613
|
const s = t.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
|
|
1097
614
|
for (const [d, c] of Object.entries(s))
|
|
1098
|
-
l["data-prev-" +
|
|
1099
|
-
const a =
|
|
615
|
+
l["data-prev-" + Re[d]] = c || "none";
|
|
616
|
+
const a = W.node(i, i + r.nodeSize, {
|
|
1100
617
|
...l
|
|
1101
618
|
});
|
|
1102
619
|
o.push(a);
|
|
1103
|
-
}),
|
|
620
|
+
}), $.create(e.doc, o);
|
|
1104
621
|
}
|
|
1105
622
|
}
|
|
1106
623
|
});
|
|
1107
|
-
},
|
|
624
|
+
}, Et = "_blockOuter_xo7pf_5", St = "_block_xo7pf_5", Tt = "_reactNodeViewRenderer_xo7pf_17", Mt = "_blockContent_xo7pf_22", Bt = "_blockGroup_xo7pf_42", xt = "_wrapper_xo7pf_226", It = "_addImageButton_xo7pf_234", At = "_addImageButtonIcon_xo7pf_250", _t = "_addImageButtonText_xo7pf_256", Ht = "_imageAndCaptionWrapper_xo7pf_260", Lt = "_imageWrapper_xo7pf_266", Nt = "_image_xo7pf_260", Pt = "_resizeHandle_xo7pf_279", Dt = "_caption_xo7pf_294", Ot = "_isEmpty_xo7pf_300", Rt = "_inlineContent_xo7pf_300", zt = "_isFilter_xo7pf_301", Vt = "_hasAnchor_xo7pf_313", g = {
|
|
625
|
+
blockOuter: Et,
|
|
626
|
+
block: St,
|
|
627
|
+
reactNodeViewRenderer: Tt,
|
|
628
|
+
blockContent: Mt,
|
|
629
|
+
blockGroup: Bt,
|
|
630
|
+
wrapper: xt,
|
|
631
|
+
addImageButton: It,
|
|
632
|
+
addImageButtonIcon: At,
|
|
633
|
+
addImageButtonText: _t,
|
|
634
|
+
imageAndCaptionWrapper: Ht,
|
|
635
|
+
imageWrapper: Lt,
|
|
636
|
+
image: Nt,
|
|
637
|
+
resizeHandle: Pt,
|
|
638
|
+
caption: Dt,
|
|
639
|
+
isEmpty: Ot,
|
|
640
|
+
inlineContent: Rt,
|
|
641
|
+
isFilter: zt,
|
|
642
|
+
hasAnchor: Vt
|
|
643
|
+
}, Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
644
|
+
__proto__: null,
|
|
645
|
+
addImageButton: It,
|
|
646
|
+
addImageButtonIcon: At,
|
|
647
|
+
addImageButtonText: _t,
|
|
648
|
+
block: St,
|
|
649
|
+
blockContent: Mt,
|
|
650
|
+
blockGroup: Bt,
|
|
651
|
+
blockOuter: Et,
|
|
652
|
+
caption: Dt,
|
|
653
|
+
default: g,
|
|
654
|
+
hasAnchor: Vt,
|
|
655
|
+
image: Nt,
|
|
656
|
+
imageAndCaptionWrapper: Ht,
|
|
657
|
+
imageWrapper: Lt,
|
|
658
|
+
inlineContent: Rt,
|
|
659
|
+
isEmpty: Ot,
|
|
660
|
+
isFilter: zt,
|
|
661
|
+
reactNodeViewRenderer: Tt,
|
|
662
|
+
resizeHandle: Pt,
|
|
663
|
+
wrapper: xt
|
|
664
|
+
}, Symbol.toStringTag, { value: "Module" })), Ve = {
|
|
1108
665
|
blockColor: "data-block-color",
|
|
1109
666
|
blockStyle: "data-block-style",
|
|
1110
667
|
id: "data-id",
|
|
1111
668
|
depth: "data-depth",
|
|
1112
669
|
depthChange: "data-depth-change"
|
|
1113
|
-
},
|
|
670
|
+
}, Ue = new B("non-editable-block"), Fe = () => new T({
|
|
671
|
+
key: Ue,
|
|
672
|
+
props: {
|
|
673
|
+
handleKeyDown: (n, e) => {
|
|
674
|
+
"node" in n.state.selection && e.preventDefault();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}), We = G.create({
|
|
1114
678
|
name: "blockContainer",
|
|
1115
679
|
group: "blockContainer",
|
|
1116
680
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -1126,7 +690,7 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1126
690
|
if (typeof n == "string")
|
|
1127
691
|
return !1;
|
|
1128
692
|
const e = {};
|
|
1129
|
-
for (const [t, o] of Object.entries(
|
|
693
|
+
for (const [t, o] of Object.entries(Ve))
|
|
1130
694
|
n.getAttribute(o) && (e[t] = n.getAttribute(o));
|
|
1131
695
|
return n.getAttribute("data-node-type") === "blockContainer" ? e : !1;
|
|
1132
696
|
}
|
|
@@ -1138,16 +702,16 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1138
702
|
const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockContainer) || {};
|
|
1139
703
|
return [
|
|
1140
704
|
"div",
|
|
1141
|
-
|
|
1142
|
-
class:
|
|
705
|
+
N(n, {
|
|
706
|
+
class: g.blockOuter,
|
|
1143
707
|
"data-node-type": "block-outer"
|
|
1144
708
|
}),
|
|
1145
709
|
[
|
|
1146
710
|
"div",
|
|
1147
|
-
|
|
711
|
+
N(
|
|
1148
712
|
{
|
|
1149
713
|
...e,
|
|
1150
|
-
class:
|
|
714
|
+
class: S(g.block, e.class),
|
|
1151
715
|
"data-node-type": this.name
|
|
1152
716
|
},
|
|
1153
717
|
n
|
|
@@ -1165,7 +729,7 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1165
729
|
},
|
|
1166
730
|
// Deletes a block at a given position.
|
|
1167
731
|
BNDeleteBlock: (n) => ({ state: e, dispatch: t }) => {
|
|
1168
|
-
const o =
|
|
732
|
+
const o = b(e.doc, n);
|
|
1169
733
|
if (o === void 0)
|
|
1170
734
|
return !1;
|
|
1171
735
|
const { startPos: r, endPos: i } = o;
|
|
@@ -1173,40 +737,42 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1173
737
|
},
|
|
1174
738
|
// Updates a block at a given position.
|
|
1175
739
|
BNUpdateBlock: (n, e) => ({ state: t, dispatch: o }) => {
|
|
1176
|
-
const r =
|
|
740
|
+
const r = b(t.doc, n);
|
|
1177
741
|
if (r === void 0)
|
|
1178
742
|
return !1;
|
|
1179
743
|
const { startPos: i, endPos: s, node: l, contentNode: a } = r;
|
|
1180
744
|
if (o) {
|
|
1181
745
|
if (e.children !== void 0) {
|
|
1182
|
-
const
|
|
1183
|
-
for (const
|
|
1184
|
-
|
|
746
|
+
const p = [];
|
|
747
|
+
for (const f of e.children)
|
|
748
|
+
p.push(V(f, t.schema));
|
|
1185
749
|
l.childCount === 2 ? t.tr.replace(
|
|
1186
750
|
i + a.nodeSize + 1,
|
|
1187
751
|
s - 1,
|
|
1188
|
-
new
|
|
752
|
+
new L(P.from(p), 0, 0)
|
|
1189
753
|
) : t.tr.insert(
|
|
1190
754
|
i + a.nodeSize,
|
|
1191
|
-
t.schema.nodes.blockGroup.create({},
|
|
755
|
+
t.schema.nodes.blockGroup.create({}, p)
|
|
1192
756
|
);
|
|
1193
757
|
}
|
|
1194
758
|
if (e.content !== void 0) {
|
|
1195
|
-
let
|
|
1196
|
-
typeof e.content == "string" ?
|
|
759
|
+
let p = [];
|
|
760
|
+
typeof e.content == "string" ? p.push(t.schema.text(e.content)) : p = Ct(e.content, t.schema), t.tr.replace(
|
|
1197
761
|
i + 1,
|
|
1198
762
|
i + a.nodeSize - 1,
|
|
1199
|
-
new
|
|
763
|
+
new L(P.from(p), 0, 0)
|
|
1200
764
|
);
|
|
1201
765
|
}
|
|
1202
|
-
const d = a.type.name, c = e.type || d,
|
|
1203
|
-
|
|
766
|
+
const d = a.type.name, c = e.type || d, m = t.schema.nodes[d].spec.content, h = t.schema.nodes[c].spec.content;
|
|
767
|
+
m === "inline*" && h === "" ? t.tr.replaceWith(
|
|
1204
768
|
i,
|
|
1205
769
|
s,
|
|
1206
770
|
t.schema.nodes[c].create({
|
|
1207
771
|
...a.attrs,
|
|
1208
772
|
...e.props
|
|
1209
773
|
})
|
|
774
|
+
).setSelection(
|
|
775
|
+
new mt(t.tr.doc.resolve(i))
|
|
1210
776
|
) : t.tr.setNodeMarkup(
|
|
1211
777
|
i,
|
|
1212
778
|
e.type === void 0 ? void 0 : t.schema.nodes[e.type],
|
|
@@ -1242,57 +808,57 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1242
808
|
const o = e.doc.resolve(n + 1).node().type.name === "blockContainer", r = e.doc.resolve(n - 1).node().type.name === "blockContainer";
|
|
1243
809
|
if (!o || !r)
|
|
1244
810
|
return !1;
|
|
1245
|
-
const i =
|
|
811
|
+
const i = b(
|
|
1246
812
|
e.doc,
|
|
1247
813
|
n + 1
|
|
1248
814
|
), { node: s, contentNode: l, startPos: a, endPos: d, depth: c } = i;
|
|
1249
815
|
if (s.childCount === 2) {
|
|
1250
|
-
const
|
|
816
|
+
const p = e.doc.resolve(
|
|
1251
817
|
a + l.nodeSize + 1
|
|
1252
|
-
),
|
|
1253
|
-
t && e.tr.lift(
|
|
818
|
+
), f = e.doc.resolve(d - 1), k = p.blockRange(f);
|
|
819
|
+
t && e.tr.lift(k, c - 1);
|
|
1254
820
|
}
|
|
1255
|
-
let
|
|
1256
|
-
for (;
|
|
1257
|
-
if (
|
|
821
|
+
let m = n - 1, h = b(e.doc, m);
|
|
822
|
+
for (; h.numChildBlocks > 0; )
|
|
823
|
+
if (m--, h = b(e.doc, m), h === void 0)
|
|
1258
824
|
return !1;
|
|
1259
825
|
return t && (t(
|
|
1260
826
|
e.tr.deleteRange(a, a + l.nodeSize).replace(
|
|
1261
|
-
|
|
827
|
+
m - 1,
|
|
1262
828
|
a,
|
|
1263
|
-
new
|
|
829
|
+
new L(l.content, 0, 0)
|
|
1264
830
|
).scrollIntoView()
|
|
1265
831
|
), e.tr.setSelection(
|
|
1266
|
-
new
|
|
832
|
+
new it(e.doc.resolve(m - 1))
|
|
1267
833
|
)), !0;
|
|
1268
834
|
},
|
|
1269
835
|
// Splits a block at a given position. Content after the position is moved to a new block below, at the same
|
|
1270
836
|
// nesting level.
|
|
1271
837
|
BNSplitBlock: (n, e) => ({ state: t, dispatch: o }) => {
|
|
1272
|
-
const r =
|
|
838
|
+
const r = b(t.doc, n);
|
|
1273
839
|
if (r === void 0)
|
|
1274
840
|
return !1;
|
|
1275
|
-
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n),
|
|
1276
|
-
return o && (t.tr.insert(
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
841
|
+
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), m = t.doc.cut(n, a - 1), h = t.schema.nodes.blockContainer.createAndFill(), p = a + 1, f = p + 2;
|
|
842
|
+
return o && (t.tr.insert(p, h), t.tr.replace(
|
|
843
|
+
f,
|
|
844
|
+
f + 1,
|
|
845
|
+
m.content.size > 0 ? new L(
|
|
846
|
+
P.from(m),
|
|
1281
847
|
d + 2,
|
|
1282
848
|
d + 2
|
|
1283
849
|
) : void 0
|
|
1284
850
|
), e && t.tr.setBlockType(
|
|
1285
|
-
|
|
1286
|
-
|
|
851
|
+
f,
|
|
852
|
+
f,
|
|
1287
853
|
t.schema.node(s).type,
|
|
1288
854
|
i.attrs
|
|
1289
855
|
), t.tr.setSelection(
|
|
1290
|
-
new
|
|
856
|
+
new it(t.doc.resolve(f))
|
|
1291
857
|
), t.tr.replace(
|
|
1292
858
|
l + 1,
|
|
1293
859
|
a - 1,
|
|
1294
|
-
c.content.size > 0 ? new
|
|
1295
|
-
|
|
860
|
+
c.content.size > 0 ? new L(
|
|
861
|
+
P.from(c),
|
|
1296
862
|
d + 2,
|
|
1297
863
|
d + 2
|
|
1298
864
|
) : void 0
|
|
@@ -1301,7 +867,7 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1301
867
|
};
|
|
1302
868
|
},
|
|
1303
869
|
addProseMirrorPlugins() {
|
|
1304
|
-
return [
|
|
870
|
+
return [ze(), Fe()];
|
|
1305
871
|
},
|
|
1306
872
|
addKeyboardShortcuts() {
|
|
1307
873
|
return {
|
|
@@ -1312,7 +878,7 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1312
878
|
() => t.undoInputRule(),
|
|
1313
879
|
// Reverts block content type to a paragraph if the selection is at the start of the block.
|
|
1314
880
|
() => t.command(({ state: o }) => {
|
|
1315
|
-
const { contentType: r } =
|
|
881
|
+
const { contentType: r } = b(
|
|
1316
882
|
o.doc,
|
|
1317
883
|
o.selection.from
|
|
1318
884
|
), i = o.selection.$anchor.parentOffset === 0, s = r.name === "paragraph";
|
|
@@ -1326,7 +892,7 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1326
892
|
// Merges block with the previous one if it isn't indented, isn't the first block in the doc, and the selection
|
|
1327
893
|
// is at the start of the block.
|
|
1328
894
|
() => t.command(({ state: o }) => {
|
|
1329
|
-
const { depth: r, startPos: i } =
|
|
895
|
+
const { depth: r, startPos: i } = b(
|
|
1330
896
|
o.doc,
|
|
1331
897
|
o.selection.from
|
|
1332
898
|
), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = i === 2, d = i - 1;
|
|
@@ -1337,7 +903,7 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1337
903
|
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
1338
904
|
// of the block.
|
|
1339
905
|
() => t.command(({ state: o }) => {
|
|
1340
|
-
const { node: r, depth: i } =
|
|
906
|
+
const { node: r, depth: i } = b(
|
|
1341
907
|
o.doc,
|
|
1342
908
|
o.selection.from
|
|
1343
909
|
), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = r.textContent.length === 0, d = i > 2;
|
|
@@ -1346,20 +912,20 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1346
912
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
1347
913
|
// empty & at the start of the block.
|
|
1348
914
|
() => t.command(({ state: o, chain: r }) => {
|
|
1349
|
-
const { node: i, endPos: s } =
|
|
915
|
+
const { node: i, endPos: s } = b(
|
|
1350
916
|
o.doc,
|
|
1351
917
|
o.selection.from
|
|
1352
918
|
), l = o.selection.$anchor.parentOffset === 0, a = o.selection.anchor === o.selection.head, d = i.textContent.length === 0;
|
|
1353
919
|
if (l && a && d) {
|
|
1354
|
-
const c = s + 1,
|
|
1355
|
-
return r().BNCreateBlock(c).setTextSelection(
|
|
920
|
+
const c = s + 1, m = c + 2;
|
|
921
|
+
return r().BNCreateBlock(c).setTextSelection(m).run(), !0;
|
|
1356
922
|
}
|
|
1357
923
|
return !1;
|
|
1358
924
|
}),
|
|
1359
925
|
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
1360
926
|
// deletes the selection beforehand, if it's not empty.
|
|
1361
927
|
() => t.command(({ state: o, chain: r }) => {
|
|
1362
|
-
const { node: i } =
|
|
928
|
+
const { node: i } = b(
|
|
1363
929
|
o.doc,
|
|
1364
930
|
o.selection.from
|
|
1365
931
|
);
|
|
@@ -1372,36 +938,10 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1372
938
|
"Shift-Tab": () => (this.editor.commands.liftListItem("blockContainer"), !0),
|
|
1373
939
|
"Mod-Alt-0": () => this.editor.commands.BNCreateBlock(
|
|
1374
940
|
this.editor.state.selection.anchor + 2
|
|
1375
|
-
)
|
|
1376
|
-
"Mod-Alt-1": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1377
|
-
type: "heading",
|
|
1378
|
-
props: {
|
|
1379
|
-
level: "1"
|
|
1380
|
-
}
|
|
1381
|
-
}),
|
|
1382
|
-
"Mod-Alt-2": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1383
|
-
type: "heading",
|
|
1384
|
-
props: {
|
|
1385
|
-
level: "2"
|
|
1386
|
-
}
|
|
1387
|
-
}),
|
|
1388
|
-
"Mod-Alt-3": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1389
|
-
type: "heading",
|
|
1390
|
-
props: {
|
|
1391
|
-
level: "3"
|
|
1392
|
-
}
|
|
1393
|
-
}),
|
|
1394
|
-
"Mod-Shift-7": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1395
|
-
type: "bulletListItem",
|
|
1396
|
-
props: {}
|
|
1397
|
-
}),
|
|
1398
|
-
"Mod-Shift-8": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1399
|
-
type: "numberedListItem",
|
|
1400
|
-
props: {}
|
|
1401
|
-
})
|
|
941
|
+
)
|
|
1402
942
|
};
|
|
1403
943
|
}
|
|
1404
|
-
}),
|
|
944
|
+
}), $e = G.create({
|
|
1405
945
|
name: "blockGroup",
|
|
1406
946
|
group: "blockGroup",
|
|
1407
947
|
content: "blockContainer+",
|
|
@@ -1418,11 +958,11 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1418
958
|
const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockGroup) || {};
|
|
1419
959
|
return [
|
|
1420
960
|
"div",
|
|
1421
|
-
|
|
961
|
+
N(
|
|
1422
962
|
{
|
|
1423
963
|
...e,
|
|
1424
|
-
class:
|
|
1425
|
-
|
|
964
|
+
class: S(
|
|
965
|
+
g.blockGroup,
|
|
1426
966
|
e.class
|
|
1427
967
|
),
|
|
1428
968
|
"data-node-type": "blockGroup"
|
|
@@ -1432,13 +972,13 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1432
972
|
0
|
|
1433
973
|
];
|
|
1434
974
|
}
|
|
1435
|
-
}),
|
|
975
|
+
}), Ge = G.create({
|
|
1436
976
|
name: "doc",
|
|
1437
977
|
topNode: !0,
|
|
1438
978
|
content: "blockGroup"
|
|
1439
|
-
}),
|
|
1440
|
-
const e =
|
|
1441
|
-
return new
|
|
979
|
+
}), je = (n) => {
|
|
980
|
+
const e = Y.fromSchema(n);
|
|
981
|
+
return new Y(
|
|
1442
982
|
{
|
|
1443
983
|
...e.nodes
|
|
1444
984
|
// TODO: If a serializer is defined in the config for a custom block, it
|
|
@@ -1448,21 +988,21 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1448
988
|
},
|
|
1449
989
|
e.marks
|
|
1450
990
|
);
|
|
1451
|
-
},
|
|
991
|
+
}, qe = A.create({
|
|
1452
992
|
addProseMirrorPlugins() {
|
|
1453
993
|
return [
|
|
1454
|
-
new
|
|
994
|
+
new T({
|
|
1455
995
|
props: {
|
|
1456
|
-
clipboardSerializer:
|
|
996
|
+
clipboardSerializer: je(this.editor.schema)
|
|
1457
997
|
}
|
|
1458
998
|
})
|
|
1459
999
|
];
|
|
1460
1000
|
}
|
|
1461
1001
|
});
|
|
1462
|
-
class
|
|
1002
|
+
class U {
|
|
1463
1003
|
constructor() {
|
|
1464
1004
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1465
|
-
|
|
1005
|
+
u(this, "callbacks", {});
|
|
1466
1006
|
}
|
|
1467
1007
|
on(e, t) {
|
|
1468
1008
|
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
@@ -1479,16 +1019,16 @@ class G {
|
|
|
1479
1019
|
this.callbacks = {};
|
|
1480
1020
|
}
|
|
1481
1021
|
}
|
|
1482
|
-
const
|
|
1022
|
+
const Xe = ee(
|
|
1483
1023
|
(n) => n.type.name === "blockContainer"
|
|
1484
1024
|
);
|
|
1485
|
-
class
|
|
1025
|
+
class Ke {
|
|
1486
1026
|
constructor(e, t, o = () => {
|
|
1487
1027
|
}) {
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1028
|
+
u(this, "suggestionsMenuState");
|
|
1029
|
+
u(this, "updateSuggestionsMenu");
|
|
1030
|
+
u(this, "pluginState");
|
|
1031
|
+
u(this, "handleScroll", () => {
|
|
1492
1032
|
var e;
|
|
1493
1033
|
if ((e = this.suggestionsMenuState) != null && e.show) {
|
|
1494
1034
|
const t = document.querySelector(
|
|
@@ -1497,7 +1037,7 @@ class Fe {
|
|
|
1497
1037
|
this.suggestionsMenuState.referencePos = t.getBoundingClientRect(), this.updateSuggestionsMenu();
|
|
1498
1038
|
}
|
|
1499
1039
|
});
|
|
1500
|
-
this.editor = e, this.pluginKey = t, this.pluginState =
|
|
1040
|
+
this.editor = e, this.pluginKey = t, this.pluginState = J(), this.updateSuggestionsMenu = () => {
|
|
1501
1041
|
if (!this.suggestionsMenuState)
|
|
1502
1042
|
throw new Error("Attempting to update uninitialized suggestions menu");
|
|
1503
1043
|
o(this.suggestionsMenuState);
|
|
@@ -1525,7 +1065,7 @@ class Fe {
|
|
|
1525
1065
|
document.removeEventListener("scroll", this.handleScroll);
|
|
1526
1066
|
}
|
|
1527
1067
|
}
|
|
1528
|
-
function
|
|
1068
|
+
function J() {
|
|
1529
1069
|
return {
|
|
1530
1070
|
active: !1,
|
|
1531
1071
|
triggerCharacter: void 0,
|
|
@@ -1536,7 +1076,7 @@ function Y() {
|
|
|
1536
1076
|
decorationId: void 0
|
|
1537
1077
|
};
|
|
1538
1078
|
}
|
|
1539
|
-
const
|
|
1079
|
+
const Ye = (n, e, t, o, r = () => [], i = () => {
|
|
1540
1080
|
}) => {
|
|
1541
1081
|
if (o.length !== 1)
|
|
1542
1082
|
throw new Error("'char' should be a single character");
|
|
@@ -1545,9 +1085,9 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1545
1085
|
a.dispatch(a.state.tr.setMeta(t, { deactivate: !0 }));
|
|
1546
1086
|
};
|
|
1547
1087
|
return {
|
|
1548
|
-
plugin: new
|
|
1088
|
+
plugin: new T({
|
|
1549
1089
|
key: t,
|
|
1550
|
-
view: () => (s = new
|
|
1090
|
+
view: () => (s = new Ke(
|
|
1551
1091
|
n,
|
|
1552
1092
|
t,
|
|
1553
1093
|
e
|
|
@@ -1555,18 +1095,18 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1555
1095
|
state: {
|
|
1556
1096
|
// Initialize the plugin's internal state.
|
|
1557
1097
|
init() {
|
|
1558
|
-
return
|
|
1098
|
+
return J();
|
|
1559
1099
|
},
|
|
1560
1100
|
// Apply changes to the plugin state from an editor transaction.
|
|
1561
|
-
apply(a, d, c,
|
|
1562
|
-
var
|
|
1101
|
+
apply(a, d, c, m) {
|
|
1102
|
+
var p, f, k, v;
|
|
1563
1103
|
if (a.getMeta("orderedListIndexing") !== void 0)
|
|
1564
1104
|
return d;
|
|
1565
|
-
if ((
|
|
1105
|
+
if ((p = a.getMeta(t)) != null && p.activate)
|
|
1566
1106
|
return {
|
|
1567
1107
|
active: !0,
|
|
1568
|
-
triggerCharacter: ((
|
|
1569
|
-
queryStartPos:
|
|
1108
|
+
triggerCharacter: ((f = a.getMeta(t)) == null ? void 0 : f.triggerCharacter) || "",
|
|
1109
|
+
queryStartPos: m.selection.from,
|
|
1570
1110
|
items: r(""),
|
|
1571
1111
|
keyboardHoveredItemIndex: 0,
|
|
1572
1112
|
// TODO: Maybe should be 1 if the menu has no possible items? Probably redundant since a menu with no items
|
|
@@ -1576,30 +1116,30 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1576
1116
|
};
|
|
1577
1117
|
if (!d.active)
|
|
1578
1118
|
return d;
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1119
|
+
const h = { ...d };
|
|
1120
|
+
if (h.items = r(
|
|
1121
|
+
m.doc.textBetween(
|
|
1582
1122
|
d.queryStartPos,
|
|
1583
|
-
|
|
1123
|
+
m.selection.from
|
|
1584
1124
|
)
|
|
1585
|
-
),
|
|
1125
|
+
), h.notFoundCount = 0, h.items.length === 0 && (h.notFoundCount = Math.max(
|
|
1586
1126
|
0,
|
|
1587
|
-
d.notFoundCount + (
|
|
1127
|
+
d.notFoundCount + (m.selection.from - c.selection.from)
|
|
1588
1128
|
)), // Highlighting text should hide the menu.
|
|
1589
|
-
|
|
1590
|
-
(
|
|
1129
|
+
m.selection.from !== m.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
|
|
1130
|
+
(k = a.getMeta(t)) != null && k.deactivate || // Certain mouse events should hide the menu.
|
|
1591
1131
|
// TODO: Change to global mousedown listener.
|
|
1592
1132
|
a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1593
|
-
d.active &&
|
|
1133
|
+
d.active && m.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
|
|
1594
1134
|
// the menu.
|
|
1595
|
-
|
|
1596
|
-
return
|
|
1597
|
-
if (((
|
|
1598
|
-
let
|
|
1599
|
-
|
|
1135
|
+
h.notFoundCount > 3)
|
|
1136
|
+
return J();
|
|
1137
|
+
if (((v = a.getMeta(t)) == null ? void 0 : v.selectedItemIndexChanged) !== void 0) {
|
|
1138
|
+
let w = a.getMeta(t).selectedItemIndexChanged;
|
|
1139
|
+
w < 0 ? w = d.items.length - 1 : w >= d.items.length && (w = 0), h.keyboardHoveredItemIndex = w;
|
|
1600
1140
|
} else
|
|
1601
|
-
c.selection.from !==
|
|
1602
|
-
return
|
|
1141
|
+
c.selection.from !== m.selection.from && (h.keyboardHoveredItemIndex = 0);
|
|
1142
|
+
return h;
|
|
1603
1143
|
}
|
|
1604
1144
|
},
|
|
1605
1145
|
props: {
|
|
@@ -1615,39 +1155,39 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1615
1155
|
if (!c)
|
|
1616
1156
|
return !1;
|
|
1617
1157
|
const {
|
|
1618
|
-
triggerCharacter:
|
|
1619
|
-
queryStartPos:
|
|
1620
|
-
items:
|
|
1621
|
-
keyboardHoveredItemIndex:
|
|
1158
|
+
triggerCharacter: m,
|
|
1159
|
+
queryStartPos: h,
|
|
1160
|
+
items: p,
|
|
1161
|
+
keyboardHoveredItemIndex: f
|
|
1622
1162
|
} = t.getState(a.state);
|
|
1623
1163
|
return d.key === "ArrowUp" ? (a.dispatch(
|
|
1624
1164
|
a.state.tr.setMeta(t, {
|
|
1625
|
-
selectedItemIndexChanged:
|
|
1165
|
+
selectedItemIndexChanged: f - 1
|
|
1626
1166
|
})
|
|
1627
1167
|
), !0) : d.key === "ArrowDown" ? (a.dispatch(
|
|
1628
1168
|
a.state.tr.setMeta(t, {
|
|
1629
|
-
selectedItemIndexChanged:
|
|
1169
|
+
selectedItemIndexChanged: f + 1
|
|
1630
1170
|
})
|
|
1631
1171
|
), !0) : d.key === "Enter" ? (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1632
|
-
from:
|
|
1172
|
+
from: h - m.length,
|
|
1633
1173
|
to: n._tiptapEditor.state.selection.from
|
|
1634
1174
|
}).run(), i({
|
|
1635
|
-
item: f
|
|
1175
|
+
item: p[f],
|
|
1636
1176
|
editor: n
|
|
1637
1177
|
}), !0) : d.key === "Escape" ? (l(a), !0) : !1;
|
|
1638
1178
|
},
|
|
1639
1179
|
// Setup decorator on the currently active suggestion.
|
|
1640
1180
|
decorations(a) {
|
|
1641
|
-
const { active: d, decorationId: c, queryStartPos:
|
|
1181
|
+
const { active: d, decorationId: c, queryStartPos: m, triggerCharacter: h } = this.getState(a);
|
|
1642
1182
|
if (!d)
|
|
1643
1183
|
return null;
|
|
1644
|
-
if (
|
|
1645
|
-
const
|
|
1646
|
-
if (
|
|
1647
|
-
return
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1184
|
+
if (h === "") {
|
|
1185
|
+
const p = Xe(a.selection);
|
|
1186
|
+
if (p)
|
|
1187
|
+
return $.create(a.doc, [
|
|
1188
|
+
W.node(
|
|
1189
|
+
p.pos,
|
|
1190
|
+
p.pos + p.node.nodeSize,
|
|
1651
1191
|
{
|
|
1652
1192
|
nodeName: "span",
|
|
1653
1193
|
class: "suggestion-decorator",
|
|
@@ -1656,10 +1196,10 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1656
1196
|
)
|
|
1657
1197
|
]);
|
|
1658
1198
|
}
|
|
1659
|
-
return
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1199
|
+
return $.create(a.doc, [
|
|
1200
|
+
W.inline(
|
|
1201
|
+
m - h.length,
|
|
1202
|
+
m,
|
|
1663
1203
|
{
|
|
1664
1204
|
nodeName: "span",
|
|
1665
1205
|
class: "suggestion-decorator",
|
|
@@ -1680,18 +1220,18 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1680
1220
|
});
|
|
1681
1221
|
}
|
|
1682
1222
|
};
|
|
1683
|
-
},
|
|
1684
|
-
class
|
|
1223
|
+
}, tt = new B("SlashMenuPlugin");
|
|
1224
|
+
class Je extends U {
|
|
1685
1225
|
constructor(t, o) {
|
|
1686
1226
|
super();
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
const r =
|
|
1227
|
+
u(this, "plugin");
|
|
1228
|
+
u(this, "itemCallback");
|
|
1229
|
+
const r = Ye(
|
|
1690
1230
|
t,
|
|
1691
1231
|
(i) => {
|
|
1692
1232
|
this.emit("update", i);
|
|
1693
1233
|
},
|
|
1694
|
-
|
|
1234
|
+
tt,
|
|
1695
1235
|
"/",
|
|
1696
1236
|
(i) => o.filter(
|
|
1697
1237
|
({ name: s, aliases: l }) => s.toLowerCase().startsWith(i.toLowerCase()) || l && l.filter(
|
|
@@ -1706,7 +1246,7 @@ class $e extends G {
|
|
|
1706
1246
|
return this.on("update", t);
|
|
1707
1247
|
}
|
|
1708
1248
|
}
|
|
1709
|
-
const
|
|
1249
|
+
const Ze = new B("blocknote-placeholder"), Qe = A.create({
|
|
1710
1250
|
name: "placeholder",
|
|
1711
1251
|
addOptions() {
|
|
1712
1252
|
return {
|
|
@@ -1722,30 +1262,30 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1722
1262
|
},
|
|
1723
1263
|
addProseMirrorPlugins() {
|
|
1724
1264
|
return [
|
|
1725
|
-
new
|
|
1726
|
-
key:
|
|
1265
|
+
new T({
|
|
1266
|
+
key: Ze,
|
|
1727
1267
|
props: {
|
|
1728
1268
|
decorations: (n) => {
|
|
1729
|
-
const { doc: e, selection: t } = n, o =
|
|
1269
|
+
const { doc: e, selection: t } = n, o = tt.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
|
|
1730
1270
|
if (r)
|
|
1731
1271
|
return e.descendants((l, a) => {
|
|
1732
1272
|
const d = i >= a && i <= a + l.nodeSize, c = !l.isLeaf && !l.childCount;
|
|
1733
1273
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
1734
|
-
const
|
|
1735
|
-
this.editor.isEmpty &&
|
|
1736
|
-
const
|
|
1737
|
-
class:
|
|
1274
|
+
const m = [this.options.emptyNodeClass];
|
|
1275
|
+
this.editor.isEmpty && m.push(this.options.emptyEditorClass), d && m.push(this.options.hasAnchorClass), (o == null ? void 0 : o.triggerCharacter) === "" && (o != null && o.active) && m.push(this.options.isFilterClass);
|
|
1276
|
+
const h = W.node(a, a + l.nodeSize, {
|
|
1277
|
+
class: m.join(" ")
|
|
1738
1278
|
});
|
|
1739
|
-
s.push(
|
|
1279
|
+
s.push(h);
|
|
1740
1280
|
}
|
|
1741
1281
|
return this.options.includeChildren;
|
|
1742
|
-
}),
|
|
1282
|
+
}), $.create(e, s);
|
|
1743
1283
|
}
|
|
1744
1284
|
}
|
|
1745
1285
|
})
|
|
1746
1286
|
];
|
|
1747
1287
|
}
|
|
1748
|
-
}),
|
|
1288
|
+
}), to = A.create({
|
|
1749
1289
|
name: "textAlignment",
|
|
1750
1290
|
addGlobalAttributes() {
|
|
1751
1291
|
return [
|
|
@@ -1768,7 +1308,7 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1768
1308
|
addCommands() {
|
|
1769
1309
|
return {
|
|
1770
1310
|
setTextAlignment: (n) => ({ state: e }) => {
|
|
1771
|
-
const t = [], o =
|
|
1311
|
+
const t = [], o = b(
|
|
1772
1312
|
e.doc,
|
|
1773
1313
|
e.selection.from
|
|
1774
1314
|
);
|
|
@@ -1783,7 +1323,7 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1783
1323
|
}
|
|
1784
1324
|
};
|
|
1785
1325
|
}
|
|
1786
|
-
}),
|
|
1326
|
+
}), eo = A.create({
|
|
1787
1327
|
name: "blockTextColor",
|
|
1788
1328
|
addGlobalAttributes() {
|
|
1789
1329
|
return [
|
|
@@ -1791,9 +1331,9 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1791
1331
|
types: ["blockContainer"],
|
|
1792
1332
|
attributes: {
|
|
1793
1333
|
textColor: {
|
|
1794
|
-
default:
|
|
1795
|
-
parseHTML: (n) => n.hasAttribute("data-text-color") ? n.getAttribute("data-text-color") :
|
|
1796
|
-
renderHTML: (n) => n.textColor !==
|
|
1334
|
+
default: C.textColor.default,
|
|
1335
|
+
parseHTML: (n) => n.hasAttribute("data-text-color") ? n.getAttribute("data-text-color") : C.textColor.default,
|
|
1336
|
+
renderHTML: (n) => n.textColor !== C.textColor.default && {
|
|
1797
1337
|
"data-text-color": n.textColor
|
|
1798
1338
|
}
|
|
1799
1339
|
}
|
|
@@ -1804,12 +1344,12 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1804
1344
|
addCommands() {
|
|
1805
1345
|
return {
|
|
1806
1346
|
setBlockTextColor: (n, e) => ({ state: t, view: o }) => {
|
|
1807
|
-
const r =
|
|
1347
|
+
const r = b(t.doc, n);
|
|
1808
1348
|
return r === void 0 ? !1 : (t.tr.setNodeAttribute(r.startPos - 1, "textColor", e), o.focus(), !0);
|
|
1809
1349
|
}
|
|
1810
1350
|
};
|
|
1811
1351
|
}
|
|
1812
|
-
}),
|
|
1352
|
+
}), oo = ht.create({
|
|
1813
1353
|
name: "textColor",
|
|
1814
1354
|
addAttributes() {
|
|
1815
1355
|
return {
|
|
@@ -1835,15 +1375,15 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1835
1375
|
},
|
|
1836
1376
|
addCommands() {
|
|
1837
1377
|
return {
|
|
1838
|
-
setTextColor: (n) => ({ commands: e }) => n !==
|
|
1378
|
+
setTextColor: (n) => ({ commands: e }) => n !== C.textColor.default ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
|
|
1839
1379
|
};
|
|
1840
1380
|
}
|
|
1841
|
-
}),
|
|
1381
|
+
}), no = A.create({
|
|
1842
1382
|
name: "trailingNode",
|
|
1843
1383
|
addProseMirrorPlugins() {
|
|
1844
|
-
const n = new
|
|
1384
|
+
const n = new B(this.name);
|
|
1845
1385
|
return [
|
|
1846
|
-
new
|
|
1386
|
+
new T({
|
|
1847
1387
|
key: n,
|
|
1848
1388
|
appendTransaction: (e, t, o) => {
|
|
1849
1389
|
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;
|
|
@@ -1853,306 +1393,1019 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1853
1393
|
d.create(void 0, c.create())
|
|
1854
1394
|
);
|
|
1855
1395
|
},
|
|
1856
|
-
state: {
|
|
1857
|
-
init: (e, t) => {
|
|
1858
|
-
},
|
|
1859
|
-
apply: (e, t) => {
|
|
1860
|
-
if (!e.docChanged)
|
|
1861
|
-
return t;
|
|
1862
|
-
let o = e.doc.lastChild;
|
|
1863
|
-
if (!o || o.type.name !== "blockGroup")
|
|
1864
|
-
throw new Error("Expected blockGroup");
|
|
1865
|
-
if (o = o.lastChild, !o || o.type.name !== "blockContainer")
|
|
1866
|
-
throw new Error("Expected blockContainer");
|
|
1867
|
-
const r = o.firstChild;
|
|
1868
|
-
if (!r)
|
|
1869
|
-
throw new Error("Expected blockContent");
|
|
1870
|
-
return o.nodeSize > 4 || r.type.spec.content !== "inline*";
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
})
|
|
1396
|
+
state: {
|
|
1397
|
+
init: (e, t) => {
|
|
1398
|
+
},
|
|
1399
|
+
apply: (e, t) => {
|
|
1400
|
+
if (!e.docChanged)
|
|
1401
|
+
return t;
|
|
1402
|
+
let o = e.doc.lastChild;
|
|
1403
|
+
if (!o || o.type.name !== "blockGroup")
|
|
1404
|
+
throw new Error("Expected blockGroup");
|
|
1405
|
+
if (o = o.lastChild, !o || o.type.name !== "blockContainer")
|
|
1406
|
+
throw new Error("Expected blockContainer");
|
|
1407
|
+
const r = o.firstChild;
|
|
1408
|
+
if (!r)
|
|
1409
|
+
throw new Error("Expected blockContent");
|
|
1410
|
+
return o.nodeSize > 4 || r.type.spec.content !== "inline*";
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
})
|
|
1414
|
+
];
|
|
1415
|
+
}
|
|
1416
|
+
}), ro = (n) => {
|
|
1417
|
+
var t;
|
|
1418
|
+
const e = [
|
|
1419
|
+
R.ClipboardTextSerializer,
|
|
1420
|
+
R.Commands,
|
|
1421
|
+
R.Editable,
|
|
1422
|
+
R.FocusEvents,
|
|
1423
|
+
R.Tabindex,
|
|
1424
|
+
// DevTools,
|
|
1425
|
+
ce,
|
|
1426
|
+
// DropCursor,
|
|
1427
|
+
Qe.configure({
|
|
1428
|
+
emptyNodeClass: g.isEmpty,
|
|
1429
|
+
hasAnchorClass: g.hasAnchor,
|
|
1430
|
+
isFilterClass: g.isFilter,
|
|
1431
|
+
includeChildren: !0,
|
|
1432
|
+
showOnlyCurrent: !1
|
|
1433
|
+
}),
|
|
1434
|
+
j.configure({
|
|
1435
|
+
types: ["blockContainer"]
|
|
1436
|
+
}),
|
|
1437
|
+
ue,
|
|
1438
|
+
// Comments,
|
|
1439
|
+
// basics:
|
|
1440
|
+
ge,
|
|
1441
|
+
// marks:
|
|
1442
|
+
ie,
|
|
1443
|
+
se,
|
|
1444
|
+
he,
|
|
1445
|
+
fe,
|
|
1446
|
+
ke,
|
|
1447
|
+
me,
|
|
1448
|
+
oo,
|
|
1449
|
+
eo,
|
|
1450
|
+
_e,
|
|
1451
|
+
Ae,
|
|
1452
|
+
to,
|
|
1453
|
+
// nodes
|
|
1454
|
+
Ge,
|
|
1455
|
+
We.configure({
|
|
1456
|
+
domAttributes: n.domAttributes
|
|
1457
|
+
}),
|
|
1458
|
+
$e.configure({
|
|
1459
|
+
domAttributes: n.domAttributes
|
|
1460
|
+
}),
|
|
1461
|
+
...Object.values(n.blockSchema).map(
|
|
1462
|
+
(o) => o.node.configure({
|
|
1463
|
+
editor: n.editor,
|
|
1464
|
+
domAttributes: n.domAttributes
|
|
1465
|
+
})
|
|
1466
|
+
),
|
|
1467
|
+
qe,
|
|
1468
|
+
de.configure({ width: 5, color: "#ddeeff" }),
|
|
1469
|
+
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
1470
|
+
// should be handled before Enter handlers in other components like splitListItem
|
|
1471
|
+
no
|
|
1472
|
+
];
|
|
1473
|
+
if (n.collaboration) {
|
|
1474
|
+
if (e.push(
|
|
1475
|
+
ae.configure({
|
|
1476
|
+
fragment: n.collaboration.fragment
|
|
1477
|
+
})
|
|
1478
|
+
), (t = n.collaboration.provider) != null && t.awareness) {
|
|
1479
|
+
const o = (r) => {
|
|
1480
|
+
const i = document.createElement("span");
|
|
1481
|
+
i.classList.add(D["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
|
|
1482
|
+
const s = document.createElement("span");
|
|
1483
|
+
s.classList.add(D["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
|
|
1484
|
+
const l = document.createTextNode(""), a = document.createTextNode("");
|
|
1485
|
+
return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
|
|
1486
|
+
};
|
|
1487
|
+
e.push(
|
|
1488
|
+
le.configure({
|
|
1489
|
+
user: n.collaboration.user,
|
|
1490
|
+
render: n.collaboration.renderCursor || o,
|
|
1491
|
+
provider: n.collaboration.provider
|
|
1492
|
+
})
|
|
1493
|
+
);
|
|
1494
|
+
}
|
|
1495
|
+
} else
|
|
1496
|
+
e.push(pe);
|
|
1497
|
+
return e;
|
|
1498
|
+
};
|
|
1499
|
+
function et(n, e) {
|
|
1500
|
+
let t, o;
|
|
1501
|
+
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)
|
|
1502
|
+
throw Error("Could not find block in the editor with matching ID.");
|
|
1503
|
+
return {
|
|
1504
|
+
node: t,
|
|
1505
|
+
posBeforeNode: o
|
|
1506
|
+
};
|
|
1507
|
+
}
|
|
1508
|
+
function Ut(n, e, t = "before", o) {
|
|
1509
|
+
const r = typeof e == "string" ? e : e.id, i = [];
|
|
1510
|
+
for (const d of n)
|
|
1511
|
+
i.push(V(d, o.schema));
|
|
1512
|
+
let s = -1;
|
|
1513
|
+
const { node: l, posBeforeNode: a } = et(r, o.state.doc);
|
|
1514
|
+
if (t === "before" && (s = a), t === "after" && (s = a + l.nodeSize), t === "nested") {
|
|
1515
|
+
if (l.childCount < 2) {
|
|
1516
|
+
s = a + l.firstChild.nodeSize + 1;
|
|
1517
|
+
const d = o.state.schema.nodes.blockGroup.create(
|
|
1518
|
+
{},
|
|
1519
|
+
i
|
|
1520
|
+
);
|
|
1521
|
+
o.view.dispatch(
|
|
1522
|
+
o.state.tr.insert(s, d)
|
|
1523
|
+
);
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
s = a + l.firstChild.nodeSize + 2;
|
|
1527
|
+
}
|
|
1528
|
+
o.view.dispatch(o.state.tr.insert(s, i));
|
|
1529
|
+
}
|
|
1530
|
+
function io(n, e, t) {
|
|
1531
|
+
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = et(o, t.state.doc);
|
|
1532
|
+
t.commands.BNUpdateBlock(r + 1, e);
|
|
1533
|
+
}
|
|
1534
|
+
function Ft(n, e) {
|
|
1535
|
+
const t = new Set(
|
|
1536
|
+
n.map(
|
|
1537
|
+
(r) => typeof r == "string" ? r : r.id
|
|
1538
|
+
)
|
|
1539
|
+
);
|
|
1540
|
+
let o = 0;
|
|
1541
|
+
if (e.state.doc.descendants((r, i) => {
|
|
1542
|
+
if (t.size === 0)
|
|
1543
|
+
return !1;
|
|
1544
|
+
if (r.type.name !== "blockContainer" || !t.has(r.attrs.id))
|
|
1545
|
+
return !0;
|
|
1546
|
+
t.delete(r.attrs.id);
|
|
1547
|
+
const s = e.state.doc.nodeSize;
|
|
1548
|
+
e.commands.BNDeleteBlock(i - o + 1);
|
|
1549
|
+
const l = e.state.doc.nodeSize;
|
|
1550
|
+
return o += s - l, !1;
|
|
1551
|
+
}), t.size > 0) {
|
|
1552
|
+
const r = [...t].join(`
|
|
1553
|
+
`);
|
|
1554
|
+
throw Error(
|
|
1555
|
+
"Blocks with the following IDs could not be found in the editor: " + r
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
function so(n, e, t) {
|
|
1560
|
+
Ut(e, n[0], "before", t), Ft(n, t);
|
|
1561
|
+
}
|
|
1562
|
+
function ao() {
|
|
1563
|
+
const n = (e) => {
|
|
1564
|
+
let t = e.children.length;
|
|
1565
|
+
for (let o = 0; o < t; o++) {
|
|
1566
|
+
const r = e.children[o];
|
|
1567
|
+
if (r.type === "element" && (n(r), r.tagName === "u"))
|
|
1568
|
+
if (r.children.length > 0) {
|
|
1569
|
+
e.children.splice(o, 1, ...r.children);
|
|
1570
|
+
const i = r.children.length - 1;
|
|
1571
|
+
t += i, o += i;
|
|
1572
|
+
} else
|
|
1573
|
+
e.children.splice(o, 1), t--, o--;
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
return n;
|
|
1577
|
+
}
|
|
1578
|
+
function lo(n) {
|
|
1579
|
+
const e = /* @__PURE__ */ new Set([
|
|
1580
|
+
...n.orderedListItemBlockTypes,
|
|
1581
|
+
...n.unorderedListItemBlockTypes
|
|
1582
|
+
]), t = (o) => {
|
|
1583
|
+
let r = o.children.length, i;
|
|
1584
|
+
for (let s = 0; s < r; s++) {
|
|
1585
|
+
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, m = e.has(
|
|
1586
|
+
d.properties.dataContentType
|
|
1587
|
+
), h = m ? n.orderedListItemBlockTypes.has(
|
|
1588
|
+
d.properties.dataContentType
|
|
1589
|
+
) ? "ol" : "ul" : null;
|
|
1590
|
+
if (c !== null && t(c), i && i.tagName !== h) {
|
|
1591
|
+
o.children.splice(
|
|
1592
|
+
s - i.children.length,
|
|
1593
|
+
i.children.length,
|
|
1594
|
+
i
|
|
1595
|
+
);
|
|
1596
|
+
const p = i.children.length - 1;
|
|
1597
|
+
s -= p, r -= p, i = void 0;
|
|
1598
|
+
}
|
|
1599
|
+
if (m) {
|
|
1600
|
+
i || (i = st(
|
|
1601
|
+
document.createElement(h)
|
|
1602
|
+
));
|
|
1603
|
+
const p = st(
|
|
1604
|
+
document.createElement("li")
|
|
1605
|
+
);
|
|
1606
|
+
p.children.push(d.children[0]), c !== null && p.children.push(...c.children), i.children.push(p);
|
|
1607
|
+
} else if (c !== null) {
|
|
1608
|
+
o.children.splice(s + 1, 0, ...c.children), o.children[s] = d.children[0];
|
|
1609
|
+
const p = c.children.length;
|
|
1610
|
+
s += p, r += p;
|
|
1611
|
+
} else
|
|
1612
|
+
o.children[s] = d.children[0];
|
|
1613
|
+
}
|
|
1614
|
+
i && o.children.splice(
|
|
1615
|
+
r - i.children.length,
|
|
1616
|
+
i.children.length,
|
|
1617
|
+
i
|
|
1618
|
+
);
|
|
1619
|
+
};
|
|
1620
|
+
return t;
|
|
1621
|
+
}
|
|
1622
|
+
async function Wt(n, e) {
|
|
1623
|
+
const t = document.createElement("div"), o = Y.fromSchema(e);
|
|
1624
|
+
for (const i of n) {
|
|
1625
|
+
const s = V(i, e), l = o.serializeNode(s);
|
|
1626
|
+
t.appendChild(l);
|
|
1627
|
+
}
|
|
1628
|
+
return (await Q().use(ft, { fragment: !0 }).use(lo, {
|
|
1629
|
+
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
1630
|
+
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
1631
|
+
}).use(gt).process(t.innerHTML)).value;
|
|
1632
|
+
}
|
|
1633
|
+
async function $t(n, e, t) {
|
|
1634
|
+
const o = document.createElement("div");
|
|
1635
|
+
o.innerHTML = n.trim();
|
|
1636
|
+
const i = be.fromSchema(t).parse(o), s = [];
|
|
1637
|
+
for (let l = 0; l < i.firstChild.childCount; l++)
|
|
1638
|
+
s.push(x(i.firstChild.child(l), e));
|
|
1639
|
+
return s;
|
|
1640
|
+
}
|
|
1641
|
+
async function co(n, e) {
|
|
1642
|
+
return (await Q().use(ft, { fragment: !0 }).use(ao).use(we).use(kt).use(Te).process(await Wt(n, e))).value;
|
|
1643
|
+
}
|
|
1644
|
+
function uo(n, e) {
|
|
1645
|
+
const t = e.value ? e.value + `
|
|
1646
|
+
` : "", o = {};
|
|
1647
|
+
e.lang && (o["data-language"] = e.lang);
|
|
1648
|
+
let r = {
|
|
1649
|
+
type: "element",
|
|
1650
|
+
tagName: "code",
|
|
1651
|
+
properties: o,
|
|
1652
|
+
children: [{ type: "text", value: t }]
|
|
1653
|
+
};
|
|
1654
|
+
return e.meta && (r.data = { meta: e.meta }), n.patch(e, r), r = n.applyData(e, r), r = {
|
|
1655
|
+
type: "element",
|
|
1656
|
+
tagName: "pre",
|
|
1657
|
+
properties: {},
|
|
1658
|
+
children: [r]
|
|
1659
|
+
}, n.patch(e, r), r;
|
|
1660
|
+
}
|
|
1661
|
+
async function po(n, e, t) {
|
|
1662
|
+
const o = await Q().use(Ce).use(kt).use(Ee, {
|
|
1663
|
+
handlers: {
|
|
1664
|
+
...Se,
|
|
1665
|
+
code: uo
|
|
1666
|
+
}
|
|
1667
|
+
}).use(gt).process(n);
|
|
1668
|
+
return $t(o.value, e, t);
|
|
1669
|
+
}
|
|
1670
|
+
function dt(n) {
|
|
1671
|
+
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1672
|
+
}
|
|
1673
|
+
function ho(n) {
|
|
1674
|
+
const e = {};
|
|
1675
|
+
return Object.entries(n.propSchema).forEach(([t, o]) => {
|
|
1676
|
+
e[t] = {
|
|
1677
|
+
default: o.default,
|
|
1678
|
+
keepOnSplit: !0,
|
|
1679
|
+
// Props are displayed in kebab-case as HTML attributes. If a prop's
|
|
1680
|
+
// value is the same as its default, we don't display an HTML
|
|
1681
|
+
// attribute for it.
|
|
1682
|
+
parseHTML: (r) => r.getAttribute(dt(t)),
|
|
1683
|
+
renderHTML: (r) => r[t] !== o.default ? {
|
|
1684
|
+
[dt(t)]: r[t]
|
|
1685
|
+
} : {}
|
|
1686
|
+
};
|
|
1687
|
+
}), e;
|
|
1688
|
+
}
|
|
1689
|
+
function mo(n) {
|
|
1690
|
+
return [
|
|
1691
|
+
{
|
|
1692
|
+
tag: "div[data-content-type=" + n.type + "]"
|
|
1693
|
+
}
|
|
1694
|
+
];
|
|
1695
|
+
}
|
|
1696
|
+
function fo(n, e) {
|
|
1697
|
+
const t = document.createElement("div");
|
|
1698
|
+
t.setAttribute("data-content-type", n.type);
|
|
1699
|
+
for (const [r, i] of Object.entries(e))
|
|
1700
|
+
t.setAttribute(r, i);
|
|
1701
|
+
let o;
|
|
1702
|
+
return n.containsInlineContent ? (o = document.createElement("div"), t.appendChild(o)) : o = void 0, o !== void 0 ? {
|
|
1703
|
+
dom: t,
|
|
1704
|
+
contentDOM: o
|
|
1705
|
+
} : {
|
|
1706
|
+
dom: t
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
function go(n) {
|
|
1710
|
+
return {
|
|
1711
|
+
node: F({
|
|
1712
|
+
name: n.type,
|
|
1713
|
+
content: n.containsInlineContent ? "inline*" : "",
|
|
1714
|
+
selectable: !0,
|
|
1715
|
+
addAttributes() {
|
|
1716
|
+
return ho(n);
|
|
1717
|
+
},
|
|
1718
|
+
parseHTML() {
|
|
1719
|
+
return mo(n);
|
|
1720
|
+
},
|
|
1721
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
1722
|
+
return fo(n, t);
|
|
1723
|
+
},
|
|
1724
|
+
addNodeView() {
|
|
1725
|
+
return ({ HTMLAttributes: t, getPos: o }) => {
|
|
1726
|
+
var p, f;
|
|
1727
|
+
const r = document.createElement("div"), i = ((p = this.options.domAttributes) == null ? void 0 : p.blockContent) || {};
|
|
1728
|
+
for (const [k, v] of Object.entries(
|
|
1729
|
+
i
|
|
1730
|
+
))
|
|
1731
|
+
k !== "class" && r.setAttribute(k, v);
|
|
1732
|
+
r.className = S(
|
|
1733
|
+
g.blockContent,
|
|
1734
|
+
i.class
|
|
1735
|
+
), r.setAttribute("data-content-type", n.type);
|
|
1736
|
+
for (const [k, v] of Object.entries(t))
|
|
1737
|
+
r.setAttribute(k, v);
|
|
1738
|
+
const s = this.options.editor;
|
|
1739
|
+
if (typeof o == "boolean")
|
|
1740
|
+
throw new Error(
|
|
1741
|
+
"Cannot find node position as getPos is a boolean, not a function."
|
|
1742
|
+
);
|
|
1743
|
+
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, m = s.getBlock(c);
|
|
1744
|
+
if (m.type !== n.type)
|
|
1745
|
+
throw new Error("Block type does not match");
|
|
1746
|
+
const h = n.render(m, s);
|
|
1747
|
+
if (n.containsInlineContent) {
|
|
1748
|
+
const k = h.contentDOM, v = ((f = this.options.domAttributes) == null ? void 0 : f.inlineContent) || {};
|
|
1749
|
+
for (const [w, E] of Object.entries(
|
|
1750
|
+
v
|
|
1751
|
+
))
|
|
1752
|
+
w !== "class" && k.setAttribute(w, E);
|
|
1753
|
+
k.className = S(
|
|
1754
|
+
k.className,
|
|
1755
|
+
g.inlineContent,
|
|
1756
|
+
v.class
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
return r.appendChild(h.dom), "contentDOM" in h ? {
|
|
1760
|
+
dom: r,
|
|
1761
|
+
contentDOM: h.contentDOM,
|
|
1762
|
+
destroy: h.destroy
|
|
1763
|
+
} : {
|
|
1764
|
+
dom: r,
|
|
1765
|
+
destroy: h.destroy
|
|
1766
|
+
};
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
}),
|
|
1770
|
+
propSchema: n.propSchema
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
function F(n) {
|
|
1774
|
+
return G.create({
|
|
1775
|
+
...n,
|
|
1776
|
+
group: "blockContent",
|
|
1777
|
+
content: n.content
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
const ko = {
|
|
1781
|
+
...C,
|
|
1782
|
+
level: { default: 1, values: [1, 2, 3] }
|
|
1783
|
+
}, bo = F({
|
|
1784
|
+
name: "heading",
|
|
1785
|
+
content: "inline*",
|
|
1786
|
+
addAttributes() {
|
|
1787
|
+
return {
|
|
1788
|
+
level: {
|
|
1789
|
+
default: 1,
|
|
1790
|
+
// instead of "level" attributes, use "data-level"
|
|
1791
|
+
parseHTML: (n) => n.getAttribute("data-level"),
|
|
1792
|
+
renderHTML: (n) => ({
|
|
1793
|
+
"data-level": n.level.toString()
|
|
1794
|
+
})
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
},
|
|
1798
|
+
addInputRules() {
|
|
1799
|
+
return [
|
|
1800
|
+
...[1, 2, 3].map((n) => new Z({
|
|
1801
|
+
find: new RegExp(`^(#{${n}})\\s$`),
|
|
1802
|
+
handler: ({ state: e, chain: t, range: o }) => {
|
|
1803
|
+
t().BNUpdateBlock(e.selection.from, {
|
|
1804
|
+
type: "heading",
|
|
1805
|
+
props: {
|
|
1806
|
+
level: n
|
|
1807
|
+
}
|
|
1808
|
+
}).deleteRange({ from: o.from, to: o.to });
|
|
1809
|
+
}
|
|
1810
|
+
}))
|
|
1811
|
+
];
|
|
1812
|
+
},
|
|
1813
|
+
addKeyboardShortcuts() {
|
|
1814
|
+
return {
|
|
1815
|
+
"Mod-Alt-1": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1816
|
+
type: "heading",
|
|
1817
|
+
props: {
|
|
1818
|
+
level: 1
|
|
1819
|
+
}
|
|
1820
|
+
}),
|
|
1821
|
+
"Mod-Alt-2": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1822
|
+
type: "heading",
|
|
1823
|
+
props: {
|
|
1824
|
+
level: 2
|
|
1825
|
+
}
|
|
1826
|
+
}),
|
|
1827
|
+
"Mod-Alt-3": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1828
|
+
type: "heading",
|
|
1829
|
+
props: {
|
|
1830
|
+
level: 3
|
|
1831
|
+
}
|
|
1832
|
+
})
|
|
1833
|
+
};
|
|
1834
|
+
},
|
|
1835
|
+
parseHTML() {
|
|
1836
|
+
return [
|
|
1837
|
+
{
|
|
1838
|
+
tag: "h1",
|
|
1839
|
+
attrs: { level: 1 },
|
|
1840
|
+
node: "heading"
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
tag: "h2",
|
|
1844
|
+
attrs: { level: 2 },
|
|
1845
|
+
node: "heading"
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
tag: "h3",
|
|
1849
|
+
attrs: { level: 3 },
|
|
1850
|
+
node: "heading"
|
|
1851
|
+
}
|
|
1852
|
+
];
|
|
1853
|
+
},
|
|
1854
|
+
renderHTML({ node: n, HTMLAttributes: e }) {
|
|
1855
|
+
var r, i;
|
|
1856
|
+
const t = ((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {}, o = ((i = this.options.domAttributes) == null ? void 0 : i.inlineContent) || {};
|
|
1857
|
+
return [
|
|
1858
|
+
"div",
|
|
1859
|
+
N(e, {
|
|
1860
|
+
...t,
|
|
1861
|
+
class: S(
|
|
1862
|
+
g.blockContent,
|
|
1863
|
+
t.class
|
|
1864
|
+
),
|
|
1865
|
+
"data-content-type": this.name
|
|
1866
|
+
}),
|
|
1867
|
+
[
|
|
1868
|
+
`h${n.attrs.level}`,
|
|
1869
|
+
{
|
|
1870
|
+
...o,
|
|
1871
|
+
class: S(
|
|
1872
|
+
g.inlineContent,
|
|
1873
|
+
o.class
|
|
1874
|
+
)
|
|
1875
|
+
},
|
|
1876
|
+
0
|
|
1877
|
+
]
|
|
1878
|
+
];
|
|
1879
|
+
}
|
|
1880
|
+
}), yo = {
|
|
1881
|
+
node: bo,
|
|
1882
|
+
propSchema: ko
|
|
1883
|
+
}, Gt = (n) => {
|
|
1884
|
+
const { node: e, contentType: t } = b(
|
|
1885
|
+
n.state.doc,
|
|
1886
|
+
n.state.selection.from
|
|
1887
|
+
), o = n.state.selection.anchor === n.state.selection.head;
|
|
1888
|
+
return !t.name.endsWith("ListItem") || !o ? !1 : n.commands.first(({ state: r, chain: i, commands: s }) => [
|
|
1889
|
+
() => (
|
|
1890
|
+
// Changes list item block to a text block if the content is empty.
|
|
1891
|
+
s.command(() => e.textContent.length === 0 ? s.BNUpdateBlock(r.selection.from, {
|
|
1892
|
+
type: "paragraph",
|
|
1893
|
+
props: {}
|
|
1894
|
+
}) : !1)
|
|
1895
|
+
),
|
|
1896
|
+
() => (
|
|
1897
|
+
// Splits the current block, moving content inside that's after the cursor to a new block of the same type
|
|
1898
|
+
// below.
|
|
1899
|
+
s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
|
|
1900
|
+
)
|
|
1901
|
+
]);
|
|
1902
|
+
}, vo = {
|
|
1903
|
+
...C
|
|
1904
|
+
}, wo = F({
|
|
1905
|
+
name: "bulletListItem",
|
|
1906
|
+
content: "inline*",
|
|
1907
|
+
addInputRules() {
|
|
1908
|
+
return [
|
|
1909
|
+
// Creates an unordered list when starting with "-", "+", or "*".
|
|
1910
|
+
new Z({
|
|
1911
|
+
find: new RegExp("^[-+*]\\s$"),
|
|
1912
|
+
handler: ({ state: n, chain: e, range: t }) => {
|
|
1913
|
+
e().BNUpdateBlock(n.selection.from, {
|
|
1914
|
+
type: "bulletListItem",
|
|
1915
|
+
props: {}
|
|
1916
|
+
}).deleteRange({ from: t.from, to: t.to });
|
|
1917
|
+
}
|
|
1918
|
+
})
|
|
1919
|
+
];
|
|
1920
|
+
},
|
|
1921
|
+
addKeyboardShortcuts() {
|
|
1922
|
+
return {
|
|
1923
|
+
Enter: () => Gt(this.editor),
|
|
1924
|
+
"Mod-Shift-7": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
1925
|
+
type: "bulletListItem",
|
|
1926
|
+
props: {}
|
|
1927
|
+
})
|
|
1928
|
+
};
|
|
1929
|
+
},
|
|
1930
|
+
parseHTML() {
|
|
1931
|
+
return [
|
|
1932
|
+
// Case for regular HTML list structure.
|
|
1933
|
+
{
|
|
1934
|
+
tag: "li",
|
|
1935
|
+
getAttrs: (n) => {
|
|
1936
|
+
if (typeof n == "string")
|
|
1937
|
+
return !1;
|
|
1938
|
+
const e = n.parentElement;
|
|
1939
|
+
return e === null ? !1 : e.tagName === "UL" ? {} : !1;
|
|
1940
|
+
},
|
|
1941
|
+
node: "bulletListItem"
|
|
1942
|
+
},
|
|
1943
|
+
// Case for BlockNote list structure.
|
|
1944
|
+
{
|
|
1945
|
+
tag: "p",
|
|
1946
|
+
getAttrs: (n) => {
|
|
1947
|
+
if (typeof n == "string")
|
|
1948
|
+
return !1;
|
|
1949
|
+
const e = n.parentElement;
|
|
1950
|
+
return e === null ? !1 : e.getAttribute("data-content-type") === "bulletListItem" ? {} : !1;
|
|
1951
|
+
},
|
|
1952
|
+
priority: 300,
|
|
1953
|
+
node: "bulletListItem"
|
|
1954
|
+
}
|
|
1955
|
+
];
|
|
1956
|
+
},
|
|
1957
|
+
renderHTML({ HTMLAttributes: n }) {
|
|
1958
|
+
var o, r;
|
|
1959
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
1960
|
+
return [
|
|
1961
|
+
"div",
|
|
1962
|
+
N(n, {
|
|
1963
|
+
...e,
|
|
1964
|
+
class: S(
|
|
1965
|
+
g.blockContent,
|
|
1966
|
+
e.class
|
|
1967
|
+
),
|
|
1968
|
+
"data-content-type": this.name
|
|
1969
|
+
}),
|
|
1970
|
+
[
|
|
1971
|
+
"p",
|
|
1972
|
+
{
|
|
1973
|
+
...t,
|
|
1974
|
+
class: S(
|
|
1975
|
+
g.inlineContent,
|
|
1976
|
+
t.class
|
|
1977
|
+
)
|
|
1978
|
+
},
|
|
1979
|
+
0
|
|
1980
|
+
]
|
|
1981
|
+
];
|
|
1982
|
+
}
|
|
1983
|
+
}), Co = {
|
|
1984
|
+
node: wo,
|
|
1985
|
+
propSchema: vo
|
|
1986
|
+
}, Eo = new B("numbered-list-indexing"), So = () => new T({
|
|
1987
|
+
key: Eo,
|
|
1988
|
+
appendTransaction: (n, e, t) => {
|
|
1989
|
+
const o = t.tr;
|
|
1990
|
+
o.setMeta("numberedListIndexing", !0);
|
|
1991
|
+
let r = !1;
|
|
1992
|
+
return t.doc.descendants((i, s) => {
|
|
1993
|
+
if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
|
|
1994
|
+
let l = "1";
|
|
1995
|
+
const a = s === 1, d = b(o.doc, s + 1);
|
|
1996
|
+
if (d === void 0)
|
|
1997
|
+
return;
|
|
1998
|
+
if (!a) {
|
|
1999
|
+
const h = b(o.doc, s - 2);
|
|
2000
|
+
if (h === void 0)
|
|
2001
|
+
return;
|
|
2002
|
+
if (!(d.depth !== h.depth)) {
|
|
2003
|
+
const f = h.contentNode;
|
|
2004
|
+
if (h.contentType.name === "numberedListItem") {
|
|
2005
|
+
const w = f.attrs.index;
|
|
2006
|
+
l = (parseInt(w) + 1).toString();
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
d.contentNode.attrs.index !== l && (r = !0, o.setNodeMarkup(s + 1, void 0, {
|
|
2011
|
+
index: l
|
|
2012
|
+
}));
|
|
2013
|
+
}
|
|
2014
|
+
}), r ? o : null;
|
|
2015
|
+
}
|
|
2016
|
+
}), To = {
|
|
2017
|
+
...C
|
|
2018
|
+
}, Mo = F({
|
|
2019
|
+
name: "numberedListItem",
|
|
2020
|
+
content: "inline*",
|
|
2021
|
+
addAttributes() {
|
|
2022
|
+
return {
|
|
2023
|
+
index: {
|
|
2024
|
+
default: null,
|
|
2025
|
+
parseHTML: (n) => n.getAttribute("data-index"),
|
|
2026
|
+
renderHTML: (n) => ({
|
|
2027
|
+
"data-index": n.index
|
|
2028
|
+
})
|
|
2029
|
+
}
|
|
2030
|
+
};
|
|
2031
|
+
},
|
|
2032
|
+
addInputRules() {
|
|
2033
|
+
return [
|
|
2034
|
+
// Creates an ordered list when starting with "1.".
|
|
2035
|
+
new Z({
|
|
2036
|
+
find: new RegExp("^1\\.\\s$"),
|
|
2037
|
+
handler: ({ state: n, chain: e, range: t }) => {
|
|
2038
|
+
e().BNUpdateBlock(n.selection.from, {
|
|
2039
|
+
type: "numberedListItem",
|
|
2040
|
+
props: {}
|
|
2041
|
+
}).deleteRange({ from: t.from, to: t.to });
|
|
2042
|
+
}
|
|
2043
|
+
})
|
|
2044
|
+
];
|
|
2045
|
+
},
|
|
2046
|
+
addKeyboardShortcuts() {
|
|
2047
|
+
return {
|
|
2048
|
+
Enter: () => Gt(this.editor),
|
|
2049
|
+
"Mod-Shift-8": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
|
|
2050
|
+
type: "numberedListItem",
|
|
2051
|
+
props: {}
|
|
2052
|
+
})
|
|
2053
|
+
};
|
|
2054
|
+
},
|
|
2055
|
+
addProseMirrorPlugins() {
|
|
2056
|
+
return [So()];
|
|
2057
|
+
},
|
|
2058
|
+
parseHTML() {
|
|
2059
|
+
return [
|
|
2060
|
+
// Case for regular HTML list structure.
|
|
2061
|
+
// (e.g.: when pasting from other apps)
|
|
2062
|
+
{
|
|
2063
|
+
tag: "li",
|
|
2064
|
+
getAttrs: (n) => {
|
|
2065
|
+
if (typeof n == "string")
|
|
2066
|
+
return !1;
|
|
2067
|
+
const e = n.parentElement;
|
|
2068
|
+
return e === null ? !1 : e.tagName === "OL" ? {} : !1;
|
|
2069
|
+
},
|
|
2070
|
+
node: "numberedListItem"
|
|
2071
|
+
},
|
|
2072
|
+
// Case for BlockNote list structure.
|
|
2073
|
+
// (e.g.: when pasting from blocknote)
|
|
2074
|
+
{
|
|
2075
|
+
tag: "p",
|
|
2076
|
+
getAttrs: (n) => {
|
|
2077
|
+
if (typeof n == "string")
|
|
2078
|
+
return !1;
|
|
2079
|
+
const e = n.parentElement;
|
|
2080
|
+
return e === null ? !1 : e.getAttribute("data-content-type") === "numberedListItem" ? {} : !1;
|
|
2081
|
+
},
|
|
2082
|
+
priority: 300,
|
|
2083
|
+
node: "numberedListItem"
|
|
2084
|
+
}
|
|
2085
|
+
];
|
|
2086
|
+
},
|
|
2087
|
+
renderHTML({ HTMLAttributes: n }) {
|
|
2088
|
+
var o, r;
|
|
2089
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
2090
|
+
return [
|
|
2091
|
+
"div",
|
|
2092
|
+
N(n, {
|
|
2093
|
+
...e,
|
|
2094
|
+
class: S(
|
|
2095
|
+
g.blockContent,
|
|
2096
|
+
e.class
|
|
2097
|
+
),
|
|
2098
|
+
"data-content-type": this.name
|
|
2099
|
+
}),
|
|
2100
|
+
// we use a <p> tag, because for <li> tags we'd need to add a <ul> parent for around siblings to be semantically correct,
|
|
2101
|
+
// which would be quite cumbersome
|
|
2102
|
+
[
|
|
2103
|
+
"p",
|
|
2104
|
+
{
|
|
2105
|
+
...t,
|
|
2106
|
+
class: S(
|
|
2107
|
+
g.inlineContent,
|
|
2108
|
+
t.class
|
|
2109
|
+
)
|
|
2110
|
+
},
|
|
2111
|
+
0
|
|
2112
|
+
]
|
|
2113
|
+
];
|
|
2114
|
+
}
|
|
2115
|
+
}), Bo = {
|
|
2116
|
+
node: Mo,
|
|
2117
|
+
propSchema: To
|
|
2118
|
+
}, xo = {
|
|
2119
|
+
...C
|
|
2120
|
+
}, Io = F({
|
|
2121
|
+
name: "paragraph",
|
|
2122
|
+
content: "inline*",
|
|
2123
|
+
parseHTML() {
|
|
2124
|
+
return [
|
|
2125
|
+
{
|
|
2126
|
+
tag: "p",
|
|
2127
|
+
priority: 200,
|
|
2128
|
+
node: "paragraph"
|
|
2129
|
+
}
|
|
2130
|
+
];
|
|
2131
|
+
},
|
|
2132
|
+
renderHTML({ HTMLAttributes: n }) {
|
|
2133
|
+
var o, r;
|
|
2134
|
+
const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
|
|
2135
|
+
return [
|
|
2136
|
+
"div",
|
|
2137
|
+
N(
|
|
2138
|
+
{
|
|
2139
|
+
...e,
|
|
2140
|
+
class: S(
|
|
2141
|
+
g.blockContent,
|
|
2142
|
+
e.class
|
|
2143
|
+
),
|
|
2144
|
+
"data-content-type": this.name
|
|
2145
|
+
},
|
|
2146
|
+
n
|
|
2147
|
+
),
|
|
2148
|
+
[
|
|
2149
|
+
"p",
|
|
2150
|
+
{
|
|
2151
|
+
...t,
|
|
2152
|
+
class: S(
|
|
2153
|
+
g.inlineContent,
|
|
2154
|
+
t.class
|
|
2155
|
+
)
|
|
2156
|
+
},
|
|
2157
|
+
0
|
|
2158
|
+
]
|
|
1874
2159
|
];
|
|
1875
2160
|
}
|
|
1876
|
-
}),
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
L.ClipboardTextSerializer,
|
|
1880
|
-
L.Commands,
|
|
1881
|
-
L.Editable,
|
|
1882
|
-
L.FocusEvents,
|
|
1883
|
-
L.Tabindex,
|
|
1884
|
-
// DevTools,
|
|
1885
|
-
Kt,
|
|
1886
|
-
// DropCursor,
|
|
1887
|
-
qe.configure({
|
|
1888
|
-
emptyNodeClass: y.isEmpty,
|
|
1889
|
-
hasAnchorClass: y.hasAnchor,
|
|
1890
|
-
isFilterClass: y.isFilter,
|
|
1891
|
-
includeChildren: !0,
|
|
1892
|
-
showOnlyCurrent: !1
|
|
1893
|
-
}),
|
|
1894
|
-
F.configure({
|
|
1895
|
-
types: ["blockContainer"]
|
|
1896
|
-
}),
|
|
1897
|
-
Jt,
|
|
1898
|
-
// Comments,
|
|
1899
|
-
// basics:
|
|
1900
|
-
ee,
|
|
1901
|
-
// marks:
|
|
1902
|
-
$t,
|
|
1903
|
-
jt,
|
|
1904
|
-
Zt,
|
|
1905
|
-
te,
|
|
1906
|
-
oe,
|
|
1907
|
-
Qt,
|
|
1908
|
-
Ke,
|
|
1909
|
-
Ye,
|
|
1910
|
-
ge,
|
|
1911
|
-
ke,
|
|
1912
|
-
We,
|
|
1913
|
-
// nodes
|
|
1914
|
-
Re,
|
|
1915
|
-
Oe.configure({
|
|
1916
|
-
domAttributes: n.domAttributes
|
|
1917
|
-
}),
|
|
1918
|
-
De.configure({
|
|
1919
|
-
domAttributes: n.domAttributes
|
|
1920
|
-
}),
|
|
1921
|
-
...Object.values(n.blockSchema).map(
|
|
1922
|
-
(o) => o.node.configure({
|
|
1923
|
-
editor: n.editor,
|
|
1924
|
-
domAttributes: n.domAttributes
|
|
1925
|
-
})
|
|
1926
|
-
),
|
|
1927
|
-
ze,
|
|
1928
|
-
Yt.configure({ width: 5, color: "#ddeeff" }),
|
|
1929
|
-
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
1930
|
-
// should be handled before Enter handlers in other components like splitListItem
|
|
1931
|
-
Je
|
|
1932
|
-
];
|
|
1933
|
-
if (n.collaboration) {
|
|
1934
|
-
if (e.push(
|
|
1935
|
-
qt.configure({
|
|
1936
|
-
fragment: n.collaboration.fragment
|
|
1937
|
-
})
|
|
1938
|
-
), (t = n.collaboration.provider) != null && t.awareness) {
|
|
1939
|
-
const o = (r) => {
|
|
1940
|
-
const i = document.createElement("span");
|
|
1941
|
-
i.classList.add(H["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
|
|
1942
|
-
const s = document.createElement("span");
|
|
1943
|
-
s.classList.add(H["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
|
|
1944
|
-
const l = document.createTextNode(""), a = document.createTextNode("");
|
|
1945
|
-
return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
|
|
1946
|
-
};
|
|
1947
|
-
e.push(
|
|
1948
|
-
Wt.configure({
|
|
1949
|
-
user: n.collaboration.user,
|
|
1950
|
-
render: n.collaboration.renderCursor || o,
|
|
1951
|
-
provider: n.collaboration.provider
|
|
1952
|
-
})
|
|
1953
|
-
);
|
|
1954
|
-
}
|
|
1955
|
-
} else
|
|
1956
|
-
e.push(Xt);
|
|
1957
|
-
return e;
|
|
2161
|
+
}), Ao = {
|
|
2162
|
+
node: Io,
|
|
2163
|
+
propSchema: xo
|
|
1958
2164
|
};
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
node
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
2165
|
+
class _o {
|
|
2166
|
+
constructor(e, t, o) {
|
|
2167
|
+
u(this, "imageToolbarState");
|
|
2168
|
+
u(this, "updateImageToolbar");
|
|
2169
|
+
u(this, "prevWasEditable", null);
|
|
2170
|
+
u(this, "shouldShow", (e) => "node" in e.selection && e.selection.node.type.name === "image" && e.selection.node.attrs.src === "");
|
|
2171
|
+
u(this, "mouseDownHandler", () => {
|
|
2172
|
+
var e;
|
|
2173
|
+
(e = this.imageToolbarState) != null && e.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
2174
|
+
});
|
|
2175
|
+
// For dragging the whole editor.
|
|
2176
|
+
u(this, "dragstartHandler", () => {
|
|
2177
|
+
var e;
|
|
2178
|
+
(e = this.imageToolbarState) != null && e.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
2179
|
+
});
|
|
2180
|
+
u(this, "blurHandler", (e) => {
|
|
2181
|
+
var o;
|
|
2182
|
+
const t = this.pmView.dom.parentElement;
|
|
2183
|
+
// An element is clicked.
|
|
2184
|
+
e && e.relatedTarget && // Element is inside the editor.
|
|
2185
|
+
(t === e.relatedTarget || t.contains(e.relatedTarget)) || (o = this.imageToolbarState) != null && o.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
2186
|
+
});
|
|
2187
|
+
u(this, "scrollHandler", () => {
|
|
2188
|
+
var e;
|
|
2189
|
+
if ((e = this.imageToolbarState) != null && e.show) {
|
|
2190
|
+
const t = document.querySelector(
|
|
2191
|
+
`[data-node-type="blockContainer"][data-id="${this.imageToolbarState.block.id}"]`
|
|
2192
|
+
);
|
|
2193
|
+
this.imageToolbarState.referencePos = t.getBoundingClientRect(), this.updateImageToolbar();
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
this.pluginKey = e, this.pmView = t, this.updateImageToolbar = () => {
|
|
2197
|
+
if (!this.imageToolbarState)
|
|
2198
|
+
throw new Error("Attempting to update uninitialized image toolbar");
|
|
2199
|
+
o(this.imageToolbarState);
|
|
2200
|
+
}, t.dom.addEventListener("mousedown", this.mouseDownHandler), t.dom.addEventListener("dragstart", this.dragstartHandler), t.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2201
|
+
}
|
|
2202
|
+
update(e, t) {
|
|
2203
|
+
var r, i;
|
|
2204
|
+
const o = this.pluginKey.getState(e.state);
|
|
2205
|
+
if (!((r = this.imageToolbarState) != null && r.show) && o.block) {
|
|
2206
|
+
const s = document.querySelector(
|
|
2207
|
+
`[data-node-type="blockContainer"][data-id="${o.block.id}"]`
|
|
1983
2208
|
);
|
|
2209
|
+
this.imageToolbarState = {
|
|
2210
|
+
show: !0,
|
|
2211
|
+
referencePos: s.getBoundingClientRect(),
|
|
2212
|
+
block: o.block
|
|
2213
|
+
}, this.updateImageToolbar();
|
|
1984
2214
|
return;
|
|
1985
2215
|
}
|
|
1986
|
-
|
|
2216
|
+
(!e.state.selection.eq(t.selection) || !e.state.doc.eq(t.doc)) && (i = this.imageToolbarState) != null && i.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
|
|
1987
2217
|
}
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
function Ze(n, e, t) {
|
|
1991
|
-
const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = Z(o, t.state.doc);
|
|
1992
|
-
t.commands.BNUpdateBlock(r + 1, e);
|
|
1993
|
-
}
|
|
1994
|
-
function At(n, e) {
|
|
1995
|
-
const t = new Set(
|
|
1996
|
-
n.map(
|
|
1997
|
-
(r) => typeof r == "string" ? r : r.id
|
|
1998
|
-
)
|
|
1999
|
-
);
|
|
2000
|
-
let o = 0;
|
|
2001
|
-
if (e.state.doc.descendants((r, i) => {
|
|
2002
|
-
if (t.size === 0)
|
|
2003
|
-
return !1;
|
|
2004
|
-
if (r.type.name !== "blockContainer" || !t.has(r.attrs.id))
|
|
2005
|
-
return !0;
|
|
2006
|
-
t.delete(r.attrs.id);
|
|
2007
|
-
const s = e.state.doc.nodeSize;
|
|
2008
|
-
e.commands.BNDeleteBlock(i - o + 1);
|
|
2009
|
-
const l = e.state.doc.nodeSize;
|
|
2010
|
-
return o += s - l, !1;
|
|
2011
|
-
}), t.size > 0) {
|
|
2012
|
-
const r = [...t].join(`
|
|
2013
|
-
`);
|
|
2014
|
-
throw Error(
|
|
2015
|
-
"Blocks with the following IDs could not be found in the editor: " + r
|
|
2016
|
-
);
|
|
2218
|
+
destroy() {
|
|
2219
|
+
this.pmView.dom.removeEventListener("mousedown", this.mouseDownHandler), this.pmView.dom.removeEventListener("dragstart", this.dragstartHandler), this.pmView.dom.removeEventListener("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
|
|
2017
2220
|
}
|
|
2018
2221
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, h = e.has(
|
|
2046
|
-
d.properties.dataContentType
|
|
2047
|
-
), u = h ? n.orderedListItemBlockTypes.has(
|
|
2048
|
-
d.properties.dataContentType
|
|
2049
|
-
) ? "ol" : "ul" : null;
|
|
2050
|
-
if (c !== null && t(c), i && i.tagName !== u) {
|
|
2051
|
-
o.children.splice(
|
|
2052
|
-
s - i.children.length,
|
|
2053
|
-
i.children.length,
|
|
2054
|
-
i
|
|
2055
|
-
);
|
|
2056
|
-
const f = i.children.length - 1;
|
|
2057
|
-
s -= f, r -= f, i = void 0;
|
|
2222
|
+
const z = new B("ImageToolbarPlugin");
|
|
2223
|
+
class Ho extends U {
|
|
2224
|
+
constructor(t) {
|
|
2225
|
+
super();
|
|
2226
|
+
u(this, "view");
|
|
2227
|
+
u(this, "plugin");
|
|
2228
|
+
this.plugin = new T({
|
|
2229
|
+
key: z,
|
|
2230
|
+
view: (o) => (this.view = new _o(
|
|
2231
|
+
// editor,
|
|
2232
|
+
z,
|
|
2233
|
+
o,
|
|
2234
|
+
(r) => {
|
|
2235
|
+
this.emit("update", r);
|
|
2236
|
+
}
|
|
2237
|
+
), this.view),
|
|
2238
|
+
state: {
|
|
2239
|
+
init: () => ({
|
|
2240
|
+
block: void 0
|
|
2241
|
+
}),
|
|
2242
|
+
apply: (o) => {
|
|
2243
|
+
var i;
|
|
2244
|
+
return {
|
|
2245
|
+
block: (i = o.getMeta(z)) == null ? void 0 : i.block
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2058
2248
|
}
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
const f = nt(
|
|
2064
|
-
document.createElement("li")
|
|
2065
|
-
);
|
|
2066
|
-
f.children.push(d.children[0]), c !== null && f.children.push(...c.children), i.children.push(f);
|
|
2067
|
-
} else if (c !== null) {
|
|
2068
|
-
o.children.splice(s + 1, 0, ...c.children), o.children[s] = d.children[0];
|
|
2069
|
-
const f = c.children.length;
|
|
2070
|
-
s += f, r += f;
|
|
2071
|
-
} else
|
|
2072
|
-
o.children[s] = d.children[0];
|
|
2073
|
-
}
|
|
2074
|
-
i && o.children.splice(
|
|
2075
|
-
r - i.children.length,
|
|
2076
|
-
i.children.length,
|
|
2077
|
-
i
|
|
2078
|
-
);
|
|
2079
|
-
};
|
|
2080
|
-
return t;
|
|
2081
|
-
}
|
|
2082
|
-
async function It(n, e) {
|
|
2083
|
-
const t = document.createElement("div"), o = W.fromSchema(e);
|
|
2084
|
-
for (const i of n) {
|
|
2085
|
-
const s = D(i, e), l = o.serializeNode(s);
|
|
2086
|
-
t.appendChild(l);
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
onUpdate(t) {
|
|
2252
|
+
return this.on("update", t);
|
|
2087
2253
|
}
|
|
2088
|
-
return (await J().use(dt, { fragment: !0 }).use(eo, {
|
|
2089
|
-
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
2090
|
-
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
2091
|
-
}).use(ct).process(t.innerHTML)).value;
|
|
2092
2254
|
}
|
|
2093
|
-
|
|
2255
|
+
const Lo = {
|
|
2256
|
+
textAlignment: C.textAlignment,
|
|
2257
|
+
backgroundColor: C.backgroundColor,
|
|
2258
|
+
// Image url.
|
|
2259
|
+
url: {
|
|
2260
|
+
default: ""
|
|
2261
|
+
},
|
|
2262
|
+
// Image caption.
|
|
2263
|
+
caption: {
|
|
2264
|
+
default: ""
|
|
2265
|
+
},
|
|
2266
|
+
// Image width in px.
|
|
2267
|
+
width: {
|
|
2268
|
+
default: 512
|
|
2269
|
+
}
|
|
2270
|
+
}, ct = (n) => {
|
|
2271
|
+
switch (n) {
|
|
2272
|
+
case "left":
|
|
2273
|
+
return "flex-start";
|
|
2274
|
+
case "center":
|
|
2275
|
+
return "center";
|
|
2276
|
+
case "right":
|
|
2277
|
+
return "flex-end";
|
|
2278
|
+
default:
|
|
2279
|
+
return "flex-start";
|
|
2280
|
+
}
|
|
2281
|
+
}, ut = 64, No = (n, e) => {
|
|
2282
|
+
const t = document.createElement("div");
|
|
2283
|
+
t.className = g.wrapper, t.style.alignItems = ct(
|
|
2284
|
+
n.props.textAlignment
|
|
2285
|
+
);
|
|
2094
2286
|
const o = document.createElement("div");
|
|
2095
|
-
o.
|
|
2096
|
-
const
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2287
|
+
o.className = g.addImageButton, o.style.display = n.props.url === "" ? "" : "none";
|
|
2288
|
+
const r = document.createElement("div");
|
|
2289
|
+
r.className = g.addImageButtonIcon;
|
|
2290
|
+
const i = document.createElement("p");
|
|
2291
|
+
i.className = g.addImageButtonText, i.innerText = "Add Image";
|
|
2292
|
+
const s = document.createElement("div");
|
|
2293
|
+
s.className = g.imageAndCaptionWrapper, s.style.display = n.props.url !== "" ? "" : "none";
|
|
2294
|
+
const l = document.createElement("div");
|
|
2295
|
+
l.className = g.imageWrapper, l.style.display = n.props.url !== "" ? "" : "none";
|
|
2296
|
+
const a = document.createElement("img");
|
|
2297
|
+
a.className = g.image, a.src = n.props.url, a.alt = "placeholder", a.contentEditable = "false", a.draggable = !1, a.style.width = `${Math.min(
|
|
2298
|
+
n.props.width,
|
|
2299
|
+
e.domElement.firstElementChild.clientWidth
|
|
2300
|
+
)}px`;
|
|
2301
|
+
const d = document.createElement("div");
|
|
2302
|
+
d.className = g.resizeHandle, d.style.left = "4px";
|
|
2303
|
+
const c = document.createElement("div");
|
|
2304
|
+
c.className = g.resizeHandle, c.style.right = "4px";
|
|
2305
|
+
const m = document.createElement("p");
|
|
2306
|
+
m.className = g.caption, m.innerText = n.props.caption, m.style.padding = n.props.caption ? "4px" : "";
|
|
2307
|
+
const h = () => {
|
|
2308
|
+
var q;
|
|
2309
|
+
const y = ((q = e.getSelection()) == null ? void 0 : q.blocks) || [];
|
|
2310
|
+
[e.getTextCursorPosition().block, ...y].find(
|
|
2311
|
+
(Kt) => Kt.id === n.id
|
|
2312
|
+
) !== void 0 ? (o.style.outline = "4px solid rgb(100, 160, 255)", s.style.outline = "4px solid rgb(100, 160, 255)") : (o.style.outline = "", s.style.outline = "");
|
|
2113
2313
|
};
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2314
|
+
e.onEditorContentChange(h), e.onEditorSelectionChange(h);
|
|
2315
|
+
let p;
|
|
2316
|
+
const f = (y) => {
|
|
2317
|
+
if (!p)
|
|
2318
|
+
return;
|
|
2319
|
+
let M;
|
|
2320
|
+
ct(n.props.textAlignment) === "center" ? p.handleUsed === "left" ? M = p.initialWidth + (p.initialClientX - y.clientX) * 2 : M = p.initialWidth + (y.clientX - p.initialClientX) * 2 : p.handleUsed === "left" ? M = p.initialWidth + p.initialClientX - y.clientX : M = p.initialWidth + y.clientX - p.initialClientX, M < ut ? a.style.width = `${ut}px` : M > e.domElement.firstElementChild.clientWidth ? a.style.width = `${e.domElement.firstElementChild.clientWidth}px` : a.style.width = `${M}px`;
|
|
2321
|
+
}, k = (y) => {
|
|
2322
|
+
p && ((!y.target || !l.contains(y.target)) && l.contains(d) && l.contains(c) && (d.style.display = "none", c.style.display = "none"), p = void 0, e.updateBlock(n, {
|
|
2323
|
+
type: "image",
|
|
2324
|
+
props: {
|
|
2325
|
+
// Removes "px" from the end of the width string and converts to float.
|
|
2326
|
+
width: parseFloat(a.style.width.slice(0, -2))
|
|
2327
|
+
}
|
|
2328
|
+
}));
|
|
2329
|
+
}, v = (y) => {
|
|
2330
|
+
y.preventDefault();
|
|
2331
|
+
}, w = () => {
|
|
2332
|
+
e._tiptapEditor.view.dispatch(
|
|
2333
|
+
e._tiptapEditor.state.tr.setMeta(z, {
|
|
2334
|
+
block: n
|
|
2335
|
+
})
|
|
2336
|
+
);
|
|
2337
|
+
}, E = (y) => {
|
|
2338
|
+
y.preventDefault(), d.style.display = "block", c.style.display = "block", p = {
|
|
2339
|
+
handleUsed: "left",
|
|
2340
|
+
initialWidth: n.props.width,
|
|
2341
|
+
initialClientX: y.clientX
|
|
2342
|
+
};
|
|
2343
|
+
}, _ = (y) => {
|
|
2344
|
+
y.preventDefault(), d.style.display = "block", c.style.display = "block", p = {
|
|
2345
|
+
handleUsed: "right",
|
|
2346
|
+
initialWidth: n.props.width,
|
|
2347
|
+
initialClientX: y.clientX
|
|
2348
|
+
};
|
|
2349
|
+
};
|
|
2350
|
+
return t.appendChild(o), o.appendChild(r), o.appendChild(i), t.appendChild(s), s.appendChild(l), l.appendChild(a), l.appendChild(d), l.appendChild(c), s.appendChild(m), window.addEventListener("mousemove", f), window.addEventListener("mouseup", k), o.addEventListener("mousedown", v), o.addEventListener("click", w), d.addEventListener(
|
|
2351
|
+
"mousedown",
|
|
2352
|
+
E
|
|
2353
|
+
), c.addEventListener(
|
|
2354
|
+
"mousedown",
|
|
2355
|
+
_
|
|
2356
|
+
), {
|
|
2357
|
+
dom: t,
|
|
2358
|
+
destroy: () => {
|
|
2359
|
+
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", k), o.removeEventListener(
|
|
2360
|
+
"mousedown",
|
|
2361
|
+
v
|
|
2362
|
+
), o.removeEventListener("click", w), d.removeEventListener(
|
|
2363
|
+
"mousedown",
|
|
2364
|
+
E
|
|
2365
|
+
), c.removeEventListener(
|
|
2366
|
+
"mousedown",
|
|
2367
|
+
_
|
|
2368
|
+
);
|
|
2126
2369
|
}
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2370
|
+
};
|
|
2371
|
+
}, Po = go({
|
|
2372
|
+
type: "image",
|
|
2373
|
+
propSchema: Lo,
|
|
2374
|
+
containsInlineContent: !1,
|
|
2375
|
+
render: No
|
|
2376
|
+
}), jt = {
|
|
2377
|
+
paragraph: Ao,
|
|
2378
|
+
heading: yo,
|
|
2379
|
+
bulletListItem: Co,
|
|
2380
|
+
numberedListItem: Bo,
|
|
2381
|
+
image: Po
|
|
2382
|
+
};
|
|
2383
|
+
class Do {
|
|
2131
2384
|
constructor(e, t, o) {
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length &&
|
|
2385
|
+
u(this, "formattingToolbarState");
|
|
2386
|
+
u(this, "updateFormattingToolbar");
|
|
2387
|
+
u(this, "preventHide", !1);
|
|
2388
|
+
u(this, "preventShow", !1);
|
|
2389
|
+
u(this, "prevWasEditable", null);
|
|
2390
|
+
u(this, "shouldShow", ({ view: e, state: t, from: o, to: r }) => {
|
|
2391
|
+
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length && oe(t.selection);
|
|
2139
2392
|
return !(!e.hasFocus() || l || a);
|
|
2140
2393
|
});
|
|
2141
|
-
|
|
2394
|
+
u(this, "viewMousedownHandler", () => {
|
|
2142
2395
|
this.preventShow = !0;
|
|
2143
2396
|
});
|
|
2144
|
-
|
|
2397
|
+
u(this, "viewMouseupHandler", () => {
|
|
2145
2398
|
this.preventShow = !1, setTimeout(() => this.update(this.pmView));
|
|
2146
2399
|
});
|
|
2147
2400
|
// For dragging the whole editor.
|
|
2148
|
-
|
|
2401
|
+
u(this, "dragstartHandler", () => {
|
|
2149
2402
|
var e;
|
|
2150
2403
|
(e = this.formattingToolbarState) != null && e.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2151
2404
|
});
|
|
2152
|
-
|
|
2405
|
+
u(this, "focusHandler", () => {
|
|
2153
2406
|
setTimeout(() => this.update(this.pmView));
|
|
2154
2407
|
});
|
|
2155
|
-
|
|
2408
|
+
u(this, "blurHandler", (e) => {
|
|
2156
2409
|
var o;
|
|
2157
2410
|
if (this.preventHide) {
|
|
2158
2411
|
this.preventHide = !1;
|
|
@@ -2163,7 +2416,7 @@ class io {
|
|
|
2163
2416
|
e && e.relatedTarget && // Element is inside the editor.
|
|
2164
2417
|
(t === e.relatedTarget || t.contains(e.relatedTarget)) || (o = this.formattingToolbarState) != null && o.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2165
2418
|
});
|
|
2166
|
-
|
|
2419
|
+
u(this, "scrollHandler", () => {
|
|
2167
2420
|
var e;
|
|
2168
2421
|
(e = this.formattingToolbarState) != null && e.show && (this.formattingToolbarState.referencePos = this.getSelectionBoundingBox(), this.updateFormattingToolbar());
|
|
2169
2422
|
});
|
|
@@ -2176,25 +2429,25 @@ class io {
|
|
|
2176
2429
|
}, 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);
|
|
2177
2430
|
}
|
|
2178
2431
|
update(e, t) {
|
|
2179
|
-
var
|
|
2432
|
+
var h, p;
|
|
2180
2433
|
const { state: o, composing: r } = e, { doc: i, selection: s } = o, l = t && t.doc.eq(i) && t.selection.eq(s);
|
|
2181
2434
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
|
|
2182
2435
|
return;
|
|
2183
2436
|
this.prevWasEditable = this.editor.isEditable;
|
|
2184
|
-
const { ranges: a } = s, d = Math.min(...a.map((
|
|
2437
|
+
const { ranges: a } = s, d = Math.min(...a.map((f) => f.$from.pos)), c = Math.max(...a.map((f) => f.$to.pos)), m = (h = this.shouldShow) == null ? void 0 : h.call(this, {
|
|
2185
2438
|
view: e,
|
|
2186
2439
|
state: o,
|
|
2187
2440
|
from: d,
|
|
2188
2441
|
to: c
|
|
2189
2442
|
});
|
|
2190
|
-
if (this.editor.isEditable && !this.preventShow && (
|
|
2443
|
+
if (this.editor.isEditable && !this.preventShow && (m || this.preventHide)) {
|
|
2191
2444
|
this.formattingToolbarState = {
|
|
2192
2445
|
show: !0,
|
|
2193
2446
|
referencePos: this.getSelectionBoundingBox()
|
|
2194
2447
|
}, this.updateFormattingToolbar();
|
|
2195
2448
|
return;
|
|
2196
2449
|
}
|
|
2197
|
-
if ((
|
|
2450
|
+
if ((p = this.formattingToolbarState) != null && p.show && !this.preventHide && (!m || this.preventShow || !this.editor.isEditable)) {
|
|
2198
2451
|
this.formattingToolbarState.show = !1, this.updateFormattingToolbar();
|
|
2199
2452
|
return;
|
|
2200
2453
|
}
|
|
@@ -2204,25 +2457,25 @@ class io {
|
|
|
2204
2457
|
}
|
|
2205
2458
|
getSelectionBoundingBox() {
|
|
2206
2459
|
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));
|
|
2207
|
-
if (
|
|
2460
|
+
if (ne(t)) {
|
|
2208
2461
|
const s = this.pmView.nodeDOM(r);
|
|
2209
2462
|
if (s)
|
|
2210
2463
|
return s.getBoundingClientRect();
|
|
2211
2464
|
}
|
|
2212
|
-
return
|
|
2465
|
+
return K(this.pmView, r, i);
|
|
2213
2466
|
}
|
|
2214
2467
|
}
|
|
2215
|
-
const
|
|
2468
|
+
const Oo = new B(
|
|
2216
2469
|
"FormattingToolbarPlugin"
|
|
2217
2470
|
);
|
|
2218
|
-
class
|
|
2471
|
+
class Ro extends U {
|
|
2219
2472
|
constructor(t) {
|
|
2220
2473
|
super();
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
this.plugin = new
|
|
2224
|
-
key:
|
|
2225
|
-
view: (o) => (this.view = new
|
|
2474
|
+
u(this, "view");
|
|
2475
|
+
u(this, "plugin");
|
|
2476
|
+
this.plugin = new T({
|
|
2477
|
+
key: Oo,
|
|
2478
|
+
view: (o) => (this.view = new Do(t, o, (r) => {
|
|
2226
2479
|
this.emit("update", r);
|
|
2227
2480
|
}), this.view)
|
|
2228
2481
|
});
|
|
@@ -2231,27 +2484,27 @@ class ao extends G {
|
|
|
2231
2484
|
return this.on("update", t);
|
|
2232
2485
|
}
|
|
2233
2486
|
}
|
|
2234
|
-
class
|
|
2487
|
+
class zo {
|
|
2235
2488
|
constructor(e, t, o) {
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2489
|
+
u(this, "hyperlinkToolbarState");
|
|
2490
|
+
u(this, "updateHyperlinkToolbar");
|
|
2491
|
+
u(this, "menuUpdateTimer");
|
|
2492
|
+
u(this, "startMenuUpdateTimer");
|
|
2493
|
+
u(this, "stopMenuUpdateTimer");
|
|
2494
|
+
u(this, "mouseHoveredHyperlinkMark");
|
|
2495
|
+
u(this, "mouseHoveredHyperlinkMarkRange");
|
|
2496
|
+
u(this, "keyboardHoveredHyperlinkMark");
|
|
2497
|
+
u(this, "keyboardHoveredHyperlinkMarkRange");
|
|
2498
|
+
u(this, "hyperlinkMark");
|
|
2499
|
+
u(this, "hyperlinkMarkRange");
|
|
2500
|
+
u(this, "mouseOverHandler", (e) => {
|
|
2248
2501
|
if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), e.target instanceof HTMLAnchorElement && e.target.nodeName === "A") {
|
|
2249
2502
|
const t = e.target, o = this.pmView.posAtDOM(t, 0) + 1, r = this.pmView.state.doc.resolve(
|
|
2250
2503
|
o
|
|
2251
2504
|
), i = r.marks();
|
|
2252
2505
|
for (const s of i)
|
|
2253
2506
|
if (s.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2254
|
-
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange =
|
|
2507
|
+
this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = rt(
|
|
2255
2508
|
r,
|
|
2256
2509
|
s.type,
|
|
2257
2510
|
s.attrs
|
|
@@ -2261,7 +2514,7 @@ class lo {
|
|
|
2261
2514
|
}
|
|
2262
2515
|
return this.startMenuUpdateTimer(), !1;
|
|
2263
2516
|
});
|
|
2264
|
-
|
|
2517
|
+
u(this, "clickHandler", (e) => {
|
|
2265
2518
|
var o;
|
|
2266
2519
|
const t = this.pmView.dom.parentElement;
|
|
2267
2520
|
// Toolbar is open.
|
|
@@ -2269,9 +2522,9 @@ class lo {
|
|
|
2269
2522
|
e && e.target && // The clicked element is not the editor.
|
|
2270
2523
|
!(t === e.target || t.contains(e.target)) && (o = this.hyperlinkToolbarState) != null && o.show && (this.hyperlinkToolbarState.show = !1, this.updateHyperlinkToolbar());
|
|
2271
2524
|
});
|
|
2272
|
-
|
|
2525
|
+
u(this, "scrollHandler", () => {
|
|
2273
2526
|
var e;
|
|
2274
|
-
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos =
|
|
2527
|
+
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos = K(
|
|
2275
2528
|
this.pmView,
|
|
2276
2529
|
this.hyperlinkMarkRange.from,
|
|
2277
2530
|
this.hyperlinkMarkRange.to
|
|
@@ -2319,7 +2572,7 @@ class lo {
|
|
|
2319
2572
|
const o = this.pmView.state.selection.$from.marks();
|
|
2320
2573
|
for (const r of o)
|
|
2321
2574
|
if (r.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2322
|
-
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange =
|
|
2575
|
+
this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange = rt(
|
|
2323
2576
|
this.pmView.state.selection.$from,
|
|
2324
2577
|
r.type,
|
|
2325
2578
|
r.attrs
|
|
@@ -2330,7 +2583,7 @@ class lo {
|
|
|
2330
2583
|
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) {
|
|
2331
2584
|
this.hyperlinkToolbarState = {
|
|
2332
2585
|
show: !0,
|
|
2333
|
-
referencePos:
|
|
2586
|
+
referencePos: K(
|
|
2334
2587
|
this.pmView,
|
|
2335
2588
|
this.hyperlinkMarkRange.from,
|
|
2336
2589
|
this.hyperlinkMarkRange.to
|
|
@@ -2352,24 +2605,24 @@ class lo {
|
|
|
2352
2605
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2353
2606
|
}
|
|
2354
2607
|
}
|
|
2355
|
-
const
|
|
2608
|
+
const Vo = new B(
|
|
2356
2609
|
"HyperlinkToolbarPlugin"
|
|
2357
2610
|
);
|
|
2358
|
-
class
|
|
2611
|
+
class Uo extends U {
|
|
2359
2612
|
constructor(t) {
|
|
2360
2613
|
super();
|
|
2361
|
-
|
|
2362
|
-
|
|
2614
|
+
u(this, "view");
|
|
2615
|
+
u(this, "plugin");
|
|
2363
2616
|
/**
|
|
2364
2617
|
* Edit the currently hovered hyperlink.
|
|
2365
2618
|
*/
|
|
2366
|
-
|
|
2619
|
+
u(this, "editHyperlink", (t, o) => {
|
|
2367
2620
|
this.view.editHyperlink(t, o);
|
|
2368
2621
|
});
|
|
2369
2622
|
/**
|
|
2370
2623
|
* Delete the currently hovered hyperlink.
|
|
2371
2624
|
*/
|
|
2372
|
-
|
|
2625
|
+
u(this, "deleteHyperlink", () => {
|
|
2373
2626
|
this.view.deleteHyperlink();
|
|
2374
2627
|
});
|
|
2375
2628
|
/**
|
|
@@ -2378,7 +2631,7 @@ class uo extends G {
|
|
|
2378
2631
|
*
|
|
2379
2632
|
* This function starts the delay timer, and should be used for when the mouse cursor enters the hyperlink toolbar.
|
|
2380
2633
|
*/
|
|
2381
|
-
|
|
2634
|
+
u(this, "startHideTimer", () => {
|
|
2382
2635
|
this.view.startMenuUpdateTimer();
|
|
2383
2636
|
});
|
|
2384
2637
|
/**
|
|
@@ -2387,12 +2640,12 @@ class uo extends G {
|
|
|
2387
2640
|
*
|
|
2388
2641
|
* This function stops the delay timer, and should be used for when the mouse cursor exits the hyperlink toolbar.
|
|
2389
2642
|
*/
|
|
2390
|
-
|
|
2643
|
+
u(this, "stopHideTimer", () => {
|
|
2391
2644
|
this.view.stopMenuUpdateTimer();
|
|
2392
2645
|
});
|
|
2393
|
-
this.plugin = new
|
|
2394
|
-
key:
|
|
2395
|
-
view: (o) => (this.view = new
|
|
2646
|
+
this.plugin = new T({
|
|
2647
|
+
key: Vo,
|
|
2648
|
+
view: (o) => (this.view = new zo(t, o, (r) => {
|
|
2396
2649
|
this.emit("update", r);
|
|
2397
2650
|
}), this.view)
|
|
2398
2651
|
});
|
|
@@ -2401,10 +2654,10 @@ class uo extends G {
|
|
|
2401
2654
|
return this.on("update", t);
|
|
2402
2655
|
}
|
|
2403
2656
|
}
|
|
2404
|
-
class
|
|
2657
|
+
class O extends X {
|
|
2405
2658
|
constructor(t, o) {
|
|
2406
2659
|
super(t, o);
|
|
2407
|
-
|
|
2660
|
+
u(this, "nodes");
|
|
2408
2661
|
const r = t.node();
|
|
2409
2662
|
this.nodes = [], t.doc.nodesBetween(t.pos, o.pos, (i, s, l) => {
|
|
2410
2663
|
if (l !== null && l.eq(r))
|
|
@@ -2412,13 +2665,13 @@ class N extends j {
|
|
|
2412
2665
|
});
|
|
2413
2666
|
}
|
|
2414
2667
|
static create(t, o, r = o) {
|
|
2415
|
-
return new
|
|
2668
|
+
return new O(t.resolve(o), t.resolve(r));
|
|
2416
2669
|
}
|
|
2417
2670
|
content() {
|
|
2418
|
-
return new
|
|
2671
|
+
return new L(P.from(this.nodes), 0, 0);
|
|
2419
2672
|
}
|
|
2420
2673
|
eq(t) {
|
|
2421
|
-
if (!(t instanceof
|
|
2674
|
+
if (!(t instanceof O) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
|
|
2422
2675
|
return !1;
|
|
2423
2676
|
for (let o = 0; o < this.nodes.length; o++)
|
|
2424
2677
|
if (!this.nodes[o].eq(t.nodes[o]))
|
|
@@ -2427,7 +2680,7 @@ class N extends j {
|
|
|
2427
2680
|
}
|
|
2428
2681
|
map(t, o) {
|
|
2429
2682
|
const r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2430
|
-
return i.deleted ?
|
|
2683
|
+
return i.deleted ? X.near(t.resolve(r.pos)) : r.deleted ? X.near(t.resolve(i.pos)) : new O(
|
|
2431
2684
|
t.resolve(r.pos),
|
|
2432
2685
|
t.resolve(i.pos)
|
|
2433
2686
|
);
|
|
@@ -2436,9 +2689,9 @@ class N extends j {
|
|
|
2436
2689
|
return { type: "node", anchor: this.anchor, head: this.head };
|
|
2437
2690
|
}
|
|
2438
2691
|
}
|
|
2439
|
-
const
|
|
2440
|
-
let
|
|
2441
|
-
function
|
|
2692
|
+
const Fo = ve.__serializeForClipboard;
|
|
2693
|
+
let I;
|
|
2694
|
+
function qt(n, e) {
|
|
2442
2695
|
var r;
|
|
2443
2696
|
if (!e.dom.isConnected)
|
|
2444
2697
|
return;
|
|
@@ -2453,15 +2706,15 @@ function Ht(n, e) {
|
|
|
2453
2706
|
return { node: o, id: o.getAttribute("data-id") };
|
|
2454
2707
|
}
|
|
2455
2708
|
}
|
|
2456
|
-
function
|
|
2457
|
-
const t =
|
|
2709
|
+
function Wo(n, e) {
|
|
2710
|
+
const t = qt(n, e);
|
|
2458
2711
|
if (t && t.node.nodeType === 1) {
|
|
2459
2712
|
const o = e.docView, r = o.nearestDesc(t.node, !0);
|
|
2460
2713
|
return !r || r === o ? null : r.posBefore;
|
|
2461
2714
|
}
|
|
2462
2715
|
return null;
|
|
2463
2716
|
}
|
|
2464
|
-
function
|
|
2717
|
+
function $o(n, e) {
|
|
2465
2718
|
let t, o;
|
|
2466
2719
|
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);
|
|
2467
2720
|
if (r && i) {
|
|
@@ -2471,9 +2724,9 @@ function fo(n, e) {
|
|
|
2471
2724
|
t = n.from, o = n.to;
|
|
2472
2725
|
return { from: t, to: o };
|
|
2473
2726
|
}
|
|
2474
|
-
function
|
|
2727
|
+
function pt(n, e, t = e) {
|
|
2475
2728
|
e === t && (t += n.state.doc.resolve(e + 1).node().nodeSize);
|
|
2476
|
-
const o = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, i = (c,
|
|
2729
|
+
const o = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, i = (c, m) => Array.prototype.indexOf.call(c.children, m), s = i(
|
|
2477
2730
|
r,
|
|
2478
2731
|
// Expects from position to be just before the first selected block.
|
|
2479
2732
|
n.domAtPos(e + 1).node.parentElement
|
|
@@ -2484,50 +2737,50 @@ function at(n, e, t = e) {
|
|
|
2484
2737
|
);
|
|
2485
2738
|
for (let c = r.childElementCount - 1; c >= 0; c--)
|
|
2486
2739
|
(c > l || c < s) && o.removeChild(o.children[c]);
|
|
2487
|
-
|
|
2740
|
+
Xt(), I = o;
|
|
2488
2741
|
const d = n.dom.className.split(" ").filter(
|
|
2489
2742
|
(c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
|
|
2490
2743
|
).join(" ");
|
|
2491
|
-
|
|
2744
|
+
I.className = I.className + " " + D.dragPreview + " " + d, document.body.appendChild(I);
|
|
2492
2745
|
}
|
|
2493
|
-
function
|
|
2494
|
-
|
|
2746
|
+
function Xt() {
|
|
2747
|
+
I !== void 0 && (document.body.removeChild(I), I = void 0);
|
|
2495
2748
|
}
|
|
2496
|
-
function
|
|
2749
|
+
function Go(n, e) {
|
|
2497
2750
|
if (!n.dataTransfer)
|
|
2498
2751
|
return;
|
|
2499
2752
|
const t = e.dom.getBoundingClientRect(), o = {
|
|
2500
2753
|
left: t.left + t.width / 2,
|
|
2501
2754
|
// take middle of editor
|
|
2502
2755
|
top: n.clientY
|
|
2503
|
-
}, r =
|
|
2756
|
+
}, r = Wo(o, e);
|
|
2504
2757
|
if (r != null) {
|
|
2505
|
-
const i = e.state.selection, s = e.state.doc, { from: l, to: a } =
|
|
2758
|
+
const i = e.state.selection, s = e.state.doc, { from: l, to: a } = $o(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof O;
|
|
2506
2759
|
d && c ? (e.dispatch(
|
|
2507
|
-
e.state.tr.setSelection(
|
|
2508
|
-
),
|
|
2509
|
-
e.state.tr.setSelection(
|
|
2510
|
-
),
|
|
2511
|
-
const
|
|
2512
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html",
|
|
2760
|
+
e.state.tr.setSelection(O.create(s, l, a))
|
|
2761
|
+
), pt(e, l, a)) : (e.dispatch(
|
|
2762
|
+
e.state.tr.setSelection(mt.create(e.state.doc, r))
|
|
2763
|
+
), pt(e, r));
|
|
2764
|
+
const m = e.state.selection.content(), { dom: h, text: p } = Fo(e, m);
|
|
2765
|
+
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", h.innerHTML), n.dataTransfer.setData("text/plain", p), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(I, 0, 0), e.dragging = { slice: m, move: !0 };
|
|
2513
2766
|
}
|
|
2514
2767
|
}
|
|
2515
|
-
class
|
|
2768
|
+
class jo {
|
|
2516
2769
|
constructor(e, t, o) {
|
|
2517
|
-
|
|
2770
|
+
u(this, "sideMenuState");
|
|
2518
2771
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
2519
2772
|
// When false, the drag handle with be just to the left of the element
|
|
2520
2773
|
// TODO: Is there any case where we want this to be false?
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2774
|
+
u(this, "horizontalPosAnchoredAtRoot");
|
|
2775
|
+
u(this, "horizontalPosAnchor");
|
|
2776
|
+
u(this, "hoveredBlock");
|
|
2524
2777
|
// Used to check if currently dragged content comes from this editor instance.
|
|
2525
|
-
|
|
2526
|
-
|
|
2778
|
+
u(this, "isDragging", !1);
|
|
2779
|
+
u(this, "menuFrozen", !1);
|
|
2527
2780
|
/**
|
|
2528
2781
|
* Sets isDragging when dragging text.
|
|
2529
2782
|
*/
|
|
2530
|
-
|
|
2783
|
+
u(this, "onDragStart", () => {
|
|
2531
2784
|
this.isDragging = !0;
|
|
2532
2785
|
});
|
|
2533
2786
|
/**
|
|
@@ -2535,7 +2788,7 @@ class ko {
|
|
|
2535
2788
|
* we dispatch a fake event, so that we can still drop the content
|
|
2536
2789
|
* when dragging / dropping to the side of the editor
|
|
2537
2790
|
*/
|
|
2538
|
-
|
|
2791
|
+
u(this, "onDrop", (e) => {
|
|
2539
2792
|
if (this.editor._tiptapEditor.commands.blur(), e.synthetic || !this.isDragging)
|
|
2540
2793
|
return;
|
|
2541
2794
|
const t = this.pmView.posAtCoords({
|
|
@@ -2552,7 +2805,7 @@ class ko {
|
|
|
2552
2805
|
* we dispatch a fake event, so that we can still drop the content
|
|
2553
2806
|
* when dragging / dropping to the side of the editor
|
|
2554
2807
|
*/
|
|
2555
|
-
|
|
2808
|
+
u(this, "onDragOver", (e) => {
|
|
2556
2809
|
if (e.synthetic || !this.isDragging)
|
|
2557
2810
|
return;
|
|
2558
2811
|
const t = this.pmView.posAtCoords({
|
|
@@ -2564,12 +2817,12 @@ class ko {
|
|
|
2564
2817
|
o.clientX = r.left + r.width / 2, o.clientY = e.clientY, o.dataTransfer = e.dataTransfer, o.preventDefault = () => e.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
|
|
2565
2818
|
}
|
|
2566
2819
|
});
|
|
2567
|
-
|
|
2820
|
+
u(this, "onKeyDown", (e) => {
|
|
2568
2821
|
var t;
|
|
2569
2822
|
(t = this.sideMenuState) != null && t.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2570
2823
|
});
|
|
2571
|
-
|
|
2572
|
-
var d, c,
|
|
2824
|
+
u(this, "onMouseMove", (e) => {
|
|
2825
|
+
var d, c, m, h, p;
|
|
2573
2826
|
if (this.menuFrozen)
|
|
2574
2827
|
return;
|
|
2575
2828
|
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;
|
|
@@ -2587,24 +2840,24 @@ class ko {
|
|
|
2587
2840
|
left: t.left + t.width / 2,
|
|
2588
2841
|
// take middle of editor
|
|
2589
2842
|
top: e.clientY
|
|
2590
|
-
}, l =
|
|
2843
|
+
}, l = qt(s, this.pmView);
|
|
2591
2844
|
if (!l || !this.editor.isEditable) {
|
|
2592
2845
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2593
2846
|
return;
|
|
2594
2847
|
}
|
|
2595
|
-
if ((
|
|
2848
|
+
if ((m = this.sideMenuState) != null && m.show && ((h = this.hoveredBlock) != null && h.hasAttribute("data-id")) && ((p = this.hoveredBlock) == null ? void 0 : p.getAttribute("data-id")) === l.id)
|
|
2596
2849
|
return;
|
|
2597
2850
|
this.hoveredBlock = l.node;
|
|
2598
2851
|
const a = l.node.firstChild;
|
|
2599
2852
|
if (a && this.editor.isEditable) {
|
|
2600
|
-
const
|
|
2853
|
+
const f = a.getBoundingClientRect();
|
|
2601
2854
|
this.sideMenuState = {
|
|
2602
2855
|
show: !0,
|
|
2603
2856
|
referencePos: new DOMRect(
|
|
2604
|
-
this.horizontalPosAnchoredAtRoot ? this.horizontalPosAnchor :
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2857
|
+
this.horizontalPosAnchoredAtRoot ? this.horizontalPosAnchor : f.x,
|
|
2858
|
+
f.y,
|
|
2859
|
+
f.width,
|
|
2860
|
+
f.height
|
|
2608
2861
|
),
|
|
2609
2862
|
block: this.editor.getBlock(
|
|
2610
2863
|
this.hoveredBlock.getAttribute("data-id")
|
|
@@ -2612,7 +2865,7 @@ class ko {
|
|
|
2612
2865
|
}, this.updateSideMenu(this.sideMenuState);
|
|
2613
2866
|
}
|
|
2614
2867
|
});
|
|
2615
|
-
|
|
2868
|
+
u(this, "onScroll", () => {
|
|
2616
2869
|
var e;
|
|
2617
2870
|
if ((e = this.sideMenuState) != null && e.show) {
|
|
2618
2871
|
const o = this.hoveredBlock.firstChild.getBoundingClientRect();
|
|
@@ -2639,7 +2892,7 @@ class ko {
|
|
|
2639
2892
|
});
|
|
2640
2893
|
if (!o)
|
|
2641
2894
|
return;
|
|
2642
|
-
const r =
|
|
2895
|
+
const r = b(
|
|
2643
2896
|
this.editor._tiptapEditor.state.doc,
|
|
2644
2897
|
o.pos
|
|
2645
2898
|
);
|
|
@@ -2652,7 +2905,7 @@ class ko {
|
|
|
2652
2905
|
} else
|
|
2653
2906
|
this.editor._tiptapEditor.commands.setTextSelection(s);
|
|
2654
2907
|
this.pmView.focus(), this.pmView.dispatch(
|
|
2655
|
-
this.pmView.state.tr.scrollIntoView().setMeta(
|
|
2908
|
+
this.pmView.state.tr.scrollIntoView().setMeta(tt, {
|
|
2656
2909
|
// TODO import suggestion plugin key
|
|
2657
2910
|
activate: !0,
|
|
2658
2911
|
type: "drag"
|
|
@@ -2660,42 +2913,42 @@ class ko {
|
|
|
2660
2913
|
);
|
|
2661
2914
|
}
|
|
2662
2915
|
}
|
|
2663
|
-
const
|
|
2664
|
-
class
|
|
2916
|
+
const qo = new B("SideMenuPlugin");
|
|
2917
|
+
class Xo extends U {
|
|
2665
2918
|
constructor(t) {
|
|
2666
2919
|
super();
|
|
2667
|
-
|
|
2668
|
-
|
|
2920
|
+
u(this, "sideMenuView");
|
|
2921
|
+
u(this, "plugin");
|
|
2669
2922
|
/**
|
|
2670
2923
|
* If the block is empty, opens the slash menu. If the block has content,
|
|
2671
2924
|
* creates a new block below and opens the slash menu in it.
|
|
2672
2925
|
*/
|
|
2673
|
-
|
|
2926
|
+
u(this, "addBlock", () => this.sideMenuView.addBlock());
|
|
2674
2927
|
/**
|
|
2675
2928
|
* Handles drag & drop events for blocks.
|
|
2676
2929
|
*/
|
|
2677
|
-
|
|
2678
|
-
this.sideMenuView.isDragging = !0,
|
|
2930
|
+
u(this, "blockDragStart", (t) => {
|
|
2931
|
+
this.sideMenuView.isDragging = !0, Go(t, this.editor.prosemirrorView);
|
|
2679
2932
|
});
|
|
2680
2933
|
/**
|
|
2681
2934
|
* Handles drag & drop events for blocks.
|
|
2682
2935
|
*/
|
|
2683
|
-
|
|
2936
|
+
u(this, "blockDragEnd", () => Xt());
|
|
2684
2937
|
/**
|
|
2685
2938
|
* Freezes the side menu. When frozen, the side menu will stay
|
|
2686
2939
|
* attached to the same block regardless of which block is hovered by the
|
|
2687
2940
|
* mouse cursor.
|
|
2688
2941
|
*/
|
|
2689
|
-
|
|
2942
|
+
u(this, "freezeMenu", () => this.sideMenuView.menuFrozen = !0);
|
|
2690
2943
|
/**
|
|
2691
2944
|
* Unfreezes the side menu. When frozen, the side menu will stay
|
|
2692
2945
|
* attached to the same block regardless of which block is hovered by the
|
|
2693
2946
|
* mouse cursor.
|
|
2694
2947
|
*/
|
|
2695
|
-
|
|
2696
|
-
this.editor = t, this.plugin = new
|
|
2697
|
-
key:
|
|
2698
|
-
view: (o) => (this.sideMenuView = new
|
|
2948
|
+
u(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2949
|
+
this.editor = t, this.plugin = new T({
|
|
2950
|
+
key: qo,
|
|
2951
|
+
view: (o) => (this.sideMenuView = new jo(
|
|
2699
2952
|
t,
|
|
2700
2953
|
o,
|
|
2701
2954
|
(r) => {
|
|
@@ -2708,69 +2961,100 @@ class bo extends G {
|
|
|
2708
2961
|
return this.on("update", t);
|
|
2709
2962
|
}
|
|
2710
2963
|
}
|
|
2711
|
-
function
|
|
2964
|
+
function H(n, e) {
|
|
2712
2965
|
const t = n.getTextCursorPosition().block;
|
|
2966
|
+
if (t.content === void 0)
|
|
2967
|
+
throw new Error(
|
|
2968
|
+
"Slash Menu open in a block that doesn't contain inline content."
|
|
2969
|
+
);
|
|
2713
2970
|
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));
|
|
2714
2971
|
}
|
|
2715
|
-
const
|
|
2972
|
+
const Ko = (n = jt) => {
|
|
2716
2973
|
var t, o, r;
|
|
2717
2974
|
const e = [];
|
|
2718
|
-
return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes(
|
|
2975
|
+
return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes(1) && e.push({
|
|
2719
2976
|
name: "Heading",
|
|
2720
2977
|
aliases: ["h", "heading1", "h1"],
|
|
2721
|
-
execute: (i) =>
|
|
2978
|
+
execute: (i) => H(i, {
|
|
2722
2979
|
type: "heading",
|
|
2723
|
-
props: { level:
|
|
2980
|
+
props: { level: 1 }
|
|
2724
2981
|
})
|
|
2725
|
-
}), (o = n.heading.propSchema.level.values) != null && o.includes(
|
|
2982
|
+
}), (o = n.heading.propSchema.level.values) != null && o.includes(2) && e.push({
|
|
2726
2983
|
name: "Heading 2",
|
|
2727
2984
|
aliases: ["h2", "heading2", "subheading"],
|
|
2728
|
-
execute: (i) =>
|
|
2985
|
+
execute: (i) => H(i, {
|
|
2729
2986
|
type: "heading",
|
|
2730
|
-
props: { level:
|
|
2987
|
+
props: { level: 2 }
|
|
2731
2988
|
})
|
|
2732
|
-
}), (r = n.heading.propSchema.level.values) != null && r.includes(
|
|
2989
|
+
}), (r = n.heading.propSchema.level.values) != null && r.includes(3) && e.push({
|
|
2733
2990
|
name: "Heading 3",
|
|
2734
2991
|
aliases: ["h3", "heading3", "subheading"],
|
|
2735
|
-
execute: (i) =>
|
|
2992
|
+
execute: (i) => H(i, {
|
|
2736
2993
|
type: "heading",
|
|
2737
|
-
props: { level:
|
|
2994
|
+
props: { level: 3 }
|
|
2738
2995
|
})
|
|
2739
2996
|
})), "bulletListItem" in n && e.push({
|
|
2740
2997
|
name: "Bullet List",
|
|
2741
2998
|
aliases: ["ul", "list", "bulletlist", "bullet list"],
|
|
2742
|
-
execute: (i) =>
|
|
2999
|
+
execute: (i) => H(i, {
|
|
2743
3000
|
type: "bulletListItem"
|
|
2744
3001
|
})
|
|
2745
3002
|
}), "numberedListItem" in n && e.push({
|
|
2746
3003
|
name: "Numbered List",
|
|
2747
3004
|
aliases: ["li", "list", "numberedlist", "numbered list"],
|
|
2748
|
-
execute: (i) =>
|
|
3005
|
+
execute: (i) => H(i, {
|
|
2749
3006
|
type: "numberedListItem"
|
|
2750
3007
|
})
|
|
2751
3008
|
}), "paragraph" in n && e.push({
|
|
2752
3009
|
name: "Paragraph",
|
|
2753
3010
|
aliases: ["p"],
|
|
2754
|
-
execute: (i) =>
|
|
3011
|
+
execute: (i) => H(i, {
|
|
2755
3012
|
type: "paragraph"
|
|
2756
3013
|
})
|
|
3014
|
+
}), "image" in n && e.push({
|
|
3015
|
+
name: "Image",
|
|
3016
|
+
aliases: [
|
|
3017
|
+
"image",
|
|
3018
|
+
"imageUpload",
|
|
3019
|
+
"upload",
|
|
3020
|
+
"img",
|
|
3021
|
+
"picture",
|
|
3022
|
+
"media",
|
|
3023
|
+
"url",
|
|
3024
|
+
"drive",
|
|
3025
|
+
"dropbox"
|
|
3026
|
+
],
|
|
3027
|
+
execute: (i) => {
|
|
3028
|
+
H(i, {
|
|
3029
|
+
type: "image"
|
|
3030
|
+
}), i.setTextCursorPosition(
|
|
3031
|
+
i.getTextCursorPosition().nextBlock,
|
|
3032
|
+
"start"
|
|
3033
|
+
), i._tiptapEditor.view.dispatch(
|
|
3034
|
+
i._tiptapEditor.state.tr.setMeta(z, {
|
|
3035
|
+
block: i.getTextCursorPosition().prevBlock
|
|
3036
|
+
})
|
|
3037
|
+
);
|
|
3038
|
+
}
|
|
2757
3039
|
}), e;
|
|
2758
|
-
},
|
|
3040
|
+
}, Yo = {
|
|
2759
3041
|
enableInputRules: !0,
|
|
2760
3042
|
enablePasteRules: !0,
|
|
2761
3043
|
enableCoreExtensions: !1
|
|
2762
3044
|
};
|
|
2763
|
-
class
|
|
3045
|
+
class xn {
|
|
2764
3046
|
constructor(e = {}) {
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
3047
|
+
u(this, "_tiptapEditor");
|
|
3048
|
+
u(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
3049
|
+
u(this, "schema");
|
|
3050
|
+
u(this, "ready", !1);
|
|
3051
|
+
u(this, "sideMenu");
|
|
3052
|
+
u(this, "formattingToolbar");
|
|
3053
|
+
u(this, "slashMenu");
|
|
3054
|
+
u(this, "hyperlinkToolbar");
|
|
3055
|
+
u(this, "imageToolbar");
|
|
3056
|
+
u(this, "uploadFile");
|
|
3057
|
+
var l, a, d, c, m;
|
|
2774
3058
|
this.options = e;
|
|
2775
3059
|
const t = {
|
|
2776
3060
|
defaultStyles: !0,
|
|
@@ -2779,73 +3063,76 @@ class Qo {
|
|
|
2779
3063
|
// If BSchema is not specified, then options.blockSchema should also not
|
|
2780
3064
|
// be defined. Unfortunately, trying to implement these constraints seems
|
|
2781
3065
|
// to be a huge pain, hence the `as any` casts.
|
|
2782
|
-
blockSchema: e.blockSchema ||
|
|
3066
|
+
blockSchema: e.blockSchema || jt,
|
|
2783
3067
|
...e
|
|
2784
3068
|
};
|
|
2785
|
-
this.sideMenu = new
|
|
3069
|
+
this.sideMenu = new Xo(this), this.formattingToolbar = new Ro(this), this.slashMenu = new Je(
|
|
2786
3070
|
this,
|
|
2787
|
-
t.slashMenuItems ||
|
|
2788
|
-
), this.hyperlinkToolbar = new
|
|
2789
|
-
const o =
|
|
3071
|
+
t.slashMenuItems || Ko(t.blockSchema)
|
|
3072
|
+
), this.hyperlinkToolbar = new Uo(this), this.imageToolbar = new Ho(this);
|
|
3073
|
+
const o = ro({
|
|
2790
3074
|
editor: this,
|
|
2791
3075
|
domAttributes: t.domAttributes || {},
|
|
2792
3076
|
blockSchema: t.blockSchema,
|
|
2793
3077
|
collaboration: t.collaboration
|
|
2794
|
-
}), r =
|
|
3078
|
+
}), r = A.create({
|
|
2795
3079
|
name: "BlockNoteUIExtension",
|
|
2796
3080
|
addProseMirrorPlugins: () => [
|
|
2797
3081
|
this.sideMenu.plugin,
|
|
2798
3082
|
this.formattingToolbar.plugin,
|
|
2799
3083
|
this.slashMenu.plugin,
|
|
2800
|
-
this.hyperlinkToolbar.plugin
|
|
3084
|
+
this.hyperlinkToolbar.plugin,
|
|
3085
|
+
this.imageToolbar.plugin
|
|
2801
3086
|
]
|
|
2802
3087
|
});
|
|
2803
|
-
o.push(r), this.schema = t.blockSchema;
|
|
3088
|
+
o.push(r), this.schema = t.blockSchema, this.uploadFile = t.uploadFile;
|
|
2804
3089
|
const i = t.initialContent || (e.collaboration ? void 0 : [
|
|
2805
3090
|
{
|
|
2806
3091
|
type: "paragraph",
|
|
2807
|
-
id:
|
|
3092
|
+
id: j.options.generateID()
|
|
2808
3093
|
}
|
|
2809
3094
|
]), s = {
|
|
2810
|
-
...
|
|
3095
|
+
...Yo,
|
|
2811
3096
|
...t._tiptapOptions,
|
|
2812
|
-
|
|
2813
|
-
var u;
|
|
2814
|
-
(u = t.onEditorReady) == null || u.call(t, this), this.ready = !0;
|
|
2815
|
-
},
|
|
2816
|
-
onBeforeCreate(u) {
|
|
3097
|
+
onBeforeCreate(h) {
|
|
2817
3098
|
if (!i)
|
|
2818
3099
|
return;
|
|
2819
|
-
const
|
|
3100
|
+
const p = h.editor.schema, f = p.node(
|
|
2820
3101
|
"doc",
|
|
2821
3102
|
void 0,
|
|
2822
|
-
|
|
3103
|
+
p.node("blockGroup", void 0, [
|
|
3104
|
+
V({ id: "initialBlock", type: "paragraph" }, p)
|
|
3105
|
+
])
|
|
2823
3106
|
);
|
|
2824
|
-
|
|
3107
|
+
h.editor.options.content = f.toJSON();
|
|
3108
|
+
},
|
|
3109
|
+
onCreate: () => {
|
|
3110
|
+
var h;
|
|
3111
|
+
i !== void 0 && this.replaceBlocks(this.topLevelBlocks, i), (h = t.onEditorReady) == null || h.call(t, this), this.ready = !0;
|
|
2825
3112
|
},
|
|
2826
3113
|
onUpdate: () => {
|
|
2827
|
-
var
|
|
2828
|
-
this.ready && ((
|
|
3114
|
+
var h;
|
|
3115
|
+
this.ready && ((h = t.onEditorContentChange) == null || h.call(t, this));
|
|
2829
3116
|
},
|
|
2830
3117
|
onSelectionUpdate: () => {
|
|
2831
|
-
var
|
|
2832
|
-
this.ready && ((
|
|
3118
|
+
var h;
|
|
3119
|
+
this.ready && ((h = t.onTextCursorPositionChange) == null || h.call(t, this));
|
|
2833
3120
|
},
|
|
2834
3121
|
editable: e.editable === void 0 ? !0 : e.editable,
|
|
2835
3122
|
extensions: t.enableBlockNoteExtensions === !1 ? (l = t._tiptapOptions) == null ? void 0 : l.extensions : [...((a = t._tiptapOptions) == null ? void 0 : a.extensions) || [], ...o],
|
|
2836
3123
|
editorProps: {
|
|
2837
3124
|
attributes: {
|
|
2838
3125
|
...(d = t.domAttributes) == null ? void 0 : d.editor,
|
|
2839
|
-
class:
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
t.defaultStyles ?
|
|
2843
|
-
((
|
|
3126
|
+
class: S(
|
|
3127
|
+
D.bnEditor,
|
|
3128
|
+
D.bnRoot,
|
|
3129
|
+
t.defaultStyles ? D.defaultStyles : "",
|
|
3130
|
+
((m = (c = t.domAttributes) == null ? void 0 : c.editor) == null ? void 0 : m.class) || ""
|
|
2844
3131
|
)
|
|
2845
3132
|
}
|
|
2846
3133
|
}
|
|
2847
3134
|
};
|
|
2848
|
-
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new
|
|
3135
|
+
t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new re(s);
|
|
2849
3136
|
}
|
|
2850
3137
|
get prosemirrorView() {
|
|
2851
3138
|
return this._tiptapEditor.view;
|
|
@@ -2865,7 +3152,7 @@ class Qo {
|
|
|
2865
3152
|
*/
|
|
2866
3153
|
get topLevelBlocks() {
|
|
2867
3154
|
const e = [];
|
|
2868
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(
|
|
3155
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(x(t, this.schema, this.blockCache)), !1)), e;
|
|
2869
3156
|
}
|
|
2870
3157
|
/**
|
|
2871
3158
|
* Gets a snapshot of an existing block from the editor.
|
|
@@ -2875,7 +3162,7 @@ class Qo {
|
|
|
2875
3162
|
getBlock(e) {
|
|
2876
3163
|
const t = typeof e == "string" ? e : e.id;
|
|
2877
3164
|
let o;
|
|
2878
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (o =
|
|
3165
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (o = x(r, this.schema, this.blockCache), !1)), o;
|
|
2879
3166
|
}
|
|
2880
3167
|
/**
|
|
2881
3168
|
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
@@ -2916,7 +3203,7 @@ class Qo {
|
|
|
2916
3203
|
* @returns A snapshot of the current text cursor position.
|
|
2917
3204
|
*/
|
|
2918
3205
|
getTextCursorPosition() {
|
|
2919
|
-
const { node: e, depth: t, startPos: o, endPos: r } =
|
|
3206
|
+
const { node: e, depth: t, startPos: o, endPos: r } = b(
|
|
2920
3207
|
this._tiptapEditor.state.doc,
|
|
2921
3208
|
this._tiptapEditor.state.selection.from
|
|
2922
3209
|
), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), s = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
|
|
@@ -2924,9 +3211,9 @@ class Qo {
|
|
|
2924
3211
|
i > 0 && (l = this._tiptapEditor.state.doc.resolve(o - 2).node());
|
|
2925
3212
|
let a;
|
|
2926
3213
|
return i < s - 1 && (a = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
|
|
2927
|
-
block:
|
|
2928
|
-
prevBlock: l === void 0 ? void 0 :
|
|
2929
|
-
nextBlock: a === void 0 ? void 0 :
|
|
3214
|
+
block: x(e, this.schema, this.blockCache),
|
|
3215
|
+
prevBlock: l === void 0 ? void 0 : x(l, this.schema, this.blockCache),
|
|
3216
|
+
nextBlock: a === void 0 ? void 0 : x(a, this.schema, this.blockCache)
|
|
2930
3217
|
};
|
|
2931
3218
|
}
|
|
2932
3219
|
/**
|
|
@@ -2936,10 +3223,14 @@ class Qo {
|
|
|
2936
3223
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
2937
3224
|
*/
|
|
2938
3225
|
setTextCursorPosition(e, t = "start") {
|
|
2939
|
-
const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } =
|
|
3226
|
+
const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } = et(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = b(
|
|
2940
3227
|
this._tiptapEditor.state.doc,
|
|
2941
3228
|
r + 2
|
|
2942
3229
|
);
|
|
3230
|
+
if (s.type.spec.content === "") {
|
|
3231
|
+
this._tiptapEditor.commands.setNodeSelection(i);
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
2943
3234
|
t === "start" ? this._tiptapEditor.commands.setTextSelection(i + 1) : this._tiptapEditor.commands.setTextSelection(
|
|
2944
3235
|
i + s.nodeSize - 1
|
|
2945
3236
|
);
|
|
@@ -2948,11 +3239,11 @@ class Qo {
|
|
|
2948
3239
|
* Gets a snapshot of the current selection.
|
|
2949
3240
|
*/
|
|
2950
3241
|
getSelection() {
|
|
2951
|
-
if (this._tiptapEditor.state.selection.from === this._tiptapEditor.state.selection.to)
|
|
3242
|
+
if (this._tiptapEditor.state.selection.from === this._tiptapEditor.state.selection.to || "node" in this._tiptapEditor.state.selection)
|
|
2952
3243
|
return;
|
|
2953
3244
|
const e = [];
|
|
2954
3245
|
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(
|
|
2955
|
-
|
|
3246
|
+
x(
|
|
2956
3247
|
this._tiptapEditor.state.doc.resolve(o).node(),
|
|
2957
3248
|
this.schema,
|
|
2958
3249
|
this.blockCache
|
|
@@ -2982,7 +3273,7 @@ class Qo {
|
|
|
2982
3273
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
2983
3274
|
*/
|
|
2984
3275
|
insertBlocks(e, t, o = "before") {
|
|
2985
|
-
|
|
3276
|
+
Ut(e, t, o, this._tiptapEditor);
|
|
2986
3277
|
}
|
|
2987
3278
|
/**
|
|
2988
3279
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -2992,14 +3283,14 @@ class Qo {
|
|
|
2992
3283
|
* @param update A partial block which defines how the existing block should be changed.
|
|
2993
3284
|
*/
|
|
2994
3285
|
updateBlock(e, t) {
|
|
2995
|
-
|
|
3286
|
+
io(e, t, this._tiptapEditor);
|
|
2996
3287
|
}
|
|
2997
3288
|
/**
|
|
2998
3289
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
2999
3290
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
3000
3291
|
*/
|
|
3001
3292
|
removeBlocks(e) {
|
|
3002
|
-
|
|
3293
|
+
Ft(e, this._tiptapEditor);
|
|
3003
3294
|
}
|
|
3004
3295
|
/**
|
|
3005
3296
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -3009,7 +3300,7 @@ class Qo {
|
|
|
3009
3300
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
3010
3301
|
*/
|
|
3011
3302
|
replaceBlocks(e, t) {
|
|
3012
|
-
|
|
3303
|
+
so(e, t, this._tiptapEditor);
|
|
3013
3304
|
}
|
|
3014
3305
|
/**
|
|
3015
3306
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
@@ -3101,7 +3392,7 @@ class Qo {
|
|
|
3101
3392
|
* Checks if the block containing the text cursor can be nested.
|
|
3102
3393
|
*/
|
|
3103
3394
|
canNestBlock() {
|
|
3104
|
-
const { startPos: e, depth: t } =
|
|
3395
|
+
const { startPos: e, depth: t } = b(
|
|
3105
3396
|
this._tiptapEditor.state.doc,
|
|
3106
3397
|
this._tiptapEditor.state.selection.from
|
|
3107
3398
|
);
|
|
@@ -3117,7 +3408,7 @@ class Qo {
|
|
|
3117
3408
|
* Checks if the block containing the text cursor is nested.
|
|
3118
3409
|
*/
|
|
3119
3410
|
canUnnestBlock() {
|
|
3120
|
-
const { depth: e } =
|
|
3411
|
+
const { depth: e } = b(
|
|
3121
3412
|
this._tiptapEditor.state.doc,
|
|
3122
3413
|
this._tiptapEditor.state.selection.from
|
|
3123
3414
|
);
|
|
@@ -3136,7 +3427,7 @@ class Qo {
|
|
|
3136
3427
|
* @returns The blocks, serialized as an HTML string.
|
|
3137
3428
|
*/
|
|
3138
3429
|
async blocksToHTML(e) {
|
|
3139
|
-
return
|
|
3430
|
+
return Wt(e, this._tiptapEditor.schema);
|
|
3140
3431
|
}
|
|
3141
3432
|
/**
|
|
3142
3433
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
@@ -3146,7 +3437,7 @@ class Qo {
|
|
|
3146
3437
|
* @returns The blocks parsed from the HTML string.
|
|
3147
3438
|
*/
|
|
3148
3439
|
async HTMLToBlocks(e) {
|
|
3149
|
-
return
|
|
3440
|
+
return $t(e, this.schema, this._tiptapEditor.schema);
|
|
3150
3441
|
}
|
|
3151
3442
|
/**
|
|
3152
3443
|
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
@@ -3155,7 +3446,7 @@ class Qo {
|
|
|
3155
3446
|
* @returns The blocks, serialized as a Markdown string.
|
|
3156
3447
|
*/
|
|
3157
3448
|
async blocksToMarkdown(e) {
|
|
3158
|
-
return
|
|
3449
|
+
return co(e, this._tiptapEditor.schema);
|
|
3159
3450
|
}
|
|
3160
3451
|
/**
|
|
3161
3452
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -3165,7 +3456,7 @@ class Qo {
|
|
|
3165
3456
|
* @returns The blocks parsed from the Markdown string.
|
|
3166
3457
|
*/
|
|
3167
3458
|
async markdownToBlocks(e) {
|
|
3168
|
-
return
|
|
3459
|
+
return po(e, this.schema, this._tiptapEditor.schema);
|
|
3169
3460
|
}
|
|
3170
3461
|
/**
|
|
3171
3462
|
* Updates the user info for the current user that's shown to other collaborators.
|
|
@@ -3178,34 +3469,48 @@ class Qo {
|
|
|
3178
3469
|
this._tiptapEditor.commands.updateUser(e);
|
|
3179
3470
|
}
|
|
3180
3471
|
}
|
|
3472
|
+
const In = async (n) => {
|
|
3473
|
+
const e = new FormData();
|
|
3474
|
+
return e.append("file", n), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
|
|
3475
|
+
method: "POST",
|
|
3476
|
+
body: e
|
|
3477
|
+
})).json()).data.url.replace(
|
|
3478
|
+
"tmpfiles.org/",
|
|
3479
|
+
"tmpfiles.org/dl/"
|
|
3480
|
+
);
|
|
3481
|
+
};
|
|
3181
3482
|
export {
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3483
|
+
xn as BlockNoteEditor,
|
|
3484
|
+
qe as CustomBlockSerializerExtension,
|
|
3485
|
+
Ro as FormattingToolbarProsemirrorPlugin,
|
|
3486
|
+
Do as FormattingToolbarView,
|
|
3487
|
+
Uo as HyperlinkToolbarProsemirrorPlugin,
|
|
3488
|
+
Ho as ImageToolbarProsemirrorPlugin,
|
|
3489
|
+
_o as ImageToolbarView,
|
|
3490
|
+
Xo as SideMenuProsemirrorPlugin,
|
|
3491
|
+
jo as SideMenuView,
|
|
3492
|
+
Je as SlashMenuProsemirrorPlugin,
|
|
3493
|
+
Pe as UnreachableCaseError,
|
|
3494
|
+
Bn as blockStyles,
|
|
3495
|
+
dt as camelToDataKebab,
|
|
3496
|
+
go as createBlockSpec,
|
|
3497
|
+
F as createTipTapBlock,
|
|
3498
|
+
jt as defaultBlockSchema,
|
|
3499
|
+
C as defaultProps,
|
|
3500
|
+
Mn as formatKeyboardShortcut,
|
|
3501
|
+
Oo as formattingToolbarPluginKey,
|
|
3502
|
+
ro as getBlockNoteExtensions,
|
|
3503
|
+
Ko as getDefaultSlashMenuItems,
|
|
3504
|
+
Vo as hyperlinkToolbarPluginKey,
|
|
3505
|
+
z as imageToolbarPluginKey,
|
|
3506
|
+
Ne as isAppleOS,
|
|
3507
|
+
S as mergeCSSClasses,
|
|
3508
|
+
mo as parse,
|
|
3509
|
+
ho as propsToAttributes,
|
|
3510
|
+
fo as render,
|
|
3511
|
+
Ye as setupSuggestionsMenu,
|
|
3512
|
+
qo as sideMenuPluginKey,
|
|
3513
|
+
tt as slashMenuPluginKey,
|
|
3514
|
+
In as uploadToTmpFilesDotOrg_DEV_ONLY
|
|
3210
3515
|
};
|
|
3211
3516
|
//# sourceMappingURL=blocknote.js.map
|