@blocknote/core 0.47.3 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-B6RhuQ3V.js +27 -0
- package/dist/BlockNoteExtension-B6RhuQ3V.js.map +1 -0
- package/dist/BlockNoteExtension-ab0REuob.cjs +2 -0
- package/dist/BlockNoteExtension-ab0REuob.cjs.map +1 -0
- package/dist/EventEmitter-CuPnGDYt.js +22 -0
- package/dist/EventEmitter-CuPnGDYt.js.map +1 -0
- package/dist/EventEmitter-DHdSnYCD.cjs +2 -0
- package/dist/EventEmitter-DHdSnYCD.cjs.map +1 -0
- package/dist/ShowSelection-BsHFfdMi.js +29 -0
- package/dist/ShowSelection-BsHFfdMi.js.map +1 -0
- package/dist/ShowSelection-DhXglbt8.cjs +2 -0
- package/dist/ShowSelection-DhXglbt8.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -5
- package/dist/blocknote.js +7 -4256
- package/dist/blocks-BEvIOzln.cjs +11 -0
- package/dist/blocks-BEvIOzln.cjs.map +1 -0
- package/dist/blocks-DYl7UTS4.js +3313 -0
- package/dist/blocks-DYl7UTS4.js.map +1 -0
- package/dist/blocks.cjs +1 -2
- package/dist/blocks.js +2 -74
- package/dist/comments.cjs +2 -2
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +604 -900
- package/dist/comments.js.map +1 -1
- package/dist/en-C4ykW581.cjs +2 -0
- package/dist/en-C4ykW581.cjs.map +1 -0
- package/dist/en-QsSI16s5.js +453 -0
- package/dist/en-QsSI16s5.js.map +1 -0
- package/dist/extensions-3nf9PPhA.js +1495 -0
- package/dist/extensions-3nf9PPhA.js.map +1 -0
- package/dist/extensions-D9y6evn6.cjs +2 -0
- package/dist/extensions-D9y6evn6.cjs.map +1 -0
- package/dist/extensions.cjs +1 -2
- package/dist/extensions.js +4 -36
- package/dist/locales.cjs +2 -2
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +10049 -9111
- package/dist/locales.js.map +1 -1
- package/dist/src-BKJH7Jla.cjs +5 -0
- package/dist/src-BKJH7Jla.cjs.map +1 -0
- package/dist/src-Hjv1f5lc.js +2386 -0
- package/dist/src-Hjv1f5lc.js.map +1 -0
- package/dist/style.css +2 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +2 -2
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +20 -38
- package/dist/yjs.js.map +1 -1
- package/package.json +8 -8
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +15 -1
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +5 -0
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +1095 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +661 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +128 -11
- package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +17 -23
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +346 -0
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +143 -71
- package/src/editor/Block.css +5 -8
- package/src/editor/BlockNoteEditor.ts +38 -1
- package/src/editor/editor.css +0 -20
- package/src/editor/managers/ExtensionManager/extensions.ts +12 -1
- package/src/editor/performance.test.ts +134 -0
- package/src/extensions/Collaboration/ForkYDoc.test.ts +115 -103
- package/src/extensions/Placeholder/Placeholder.ts +1 -1
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +86 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +33 -49
- package/src/extensions/SideMenu/SideMenu.ts +14 -8
- package/src/extensions/TableHandles/TableHandles.ts +14 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +57 -17
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +9 -8
- package/src/index.ts +1 -1
- package/src/schema/blocks/createSpec.ts +6 -2
- package/src/schema/inlineContent/types.ts +0 -1
- package/src/vite-env.d.ts +6 -0
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +14 -1
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +1 -0
- package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +13 -0
- package/types/src/editor/performance.test.d.ts +1 -0
- package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -0
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs +0 -2
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +0 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js +0 -25
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +0 -1
- package/dist/BlockNoteSchema-CCs_V3lo.cjs +0 -2
- package/dist/BlockNoteSchema-CCs_V3lo.cjs.map +0 -1
- package/dist/BlockNoteSchema-ooiKsd5B.js +0 -270
- package/dist/BlockNoteSchema-ooiKsd5B.js.map +0 -1
- package/dist/EventEmitter-CLwfmbqG.cjs +0 -2
- package/dist/EventEmitter-CLwfmbqG.cjs.map +0 -1
- package/dist/EventEmitter-CjSwpTbz.js +0 -27
- package/dist/EventEmitter-CjSwpTbz.js.map +0 -1
- package/dist/ShowSelection-B0ch3unP.js +0 -51
- package/dist/ShowSelection-B0ch3unP.js.map +0 -1
- package/dist/ShowSelection-BxnbRvy4.cjs +0 -2
- package/dist/ShowSelection-BxnbRvy4.cjs.map +0 -1
- package/dist/TrailingNode-GzE59m_7.js +0 -2288
- package/dist/TrailingNode-GzE59m_7.js.map +0 -1
- package/dist/TrailingNode-n0WdMPUl.cjs +0 -2
- package/dist/TrailingNode-n0WdMPUl.cjs.map +0 -1
- package/dist/blockToNode-BNoNIXU7.js +0 -1140
- package/dist/blockToNode-BNoNIXU7.js.map +0 -1
- package/dist/blockToNode-CumVjgem.cjs +0 -7
- package/dist/blockToNode-CumVjgem.cjs.map +0 -1
- package/dist/blocknote.cjs.map +0 -1
- package/dist/blocknote.js.map +0 -1
- package/dist/blocks.cjs.map +0 -1
- package/dist/blocks.js.map +0 -1
- package/dist/defaultBlocks-Dg9kQWXm.cjs +0 -6
- package/dist/defaultBlocks-Dg9kQWXm.cjs.map +0 -1
- package/dist/defaultBlocks-ZzGbYgQn.js +0 -3284
- package/dist/defaultBlocks-ZzGbYgQn.js.map +0 -1
- package/dist/en-Cl87Uuyf.cjs +0 -2
- package/dist/en-Cl87Uuyf.cjs.map +0 -1
- package/dist/en-njEqD7AG.js +0 -408
- package/dist/en-njEqD7AG.js.map +0 -1
- package/dist/extensions.cjs.map +0 -1
- package/dist/extensions.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,3284 +0,0 @@
|
|
|
1
|
-
var Ve = Object.defineProperty;
|
|
2
|
-
var We = (e, t, n) => t in e ? Ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
-
var w = (e, t, n) => We(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { TableMap as Ce, goToNextCell as oe, columnResizing as Re, tableEditing as Fe, CellSelection as ke, TableView as $e } from "prosemirror-tables";
|
|
5
|
-
import { Node as P, Mark as Ue, Extension as qe, callOrReturn as je, getExtensionField as Ge, mergeAttributes as Z, findParentNode as ze } from "@tiptap/core";
|
|
6
|
-
import { TextSelection as ye, Plugin as Ze, PluginKey as Xe } from "prosemirror-state";
|
|
7
|
-
import { DecorationSet as re, Decoration as ae } from "prosemirror-view";
|
|
8
|
-
import { ReplaceStep as Ke, Mapping as Qe } from "prosemirror-transform";
|
|
9
|
-
import { ySyncPluginKey as se, absolutePositionToRelativePosition as Je, relativePositionToAbsolutePosition as Ye } from "y-prosemirror";
|
|
10
|
-
import { c as y, a as ve } from "./BlockNoteExtension-C2X7LW-V.js";
|
|
11
|
-
import { b as X, v as et, g as O, a as Ee, i as ie, t as tt, U as nt, q as ot, A as G, r as rt, w as Se, J as at } from "./blockToNode-BNoNIXU7.js";
|
|
12
|
-
import st from "@tiptap/extension-bold";
|
|
13
|
-
import it from "@tiptap/extension-code";
|
|
14
|
-
import ct from "@tiptap/extension-italic";
|
|
15
|
-
import lt from "@tiptap/extension-strike";
|
|
16
|
-
import dt from "@tiptap/extension-underline";
|
|
17
|
-
import { DOMParser as xe, Fragment as ut, DOMSerializer as ce } from "@tiptap/pm/model";
|
|
18
|
-
import { createHighlightPlugin as pt } from "prosemirror-highlight";
|
|
19
|
-
import { createParser as ft } from "prosemirror-highlight/shiki";
|
|
20
|
-
import { Slice as Me, Fragment as _, DOMParser as K } from "prosemirror-model";
|
|
21
|
-
import { Plugin as mt, PluginKey as ht } from "@tiptap/pm/state";
|
|
22
|
-
import { DecorationSet as le, Decoration as gt } from "@tiptap/pm/view";
|
|
23
|
-
const bt = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
|
|
24
|
-
function L(e, t = "Ctrl") {
|
|
25
|
-
return bt() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
|
|
26
|
-
}
|
|
27
|
-
function D(...e) {
|
|
28
|
-
return [
|
|
29
|
-
// Converts to & from set to remove duplicates.
|
|
30
|
-
...new Set(
|
|
31
|
-
e.filter((t) => t).join(" ").split(" ")
|
|
32
|
-
)
|
|
33
|
-
].join(" ");
|
|
34
|
-
}
|
|
35
|
-
const po = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
36
|
-
function Ct(e, t, n, o) {
|
|
37
|
-
const r = document.createElement("div");
|
|
38
|
-
r.className = D(
|
|
39
|
-
"bn-block-content",
|
|
40
|
-
n.class
|
|
41
|
-
), r.setAttribute("data-content-type", e);
|
|
42
|
-
for (const [s, i] of Object.entries(n))
|
|
43
|
-
s !== "class" && r.setAttribute(s, i);
|
|
44
|
-
const a = document.createElement(t);
|
|
45
|
-
a.className = D(
|
|
46
|
-
"bn-inline-content",
|
|
47
|
-
o.class
|
|
48
|
-
);
|
|
49
|
-
for (const [s, i] of Object.entries(
|
|
50
|
-
o
|
|
51
|
-
))
|
|
52
|
-
s !== "class" && a.setAttribute(s, i);
|
|
53
|
-
return r.appendChild(a), {
|
|
54
|
-
dom: r,
|
|
55
|
-
contentDOM: a
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const de = (e, t) => {
|
|
59
|
-
let n = X(e, t.pmSchema);
|
|
60
|
-
n.type.name === "blockContainer" && (n = n.firstChild);
|
|
61
|
-
const o = t.pmSchema.nodes[n.type.name].spec.toDOM;
|
|
62
|
-
if (o === void 0)
|
|
63
|
-
throw new Error(
|
|
64
|
-
"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
|
|
65
|
-
);
|
|
66
|
-
const r = o(n);
|
|
67
|
-
if (typeof r != "object" || !("dom" in r))
|
|
68
|
-
throw new Error(
|
|
69
|
-
"Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property."
|
|
70
|
-
);
|
|
71
|
-
return r;
|
|
72
|
-
};
|
|
73
|
-
function we(e, t = "<br>") {
|
|
74
|
-
const n = e.querySelectorAll("p");
|
|
75
|
-
if (n.length > 1) {
|
|
76
|
-
const o = n[0];
|
|
77
|
-
for (let r = 1; r < n.length; r++) {
|
|
78
|
-
const a = n[r];
|
|
79
|
-
o.innerHTML += t + a.innerHTML, a.remove();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function F(e) {
|
|
84
|
-
return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
85
|
-
}
|
|
86
|
-
function fo(e) {
|
|
87
|
-
const t = e.split("/");
|
|
88
|
-
return !t.length || // invalid?
|
|
89
|
-
t[t.length - 1] === "" ? e : t[t.length - 1];
|
|
90
|
-
}
|
|
91
|
-
function mo(e) {
|
|
92
|
-
var n;
|
|
93
|
-
const t = [
|
|
94
|
-
"mp4",
|
|
95
|
-
"webm",
|
|
96
|
-
"ogg",
|
|
97
|
-
"mov",
|
|
98
|
-
"mkv",
|
|
99
|
-
"flv",
|
|
100
|
-
"avi",
|
|
101
|
-
"wmv",
|
|
102
|
-
"m4v"
|
|
103
|
-
];
|
|
104
|
-
try {
|
|
105
|
-
const r = ((n = new URL(e).pathname.split(".").pop()) == null ? void 0 : n.toLowerCase()) || "";
|
|
106
|
-
return t.includes(r);
|
|
107
|
-
} catch {
|
|
108
|
-
return !1;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function kt(e) {
|
|
112
|
-
const t = {};
|
|
113
|
-
return Object.entries(e).forEach(([n, o]) => {
|
|
114
|
-
t[n] = {
|
|
115
|
-
default: o.default,
|
|
116
|
-
keepOnSplit: !0,
|
|
117
|
-
// Props are displayed in kebab-case as HTML attributes. If a prop's
|
|
118
|
-
// value is the same as its default, we don't display an HTML
|
|
119
|
-
// attribute for it.
|
|
120
|
-
parseHTML: (r) => {
|
|
121
|
-
const a = r.getAttribute(F(n));
|
|
122
|
-
if (a === null)
|
|
123
|
-
return null;
|
|
124
|
-
if (o.default === void 0 && o.type === "boolean" || o.default !== void 0 && typeof o.default == "boolean")
|
|
125
|
-
return a === "true" ? !0 : a === "false" ? !1 : null;
|
|
126
|
-
if (o.default === void 0 && o.type === "number" || o.default !== void 0 && typeof o.default == "number") {
|
|
127
|
-
const s = parseFloat(a);
|
|
128
|
-
return !Number.isNaN(s) && Number.isFinite(s) ? s : null;
|
|
129
|
-
}
|
|
130
|
-
return a;
|
|
131
|
-
},
|
|
132
|
-
renderHTML: (r) => r[n] !== o.default ? {
|
|
133
|
-
[F(n)]: r[n]
|
|
134
|
-
} : {}
|
|
135
|
-
};
|
|
136
|
-
}), t;
|
|
137
|
-
}
|
|
138
|
-
function yt(e, t, n, o) {
|
|
139
|
-
const r = e();
|
|
140
|
-
if (r === void 0)
|
|
141
|
-
throw new Error("Cannot find node position");
|
|
142
|
-
const s = n.state.doc.resolve(r).node().attrs.id;
|
|
143
|
-
if (!s)
|
|
144
|
-
throw new Error("Block doesn't have id");
|
|
145
|
-
const i = t.getBlock(s);
|
|
146
|
-
if (i.type !== o)
|
|
147
|
-
throw new Error("Block type does not match");
|
|
148
|
-
return i;
|
|
149
|
-
}
|
|
150
|
-
function z(e, t, n, o, r = !1, a) {
|
|
151
|
-
const s = document.createElement("div");
|
|
152
|
-
if (a !== void 0)
|
|
153
|
-
for (const [i, c] of Object.entries(a))
|
|
154
|
-
i !== "class" && s.setAttribute(i, c);
|
|
155
|
-
s.className = D(
|
|
156
|
-
"bn-block-content",
|
|
157
|
-
(a == null ? void 0 : a.class) || ""
|
|
158
|
-
), s.setAttribute("data-content-type", t);
|
|
159
|
-
for (const [i, c] of Object.entries(n)) {
|
|
160
|
-
const u = o[i].default;
|
|
161
|
-
c !== u && s.setAttribute(F(i), c);
|
|
162
|
-
}
|
|
163
|
-
return r && s.setAttribute("data-file-block", ""), s.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = D(
|
|
164
|
-
"bn-inline-content",
|
|
165
|
-
e.contentDOM.className
|
|
166
|
-
)), {
|
|
167
|
-
...e,
|
|
168
|
-
dom: s
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function vt(e, t, n) {
|
|
172
|
-
return {
|
|
173
|
-
config: {
|
|
174
|
-
type: e.type,
|
|
175
|
-
content: e.content,
|
|
176
|
-
propSchema: t
|
|
177
|
-
},
|
|
178
|
-
implementation: {
|
|
179
|
-
node: e.node,
|
|
180
|
-
render: de,
|
|
181
|
-
toExternalHTML: de
|
|
182
|
-
},
|
|
183
|
-
extensions: n
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function Et(e, t) {
|
|
187
|
-
e.stopEvent = (n) => (n.type === "mousedown" && setTimeout(() => {
|
|
188
|
-
t.view.dom.blur();
|
|
189
|
-
}, 10), !0);
|
|
190
|
-
}
|
|
191
|
-
function St(e, t) {
|
|
192
|
-
const n = [
|
|
193
|
-
{
|
|
194
|
-
tag: "[data-content-type=" + e.type + "]",
|
|
195
|
-
contentElement: ".bn-inline-content"
|
|
196
|
-
}
|
|
197
|
-
];
|
|
198
|
-
return t.parse && n.push({
|
|
199
|
-
tag: "*",
|
|
200
|
-
getAttrs(o) {
|
|
201
|
-
var a;
|
|
202
|
-
if (typeof o == "string")
|
|
203
|
-
return !1;
|
|
204
|
-
const r = (a = t.parse) == null ? void 0 : a.call(t, o);
|
|
205
|
-
return r === void 0 ? !1 : r;
|
|
206
|
-
},
|
|
207
|
-
// Because we do the parsing ourselves, we want to preserve whitespace for content we've parsed
|
|
208
|
-
preserveWhitespace: !0,
|
|
209
|
-
getContent: e.content === "inline" || e.content === "none" ? (o, r) => {
|
|
210
|
-
var a;
|
|
211
|
-
if (t.parseContent) {
|
|
212
|
-
const s = t.parseContent({
|
|
213
|
-
el: o,
|
|
214
|
-
schema: r
|
|
215
|
-
});
|
|
216
|
-
if (s !== void 0)
|
|
217
|
-
return s;
|
|
218
|
-
}
|
|
219
|
-
if (e.content === "inline") {
|
|
220
|
-
const i = o.cloneNode(!0);
|
|
221
|
-
return we(
|
|
222
|
-
i,
|
|
223
|
-
(a = t.meta) != null && a.code ? `
|
|
224
|
-
` : "<br>"
|
|
225
|
-
), xe.fromSchema(r).parse(i, {
|
|
226
|
-
topNode: r.nodes.paragraph.create(),
|
|
227
|
-
preserveWhitespace: !0
|
|
228
|
-
}).content;
|
|
229
|
-
}
|
|
230
|
-
return ut.empty;
|
|
231
|
-
} : void 0
|
|
232
|
-
}), n;
|
|
233
|
-
}
|
|
234
|
-
function ho(e, t, n, o) {
|
|
235
|
-
var a, s, i, c;
|
|
236
|
-
const r = t.node || P.create({
|
|
237
|
-
name: e.type,
|
|
238
|
-
content: e.content === "inline" ? "inline*" : e.content === "none" ? "" : e.content,
|
|
239
|
-
group: "blockContent",
|
|
240
|
-
selectable: ((a = t.meta) == null ? void 0 : a.selectable) ?? !0,
|
|
241
|
-
isolating: ((s = t.meta) == null ? void 0 : s.isolating) ?? !0,
|
|
242
|
-
code: ((i = t.meta) == null ? void 0 : i.code) ?? !1,
|
|
243
|
-
defining: ((c = t.meta) == null ? void 0 : c.defining) ?? !0,
|
|
244
|
-
priority: o,
|
|
245
|
-
addAttributes() {
|
|
246
|
-
return kt(e.propSchema);
|
|
247
|
-
},
|
|
248
|
-
parseHTML() {
|
|
249
|
-
return St(e, t);
|
|
250
|
-
},
|
|
251
|
-
renderHTML({ HTMLAttributes: l }) {
|
|
252
|
-
var d;
|
|
253
|
-
const u = document.createElement("div");
|
|
254
|
-
return z(
|
|
255
|
-
{
|
|
256
|
-
dom: u,
|
|
257
|
-
contentDOM: e.content === "inline" ? u : void 0
|
|
258
|
-
},
|
|
259
|
-
e.type,
|
|
260
|
-
{},
|
|
261
|
-
e.propSchema,
|
|
262
|
-
((d = t.meta) == null ? void 0 : d.fileBlockAccept) !== void 0,
|
|
263
|
-
l
|
|
264
|
-
);
|
|
265
|
-
},
|
|
266
|
-
addNodeView() {
|
|
267
|
-
return (l) => {
|
|
268
|
-
var f, E;
|
|
269
|
-
const u = this.options.editor, d = yt(
|
|
270
|
-
l.getPos,
|
|
271
|
-
u,
|
|
272
|
-
this.editor,
|
|
273
|
-
e.type
|
|
274
|
-
), p = ((f = this.options.domAttributes) == null ? void 0 : f.blockContent) || {}, h = t.render.call(
|
|
275
|
-
{ blockContentDOMAttributes: p, props: l, renderType: "nodeView" },
|
|
276
|
-
d,
|
|
277
|
-
u
|
|
278
|
-
);
|
|
279
|
-
return ((E = t.meta) == null ? void 0 : E.selectable) === !1 && Et(h, this.editor), h;
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
if (r.name !== e.type)
|
|
284
|
-
throw new Error(
|
|
285
|
-
"Node name does not match block type. This is a bug in BlockNote."
|
|
286
|
-
);
|
|
287
|
-
return {
|
|
288
|
-
config: e,
|
|
289
|
-
implementation: {
|
|
290
|
-
...t,
|
|
291
|
-
node: r,
|
|
292
|
-
render(l, u) {
|
|
293
|
-
var p;
|
|
294
|
-
const d = ((p = r.options.domAttributes) == null ? void 0 : p.blockContent) || {};
|
|
295
|
-
return t.render.call(
|
|
296
|
-
{
|
|
297
|
-
blockContentDOMAttributes: d,
|
|
298
|
-
props: void 0,
|
|
299
|
-
renderType: "dom"
|
|
300
|
-
},
|
|
301
|
-
l,
|
|
302
|
-
u
|
|
303
|
-
);
|
|
304
|
-
},
|
|
305
|
-
// TODO: this should not have wrapInBlockStructure and generally be a lot simpler
|
|
306
|
-
// post-processing in externalHTMLExporter should not be necessary
|
|
307
|
-
toExternalHTML: (l, u, d) => {
|
|
308
|
-
var h, f;
|
|
309
|
-
const p = ((h = r.options.domAttributes) == null ? void 0 : h.blockContent) || {};
|
|
310
|
-
return ((f = t.toExternalHTML) == null ? void 0 : f.call(
|
|
311
|
-
{ blockContentDOMAttributes: p },
|
|
312
|
-
l,
|
|
313
|
-
u,
|
|
314
|
-
d
|
|
315
|
-
)) ?? t.render.call(
|
|
316
|
-
{ blockContentDOMAttributes: p, renderType: "dom", props: void 0 },
|
|
317
|
-
l,
|
|
318
|
-
u
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
extensions: n
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function go(e) {
|
|
326
|
-
return e;
|
|
327
|
-
}
|
|
328
|
-
function v(e, t, n) {
|
|
329
|
-
return (o = {}) => {
|
|
330
|
-
const r = typeof e == "function" ? e(o) : e, a = typeof t == "function" ? t(o) : t, s = n ? typeof n == "function" ? n(o) : n : void 0;
|
|
331
|
-
return {
|
|
332
|
-
config: r,
|
|
333
|
-
implementation: {
|
|
334
|
-
...a,
|
|
335
|
-
// TODO: this should not have wrapInBlockStructure and generally be a lot simpler
|
|
336
|
-
// post-processing in externalHTMLExporter should not be necessary
|
|
337
|
-
toExternalHTML(i, c, l) {
|
|
338
|
-
var d, p;
|
|
339
|
-
const u = (d = a.toExternalHTML) == null ? void 0 : d.call(
|
|
340
|
-
{ blockContentDOMAttributes: this.blockContentDOMAttributes },
|
|
341
|
-
i,
|
|
342
|
-
c,
|
|
343
|
-
l
|
|
344
|
-
);
|
|
345
|
-
if (u !== void 0)
|
|
346
|
-
return z(
|
|
347
|
-
u,
|
|
348
|
-
i.type,
|
|
349
|
-
i.props,
|
|
350
|
-
r.propSchema,
|
|
351
|
-
((p = a.meta) == null ? void 0 : p.fileBlockAccept) !== void 0
|
|
352
|
-
);
|
|
353
|
-
},
|
|
354
|
-
render(i, c) {
|
|
355
|
-
var d;
|
|
356
|
-
const l = a.render.call(
|
|
357
|
-
{
|
|
358
|
-
blockContentDOMAttributes: this.blockContentDOMAttributes,
|
|
359
|
-
renderType: this.renderType,
|
|
360
|
-
props: this.props
|
|
361
|
-
},
|
|
362
|
-
i,
|
|
363
|
-
c
|
|
364
|
-
);
|
|
365
|
-
return z(
|
|
366
|
-
l,
|
|
367
|
-
i.type,
|
|
368
|
-
i.props,
|
|
369
|
-
r.propSchema,
|
|
370
|
-
((d = a.meta) == null ? void 0 : d.fileBlockAccept) !== void 0,
|
|
371
|
-
this.blockContentDOMAttributes
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
extensions: s
|
|
376
|
-
};
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
function bo(e, t, n, o) {
|
|
380
|
-
return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([r, a]) => {
|
|
381
|
-
const s = o[r];
|
|
382
|
-
return a !== s.default;
|
|
383
|
-
}).map(([r, a]) => [F(r), a]).forEach(([r, a]) => e.dom.setAttribute(r, a)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
384
|
-
}
|
|
385
|
-
function Co(e) {
|
|
386
|
-
return {
|
|
387
|
-
Backspace: ({ editor: t }) => {
|
|
388
|
-
const n = t.state.selection.$from;
|
|
389
|
-
return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function xt(e, t) {
|
|
394
|
-
return {
|
|
395
|
-
config: e,
|
|
396
|
-
implementation: t
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
function ko(e, t, n) {
|
|
400
|
-
return xt(
|
|
401
|
-
{
|
|
402
|
-
type: e.name,
|
|
403
|
-
propSchema: t,
|
|
404
|
-
content: e.config.content === "inline*" ? "styled" : "none"
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
...n,
|
|
408
|
-
node: e
|
|
409
|
-
}
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
function Mt(e) {
|
|
413
|
-
return Object.fromEntries(
|
|
414
|
-
Object.entries(e).map(([t, n]) => [t, n.config])
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
function wt(e) {
|
|
418
|
-
return e === "boolean" ? {} : {
|
|
419
|
-
stringValue: {
|
|
420
|
-
default: void 0,
|
|
421
|
-
keepOnSplit: !0,
|
|
422
|
-
parseHTML: (t) => t.getAttribute("data-value"),
|
|
423
|
-
renderHTML: (t) => t.stringValue !== void 0 ? {
|
|
424
|
-
"data-value": t.stringValue
|
|
425
|
-
} : {}
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
function W(e, t, n, o) {
|
|
430
|
-
return e.dom.setAttribute("data-style-type", t), o === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
431
|
-
}
|
|
432
|
-
function Le(e, t) {
|
|
433
|
-
return {
|
|
434
|
-
config: e,
|
|
435
|
-
implementation: t
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
function I(e, t) {
|
|
439
|
-
return Le(
|
|
440
|
-
{
|
|
441
|
-
type: e.name,
|
|
442
|
-
propSchema: t
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
mark: e,
|
|
446
|
-
render(n, o) {
|
|
447
|
-
const r = o.pmSchema.marks[e.name].spec.toDOM;
|
|
448
|
-
if (r === void 0)
|
|
449
|
-
throw new Error(
|
|
450
|
-
"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
|
|
451
|
-
);
|
|
452
|
-
const a = o.pmSchema.mark(e.name, {
|
|
453
|
-
stringValue: n
|
|
454
|
-
}), s = ce.renderSpec(
|
|
455
|
-
document,
|
|
456
|
-
r(a, !0)
|
|
457
|
-
);
|
|
458
|
-
if (typeof s != "object" || !("dom" in s))
|
|
459
|
-
throw new Error(
|
|
460
|
-
"Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property."
|
|
461
|
-
);
|
|
462
|
-
return s;
|
|
463
|
-
},
|
|
464
|
-
toExternalHTML(n, o) {
|
|
465
|
-
const r = o.pmSchema.marks[e.name].spec.toDOM;
|
|
466
|
-
if (r === void 0)
|
|
467
|
-
throw new Error(
|
|
468
|
-
"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
|
|
469
|
-
);
|
|
470
|
-
const a = o.pmSchema.mark(e.name, {
|
|
471
|
-
stringValue: n
|
|
472
|
-
}), s = ce.renderSpec(
|
|
473
|
-
document,
|
|
474
|
-
r(a, !0)
|
|
475
|
-
);
|
|
476
|
-
if (typeof s != "object" || !("dom" in s))
|
|
477
|
-
throw new Error(
|
|
478
|
-
"Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property."
|
|
479
|
-
);
|
|
480
|
-
return s;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
function Lt(e) {
|
|
486
|
-
return Object.fromEntries(
|
|
487
|
-
Object.entries(e).map(([t, n]) => [t, n.config])
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
function Tt(e, t) {
|
|
491
|
-
const n = [
|
|
492
|
-
{
|
|
493
|
-
tag: `[data-style-type="${e.type}"]`,
|
|
494
|
-
contentElement: (o) => {
|
|
495
|
-
const r = o;
|
|
496
|
-
return r.matches("[data-editable]") ? r : r.querySelector("[data-editable]") || r;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
];
|
|
500
|
-
return t && n.push({
|
|
501
|
-
tag: "*",
|
|
502
|
-
// By default, styles can overlap each other, so the rules should not
|
|
503
|
-
// completely consume the element they parse (which can have multiple
|
|
504
|
-
// styles).
|
|
505
|
-
consuming: !1,
|
|
506
|
-
getAttrs(o) {
|
|
507
|
-
if (typeof o == "string")
|
|
508
|
-
return !1;
|
|
509
|
-
const r = t == null ? void 0 : t(o);
|
|
510
|
-
return r === void 0 ? !1 : { stringValue: r };
|
|
511
|
-
}
|
|
512
|
-
}), n;
|
|
513
|
-
}
|
|
514
|
-
function Te(e, t) {
|
|
515
|
-
const n = Ue.create({
|
|
516
|
-
name: e.type,
|
|
517
|
-
addAttributes() {
|
|
518
|
-
return wt(e.propSchema);
|
|
519
|
-
},
|
|
520
|
-
parseHTML() {
|
|
521
|
-
return Tt(e, t.parse);
|
|
522
|
-
},
|
|
523
|
-
renderHTML({ mark: o }) {
|
|
524
|
-
const r = (t.toExternalHTML || t.render)(o.attrs.stringValue);
|
|
525
|
-
return W(
|
|
526
|
-
r,
|
|
527
|
-
e.type,
|
|
528
|
-
o.attrs.stringValue,
|
|
529
|
-
e.propSchema
|
|
530
|
-
);
|
|
531
|
-
},
|
|
532
|
-
addMarkView() {
|
|
533
|
-
return ({ mark: o }) => {
|
|
534
|
-
const r = t.render(o.attrs.stringValue);
|
|
535
|
-
return W(
|
|
536
|
-
r,
|
|
537
|
-
e.type,
|
|
538
|
-
o.attrs.stringValue,
|
|
539
|
-
e.propSchema
|
|
540
|
-
);
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
return Le(e, {
|
|
545
|
-
...t,
|
|
546
|
-
mark: n,
|
|
547
|
-
render: (o) => {
|
|
548
|
-
const r = t.render(o);
|
|
549
|
-
return W(
|
|
550
|
-
r,
|
|
551
|
-
e.type,
|
|
552
|
-
o,
|
|
553
|
-
e.propSchema
|
|
554
|
-
);
|
|
555
|
-
},
|
|
556
|
-
toExternalHTML: (o) => {
|
|
557
|
-
const r = (t.toExternalHTML || t.render)(o);
|
|
558
|
-
return W(
|
|
559
|
-
r,
|
|
560
|
-
e.type,
|
|
561
|
-
o,
|
|
562
|
-
e.propSchema
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
function Bt(e, t) {
|
|
568
|
-
let n, o;
|
|
569
|
-
if (t.firstChild.descendants((r, a) => n ? !1 : !At(r) || r.attrs.id !== e ? !0 : (n = r, o = a + 1, !1)), !(n === void 0 || o === void 0))
|
|
570
|
-
return {
|
|
571
|
-
node: n,
|
|
572
|
-
posBeforeNode: o
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
function At(e) {
|
|
576
|
-
return e.type.isInGroup("bnBlock");
|
|
577
|
-
}
|
|
578
|
-
const yo = (e, t) => ({
|
|
579
|
-
tr: n,
|
|
580
|
-
dispatch: o
|
|
581
|
-
}) => (o && Q(n, e, t), !0);
|
|
582
|
-
function Q(e, t, n, o, r) {
|
|
583
|
-
const a = et(e.doc.resolve(t));
|
|
584
|
-
let s = null;
|
|
585
|
-
a.blockNoteType === "table" && (s = Pt(e));
|
|
586
|
-
const i = O(e);
|
|
587
|
-
if (o !== void 0 && r !== void 0 && o > r)
|
|
588
|
-
throw new Error("Invalid replaceFromPos or replaceToPos");
|
|
589
|
-
const c = i.nodes[a.blockNoteType], l = i.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : i.nodes.blockContainer;
|
|
590
|
-
if (a.isBlockContainer && l.isInGroup("blockContent")) {
|
|
591
|
-
const d = o !== void 0 && o > a.blockContent.beforePos && o < a.blockContent.afterPos ? o - a.blockContent.beforePos - 1 : void 0, p = r !== void 0 && r > a.blockContent.beforePos && r < a.blockContent.afterPos ? r - a.blockContent.beforePos - 1 : void 0;
|
|
592
|
-
ue(n, e, a), Nt(
|
|
593
|
-
n,
|
|
594
|
-
e,
|
|
595
|
-
c,
|
|
596
|
-
l,
|
|
597
|
-
a,
|
|
598
|
-
d,
|
|
599
|
-
p
|
|
600
|
-
);
|
|
601
|
-
} else if (!a.isBlockContainer && l.isInGroup("bnBlock"))
|
|
602
|
-
ue(n, e, a);
|
|
603
|
-
else {
|
|
604
|
-
const d = Ee(a.bnBlock.node, i);
|
|
605
|
-
e.replaceWith(
|
|
606
|
-
a.bnBlock.beforePos,
|
|
607
|
-
a.bnBlock.afterPos,
|
|
608
|
-
X(
|
|
609
|
-
{
|
|
610
|
-
children: d.children,
|
|
611
|
-
// if no children are passed in, use existing children
|
|
612
|
-
...n
|
|
613
|
-
},
|
|
614
|
-
i
|
|
615
|
-
)
|
|
616
|
-
);
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
e.setNodeMarkup(a.bnBlock.beforePos, u, {
|
|
620
|
-
...a.bnBlock.node.attrs,
|
|
621
|
-
...n.props
|
|
622
|
-
}), s && It(e, a, s);
|
|
623
|
-
}
|
|
624
|
-
function Nt(e, t, n, o, r, a, s) {
|
|
625
|
-
const i = O(t);
|
|
626
|
-
let c = "keep";
|
|
627
|
-
if (e.content)
|
|
628
|
-
if (typeof e.content == "string")
|
|
629
|
-
c = ie(
|
|
630
|
-
[e.content],
|
|
631
|
-
i,
|
|
632
|
-
o.name
|
|
633
|
-
);
|
|
634
|
-
else if (Array.isArray(e.content))
|
|
635
|
-
c = ie(e.content, i, o.name);
|
|
636
|
-
else if (e.content.type === "tableContent")
|
|
637
|
-
c = tt(e.content, i);
|
|
638
|
-
else
|
|
639
|
-
throw new nt(e.content.type);
|
|
640
|
-
else
|
|
641
|
-
n.spec.content === "" || o.spec.content !== n.spec.content && (c = []);
|
|
642
|
-
if (c === "keep")
|
|
643
|
-
t.setNodeMarkup(r.blockContent.beforePos, o, {
|
|
644
|
-
...r.blockContent.node.attrs,
|
|
645
|
-
...e.props
|
|
646
|
-
});
|
|
647
|
-
else if (a !== void 0 || s !== void 0) {
|
|
648
|
-
t.setNodeMarkup(r.blockContent.beforePos, o, {
|
|
649
|
-
...r.blockContent.node.attrs,
|
|
650
|
-
...e.props
|
|
651
|
-
});
|
|
652
|
-
const l = r.blockContent.beforePos + 1 + (a ?? 0), u = r.blockContent.beforePos + 1 + (s ?? r.blockContent.node.content.size), d = t.doc.resolve(r.blockContent.beforePos).depth, p = t.doc.resolve(l).depth, h = t.doc.resolve(u).depth;
|
|
653
|
-
t.replace(
|
|
654
|
-
l,
|
|
655
|
-
u,
|
|
656
|
-
new Me(
|
|
657
|
-
_.from(c),
|
|
658
|
-
p - d - 1,
|
|
659
|
-
h - d - 1
|
|
660
|
-
)
|
|
661
|
-
);
|
|
662
|
-
} else
|
|
663
|
-
t.replaceWith(
|
|
664
|
-
r.blockContent.beforePos,
|
|
665
|
-
r.blockContent.afterPos,
|
|
666
|
-
o.createChecked(
|
|
667
|
-
{
|
|
668
|
-
...r.blockContent.node.attrs,
|
|
669
|
-
...e.props
|
|
670
|
-
},
|
|
671
|
-
c
|
|
672
|
-
)
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
function ue(e, t, n) {
|
|
676
|
-
const o = O(t);
|
|
677
|
-
if (e.children !== void 0 && e.children.length > 0) {
|
|
678
|
-
const r = e.children.map((a) => X(a, o));
|
|
679
|
-
if (n.childContainer)
|
|
680
|
-
t.step(
|
|
681
|
-
new Ke(
|
|
682
|
-
n.childContainer.beforePos + 1,
|
|
683
|
-
n.childContainer.afterPos - 1,
|
|
684
|
-
new Me(_.from(r), 0, 0)
|
|
685
|
-
)
|
|
686
|
-
);
|
|
687
|
-
else {
|
|
688
|
-
if (!n.isBlockContainer)
|
|
689
|
-
throw new Error("impossible");
|
|
690
|
-
t.insert(
|
|
691
|
-
n.blockContent.afterPos,
|
|
692
|
-
o.nodes.blockGroup.createChecked({}, r)
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
function vo(e, t, n, o, r) {
|
|
698
|
-
const a = typeof t == "string" ? t : t.id, s = Bt(a, e.doc);
|
|
699
|
-
if (!s)
|
|
700
|
-
throw new Error(`Block with ID ${a} not found`);
|
|
701
|
-
Q(
|
|
702
|
-
e,
|
|
703
|
-
s.posBeforeNode,
|
|
704
|
-
n,
|
|
705
|
-
o,
|
|
706
|
-
r
|
|
707
|
-
);
|
|
708
|
-
const i = e.doc.resolve(s.posBeforeNode + 1).node(), c = O(e);
|
|
709
|
-
return Ee(i, c);
|
|
710
|
-
}
|
|
711
|
-
function Pt(e) {
|
|
712
|
-
const t = "selection" in e ? e.selection : null;
|
|
713
|
-
if (!(t instanceof ye))
|
|
714
|
-
return null;
|
|
715
|
-
const n = e.doc.resolve(t.head);
|
|
716
|
-
let o = -1, r = -1;
|
|
717
|
-
for (let x = n.depth; x >= 0; x--) {
|
|
718
|
-
const S = n.node(x).type.name;
|
|
719
|
-
if (o < 0 && (S === "tableCell" || S === "tableHeader") && (o = x), S === "table") {
|
|
720
|
-
r = x;
|
|
721
|
-
break;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
if (o < 0 || r < 0)
|
|
725
|
-
return null;
|
|
726
|
-
const a = n.before(o), s = n.before(r), i = e.doc.nodeAt(s);
|
|
727
|
-
if (!i || i.type.name !== "table")
|
|
728
|
-
return null;
|
|
729
|
-
const c = Ce.get(i), l = a - (s + 1), u = c.map.indexOf(l);
|
|
730
|
-
if (u < 0)
|
|
731
|
-
return null;
|
|
732
|
-
const d = Math.floor(u / c.width), p = u % c.width, f = a + 1 + 1, E = Math.max(0, t.head - f);
|
|
733
|
-
return { row: d, col: p, offset: E };
|
|
734
|
-
}
|
|
735
|
-
function It(e, t, n) {
|
|
736
|
-
var x;
|
|
737
|
-
if (t.blockNoteType !== "table")
|
|
738
|
-
return !1;
|
|
739
|
-
let o = -1;
|
|
740
|
-
if (t.isBlockContainer)
|
|
741
|
-
o = e.mapping.map(t.blockContent.beforePos);
|
|
742
|
-
else {
|
|
743
|
-
const S = e.mapping.map(t.bnBlock.beforePos), N = S + (((x = e.doc.nodeAt(S)) == null ? void 0 : x.nodeSize) || 0);
|
|
744
|
-
e.doc.nodesBetween(S, N, (g, M) => g.type.name === "table" ? (o = M, !1) : !0);
|
|
745
|
-
}
|
|
746
|
-
const r = o >= 0 ? e.doc.nodeAt(o) : null;
|
|
747
|
-
if (!r || r.type.name !== "table")
|
|
748
|
-
return !1;
|
|
749
|
-
const a = Ce.get(r), s = Math.max(0, Math.min(n.row, a.height - 1)), i = Math.max(0, Math.min(n.col, a.width - 1)), c = s * a.width + i, l = a.map[c];
|
|
750
|
-
if (l == null)
|
|
751
|
-
return !1;
|
|
752
|
-
const d = o + 1 + l + 1, p = e.doc.nodeAt(d), h = d + 1, f = p ? p.content.size : 0, E = h + Math.max(0, Math.min(n.offset, f));
|
|
753
|
-
return "selection" in e && e.setSelection(ye.create(e.doc, E)), !0;
|
|
754
|
-
}
|
|
755
|
-
const T = {
|
|
756
|
-
gray: {
|
|
757
|
-
text: "#9b9a97",
|
|
758
|
-
background: "#ebeced"
|
|
759
|
-
},
|
|
760
|
-
brown: {
|
|
761
|
-
text: "#64473a",
|
|
762
|
-
background: "#e9e5e3"
|
|
763
|
-
},
|
|
764
|
-
red: {
|
|
765
|
-
text: "#e03e3e",
|
|
766
|
-
background: "#fbe4e4"
|
|
767
|
-
},
|
|
768
|
-
orange: {
|
|
769
|
-
text: "#d9730d",
|
|
770
|
-
background: "#f6e9d9"
|
|
771
|
-
},
|
|
772
|
-
yellow: {
|
|
773
|
-
text: "#dfab01",
|
|
774
|
-
background: "#fbf3db"
|
|
775
|
-
},
|
|
776
|
-
green: {
|
|
777
|
-
text: "#4d6461",
|
|
778
|
-
background: "#ddedea"
|
|
779
|
-
},
|
|
780
|
-
blue: {
|
|
781
|
-
text: "#0b6e99",
|
|
782
|
-
background: "#ddebf1"
|
|
783
|
-
},
|
|
784
|
-
purple: {
|
|
785
|
-
text: "#6940a5",
|
|
786
|
-
background: "#eae4f2"
|
|
787
|
-
},
|
|
788
|
-
pink: {
|
|
789
|
-
text: "#ad1a72",
|
|
790
|
-
background: "#f4dfeb"
|
|
791
|
-
}
|
|
792
|
-
}, Eo = {
|
|
793
|
-
gray: {
|
|
794
|
-
text: "#bebdb8",
|
|
795
|
-
background: "#9b9a97"
|
|
796
|
-
},
|
|
797
|
-
brown: {
|
|
798
|
-
text: "#8e6552",
|
|
799
|
-
background: "#64473a"
|
|
800
|
-
},
|
|
801
|
-
red: {
|
|
802
|
-
text: "#ec4040",
|
|
803
|
-
background: "#be3434"
|
|
804
|
-
},
|
|
805
|
-
orange: {
|
|
806
|
-
text: "#e3790d",
|
|
807
|
-
background: "#b7600a"
|
|
808
|
-
},
|
|
809
|
-
yellow: {
|
|
810
|
-
text: "#dfab01",
|
|
811
|
-
background: "#b58b00"
|
|
812
|
-
},
|
|
813
|
-
green: {
|
|
814
|
-
text: "#6b8b87",
|
|
815
|
-
background: "#4d6461"
|
|
816
|
-
},
|
|
817
|
-
blue: {
|
|
818
|
-
text: "#0e87bc",
|
|
819
|
-
background: "#0b6e99"
|
|
820
|
-
},
|
|
821
|
-
purple: {
|
|
822
|
-
text: "#8552d7",
|
|
823
|
-
background: "#6940a5"
|
|
824
|
-
},
|
|
825
|
-
pink: {
|
|
826
|
-
text: "#da208f",
|
|
827
|
-
background: "#ad1a72"
|
|
828
|
-
}
|
|
829
|
-
}, m = {
|
|
830
|
-
backgroundColor: {
|
|
831
|
-
default: "default"
|
|
832
|
-
},
|
|
833
|
-
textColor: {
|
|
834
|
-
default: "default"
|
|
835
|
-
},
|
|
836
|
-
textAlignment: {
|
|
837
|
-
default: "left",
|
|
838
|
-
values: ["left", "center", "right", "justify"]
|
|
839
|
-
}
|
|
840
|
-
}, C = (e) => {
|
|
841
|
-
const t = {};
|
|
842
|
-
return e.hasAttribute("data-background-color") ? t.backgroundColor = e.getAttribute("data-background-color") : e.style.backgroundColor && (t.backgroundColor = e.style.backgroundColor), e.hasAttribute("data-text-color") ? t.textColor = e.getAttribute("data-text-color") : e.style.color && (t.textColor = e.style.color), t.textAlignment = m.textAlignment.values.includes(
|
|
843
|
-
e.style.textAlign
|
|
844
|
-
) ? e.style.textAlign : void 0, t;
|
|
845
|
-
}, A = (e, t) => {
|
|
846
|
-
e.backgroundColor && e.backgroundColor !== m.backgroundColor.default && (t.style.backgroundColor = e.backgroundColor in T ? T[e.backgroundColor].background : e.backgroundColor), e.textColor && e.textColor !== m.textColor.default && (t.style.color = e.textColor in T ? T[e.textColor].text : e.textColor), e.textAlignment && e.textAlignment !== m.textAlignment.default && (t.style.textAlign = e.textAlignment);
|
|
847
|
-
}, So = (e = "backgroundColor") => ({
|
|
848
|
-
default: m.backgroundColor.default,
|
|
849
|
-
parseHTML: (t) => t.hasAttribute("data-background-color") ? t.getAttribute("data-background-color") : t.style.backgroundColor ? t.style.backgroundColor : m.backgroundColor.default,
|
|
850
|
-
renderHTML: (t) => t[e] === m.backgroundColor.default ? {} : {
|
|
851
|
-
"data-background-color": t[e]
|
|
852
|
-
}
|
|
853
|
-
}), xo = (e = "textColor") => ({
|
|
854
|
-
default: m.textColor.default,
|
|
855
|
-
parseHTML: (t) => t.hasAttribute("data-text-color") ? t.getAttribute("data-text-color") : t.style.color ? t.style.color : m.textColor.default,
|
|
856
|
-
renderHTML: (t) => t[e] === m.textColor.default ? {} : {
|
|
857
|
-
"data-text-color": t[e]
|
|
858
|
-
}
|
|
859
|
-
}), Mo = (e = "textAlignment") => ({
|
|
860
|
-
default: m.textAlignment.default,
|
|
861
|
-
parseHTML: (t) => t.hasAttribute("data-text-alignment") ? t.getAttribute("data-text-alignment") : t.style.textAlign ? t.style.textAlign : m.textAlignment.default,
|
|
862
|
-
renderHTML: (t) => t[e] === m.textAlignment.default ? {} : {
|
|
863
|
-
"data-text-alignment": t[e]
|
|
864
|
-
}
|
|
865
|
-
}), $ = (e, t) => {
|
|
866
|
-
const n = e.querySelector(
|
|
867
|
-
t
|
|
868
|
-
);
|
|
869
|
-
if (!n)
|
|
870
|
-
return;
|
|
871
|
-
const o = e.querySelector("figcaption"), r = (o == null ? void 0 : o.textContent) ?? void 0;
|
|
872
|
-
return { targetElement: n, caption: r };
|
|
873
|
-
}, H = y(({ editor: e }) => {
|
|
874
|
-
const t = ve(void 0);
|
|
875
|
-
function n() {
|
|
876
|
-
t.setState(void 0);
|
|
877
|
-
}
|
|
878
|
-
return {
|
|
879
|
-
key: "filePanel",
|
|
880
|
-
store: t,
|
|
881
|
-
mount({ signal: o }) {
|
|
882
|
-
const r = e.onChange(
|
|
883
|
-
n,
|
|
884
|
-
// Don't trigger if the changes are caused by a remote user.
|
|
885
|
-
!1
|
|
886
|
-
), a = e.onSelectionChange(
|
|
887
|
-
n,
|
|
888
|
-
// Don't trigger if the changes are caused by a remote user.
|
|
889
|
-
!1
|
|
890
|
-
);
|
|
891
|
-
o.addEventListener("abort", () => {
|
|
892
|
-
r(), a();
|
|
893
|
-
});
|
|
894
|
-
},
|
|
895
|
-
closeMenu: n,
|
|
896
|
-
showMenu(o) {
|
|
897
|
-
t.setState(o);
|
|
898
|
-
}
|
|
899
|
-
};
|
|
900
|
-
}), Ht = (e, t, n) => {
|
|
901
|
-
const o = document.createElement("div");
|
|
902
|
-
o.className = "bn-add-file-button";
|
|
903
|
-
const r = document.createElement("div");
|
|
904
|
-
r.className = "bn-add-file-button-icon", n ? r.appendChild(n) : r.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>', o.appendChild(r);
|
|
905
|
-
const a = document.createElement("p");
|
|
906
|
-
a.className = "bn-add-file-button-text", a.innerHTML = e.type in t.dictionary.file_blocks.add_button_text ? t.dictionary.file_blocks.add_button_text[e.type] : t.dictionary.file_blocks.add_button_text.file, o.appendChild(a);
|
|
907
|
-
const s = (c) => {
|
|
908
|
-
c.preventDefault(), c.stopPropagation();
|
|
909
|
-
}, i = () => {
|
|
910
|
-
var c;
|
|
911
|
-
t.isEditable && ((c = t.getExtension(H)) == null || c.showMenu(e.id));
|
|
912
|
-
};
|
|
913
|
-
return o.addEventListener(
|
|
914
|
-
"mousedown",
|
|
915
|
-
s,
|
|
916
|
-
!0
|
|
917
|
-
), o.addEventListener("click", i, !0), {
|
|
918
|
-
dom: o,
|
|
919
|
-
destroy: () => {
|
|
920
|
-
o.removeEventListener(
|
|
921
|
-
"mousedown",
|
|
922
|
-
s,
|
|
923
|
-
!0
|
|
924
|
-
), o.removeEventListener(
|
|
925
|
-
"click",
|
|
926
|
-
i,
|
|
927
|
-
!0
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
|
-
};
|
|
931
|
-
}, Dt = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>', Ot = (e) => {
|
|
932
|
-
const t = document.createElement("div");
|
|
933
|
-
t.className = "bn-file-name-with-icon";
|
|
934
|
-
const n = document.createElement("div");
|
|
935
|
-
n.className = "bn-file-icon", n.innerHTML = Dt, t.appendChild(n);
|
|
936
|
-
const o = document.createElement("p");
|
|
937
|
-
return o.className = "bn-file-name", o.textContent = e.props.name, t.appendChild(o), {
|
|
938
|
-
dom: t
|
|
939
|
-
};
|
|
940
|
-
}, J = (e, t, n, o) => {
|
|
941
|
-
const r = document.createElement("div");
|
|
942
|
-
if (r.className = "bn-file-block-content-wrapper", e.props.url === "") {
|
|
943
|
-
const s = Ht(e, t, o);
|
|
944
|
-
r.appendChild(s.dom);
|
|
945
|
-
const i = t.onUploadStart((c) => {
|
|
946
|
-
if (c === e.id) {
|
|
947
|
-
r.removeChild(s.dom);
|
|
948
|
-
const l = document.createElement("div");
|
|
949
|
-
l.className = "bn-file-loading-preview", l.textContent = "Loading...", r.appendChild(l);
|
|
950
|
-
}
|
|
951
|
-
});
|
|
952
|
-
return {
|
|
953
|
-
dom: r,
|
|
954
|
-
destroy: () => {
|
|
955
|
-
i(), s.destroy();
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
}
|
|
959
|
-
const a = { dom: r };
|
|
960
|
-
if (e.props.showPreview === !1 || !n) {
|
|
961
|
-
const s = Ot(e);
|
|
962
|
-
r.appendChild(s.dom), a.destroy = () => {
|
|
963
|
-
var i;
|
|
964
|
-
(i = s.destroy) == null || i.call(s);
|
|
965
|
-
};
|
|
966
|
-
} else
|
|
967
|
-
r.appendChild(n.dom);
|
|
968
|
-
if (e.props.caption) {
|
|
969
|
-
const s = document.createElement("p");
|
|
970
|
-
s.className = "bn-file-caption", s.textContent = e.props.caption, r.appendChild(s);
|
|
971
|
-
}
|
|
972
|
-
return a;
|
|
973
|
-
}, Y = (e, t) => {
|
|
974
|
-
const n = document.createElement("figure"), o = document.createElement("figcaption");
|
|
975
|
-
return o.textContent = t, n.appendChild(e), n.appendChild(o), { dom: n };
|
|
976
|
-
}, U = (e, t) => {
|
|
977
|
-
const n = document.createElement("div"), o = document.createElement("p");
|
|
978
|
-
return o.textContent = t, n.appendChild(e), n.appendChild(o), {
|
|
979
|
-
dom: n
|
|
980
|
-
};
|
|
981
|
-
}, pe = (e) => ({ url: e.src || void 0 }), _t = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>', Vt = (e) => ({
|
|
982
|
-
type: "audio",
|
|
983
|
-
propSchema: {
|
|
984
|
-
backgroundColor: m.backgroundColor,
|
|
985
|
-
// File name.
|
|
986
|
-
name: {
|
|
987
|
-
default: ""
|
|
988
|
-
},
|
|
989
|
-
// File url.
|
|
990
|
-
url: {
|
|
991
|
-
default: ""
|
|
992
|
-
},
|
|
993
|
-
// File caption.
|
|
994
|
-
caption: {
|
|
995
|
-
default: ""
|
|
996
|
-
},
|
|
997
|
-
showPreview: {
|
|
998
|
-
default: !0
|
|
999
|
-
}
|
|
1000
|
-
},
|
|
1001
|
-
content: "none"
|
|
1002
|
-
}), Wt = (e = {}) => (t) => {
|
|
1003
|
-
if (t.tagName === "AUDIO") {
|
|
1004
|
-
if (t.closest("figure"))
|
|
1005
|
-
return;
|
|
1006
|
-
const { backgroundColor: n } = C(t);
|
|
1007
|
-
return {
|
|
1008
|
-
...pe(t),
|
|
1009
|
-
backgroundColor: n
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
if (t.tagName === "FIGURE") {
|
|
1013
|
-
const n = $(t, "audio");
|
|
1014
|
-
if (!n)
|
|
1015
|
-
return;
|
|
1016
|
-
const { targetElement: o, caption: r } = n, { backgroundColor: a } = C(t);
|
|
1017
|
-
return {
|
|
1018
|
-
...pe(o),
|
|
1019
|
-
backgroundColor: a,
|
|
1020
|
-
caption: r
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
}, Rt = (e = {}) => (t, n) => {
|
|
1024
|
-
const o = document.createElement("div");
|
|
1025
|
-
o.innerHTML = e.icon ?? _t;
|
|
1026
|
-
const r = document.createElement("audio");
|
|
1027
|
-
return r.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((a) => {
|
|
1028
|
-
r.src = a;
|
|
1029
|
-
}) : r.src = t.props.url, r.controls = !0, r.contentEditable = "false", r.draggable = !1, J(
|
|
1030
|
-
t,
|
|
1031
|
-
n,
|
|
1032
|
-
{ dom: r },
|
|
1033
|
-
o.firstElementChild
|
|
1034
|
-
);
|
|
1035
|
-
}, Ft = (e = {}) => (t, n) => {
|
|
1036
|
-
if (!t.props.url) {
|
|
1037
|
-
const r = document.createElement("p");
|
|
1038
|
-
return r.textContent = "Add audio", {
|
|
1039
|
-
dom: r
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
let o;
|
|
1043
|
-
return t.props.showPreview ? (o = document.createElement("audio"), o.src = t.props.url) : (o = document.createElement("a"), o.href = t.props.url, o.textContent = t.props.name || t.props.url), t.props.caption ? t.props.showPreview ? Y(o, t.props.caption) : U(o, t.props.caption) : {
|
|
1044
|
-
dom: o
|
|
1045
|
-
};
|
|
1046
|
-
}, $t = v(
|
|
1047
|
-
Vt,
|
|
1048
|
-
(e) => ({
|
|
1049
|
-
meta: {
|
|
1050
|
-
fileBlockAccept: ["audio/*"]
|
|
1051
|
-
},
|
|
1052
|
-
parse: Wt(e),
|
|
1053
|
-
render: Rt(e),
|
|
1054
|
-
toExternalHTML: Ft(e),
|
|
1055
|
-
runsBefore: ["file"]
|
|
1056
|
-
})
|
|
1057
|
-
), fe = Symbol.for("blocknote.shikiParser"), j = Symbol.for(
|
|
1058
|
-
"blocknote.shikiHighlighterPromise"
|
|
1059
|
-
);
|
|
1060
|
-
function Ut(e) {
|
|
1061
|
-
const t = globalThis;
|
|
1062
|
-
let n, o, r = !1;
|
|
1063
|
-
return pt({
|
|
1064
|
-
parser: (s) => {
|
|
1065
|
-
if (!e.createHighlighter)
|
|
1066
|
-
return process.env.NODE_ENV === "development" && !r && (console.log(
|
|
1067
|
-
"For syntax highlighting of code blocks, you must provide a `createCodeBlockSpec({ createHighlighter: () => ... })` function"
|
|
1068
|
-
), r = !0), [];
|
|
1069
|
-
if (!n)
|
|
1070
|
-
return t[j] = t[j] || e.createHighlighter(), t[j].then(
|
|
1071
|
-
(c) => {
|
|
1072
|
-
n = c;
|
|
1073
|
-
}
|
|
1074
|
-
);
|
|
1075
|
-
const i = Be(e, s.language);
|
|
1076
|
-
return !i || i === "text" || i === "none" || i === "plaintext" || i === "txt" ? [] : n.getLoadedLanguages().includes(i) ? (o || (o = t[fe] || ft(n), t[fe] = o), o(s)) : n.loadLanguage(i);
|
|
1077
|
-
},
|
|
1078
|
-
languageExtractor: (s) => s.attrs.language,
|
|
1079
|
-
nodeTypes: ["codeBlock"]
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
const qt = ({ defaultLanguage: e = "text" }) => ({
|
|
1083
|
-
type: "codeBlock",
|
|
1084
|
-
propSchema: {
|
|
1085
|
-
language: {
|
|
1086
|
-
default: e
|
|
1087
|
-
}
|
|
1088
|
-
},
|
|
1089
|
-
content: "inline"
|
|
1090
|
-
}), jt = v(
|
|
1091
|
-
qt,
|
|
1092
|
-
(e) => ({
|
|
1093
|
-
meta: {
|
|
1094
|
-
code: !0,
|
|
1095
|
-
defining: !0,
|
|
1096
|
-
isolating: !1
|
|
1097
|
-
},
|
|
1098
|
-
parse: (t) => {
|
|
1099
|
-
var r, a;
|
|
1100
|
-
if (t.tagName !== "PRE" || t.childElementCount !== 1 || ((r = t.firstElementChild) == null ? void 0 : r.tagName) !== "CODE")
|
|
1101
|
-
return;
|
|
1102
|
-
const n = t.firstElementChild;
|
|
1103
|
-
return { language: n.getAttribute("data-language") || ((a = n.className.split(" ").find((s) => s.includes("language-"))) == null ? void 0 : a.replace("language-", "")) };
|
|
1104
|
-
},
|
|
1105
|
-
parseContent: ({ el: t, schema: n }) => {
|
|
1106
|
-
const o = xe.fromSchema(n), r = t.firstElementChild;
|
|
1107
|
-
return o.parse(r, {
|
|
1108
|
-
preserveWhitespace: "full",
|
|
1109
|
-
topNode: n.nodes.codeBlock.create()
|
|
1110
|
-
}).content;
|
|
1111
|
-
},
|
|
1112
|
-
render(t, n) {
|
|
1113
|
-
const o = document.createDocumentFragment(), r = document.createElement("pre"), a = document.createElement("code");
|
|
1114
|
-
r.appendChild(a);
|
|
1115
|
-
let s;
|
|
1116
|
-
if (e.supportedLanguages) {
|
|
1117
|
-
const i = document.createElement("select");
|
|
1118
|
-
if (Object.entries(e.supportedLanguages ?? {}).forEach(
|
|
1119
|
-
([l, { name: u }]) => {
|
|
1120
|
-
const d = document.createElement("option");
|
|
1121
|
-
d.value = l, d.text = u, i.appendChild(d);
|
|
1122
|
-
}
|
|
1123
|
-
), i.value = t.props.language || e.defaultLanguage || "text", n.isEditable) {
|
|
1124
|
-
const l = (u) => {
|
|
1125
|
-
const d = u.target.value;
|
|
1126
|
-
n.updateBlock(t.id, { props: { language: d } });
|
|
1127
|
-
};
|
|
1128
|
-
i.addEventListener("change", l), s = () => i.removeEventListener("change", l);
|
|
1129
|
-
} else
|
|
1130
|
-
i.disabled = !0;
|
|
1131
|
-
const c = document.createElement("div");
|
|
1132
|
-
c.contentEditable = "false", c.appendChild(i), o.appendChild(c);
|
|
1133
|
-
}
|
|
1134
|
-
return o.appendChild(r), {
|
|
1135
|
-
dom: o,
|
|
1136
|
-
contentDOM: a,
|
|
1137
|
-
destroy: () => {
|
|
1138
|
-
s == null || s();
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
},
|
|
1142
|
-
toExternalHTML(t) {
|
|
1143
|
-
const n = document.createElement("pre"), o = document.createElement("code");
|
|
1144
|
-
return o.className = `language-${t.props.language}`, o.dataset.language = t.props.language, n.appendChild(o), {
|
|
1145
|
-
dom: n,
|
|
1146
|
-
contentDOM: o
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
}),
|
|
1150
|
-
(e) => [
|
|
1151
|
-
y({
|
|
1152
|
-
key: "code-block-highlighter",
|
|
1153
|
-
prosemirrorPlugins: [Ut(e)]
|
|
1154
|
-
}),
|
|
1155
|
-
y({
|
|
1156
|
-
key: "code-block-keyboard-shortcuts",
|
|
1157
|
-
keyboardShortcuts: {
|
|
1158
|
-
Delete: ({ editor: t }) => t.transact((n) => {
|
|
1159
|
-
const { block: o } = t.getTextCursorPosition();
|
|
1160
|
-
if (o.type !== "codeBlock")
|
|
1161
|
-
return !1;
|
|
1162
|
-
const { $from: r } = n.selection;
|
|
1163
|
-
return r.parent.textContent ? !1 : (t.removeBlocks([o]), !0);
|
|
1164
|
-
}),
|
|
1165
|
-
Tab: ({ editor: t }) => e.indentLineWithTab === !1 ? !1 : t.transact((n) => {
|
|
1166
|
-
const { block: o } = t.getTextCursorPosition();
|
|
1167
|
-
return o.type === "codeBlock" ? (n.insertText(" "), !0) : !1;
|
|
1168
|
-
}),
|
|
1169
|
-
Enter: ({ editor: t }) => t.transact((n) => {
|
|
1170
|
-
const { block: o, nextBlock: r } = t.getTextCursorPosition();
|
|
1171
|
-
if (o.type !== "codeBlock")
|
|
1172
|
-
return !1;
|
|
1173
|
-
const { $from: a } = n.selection, s = a.parentOffset === a.parent.nodeSize - 2, i = a.parent.textContent.endsWith(`
|
|
1174
|
-
|
|
1175
|
-
`);
|
|
1176
|
-
if (s && i) {
|
|
1177
|
-
if (n.delete(a.pos - 2, a.pos), r)
|
|
1178
|
-
return t.setTextCursorPosition(r, "start"), !0;
|
|
1179
|
-
const [c] = t.insertBlocks(
|
|
1180
|
-
[{ type: "paragraph" }],
|
|
1181
|
-
o,
|
|
1182
|
-
"after"
|
|
1183
|
-
);
|
|
1184
|
-
return t.setTextCursorPosition(c, "start"), !0;
|
|
1185
|
-
}
|
|
1186
|
-
return n.insertText(`
|
|
1187
|
-
`), !0;
|
|
1188
|
-
}),
|
|
1189
|
-
"Shift-Enter": ({ editor: t }) => t.transact(() => {
|
|
1190
|
-
const { block: n } = t.getTextCursorPosition();
|
|
1191
|
-
if (n.type !== "codeBlock")
|
|
1192
|
-
return !1;
|
|
1193
|
-
const [o] = t.insertBlocks(
|
|
1194
|
-
// insert a new paragraph
|
|
1195
|
-
[{ type: "paragraph" }],
|
|
1196
|
-
n,
|
|
1197
|
-
"after"
|
|
1198
|
-
);
|
|
1199
|
-
return t.setTextCursorPosition(o, "start"), !0;
|
|
1200
|
-
})
|
|
1201
|
-
},
|
|
1202
|
-
inputRules: [
|
|
1203
|
-
{
|
|
1204
|
-
find: /^```(.*?)\s$/,
|
|
1205
|
-
replace: ({ match: t }) => {
|
|
1206
|
-
const n = t[1].trim();
|
|
1207
|
-
return {
|
|
1208
|
-
type: "codeBlock",
|
|
1209
|
-
props: {
|
|
1210
|
-
language: {
|
|
1211
|
-
language: Be(e, n) ?? n
|
|
1212
|
-
}.language
|
|
1213
|
-
},
|
|
1214
|
-
content: []
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
]
|
|
1219
|
-
})
|
|
1220
|
-
]
|
|
1221
|
-
);
|
|
1222
|
-
function Be(e, t) {
|
|
1223
|
-
var n;
|
|
1224
|
-
return (n = Object.entries(e.supportedLanguages ?? {}).find(
|
|
1225
|
-
([o, { aliases: r }]) => (r == null ? void 0 : r.includes(t)) || o === t
|
|
1226
|
-
)) == null ? void 0 : n[0];
|
|
1227
|
-
}
|
|
1228
|
-
const Gt = () => ({
|
|
1229
|
-
type: "divider",
|
|
1230
|
-
propSchema: {},
|
|
1231
|
-
content: "none"
|
|
1232
|
-
}), zt = v(
|
|
1233
|
-
Gt,
|
|
1234
|
-
{
|
|
1235
|
-
meta: {
|
|
1236
|
-
isolating: !1
|
|
1237
|
-
},
|
|
1238
|
-
parse(e) {
|
|
1239
|
-
if (e.tagName === "HR")
|
|
1240
|
-
return {};
|
|
1241
|
-
},
|
|
1242
|
-
render() {
|
|
1243
|
-
return {
|
|
1244
|
-
dom: document.createElement("hr")
|
|
1245
|
-
};
|
|
1246
|
-
}
|
|
1247
|
-
},
|
|
1248
|
-
[
|
|
1249
|
-
y({
|
|
1250
|
-
key: "divider-block-shortcuts",
|
|
1251
|
-
inputRules: [
|
|
1252
|
-
{
|
|
1253
|
-
find: new RegExp("^---$"),
|
|
1254
|
-
replace() {
|
|
1255
|
-
return { type: "divider", props: {}, content: [] };
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
]
|
|
1259
|
-
})
|
|
1260
|
-
]
|
|
1261
|
-
), me = (e) => ({ url: e.src || void 0 }), Zt = () => ({
|
|
1262
|
-
type: "file",
|
|
1263
|
-
propSchema: {
|
|
1264
|
-
backgroundColor: m.backgroundColor,
|
|
1265
|
-
// File name.
|
|
1266
|
-
name: {
|
|
1267
|
-
default: ""
|
|
1268
|
-
},
|
|
1269
|
-
// File url.
|
|
1270
|
-
url: {
|
|
1271
|
-
default: ""
|
|
1272
|
-
},
|
|
1273
|
-
// File caption.
|
|
1274
|
-
caption: {
|
|
1275
|
-
default: ""
|
|
1276
|
-
}
|
|
1277
|
-
},
|
|
1278
|
-
content: "none"
|
|
1279
|
-
}), Xt = () => (e) => {
|
|
1280
|
-
if (e.tagName === "EMBED") {
|
|
1281
|
-
if (e.closest("figure"))
|
|
1282
|
-
return;
|
|
1283
|
-
const { backgroundColor: t } = C(e);
|
|
1284
|
-
return {
|
|
1285
|
-
...me(e),
|
|
1286
|
-
backgroundColor: t
|
|
1287
|
-
};
|
|
1288
|
-
}
|
|
1289
|
-
if (e.tagName === "FIGURE") {
|
|
1290
|
-
const t = $(e, "embed");
|
|
1291
|
-
if (!t)
|
|
1292
|
-
return;
|
|
1293
|
-
const { targetElement: n, caption: o } = t, { backgroundColor: r } = C(e);
|
|
1294
|
-
return {
|
|
1295
|
-
...me(n),
|
|
1296
|
-
backgroundColor: r,
|
|
1297
|
-
caption: o
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
}, Kt = v(Zt, {
|
|
1301
|
-
meta: {
|
|
1302
|
-
fileBlockAccept: ["*/*"]
|
|
1303
|
-
},
|
|
1304
|
-
parse: Xt(),
|
|
1305
|
-
render(e, t) {
|
|
1306
|
-
return J(e, t);
|
|
1307
|
-
},
|
|
1308
|
-
toExternalHTML(e) {
|
|
1309
|
-
if (!e.props.url) {
|
|
1310
|
-
const n = document.createElement("p");
|
|
1311
|
-
return n.textContent = "Add file", {
|
|
1312
|
-
dom: n
|
|
1313
|
-
};
|
|
1314
|
-
}
|
|
1315
|
-
const t = document.createElement("a");
|
|
1316
|
-
return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? U(t, e.props.caption) : {
|
|
1317
|
-
dom: t
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
});
|
|
1321
|
-
function Ae(e, t, n) {
|
|
1322
|
-
var u;
|
|
1323
|
-
const o = K.fromSchema(t), r = e.querySelector(":scope > summary");
|
|
1324
|
-
let a;
|
|
1325
|
-
if (r) {
|
|
1326
|
-
const d = r.cloneNode(!0);
|
|
1327
|
-
we(d), a = o.parse(d, {
|
|
1328
|
-
topNode: t.nodes.paragraph.create(),
|
|
1329
|
-
preserveWhitespace: !0
|
|
1330
|
-
}).content;
|
|
1331
|
-
} else
|
|
1332
|
-
a = _.empty;
|
|
1333
|
-
const s = document.createElement("div");
|
|
1334
|
-
s.setAttribute("data-node-type", "blockGroup");
|
|
1335
|
-
let i = !1;
|
|
1336
|
-
for (const d of Array.from(e.childNodes))
|
|
1337
|
-
d.tagName !== "SUMMARY" && (d.nodeType === 3 && !((u = d.textContent) != null && u.trim()) || (i = !0, s.appendChild(d.cloneNode(!0))));
|
|
1338
|
-
const c = t.nodes[n].create({}, a);
|
|
1339
|
-
if (!i)
|
|
1340
|
-
return c.content;
|
|
1341
|
-
const l = o.parse(s, {
|
|
1342
|
-
topNode: t.nodes.blockGroup.create()
|
|
1343
|
-
});
|
|
1344
|
-
return l.content.size > 0 ? c.content.addToEnd(l) : c.content;
|
|
1345
|
-
}
|
|
1346
|
-
const Qt = {
|
|
1347
|
-
set: (e, t) => window.localStorage.setItem(
|
|
1348
|
-
`toggle-${e.id}`,
|
|
1349
|
-
t ? "true" : "false"
|
|
1350
|
-
),
|
|
1351
|
-
get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
|
|
1352
|
-
}, Ne = (e, t, n, o = Qt) => {
|
|
1353
|
-
if ("isToggleable" in e.props && !e.props.isToggleable)
|
|
1354
|
-
return {
|
|
1355
|
-
dom: n
|
|
1356
|
-
};
|
|
1357
|
-
const r = document.createElement("div"), a = document.createElement("div");
|
|
1358
|
-
a.className = "bn-toggle-wrapper";
|
|
1359
|
-
const s = document.createElement("button");
|
|
1360
|
-
s.className = "bn-toggle-button", s.type = "button", s.innerHTML = // https://fonts.google.com/icons?selected=Material+Symbols+Rounded:chevron_right:FILL@0;wght@700;GRAD@0;opsz@24&icon.query=chevron&icon.style=Rounded&icon.size=24&icon.color=%23e8eaed
|
|
1361
|
-
'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';
|
|
1362
|
-
const i = (f) => f.preventDefault();
|
|
1363
|
-
s.addEventListener("mousedown", i);
|
|
1364
|
-
const c = () => {
|
|
1365
|
-
var f;
|
|
1366
|
-
a.getAttribute("data-show-children") === "true" ? (a.setAttribute("data-show-children", "false"), o.set(t.getBlock(e), !1), r.contains(l) && r.removeChild(l)) : (a.setAttribute("data-show-children", "true"), o.set(t.getBlock(e), !0), t.isEditable && ((f = t.getBlock(e)) == null ? void 0 : f.children.length) === 0 && !r.contains(l) && r.appendChild(l));
|
|
1367
|
-
};
|
|
1368
|
-
s.addEventListener("click", c), a.appendChild(s), a.appendChild(n);
|
|
1369
|
-
const l = document.createElement("button");
|
|
1370
|
-
l.className = "bn-toggle-add-block-button", l.type = "button", l.textContent = t.dictionary.toggle_blocks.add_block_button;
|
|
1371
|
-
const u = (f) => f.preventDefault();
|
|
1372
|
-
l.addEventListener(
|
|
1373
|
-
"mousedown",
|
|
1374
|
-
u
|
|
1375
|
-
);
|
|
1376
|
-
const d = () => {
|
|
1377
|
-
t.transact(() => {
|
|
1378
|
-
const f = t.updateBlock(e, {
|
|
1379
|
-
// Single empty block with default type.
|
|
1380
|
-
children: [{}]
|
|
1381
|
-
});
|
|
1382
|
-
t.setTextCursorPosition(f.children[0].id, "end"), t.focus();
|
|
1383
|
-
});
|
|
1384
|
-
};
|
|
1385
|
-
l.addEventListener("click", d), r.appendChild(a);
|
|
1386
|
-
let p = e.children.length;
|
|
1387
|
-
const h = t.onChange(() => {
|
|
1388
|
-
var E;
|
|
1389
|
-
const f = ((E = t.getBlock(e)) == null ? void 0 : E.children.length) ?? 0;
|
|
1390
|
-
f > p ? (a.getAttribute("data-show-children") === "false" && (a.setAttribute("data-show-children", "true"), o.set(t.getBlock(e), !0)), r.contains(l) && r.removeChild(l)) : f === 0 && f < p && (a.getAttribute("data-show-children") === "true" && (a.setAttribute("data-show-children", "false"), o.set(t.getBlock(e), !1)), r.contains(l) && r.removeChild(l)), p = f;
|
|
1391
|
-
});
|
|
1392
|
-
return o.get(e) ? (a.setAttribute("data-show-children", "true"), t.isEditable && e.children.length === 0 && r.appendChild(l)) : a.setAttribute("data-show-children", "false"), {
|
|
1393
|
-
dom: r,
|
|
1394
|
-
// Prevents re-renders when the toggle button is clicked.
|
|
1395
|
-
ignoreMutation: (f) => f instanceof MutationRecord && // We want to prevent re-renders when the view changes, so we ignore
|
|
1396
|
-
// all mutations where the `data-show-children` attribute is changed
|
|
1397
|
-
// or the "add block" button is added/removed.
|
|
1398
|
-
(f.type === "attributes" && f.target === a && f.attributeName === "data-show-children" || f.type === "childList" && (f.addedNodes[0] === l || f.removedNodes[0] === l)),
|
|
1399
|
-
destroy: () => {
|
|
1400
|
-
s.removeEventListener("mousedown", i), s.removeEventListener("click", c), l.removeEventListener(
|
|
1401
|
-
"mousedown",
|
|
1402
|
-
u
|
|
1403
|
-
), l.removeEventListener(
|
|
1404
|
-
"click",
|
|
1405
|
-
d
|
|
1406
|
-
), h == null || h();
|
|
1407
|
-
}
|
|
1408
|
-
};
|
|
1409
|
-
}, Pe = [1, 2, 3, 4, 5, 6], Jt = (e) => ({ editor: t }) => {
|
|
1410
|
-
const n = t.getTextCursorPosition();
|
|
1411
|
-
return t.schema.blockSchema[n.block.type].content !== "inline" ? !1 : (t.updateBlock(n.block, {
|
|
1412
|
-
type: "heading",
|
|
1413
|
-
props: { level: e }
|
|
1414
|
-
}), !0);
|
|
1415
|
-
}, Yt = ({
|
|
1416
|
-
defaultLevel: e = 1,
|
|
1417
|
-
levels: t = Pe,
|
|
1418
|
-
allowToggleHeadings: n = !0
|
|
1419
|
-
} = {}) => ({
|
|
1420
|
-
type: "heading",
|
|
1421
|
-
propSchema: {
|
|
1422
|
-
...m,
|
|
1423
|
-
level: { default: e, values: t },
|
|
1424
|
-
...n ? { isToggleable: { default: !1, optional: !0 } } : {}
|
|
1425
|
-
},
|
|
1426
|
-
content: "inline"
|
|
1427
|
-
}), en = v(
|
|
1428
|
-
Yt,
|
|
1429
|
-
({ allowToggleHeadings: e = !0 } = {}) => ({
|
|
1430
|
-
meta: {
|
|
1431
|
-
isolating: !1
|
|
1432
|
-
},
|
|
1433
|
-
parse(t) {
|
|
1434
|
-
if (e && t.tagName === "DETAILS") {
|
|
1435
|
-
const o = t.querySelector(":scope > summary");
|
|
1436
|
-
if (!o)
|
|
1437
|
-
return;
|
|
1438
|
-
const r = o.querySelector("h1, h2, h3, h4, h5, h6");
|
|
1439
|
-
return r ? {
|
|
1440
|
-
...C(r),
|
|
1441
|
-
level: parseInt(r.tagName[1]),
|
|
1442
|
-
isToggleable: !0
|
|
1443
|
-
} : void 0;
|
|
1444
|
-
}
|
|
1445
|
-
let n;
|
|
1446
|
-
switch (t.tagName) {
|
|
1447
|
-
case "H1":
|
|
1448
|
-
n = 1;
|
|
1449
|
-
break;
|
|
1450
|
-
case "H2":
|
|
1451
|
-
n = 2;
|
|
1452
|
-
break;
|
|
1453
|
-
case "H3":
|
|
1454
|
-
n = 3;
|
|
1455
|
-
break;
|
|
1456
|
-
case "H4":
|
|
1457
|
-
n = 4;
|
|
1458
|
-
break;
|
|
1459
|
-
case "H5":
|
|
1460
|
-
n = 5;
|
|
1461
|
-
break;
|
|
1462
|
-
case "H6":
|
|
1463
|
-
n = 6;
|
|
1464
|
-
break;
|
|
1465
|
-
default:
|
|
1466
|
-
return;
|
|
1467
|
-
}
|
|
1468
|
-
return {
|
|
1469
|
-
...C(t),
|
|
1470
|
-
level: n
|
|
1471
|
-
};
|
|
1472
|
-
},
|
|
1473
|
-
...e ? {
|
|
1474
|
-
parseContent: ({ el: t, schema: n }) => {
|
|
1475
|
-
if (t.tagName === "DETAILS")
|
|
1476
|
-
return Ae(t, n, "heading");
|
|
1477
|
-
}
|
|
1478
|
-
} : {},
|
|
1479
|
-
runsBefore: ["toggleListItem"],
|
|
1480
|
-
render(t, n) {
|
|
1481
|
-
const o = document.createElement(`h${t.props.level}`);
|
|
1482
|
-
return e ? { ...Ne(t, n, o), contentDOM: o } : {
|
|
1483
|
-
dom: o,
|
|
1484
|
-
contentDOM: o
|
|
1485
|
-
};
|
|
1486
|
-
},
|
|
1487
|
-
toExternalHTML(t) {
|
|
1488
|
-
const n = document.createElement(`h${t.props.level}`);
|
|
1489
|
-
if (A(t.props, n), e && t.props.isToggleable) {
|
|
1490
|
-
const o = document.createElement("details");
|
|
1491
|
-
o.setAttribute("open", "");
|
|
1492
|
-
const r = document.createElement("summary");
|
|
1493
|
-
return r.appendChild(n), o.appendChild(r), {
|
|
1494
|
-
dom: o,
|
|
1495
|
-
contentDOM: n,
|
|
1496
|
-
childrenDOM: o
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
return {
|
|
1500
|
-
dom: n,
|
|
1501
|
-
contentDOM: n
|
|
1502
|
-
};
|
|
1503
|
-
}
|
|
1504
|
-
}),
|
|
1505
|
-
({ levels: e = Pe } = {}) => [
|
|
1506
|
-
y({
|
|
1507
|
-
key: "heading-shortcuts",
|
|
1508
|
-
keyboardShortcuts: Object.fromEntries(
|
|
1509
|
-
e.map((t) => [
|
|
1510
|
-
`Mod-Alt-${t}`,
|
|
1511
|
-
Jt(t)
|
|
1512
|
-
]) ?? []
|
|
1513
|
-
),
|
|
1514
|
-
inputRules: e.map((t) => ({
|
|
1515
|
-
find: new RegExp(`^(#{${t}})\\s$`),
|
|
1516
|
-
replace({ match: n }) {
|
|
1517
|
-
return {
|
|
1518
|
-
type: "heading",
|
|
1519
|
-
props: {
|
|
1520
|
-
level: n[1].length
|
|
1521
|
-
}
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
}))
|
|
1525
|
-
})
|
|
1526
|
-
]
|
|
1527
|
-
), Ie = (e, t, n, o, r) => {
|
|
1528
|
-
const { dom: a, destroy: s } = J(
|
|
1529
|
-
e,
|
|
1530
|
-
t,
|
|
1531
|
-
n,
|
|
1532
|
-
r
|
|
1533
|
-
), i = a;
|
|
1534
|
-
i.style.position = "relative", e.props.url && e.props.showPreview && (e.props.previewWidth ? i.style.width = `${e.props.previewWidth}px` : i.style.width = "fit-content");
|
|
1535
|
-
const c = document.createElement("div");
|
|
1536
|
-
c.className = "bn-resize-handle", c.style.left = "4px";
|
|
1537
|
-
const l = document.createElement("div");
|
|
1538
|
-
l.className = "bn-resize-handle", l.style.right = "4px";
|
|
1539
|
-
const u = document.createElement("div");
|
|
1540
|
-
u.style.position = "absolute", u.style.height = "100%", u.style.width = "100%";
|
|
1541
|
-
let d, p = e.props.previewWidth;
|
|
1542
|
-
const h = (g) => {
|
|
1543
|
-
var te, ne;
|
|
1544
|
-
if (!d) {
|
|
1545
|
-
!t.isEditable && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l));
|
|
1546
|
-
return;
|
|
1547
|
-
}
|
|
1548
|
-
let M;
|
|
1549
|
-
const V = "touches" in g ? g.touches[0].clientX : g.clientX;
|
|
1550
|
-
e.props.textAlignment === "center" ? d.handleUsed === "left" ? M = d.initialWidth + (d.initialClientX - V) * 2 : M = d.initialWidth + (V - d.initialClientX) * 2 : d.handleUsed === "left" ? M = d.initialWidth + d.initialClientX - V : M = d.initialWidth + V - d.initialClientX, p = Math.min(
|
|
1551
|
-
Math.max(M, 64),
|
|
1552
|
-
((ne = (te = t.domElement) == null ? void 0 : te.firstElementChild) == null ? void 0 : ne.clientWidth) || Number.MAX_VALUE
|
|
1553
|
-
), i.style.width = `${p}px`;
|
|
1554
|
-
}, f = (g) => {
|
|
1555
|
-
(!g.target || !i.contains(g.target) || !t.isEditable) && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l)), d && (d = void 0, i.contains(u) && i.removeChild(u), t.updateBlock(e, {
|
|
1556
|
-
props: {
|
|
1557
|
-
previewWidth: p
|
|
1558
|
-
}
|
|
1559
|
-
}));
|
|
1560
|
-
}, E = () => {
|
|
1561
|
-
t.isEditable && (o.appendChild(c), o.appendChild(l));
|
|
1562
|
-
}, x = (g) => {
|
|
1563
|
-
g.relatedTarget === c || g.relatedTarget === l || d || t.isEditable && o.contains(c) && o.contains(l) && (o.removeChild(c), o.removeChild(l));
|
|
1564
|
-
}, S = (g) => {
|
|
1565
|
-
g.preventDefault(), i.contains(u) || i.appendChild(u);
|
|
1566
|
-
const M = "touches" in g ? g.touches[0].clientX : g.clientX;
|
|
1567
|
-
d = {
|
|
1568
|
-
handleUsed: "left",
|
|
1569
|
-
initialWidth: i.clientWidth,
|
|
1570
|
-
initialClientX: M
|
|
1571
|
-
};
|
|
1572
|
-
}, N = (g) => {
|
|
1573
|
-
g.preventDefault(), i.contains(u) || i.appendChild(u);
|
|
1574
|
-
const M = "touches" in g ? g.touches[0].clientX : g.clientX;
|
|
1575
|
-
d = {
|
|
1576
|
-
handleUsed: "right",
|
|
1577
|
-
initialWidth: i.clientWidth,
|
|
1578
|
-
initialClientX: M
|
|
1579
|
-
};
|
|
1580
|
-
};
|
|
1581
|
-
return window.addEventListener("mousemove", h), window.addEventListener("touchmove", h), window.addEventListener("mouseup", f), window.addEventListener("touchend", f), i.addEventListener("mouseenter", E), i.addEventListener("mouseleave", x), c.addEventListener(
|
|
1582
|
-
"mousedown",
|
|
1583
|
-
S
|
|
1584
|
-
), c.addEventListener(
|
|
1585
|
-
"touchstart",
|
|
1586
|
-
S
|
|
1587
|
-
), l.addEventListener(
|
|
1588
|
-
"mousedown",
|
|
1589
|
-
N
|
|
1590
|
-
), l.addEventListener(
|
|
1591
|
-
"touchstart",
|
|
1592
|
-
N
|
|
1593
|
-
), {
|
|
1594
|
-
dom: i,
|
|
1595
|
-
destroy: () => {
|
|
1596
|
-
s == null || s(), window.removeEventListener("mousemove", h), window.removeEventListener("touchmove", h), window.removeEventListener("mouseup", f), window.removeEventListener("touchend", f), i.removeEventListener("mouseenter", E), i.removeEventListener("mouseleave", x), c.removeEventListener(
|
|
1597
|
-
"mousedown",
|
|
1598
|
-
S
|
|
1599
|
-
), c.removeEventListener(
|
|
1600
|
-
"touchstart",
|
|
1601
|
-
S
|
|
1602
|
-
), l.removeEventListener(
|
|
1603
|
-
"mousedown",
|
|
1604
|
-
N
|
|
1605
|
-
), l.removeEventListener(
|
|
1606
|
-
"touchstart",
|
|
1607
|
-
N
|
|
1608
|
-
);
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
}, he = (e) => {
|
|
1612
|
-
const t = e.src || void 0, n = e.width || void 0, o = e.alt || void 0;
|
|
1613
|
-
return { url: t, previewWidth: n, name: o };
|
|
1614
|
-
}, tn = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>', nn = (e = {}) => ({
|
|
1615
|
-
type: "image",
|
|
1616
|
-
propSchema: {
|
|
1617
|
-
textAlignment: m.textAlignment,
|
|
1618
|
-
backgroundColor: m.backgroundColor,
|
|
1619
|
-
// File name.
|
|
1620
|
-
name: {
|
|
1621
|
-
default: ""
|
|
1622
|
-
},
|
|
1623
|
-
// File url.
|
|
1624
|
-
url: {
|
|
1625
|
-
default: ""
|
|
1626
|
-
},
|
|
1627
|
-
// File caption.
|
|
1628
|
-
caption: {
|
|
1629
|
-
default: ""
|
|
1630
|
-
},
|
|
1631
|
-
showPreview: {
|
|
1632
|
-
default: !0
|
|
1633
|
-
},
|
|
1634
|
-
// File preview width in px.
|
|
1635
|
-
previewWidth: {
|
|
1636
|
-
default: void 0,
|
|
1637
|
-
type: "number"
|
|
1638
|
-
}
|
|
1639
|
-
},
|
|
1640
|
-
content: "none"
|
|
1641
|
-
}), on = (e = {}) => (t) => {
|
|
1642
|
-
if (t.tagName === "IMG") {
|
|
1643
|
-
if (t.closest("figure"))
|
|
1644
|
-
return;
|
|
1645
|
-
const { backgroundColor: n } = C(t);
|
|
1646
|
-
return {
|
|
1647
|
-
...he(t),
|
|
1648
|
-
backgroundColor: n
|
|
1649
|
-
};
|
|
1650
|
-
}
|
|
1651
|
-
if (t.tagName === "FIGURE") {
|
|
1652
|
-
const n = $(t, "img");
|
|
1653
|
-
if (!n)
|
|
1654
|
-
return;
|
|
1655
|
-
const { targetElement: o, caption: r } = n, { backgroundColor: a } = C(t);
|
|
1656
|
-
return {
|
|
1657
|
-
...he(o),
|
|
1658
|
-
backgroundColor: a,
|
|
1659
|
-
caption: r
|
|
1660
|
-
};
|
|
1661
|
-
}
|
|
1662
|
-
}, rn = (e = {}) => (t, n) => {
|
|
1663
|
-
const o = document.createElement("div");
|
|
1664
|
-
o.innerHTML = e.icon ?? tn;
|
|
1665
|
-
const r = document.createElement("div");
|
|
1666
|
-
r.className = "bn-visual-media-wrapper";
|
|
1667
|
-
const a = document.createElement("img");
|
|
1668
|
-
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((s) => {
|
|
1669
|
-
a.src = s;
|
|
1670
|
-
}) : a.src = t.props.url, a.alt = t.props.name || t.props.caption || "BlockNote image", a.contentEditable = "false", a.draggable = !1, r.appendChild(a), Ie(
|
|
1671
|
-
t,
|
|
1672
|
-
n,
|
|
1673
|
-
{ dom: r },
|
|
1674
|
-
r,
|
|
1675
|
-
o.firstElementChild
|
|
1676
|
-
);
|
|
1677
|
-
}, an = (e = {}) => (t, n) => {
|
|
1678
|
-
if (!t.props.url) {
|
|
1679
|
-
const r = document.createElement("p");
|
|
1680
|
-
return r.textContent = "Add image", {
|
|
1681
|
-
dom: r
|
|
1682
|
-
};
|
|
1683
|
-
}
|
|
1684
|
-
let o;
|
|
1685
|
-
return t.props.showPreview ? (o = document.createElement("img"), o.src = t.props.url, o.alt = t.props.name || t.props.caption || "BlockNote image", t.props.previewWidth && (o.width = t.props.previewWidth)) : (o = document.createElement("a"), o.href = t.props.url, o.textContent = t.props.name || t.props.url), t.props.caption ? t.props.showPreview ? Y(o, t.props.caption) : U(o, t.props.caption) : {
|
|
1686
|
-
dom: o
|
|
1687
|
-
};
|
|
1688
|
-
}, sn = v(
|
|
1689
|
-
nn,
|
|
1690
|
-
(e) => ({
|
|
1691
|
-
meta: {
|
|
1692
|
-
fileBlockAccept: ["image/*"]
|
|
1693
|
-
},
|
|
1694
|
-
parse: on(e),
|
|
1695
|
-
render: rn(e),
|
|
1696
|
-
toExternalHTML: an(e),
|
|
1697
|
-
runsBefore: ["file"]
|
|
1698
|
-
})
|
|
1699
|
-
), wo = (e, t, n) => ({
|
|
1700
|
-
state: o,
|
|
1701
|
-
dispatch: r
|
|
1702
|
-
}) => r ? He(o.tr, e, t, n) : !0, He = (e, t, n, o) => {
|
|
1703
|
-
const r = ot(e.doc, t), a = G(r);
|
|
1704
|
-
if (!a.isBlockContainer)
|
|
1705
|
-
return !1;
|
|
1706
|
-
const s = O(e), i = [
|
|
1707
|
-
{
|
|
1708
|
-
type: a.bnBlock.node.type,
|
|
1709
|
-
// always keep blockcontainer type
|
|
1710
|
-
attrs: o ? { ...a.bnBlock.node.attrs, id: void 0 } : {}
|
|
1711
|
-
},
|
|
1712
|
-
{
|
|
1713
|
-
type: n ? a.blockContent.node.type : s.nodes.paragraph,
|
|
1714
|
-
attrs: o ? { ...a.blockContent.node.attrs } : {}
|
|
1715
|
-
}
|
|
1716
|
-
];
|
|
1717
|
-
return e.split(t, 2, i), !0;
|
|
1718
|
-
}, q = (e, t) => {
|
|
1719
|
-
const { blockInfo: n, selectionEmpty: o } = e.transact((s) => ({
|
|
1720
|
-
blockInfo: rt(s),
|
|
1721
|
-
selectionEmpty: s.selection.anchor === s.selection.head
|
|
1722
|
-
}));
|
|
1723
|
-
if (!n.isBlockContainer)
|
|
1724
|
-
return !1;
|
|
1725
|
-
const { bnBlock: r, blockContent: a } = n;
|
|
1726
|
-
return a.node.type.name !== t || !o ? !1 : a.node.childCount === 0 ? (e.transact((s) => {
|
|
1727
|
-
Q(s, r.beforePos, {
|
|
1728
|
-
type: "paragraph",
|
|
1729
|
-
props: {}
|
|
1730
|
-
});
|
|
1731
|
-
}), !0) : a.node.childCount > 0 ? e.transact((s) => (s.deleteSelection(), He(s, s.selection.from, !0))) : !1;
|
|
1732
|
-
};
|
|
1733
|
-
function ee(e, t, n) {
|
|
1734
|
-
var d, p, h;
|
|
1735
|
-
const o = K.fromSchema(t), r = e, a = document.createElement("div");
|
|
1736
|
-
a.setAttribute("data-node-type", "blockGroup");
|
|
1737
|
-
for (const f of Array.from(r.childNodes))
|
|
1738
|
-
a.appendChild(f.cloneNode(!0));
|
|
1739
|
-
let s = o.parse(a, {
|
|
1740
|
-
topNode: t.nodes.blockGroup.create()
|
|
1741
|
-
});
|
|
1742
|
-
((p = (d = s.firstChild) == null ? void 0 : d.firstChild) == null ? void 0 : p.type.name) === "checkListItem" && (s = s.copy(
|
|
1743
|
-
s.content.cut(
|
|
1744
|
-
s.firstChild.firstChild.nodeSize + 2
|
|
1745
|
-
)
|
|
1746
|
-
));
|
|
1747
|
-
const i = (h = s.firstChild) == null ? void 0 : h.firstChild;
|
|
1748
|
-
if (!(i != null && i.isTextblock))
|
|
1749
|
-
return _.from(s);
|
|
1750
|
-
const c = t.nodes[n].create(
|
|
1751
|
-
{},
|
|
1752
|
-
i.content
|
|
1753
|
-
), l = s.content.cut(
|
|
1754
|
-
// +2 for the `blockGroup` node's start and end markers
|
|
1755
|
-
i.nodeSize + 2
|
|
1756
|
-
);
|
|
1757
|
-
if (l.size > 0) {
|
|
1758
|
-
const f = s.copy(l);
|
|
1759
|
-
return c.content.addToEnd(f);
|
|
1760
|
-
}
|
|
1761
|
-
return c.content;
|
|
1762
|
-
}
|
|
1763
|
-
const cn = () => ({
|
|
1764
|
-
type: "bulletListItem",
|
|
1765
|
-
propSchema: {
|
|
1766
|
-
...m
|
|
1767
|
-
},
|
|
1768
|
-
content: "inline"
|
|
1769
|
-
}), ln = v(
|
|
1770
|
-
cn,
|
|
1771
|
-
{
|
|
1772
|
-
meta: {
|
|
1773
|
-
isolating: !1
|
|
1774
|
-
},
|
|
1775
|
-
parse(e) {
|
|
1776
|
-
var n;
|
|
1777
|
-
if (e.tagName !== "LI")
|
|
1778
|
-
return;
|
|
1779
|
-
const t = e.parentElement;
|
|
1780
|
-
if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && ((n = t.parentElement) == null ? void 0 : n.tagName) === "UL"))
|
|
1781
|
-
return C(e);
|
|
1782
|
-
},
|
|
1783
|
-
// As `li` elements can contain multiple paragraphs, we need to merge their contents
|
|
1784
|
-
// into a single one so that ProseMirror can parse everything correctly.
|
|
1785
|
-
parseContent: ({ el: e, schema: t }) => ee(e, t, "bulletListItem"),
|
|
1786
|
-
render() {
|
|
1787
|
-
const e = document.createElement("p");
|
|
1788
|
-
return {
|
|
1789
|
-
dom: e,
|
|
1790
|
-
contentDOM: e
|
|
1791
|
-
};
|
|
1792
|
-
},
|
|
1793
|
-
toExternalHTML(e) {
|
|
1794
|
-
const t = document.createElement("li"), n = document.createElement("p");
|
|
1795
|
-
return A(e.props, t), t.appendChild(n), {
|
|
1796
|
-
dom: t,
|
|
1797
|
-
contentDOM: n
|
|
1798
|
-
};
|
|
1799
|
-
}
|
|
1800
|
-
},
|
|
1801
|
-
[
|
|
1802
|
-
y({
|
|
1803
|
-
key: "bullet-list-item-shortcuts",
|
|
1804
|
-
keyboardShortcuts: {
|
|
1805
|
-
Enter: ({ editor: e }) => q(e, "bulletListItem"),
|
|
1806
|
-
"Mod-Shift-8": ({ editor: e }) => {
|
|
1807
|
-
const t = e.getTextCursorPosition();
|
|
1808
|
-
return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
|
|
1809
|
-
type: "bulletListItem",
|
|
1810
|
-
props: {}
|
|
1811
|
-
}), !0);
|
|
1812
|
-
}
|
|
1813
|
-
},
|
|
1814
|
-
inputRules: [
|
|
1815
|
-
{
|
|
1816
|
-
find: /^\s?[-+*]\s$/,
|
|
1817
|
-
replace({ editor: e }) {
|
|
1818
|
-
if (Se(
|
|
1819
|
-
e.prosemirrorState
|
|
1820
|
-
).blockNoteType !== "heading")
|
|
1821
|
-
return {
|
|
1822
|
-
type: "bulletListItem",
|
|
1823
|
-
props: {}
|
|
1824
|
-
};
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
]
|
|
1828
|
-
})
|
|
1829
|
-
]
|
|
1830
|
-
), dn = () => ({
|
|
1831
|
-
type: "checkListItem",
|
|
1832
|
-
propSchema: {
|
|
1833
|
-
...m,
|
|
1834
|
-
checked: { default: !1, type: "boolean" }
|
|
1835
|
-
},
|
|
1836
|
-
content: "inline"
|
|
1837
|
-
}), un = v(
|
|
1838
|
-
dn,
|
|
1839
|
-
{
|
|
1840
|
-
meta: {
|
|
1841
|
-
isolating: !1
|
|
1842
|
-
},
|
|
1843
|
-
parse(e) {
|
|
1844
|
-
var n;
|
|
1845
|
-
if (e.tagName === "input")
|
|
1846
|
-
return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
|
|
1847
|
-
if (e.tagName !== "LI")
|
|
1848
|
-
return;
|
|
1849
|
-
const t = e.parentElement;
|
|
1850
|
-
if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && ((n = t.parentElement) == null ? void 0 : n.tagName) === "UL")) {
|
|
1851
|
-
const o = e.querySelector("input[type=checkbox]") || null;
|
|
1852
|
-
return o === null ? void 0 : { ...C(e), checked: o.checked };
|
|
1853
|
-
}
|
|
1854
|
-
},
|
|
1855
|
-
// As `li` elements can contain multiple paragraphs, we need to merge their contents
|
|
1856
|
-
// into a single one so that ProseMirror can parse everything correctly.
|
|
1857
|
-
parseContent: ({ el: e, schema: t }) => ee(e, t, "checkListItem"),
|
|
1858
|
-
render(e, t) {
|
|
1859
|
-
const n = document.createDocumentFragment(), o = document.createElement("input");
|
|
1860
|
-
o.type = "checkbox", o.checked = e.props.checked, e.props.checked && o.setAttribute("checked", ""), o.disabled = !t.isEditable, o.addEventListener("change", () => {
|
|
1861
|
-
t.isEditable && t.updateBlock(e, { props: { checked: !e.props.checked } });
|
|
1862
|
-
});
|
|
1863
|
-
const r = document.createElement("p"), a = document.createElement("div");
|
|
1864
|
-
return a.contentEditable = "false", a.appendChild(o), n.appendChild(a), n.appendChild(r), {
|
|
1865
|
-
dom: n,
|
|
1866
|
-
contentDOM: r
|
|
1867
|
-
};
|
|
1868
|
-
},
|
|
1869
|
-
toExternalHTML(e) {
|
|
1870
|
-
const t = document.createElement("li"), n = document.createElement("input");
|
|
1871
|
-
n.type = "checkbox", n.checked = e.props.checked, e.props.checked && n.setAttribute("checked", "");
|
|
1872
|
-
const o = document.createElement("p");
|
|
1873
|
-
return A(e.props, t), t.appendChild(n), t.appendChild(o), {
|
|
1874
|
-
dom: t,
|
|
1875
|
-
contentDOM: o
|
|
1876
|
-
};
|
|
1877
|
-
},
|
|
1878
|
-
runsBefore: ["bulletListItem"]
|
|
1879
|
-
},
|
|
1880
|
-
[
|
|
1881
|
-
y({
|
|
1882
|
-
key: "check-list-item-shortcuts",
|
|
1883
|
-
keyboardShortcuts: {
|
|
1884
|
-
Enter: ({ editor: e }) => q(e, "checkListItem"),
|
|
1885
|
-
"Mod-Shift-9": ({ editor: e }) => {
|
|
1886
|
-
const t = e.getTextCursorPosition();
|
|
1887
|
-
return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
|
|
1888
|
-
type: "checkListItem",
|
|
1889
|
-
props: {}
|
|
1890
|
-
}), !0);
|
|
1891
|
-
}
|
|
1892
|
-
},
|
|
1893
|
-
inputRules: [
|
|
1894
|
-
{
|
|
1895
|
-
find: /^\s?\[\s*\]\s$/,
|
|
1896
|
-
replace() {
|
|
1897
|
-
return {
|
|
1898
|
-
type: "checkListItem",
|
|
1899
|
-
props: {
|
|
1900
|
-
checked: !1
|
|
1901
|
-
}
|
|
1902
|
-
};
|
|
1903
|
-
}
|
|
1904
|
-
},
|
|
1905
|
-
{
|
|
1906
|
-
find: /^\s?\[[Xx]\]\s$/,
|
|
1907
|
-
replace() {
|
|
1908
|
-
return {
|
|
1909
|
-
type: "checkListItem",
|
|
1910
|
-
props: {
|
|
1911
|
-
checked: !0
|
|
1912
|
-
}
|
|
1913
|
-
};
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
]
|
|
1917
|
-
})
|
|
1918
|
-
]
|
|
1919
|
-
);
|
|
1920
|
-
function De(e, t, n, o) {
|
|
1921
|
-
let r = e.firstChild.attrs.start || 1, a = !0;
|
|
1922
|
-
const s = !!e.firstChild.attrs.start, i = G({
|
|
1923
|
-
posBeforeNode: t,
|
|
1924
|
-
node: e
|
|
1925
|
-
});
|
|
1926
|
-
if (!i.isBlockContainer)
|
|
1927
|
-
throw new Error("impossible");
|
|
1928
|
-
const c = n.doc.resolve(i.bnBlock.beforePos).nodeBefore, l = c ? o.get(c) : void 0;
|
|
1929
|
-
return l !== void 0 ? (r = l + 1, a = !1) : c && G({
|
|
1930
|
-
posBeforeNode: i.bnBlock.beforePos - c.nodeSize,
|
|
1931
|
-
node: c
|
|
1932
|
-
}).blockNoteType === "numberedListItem" && (r = De(
|
|
1933
|
-
c,
|
|
1934
|
-
i.bnBlock.beforePos - c.nodeSize,
|
|
1935
|
-
n,
|
|
1936
|
-
o
|
|
1937
|
-
).index + 1, a = !1), o.set(e, r), { index: r, isFirst: a, hasStart: s };
|
|
1938
|
-
}
|
|
1939
|
-
function ge(e, t) {
|
|
1940
|
-
const n = /* @__PURE__ */ new Map(), o = t.decorations.map(
|
|
1941
|
-
e.mapping,
|
|
1942
|
-
e.doc
|
|
1943
|
-
), r = [];
|
|
1944
|
-
e.doc.nodesBetween(0, e.doc.nodeSize - 2, (s, i) => {
|
|
1945
|
-
if (s.type.name === "blockContainer" && s.firstChild.type.name === "numberedListItem") {
|
|
1946
|
-
const { index: c, isFirst: l, hasStart: u } = De(
|
|
1947
|
-
s,
|
|
1948
|
-
i,
|
|
1949
|
-
e,
|
|
1950
|
-
n
|
|
1951
|
-
);
|
|
1952
|
-
if (o.find(
|
|
1953
|
-
i,
|
|
1954
|
-
i + s.nodeSize,
|
|
1955
|
-
(p) => p.index === c && p.isFirst === l && p.hasStart === u
|
|
1956
|
-
).length === 0) {
|
|
1957
|
-
const p = e.doc.nodeAt(i + 1);
|
|
1958
|
-
r.push(
|
|
1959
|
-
// move in by 1 to account for the block container
|
|
1960
|
-
gt.node(i + 1, i + 1 + p.nodeSize, {
|
|
1961
|
-
"data-index": c.toString()
|
|
1962
|
-
})
|
|
1963
|
-
);
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
});
|
|
1967
|
-
const a = r.flatMap(
|
|
1968
|
-
(s) => o.find(s.from, s.to)
|
|
1969
|
-
);
|
|
1970
|
-
return {
|
|
1971
|
-
decorations: o.remove(a).add(e.doc, r)
|
|
1972
|
-
};
|
|
1973
|
-
}
|
|
1974
|
-
const pn = () => new mt({
|
|
1975
|
-
key: new ht("numbered-list-indexing-decorations"),
|
|
1976
|
-
state: {
|
|
1977
|
-
init(e, t) {
|
|
1978
|
-
return ge(t.tr, {
|
|
1979
|
-
decorations: le.empty
|
|
1980
|
-
});
|
|
1981
|
-
},
|
|
1982
|
-
apply(e, t) {
|
|
1983
|
-
return !e.docChanged && !e.selectionSet && t.decorations ? t : ge(e, t);
|
|
1984
|
-
}
|
|
1985
|
-
},
|
|
1986
|
-
props: {
|
|
1987
|
-
decorations(e) {
|
|
1988
|
-
var t;
|
|
1989
|
-
return ((t = this.getState(e)) == null ? void 0 : t.decorations) ?? le.empty;
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
}), fn = () => ({
|
|
1993
|
-
type: "numberedListItem",
|
|
1994
|
-
propSchema: {
|
|
1995
|
-
...m,
|
|
1996
|
-
start: { default: void 0, type: "number" }
|
|
1997
|
-
},
|
|
1998
|
-
content: "inline"
|
|
1999
|
-
}), mn = v(
|
|
2000
|
-
fn,
|
|
2001
|
-
{
|
|
2002
|
-
meta: {
|
|
2003
|
-
isolating: !1
|
|
2004
|
-
},
|
|
2005
|
-
parse(e) {
|
|
2006
|
-
var n;
|
|
2007
|
-
if (e.tagName !== "LI")
|
|
2008
|
-
return;
|
|
2009
|
-
const t = e.parentElement;
|
|
2010
|
-
if (t !== null && (t.tagName === "OL" || t.tagName === "DIV" && ((n = t.parentElement) == null ? void 0 : n.tagName) === "OL")) {
|
|
2011
|
-
const o = parseInt(t.getAttribute("start") || "1"), r = C(e);
|
|
2012
|
-
return e.previousElementSibling || o === 1 ? r : {
|
|
2013
|
-
...r,
|
|
2014
|
-
start: o
|
|
2015
|
-
};
|
|
2016
|
-
}
|
|
2017
|
-
},
|
|
2018
|
-
// As `li` elements can contain multiple paragraphs, we need to merge their contents
|
|
2019
|
-
// into a single one so that ProseMirror can parse everything correctly.
|
|
2020
|
-
parseContent: ({ el: e, schema: t }) => ee(e, t, "numberedListItem"),
|
|
2021
|
-
render() {
|
|
2022
|
-
const e = document.createElement("p");
|
|
2023
|
-
return {
|
|
2024
|
-
dom: e,
|
|
2025
|
-
contentDOM: e
|
|
2026
|
-
};
|
|
2027
|
-
},
|
|
2028
|
-
toExternalHTML(e) {
|
|
2029
|
-
const t = document.createElement("li"), n = document.createElement("p");
|
|
2030
|
-
return A(e.props, t), t.appendChild(n), {
|
|
2031
|
-
dom: t,
|
|
2032
|
-
contentDOM: n
|
|
2033
|
-
};
|
|
2034
|
-
}
|
|
2035
|
-
},
|
|
2036
|
-
[
|
|
2037
|
-
y({
|
|
2038
|
-
key: "numbered-list-item-shortcuts",
|
|
2039
|
-
inputRules: [
|
|
2040
|
-
{
|
|
2041
|
-
find: /^\s?(\d+)\.\s$/,
|
|
2042
|
-
replace({ match: e, editor: t }) {
|
|
2043
|
-
if (Se(
|
|
2044
|
-
t.prosemirrorState
|
|
2045
|
-
).blockNoteType === "heading")
|
|
2046
|
-
return;
|
|
2047
|
-
const o = parseInt(e[1]);
|
|
2048
|
-
return {
|
|
2049
|
-
type: "numberedListItem",
|
|
2050
|
-
props: {
|
|
2051
|
-
start: o !== 1 ? o : void 0
|
|
2052
|
-
}
|
|
2053
|
-
};
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
],
|
|
2057
|
-
keyboardShortcuts: {
|
|
2058
|
-
Enter: ({ editor: e }) => q(e, "numberedListItem"),
|
|
2059
|
-
"Mod-Shift-7": ({ editor: e }) => {
|
|
2060
|
-
const t = e.getTextCursorPosition();
|
|
2061
|
-
return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
|
|
2062
|
-
type: "numberedListItem",
|
|
2063
|
-
props: {}
|
|
2064
|
-
}), !0);
|
|
2065
|
-
}
|
|
2066
|
-
},
|
|
2067
|
-
prosemirrorPlugins: [pn()]
|
|
2068
|
-
})
|
|
2069
|
-
]
|
|
2070
|
-
), hn = () => ({
|
|
2071
|
-
type: "toggleListItem",
|
|
2072
|
-
propSchema: {
|
|
2073
|
-
...m
|
|
2074
|
-
},
|
|
2075
|
-
content: "inline"
|
|
2076
|
-
}), gn = v(
|
|
2077
|
-
hn,
|
|
2078
|
-
{
|
|
2079
|
-
meta: {
|
|
2080
|
-
isolating: !1
|
|
2081
|
-
},
|
|
2082
|
-
parse(e) {
|
|
2083
|
-
var t;
|
|
2084
|
-
if (e.tagName === "DETAILS")
|
|
2085
|
-
return C(e);
|
|
2086
|
-
if (e.tagName === "LI") {
|
|
2087
|
-
const n = e.parentElement;
|
|
2088
|
-
if (n && (n.tagName === "UL" || n.tagName === "DIV" && ((t = n.parentElement) == null ? void 0 : t.tagName) === "UL") && e.querySelector(":scope > details"))
|
|
2089
|
-
return C(e);
|
|
2090
|
-
}
|
|
2091
|
-
},
|
|
2092
|
-
parseContent: ({ el: e, schema: t }) => {
|
|
2093
|
-
const n = e.tagName === "DETAILS" ? e : e.querySelector(":scope > details");
|
|
2094
|
-
if (!n)
|
|
2095
|
-
throw new Error("No details found in toggleListItem parseContent");
|
|
2096
|
-
return Ae(
|
|
2097
|
-
n,
|
|
2098
|
-
t,
|
|
2099
|
-
"toggleListItem"
|
|
2100
|
-
);
|
|
2101
|
-
},
|
|
2102
|
-
runsBefore: ["bulletListItem"],
|
|
2103
|
-
render(e, t) {
|
|
2104
|
-
const n = document.createElement("p");
|
|
2105
|
-
return { ...Ne(
|
|
2106
|
-
e,
|
|
2107
|
-
t,
|
|
2108
|
-
n
|
|
2109
|
-
), contentDOM: n };
|
|
2110
|
-
},
|
|
2111
|
-
toExternalHTML(e) {
|
|
2112
|
-
const t = document.createElement("li"), n = document.createElement("details");
|
|
2113
|
-
n.setAttribute("open", "");
|
|
2114
|
-
const o = document.createElement("summary"), r = document.createElement("p");
|
|
2115
|
-
return o.appendChild(r), n.appendChild(o), A(e.props, t), t.appendChild(n), {
|
|
2116
|
-
dom: t,
|
|
2117
|
-
contentDOM: r,
|
|
2118
|
-
childrenDOM: n
|
|
2119
|
-
};
|
|
2120
|
-
}
|
|
2121
|
-
},
|
|
2122
|
-
[
|
|
2123
|
-
y({
|
|
2124
|
-
key: "toggle-list-item-shortcuts",
|
|
2125
|
-
keyboardShortcuts: {
|
|
2126
|
-
Enter: ({ editor: e }) => q(e, "toggleListItem"),
|
|
2127
|
-
"Mod-Shift-6": ({ editor: e }) => {
|
|
2128
|
-
const t = e.getTextCursorPosition();
|
|
2129
|
-
return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
|
|
2130
|
-
type: "toggleListItem",
|
|
2131
|
-
props: {}
|
|
2132
|
-
}), !0);
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
})
|
|
2136
|
-
]
|
|
2137
|
-
), bn = () => ({
|
|
2138
|
-
type: "paragraph",
|
|
2139
|
-
propSchema: m,
|
|
2140
|
-
content: "inline"
|
|
2141
|
-
}), Cn = v(
|
|
2142
|
-
bn,
|
|
2143
|
-
{
|
|
2144
|
-
meta: {
|
|
2145
|
-
isolating: !1
|
|
2146
|
-
},
|
|
2147
|
-
parse: (e) => {
|
|
2148
|
-
var t;
|
|
2149
|
-
if (e.tagName === "P" && (t = e.textContent) != null && t.trim())
|
|
2150
|
-
return C(e);
|
|
2151
|
-
},
|
|
2152
|
-
render: () => {
|
|
2153
|
-
const e = document.createElement("p");
|
|
2154
|
-
return {
|
|
2155
|
-
dom: e,
|
|
2156
|
-
contentDOM: e
|
|
2157
|
-
};
|
|
2158
|
-
},
|
|
2159
|
-
toExternalHTML: (e) => {
|
|
2160
|
-
const t = document.createElement("p");
|
|
2161
|
-
return A(e.props, t), {
|
|
2162
|
-
dom: t,
|
|
2163
|
-
contentDOM: t
|
|
2164
|
-
};
|
|
2165
|
-
},
|
|
2166
|
-
runsBefore: ["default", "heading"]
|
|
2167
|
-
},
|
|
2168
|
-
[
|
|
2169
|
-
y({
|
|
2170
|
-
key: "paragraph-shortcuts",
|
|
2171
|
-
keyboardShortcuts: {
|
|
2172
|
-
"Mod-Alt-0": ({ editor: e }) => {
|
|
2173
|
-
const t = e.getTextCursorPosition();
|
|
2174
|
-
return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
|
|
2175
|
-
type: "paragraph",
|
|
2176
|
-
props: {}
|
|
2177
|
-
}), !0);
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
})
|
|
2181
|
-
]
|
|
2182
|
-
), kn = () => ({
|
|
2183
|
-
type: "quote",
|
|
2184
|
-
propSchema: {
|
|
2185
|
-
backgroundColor: m.backgroundColor,
|
|
2186
|
-
textColor: m.textColor
|
|
2187
|
-
},
|
|
2188
|
-
content: "inline"
|
|
2189
|
-
}), yn = v(
|
|
2190
|
-
kn,
|
|
2191
|
-
{
|
|
2192
|
-
meta: {
|
|
2193
|
-
isolating: !1
|
|
2194
|
-
},
|
|
2195
|
-
parse(e) {
|
|
2196
|
-
if (e.tagName === "BLOCKQUOTE") {
|
|
2197
|
-
const { backgroundColor: t, textColor: n } = C(e);
|
|
2198
|
-
return { backgroundColor: t, textColor: n };
|
|
2199
|
-
}
|
|
2200
|
-
},
|
|
2201
|
-
render() {
|
|
2202
|
-
const e = document.createElement("blockquote");
|
|
2203
|
-
return {
|
|
2204
|
-
dom: e,
|
|
2205
|
-
contentDOM: e
|
|
2206
|
-
};
|
|
2207
|
-
},
|
|
2208
|
-
toExternalHTML(e) {
|
|
2209
|
-
const t = document.createElement("blockquote");
|
|
2210
|
-
return A(e.props, t), {
|
|
2211
|
-
dom: t,
|
|
2212
|
-
contentDOM: t
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2215
|
-
},
|
|
2216
|
-
[
|
|
2217
|
-
y({
|
|
2218
|
-
key: "quote-block-shortcuts",
|
|
2219
|
-
keyboardShortcuts: {
|
|
2220
|
-
"Mod-Alt-q": ({ editor: e }) => {
|
|
2221
|
-
const t = e.getTextCursorPosition();
|
|
2222
|
-
return e.schema.blockSchema[t.block.type].content !== "inline" ? !1 : (e.updateBlock(t.block, {
|
|
2223
|
-
type: "quote",
|
|
2224
|
-
props: {}
|
|
2225
|
-
}), !0);
|
|
2226
|
-
}
|
|
2227
|
-
},
|
|
2228
|
-
inputRules: [
|
|
2229
|
-
{
|
|
2230
|
-
find: new RegExp("^>\\s$"),
|
|
2231
|
-
replace() {
|
|
2232
|
-
return {
|
|
2233
|
-
type: "quote",
|
|
2234
|
-
props: {}
|
|
2235
|
-
};
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
]
|
|
2239
|
-
})
|
|
2240
|
-
]
|
|
2241
|
-
), vn = 35, Oe = 120, Lo = 31, En = qe.create({
|
|
2242
|
-
name: "BlockNoteTableExtension",
|
|
2243
|
-
addProseMirrorPlugins: () => [
|
|
2244
|
-
Re({
|
|
2245
|
-
cellMinWidth: vn,
|
|
2246
|
-
defaultCellMinWidth: Oe,
|
|
2247
|
-
// We set this to null as we implement our own node view in the table
|
|
2248
|
-
// block content. This node view is the same as what's used by default,
|
|
2249
|
-
// but is wrapped in a `blockContent` HTML element.
|
|
2250
|
-
View: null
|
|
2251
|
-
}),
|
|
2252
|
-
Fe()
|
|
2253
|
-
],
|
|
2254
|
-
addKeyboardShortcuts() {
|
|
2255
|
-
return {
|
|
2256
|
-
// Makes enter create a new line within the cell.
|
|
2257
|
-
Enter: () => this.editor.state.selection.empty && this.editor.state.selection.$head.parent.type.name === "tableParagraph" ? (this.editor.commands.insertContent({ type: "hardBreak" }), !0) : !1,
|
|
2258
|
-
// Ensures that backspace won't delete the table if the text cursor is at
|
|
2259
|
-
// the start of a cell and the selection is empty.
|
|
2260
|
-
Backspace: () => {
|
|
2261
|
-
const e = this.editor.state.selection, t = e.empty, n = e.$head.parentOffset === 0, o = e.$head.node().type.name === "tableParagraph";
|
|
2262
|
-
return t && n && o;
|
|
2263
|
-
},
|
|
2264
|
-
// Enables navigating cells using the tab key.
|
|
2265
|
-
Tab: () => this.editor.commands.command(
|
|
2266
|
-
({ state: e, dispatch: t, view: n }) => oe(1)(e, t, n)
|
|
2267
|
-
),
|
|
2268
|
-
"Shift-Tab": () => this.editor.commands.command(
|
|
2269
|
-
({ state: e, dispatch: t, view: n }) => oe(-1)(e, t, n)
|
|
2270
|
-
)
|
|
2271
|
-
};
|
|
2272
|
-
},
|
|
2273
|
-
extendNodeSchema(e) {
|
|
2274
|
-
const t = {
|
|
2275
|
-
name: e.name,
|
|
2276
|
-
options: e.options,
|
|
2277
|
-
storage: e.storage
|
|
2278
|
-
};
|
|
2279
|
-
return {
|
|
2280
|
-
tableRole: je(
|
|
2281
|
-
Ge(e, "tableRole", t)
|
|
2282
|
-
)
|
|
2283
|
-
};
|
|
2284
|
-
}
|
|
2285
|
-
}), Sn = {
|
|
2286
|
-
textColor: m.textColor
|
|
2287
|
-
}, xn = P.create({
|
|
2288
|
-
name: "tableHeader",
|
|
2289
|
-
addOptions() {
|
|
2290
|
-
return {
|
|
2291
|
-
HTMLAttributes: {}
|
|
2292
|
-
};
|
|
2293
|
-
},
|
|
2294
|
-
/**
|
|
2295
|
-
* We allow table headers and cells to have multiple tableContent nodes because
|
|
2296
|
-
* when merging cells, prosemirror-tables will concat the contents of the cells naively.
|
|
2297
|
-
* This would cause that content to overflow into other cells when prosemirror tries to enforce the cell structure.
|
|
2298
|
-
*
|
|
2299
|
-
* So, we manually fix this up when reading back in the `nodeToBlock` and only ever place a single tableContent back into the cell.
|
|
2300
|
-
*/
|
|
2301
|
-
content: "tableContent+",
|
|
2302
|
-
addAttributes() {
|
|
2303
|
-
return {
|
|
2304
|
-
colspan: {
|
|
2305
|
-
default: 1
|
|
2306
|
-
},
|
|
2307
|
-
rowspan: {
|
|
2308
|
-
default: 1
|
|
2309
|
-
},
|
|
2310
|
-
colwidth: {
|
|
2311
|
-
default: null,
|
|
2312
|
-
parseHTML: (e) => {
|
|
2313
|
-
const t = e.getAttribute("colwidth");
|
|
2314
|
-
return t ? t.split(",").map((o) => parseInt(o, 10)) : null;
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
};
|
|
2318
|
-
},
|
|
2319
|
-
tableRole: "header_cell",
|
|
2320
|
-
isolating: !0,
|
|
2321
|
-
parseHTML() {
|
|
2322
|
-
return [
|
|
2323
|
-
{
|
|
2324
|
-
tag: "th",
|
|
2325
|
-
// As `th` elements can contain multiple paragraphs, we need to merge their contents
|
|
2326
|
-
// into a single one so that ProseMirror can parse everything correctly.
|
|
2327
|
-
getContent: (e, t) => _e(e, t)
|
|
2328
|
-
}
|
|
2329
|
-
];
|
|
2330
|
-
},
|
|
2331
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
2332
|
-
return [
|
|
2333
|
-
"th",
|
|
2334
|
-
Z(this.options.HTMLAttributes, e),
|
|
2335
|
-
0
|
|
2336
|
-
];
|
|
2337
|
-
}
|
|
2338
|
-
}), Mn = P.create({
|
|
2339
|
-
name: "tableCell",
|
|
2340
|
-
addOptions() {
|
|
2341
|
-
return {
|
|
2342
|
-
HTMLAttributes: {}
|
|
2343
|
-
};
|
|
2344
|
-
},
|
|
2345
|
-
content: "tableContent+",
|
|
2346
|
-
addAttributes() {
|
|
2347
|
-
return {
|
|
2348
|
-
colspan: {
|
|
2349
|
-
default: 1
|
|
2350
|
-
},
|
|
2351
|
-
rowspan: {
|
|
2352
|
-
default: 1
|
|
2353
|
-
},
|
|
2354
|
-
colwidth: {
|
|
2355
|
-
default: null,
|
|
2356
|
-
parseHTML: (e) => {
|
|
2357
|
-
const t = e.getAttribute("colwidth");
|
|
2358
|
-
return t ? t.split(",").map((o) => parseInt(o, 10)) : null;
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
};
|
|
2362
|
-
},
|
|
2363
|
-
tableRole: "cell",
|
|
2364
|
-
isolating: !0,
|
|
2365
|
-
parseHTML() {
|
|
2366
|
-
return [
|
|
2367
|
-
{
|
|
2368
|
-
tag: "td",
|
|
2369
|
-
// As `td` elements can contain multiple paragraphs, we need to merge their contents
|
|
2370
|
-
// into a single one so that ProseMirror can parse everything correctly.
|
|
2371
|
-
getContent: (e, t) => _e(e, t)
|
|
2372
|
-
}
|
|
2373
|
-
];
|
|
2374
|
-
},
|
|
2375
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
2376
|
-
return [
|
|
2377
|
-
"td",
|
|
2378
|
-
Z(this.options.HTMLAttributes, e),
|
|
2379
|
-
0
|
|
2380
|
-
];
|
|
2381
|
-
}
|
|
2382
|
-
}), wn = P.create({
|
|
2383
|
-
name: "table",
|
|
2384
|
-
content: "tableRow+",
|
|
2385
|
-
group: "blockContent",
|
|
2386
|
-
tableRole: "table",
|
|
2387
|
-
marks: "deletion insertion modification",
|
|
2388
|
-
isolating: !0,
|
|
2389
|
-
parseHTML() {
|
|
2390
|
-
return [
|
|
2391
|
-
{
|
|
2392
|
-
tag: "table"
|
|
2393
|
-
}
|
|
2394
|
-
];
|
|
2395
|
-
},
|
|
2396
|
-
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2397
|
-
var r, a, s;
|
|
2398
|
-
const n = Ct(
|
|
2399
|
-
this.name,
|
|
2400
|
-
"table",
|
|
2401
|
-
{
|
|
2402
|
-
...((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {},
|
|
2403
|
-
...t
|
|
2404
|
-
},
|
|
2405
|
-
((a = this.options.domAttributes) == null ? void 0 : a.inlineContent) || {}
|
|
2406
|
-
), o = document.createElement("colgroup");
|
|
2407
|
-
for (const i of e.children[0].children)
|
|
2408
|
-
if (i.attrs.colwidth)
|
|
2409
|
-
for (const l of i.attrs.colwidth) {
|
|
2410
|
-
const u = document.createElement("col");
|
|
2411
|
-
l && (u.style = `width: ${l}px`), o.appendChild(u);
|
|
2412
|
-
}
|
|
2413
|
-
else
|
|
2414
|
-
o.appendChild(document.createElement("col"));
|
|
2415
|
-
return (s = n.dom.firstChild) == null || s.appendChild(o), n;
|
|
2416
|
-
},
|
|
2417
|
-
// This node view is needed for the `columnResizing` plugin. By default, the
|
|
2418
|
-
// plugin adds its own node view, which overrides how the node is rendered vs
|
|
2419
|
-
// `renderHTML`. This means that the wrapping `blockContent` HTML element is
|
|
2420
|
-
// no longer rendered. The `columnResizing` plugin uses the `TableView` as its
|
|
2421
|
-
// default node view. `BlockNoteTableView` extends it by wrapping it in a
|
|
2422
|
-
// `blockContent` element, so the DOM structure is consistent with other block
|
|
2423
|
-
// types.
|
|
2424
|
-
addNodeView() {
|
|
2425
|
-
return ({ node: e, HTMLAttributes: t }) => {
|
|
2426
|
-
var o;
|
|
2427
|
-
class n extends $e {
|
|
2428
|
-
constructor(a, s, i) {
|
|
2429
|
-
super(a, s), this.node = a, this.cellMinWidth = s, this.blockContentHTMLAttributes = i;
|
|
2430
|
-
const c = document.createElement("div");
|
|
2431
|
-
c.className = D(
|
|
2432
|
-
"bn-block-content",
|
|
2433
|
-
i.class
|
|
2434
|
-
), c.setAttribute("data-content-type", "table");
|
|
2435
|
-
for (const [p, h] of Object.entries(
|
|
2436
|
-
i
|
|
2437
|
-
))
|
|
2438
|
-
p !== "class" && c.setAttribute(p, h);
|
|
2439
|
-
const l = this.dom, u = document.createElement("div");
|
|
2440
|
-
u.className = "tableWrapper-inner", u.appendChild(l.firstChild), l.appendChild(u), c.appendChild(l);
|
|
2441
|
-
const d = document.createElement("div");
|
|
2442
|
-
d.className = "table-widgets-container", d.style.position = "relative", l.appendChild(d), this.dom = c;
|
|
2443
|
-
}
|
|
2444
|
-
ignoreMutation(a) {
|
|
2445
|
-
return !a.target.closest(".tableWrapper-inner") || super.ignoreMutation(a);
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
return new n(e, Oe, {
|
|
2449
|
-
...((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {},
|
|
2450
|
-
...t
|
|
2451
|
-
});
|
|
2452
|
-
};
|
|
2453
|
-
}
|
|
2454
|
-
}), Ln = P.create({
|
|
2455
|
-
name: "tableParagraph",
|
|
2456
|
-
group: "tableContent",
|
|
2457
|
-
content: "inline*",
|
|
2458
|
-
parseHTML() {
|
|
2459
|
-
return [
|
|
2460
|
-
{
|
|
2461
|
-
tag: "p",
|
|
2462
|
-
getAttrs: (e) => {
|
|
2463
|
-
if (typeof e == "string" || !e.textContent || !e.closest("[data-content-type]"))
|
|
2464
|
-
return !1;
|
|
2465
|
-
const t = e.parentElement;
|
|
2466
|
-
return t === null ? !1 : t.tagName === "TD" || t.tagName === "TH" ? {} : !1;
|
|
2467
|
-
},
|
|
2468
|
-
node: "tableParagraph"
|
|
2469
|
-
}
|
|
2470
|
-
];
|
|
2471
|
-
},
|
|
2472
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
2473
|
-
return ["p", e, 0];
|
|
2474
|
-
}
|
|
2475
|
-
}), Tn = P.create({
|
|
2476
|
-
name: "tableRow",
|
|
2477
|
-
addOptions() {
|
|
2478
|
-
return {
|
|
2479
|
-
HTMLAttributes: {}
|
|
2480
|
-
};
|
|
2481
|
-
},
|
|
2482
|
-
content: "(tableCell | tableHeader)+",
|
|
2483
|
-
tableRole: "row",
|
|
2484
|
-
marks: "deletion insertion modification",
|
|
2485
|
-
parseHTML() {
|
|
2486
|
-
return [{ tag: "tr" }];
|
|
2487
|
-
},
|
|
2488
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
2489
|
-
return [
|
|
2490
|
-
"tr",
|
|
2491
|
-
Z(this.options.HTMLAttributes, e),
|
|
2492
|
-
0
|
|
2493
|
-
];
|
|
2494
|
-
}
|
|
2495
|
-
});
|
|
2496
|
-
function _e(e, t) {
|
|
2497
|
-
const o = K.fromSchema(t).parse(e, {
|
|
2498
|
-
topNode: t.nodes.blockGroup.create()
|
|
2499
|
-
}), r = [];
|
|
2500
|
-
return o.content.descendants((a) => {
|
|
2501
|
-
if (a.isInline)
|
|
2502
|
-
return r.push(a), !1;
|
|
2503
|
-
}), _.fromArray(r);
|
|
2504
|
-
}
|
|
2505
|
-
const Bn = () => vt(
|
|
2506
|
-
{ node: wn, type: "table", content: "table" },
|
|
2507
|
-
Sn,
|
|
2508
|
-
[
|
|
2509
|
-
y({
|
|
2510
|
-
key: "table-extensions",
|
|
2511
|
-
tiptapExtensions: [
|
|
2512
|
-
En,
|
|
2513
|
-
Ln,
|
|
2514
|
-
xn,
|
|
2515
|
-
Mn,
|
|
2516
|
-
Tn
|
|
2517
|
-
]
|
|
2518
|
-
}),
|
|
2519
|
-
// Extension for keyboard shortcut which deletes the table if it's empty
|
|
2520
|
-
// and all cells are selected. Uses a separate extension as it needs
|
|
2521
|
-
// priority over keyboard handlers in the `TableExtension`'s
|
|
2522
|
-
// `tableEditing` plugin.
|
|
2523
|
-
y({
|
|
2524
|
-
key: "table-keyboard-delete",
|
|
2525
|
-
keyboardShortcuts: {
|
|
2526
|
-
Backspace: ({ editor: e }) => {
|
|
2527
|
-
if (!(e.prosemirrorState.selection instanceof ke))
|
|
2528
|
-
return !1;
|
|
2529
|
-
const t = e.getTextCursorPosition().block, n = t.content;
|
|
2530
|
-
let o = 0;
|
|
2531
|
-
for (const a of n.rows)
|
|
2532
|
-
for (const s of a.cells) {
|
|
2533
|
-
if ("type" in s && s.content.length > 0 || !("type" in s) && s.length > 0)
|
|
2534
|
-
return !1;
|
|
2535
|
-
o++;
|
|
2536
|
-
}
|
|
2537
|
-
let r = 0;
|
|
2538
|
-
return e.prosemirrorState.selection.forEachCell(() => {
|
|
2539
|
-
r++;
|
|
2540
|
-
}), r < o ? !1 : (e.transact(() => {
|
|
2541
|
-
(e.getPrevBlock(t) || e.getNextBlock(t)) && e.setTextCursorPosition(t), e.removeBlocks([t]);
|
|
2542
|
-
}), !0);
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
|
-
})
|
|
2546
|
-
]
|
|
2547
|
-
), be = (e) => {
|
|
2548
|
-
const t = e.src || void 0, n = e.width || void 0;
|
|
2549
|
-
return { url: t, previewWidth: n };
|
|
2550
|
-
}, An = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>', Nn = (e) => ({
|
|
2551
|
-
type: "video",
|
|
2552
|
-
propSchema: {
|
|
2553
|
-
textAlignment: m.textAlignment,
|
|
2554
|
-
backgroundColor: m.backgroundColor,
|
|
2555
|
-
name: { default: "" },
|
|
2556
|
-
url: { default: "" },
|
|
2557
|
-
caption: { default: "" },
|
|
2558
|
-
showPreview: { default: !0 },
|
|
2559
|
-
previewWidth: { default: void 0, type: "number" }
|
|
2560
|
-
},
|
|
2561
|
-
content: "none"
|
|
2562
|
-
}), Pn = (e) => (t) => {
|
|
2563
|
-
if (t.tagName === "VIDEO") {
|
|
2564
|
-
if (t.closest("figure"))
|
|
2565
|
-
return;
|
|
2566
|
-
const { backgroundColor: n } = C(t);
|
|
2567
|
-
return {
|
|
2568
|
-
...be(t),
|
|
2569
|
-
backgroundColor: n
|
|
2570
|
-
};
|
|
2571
|
-
}
|
|
2572
|
-
if (t.tagName === "FIGURE") {
|
|
2573
|
-
const n = $(t, "video");
|
|
2574
|
-
if (!n)
|
|
2575
|
-
return;
|
|
2576
|
-
const { targetElement: o, caption: r } = n, { backgroundColor: a } = C(t);
|
|
2577
|
-
return {
|
|
2578
|
-
...be(o),
|
|
2579
|
-
backgroundColor: a,
|
|
2580
|
-
caption: r
|
|
2581
|
-
};
|
|
2582
|
-
}
|
|
2583
|
-
}, In = v(
|
|
2584
|
-
Nn,
|
|
2585
|
-
(e) => ({
|
|
2586
|
-
meta: {
|
|
2587
|
-
fileBlockAccept: ["video/*"]
|
|
2588
|
-
},
|
|
2589
|
-
parse: Pn(),
|
|
2590
|
-
render(t, n) {
|
|
2591
|
-
const o = document.createElement("div");
|
|
2592
|
-
o.innerHTML = e.icon ?? An;
|
|
2593
|
-
const r = document.createElement("div");
|
|
2594
|
-
r.className = "bn-visual-media-wrapper";
|
|
2595
|
-
const a = document.createElement("video");
|
|
2596
|
-
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((s) => {
|
|
2597
|
-
a.src = s;
|
|
2598
|
-
}) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, a.width = t.props.previewWidth, r.appendChild(a), Ie(
|
|
2599
|
-
t,
|
|
2600
|
-
n,
|
|
2601
|
-
{ dom: r },
|
|
2602
|
-
r,
|
|
2603
|
-
o.firstElementChild
|
|
2604
|
-
);
|
|
2605
|
-
},
|
|
2606
|
-
toExternalHTML(t) {
|
|
2607
|
-
if (!t.props.url) {
|
|
2608
|
-
const o = document.createElement("p");
|
|
2609
|
-
return o.textContent = "Add video", {
|
|
2610
|
-
dom: o
|
|
2611
|
-
};
|
|
2612
|
-
}
|
|
2613
|
-
let n;
|
|
2614
|
-
return t.props.showPreview ? (n = document.createElement("video"), n.src = t.props.url, t.props.previewWidth && (n.width = t.props.previewWidth)) : (n = document.createElement("a"), n.href = t.props.url, n.textContent = t.props.name || t.props.url), t.props.caption ? t.props.showPreview ? Y(n, t.props.caption) : U(n, t.props.caption) : {
|
|
2615
|
-
dom: n
|
|
2616
|
-
};
|
|
2617
|
-
},
|
|
2618
|
-
runsBefore: ["file"]
|
|
2619
|
-
})
|
|
2620
|
-
);
|
|
2621
|
-
function b(e, t, n) {
|
|
2622
|
-
if (!(t in e.schema.blockSpecs))
|
|
2623
|
-
return !1;
|
|
2624
|
-
if (!n)
|
|
2625
|
-
return !0;
|
|
2626
|
-
for (const [o, r] of Object.entries(n)) {
|
|
2627
|
-
if (!(o in e.schema.blockSpecs[t].config.propSchema))
|
|
2628
|
-
return !1;
|
|
2629
|
-
if (typeof r == "string") {
|
|
2630
|
-
if (e.schema.blockSpecs[t].config.propSchema[o].default !== void 0 && typeof e.schema.blockSpecs[t].config.propSchema[o].default !== r || e.schema.blockSpecs[t].config.propSchema[o].type !== void 0 && e.schema.blockSpecs[t].config.propSchema[o].type !== r)
|
|
2631
|
-
return !1;
|
|
2632
|
-
} else {
|
|
2633
|
-
if (e.schema.blockSpecs[t].config.propSchema[o].default !== r.default || e.schema.blockSpecs[t].config.propSchema[o].default === void 0 && r.default === void 0 && e.schema.blockSpecs[t].config.propSchema[o].type !== r.type || typeof e.schema.blockSpecs[t].config.propSchema[o].values != typeof r.values)
|
|
2634
|
-
return !1;
|
|
2635
|
-
if (typeof e.schema.blockSpecs[t].config.propSchema[o].values == "object" && typeof r.values == "object") {
|
|
2636
|
-
for (const a of r.values)
|
|
2637
|
-
if (!e.schema.blockSpecs[t].config.propSchema[o].values.includes(a))
|
|
2638
|
-
return !1;
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
return !0;
|
|
2643
|
-
}
|
|
2644
|
-
function To(e, t, n, o) {
|
|
2645
|
-
return b(t, n, o) && e.type === n;
|
|
2646
|
-
}
|
|
2647
|
-
function Bo(e) {
|
|
2648
|
-
return e instanceof ke;
|
|
2649
|
-
}
|
|
2650
|
-
const R = /* @__PURE__ */ new Map();
|
|
2651
|
-
function Hn(e) {
|
|
2652
|
-
if (R.has(e))
|
|
2653
|
-
return R.get(e);
|
|
2654
|
-
const t = new Qe();
|
|
2655
|
-
return e._tiptapEditor.on("transaction", ({ transaction: n }) => {
|
|
2656
|
-
t.appendMapping(n.mapping);
|
|
2657
|
-
}), e._tiptapEditor.on("destroy", () => {
|
|
2658
|
-
R.delete(e);
|
|
2659
|
-
}), R.set(e, t), t;
|
|
2660
|
-
}
|
|
2661
|
-
function Dn(e, t, n = "left") {
|
|
2662
|
-
const o = se.getState(e.prosemirrorState);
|
|
2663
|
-
if (!o) {
|
|
2664
|
-
const a = Hn(e), s = a.maps.length;
|
|
2665
|
-
return () => a.slice(s).map(t, n === "left" ? -1 : 1);
|
|
2666
|
-
}
|
|
2667
|
-
const r = Je(
|
|
2668
|
-
// Track the position after the position if we are on the right side
|
|
2669
|
-
t + (n === "right" ? 1 : -1),
|
|
2670
|
-
o.binding.type,
|
|
2671
|
-
o.binding.mapping
|
|
2672
|
-
);
|
|
2673
|
-
return () => {
|
|
2674
|
-
const a = se.getState(
|
|
2675
|
-
e.prosemirrorState
|
|
2676
|
-
), s = Ye(
|
|
2677
|
-
a.doc,
|
|
2678
|
-
a.binding.type,
|
|
2679
|
-
r,
|
|
2680
|
-
a.binding.mapping
|
|
2681
|
-
);
|
|
2682
|
-
if (s === null)
|
|
2683
|
-
throw new Error("Position not found, cannot track positions");
|
|
2684
|
-
return s + (n === "right" ? -1 : 1);
|
|
2685
|
-
};
|
|
2686
|
-
}
|
|
2687
|
-
const On = ze((e) => e.type.name === "blockContainer");
|
|
2688
|
-
class _n {
|
|
2689
|
-
constructor(t, n, o) {
|
|
2690
|
-
w(this, "state");
|
|
2691
|
-
w(this, "emitUpdate");
|
|
2692
|
-
w(this, "rootEl");
|
|
2693
|
-
w(this, "pluginState");
|
|
2694
|
-
w(this, "handleScroll", () => {
|
|
2695
|
-
var t, n;
|
|
2696
|
-
if ((t = this.state) != null && t.show) {
|
|
2697
|
-
const o = (n = this.rootEl) == null ? void 0 : n.querySelector(
|
|
2698
|
-
`[data-decoration-id="${this.pluginState.decorationId}"]`
|
|
2699
|
-
);
|
|
2700
|
-
if (!o)
|
|
2701
|
-
return;
|
|
2702
|
-
this.state.referencePos = o.getBoundingClientRect().toJSON(), this.emitUpdate(this.pluginState.triggerCharacter);
|
|
2703
|
-
}
|
|
2704
|
-
});
|
|
2705
|
-
w(this, "closeMenu", () => {
|
|
2706
|
-
this.editor.transact((t) => t.setMeta(B, null));
|
|
2707
|
-
});
|
|
2708
|
-
w(this, "clearQuery", () => {
|
|
2709
|
-
this.pluginState !== void 0 && this.editor._tiptapEditor.chain().focus().deleteRange({
|
|
2710
|
-
from: this.pluginState.queryStartPos() - (this.pluginState.deleteTriggerCharacter ? this.pluginState.triggerCharacter.length : 0),
|
|
2711
|
-
to: this.editor.transact((t) => t.selection.from)
|
|
2712
|
-
}).run();
|
|
2713
|
-
});
|
|
2714
|
-
var r;
|
|
2715
|
-
this.editor = t, this.pluginState = void 0, this.emitUpdate = (a) => {
|
|
2716
|
-
var s;
|
|
2717
|
-
if (!this.state)
|
|
2718
|
-
throw new Error("Attempting to update uninitialized suggestions menu");
|
|
2719
|
-
n(a, {
|
|
2720
|
-
...this.state,
|
|
2721
|
-
ignoreQueryLength: (s = this.pluginState) == null ? void 0 : s.ignoreQueryLength
|
|
2722
|
-
});
|
|
2723
|
-
}, this.rootEl = o.root, (r = this.rootEl) == null || r.addEventListener("scroll", this.handleScroll, !0);
|
|
2724
|
-
}
|
|
2725
|
-
update(t, n) {
|
|
2726
|
-
var l;
|
|
2727
|
-
const o = B.getState(n), r = B.getState(
|
|
2728
|
-
t.state
|
|
2729
|
-
), a = o === void 0 && r !== void 0, s = o !== void 0 && r === void 0;
|
|
2730
|
-
if (!a && !(o !== void 0 && r !== void 0) && !s)
|
|
2731
|
-
return;
|
|
2732
|
-
if (this.pluginState = s ? o : r, s || !this.editor.isEditable) {
|
|
2733
|
-
this.state && (this.state.show = !1), this.emitUpdate(this.pluginState.triggerCharacter);
|
|
2734
|
-
return;
|
|
2735
|
-
}
|
|
2736
|
-
const c = (l = this.rootEl) == null ? void 0 : l.querySelector(
|
|
2737
|
-
`[data-decoration-id="${this.pluginState.decorationId}"]`
|
|
2738
|
-
);
|
|
2739
|
-
this.editor.isEditable && c && (this.state = {
|
|
2740
|
-
show: !0,
|
|
2741
|
-
referencePos: c.getBoundingClientRect().toJSON(),
|
|
2742
|
-
query: this.pluginState.query
|
|
2743
|
-
}, this.emitUpdate(this.pluginState.triggerCharacter));
|
|
2744
|
-
}
|
|
2745
|
-
destroy() {
|
|
2746
|
-
var t;
|
|
2747
|
-
(t = this.rootEl) == null || t.removeEventListener("scroll", this.handleScroll, !0);
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2750
|
-
const B = new Xe("SuggestionMenuPlugin"), Vn = y(({ editor: e }) => {
|
|
2751
|
-
const t = /* @__PURE__ */ new Map();
|
|
2752
|
-
let n;
|
|
2753
|
-
const o = ve(void 0);
|
|
2754
|
-
return {
|
|
2755
|
-
key: "suggestionMenu",
|
|
2756
|
-
store: o,
|
|
2757
|
-
addSuggestionMenu: (r) => {
|
|
2758
|
-
t.set(r.triggerCharacter, r);
|
|
2759
|
-
},
|
|
2760
|
-
removeSuggestionMenu: (r) => {
|
|
2761
|
-
t.delete(r);
|
|
2762
|
-
},
|
|
2763
|
-
closeMenu: () => {
|
|
2764
|
-
n == null || n.closeMenu();
|
|
2765
|
-
},
|
|
2766
|
-
clearQuery: () => {
|
|
2767
|
-
n == null || n.clearQuery();
|
|
2768
|
-
},
|
|
2769
|
-
shown: () => {
|
|
2770
|
-
var r;
|
|
2771
|
-
return ((r = n == null ? void 0 : n.state) == null ? void 0 : r.show) || !1;
|
|
2772
|
-
},
|
|
2773
|
-
openSuggestionMenu: (r, a) => {
|
|
2774
|
-
e.headless || (e.focus(), e.transact((s) => {
|
|
2775
|
-
a != null && a.deleteTriggerCharacter && s.insertText(r), s.scrollIntoView().setMeta(B, {
|
|
2776
|
-
triggerCharacter: r,
|
|
2777
|
-
deleteTriggerCharacter: (a == null ? void 0 : a.deleteTriggerCharacter) || !1,
|
|
2778
|
-
ignoreQueryLength: (a == null ? void 0 : a.ignoreQueryLength) || !1
|
|
2779
|
-
});
|
|
2780
|
-
}));
|
|
2781
|
-
},
|
|
2782
|
-
// TODO this whole plugin needs to be refactored (but I've done the minimal)
|
|
2783
|
-
prosemirrorPlugins: [
|
|
2784
|
-
new Ze({
|
|
2785
|
-
key: B,
|
|
2786
|
-
view: (r) => (n = new _n(
|
|
2787
|
-
e,
|
|
2788
|
-
(a, s) => {
|
|
2789
|
-
o.setState({ ...s, triggerCharacter: a });
|
|
2790
|
-
},
|
|
2791
|
-
r
|
|
2792
|
-
), n),
|
|
2793
|
-
state: {
|
|
2794
|
-
// Initialize the plugin's internal state.
|
|
2795
|
-
init() {
|
|
2796
|
-
},
|
|
2797
|
-
// Apply changes to the plugin state from an editor transaction.
|
|
2798
|
-
apply: (r, a, s, i) => {
|
|
2799
|
-
if (r.selection.$from.parent.type.spec.code)
|
|
2800
|
-
return a;
|
|
2801
|
-
const c = r.getMeta(B);
|
|
2802
|
-
if (typeof c == "object" && c !== null) {
|
|
2803
|
-
a && (n == null || n.closeMenu());
|
|
2804
|
-
const u = Dn(
|
|
2805
|
-
e,
|
|
2806
|
-
i.selection.from - // Need to account for the trigger char that was inserted, so we offset the position by the length of the trigger character.
|
|
2807
|
-
c.triggerCharacter.length
|
|
2808
|
-
);
|
|
2809
|
-
return {
|
|
2810
|
-
triggerCharacter: c.triggerCharacter,
|
|
2811
|
-
deleteTriggerCharacter: c.deleteTriggerCharacter !== !1,
|
|
2812
|
-
// When reading the queryStartPos, we offset the result by the length of the trigger character, to make it easy on the caller
|
|
2813
|
-
queryStartPos: () => u() + c.triggerCharacter.length,
|
|
2814
|
-
query: "",
|
|
2815
|
-
decorationId: `id_${Math.floor(Math.random() * 4294967295)}`,
|
|
2816
|
-
ignoreQueryLength: c == null ? void 0 : c.ignoreQueryLength
|
|
2817
|
-
};
|
|
2818
|
-
}
|
|
2819
|
-
if (a === void 0)
|
|
2820
|
-
return a;
|
|
2821
|
-
if (
|
|
2822
|
-
// Highlighting text should hide the menu.
|
|
2823
|
-
i.selection.from !== i.selection.to || // Transactions with plugin metadata should hide the menu.
|
|
2824
|
-
c === null || // Certain mouse events should hide the menu.
|
|
2825
|
-
// TODO: Change to global mousedown listener.
|
|
2826
|
-
r.getMeta("focus") || r.getMeta("blur") || r.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
2827
|
-
a.triggerCharacter !== void 0 && i.selection.from < a.queryStartPos() || // Moving the caret to a new block should hide the menu.
|
|
2828
|
-
!i.selection.$from.sameParent(
|
|
2829
|
-
i.doc.resolve(a.queryStartPos())
|
|
2830
|
-
)
|
|
2831
|
-
)
|
|
2832
|
-
return;
|
|
2833
|
-
const l = { ...a };
|
|
2834
|
-
return l.query = i.doc.textBetween(
|
|
2835
|
-
a.queryStartPos(),
|
|
2836
|
-
i.selection.from
|
|
2837
|
-
), l;
|
|
2838
|
-
}
|
|
2839
|
-
},
|
|
2840
|
-
props: {
|
|
2841
|
-
handleTextInput(r, a, s, i) {
|
|
2842
|
-
if (a === s) {
|
|
2843
|
-
const c = r.state.doc;
|
|
2844
|
-
for (const [l, u] of t) {
|
|
2845
|
-
const d = l.length > 1 ? c.textBetween(a - l.length, a) + i : i;
|
|
2846
|
-
if (l === d) {
|
|
2847
|
-
if (u.shouldOpen && !u.shouldOpen(r.state.tr))
|
|
2848
|
-
continue;
|
|
2849
|
-
return r.dispatch(r.state.tr.insertText(i)), r.dispatch(
|
|
2850
|
-
r.state.tr.setMeta(B, {
|
|
2851
|
-
triggerCharacter: d
|
|
2852
|
-
}).scrollIntoView()
|
|
2853
|
-
), !0;
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
return !1;
|
|
2858
|
-
},
|
|
2859
|
-
// Setup decorator on the currently active suggestion.
|
|
2860
|
-
decorations(r) {
|
|
2861
|
-
const a = this.getState(r);
|
|
2862
|
-
if (a === void 0)
|
|
2863
|
-
return null;
|
|
2864
|
-
if (!a.deleteTriggerCharacter) {
|
|
2865
|
-
const s = On(r.selection);
|
|
2866
|
-
if (s)
|
|
2867
|
-
return re.create(r.doc, [
|
|
2868
|
-
ae.node(
|
|
2869
|
-
s.pos,
|
|
2870
|
-
s.pos + s.node.nodeSize,
|
|
2871
|
-
{
|
|
2872
|
-
nodeName: "span",
|
|
2873
|
-
class: "bn-suggestion-decorator",
|
|
2874
|
-
"data-decoration-id": a.decorationId
|
|
2875
|
-
}
|
|
2876
|
-
)
|
|
2877
|
-
]);
|
|
2878
|
-
}
|
|
2879
|
-
return re.create(r.doc, [
|
|
2880
|
-
ae.inline(
|
|
2881
|
-
a.queryStartPos() - a.triggerCharacter.length,
|
|
2882
|
-
a.queryStartPos(),
|
|
2883
|
-
{
|
|
2884
|
-
nodeName: "span",
|
|
2885
|
-
class: "bn-suggestion-decorator",
|
|
2886
|
-
"data-decoration-id": a.decorationId
|
|
2887
|
-
}
|
|
2888
|
-
)
|
|
2889
|
-
]);
|
|
2890
|
-
}
|
|
2891
|
-
}
|
|
2892
|
-
})
|
|
2893
|
-
]
|
|
2894
|
-
};
|
|
2895
|
-
});
|
|
2896
|
-
function Wn(e) {
|
|
2897
|
-
let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
|
|
2898
|
-
for (; n === "none"; ) {
|
|
2899
|
-
if (t = e.getTextCursorPosition().nextBlock, t === void 0)
|
|
2900
|
-
return;
|
|
2901
|
-
n = e.schema.blockSchema[t.type].content, e.setTextCursorPosition(t, "end");
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
function k(e, t) {
|
|
2905
|
-
const n = e.getTextCursorPosition().block;
|
|
2906
|
-
if (n.content === void 0)
|
|
2907
|
-
throw new Error("Slash Menu open in a block that doesn't contain content.");
|
|
2908
|
-
let o;
|
|
2909
|
-
return Array.isArray(n.content) && (n.content.length === 1 && at(n.content[0]) && n.content[0].type === "text" && n.content[0].text === "/" || n.content.length === 0) ? (o = e.updateBlock(n, t), e.setTextCursorPosition(o)) : (o = e.insertBlocks([t], n, "after")[0], e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)), Wn(e), o;
|
|
2910
|
-
}
|
|
2911
|
-
function Ao(e) {
|
|
2912
|
-
const t = [];
|
|
2913
|
-
return b(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((n) => n <= 3).forEach((n) => {
|
|
2914
|
-
t.push({
|
|
2915
|
-
onItemClick: () => {
|
|
2916
|
-
k(e, {
|
|
2917
|
-
type: "heading",
|
|
2918
|
-
props: { level: n }
|
|
2919
|
-
});
|
|
2920
|
-
},
|
|
2921
|
-
badge: L(`Mod-Alt-${n}`),
|
|
2922
|
-
key: n === 1 ? "heading" : `heading_${n}`,
|
|
2923
|
-
...e.dictionary.slash_menu[n === 1 ? "heading" : `heading_${n}`]
|
|
2924
|
-
});
|
|
2925
|
-
}), b(e, "quote") && t.push({
|
|
2926
|
-
onItemClick: () => {
|
|
2927
|
-
k(e, {
|
|
2928
|
-
type: "quote"
|
|
2929
|
-
});
|
|
2930
|
-
},
|
|
2931
|
-
key: "quote",
|
|
2932
|
-
...e.dictionary.slash_menu.quote
|
|
2933
|
-
}), b(e, "toggleListItem") && t.push({
|
|
2934
|
-
onItemClick: () => {
|
|
2935
|
-
k(e, {
|
|
2936
|
-
type: "toggleListItem"
|
|
2937
|
-
});
|
|
2938
|
-
},
|
|
2939
|
-
badge: L("Mod-Shift-6"),
|
|
2940
|
-
key: "toggle_list",
|
|
2941
|
-
...e.dictionary.slash_menu.toggle_list
|
|
2942
|
-
}), b(e, "numberedListItem") && t.push({
|
|
2943
|
-
onItemClick: () => {
|
|
2944
|
-
k(e, {
|
|
2945
|
-
type: "numberedListItem"
|
|
2946
|
-
});
|
|
2947
|
-
},
|
|
2948
|
-
badge: L("Mod-Shift-7"),
|
|
2949
|
-
key: "numbered_list",
|
|
2950
|
-
...e.dictionary.slash_menu.numbered_list
|
|
2951
|
-
}), b(e, "bulletListItem") && t.push({
|
|
2952
|
-
onItemClick: () => {
|
|
2953
|
-
k(e, {
|
|
2954
|
-
type: "bulletListItem"
|
|
2955
|
-
});
|
|
2956
|
-
},
|
|
2957
|
-
badge: L("Mod-Shift-8"),
|
|
2958
|
-
key: "bullet_list",
|
|
2959
|
-
...e.dictionary.slash_menu.bullet_list
|
|
2960
|
-
}), b(e, "checkListItem") && t.push({
|
|
2961
|
-
onItemClick: () => {
|
|
2962
|
-
k(e, {
|
|
2963
|
-
type: "checkListItem"
|
|
2964
|
-
});
|
|
2965
|
-
},
|
|
2966
|
-
badge: L("Mod-Shift-9"),
|
|
2967
|
-
key: "check_list",
|
|
2968
|
-
...e.dictionary.slash_menu.check_list
|
|
2969
|
-
}), b(e, "paragraph") && t.push({
|
|
2970
|
-
onItemClick: () => {
|
|
2971
|
-
k(e, {
|
|
2972
|
-
type: "paragraph"
|
|
2973
|
-
});
|
|
2974
|
-
},
|
|
2975
|
-
badge: L("Mod-Alt-0"),
|
|
2976
|
-
key: "paragraph",
|
|
2977
|
-
...e.dictionary.slash_menu.paragraph
|
|
2978
|
-
}), b(e, "codeBlock") && t.push({
|
|
2979
|
-
onItemClick: () => {
|
|
2980
|
-
k(e, {
|
|
2981
|
-
type: "codeBlock"
|
|
2982
|
-
});
|
|
2983
|
-
},
|
|
2984
|
-
badge: L("Mod-Alt-c"),
|
|
2985
|
-
key: "code_block",
|
|
2986
|
-
...e.dictionary.slash_menu.code_block
|
|
2987
|
-
}), b(e, "divider") && t.push({
|
|
2988
|
-
onItemClick: () => {
|
|
2989
|
-
k(e, { type: "divider" });
|
|
2990
|
-
},
|
|
2991
|
-
key: "divider",
|
|
2992
|
-
...e.dictionary.slash_menu.divider
|
|
2993
|
-
}), b(e, "table") && t.push({
|
|
2994
|
-
onItemClick: () => {
|
|
2995
|
-
k(e, {
|
|
2996
|
-
type: "table",
|
|
2997
|
-
content: {
|
|
2998
|
-
type: "tableContent",
|
|
2999
|
-
rows: [
|
|
3000
|
-
{
|
|
3001
|
-
cells: ["", "", ""]
|
|
3002
|
-
},
|
|
3003
|
-
{
|
|
3004
|
-
cells: ["", "", ""]
|
|
3005
|
-
}
|
|
3006
|
-
]
|
|
3007
|
-
}
|
|
3008
|
-
});
|
|
3009
|
-
},
|
|
3010
|
-
badge: void 0,
|
|
3011
|
-
key: "table",
|
|
3012
|
-
...e.dictionary.slash_menu.table
|
|
3013
|
-
}), b(e, "image", { url: "string" }) && t.push({
|
|
3014
|
-
onItemClick: () => {
|
|
3015
|
-
var o;
|
|
3016
|
-
const n = k(e, {
|
|
3017
|
-
type: "image"
|
|
3018
|
-
});
|
|
3019
|
-
(o = e.getExtension(H)) == null || o.showMenu(n.id);
|
|
3020
|
-
},
|
|
3021
|
-
key: "image",
|
|
3022
|
-
...e.dictionary.slash_menu.image
|
|
3023
|
-
}), b(e, "video", { url: "string" }) && t.push({
|
|
3024
|
-
onItemClick: () => {
|
|
3025
|
-
var o;
|
|
3026
|
-
const n = k(e, {
|
|
3027
|
-
type: "video"
|
|
3028
|
-
});
|
|
3029
|
-
(o = e.getExtension(H)) == null || o.showMenu(n.id);
|
|
3030
|
-
},
|
|
3031
|
-
key: "video",
|
|
3032
|
-
...e.dictionary.slash_menu.video
|
|
3033
|
-
}), b(e, "audio", { url: "string" }) && t.push({
|
|
3034
|
-
onItemClick: () => {
|
|
3035
|
-
var o;
|
|
3036
|
-
const n = k(e, {
|
|
3037
|
-
type: "audio"
|
|
3038
|
-
});
|
|
3039
|
-
(o = e.getExtension(H)) == null || o.showMenu(n.id);
|
|
3040
|
-
},
|
|
3041
|
-
key: "audio",
|
|
3042
|
-
...e.dictionary.slash_menu.audio
|
|
3043
|
-
}), b(e, "file", { url: "string" }) && t.push({
|
|
3044
|
-
onItemClick: () => {
|
|
3045
|
-
var o;
|
|
3046
|
-
const n = k(e, {
|
|
3047
|
-
type: "file"
|
|
3048
|
-
});
|
|
3049
|
-
(o = e.getExtension(H)) == null || o.showMenu(n.id);
|
|
3050
|
-
},
|
|
3051
|
-
key: "file",
|
|
3052
|
-
...e.dictionary.slash_menu.file
|
|
3053
|
-
}), b(e, "heading", {
|
|
3054
|
-
level: "number",
|
|
3055
|
-
isToggleable: "boolean"
|
|
3056
|
-
}) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((n) => n <= 3).forEach((n) => {
|
|
3057
|
-
t.push({
|
|
3058
|
-
onItemClick: () => {
|
|
3059
|
-
k(e, {
|
|
3060
|
-
type: "heading",
|
|
3061
|
-
props: { level: n, isToggleable: !0 }
|
|
3062
|
-
});
|
|
3063
|
-
},
|
|
3064
|
-
key: n === 1 ? "toggle_heading" : `toggle_heading_${n}`,
|
|
3065
|
-
...e.dictionary.slash_menu[n === 1 ? "toggle_heading" : `toggle_heading_${n}`]
|
|
3066
|
-
});
|
|
3067
|
-
}), b(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((n) => n > 3).forEach((n) => {
|
|
3068
|
-
t.push({
|
|
3069
|
-
onItemClick: () => {
|
|
3070
|
-
k(e, {
|
|
3071
|
-
type: "heading",
|
|
3072
|
-
props: { level: n }
|
|
3073
|
-
});
|
|
3074
|
-
},
|
|
3075
|
-
badge: L(`Mod-Alt-${n}`),
|
|
3076
|
-
key: `heading_${n}`,
|
|
3077
|
-
...e.dictionary.slash_menu[`heading_${n}`]
|
|
3078
|
-
});
|
|
3079
|
-
}), t.push({
|
|
3080
|
-
onItemClick: () => {
|
|
3081
|
-
var n;
|
|
3082
|
-
(n = e.getExtension(Vn)) == null || n.openSuggestionMenu(":", {
|
|
3083
|
-
deleteTriggerCharacter: !0,
|
|
3084
|
-
ignoreQueryLength: !0
|
|
3085
|
-
});
|
|
3086
|
-
},
|
|
3087
|
-
key: "emoji",
|
|
3088
|
-
...e.dictionary.slash_menu.emoji
|
|
3089
|
-
}), t;
|
|
3090
|
-
}
|
|
3091
|
-
function No(e, t) {
|
|
3092
|
-
return e.filter(
|
|
3093
|
-
({ title: n, aliases: o }) => n.toLowerCase().includes(t.toLowerCase()) || o && o.filter(
|
|
3094
|
-
(r) => r.toLowerCase().includes(t.toLowerCase())
|
|
3095
|
-
).length !== 0
|
|
3096
|
-
);
|
|
3097
|
-
}
|
|
3098
|
-
const Po = {
|
|
3099
|
-
audio: $t(),
|
|
3100
|
-
bulletListItem: ln(),
|
|
3101
|
-
checkListItem: un(),
|
|
3102
|
-
codeBlock: jt(),
|
|
3103
|
-
divider: zt(),
|
|
3104
|
-
file: Kt(),
|
|
3105
|
-
heading: en(),
|
|
3106
|
-
image: sn(),
|
|
3107
|
-
numberedListItem: mn(),
|
|
3108
|
-
paragraph: Cn(),
|
|
3109
|
-
quote: yn(),
|
|
3110
|
-
table: Bn(),
|
|
3111
|
-
toggleListItem: gn(),
|
|
3112
|
-
video: In()
|
|
3113
|
-
}, Rn = Te(
|
|
3114
|
-
{
|
|
3115
|
-
type: "textColor",
|
|
3116
|
-
propSchema: "string"
|
|
3117
|
-
},
|
|
3118
|
-
{
|
|
3119
|
-
render: () => {
|
|
3120
|
-
const e = document.createElement("span");
|
|
3121
|
-
return {
|
|
3122
|
-
dom: e,
|
|
3123
|
-
contentDOM: e
|
|
3124
|
-
};
|
|
3125
|
-
},
|
|
3126
|
-
toExternalHTML: (e) => {
|
|
3127
|
-
const t = document.createElement("span");
|
|
3128
|
-
return e !== m.textColor.default && (t.style.color = e in T ? T[e].text : e), {
|
|
3129
|
-
dom: t,
|
|
3130
|
-
contentDOM: t
|
|
3131
|
-
};
|
|
3132
|
-
},
|
|
3133
|
-
parse: (e) => {
|
|
3134
|
-
if (e.tagName === "SPAN" && e.style.color)
|
|
3135
|
-
return e.style.color;
|
|
3136
|
-
}
|
|
3137
|
-
}
|
|
3138
|
-
), Fn = Te(
|
|
3139
|
-
{
|
|
3140
|
-
type: "backgroundColor",
|
|
3141
|
-
propSchema: "string"
|
|
3142
|
-
},
|
|
3143
|
-
{
|
|
3144
|
-
render: () => {
|
|
3145
|
-
const e = document.createElement("span");
|
|
3146
|
-
return {
|
|
3147
|
-
dom: e,
|
|
3148
|
-
contentDOM: e
|
|
3149
|
-
};
|
|
3150
|
-
},
|
|
3151
|
-
toExternalHTML: (e) => {
|
|
3152
|
-
const t = document.createElement("span");
|
|
3153
|
-
return e !== m.backgroundColor.default && (t.style.backgroundColor = e in T ? T[e].background : e), {
|
|
3154
|
-
dom: t,
|
|
3155
|
-
contentDOM: t
|
|
3156
|
-
};
|
|
3157
|
-
},
|
|
3158
|
-
parse: (e) => {
|
|
3159
|
-
if (e.tagName === "SPAN" && e.style.backgroundColor)
|
|
3160
|
-
return e.style.backgroundColor;
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
), $n = {
|
|
3164
|
-
bold: I(st, "boolean"),
|
|
3165
|
-
italic: I(ct, "boolean"),
|
|
3166
|
-
underline: I(dt, "boolean"),
|
|
3167
|
-
strike: I(lt, "boolean"),
|
|
3168
|
-
code: I(it, "boolean"),
|
|
3169
|
-
textColor: Rn,
|
|
3170
|
-
backgroundColor: Fn
|
|
3171
|
-
}, Io = Lt($n), Un = {
|
|
3172
|
-
text: { config: "text", implementation: {} },
|
|
3173
|
-
link: { config: "link", implementation: {} }
|
|
3174
|
-
}, Ho = Mt(
|
|
3175
|
-
Un
|
|
3176
|
-
);
|
|
3177
|
-
export {
|
|
3178
|
-
b as $,
|
|
3179
|
-
un as A,
|
|
3180
|
-
fn as B,
|
|
3181
|
-
mn as C,
|
|
3182
|
-
hn as D,
|
|
3183
|
-
Lo as E,
|
|
3184
|
-
_t as F,
|
|
3185
|
-
gn as G,
|
|
3186
|
-
bn as H,
|
|
3187
|
-
Cn as I,
|
|
3188
|
-
kn as J,
|
|
3189
|
-
yn as K,
|
|
3190
|
-
Sn as L,
|
|
3191
|
-
Bn as M,
|
|
3192
|
-
An as N,
|
|
3193
|
-
Nn as O,
|
|
3194
|
-
Pn as P,
|
|
3195
|
-
In as Q,
|
|
3196
|
-
Qt as R,
|
|
3197
|
-
Ne as S,
|
|
3198
|
-
Ct as T,
|
|
3199
|
-
de as U,
|
|
3200
|
-
we as V,
|
|
3201
|
-
Po as W,
|
|
3202
|
-
$n as X,
|
|
3203
|
-
Io as Y,
|
|
3204
|
-
Un as Z,
|
|
3205
|
-
Ho as _,
|
|
3206
|
-
Oe as a,
|
|
3207
|
-
To as a0,
|
|
3208
|
-
Bo as a1,
|
|
3209
|
-
m as a2,
|
|
3210
|
-
C as a3,
|
|
3211
|
-
A as a4,
|
|
3212
|
-
So as a5,
|
|
3213
|
-
xo as a6,
|
|
3214
|
-
Mo as a7,
|
|
3215
|
-
H as a8,
|
|
3216
|
-
Vn as a9,
|
|
3217
|
-
z as aA,
|
|
3218
|
-
vt as aB,
|
|
3219
|
-
xt as aC,
|
|
3220
|
-
Tt as aD,
|
|
3221
|
-
Te as aE,
|
|
3222
|
-
wt as aF,
|
|
3223
|
-
W as aG,
|
|
3224
|
-
Le as aH,
|
|
3225
|
-
I as aI,
|
|
3226
|
-
bt as aJ,
|
|
3227
|
-
L as aK,
|
|
3228
|
-
po as aL,
|
|
3229
|
-
F as aM,
|
|
3230
|
-
fo as aN,
|
|
3231
|
-
Dn as aO,
|
|
3232
|
-
k as aa,
|
|
3233
|
-
Ao as ab,
|
|
3234
|
-
No as ac,
|
|
3235
|
-
ho as ad,
|
|
3236
|
-
Lt as ae,
|
|
3237
|
-
Mt as af,
|
|
3238
|
-
go as ag,
|
|
3239
|
-
v as ah,
|
|
3240
|
-
At as ai,
|
|
3241
|
-
Bt as aj,
|
|
3242
|
-
bo as ak,
|
|
3243
|
-
Co as al,
|
|
3244
|
-
kt as am,
|
|
3245
|
-
ko as an,
|
|
3246
|
-
vo as ao,
|
|
3247
|
-
mo as ap,
|
|
3248
|
-
wo as aq,
|
|
3249
|
-
yo as ar,
|
|
3250
|
-
D as as,
|
|
3251
|
-
Q as at,
|
|
3252
|
-
Pt as au,
|
|
3253
|
-
T as av,
|
|
3254
|
-
Eo as aw,
|
|
3255
|
-
Et as ax,
|
|
3256
|
-
St as ay,
|
|
3257
|
-
yt as az,
|
|
3258
|
-
Wt as b,
|
|
3259
|
-
Vt as c,
|
|
3260
|
-
Rt as d,
|
|
3261
|
-
Ft as e,
|
|
3262
|
-
$t as f,
|
|
3263
|
-
qt as g,
|
|
3264
|
-
jt as h,
|
|
3265
|
-
Be as i,
|
|
3266
|
-
Gt as j,
|
|
3267
|
-
zt as k,
|
|
3268
|
-
Zt as l,
|
|
3269
|
-
Xt as m,
|
|
3270
|
-
Kt as n,
|
|
3271
|
-
Yt as o,
|
|
3272
|
-
pe as p,
|
|
3273
|
-
en as q,
|
|
3274
|
-
tn as r,
|
|
3275
|
-
nn as s,
|
|
3276
|
-
on as t,
|
|
3277
|
-
rn as u,
|
|
3278
|
-
an as v,
|
|
3279
|
-
sn as w,
|
|
3280
|
-
cn as x,
|
|
3281
|
-
ln as y,
|
|
3282
|
-
dn as z
|
|
3283
|
-
};
|
|
3284
|
-
//# sourceMappingURL=defaultBlocks-ZzGbYgQn.js.map
|