@blocknote/core 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +4 -4
- package/dist/{blocks-UU7EM-QM.js → blocks-D0lMxErU.js} +397 -368
- package/dist/blocks-D0lMxErU.js.map +1 -0
- package/dist/blocks-KyMOxPT3.cjs +11 -0
- package/dist/blocks-KyMOxPT3.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/{extensions-CkLT--Nc.js → extensions-CQFfm5f5.js} +619 -353
- package/dist/extensions-CQFfm5f5.js.map +1 -0
- package/dist/extensions-Cuw3zOdC.cjs +52 -0
- package/dist/extensions-Cuw3zOdC.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +1 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-SVFpMAWE.js → src-DK_8q1j5.js} +1070 -564
- package/dist/src-DK_8q1j5.js.map +1 -0
- package/dist/src-_83jmA7A.cjs +21 -0
- package/dist/src-_83jmA7A.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +8 -8
- package/package.json +1 -13
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +7 -7
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +5 -5
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +2550 -291
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +83 -2
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +103 -42
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -143
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +6 -6
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +22 -22
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +12 -8
- package/src/api/blockManipulation/setupTestEnv.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +2 -6
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +7 -2
- package/src/api/exporters/markdown/htmlToMarkdown.ts +813 -0
- package/src/api/exporters/markdown/markdownExporter.ts +2 -21
- package/src/api/nodeConversions/blockToNode.ts +3 -2
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +122 -107
- package/src/api/parsers/html/util/nestedLists.test.ts +1 -12
- package/src/api/parsers/markdown/markdownToHtml.ts +1194 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +2 -101
- package/src/blocks/Audio/block.ts +1 -4
- package/src/blocks/Code/block.test.ts +258 -0
- package/src/blocks/File/block.ts +1 -4
- package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +7 -2
- package/src/blocks/Image/block.ts +9 -6
- package/src/blocks/ListItem/BulletListItem/block.ts +7 -4
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +3 -4
- package/src/blocks/Video/block.ts +4 -5
- package/src/blocks/Video/parseVideoElement.ts +2 -1
- package/src/editor/Block.css +8 -0
- package/src/editor/BlockNoteEditor.test.ts +10 -4
- package/src/editor/BlockNoteEditor.ts +30 -13
- package/src/editor/managers/BlockManager.ts +10 -6
- package/src/editor/managers/ExtensionManager/index.ts +80 -25
- package/src/editor/performance.test.ts +2 -2
- package/src/editor/transformPasted.test.ts +295 -0
- package/src/editor/transformPasted.ts +77 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +1 -12
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +0 -11
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
- package/src/extensions/SideMenu/dragging.ts +7 -10
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +21 -0
- package/src/extensions/TrailingNode/TrailingNode.ts +124 -65
- package/src/i18n/locales/fr.ts +1 -1
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +13 -2
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +1 -1
- package/types/src/api/exporters/markdown/htmlToMarkdown.d.ts +11 -0
- package/types/src/api/parsers/markdown/markdownToHtml.d.ts +5 -0
- package/types/src/blocks/Code/block.test.d.ts +1 -0
- package/types/src/blocks/Video/block.d.ts +2 -0
- package/types/src/blocks/Video/parseVideoElement.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +20 -6
- package/types/src/editor/managers/BlockManager.d.ts +8 -4
- package/types/src/editor/transformPasted.test.d.ts +1 -0
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +8 -3
- package/dist/blocks-BFnTypT-.cjs +0 -11
- package/dist/blocks-BFnTypT-.cjs.map +0 -1
- package/dist/blocks-UU7EM-QM.js.map +0 -1
- package/dist/extensions-CYsFi5Is.cjs +0 -2
- package/dist/extensions-CYsFi5Is.cjs.map +0 -1
- package/dist/extensions-CkLT--Nc.js.map +0 -1
- package/dist/src-DsJ6yzs9.cjs +0 -5
- package/dist/src-DsJ6yzs9.cjs.map +0 -1
- package/dist/src-SVFpMAWE.js.map +0 -1
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +0 -42
- package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +0 -19
- package/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.ts +0 -39
- package/types/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.d.ts +0 -7
- package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +0 -2
- package/types/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.d.ts +0 -6
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as de, D as fe, E as pe, O as me, S as he, T as ge, _ as _e,
|
|
1
|
+
import { $t as e, At as t, Dn as n, Dt as r, Et as i, H as a, Qt as o, Rn as s, Tt as c, Ut as l, Yn as u, Zt as d, _n as f, _t as p, an as m, f as h, fn as g, gn as _, hn as v, in as ee, jn as te, jt as ne, kt as y, ln as re, m as b, mn as x, mt as ie, nn as ae, on as S, rn as oe, sn as se, t as ce, wt as le, yn as C, yt as ue, zn as w } from "./blocks-D0lMxErU.js";
|
|
2
|
+
import { C as de, D as fe, E as pe, O as me, S as he, T as ge, _ as _e, b as ve, d as ye, f as be, l as xe, m as Se, n as Ce, o as we, p as Te, t as Ee, u as De, v as Oe, w as ke, x as Ae } from "./extensions-CQFfm5f5.js";
|
|
3
3
|
import { r as je, t as Me } from "./BlockNoteExtension-B6RhuQ3V.js";
|
|
4
4
|
import { t as Ne } from "./ShowSelection-BsHFfdMi.js";
|
|
5
5
|
import { t as Pe } from "./en-B9hMApn4.js";
|
|
6
6
|
import { t as Fe } from "./EventEmitter-CuPnGDYt.js";
|
|
7
7
|
import { DOMParser as Ie, DOMSerializer as Le, Fragment as T, Node as Re, NodeRange as ze, Slice as E } from "prosemirror-model";
|
|
8
8
|
import { ReplaceAroundStep as D, ReplaceStep as Be, canJoin as Ve, liftTarget as He } from "prosemirror-transform";
|
|
9
|
-
import { Editor as Ue, Extension as O, Mark as k, Node as A, combineTransactionSteps as We, createDocument as Ge, extensions as j, findChildrenInRange as Ke, findParentNodeClosestToPos as qe, getAttributes as Je, getChangedRanges as Ye, getMarkRange as Xe, getMarksBetween as Ze, getSchema as Qe, isNodeSelection as $e, markPasteRule as et, mergeAttributes as
|
|
10
|
-
import { NodeSelection as
|
|
11
|
-
import { Fragment as
|
|
12
|
-
import { CellSelection as
|
|
13
|
-
import { Plugin as
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import lt from "rehype-stringify";
|
|
19
|
-
import { InputRule as ut, inputRules as dt } from "@handlewithcare/prosemirror-inputrules";
|
|
20
|
-
import { keymap as ft } from "@tiptap/pm/keymap";
|
|
21
|
-
import { Gapcursor as pt } from "@tiptap/extensions/gap-cursor";
|
|
22
|
-
import { Text as mt } from "@tiptap/extension-text";
|
|
9
|
+
import { Editor as Ue, Extension as O, Mark as k, Node as A, combineTransactionSteps as We, createDocument as Ge, extensions as j, findChildrenInRange as Ke, findParentNodeClosestToPos as qe, getAttributes as Je, getChangedRanges as Ye, getMarkRange as Xe, getMarksBetween as Ze, getSchema as Qe, isNodeSelection as $e, markPasteRule as et, mergeAttributes as tt, posToDOMRect as nt, selectionToInsertionEnd as rt } from "@tiptap/core";
|
|
10
|
+
import { NodeSelection as M, Plugin as N, TextSelection as P } from "prosemirror-state";
|
|
11
|
+
import { Fragment as F, Slice as I } from "@tiptap/pm/model";
|
|
12
|
+
import { CellSelection as it, TableMap as at } from "prosemirror-tables";
|
|
13
|
+
import { Plugin as ot, PluginKey as st } from "@tiptap/pm/state";
|
|
14
|
+
import { InputRule as ct, inputRules as lt } from "@handlewithcare/prosemirror-inputrules";
|
|
15
|
+
import { keymap as ut } from "@tiptap/pm/keymap";
|
|
16
|
+
import { Gapcursor as dt } from "@tiptap/extensions/gap-cursor";
|
|
17
|
+
import { Text as ft } from "@tiptap/extension-text";
|
|
23
18
|
//#region src/schema/inlineContent/createSpec.ts
|
|
24
|
-
function
|
|
19
|
+
function pt(e, t) {
|
|
25
20
|
let n = [{
|
|
26
21
|
tag: `[data-inline-content-type="${e.type}"]`,
|
|
27
22
|
contentElement: (e) => {
|
|
@@ -38,62 +33,65 @@ function ht(e, t) {
|
|
|
38
33
|
}
|
|
39
34
|
}), n;
|
|
40
35
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
43
|
-
name:
|
|
36
|
+
function mt(r, i) {
|
|
37
|
+
return e(A.create({
|
|
38
|
+
name: r.type,
|
|
44
39
|
inline: !0,
|
|
45
40
|
group: "inline",
|
|
46
|
-
draggable:
|
|
47
|
-
selectable:
|
|
48
|
-
atom:
|
|
49
|
-
content:
|
|
41
|
+
draggable: i.meta?.draggable,
|
|
42
|
+
selectable: r.content === "styled",
|
|
43
|
+
atom: r.content === "none",
|
|
44
|
+
content: r.content === "styled" ? "inline*" : "",
|
|
50
45
|
addAttributes() {
|
|
51
|
-
return r
|
|
46
|
+
return n(r.propSchema);
|
|
52
47
|
},
|
|
53
48
|
addKeyboardShortcuts() {
|
|
54
|
-
return
|
|
49
|
+
return o(r);
|
|
55
50
|
},
|
|
56
51
|
parseHTML() {
|
|
57
|
-
return
|
|
52
|
+
return pt(r, i.parse);
|
|
58
53
|
},
|
|
59
|
-
renderHTML({ node:
|
|
60
|
-
let
|
|
61
|
-
return
|
|
54
|
+
renderHTML({ node: e }) {
|
|
55
|
+
let t = this.options.editor;
|
|
56
|
+
return d(i.render.call({
|
|
62
57
|
renderType: "dom",
|
|
63
58
|
props: void 0
|
|
64
|
-
},
|
|
59
|
+
}, S(e, t.schema.inlineContentSchema, t.schema.styleSchema), () => {}, t), r.type, e.attrs, r.propSchema);
|
|
65
60
|
},
|
|
66
61
|
addNodeView() {
|
|
67
|
-
return (
|
|
68
|
-
let { node:
|
|
69
|
-
return
|
|
62
|
+
return (e) => {
|
|
63
|
+
let { node: n, getPos: a } = e, o = this.options.editor;
|
|
64
|
+
return d(i.render.call({
|
|
70
65
|
renderType: "nodeView",
|
|
71
|
-
props:
|
|
72
|
-
},
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
},
|
|
66
|
+
props: e
|
|
67
|
+
}, S(n, o.schema.inlineContentSchema, o.schema.styleSchema), (e) => {
|
|
68
|
+
let r = t([e], o.pmSchema), i = a();
|
|
69
|
+
i && o.transact((e) => e.replaceWith(i, i + n.nodeSize, r));
|
|
70
|
+
}, o), r.type, n.attrs, r.propSchema);
|
|
76
71
|
};
|
|
77
72
|
}
|
|
78
|
-
}),
|
|
79
|
-
...
|
|
80
|
-
toExternalHTML:
|
|
81
|
-
render(
|
|
82
|
-
return
|
|
73
|
+
}), r.propSchema, {
|
|
74
|
+
...i,
|
|
75
|
+
toExternalHTML: i.toExternalHTML,
|
|
76
|
+
render(e, t, n) {
|
|
77
|
+
return d(i.render(e, t, n), r.type, e.props, r.propSchema);
|
|
83
78
|
}
|
|
84
79
|
});
|
|
85
80
|
}
|
|
86
81
|
//#endregion
|
|
87
82
|
//#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
|
|
88
|
-
function
|
|
89
|
-
let a = typeof n == "string" ? n : n.id, o = g(e), s = t.map((e) =>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
function ht(e, t, n, i = "before") {
|
|
84
|
+
let a = typeof n == "string" ? n : n.id, o = g(e), s = t.map((e) => {
|
|
85
|
+
let t = y(e, o);
|
|
86
|
+
return t.check(), t;
|
|
87
|
+
}), c = r(a, e.doc);
|
|
88
|
+
if (!c) throw Error(`Block with ID ${a} not found`);
|
|
89
|
+
let l = c.posBeforeNode;
|
|
90
|
+
return i === "after" && (l += c.node.nodeSize), e.step(new Be(l, l, new E(T.from(s), 0, 0))), s.map((e) => m(e, o));
|
|
93
91
|
}
|
|
94
92
|
//#endregion
|
|
95
93
|
//#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
|
|
96
|
-
function
|
|
94
|
+
function L(e) {
|
|
97
95
|
if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
98
96
|
let t = e.firstChild;
|
|
99
97
|
if (!t) throw Error("Invalid column: does not have child node.");
|
|
@@ -101,24 +99,24 @@ function V(e) {
|
|
|
101
99
|
if (!n) throw Error("Invalid blockContainer: does not have child node.");
|
|
102
100
|
return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
|
|
103
101
|
}
|
|
104
|
-
function
|
|
102
|
+
function gt(e, t) {
|
|
105
103
|
let n = e.doc.resolve(t), r = n.nodeAfter;
|
|
106
104
|
if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
107
105
|
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
108
106
|
let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
|
|
109
107
|
if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
110
|
-
|
|
108
|
+
L(i) && e.delete(r, r + i.nodeSize);
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
|
-
function
|
|
114
|
-
|
|
111
|
+
function R(e, t) {
|
|
112
|
+
gt(e, t);
|
|
115
113
|
let n = e.doc.resolve(t).nodeAfter;
|
|
116
114
|
if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
117
115
|
if (n.childCount > 2) return;
|
|
118
116
|
if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
|
|
119
117
|
let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
|
|
120
118
|
if (!i || !o) throw Error("Invalid columnList: does not contain children.");
|
|
121
|
-
let s =
|
|
119
|
+
let s = L(i), c = L(o);
|
|
122
120
|
if (s && c) {
|
|
123
121
|
e.delete(t, t + n.nodeSize);
|
|
124
122
|
return;
|
|
@@ -134,44 +132,47 @@ function H(e, t) {
|
|
|
134
132
|
}
|
|
135
133
|
//#endregion
|
|
136
134
|
//#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
|
|
137
|
-
function
|
|
138
|
-
let r = g(e), i = n.map((e) =>
|
|
139
|
-
|
|
135
|
+
function z(e, t, n) {
|
|
136
|
+
let r = g(e), i = n.map((e) => {
|
|
137
|
+
let t = y(e, r);
|
|
138
|
+
return t.check(), t;
|
|
139
|
+
}), a = new Set(t.map((e) => typeof e == "string" ? e : e.id)), o = [], s = /* @__PURE__ */ new Set(), c = typeof t[0] == "string" ? t[0] : t[0].id, l = 0;
|
|
140
|
+
if (e.doc.descendants((t, u) => {
|
|
140
141
|
if (a.size === 0) return !1;
|
|
141
142
|
if (!t.type.isInGroup("bnBlock") || !a.has(t.attrs.id)) return !0;
|
|
142
|
-
if (o.push(
|
|
143
|
+
if (o.push(m(t, r)), a.delete(t.attrs.id), n.length > 0 && t.attrs.id === c) {
|
|
143
144
|
let t = e.doc.nodeSize;
|
|
144
|
-
e.insert(
|
|
145
|
+
e.insert(u, i);
|
|
145
146
|
let n = e.doc.nodeSize;
|
|
146
|
-
|
|
147
|
+
l += t - n;
|
|
147
148
|
}
|
|
148
|
-
let d = e.doc.nodeSize, f = e.doc.resolve(
|
|
149
|
-
f.node().type.name === "column" ? s.add(f.before(-1)) : f.node().type.name === "columnList" && s.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ? e.delete(f.before(), f.after()) : e.delete(
|
|
149
|
+
let d = e.doc.nodeSize, f = e.doc.resolve(u - l);
|
|
150
|
+
f.node().type.name === "column" ? s.add(f.before(-1)) : f.node().type.name === "columnList" && s.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ? e.delete(f.before(), f.after()) : e.delete(u - l, u - l + t.nodeSize);
|
|
150
151
|
let p = e.doc.nodeSize;
|
|
151
|
-
return
|
|
152
|
+
return l += d - p, !1;
|
|
152
153
|
}), a.size > 0) {
|
|
153
154
|
let e = [...a].join("\n");
|
|
154
155
|
throw Error("Blocks with the following IDs could not be found in the editor: " + e);
|
|
155
156
|
}
|
|
156
|
-
return s.forEach((t) =>
|
|
157
|
-
insertedBlocks: i.map((e) =>
|
|
157
|
+
return s.forEach((t) => R(e, t)), {
|
|
158
|
+
insertedBlocks: i.map((e) => m(e, r)),
|
|
158
159
|
removedBlocks: o
|
|
159
160
|
};
|
|
160
161
|
}
|
|
161
162
|
//#endregion
|
|
162
163
|
//#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
|
|
163
|
-
function
|
|
164
|
+
function _t(e, n, r, i, a) {
|
|
164
165
|
let o;
|
|
165
166
|
if (!n) throw Error("blockContent is required");
|
|
166
|
-
if (typeof n == "string") o =
|
|
167
|
-
else if (Array.isArray(n)) o =
|
|
168
|
-
else if (n.type === "tableContent") o =
|
|
169
|
-
else throw new
|
|
167
|
+
if (typeof n == "string") o = t([n], e.pmSchema, i);
|
|
168
|
+
else if (Array.isArray(n)) o = t(n, e.pmSchema, i);
|
|
169
|
+
else if (n.type === "tableContent") o = ne(n, e.pmSchema);
|
|
170
|
+
else throw new w(n.type);
|
|
170
171
|
let s = (a?.document ?? document).createDocumentFragment();
|
|
171
172
|
for (let t of o) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
172
173
|
let n = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
173
174
|
if (n) {
|
|
174
|
-
let i =
|
|
175
|
+
let i = S(t, e.schema.inlineContentSchema, e.schema.styleSchema), o = n.render.call({
|
|
175
176
|
renderType: "dom",
|
|
176
177
|
props: void 0
|
|
177
178
|
}, i, () => {}, e);
|
|
@@ -199,7 +200,7 @@ function yt(e, n, r, i, a) {
|
|
|
199
200
|
}
|
|
200
201
|
return s;
|
|
201
202
|
}
|
|
202
|
-
function
|
|
203
|
+
function vt(e, t, n, r) {
|
|
203
204
|
let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
|
|
204
205
|
for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
|
|
205
206
|
let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
|
|
@@ -211,12 +212,12 @@ function bt(e, t, n, r) {
|
|
|
211
212
|
children: o
|
|
212
213
|
}, e);
|
|
213
214
|
if (s.contentDOM && t.content) {
|
|
214
|
-
let i =
|
|
215
|
+
let i = _t(e, t.content, n, t.type, r);
|
|
215
216
|
s.contentDOM.appendChild(i);
|
|
216
217
|
}
|
|
217
218
|
if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
|
|
218
219
|
if (t.children && t.children.length > 0) {
|
|
219
|
-
let i =
|
|
220
|
+
let i = yt(e, t.children, n, r);
|
|
220
221
|
s.contentDOM?.append(i);
|
|
221
222
|
}
|
|
222
223
|
return s.dom;
|
|
@@ -225,67 +226,67 @@ function bt(e, t, n, r) {
|
|
|
225
226
|
id: t.id,
|
|
226
227
|
...a
|
|
227
228
|
}));
|
|
228
|
-
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(
|
|
229
|
+
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(bt(e, t.children, n, r)), c.dom;
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function yt(e, t, n, r) {
|
|
231
232
|
let i = (r?.document ?? document).createDocumentFragment();
|
|
232
233
|
for (let a of t) {
|
|
233
|
-
let t =
|
|
234
|
+
let t = vt(e, a, n, r);
|
|
234
235
|
i.appendChild(t);
|
|
235
236
|
}
|
|
236
237
|
return i;
|
|
237
238
|
}
|
|
238
|
-
var
|
|
239
|
-
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o =
|
|
239
|
+
var bt = (e, t, n, r) => {
|
|
240
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = yt(e, t, n, r);
|
|
240
241
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
241
|
-
},
|
|
242
|
+
}, xt = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
|
|
242
243
|
let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
|
|
243
244
|
if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
|
|
244
245
|
else {
|
|
245
246
|
let n = t.getAttribute("data-index");
|
|
246
247
|
e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
|
|
247
248
|
}
|
|
248
|
-
}), e),
|
|
249
|
+
}), e), St = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
249
250
|
e.disabled = !0;
|
|
250
|
-
}), e),
|
|
251
|
+
}), e), Ct = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
|
|
251
252
|
e.setAttribute("data-show-children", "true");
|
|
252
|
-
}), e),
|
|
253
|
+
}), e), wt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
253
254
|
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
254
|
-
}), e),
|
|
255
|
+
}), e), Tt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
255
256
|
let t = document.createElement("div");
|
|
256
257
|
t.className = "tableWrapper";
|
|
257
258
|
let n = document.createElement("div");
|
|
258
259
|
n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
|
|
259
|
-
}), e),
|
|
260
|
+
}), e), Et = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
|
|
260
261
|
let t = document.createElement("span");
|
|
261
262
|
t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
|
|
262
|
-
}), e),
|
|
263
|
+
}), e), Dt = (e, t) => {
|
|
263
264
|
let n = Le.fromSchema(e), r = [
|
|
265
|
+
xt,
|
|
266
|
+
St,
|
|
264
267
|
Ct,
|
|
265
268
|
wt,
|
|
266
269
|
Tt,
|
|
267
|
-
Et
|
|
268
|
-
Dt,
|
|
269
|
-
Ot
|
|
270
|
+
Et
|
|
270
271
|
];
|
|
271
272
|
return { serializeBlocks: (e, i) => {
|
|
272
|
-
let a =
|
|
273
|
+
let a = bt(t, e, n, i);
|
|
273
274
|
for (let e of r) a = e(a);
|
|
274
275
|
return a.outerHTML;
|
|
275
276
|
} };
|
|
276
277
|
};
|
|
277
278
|
//#endregion
|
|
278
279
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
279
|
-
function
|
|
280
|
+
function Ot(e) {
|
|
280
281
|
return e.transact((e) => {
|
|
281
282
|
let t = C(e.doc, e.selection.anchor);
|
|
282
|
-
if (e.selection instanceof
|
|
283
|
+
if (e.selection instanceof it) return {
|
|
283
284
|
type: "cell",
|
|
284
285
|
anchorBlockId: t.node.attrs.id,
|
|
285
286
|
anchorCellOffset: e.selection.$anchorCell.pos - t.posBeforeNode,
|
|
286
287
|
headCellOffset: e.selection.$headCell.pos - t.posBeforeNode
|
|
287
288
|
};
|
|
288
|
-
if (e.selection instanceof
|
|
289
|
+
if (e.selection instanceof M) return {
|
|
289
290
|
type: "node",
|
|
290
291
|
anchorBlockId: t.node.attrs.id
|
|
291
292
|
};
|
|
@@ -301,67 +302,85 @@ function At(e) {
|
|
|
301
302
|
}
|
|
302
303
|
});
|
|
303
304
|
}
|
|
304
|
-
function
|
|
305
|
-
let n =
|
|
305
|
+
function kt(e, t) {
|
|
306
|
+
let n = r(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
306
307
|
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
307
|
-
let
|
|
308
|
-
if (t.type === "cell")
|
|
309
|
-
else if (t.type === "node")
|
|
308
|
+
let i;
|
|
309
|
+
if (t.type === "cell") i = it.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
|
|
310
|
+
else if (t.type === "node") i = M.create(e.doc, n + 1);
|
|
310
311
|
else {
|
|
311
|
-
let a =
|
|
312
|
+
let a = r(t.headBlockId, e.doc)?.posBeforeNode;
|
|
312
313
|
if (a === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
313
|
-
|
|
314
|
+
i = P.create(e.doc, n + t.anchorOffset, a + t.headOffset);
|
|
314
315
|
}
|
|
315
|
-
e.setSelection(
|
|
316
|
+
e.setSelection(i);
|
|
316
317
|
}
|
|
317
|
-
function
|
|
318
|
-
return e.
|
|
319
|
-
...e,
|
|
320
|
-
children: W(e.children)
|
|
321
|
-
}).flat();
|
|
318
|
+
function At(e) {
|
|
319
|
+
return e.flatMap((e) => e.type === "column" ? e.children : [e]);
|
|
322
320
|
}
|
|
323
|
-
function
|
|
321
|
+
function B(e, t, n, r) {
|
|
322
|
+
e.transact(() => {
|
|
323
|
+
let i = e.getBlock(n);
|
|
324
|
+
if (i?.type === "columnList") {
|
|
325
|
+
let t = r === "after" ? e.getNextBlock(i) : e.getPrevBlock(i);
|
|
326
|
+
t && (n = t, r = r === "after" ? "before" : "after");
|
|
327
|
+
}
|
|
328
|
+
e.removeBlocks(t), e.insertBlocks(At(t), n, r);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
function jt(e, t, n) {
|
|
324
332
|
e.transact((r) => {
|
|
325
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
326
|
-
e
|
|
333
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = Ot(e);
|
|
334
|
+
B(e, i, t, n), kt(r, a);
|
|
327
335
|
});
|
|
328
336
|
}
|
|
329
|
-
function
|
|
337
|
+
function Mt(e) {
|
|
330
338
|
return !e || e.type !== "columnList";
|
|
331
339
|
}
|
|
332
|
-
function
|
|
340
|
+
function Nt(e, t, n) {
|
|
333
341
|
let r, i;
|
|
334
342
|
if (t ? t.children.length > 0 ? (r = t.children[t.children.length - 1], i = "after") : (r = t, i = "before") : n && (r = n, i = "before"), !r || !i) return;
|
|
335
343
|
let a = e.getParentBlock(r);
|
|
336
|
-
return
|
|
344
|
+
return Mt(a) ? {
|
|
337
345
|
referenceBlock: r,
|
|
338
346
|
placement: i
|
|
339
|
-
} :
|
|
347
|
+
} : Nt(e, i === "after" ? r : e.getPrevBlock(r), a);
|
|
340
348
|
}
|
|
341
|
-
function
|
|
349
|
+
function Pt(e, t, n) {
|
|
342
350
|
let r, i;
|
|
343
351
|
if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
|
|
344
352
|
let a = e.getParentBlock(r);
|
|
345
|
-
return
|
|
353
|
+
return Mt(a) ? {
|
|
346
354
|
referenceBlock: r,
|
|
347
355
|
placement: i
|
|
348
|
-
} :
|
|
356
|
+
} : Pt(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
349
357
|
}
|
|
350
|
-
function
|
|
358
|
+
function Ft(e, t) {
|
|
351
359
|
e.transact(() => {
|
|
352
|
-
let
|
|
353
|
-
|
|
360
|
+
let n;
|
|
361
|
+
if (t) {
|
|
362
|
+
if (n = e.getBlock(t), !n) return;
|
|
363
|
+
} else n = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block;
|
|
364
|
+
let r = Nt(e, e.getPrevBlock(n), e.getParentBlock(n));
|
|
365
|
+
r && (t ? B(e, [n], r.referenceBlock, r.placement) : jt(e, r.referenceBlock, r.placement));
|
|
354
366
|
});
|
|
355
367
|
}
|
|
356
|
-
function
|
|
368
|
+
function It(e, t) {
|
|
357
369
|
e.transact(() => {
|
|
358
|
-
let
|
|
359
|
-
|
|
370
|
+
let n;
|
|
371
|
+
if (t) {
|
|
372
|
+
if (n = e.getBlock(t), !n) return;
|
|
373
|
+
} else {
|
|
374
|
+
let t = e.getSelection();
|
|
375
|
+
n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block;
|
|
376
|
+
}
|
|
377
|
+
let r = Pt(e, e.getNextBlock(n), e.getParentBlock(n));
|
|
378
|
+
r && (t ? B(e, [n], r.referenceBlock, r.placement) : jt(e, r.referenceBlock, r.placement));
|
|
360
379
|
});
|
|
361
380
|
}
|
|
362
381
|
//#endregion
|
|
363
382
|
//#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
|
|
364
|
-
function
|
|
383
|
+
function Lt(e, t, n) {
|
|
365
384
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
366
385
|
if (!a) return !1;
|
|
367
386
|
let o = a.startIndex;
|
|
@@ -371,10 +390,10 @@ function Rt(e, t, n) {
|
|
|
371
390
|
let c = s.lastChild && s.lastChild.type === n, l = T.from(c ? t.create() : null), u = new E(T.from(t.create(null, T.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
|
|
372
391
|
return e.step(new D(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
|
|
373
392
|
}
|
|
374
|
-
function
|
|
375
|
-
return e.transact((t) =>
|
|
393
|
+
function Rt(e) {
|
|
394
|
+
return e.transact((t) => Lt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
376
395
|
}
|
|
377
|
-
function
|
|
396
|
+
function zt(e, t, n, r) {
|
|
378
397
|
let i = r.end, a = r.$to.end(r.depth);
|
|
379
398
|
if (i < a) {
|
|
380
399
|
let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
|
|
@@ -386,69 +405,69 @@ function Bt(e, t, n, r) {
|
|
|
386
405
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
387
406
|
return Ve(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
388
407
|
}
|
|
389
|
-
function
|
|
408
|
+
function V(e, t, n) {
|
|
390
409
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
391
|
-
return a && r.node(a.depth - 1).type === t ?
|
|
410
|
+
return a && r.node(a.depth - 1).type === t ? zt(e, t, n, a) : !1;
|
|
392
411
|
}
|
|
393
|
-
function
|
|
394
|
-
return e.transact((t) =>
|
|
412
|
+
function Bt(e) {
|
|
413
|
+
return e.transact((t) => V(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
395
414
|
}
|
|
396
|
-
function
|
|
415
|
+
function Vt(e) {
|
|
397
416
|
return e.transact((e) => {
|
|
398
|
-
let { bnBlock: t } =
|
|
417
|
+
let { bnBlock: t } = f(e);
|
|
399
418
|
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
400
419
|
});
|
|
401
420
|
}
|
|
402
|
-
function
|
|
421
|
+
function Ht(e) {
|
|
403
422
|
return e.transact((e) => {
|
|
404
|
-
let { bnBlock: t } =
|
|
423
|
+
let { bnBlock: t } = f(e);
|
|
405
424
|
return e.doc.resolve(t.beforePos).depth > 1;
|
|
406
425
|
});
|
|
407
426
|
}
|
|
408
427
|
//#endregion
|
|
409
428
|
//#region src/api/blockManipulation/getBlock/getBlock.ts
|
|
410
|
-
function
|
|
411
|
-
let n = typeof t == "string" ? t : t.id,
|
|
412
|
-
if (a) return
|
|
429
|
+
function Ut(e, t) {
|
|
430
|
+
let n = typeof t == "string" ? t : t.id, i = g(e), a = r(n, e);
|
|
431
|
+
if (a) return m(a.node, i);
|
|
413
432
|
}
|
|
414
|
-
function
|
|
415
|
-
let n =
|
|
433
|
+
function Wt(e, t) {
|
|
434
|
+
let n = r(typeof t == "string" ? t : t.id, e), i = g(e);
|
|
416
435
|
if (!n) return;
|
|
417
436
|
let a = e.resolve(n.posBeforeNode).nodeBefore;
|
|
418
|
-
if (a) return
|
|
437
|
+
if (a) return m(a, i);
|
|
419
438
|
}
|
|
420
|
-
function
|
|
421
|
-
let n =
|
|
439
|
+
function Gt(e, t) {
|
|
440
|
+
let n = r(typeof t == "string" ? t : t.id, e), i = g(e);
|
|
422
441
|
if (!n) return;
|
|
423
442
|
let a = e.resolve(n.posBeforeNode + n.node.nodeSize).nodeAfter;
|
|
424
|
-
if (a) return
|
|
443
|
+
if (a) return m(a, i);
|
|
425
444
|
}
|
|
426
|
-
function
|
|
427
|
-
let n = typeof t == "string" ? t : t.id,
|
|
445
|
+
function Kt(e, t) {
|
|
446
|
+
let n = typeof t == "string" ? t : t.id, i = g(e), a = r(n, e);
|
|
428
447
|
if (!a) return;
|
|
429
448
|
let o = e.resolve(a.posBeforeNode), s = o.node(), c = o.node(-1), l = c.type.name === "doc" ? void 0 : s.type.name === "blockGroup" ? c : s;
|
|
430
|
-
if (l) return
|
|
449
|
+
if (l) return m(l, i);
|
|
431
450
|
}
|
|
432
451
|
//#endregion
|
|
433
452
|
//#region src/editor/managers/BlockManager.ts
|
|
434
|
-
var
|
|
453
|
+
var qt = class {
|
|
435
454
|
constructor(e) {
|
|
436
455
|
this.editor = e;
|
|
437
456
|
}
|
|
438
457
|
get document() {
|
|
439
|
-
return this.editor.transact((e) =>
|
|
458
|
+
return this.editor.transact((e) => ee(e.doc, this.editor.pmSchema));
|
|
440
459
|
}
|
|
441
460
|
getBlock(e) {
|
|
442
|
-
return this.editor.transact((t) =>
|
|
461
|
+
return this.editor.transact((t) => Ut(t.doc, e));
|
|
443
462
|
}
|
|
444
463
|
getPrevBlock(e) {
|
|
445
|
-
return this.editor.transact((t) =>
|
|
464
|
+
return this.editor.transact((t) => Wt(t.doc, e));
|
|
446
465
|
}
|
|
447
466
|
getNextBlock(e) {
|
|
448
|
-
return this.editor.transact((t) =>
|
|
467
|
+
return this.editor.transact((t) => Gt(t.doc, e));
|
|
449
468
|
}
|
|
450
469
|
getParentBlock(e) {
|
|
451
|
-
return this.editor.transact((t) =>
|
|
470
|
+
return this.editor.transact((t) => Kt(t.doc, e));
|
|
452
471
|
}
|
|
453
472
|
forEachBlock(e, t = !1) {
|
|
454
473
|
let n = this.document.slice();
|
|
@@ -460,36 +479,36 @@ var Jt = class {
|
|
|
460
479
|
r(n);
|
|
461
480
|
}
|
|
462
481
|
insertBlocks(e, t, n = "before") {
|
|
463
|
-
return this.editor.transact((r) =>
|
|
482
|
+
return this.editor.transact((r) => ht(r, e, t, n));
|
|
464
483
|
}
|
|
465
484
|
updateBlock(e, t) {
|
|
466
|
-
return this.editor.transact((
|
|
485
|
+
return this.editor.transact((n) => le(n, e, t));
|
|
467
486
|
}
|
|
468
487
|
removeBlocks(e) {
|
|
469
|
-
return this.editor.transact((t) =>
|
|
488
|
+
return this.editor.transact((t) => z(t, e, []).removedBlocks);
|
|
470
489
|
}
|
|
471
490
|
replaceBlocks(e, t) {
|
|
472
|
-
return this.editor.transact((n) =>
|
|
491
|
+
return this.editor.transact((n) => z(n, e, t));
|
|
473
492
|
}
|
|
474
493
|
canNestBlock() {
|
|
475
|
-
return
|
|
494
|
+
return Vt(this.editor);
|
|
476
495
|
}
|
|
477
496
|
nestBlock() {
|
|
478
|
-
|
|
497
|
+
Rt(this.editor);
|
|
479
498
|
}
|
|
480
499
|
canUnnestBlock() {
|
|
481
|
-
return
|
|
500
|
+
return Ht(this.editor);
|
|
482
501
|
}
|
|
483
502
|
unnestBlock() {
|
|
484
|
-
|
|
503
|
+
Bt(this.editor);
|
|
485
504
|
}
|
|
486
|
-
moveBlocksUp() {
|
|
487
|
-
return
|
|
505
|
+
moveBlocksUp(e) {
|
|
506
|
+
return Ft(this.editor, e);
|
|
488
507
|
}
|
|
489
|
-
moveBlocksDown() {
|
|
490
|
-
return
|
|
508
|
+
moveBlocksDown(e) {
|
|
509
|
+
return It(this.editor, e);
|
|
491
510
|
}
|
|
492
|
-
},
|
|
511
|
+
}, Jt = class extends Fe {
|
|
493
512
|
constructor(e) {
|
|
494
513
|
super(), this.editor = e, e.on("create", () => {
|
|
495
514
|
e._tiptapEditor.on("update", ({ transaction: t, appendedTransactions: n }) => {
|
|
@@ -512,8 +531,8 @@ var Jt = class {
|
|
|
512
531
|
}
|
|
513
532
|
onChange(e, t = !0) {
|
|
514
533
|
let n = ({ transaction: n, appendedTransactions: r }) => {
|
|
515
|
-
!t &&
|
|
516
|
-
return
|
|
534
|
+
!t && Yt(n) || e(this.editor, { getChanges() {
|
|
535
|
+
return fe(n, r);
|
|
517
536
|
} });
|
|
518
537
|
};
|
|
519
538
|
return this.on("onChange", n), () => {
|
|
@@ -522,7 +541,7 @@ var Jt = class {
|
|
|
522
541
|
}
|
|
523
542
|
onSelectionChange(e, t = !1) {
|
|
524
543
|
let n = (n) => {
|
|
525
|
-
!t &&
|
|
544
|
+
!t && Yt(n.transaction) || e(this.editor);
|
|
526
545
|
};
|
|
527
546
|
return this.on("onSelectionChange", n), () => {
|
|
528
547
|
this.off("onSelectionChange", n);
|
|
@@ -539,30 +558,30 @@ var Jt = class {
|
|
|
539
558
|
};
|
|
540
559
|
}
|
|
541
560
|
};
|
|
542
|
-
function
|
|
561
|
+
function Yt(e) {
|
|
543
562
|
return !!e.getMeta("y-sync$");
|
|
544
563
|
}
|
|
545
564
|
//#endregion
|
|
546
565
|
//#region src/api/parsers/html/util/nestedLists.ts
|
|
547
|
-
function
|
|
566
|
+
function Xt(e) {
|
|
548
567
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
549
568
|
}
|
|
550
|
-
function
|
|
569
|
+
function Zt(e) {
|
|
551
570
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
552
571
|
}
|
|
553
|
-
function
|
|
572
|
+
function Qt(e) {
|
|
554
573
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
555
|
-
let t =
|
|
574
|
+
let t = Xt(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
|
|
556
575
|
e.remove(), r.forEach((e) => {
|
|
557
576
|
e.remove();
|
|
558
577
|
}), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
|
|
559
|
-
if (
|
|
578
|
+
if (Zt(t)) return;
|
|
560
579
|
let n = document.createElement("li");
|
|
561
580
|
n.append(t), e.insertAdjacentElement("afterend", n);
|
|
562
581
|
}), n.childNodes.length === 0 && n.remove();
|
|
563
582
|
});
|
|
564
583
|
}
|
|
565
|
-
function
|
|
584
|
+
function $t(e) {
|
|
566
585
|
e.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
567
586
|
let t = e.previousElementSibling, n = document.createElement("div");
|
|
568
587
|
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
@@ -570,25 +589,25 @@ function en(e) {
|
|
|
570
589
|
for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
|
|
571
590
|
});
|
|
572
591
|
}
|
|
573
|
-
var
|
|
574
|
-
function
|
|
575
|
-
return
|
|
592
|
+
var en = null;
|
|
593
|
+
function tn() {
|
|
594
|
+
return en ||= document.implementation.createHTMLDocument("title");
|
|
576
595
|
}
|
|
577
|
-
function
|
|
596
|
+
function nn(e) {
|
|
578
597
|
if (typeof e == "string") {
|
|
579
|
-
let t =
|
|
598
|
+
let t = tn().createElement("div");
|
|
580
599
|
t.innerHTML = e, e = t;
|
|
581
600
|
}
|
|
582
|
-
return
|
|
601
|
+
return Qt(e), $t(e), e;
|
|
583
602
|
}
|
|
584
603
|
//#endregion
|
|
585
604
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
586
|
-
function
|
|
605
|
+
function rn(e) {
|
|
587
606
|
let t = e.ownerDocument.createTreeWalker(e, 128), n;
|
|
588
607
|
for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
|
|
589
608
|
return !1;
|
|
590
609
|
}
|
|
591
|
-
function
|
|
610
|
+
function an(e) {
|
|
592
611
|
let t = new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
593
612
|
let r = n.parentElement;
|
|
594
613
|
for (; r && r !== e;) {
|
|
@@ -600,92 +619,555 @@ function on(e) {
|
|
|
600
619
|
for (; i = n.nextNode();) r.push(i);
|
|
601
620
|
for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
602
621
|
}
|
|
603
|
-
function
|
|
604
|
-
|
|
622
|
+
function on(e) {
|
|
623
|
+
rn(e) || an(e);
|
|
605
624
|
}
|
|
606
625
|
//#endregion
|
|
607
626
|
//#region src/api/parsers/html/parseHTML.ts
|
|
608
|
-
function
|
|
609
|
-
let n =
|
|
610
|
-
|
|
627
|
+
function H(e, t) {
|
|
628
|
+
let n = nn(e);
|
|
629
|
+
on(n);
|
|
611
630
|
let r = Ie.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
|
|
612
|
-
for (let e = 0; e < r.childCount; e++) i.push(
|
|
631
|
+
for (let e = 0; e < r.childCount; e++) i.push(m(r.child(e), t));
|
|
613
632
|
return i;
|
|
614
633
|
}
|
|
615
634
|
//#endregion
|
|
616
|
-
//#region src/api/parsers/markdown/
|
|
635
|
+
//#region src/api/parsers/markdown/markdownToHtml.ts
|
|
636
|
+
function U(e) {
|
|
637
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
638
|
+
}
|
|
639
|
+
function sn(e) {
|
|
640
|
+
return e ? /\w/.test(e) : !1;
|
|
641
|
+
}
|
|
642
|
+
function W(e, t, n) {
|
|
643
|
+
let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
|
|
644
|
+
return sn(r) && sn(i);
|
|
645
|
+
}
|
|
617
646
|
function cn(e, t) {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}]
|
|
628
|
-
};
|
|
629
|
-
return t.meta && (i.data = { meta: t.meta }), e.patch(t, i), i = e.applyData(t, i), i = {
|
|
630
|
-
type: "element",
|
|
631
|
-
tagName: "pre",
|
|
632
|
-
properties: {},
|
|
633
|
-
children: [i]
|
|
634
|
-
}, e.patch(t, i), i;
|
|
647
|
+
if (e[t] !== "\\" || t + 1 >= e.length) return null;
|
|
648
|
+
let n = e[t + 1];
|
|
649
|
+
return n === "\n" ? {
|
|
650
|
+
html: "<br>\n",
|
|
651
|
+
end: t + 2
|
|
652
|
+
} : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
|
|
653
|
+
html: U(n),
|
|
654
|
+
end: t + 2
|
|
655
|
+
} : null;
|
|
635
656
|
}
|
|
636
657
|
function ln(e, t) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
658
|
+
return e[t] === "`" ? Tn(e, t) : null;
|
|
659
|
+
}
|
|
660
|
+
function un(e, t) {
|
|
661
|
+
return e[t] !== "!" || e[t + 1] !== "[" ? null : En(e, t);
|
|
662
|
+
}
|
|
663
|
+
function dn(e, t) {
|
|
664
|
+
return e[t] === "[" ? Dn(e, t) : null;
|
|
665
|
+
}
|
|
666
|
+
function fn(e, t) {
|
|
667
|
+
return e[t] !== "~" || e[t + 1] !== "~" ? null : K(e, t, "~~", "<del>", "</del>");
|
|
668
|
+
}
|
|
669
|
+
function pn(e, t) {
|
|
670
|
+
return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !W(e, t, 3) ? K(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>") : null;
|
|
671
|
+
}
|
|
672
|
+
function mn(e, t) {
|
|
673
|
+
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !W(e, t, 2) ? K(e, t, e.substring(t, t + 2), "<strong>", "</strong>") : null;
|
|
674
|
+
}
|
|
675
|
+
function hn(e, t) {
|
|
676
|
+
return e[t] === "*" || e[t] === "_" && !W(e, t, 1) ? K(e, t, e[t], "<em>", "</em>") : null;
|
|
677
|
+
}
|
|
678
|
+
function gn(e, t) {
|
|
679
|
+
return e[t] === "\n" ? {
|
|
680
|
+
html: "<br>\n",
|
|
681
|
+
end: t + 1
|
|
682
|
+
} : null;
|
|
683
|
+
}
|
|
684
|
+
var _n = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, vn = /^<!--[\s\S]*?-->/, yn = /^<!\[CDATA\[[\s\S]*?\]\]>/, bn = /^<\?[\s\S]*?\?>/, xn = /^<![A-Za-z][\s\S]*?>/;
|
|
685
|
+
function Sn(e, t) {
|
|
686
|
+
if (e[t] !== "<") return null;
|
|
687
|
+
let n = e.substring(t);
|
|
688
|
+
for (let e of [
|
|
689
|
+
vn,
|
|
690
|
+
yn,
|
|
691
|
+
bn,
|
|
692
|
+
xn,
|
|
693
|
+
_n
|
|
694
|
+
]) {
|
|
695
|
+
let r = n.match(e);
|
|
696
|
+
if (r) return {
|
|
697
|
+
html: r[0],
|
|
698
|
+
end: t + r[0].length
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
var Cn = /* @__PURE__ */ new Set("\\`![~*_\n<"), wn = [
|
|
704
|
+
cn,
|
|
705
|
+
ln,
|
|
706
|
+
un,
|
|
707
|
+
dn,
|
|
708
|
+
fn,
|
|
709
|
+
pn,
|
|
710
|
+
mn,
|
|
711
|
+
hn,
|
|
712
|
+
Sn,
|
|
713
|
+
gn
|
|
714
|
+
];
|
|
715
|
+
function G(e) {
|
|
716
|
+
let t = "", n = 0;
|
|
717
|
+
for (; n < e.length;) {
|
|
718
|
+
if (e[n] === "\n" && n >= 2 && e[n - 1] === " " && e[n - 2] === " ") {
|
|
719
|
+
t = t.replace(/ +$/, ""), t += "<br>\n", n++;
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
let r = !1;
|
|
723
|
+
if (Cn.has(e[n])) for (let i of wn) {
|
|
724
|
+
let a = i(e, n);
|
|
725
|
+
if (a) {
|
|
726
|
+
t += a.html, n = a.end, r = !0;
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
if (!r) {
|
|
731
|
+
let r = n;
|
|
732
|
+
for (n++; n < e.length && !Cn.has(e[n]);) n++;
|
|
733
|
+
t += U(e.substring(r, n));
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return t;
|
|
737
|
+
}
|
|
738
|
+
function Tn(e, t) {
|
|
739
|
+
let n = 0, r = t;
|
|
740
|
+
for (; r < e.length && e[r] === "`";) n++, r++;
|
|
741
|
+
let i = r;
|
|
742
|
+
for (; i < e.length;) if (e[i] === "`") {
|
|
743
|
+
let t = 0, a = i;
|
|
744
|
+
for (; i < e.length && e[i] === "`";) t++, i++;
|
|
745
|
+
if (t === n) {
|
|
746
|
+
let t = e.substring(r, a);
|
|
747
|
+
return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t[t.length - 1] === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
|
|
748
|
+
html: `<code>${U(t)}</code>`,
|
|
749
|
+
end: i
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
} else i++;
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
755
|
+
function En(e, t) {
|
|
756
|
+
let n = On(e, t + 1);
|
|
757
|
+
if (n === -1) return null;
|
|
758
|
+
let r = t + 2;
|
|
759
|
+
if (e[n + 1] !== "(") return null;
|
|
760
|
+
let i = n + 2, a = kn(e, i - 1);
|
|
761
|
+
if (a === -1) return null;
|
|
762
|
+
let o = e.substring(r, n), { url: s, title: c } = An(e.substring(i, a));
|
|
763
|
+
if (te(s)) {
|
|
764
|
+
let e = o || c;
|
|
765
|
+
return {
|
|
766
|
+
html: `<video src="${U(s)}"${e ? ` data-name="${U(e)}"` : ""} data-url="${U(s)}" controls></video>`,
|
|
767
|
+
end: a + 1
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
let l = c === void 0 ? "" : ` title="${U(c)}"`;
|
|
771
|
+
return {
|
|
772
|
+
html: `<img src="${U(s)}" alt="${U(o)}"${l}>`,
|
|
773
|
+
end: a + 1
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
function Dn(e, t) {
|
|
777
|
+
let n = t + 1, r = On(e, t);
|
|
778
|
+
if (r === -1 || e[r + 1] !== "(") return null;
|
|
779
|
+
let i = r + 2, a = kn(e, r + 1);
|
|
780
|
+
if (a === -1) return null;
|
|
781
|
+
let o = e.substring(n, r), { url: s, title: c } = An(e.substring(i, a)), l = c === void 0 ? "" : ` title="${U(c)}"`;
|
|
782
|
+
return {
|
|
783
|
+
html: `<a href="${U(s)}"${l}>${G(o)}</a>`,
|
|
784
|
+
end: a + 1
|
|
647
785
|
};
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
786
|
+
}
|
|
787
|
+
function On(e, t) {
|
|
788
|
+
let n = 0;
|
|
789
|
+
for (let r = t; r < e.length; r++) {
|
|
790
|
+
if (e[r] === "\\" && r + 1 < e.length) {
|
|
791
|
+
r++;
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
if (e[r] === "[" && n++, e[r] === "]" && (n--, n === 0)) return r;
|
|
795
|
+
}
|
|
796
|
+
return -1;
|
|
797
|
+
}
|
|
798
|
+
function kn(e, t) {
|
|
799
|
+
let n = 0;
|
|
800
|
+
for (let r = t; r < e.length; r++) {
|
|
801
|
+
if (e[r] === "\\" && r + 1 < e.length) {
|
|
802
|
+
r++;
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
805
|
+
if (e[r] === "(" && n++, e[r] === ")" && (n--, n === 0)) return r;
|
|
806
|
+
}
|
|
807
|
+
return -1;
|
|
808
|
+
}
|
|
809
|
+
function An(e) {
|
|
810
|
+
e = e.trim();
|
|
811
|
+
let t, n;
|
|
812
|
+
if (e.startsWith("<")) {
|
|
813
|
+
let r = e.indexOf(">");
|
|
814
|
+
r === -1 ? (t = e.substring(1), n = "") : (t = e.substring(1, r), n = e.substring(r + 1).trim());
|
|
815
|
+
} else {
|
|
816
|
+
let r = e.length;
|
|
817
|
+
for (let t = 0; t < e.length; t++) {
|
|
818
|
+
if (e[t] === "\\" && t + 1 < e.length) {
|
|
819
|
+
t++;
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
if (e[t] === " " || e[t] === " " || e[t] === "\n") {
|
|
823
|
+
r = t;
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
t = e.substring(0, r), n = e.substring(r).trim();
|
|
828
|
+
}
|
|
829
|
+
let r;
|
|
830
|
+
if (n.length > 0) {
|
|
831
|
+
let e = n.match(/^"([^"]*)"$|^'([^']*)'$|^\(([^)]*)\)$/);
|
|
832
|
+
e && (r = e[1] ?? e[2] ?? e[3]);
|
|
833
|
+
}
|
|
834
|
+
return {
|
|
835
|
+
url: t,
|
|
836
|
+
title: r
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
function K(e, t, n, r, i) {
|
|
840
|
+
let a = n.length, o = t + a;
|
|
841
|
+
if (o >= e.length || e[o] === " " || e[o] === " ") return null;
|
|
842
|
+
let s = o;
|
|
843
|
+
for (; s < e.length;) {
|
|
844
|
+
if (e[s] === "\\" && s + 1 < e.length) {
|
|
845
|
+
s += 2;
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
if (e.substring(s, s + a) === n) {
|
|
849
|
+
if (e[s - 1] === " " || e[s - 1] === " ") {
|
|
850
|
+
s++;
|
|
851
|
+
continue;
|
|
852
|
+
}
|
|
853
|
+
if (a === 1 && (s > 0 && e[s - 1] === n[0] && !(s >= 2 && e[s - 2] === "\\") || s + a < e.length && e[s + a] === n[0])) {
|
|
854
|
+
s++;
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
let t = e.substring(o, s);
|
|
858
|
+
if (t.length === 0) {
|
|
859
|
+
s++;
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
862
|
+
return {
|
|
863
|
+
html: r + G(t) + i,
|
|
864
|
+
end: s + a
|
|
661
865
|
};
|
|
662
|
-
return e.patch(t, n), e.applyData(t, n);
|
|
663
866
|
}
|
|
664
|
-
|
|
867
|
+
s++;
|
|
868
|
+
}
|
|
869
|
+
return null;
|
|
665
870
|
}
|
|
666
|
-
|
|
667
|
-
|
|
871
|
+
var jn = new Set(/* @__PURE__ */ "address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));
|
|
872
|
+
function Mn(e) {
|
|
873
|
+
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
|
|
874
|
+
let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
875
|
+
return t ? jn.has(t[1].toLowerCase()) : !1;
|
|
876
|
+
}
|
|
877
|
+
function q(e) {
|
|
878
|
+
let t = e.split("\n"), n = [], r = 0, i = !0;
|
|
879
|
+
for (; r < t.length;) {
|
|
880
|
+
let e = t[r];
|
|
881
|
+
if (e.trim() === "") {
|
|
882
|
+
i = !0, r++;
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
let a = e.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
|
|
886
|
+
if (a) {
|
|
887
|
+
let e = a[1], o = e[0], s = e.length, c = a[2].trim(), l = [];
|
|
888
|
+
for (r++; r < t.length;) {
|
|
889
|
+
if (t[r].match(RegExp(`^ {0,3}${o}{${s},}\\s*$`))) {
|
|
890
|
+
r++;
|
|
891
|
+
break;
|
|
892
|
+
}
|
|
893
|
+
l.push(t[r]), r++;
|
|
894
|
+
}
|
|
895
|
+
n.push({
|
|
896
|
+
type: "codeBlock",
|
|
897
|
+
language: c || "",
|
|
898
|
+
code: l.join("\n")
|
|
899
|
+
}), i = !1;
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
let o = e.match(/^(#{1,6})\s+(.+?)(?:\s+#+\s*|\s*)$/);
|
|
903
|
+
if (o) {
|
|
904
|
+
n.push({
|
|
905
|
+
type: "heading",
|
|
906
|
+
level: o[1].length,
|
|
907
|
+
content: o[2]
|
|
908
|
+
}), i = !1, r++;
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e)) {
|
|
912
|
+
let t = n[n.length - 1];
|
|
913
|
+
if (!i && e.trim().match(/^-+$/) && t && t.type === "paragraph") {
|
|
914
|
+
let e = t;
|
|
915
|
+
n[n.length - 1] = {
|
|
916
|
+
type: "heading",
|
|
917
|
+
level: 2,
|
|
918
|
+
content: e.content
|
|
919
|
+
}, i = !1, r++;
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
n.push({ type: "hr" }), i = !1, r++;
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
if (r + 1 < t.length) {
|
|
926
|
+
let a = t[r + 1];
|
|
927
|
+
if (/^={1,}\s*$/.test(a) && e.trim().length > 0) {
|
|
928
|
+
n.push({
|
|
929
|
+
type: "heading",
|
|
930
|
+
level: 1,
|
|
931
|
+
content: e.trim()
|
|
932
|
+
}), i = !1, r += 2;
|
|
933
|
+
continue;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
let s = Nn(t, r);
|
|
937
|
+
if (s) {
|
|
938
|
+
n.push(s.token), r = s.nextLine, i = !1;
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
if (/^\s{0,3}>/.test(e)) {
|
|
942
|
+
let e = [];
|
|
943
|
+
for (; r < t.length && /^\s{0,3}>/.test(t[r]);) e.push(t[r].replace(/^\s{0,3}>\s?/, "")), r++;
|
|
944
|
+
for (; r < t.length;) {
|
|
945
|
+
let n = t[r];
|
|
946
|
+
if (n.trim() === "" || /^\s{0,3}>/.test(n) || /^(#{1,6})\s/.test(n) || /^(`{3,}|~{3,})/.test(n) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(n) || /^\s*([-*+]|\d+[.)])\s+/.test(n) || /^\s*\|(.+\|)+\s*$/.test(n)) break;
|
|
947
|
+
e.push(n), r++;
|
|
948
|
+
}
|
|
949
|
+
n.push({
|
|
950
|
+
type: "blockquote",
|
|
951
|
+
content: e.join("\n")
|
|
952
|
+
}), i = !1;
|
|
953
|
+
continue;
|
|
954
|
+
}
|
|
955
|
+
let c = e.match(/^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\] )?(.*)$/);
|
|
956
|
+
if (c) {
|
|
957
|
+
let e = c[1].length, a = c[2], o = c[3], s = c[4], l = c[5], u, d, f;
|
|
958
|
+
s ? (u = "task", f = s.trim() !== "[ ]") : /^\d+[.)]$/.test(a) ? (u = "ordered", d = parseInt(a, 10)) : u = "bullet";
|
|
959
|
+
let p = e + a.length + o.length + (s ? s.length : 0), m = e + 1, h = (e) => {
|
|
960
|
+
if (e.trim() === "") return !0;
|
|
961
|
+
let t = e.match(/^\s*/)[0].length;
|
|
962
|
+
return !!(t >= p || t >= m && e.match(/^\s*([-*+]|\d+[.)])\s+/));
|
|
963
|
+
};
|
|
964
|
+
r++;
|
|
965
|
+
let g = [];
|
|
966
|
+
for (; r < t.length;) {
|
|
967
|
+
let e = t[r];
|
|
968
|
+
if (e.trim() === "") {
|
|
969
|
+
let e = r + 1;
|
|
970
|
+
for (; e < t.length && t[e].trim() === "";) e++;
|
|
971
|
+
if (e < t.length && h(t[e])) {
|
|
972
|
+
g.push(""), r++;
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
977
|
+
if (!h(e)) break;
|
|
978
|
+
e.match(/^\s*/)[0].length >= p ? g.push(e.substring(p)) : g.push(e.substring(m)), r++;
|
|
979
|
+
}
|
|
980
|
+
let _ = g.join("\n").replace(/^\n+|\n+$/g, "");
|
|
981
|
+
n.push({
|
|
982
|
+
type: "listItem",
|
|
983
|
+
listType: u,
|
|
984
|
+
indent: e,
|
|
985
|
+
content: l.trim(),
|
|
986
|
+
start: d,
|
|
987
|
+
checked: f,
|
|
988
|
+
childContent: _ || void 0
|
|
989
|
+
}), i = !1;
|
|
990
|
+
continue;
|
|
991
|
+
}
|
|
992
|
+
if (Mn(e)) {
|
|
993
|
+
let e = [];
|
|
994
|
+
for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
|
|
995
|
+
n.push({
|
|
996
|
+
type: "rawHtml",
|
|
997
|
+
content: e.join("\n")
|
|
998
|
+
}), i = !1;
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
let l = [e];
|
|
1002
|
+
for (r++; r < t.length;) {
|
|
1003
|
+
let e = t[r];
|
|
1004
|
+
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) || Mn(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
|
|
1005
|
+
l.push(e), r++;
|
|
1006
|
+
}
|
|
1007
|
+
n.push({
|
|
1008
|
+
type: "paragraph",
|
|
1009
|
+
content: l.map((e) => e.replace(/^ {1,3}/, "")).join("\n").replace(/[ \t]+$/, "")
|
|
1010
|
+
}), i = !1;
|
|
1011
|
+
}
|
|
1012
|
+
return n;
|
|
1013
|
+
}
|
|
1014
|
+
function Nn(e, t) {
|
|
1015
|
+
if (t + 1 >= e.length) return null;
|
|
1016
|
+
let n = e[t], r = e[t + 1];
|
|
1017
|
+
if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
|
|
1018
|
+
let i = J(n), a = Pn(r), o = [], s = t + 2;
|
|
1019
|
+
for (; s < e.length;) {
|
|
1020
|
+
let t = e[s];
|
|
1021
|
+
if (!t.includes("|")) break;
|
|
1022
|
+
o.push(J(t)), s++;
|
|
1023
|
+
}
|
|
1024
|
+
return {
|
|
1025
|
+
token: {
|
|
1026
|
+
type: "table",
|
|
1027
|
+
headers: i,
|
|
1028
|
+
rows: o,
|
|
1029
|
+
alignments: a
|
|
1030
|
+
},
|
|
1031
|
+
nextLine: s
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
function J(e) {
|
|
1035
|
+
let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
|
|
1036
|
+
for (let e = 0; e < r.length; e++) r[e] === "\\" && e + 1 < r.length && r[e + 1] === "|" ? (a += "|", e++) : r[e] === "|" ? (i.push(a.trim()), a = "") : a += r[e];
|
|
1037
|
+
return i.push(a.trim()), i;
|
|
1038
|
+
}
|
|
1039
|
+
function Pn(e) {
|
|
1040
|
+
return J(e).map((e) => {
|
|
1041
|
+
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
1042
|
+
return n && r ? "center" : r ? "right" : n ? "left" : null;
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
function Y(e) {
|
|
1046
|
+
let t = "", n = 0;
|
|
1047
|
+
for (; n < e.length;) {
|
|
1048
|
+
let r = e[n];
|
|
1049
|
+
switch (r.type) {
|
|
1050
|
+
case "heading": {
|
|
1051
|
+
let e = r;
|
|
1052
|
+
t += `<h${e.level}>${G(e.content)}</h${e.level}>`, n++;
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1055
|
+
case "paragraph":
|
|
1056
|
+
t += `<p>${G(r.content)}</p>`, n++;
|
|
1057
|
+
break;
|
|
1058
|
+
case "codeBlock": {
|
|
1059
|
+
let e = r, i = e.language ? ` data-language="${U(e.language)}"` : "";
|
|
1060
|
+
t += `<pre><code${i}>${U(e.code)}</code></pre>`, n++;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
case "blockquote": {
|
|
1064
|
+
let e = Y(q(r.content));
|
|
1065
|
+
t += `<blockquote>${e}</blockquote>`, n++;
|
|
1066
|
+
break;
|
|
1067
|
+
}
|
|
1068
|
+
case "hr":
|
|
1069
|
+
t += "<hr>", n++;
|
|
1070
|
+
break;
|
|
1071
|
+
case "listItem": {
|
|
1072
|
+
let r = Fn(e, n);
|
|
1073
|
+
t += r.html, n = r.nextIndex;
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
case "table":
|
|
1077
|
+
t += Ln(r), n++;
|
|
1078
|
+
break;
|
|
1079
|
+
case "rawHtml":
|
|
1080
|
+
t += r.content, n++;
|
|
1081
|
+
break;
|
|
1082
|
+
default: n++;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
return t;
|
|
1086
|
+
}
|
|
1087
|
+
function Fn(e, t) {
|
|
1088
|
+
let n = "", r = t, i = null;
|
|
1089
|
+
for (; r < e.length && e[r].type === "listItem";) {
|
|
1090
|
+
let t = e[r], a = In(t.listType);
|
|
1091
|
+
if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
|
|
1092
|
+
if (a === "ordered") {
|
|
1093
|
+
let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
|
|
1094
|
+
n += `<ol${e}>`;
|
|
1095
|
+
} else n += "<ul>";
|
|
1096
|
+
i = a;
|
|
1097
|
+
}
|
|
1098
|
+
if (t.listType === "task") {
|
|
1099
|
+
let e = t.checked ? " checked" : "";
|
|
1100
|
+
n += `<li><input type="checkbox" disabled${e}><p>${G(t.content)}</p>`;
|
|
1101
|
+
} else n += `<li><p>${G(t.content)}</p>`;
|
|
1102
|
+
if (t.childContent) {
|
|
1103
|
+
let e = q(t.childContent);
|
|
1104
|
+
n += Y(e);
|
|
1105
|
+
}
|
|
1106
|
+
n += "</li>", r++;
|
|
1107
|
+
}
|
|
1108
|
+
return i !== null && (n += `</${i === "ordered" ? "ol" : "ul"}>`), {
|
|
1109
|
+
html: n,
|
|
1110
|
+
nextIndex: r
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
function In(e) {
|
|
1114
|
+
return e === "ordered" ? "ordered" : "bullet";
|
|
1115
|
+
}
|
|
1116
|
+
function Ln(e) {
|
|
1117
|
+
let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
|
|
1118
|
+
if (!n) {
|
|
1119
|
+
t += "<thead><tr>";
|
|
1120
|
+
for (let n = 0; n < r; n++) {
|
|
1121
|
+
let r = e.alignments[n], i = r ? ` align="${r}"` : "";
|
|
1122
|
+
t += `<th${i}>${G(e.headers[n])}</th>`;
|
|
1123
|
+
}
|
|
1124
|
+
t += "</tr></thead>";
|
|
1125
|
+
}
|
|
1126
|
+
if (e.rows.length > 0) {
|
|
1127
|
+
t += "<tbody>";
|
|
1128
|
+
for (let n of e.rows) {
|
|
1129
|
+
t += "<tr>";
|
|
1130
|
+
for (let i = 0; i < r; i++) {
|
|
1131
|
+
let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
|
|
1132
|
+
t += `<td${o}>${G(r)}</td>`;
|
|
1133
|
+
}
|
|
1134
|
+
t += "</tr>";
|
|
1135
|
+
}
|
|
1136
|
+
t += "</tbody>";
|
|
1137
|
+
}
|
|
1138
|
+
return t += "</table>", t;
|
|
1139
|
+
}
|
|
1140
|
+
function Rn(e) {
|
|
1141
|
+
return Y(q(e));
|
|
1142
|
+
}
|
|
1143
|
+
//#endregion
|
|
1144
|
+
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
1145
|
+
function zn(e) {
|
|
1146
|
+
return Rn(e);
|
|
1147
|
+
}
|
|
1148
|
+
function Bn(e, t) {
|
|
1149
|
+
return H(zn(e), t);
|
|
668
1150
|
}
|
|
669
1151
|
//#endregion
|
|
670
1152
|
//#region src/editor/managers/ExportManager.ts
|
|
671
|
-
var
|
|
1153
|
+
var Vn = class {
|
|
672
1154
|
constructor(e) {
|
|
673
1155
|
this.editor = e;
|
|
674
1156
|
}
|
|
675
1157
|
blocksToHTMLLossy(e = this.editor.document) {
|
|
676
|
-
return
|
|
1158
|
+
return me(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
677
1159
|
}
|
|
678
1160
|
blocksToFullHTML(e = this.editor.document) {
|
|
679
|
-
return
|
|
1161
|
+
return Dt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
680
1162
|
}
|
|
681
1163
|
tryParseHTMLToBlocks(e) {
|
|
682
|
-
return
|
|
1164
|
+
return H(e, this.editor.pmSchema);
|
|
683
1165
|
}
|
|
684
1166
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
685
1167
|
return De(e, this.editor.pmSchema, this.editor, {});
|
|
686
1168
|
}
|
|
687
1169
|
tryParseMarkdownToBlocks(e) {
|
|
688
|
-
return
|
|
1170
|
+
return Bn(e, this.editor.pmSchema);
|
|
689
1171
|
}
|
|
690
1172
|
pasteHTML(e, t = !1) {
|
|
691
1173
|
let n = e;
|
|
@@ -699,13 +1181,42 @@ var dn = class {
|
|
|
699
1181
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
700
1182
|
}
|
|
701
1183
|
pasteMarkdown(e) {
|
|
702
|
-
let t =
|
|
1184
|
+
let t = zn(e);
|
|
703
1185
|
return this.pasteHTML(t);
|
|
704
1186
|
}
|
|
705
|
-
}
|
|
1187
|
+
};
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1190
|
+
function Hn(e) {
|
|
1191
|
+
let { bnBlock: t } = f(e), n = g(e.doc), r = e.doc.resolve(t.beforePos), i = r.nodeBefore, a = e.doc.resolve(t.afterPos).nodeAfter, o;
|
|
1192
|
+
return r.depth > 1 && (o = r.node(), o.type.isInGroup("bnBlock") || (o = r.node(r.depth - 1))), {
|
|
1193
|
+
block: m(t.node, n),
|
|
1194
|
+
prevBlock: i === null ? void 0 : m(i, n),
|
|
1195
|
+
nextBlock: a === null ? void 0 : m(a, n),
|
|
1196
|
+
parentBlock: o === void 0 ? void 0 : m(o, n)
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
function Un(e, t, n = "start") {
|
|
1200
|
+
let i = typeof t == "string" ? t : t.id, a = re(g(e.doc)), o = r(i, e.doc);
|
|
1201
|
+
if (!o) throw Error(`Block with ID ${i} not found`);
|
|
1202
|
+
let s = x(o), c = a.blockSchema[s.blockNoteType].content;
|
|
1203
|
+
if (s.isBlockContainer) {
|
|
1204
|
+
let t = s.blockContent;
|
|
1205
|
+
if (c === "none") {
|
|
1206
|
+
e.setSelection(M.create(e.doc, t.beforePos));
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
if (c === "inline") n === "start" ? e.setSelection(P.create(e.doc, t.beforePos + 1)) : e.setSelection(P.create(e.doc, t.afterPos - 1));
|
|
1210
|
+
else if (c === "table") n === "start" ? e.setSelection(P.create(e.doc, t.beforePos + 4)) : e.setSelection(P.create(e.doc, t.afterPos - 4));
|
|
1211
|
+
else throw new w(c);
|
|
1212
|
+
} else Un(e, (n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild).attrs.id, n);
|
|
1213
|
+
}
|
|
1214
|
+
//#endregion
|
|
1215
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/tlds.ts
|
|
1216
|
+
var Wn = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
706
1217
|
//#endregion
|
|
707
1218
|
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
708
|
-
function
|
|
1219
|
+
function Gn(e) {
|
|
709
1220
|
let t = [], n = [], r = 0;
|
|
710
1221
|
for (; r < e.length;) {
|
|
711
1222
|
let i = 0;
|
|
@@ -719,59 +1230,59 @@ function pn(e) {
|
|
|
719
1230
|
}
|
|
720
1231
|
return t;
|
|
721
1232
|
}
|
|
722
|
-
var
|
|
723
|
-
function
|
|
1233
|
+
var Kn = new Set(Gn(Wn)), qn = new Set(["localhost"]), Jn = /[.,;:!?"']+$/, Yn = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Xn = /mailto:[^\s]+/g, Zn = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Qn = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
1234
|
+
function $n(e) {
|
|
724
1235
|
let t = e, n = !0;
|
|
725
1236
|
for (; n;) {
|
|
726
1237
|
n = !1;
|
|
727
1238
|
let e = t;
|
|
728
|
-
t = t.replace(
|
|
1239
|
+
t = t.replace(Jn, ""), t !== e && (n = !0);
|
|
729
1240
|
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
730
|
-
let i =
|
|
731
|
-
if (
|
|
1241
|
+
let i = er(t, e);
|
|
1242
|
+
if (er(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
732
1243
|
else break;
|
|
733
1244
|
}
|
|
734
1245
|
}
|
|
735
1246
|
return t;
|
|
736
1247
|
}
|
|
737
|
-
function
|
|
1248
|
+
function er(e, t) {
|
|
738
1249
|
let n = 0;
|
|
739
1250
|
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
740
1251
|
return n;
|
|
741
1252
|
}
|
|
742
|
-
function
|
|
1253
|
+
function tr(e) {
|
|
743
1254
|
let t = e.split(".");
|
|
744
1255
|
return t[t.length - 1].toLowerCase();
|
|
745
1256
|
}
|
|
746
|
-
function
|
|
747
|
-
let t =
|
|
748
|
-
return
|
|
1257
|
+
function nr(e) {
|
|
1258
|
+
let t = tr(e);
|
|
1259
|
+
return Kn.has(t);
|
|
749
1260
|
}
|
|
750
|
-
function
|
|
1261
|
+
function rr(e, t, n) {
|
|
751
1262
|
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
752
1263
|
}
|
|
753
|
-
function
|
|
1264
|
+
function ir(e, t) {
|
|
754
1265
|
if (!e) return [];
|
|
755
1266
|
let n = t?.defaultProtocol || "http", r = [];
|
|
756
|
-
for (let t of e.matchAll(
|
|
1267
|
+
for (let t of e.matchAll(Yn)) r.push({
|
|
757
1268
|
type: "url",
|
|
758
1269
|
value: t[0],
|
|
759
1270
|
start: t.index,
|
|
760
1271
|
end: t.index + t[0].length
|
|
761
1272
|
});
|
|
762
|
-
for (let t of e.matchAll(
|
|
1273
|
+
for (let t of e.matchAll(Xn)) r.push({
|
|
763
1274
|
type: "url",
|
|
764
1275
|
value: t[0],
|
|
765
1276
|
start: t.index,
|
|
766
1277
|
end: t.index + t[0].length
|
|
767
1278
|
});
|
|
768
|
-
for (let t of e.matchAll(
|
|
1279
|
+
for (let t of e.matchAll(Zn)) r.push({
|
|
769
1280
|
type: "email",
|
|
770
1281
|
value: t[0],
|
|
771
1282
|
start: t.index,
|
|
772
1283
|
end: t.index + t[0].length
|
|
773
1284
|
});
|
|
774
|
-
for (let t of e.matchAll(
|
|
1285
|
+
for (let t of e.matchAll(Qn)) r.push({
|
|
775
1286
|
type: "url",
|
|
776
1287
|
value: t[0],
|
|
777
1288
|
start: t.index,
|
|
@@ -782,18 +1293,18 @@ function En(e, t) {
|
|
|
782
1293
|
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
783
1294
|
let o = [];
|
|
784
1295
|
for (let e of i) {
|
|
785
|
-
let t =
|
|
1296
|
+
let t = $n(e.value);
|
|
786
1297
|
if (!t) continue;
|
|
787
1298
|
let r = e.start, i = r + t.length;
|
|
788
1299
|
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
789
1300
|
let e = new URL("http://" + t).hostname;
|
|
790
|
-
if (!
|
|
1301
|
+
if (!nr(e)) continue;
|
|
791
1302
|
}
|
|
792
1303
|
if (e.type === "email") {
|
|
793
1304
|
let e = t.split("@")[1];
|
|
794
|
-
if (!
|
|
1305
|
+
if (!nr(e)) continue;
|
|
795
1306
|
}
|
|
796
|
-
let a =
|
|
1307
|
+
let a = rr(t, e.type, n);
|
|
797
1308
|
o.push({
|
|
798
1309
|
type: e.type,
|
|
799
1310
|
value: t,
|
|
@@ -805,7 +1316,7 @@ function En(e, t) {
|
|
|
805
1316
|
}
|
|
806
1317
|
return o;
|
|
807
1318
|
}
|
|
808
|
-
function
|
|
1319
|
+
function ar(e, t = "http") {
|
|
809
1320
|
if (!e) return [X(e, 0, 0)];
|
|
810
1321
|
for (let [n, r] of [
|
|
811
1322
|
["(", ")"],
|
|
@@ -813,34 +1324,34 @@ function Dn(e, t = "http") {
|
|
|
813
1324
|
["{", "}"]
|
|
814
1325
|
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
815
1326
|
let i = e.slice(1, -1);
|
|
816
|
-
if (
|
|
1327
|
+
if (or(i)) return [
|
|
817
1328
|
X(n, 0, 1),
|
|
818
|
-
|
|
1329
|
+
sr(i, 1, 1 + i.length, t),
|
|
819
1330
|
X(r, 1 + i.length, e.length)
|
|
820
1331
|
];
|
|
821
1332
|
}
|
|
822
1333
|
if (e.endsWith(".") && e.length > 1) {
|
|
823
1334
|
let n = e.slice(0, -1);
|
|
824
|
-
if (
|
|
1335
|
+
if (or(n)) return [sr(n, 0, n.length, t), X(".", n.length, e.length)];
|
|
825
1336
|
}
|
|
826
|
-
return
|
|
1337
|
+
return or(e) ? [sr(e, 0, e.length, t)] : [X(e, 0, e.length)];
|
|
827
1338
|
}
|
|
828
|
-
function
|
|
829
|
-
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) ||
|
|
1339
|
+
function or(e) {
|
|
1340
|
+
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || qn.has(e.toLowerCase())) return !0;
|
|
830
1341
|
let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
|
|
831
1342
|
if (t) {
|
|
832
1343
|
let e = t[1].toLowerCase();
|
|
833
|
-
if (
|
|
1344
|
+
if (Kn.has(e)) return !0;
|
|
834
1345
|
}
|
|
835
1346
|
return !1;
|
|
836
1347
|
}
|
|
837
|
-
function
|
|
1348
|
+
function sr(e, t, n, r) {
|
|
838
1349
|
let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
|
|
839
1350
|
return {
|
|
840
1351
|
type: i,
|
|
841
1352
|
value: e,
|
|
842
1353
|
isLink: !0,
|
|
843
|
-
href:
|
|
1354
|
+
href: rr(e, i, r),
|
|
844
1355
|
start: t,
|
|
845
1356
|
end: n
|
|
846
1357
|
};
|
|
@@ -857,15 +1368,15 @@ function X(e, t, n) {
|
|
|
857
1368
|
}
|
|
858
1369
|
//#endregion
|
|
859
1370
|
//#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
|
|
860
|
-
var
|
|
1371
|
+
var cr = "[\0- \xA0 -\u2029 ]", lr = new RegExp(cr), ur = RegExp(`${cr}$`), dr = new RegExp(cr, "g");
|
|
861
1372
|
//#endregion
|
|
862
1373
|
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
863
|
-
function
|
|
1374
|
+
function fr(e) {
|
|
864
1375
|
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
865
1376
|
}
|
|
866
|
-
function
|
|
867
|
-
return new
|
|
868
|
-
key: new
|
|
1377
|
+
function pr(e) {
|
|
1378
|
+
return new ot({
|
|
1379
|
+
key: new st("autolink"),
|
|
869
1380
|
appendTransaction: (t, n, r) => {
|
|
870
1381
|
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
871
1382
|
if (!i || a) return;
|
|
@@ -875,16 +1386,16 @@ function Mn(e) {
|
|
|
875
1386
|
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
876
1387
|
else if (n.length) {
|
|
877
1388
|
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
878
|
-
if (!
|
|
1389
|
+
if (!ur.test(e)) return;
|
|
879
1390
|
i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
|
|
880
1391
|
}
|
|
881
1392
|
if (i && a) {
|
|
882
|
-
let t = a.split(
|
|
1393
|
+
let t = a.split(lr).filter(Boolean);
|
|
883
1394
|
if (t.length <= 0) return;
|
|
884
1395
|
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
885
1396
|
if (!n) return;
|
|
886
|
-
let c =
|
|
887
|
-
if (!
|
|
1397
|
+
let c = ar(n, e.defaultProtocol);
|
|
1398
|
+
if (!fr(c)) return;
|
|
888
1399
|
c.filter((e) => e.isLink).map((e) => ({
|
|
889
1400
|
...e,
|
|
890
1401
|
from: s + e.start + 1,
|
|
@@ -899,9 +1410,9 @@ function Mn(e) {
|
|
|
899
1410
|
}
|
|
900
1411
|
//#endregion
|
|
901
1412
|
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
902
|
-
function
|
|
903
|
-
return new
|
|
904
|
-
key: new
|
|
1413
|
+
function mr(e) {
|
|
1414
|
+
return new ot({
|
|
1415
|
+
key: new st("handleClickLink"),
|
|
905
1416
|
props: { handleClick: (t, n, r) => {
|
|
906
1417
|
if (r.button !== 0 || !t.editable) return !1;
|
|
907
1418
|
let i = null;
|
|
@@ -924,9 +1435,9 @@ function Nn(e) {
|
|
|
924
1435
|
}
|
|
925
1436
|
//#endregion
|
|
926
1437
|
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
927
|
-
function
|
|
928
|
-
return new
|
|
929
|
-
key: new
|
|
1438
|
+
function hr(e) {
|
|
1439
|
+
return new ot({
|
|
1440
|
+
key: new st("handlePasteLink"),
|
|
930
1441
|
props: { handlePaste: (t, n, r) => {
|
|
931
1442
|
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
932
1443
|
if (c) return !1;
|
|
@@ -934,26 +1445,26 @@ function Pn(e) {
|
|
|
934
1445
|
r.content.forEach((e) => {
|
|
935
1446
|
l += e.textContent;
|
|
936
1447
|
});
|
|
937
|
-
let u =
|
|
1448
|
+
let u = ir(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
938
1449
|
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
939
1450
|
} }
|
|
940
1451
|
});
|
|
941
1452
|
}
|
|
942
1453
|
//#endregion
|
|
943
1454
|
//#region src/extensions/tiptap-extensions/Link/link.ts
|
|
944
|
-
var
|
|
945
|
-
function
|
|
1455
|
+
var Z = "https", gr = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
|
|
1456
|
+
function _r(e) {
|
|
946
1457
|
if (!e) return !0;
|
|
947
|
-
let t = e.replace(
|
|
948
|
-
return
|
|
1458
|
+
let t = e.replace(dr, "");
|
|
1459
|
+
return gr.test(t);
|
|
949
1460
|
}
|
|
950
|
-
function
|
|
1461
|
+
function vr(e) {
|
|
951
1462
|
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
952
1463
|
if (t || n && !e.includes("@")) return !0;
|
|
953
1464
|
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
954
1465
|
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
955
1466
|
}
|
|
956
|
-
var
|
|
1467
|
+
var yr = k.create({
|
|
957
1468
|
name: "link",
|
|
958
1469
|
keepOnSplit: !1,
|
|
959
1470
|
exitable: !0,
|
|
@@ -968,7 +1479,7 @@ var zn = k.create({
|
|
|
968
1479
|
},
|
|
969
1480
|
editor: void 0,
|
|
970
1481
|
onClick: void 0,
|
|
971
|
-
isValidLink:
|
|
1482
|
+
isValidLink: _r
|
|
972
1483
|
};
|
|
973
1484
|
},
|
|
974
1485
|
addAttributes() {
|
|
@@ -992,11 +1503,11 @@ var zn = k.create({
|
|
|
992
1503
|
renderHTML({ HTMLAttributes: e }) {
|
|
993
1504
|
return this.options.isValidLink(e.href) ? [
|
|
994
1505
|
"a",
|
|
995
|
-
|
|
1506
|
+
tt(e, this.options.HTMLAttributes),
|
|
996
1507
|
0
|
|
997
1508
|
] : [
|
|
998
1509
|
"a",
|
|
999
|
-
|
|
1510
|
+
tt({
|
|
1000
1511
|
...e,
|
|
1001
1512
|
href: ""
|
|
1002
1513
|
}, this.options.HTMLAttributes),
|
|
@@ -1009,8 +1520,8 @@ var zn = k.create({
|
|
|
1009
1520
|
find: (t) => {
|
|
1010
1521
|
let n = [];
|
|
1011
1522
|
if (t) {
|
|
1012
|
-
let r =
|
|
1013
|
-
for (let e of r)
|
|
1523
|
+
let r = ir(t, { defaultProtocol: Z }).filter((t) => t.isLink && e(t.value));
|
|
1524
|
+
for (let e of r) vr(e.value) && n.push({
|
|
1014
1525
|
text: e.value,
|
|
1015
1526
|
data: { href: e.href },
|
|
1016
1527
|
index: e.start
|
|
@@ -1024,33 +1535,33 @@ var zn = k.create({
|
|
|
1024
1535
|
},
|
|
1025
1536
|
addProseMirrorPlugins() {
|
|
1026
1537
|
let e = [];
|
|
1027
|
-
return e.push(
|
|
1538
|
+
return e.push(pr({
|
|
1028
1539
|
type: this.type,
|
|
1029
|
-
defaultProtocol:
|
|
1540
|
+
defaultProtocol: Z,
|
|
1030
1541
|
validate: this.options.isValidLink,
|
|
1031
|
-
shouldAutoLink:
|
|
1032
|
-
})), e.push(
|
|
1542
|
+
shouldAutoLink: vr
|
|
1543
|
+
})), e.push(mr({
|
|
1033
1544
|
type: this.type,
|
|
1034
1545
|
tiptapEditor: this.editor,
|
|
1035
1546
|
editor: this.options.editor,
|
|
1036
1547
|
onClick: this.options.onClick
|
|
1037
|
-
})), e.push(
|
|
1548
|
+
})), e.push(hr({
|
|
1038
1549
|
editor: this.editor,
|
|
1039
|
-
defaultProtocol:
|
|
1550
|
+
defaultProtocol: Z,
|
|
1040
1551
|
type: this.type,
|
|
1041
|
-
shouldAutoLink:
|
|
1552
|
+
shouldAutoLink: vr,
|
|
1042
1553
|
isValidLink: this.options.isValidLink
|
|
1043
1554
|
})), e;
|
|
1044
1555
|
}
|
|
1045
|
-
}),
|
|
1556
|
+
}), br = Me(({ editor: e, options: t }) => ({
|
|
1046
1557
|
key: "link",
|
|
1047
|
-
tiptapExtensions: [
|
|
1558
|
+
tiptapExtensions: [yr.configure({
|
|
1048
1559
|
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
1049
1560
|
editor: e,
|
|
1050
1561
|
onClick: t.onClick,
|
|
1051
1562
|
...t.isValidLink ? { isValidLink: t.isValidLink } : {}
|
|
1052
1563
|
})]
|
|
1053
|
-
})),
|
|
1564
|
+
})), xr = [
|
|
1054
1565
|
"vscode-editor-data",
|
|
1055
1566
|
"blocknote/html",
|
|
1056
1567
|
"text/markdown",
|
|
@@ -1060,21 +1571,21 @@ var zn = k.create({
|
|
|
1060
1571
|
];
|
|
1061
1572
|
//#endregion
|
|
1062
1573
|
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
1063
|
-
function
|
|
1574
|
+
function Sr(e, t) {
|
|
1064
1575
|
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
1065
1576
|
return e === t;
|
|
1066
1577
|
}
|
|
1067
|
-
function
|
|
1578
|
+
function Cr(e, t) {
|
|
1068
1579
|
let n = e.split("/"), r = t.split("/");
|
|
1069
1580
|
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
1070
1581
|
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
1071
1582
|
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
1072
1583
|
}
|
|
1073
|
-
function
|
|
1584
|
+
function wr(e, t, n, r = "after") {
|
|
1074
1585
|
let i;
|
|
1075
1586
|
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
1076
1587
|
}
|
|
1077
|
-
async function
|
|
1588
|
+
async function Tr(e, t) {
|
|
1078
1589
|
if (!t.uploadFile) {
|
|
1079
1590
|
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
1080
1591
|
return;
|
|
@@ -1082,7 +1593,7 @@ async function Gn(e, t) {
|
|
|
1082
1593
|
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
1083
1594
|
if (n === null) return;
|
|
1084
1595
|
let r = null;
|
|
1085
|
-
for (let e of
|
|
1596
|
+
for (let e of xr) if (n.types.includes(e)) {
|
|
1086
1597
|
r = e;
|
|
1087
1598
|
break;
|
|
1088
1599
|
}
|
|
@@ -1094,7 +1605,7 @@ async function Gn(e, t) {
|
|
|
1094
1605
|
let r = "file";
|
|
1095
1606
|
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
1096
1607
|
let a = t.startsWith("."), o = i[n].getAsFile();
|
|
1097
|
-
if (o && (!a && o.type &&
|
|
1608
|
+
if (o && (!a && o.type && Cr(i[n].type, t) || a && Sr("." + o.name.split(".").pop(), t))) {
|
|
1098
1609
|
r = e.config.type;
|
|
1099
1610
|
break;
|
|
1100
1611
|
}
|
|
@@ -1107,7 +1618,7 @@ async function Gn(e, t) {
|
|
|
1107
1618
|
}, i;
|
|
1108
1619
|
if (e.type === "paste") {
|
|
1109
1620
|
let e = t.getTextCursorPosition().block;
|
|
1110
|
-
i =
|
|
1621
|
+
i = wr(t, e, n);
|
|
1111
1622
|
} else if (e.type === "drop") {
|
|
1112
1623
|
let r = {
|
|
1113
1624
|
left: e.clientX,
|
|
@@ -1116,7 +1627,7 @@ async function Gn(e, t) {
|
|
|
1116
1627
|
if (!a) return;
|
|
1117
1628
|
i = t.transact((e) => {
|
|
1118
1629
|
let i = C(e.doc, a.pos), o = (t.domElement?.querySelector(`[data-id="${i.node.attrs.id}"]`))?.getBoundingClientRect();
|
|
1119
|
-
return
|
|
1630
|
+
return wr(t, t.getBlock(i.node.attrs.id), n, o && (o.top + o.bottom) / 2 > r.top ? "before" : "after");
|
|
1120
1631
|
});
|
|
1121
1632
|
} else return;
|
|
1122
1633
|
let o = await t.uploadFile(a, i), s = typeof o == "string" ? { props: { url: o } } : { ...o };
|
|
@@ -1127,63 +1638,65 @@ async function Gn(e, t) {
|
|
|
1127
1638
|
}
|
|
1128
1639
|
//#endregion
|
|
1129
1640
|
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
1130
|
-
var
|
|
1641
|
+
var Er = (e) => O.create({
|
|
1131
1642
|
name: "dropFile",
|
|
1132
1643
|
addProseMirrorPlugins() {
|
|
1133
|
-
return [new
|
|
1644
|
+
return [new N({ props: { handleDOMEvents: { drop(t, n) {
|
|
1134
1645
|
if (!e.isEditable) return;
|
|
1135
1646
|
let r = null;
|
|
1136
|
-
for (let e of
|
|
1647
|
+
for (let e of xr) if (n.dataTransfer.types.includes(e)) {
|
|
1137
1648
|
r = e;
|
|
1138
1649
|
break;
|
|
1139
1650
|
}
|
|
1140
|
-
return r === null ? !0 : r === "Files" ? (
|
|
1651
|
+
return r === null ? !0 : r === "Files" ? (Tr(n, e), !0) : !1;
|
|
1141
1652
|
} } } })];
|
|
1142
1653
|
}
|
|
1143
|
-
}),
|
|
1654
|
+
}), Dr = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, Or = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, kr = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, Ar = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, jr = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, Mr = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, Nr = /\n{2} {0,3}-{2,48}\n{2}/, Pr = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, Fr = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, Ir = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, Lr = /^\s*\|(.+\|)+\s*$/m, Rr = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, zr = /^\s*\|(.+\|)+\s*$/m, Br = (e) => Dr.test(e) || Or.test(e) || kr.test(e) || Ar.test(e) || jr.test(e) || Mr.test(e) || Nr.test(e) || Pr.test(e) || Fr.test(e) || Ir.test(e) || Lr.test(e) || Rr.test(e) || zr.test(e);
|
|
1144
1655
|
//#endregion
|
|
1145
1656
|
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
1146
|
-
|
|
1657
|
+
function Vr(e, t) {
|
|
1147
1658
|
let { schema: n } = t.state;
|
|
1148
1659
|
if (!e.clipboardData) return !1;
|
|
1149
1660
|
let r = e.clipboardData.getData("text/plain");
|
|
1150
|
-
if (!r) return !1;
|
|
1151
|
-
if (!n.nodes.codeBlock) return t.pasteText(r), !0;
|
|
1661
|
+
if (!r || !n.nodes.codeBlock) return !1;
|
|
1152
1662
|
let i = e.clipboardData.getData("vscode-editor-data"), a = (i ? JSON.parse(i) : void 0)?.mode;
|
|
1153
1663
|
return a ? (t.pasteHTML(`<pre><code class="language-${a}">${r.replace(/\r\n?/g, "\n")}</code></pre>`), !0) : !1;
|
|
1154
1664
|
}
|
|
1155
1665
|
//#endregion
|
|
1156
1666
|
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
1157
|
-
function
|
|
1667
|
+
function Hr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
1158
1668
|
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
1159
1669
|
let n = e.clipboardData?.getData("text/plain");
|
|
1160
1670
|
if (n) return t.pasteText(n), !0;
|
|
1161
1671
|
}
|
|
1162
1672
|
let i;
|
|
1163
|
-
for (let t of
|
|
1673
|
+
for (let t of xr) if (e.clipboardData.types.includes(t)) {
|
|
1164
1674
|
i = t;
|
|
1165
1675
|
break;
|
|
1166
1676
|
}
|
|
1167
1677
|
if (!i) return !0;
|
|
1168
|
-
if (i === "vscode-editor-data")
|
|
1169
|
-
|
|
1678
|
+
if (i === "vscode-editor-data") {
|
|
1679
|
+
if (Vr(e, t.prosemirrorView)) return !0;
|
|
1680
|
+
i = "text/plain";
|
|
1681
|
+
}
|
|
1682
|
+
if (i === "Files") return Tr(e, t), !0;
|
|
1170
1683
|
let a = e.clipboardData.getData(i);
|
|
1171
1684
|
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
1172
1685
|
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
1173
1686
|
if (n) {
|
|
1174
1687
|
let n = e.clipboardData.getData("text/plain");
|
|
1175
|
-
if (
|
|
1688
|
+
if (Br(n)) return t.pasteMarkdown(n), !0;
|
|
1176
1689
|
}
|
|
1177
1690
|
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
1178
1691
|
}
|
|
1179
|
-
var
|
|
1692
|
+
var Ur = (e, t) => O.create({
|
|
1180
1693
|
name: "pasteFromClipboard",
|
|
1181
1694
|
addProseMirrorPlugins() {
|
|
1182
|
-
return [new
|
|
1695
|
+
return [new N({ props: { handleDOMEvents: { paste(n, r) {
|
|
1183
1696
|
if (r.preventDefault(), e.isEditable) return t({
|
|
1184
1697
|
event: r,
|
|
1185
1698
|
editor: e,
|
|
1186
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) =>
|
|
1699
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Hr({
|
|
1187
1700
|
event: r,
|
|
1188
1701
|
editor: e,
|
|
1189
1702
|
prioritizeMarkdownOverHTML: t,
|
|
@@ -1195,20 +1708,20 @@ var lr = (e, t) => O.create({
|
|
|
1195
1708
|
});
|
|
1196
1709
|
//#endregion
|
|
1197
1710
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1198
|
-
function
|
|
1199
|
-
let r = !1, i = e.state.selection instanceof
|
|
1711
|
+
function Wr(e, t, n) {
|
|
1712
|
+
let r = !1, i = e.state.selection instanceof it;
|
|
1200
1713
|
if (!i) {
|
|
1201
1714
|
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
1202
1715
|
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
1203
1716
|
r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
|
|
1204
1717
|
}
|
|
1205
|
-
let a, o =
|
|
1718
|
+
let a, o = me(e.state.schema, n);
|
|
1206
1719
|
if (i) {
|
|
1207
1720
|
t.firstChild?.type.name === "table" && (t = t.firstChild.content);
|
|
1208
|
-
let e =
|
|
1721
|
+
let e = oe(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1209
1722
|
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
1210
1723
|
} else if (r) {
|
|
1211
|
-
let e =
|
|
1724
|
+
let e = ae(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1212
1725
|
a = o.exportInlineContent(e, {});
|
|
1213
1726
|
} else {
|
|
1214
1727
|
let e = xe(t);
|
|
@@ -1216,16 +1729,16 @@ function ur(e, t, n) {
|
|
|
1216
1729
|
}
|
|
1217
1730
|
return a;
|
|
1218
1731
|
}
|
|
1219
|
-
function
|
|
1220
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new
|
|
1221
|
-
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i =
|
|
1732
|
+
function Gr(e, t) {
|
|
1733
|
+
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new M(t.doc.resolve(e.state.selection.from - 1))));
|
|
1734
|
+
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = Wr(e, r, t);
|
|
1222
1735
|
return {
|
|
1223
1736
|
clipboardHTML: n,
|
|
1224
1737
|
externalHTML: i,
|
|
1225
|
-
markdown:
|
|
1738
|
+
markdown: ye(i)
|
|
1226
1739
|
};
|
|
1227
1740
|
}
|
|
1228
|
-
var
|
|
1741
|
+
var Kr = (e) => {
|
|
1229
1742
|
if (e.state.selection.empty) return !0;
|
|
1230
1743
|
let t = window.getSelection();
|
|
1231
1744
|
if (t && !t.isCollapsed) {
|
|
@@ -1236,37 +1749,37 @@ var fr = (e) => {
|
|
|
1236
1749
|
}
|
|
1237
1750
|
}
|
|
1238
1751
|
return !1;
|
|
1239
|
-
},
|
|
1752
|
+
}, qr = (e, t, n) => {
|
|
1240
1753
|
n.preventDefault(), n.clipboardData.clearData();
|
|
1241
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1754
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = Gr(t, e);
|
|
1242
1755
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
1243
|
-
},
|
|
1756
|
+
}, Jr = (e) => O.create({
|
|
1244
1757
|
name: "copyToClipboard",
|
|
1245
1758
|
addProseMirrorPlugins() {
|
|
1246
|
-
return [new
|
|
1759
|
+
return [new N({ props: { handleDOMEvents: {
|
|
1247
1760
|
copy(t, n) {
|
|
1248
|
-
return
|
|
1761
|
+
return Kr(t) || qr(e, t, n), !0;
|
|
1249
1762
|
},
|
|
1250
1763
|
cut(t, n) {
|
|
1251
|
-
return
|
|
1764
|
+
return Kr(t) ? !0 : (qr(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
1252
1765
|
},
|
|
1253
1766
|
dragstart(t, n) {
|
|
1254
1767
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
1255
|
-
e.transact((e) => e.setSelection(new
|
|
1256
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1768
|
+
e.transact((e) => e.setSelection(new M(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
1769
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = Gr(t, e);
|
|
1257
1770
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
1258
1771
|
}
|
|
1259
1772
|
} } })];
|
|
1260
1773
|
}
|
|
1261
|
-
}),
|
|
1774
|
+
}), Yr = O.create({
|
|
1262
1775
|
name: "blockBackgroundColor",
|
|
1263
1776
|
addGlobalAttributes() {
|
|
1264
1777
|
return [{
|
|
1265
1778
|
types: ["tableCell", "tableHeader"],
|
|
1266
|
-
attributes: { backgroundColor:
|
|
1779
|
+
attributes: { backgroundColor: p() }
|
|
1267
1780
|
}];
|
|
1268
1781
|
}
|
|
1269
|
-
}),
|
|
1782
|
+
}), Xr = A.create({
|
|
1270
1783
|
name: "hardBreak",
|
|
1271
1784
|
inline: !0,
|
|
1272
1785
|
group: "inline",
|
|
@@ -1277,33 +1790,33 @@ var fr = (e) => {
|
|
|
1277
1790
|
return [{ tag: "br" }];
|
|
1278
1791
|
},
|
|
1279
1792
|
renderHTML({ HTMLAttributes: e }) {
|
|
1280
|
-
return ["br",
|
|
1793
|
+
return ["br", tt(this.options.HTMLAttributes, e)];
|
|
1281
1794
|
},
|
|
1282
1795
|
renderText() {
|
|
1283
1796
|
return "\n";
|
|
1284
1797
|
}
|
|
1285
|
-
}),
|
|
1798
|
+
}), Zr = (e, t) => {
|
|
1286
1799
|
let n = e.resolve(t), r = n.depth - 1;
|
|
1287
1800
|
if (r < 1) return;
|
|
1288
1801
|
let i = n.before(r), a = e.resolve(i).nodeAfter;
|
|
1289
|
-
if (a) return a.type.spec.group?.includes("bnBlock") ?
|
|
1802
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? v(e.resolve(i)) : Zr(e, i);
|
|
1290
1803
|
}, Q = (e, t) => {
|
|
1291
1804
|
let n = e.resolve(t), r = n.index();
|
|
1292
1805
|
if (r === 0) return;
|
|
1293
1806
|
let i = n.posAtIndex(r - 1);
|
|
1294
|
-
return
|
|
1807
|
+
return v(e.resolve(i));
|
|
1295
1808
|
}, $ = (e, t) => {
|
|
1296
1809
|
let n = e.resolve(t), r = n.index();
|
|
1297
1810
|
if (r === n.node().childCount - 1) return;
|
|
1298
1811
|
let i = n.posAtIndex(r + 1);
|
|
1299
|
-
return
|
|
1300
|
-
},
|
|
1812
|
+
return v(e.resolve(i));
|
|
1813
|
+
}, Qr = (e, t) => {
|
|
1301
1814
|
for (; t.childContainer;) {
|
|
1302
1815
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
1303
|
-
t =
|
|
1816
|
+
t = v(e.resolve(r));
|
|
1304
1817
|
}
|
|
1305
1818
|
return t;
|
|
1306
|
-
},
|
|
1819
|
+
}, $r = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", ei = (e, t, n, r) => {
|
|
1307
1820
|
if (!r.isBlockContainer) throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);
|
|
1308
1821
|
if (r.childContainer) {
|
|
1309
1822
|
let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
|
|
@@ -1317,66 +1830,66 @@ var fr = (e) => {
|
|
|
1317
1830
|
t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
|
|
1318
1831
|
}
|
|
1319
1832
|
return !0;
|
|
1320
|
-
},
|
|
1321
|
-
let r =
|
|
1833
|
+
}, ti = (e) => ({ state: t, dispatch: n }) => {
|
|
1834
|
+
let r = v(t.doc.resolve(e)), i = Q(t.doc, r.bnBlock.beforePos);
|
|
1322
1835
|
if (!i) return !1;
|
|
1323
|
-
let a =
|
|
1324
|
-
return
|
|
1325
|
-
},
|
|
1836
|
+
let a = Qr(t.doc, i);
|
|
1837
|
+
return $r(a, r) ? ei(t, n, a, r) : !1;
|
|
1838
|
+
}, ni = O.create({
|
|
1326
1839
|
priority: 50,
|
|
1327
1840
|
addKeyboardShortcuts() {
|
|
1328
1841
|
let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1329
1842
|
() => t.deleteSelection(),
|
|
1330
1843
|
() => t.undoInputRule(),
|
|
1331
1844
|
() => t.command(({ state: e }) => {
|
|
1332
|
-
let n =
|
|
1845
|
+
let n = _(e);
|
|
1333
1846
|
if (!n.isBlockContainer) return !1;
|
|
1334
1847
|
let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
|
|
1335
|
-
return r && !i ? t.command(
|
|
1848
|
+
return r && !i ? t.command(c(n.bnBlock.beforePos, {
|
|
1336
1849
|
type: "paragraph",
|
|
1337
1850
|
props: {}
|
|
1338
1851
|
})) : !1;
|
|
1339
1852
|
}),
|
|
1340
1853
|
() => t.command(({ state: e, tr: t }) => {
|
|
1341
|
-
let n =
|
|
1854
|
+
let n = _(e);
|
|
1342
1855
|
if (!n.isBlockContainer) return !1;
|
|
1343
1856
|
let { blockContent: r } = n;
|
|
1344
|
-
return e.selection.from === r.beforePos + 1 ?
|
|
1857
|
+
return e.selection.from === r.beforePos + 1 ? V(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1345
1858
|
}),
|
|
1346
1859
|
() => t.command(({ state: t }) => {
|
|
1347
|
-
let n =
|
|
1860
|
+
let n = _(t);
|
|
1348
1861
|
if (!n.isBlockContainer) return !1;
|
|
1349
1862
|
let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1350
1863
|
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
1351
1864
|
let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
|
|
1352
|
-
return o && s ? e().command(
|
|
1865
|
+
return o && s ? e().command(ti(c)).scrollIntoView().run() : !1;
|
|
1353
1866
|
}),
|
|
1354
1867
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1355
|
-
let r =
|
|
1868
|
+
let r = _(e);
|
|
1356
1869
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1357
1870
|
let i = Q(e.doc, r.bnBlock.beforePos);
|
|
1358
1871
|
if (!i || i.isBlockContainer) return !1;
|
|
1359
1872
|
if (n) {
|
|
1360
1873
|
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
1361
|
-
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(
|
|
1874
|
+
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(n.pos + 1))), !0;
|
|
1362
1875
|
}
|
|
1363
1876
|
return !1;
|
|
1364
1877
|
}),
|
|
1365
1878
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1366
|
-
let r =
|
|
1879
|
+
let r = _(e);
|
|
1367
1880
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1368
1881
|
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1369
1882
|
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1370
1883
|
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
1371
|
-
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos),
|
|
1884
|
+
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), R(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(o.pos))))), !0;
|
|
1372
1885
|
}),
|
|
1373
1886
|
() => t.command(({ state: t }) => {
|
|
1374
|
-
let n =
|
|
1887
|
+
let n = _(t);
|
|
1375
1888
|
if (!n.isBlockContainer) return !1;
|
|
1376
1889
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1377
1890
|
let r = Q(t.doc, n.bnBlock.beforePos);
|
|
1378
1891
|
if (!r) return !1;
|
|
1379
|
-
let i =
|
|
1892
|
+
let i = Qr(t.doc, r);
|
|
1380
1893
|
if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
|
|
1381
1894
|
let a = e();
|
|
1382
1895
|
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1395,11 +1908,11 @@ var fr = (e) => {
|
|
|
1395
1908
|
return !1;
|
|
1396
1909
|
}),
|
|
1397
1910
|
() => t.command(({ state: t }) => {
|
|
1398
|
-
let n =
|
|
1911
|
+
let n = _(t);
|
|
1399
1912
|
if (!n.isBlockContainer) return !1;
|
|
1400
1913
|
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1401
1914
|
if (a && r && i) {
|
|
1402
|
-
let r =
|
|
1915
|
+
let r = Qr(t.doc, a);
|
|
1403
1916
|
if (!r.isBlockContainer) return !1;
|
|
1404
1917
|
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1405
1918
|
from: n.bnBlock.beforePos,
|
|
@@ -1414,9 +1927,9 @@ var fr = (e) => {
|
|
|
1414
1927
|
]), t = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1415
1928
|
() => t.deleteSelection(),
|
|
1416
1929
|
() => t.command(({ state: t }) => {
|
|
1417
|
-
let n =
|
|
1930
|
+
let n = _(t);
|
|
1418
1931
|
if (!n.isBlockContainer || !n.childContainer) return !1;
|
|
1419
|
-
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s =
|
|
1932
|
+
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s = v(t.doc.resolve(i.beforePos + 1));
|
|
1420
1933
|
if (!s.isBlockContainer) return !1;
|
|
1421
1934
|
if (a && o) {
|
|
1422
1935
|
let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
|
|
@@ -1431,45 +1944,45 @@ var fr = (e) => {
|
|
|
1431
1944
|
return !1;
|
|
1432
1945
|
}),
|
|
1433
1946
|
() => t.command(({ state: t }) => {
|
|
1434
|
-
let n =
|
|
1947
|
+
let n = _(t);
|
|
1435
1948
|
if (!n.isBlockContainer) return !1;
|
|
1436
1949
|
let { bnBlock: r, blockContent: i } = n, a = $(t.doc, n.bnBlock.beforePos);
|
|
1437
1950
|
if (!a || !a.isBlockContainer) return !1;
|
|
1438
1951
|
let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
|
|
1439
|
-
return o && s ? e().command(
|
|
1952
|
+
return o && s ? e().command(ti(c)).scrollIntoView().run() : !1;
|
|
1440
1953
|
}),
|
|
1441
1954
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1442
|
-
let r =
|
|
1955
|
+
let r = _(e);
|
|
1443
1956
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1444
1957
|
let i = $(e.doc, r.bnBlock.beforePos);
|
|
1445
1958
|
if (!i || i.isBlockContainer) return !1;
|
|
1446
1959
|
if (n) {
|
|
1447
1960
|
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
1448
|
-
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize),
|
|
1961
|
+
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), R(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(P.near(t.doc.resolve(n.pos))), !0;
|
|
1449
1962
|
}
|
|
1450
1963
|
return !1;
|
|
1451
1964
|
}),
|
|
1452
1965
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1453
|
-
let r =
|
|
1966
|
+
let r = _(e);
|
|
1454
1967
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1455
1968
|
let i = t.doc.resolve(r.bnBlock.afterPos);
|
|
1456
1969
|
if (i.nodeAfter || i.node().type.name !== "column") return !1;
|
|
1457
1970
|
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1458
1971
|
if (n) {
|
|
1459
|
-
let e = o.pos === s - 1 ? s : o.pos + 1, n =
|
|
1460
|
-
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos),
|
|
1972
|
+
let e = o.pos === s - 1 ? s : o.pos + 1, n = v(t.doc.resolve(e));
|
|
1973
|
+
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), R(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(P.near(t.doc.resolve(e)));
|
|
1461
1974
|
}
|
|
1462
1975
|
return !0;
|
|
1463
1976
|
}),
|
|
1464
1977
|
() => t.command(({ state: t }) => {
|
|
1465
|
-
let n =
|
|
1978
|
+
let n = _(t);
|
|
1466
1979
|
if (!n.isBlockContainer) return !1;
|
|
1467
1980
|
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1468
1981
|
if (i && a) {
|
|
1469
1982
|
let i = (e, t) => {
|
|
1470
1983
|
let n = $(e, t);
|
|
1471
1984
|
if (n) return n;
|
|
1472
|
-
let r =
|
|
1985
|
+
let r = Zr(e, t);
|
|
1473
1986
|
if (r) return i(e, r.bnBlock.beforePos);
|
|
1474
1987
|
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1475
1988
|
if (!a || !a.isBlockContainer) return !1;
|
|
@@ -1482,7 +1995,7 @@ var fr = (e) => {
|
|
|
1482
1995
|
return !1;
|
|
1483
1996
|
}),
|
|
1484
1997
|
() => t.command(({ state: t }) => {
|
|
1485
|
-
let n =
|
|
1998
|
+
let n = _(t);
|
|
1486
1999
|
if (!n.isBlockContainer) return !1;
|
|
1487
2000
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1488
2001
|
let r = $(t.doc, n.bnBlock.beforePos);
|
|
@@ -1500,7 +2013,7 @@ var fr = (e) => {
|
|
|
1500
2013
|
return !1;
|
|
1501
2014
|
}),
|
|
1502
2015
|
() => t.command(({ state: t }) => {
|
|
1503
|
-
let n =
|
|
2016
|
+
let n = _(t);
|
|
1504
2017
|
if (!n.isBlockContainer) return !1;
|
|
1505
2018
|
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = $(t.doc, n.bnBlock.beforePos);
|
|
1506
2019
|
if (!a || !a.isBlockContainer) return !1;
|
|
@@ -1515,13 +2028,13 @@ var fr = (e) => {
|
|
|
1515
2028
|
})
|
|
1516
2029
|
]), n = (e = !1) => this.editor.commands.first(({ commands: t, tr: n }) => [
|
|
1517
2030
|
() => t.command(({ state: e, tr: t }) => {
|
|
1518
|
-
let n =
|
|
2031
|
+
let n = _(e);
|
|
1519
2032
|
if (!n.isBlockContainer) return !1;
|
|
1520
2033
|
let { bnBlock: r, blockContent: i } = n, { depth: a } = e.doc.resolve(r.beforePos), o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.node.childCount === 0;
|
|
1521
|
-
return o && s && c && a > 1 ?
|
|
2034
|
+
return o && s && c && a > 1 ? V(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1522
2035
|
}),
|
|
1523
2036
|
() => t.command(({ state: t }) => {
|
|
1524
|
-
let r =
|
|
2037
|
+
let r = _(t), i = this.options.editor.schema.blockSchema[r.blockNoteType].meta?.hardBreakShortcut ?? "shift+enter";
|
|
1525
2038
|
if (i === "none") return !1;
|
|
1526
2039
|
if (i === "shift+enter" && e || i === "enter") {
|
|
1527
2040
|
let e = n.storedMarks || n.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
|
|
@@ -1530,24 +2043,24 @@ var fr = (e) => {
|
|
|
1530
2043
|
return !1;
|
|
1531
2044
|
}),
|
|
1532
2045
|
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
1533
|
-
let r =
|
|
2046
|
+
let r = _(e);
|
|
1534
2047
|
if (!r.isBlockContainer) return !1;
|
|
1535
2048
|
let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
|
|
1536
2049
|
if (o && s && c) {
|
|
1537
2050
|
let a = i.afterPos, o = a + 2;
|
|
1538
2051
|
if (t) {
|
|
1539
2052
|
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
|
|
1540
|
-
n.insert(a, t).setSelection(new
|
|
2053
|
+
n.insert(a, t).setSelection(new P(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
|
|
1541
2054
|
}
|
|
1542
2055
|
return !0;
|
|
1543
2056
|
}
|
|
1544
2057
|
return !1;
|
|
1545
2058
|
}),
|
|
1546
2059
|
() => t.command(({ state: e, chain: t }) => {
|
|
1547
|
-
let n =
|
|
2060
|
+
let n = _(e);
|
|
1548
2061
|
if (!n.isBlockContainer) return !1;
|
|
1549
2062
|
let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
|
|
1550
|
-
return r.node.childCount === 0 ? !1 : (t().deleteSelection().command(
|
|
2063
|
+
return r.node.childCount === 0 ? !1 : (t().deleteSelection().command(a(e.selection.from, i, i)).run(), !0);
|
|
1551
2064
|
})
|
|
1552
2065
|
]);
|
|
1553
2066
|
return {
|
|
@@ -1555,8 +2068,8 @@ var fr = (e) => {
|
|
|
1555
2068
|
Delete: t,
|
|
1556
2069
|
Enter: () => n(),
|
|
1557
2070
|
"Shift-Enter": () => n(!0),
|
|
1558
|
-
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1559
|
-
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
2071
|
+
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(b)?.store.state || this.options.editor.getExtension(ie)?.store.state !== void 0) ? !1 : Rt(this.options.editor),
|
|
2072
|
+
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(b)?.store.state || this.options.editor.getExtension(ie)?.store.state !== void 0) ? !1 : Bt(this.options.editor),
|
|
1560
2073
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1561
2074
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1562
2075
|
"Mod-z": () => this.options.editor.undo(),
|
|
@@ -1564,7 +2077,7 @@ var fr = (e) => {
|
|
|
1564
2077
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1565
2078
|
};
|
|
1566
2079
|
}
|
|
1567
|
-
}),
|
|
2080
|
+
}), ri = k.create({
|
|
1568
2081
|
name: "insertion",
|
|
1569
2082
|
inclusive: !1,
|
|
1570
2083
|
excludes: "deletion modification insertion",
|
|
@@ -1597,7 +2110,7 @@ var fr = (e) => {
|
|
|
1597
2110
|
}]
|
|
1598
2111
|
} : {};
|
|
1599
2112
|
}
|
|
1600
|
-
}),
|
|
2113
|
+
}), ii = k.create({
|
|
1601
2114
|
name: "deletion",
|
|
1602
2115
|
inclusive: !1,
|
|
1603
2116
|
excludes: "insertion modification deletion",
|
|
@@ -1630,7 +2143,7 @@ var fr = (e) => {
|
|
|
1630
2143
|
}]
|
|
1631
2144
|
} : {};
|
|
1632
2145
|
}
|
|
1633
|
-
}),
|
|
2146
|
+
}), ai = k.create({
|
|
1634
2147
|
name: "modification",
|
|
1635
2148
|
inclusive: !1,
|
|
1636
2149
|
excludes: "deletion insertion",
|
|
@@ -1688,7 +2201,7 @@ var fr = (e) => {
|
|
|
1688
2201
|
}]
|
|
1689
2202
|
} : {};
|
|
1690
2203
|
}
|
|
1691
|
-
}),
|
|
2204
|
+
}), oi = O.create({
|
|
1692
2205
|
name: "textAlignment",
|
|
1693
2206
|
addGlobalAttributes() {
|
|
1694
2207
|
return [{
|
|
@@ -1700,7 +2213,7 @@ var fr = (e) => {
|
|
|
1700
2213
|
} }
|
|
1701
2214
|
}];
|
|
1702
2215
|
}
|
|
1703
|
-
}),
|
|
2216
|
+
}), si = O.create({
|
|
1704
2217
|
name: "blockTextColor",
|
|
1705
2218
|
addGlobalAttributes() {
|
|
1706
2219
|
return [{
|
|
@@ -1709,16 +2222,16 @@ var fr = (e) => {
|
|
|
1709
2222
|
"tableCell",
|
|
1710
2223
|
"tableHeader"
|
|
1711
2224
|
],
|
|
1712
|
-
attributes: { textColor:
|
|
2225
|
+
attributes: { textColor: ue() }
|
|
1713
2226
|
}];
|
|
1714
2227
|
}
|
|
1715
|
-
}),
|
|
2228
|
+
}), ci = {
|
|
1716
2229
|
blockColor: "data-block-color",
|
|
1717
2230
|
blockStyle: "data-block-style",
|
|
1718
2231
|
id: "data-id",
|
|
1719
2232
|
depth: "data-depth",
|
|
1720
2233
|
depthChange: "data-depth-change"
|
|
1721
|
-
},
|
|
2234
|
+
}, li = A.create({
|
|
1722
2235
|
name: "blockContainer",
|
|
1723
2236
|
group: "blockGroupChild bnBlock",
|
|
1724
2237
|
content: "blockContent blockGroup?",
|
|
@@ -1731,7 +2244,7 @@ var fr = (e) => {
|
|
|
1731
2244
|
getAttrs: (e) => {
|
|
1732
2245
|
if (typeof e == "string") return !1;
|
|
1733
2246
|
let t = {};
|
|
1734
|
-
for (let [n, r] of Object.entries(
|
|
2247
|
+
for (let [n, r] of Object.entries(ci)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
1735
2248
|
return t;
|
|
1736
2249
|
}
|
|
1737
2250
|
}, {
|
|
@@ -1754,7 +2267,7 @@ var fr = (e) => {
|
|
|
1754
2267
|
contentDOM: r
|
|
1755
2268
|
};
|
|
1756
2269
|
}
|
|
1757
|
-
}),
|
|
2270
|
+
}), ui = A.create({
|
|
1758
2271
|
name: "blockGroup",
|
|
1759
2272
|
group: "childContainer",
|
|
1760
2273
|
content: "blockGroupChild+",
|
|
@@ -1777,32 +2290,32 @@ var fr = (e) => {
|
|
|
1777
2290
|
contentDOM: n
|
|
1778
2291
|
};
|
|
1779
2292
|
}
|
|
1780
|
-
}),
|
|
2293
|
+
}), di = A.create({
|
|
1781
2294
|
name: "doc",
|
|
1782
2295
|
topNode: !0,
|
|
1783
2296
|
content: "blockGroup",
|
|
1784
2297
|
marks: "insertion modification deletion"
|
|
1785
|
-
}),
|
|
2298
|
+
}), fi = Me(({ options: e }) => ({
|
|
1786
2299
|
key: "collaboration",
|
|
1787
2300
|
blockNoteExtensions: [
|
|
1788
|
-
|
|
1789
|
-
pe(e),
|
|
2301
|
+
he(e),
|
|
1790
2302
|
ge(e),
|
|
1791
|
-
ke(),
|
|
1792
|
-
|
|
2303
|
+
ke(e),
|
|
2304
|
+
de(),
|
|
2305
|
+
Ae(e)
|
|
1793
2306
|
]
|
|
1794
2307
|
}));
|
|
1795
2308
|
//#endregion
|
|
1796
2309
|
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
1797
|
-
function
|
|
2310
|
+
function pi(e, t) {
|
|
1798
2311
|
return [
|
|
1799
2312
|
j.ClipboardTextSerializer,
|
|
1800
2313
|
j.Commands,
|
|
1801
2314
|
j.Editable,
|
|
1802
2315
|
j.FocusEvents,
|
|
1803
2316
|
j.Tabindex,
|
|
1804
|
-
|
|
1805
|
-
|
|
2317
|
+
dt,
|
|
2318
|
+
u.configure({
|
|
1806
2319
|
types: [
|
|
1807
2320
|
"blockContainer",
|
|
1808
2321
|
"columnList",
|
|
@@ -1811,46 +2324,46 @@ function Nr(e, t) {
|
|
|
1811
2324
|
setIdAttribute: t.setIdAttribute,
|
|
1812
2325
|
isWithinEditor: e.isWithinEditor
|
|
1813
2326
|
}),
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
2327
|
+
Xr,
|
|
2328
|
+
ft,
|
|
2329
|
+
ri,
|
|
2330
|
+
ii,
|
|
2331
|
+
ai,
|
|
1819
2332
|
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
2333
|
+
si,
|
|
2334
|
+
Yr,
|
|
2335
|
+
oi,
|
|
1823
2336
|
O.create({
|
|
1824
2337
|
name: "OverrideEscape",
|
|
1825
|
-
addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(
|
|
2338
|
+
addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(h)?.shown() ? !1 : (e.blur(), !0) })
|
|
1826
2339
|
}),
|
|
1827
|
-
|
|
1828
|
-
|
|
2340
|
+
di,
|
|
2341
|
+
li.configure({
|
|
1829
2342
|
editor: e,
|
|
1830
2343
|
domAttributes: t.domAttributes
|
|
1831
2344
|
}),
|
|
1832
|
-
|
|
2345
|
+
ni.configure({
|
|
1833
2346
|
editor: e,
|
|
1834
2347
|
tabBehavior: t.tabBehavior
|
|
1835
2348
|
}),
|
|
1836
|
-
|
|
2349
|
+
ui.configure({ domAttributes: t.domAttributes }),
|
|
1837
2350
|
...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
|
|
1838
2351
|
...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
|
|
1839
2352
|
editor: e,
|
|
1840
2353
|
domAttributes: t.domAttributes
|
|
1841
2354
|
})] : []]),
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
2355
|
+
Jr(e),
|
|
2356
|
+
Ur(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
2357
|
+
Er(e)
|
|
1845
2358
|
];
|
|
1846
2359
|
}
|
|
1847
|
-
function
|
|
2360
|
+
function mi(e, t) {
|
|
1848
2361
|
let n = [
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
2362
|
+
pe(),
|
|
2363
|
+
ve(t),
|
|
2364
|
+
ie(t),
|
|
2365
|
+
b(t),
|
|
2366
|
+
br({
|
|
1854
2367
|
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
1855
2368
|
onClick: t.links?.onClick,
|
|
1856
2369
|
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
@@ -1860,14 +2373,14 @@ function Pr(e, t) {
|
|
|
1860
2373
|
Te(t),
|
|
1861
2374
|
Ne(t),
|
|
1862
2375
|
we(t),
|
|
1863
|
-
|
|
2376
|
+
h(t),
|
|
1864
2377
|
...t.trailingBlock === !1 ? [] : [Ee()]
|
|
1865
2378
|
];
|
|
1866
|
-
return t.collaboration ? n.push(
|
|
2379
|
+
return t.collaboration ? n.push(fi(t.collaboration)) : n.push(Oe()), "table" in e.schema.blockSpecs && n.push(Ce(t)), t.animations !== !1 && n.push(be()), n;
|
|
1867
2380
|
}
|
|
1868
2381
|
//#endregion
|
|
1869
2382
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
1870
|
-
var
|
|
2383
|
+
var hi = class {
|
|
1871
2384
|
disabledExtensions = /* @__PURE__ */ new Set();
|
|
1872
2385
|
extensions = [];
|
|
1873
2386
|
abortMap = /* @__PURE__ */ new Map();
|
|
@@ -1888,7 +2401,7 @@ var Fr = class {
|
|
|
1888
2401
|
}), e.onUnmount(() => {
|
|
1889
2402
|
for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
|
|
1890
2403
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
1891
|
-
for (let e of
|
|
2404
|
+
for (let e of mi(this.editor, this.options)) this.addExtension(e);
|
|
1892
2405
|
for (let e of this.options.extensions ?? []) this.addExtension(e);
|
|
1893
2406
|
for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
|
|
1894
2407
|
}
|
|
@@ -1947,7 +2460,7 @@ var Fr = class {
|
|
|
1947
2460
|
this.editor.prosemirrorView.updateState(n);
|
|
1948
2461
|
}
|
|
1949
2462
|
getTiptapExtensions() {
|
|
1950
|
-
let e =
|
|
2463
|
+
let e = pi(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = l(this.extensions), n = /* @__PURE__ */ new Map();
|
|
1951
2464
|
for (let r of this.extensions) {
|
|
1952
2465
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
1953
2466
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
@@ -1961,9 +2474,15 @@ var Fr = class {
|
|
|
1961
2474
|
name: "blocknote-input-rules",
|
|
1962
2475
|
addProseMirrorPlugins() {
|
|
1963
2476
|
let e = [];
|
|
1964
|
-
|
|
2477
|
+
Array.from(n.keys()).sort().reverse().forEach((t) => {
|
|
1965
2478
|
e.push(...n.get(t));
|
|
1966
|
-
})
|
|
2479
|
+
});
|
|
2480
|
+
let t = lt({ rules: e });
|
|
2481
|
+
return [t, new N({ props: { handleKeyDown(e, n) {
|
|
2482
|
+
if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
|
|
2483
|
+
let { $cursor: r } = e.state.selection;
|
|
2484
|
+
return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
|
|
2485
|
+
} } })];
|
|
1967
2486
|
}
|
|
1968
2487
|
}));
|
|
1969
2488
|
for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
|
|
@@ -1974,23 +2493,24 @@ var Fr = class {
|
|
|
1974
2493
|
return !e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length ? {
|
|
1975
2494
|
plugins: t,
|
|
1976
2495
|
inputRules: n
|
|
1977
|
-
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new
|
|
1978
|
-
let
|
|
2496
|
+
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new ct(e.find, (t, n, r, a) => {
|
|
2497
|
+
let o = e.replace({
|
|
1979
2498
|
match: n,
|
|
1980
2499
|
range: {
|
|
1981
2500
|
from: r,
|
|
1982
|
-
to:
|
|
2501
|
+
to: a
|
|
1983
2502
|
},
|
|
1984
2503
|
editor: this.editor
|
|
1985
2504
|
});
|
|
1986
|
-
if (
|
|
1987
|
-
let e =
|
|
1988
|
-
if (this.editor.schema.blockSchema[
|
|
1989
|
-
|
|
1990
|
-
|
|
2505
|
+
if (o) {
|
|
2506
|
+
let e = t.tr, n = f(e);
|
|
2507
|
+
if (!n.isBlockContainer || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline") return null;
|
|
2508
|
+
e.deleteRange(r, a), i(e, n.bnBlock.beforePos, o);
|
|
2509
|
+
let s = n.bnBlock.node.attrs.id;
|
|
2510
|
+
return s && Un(e, s, "start"), e;
|
|
1991
2511
|
}
|
|
1992
2512
|
return null;
|
|
1993
|
-
}))), Object.keys(e.keyboardShortcuts || {}).length && t.push(
|
|
2513
|
+
}, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length && t.push(ut(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
|
|
1994
2514
|
plugins: t,
|
|
1995
2515
|
inputRules: n
|
|
1996
2516
|
});
|
|
@@ -2009,7 +2529,7 @@ var Fr = class {
|
|
|
2009
2529
|
};
|
|
2010
2530
|
//#endregion
|
|
2011
2531
|
//#region src/util/expandToWords.ts
|
|
2012
|
-
function
|
|
2532
|
+
function gi(e, t) {
|
|
2013
2533
|
let { $from: n, $to: r } = t;
|
|
2014
2534
|
if (n.pos > n.start() && n.pos < e.content.size) {
|
|
2015
2535
|
let t = e.textBetween(n.pos, n.pos + 1);
|
|
@@ -2034,16 +2554,16 @@ function Ir(e, t) {
|
|
|
2034
2554
|
}
|
|
2035
2555
|
//#endregion
|
|
2036
2556
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
2037
|
-
function
|
|
2557
|
+
function _i(e) {
|
|
2038
2558
|
let t = g(e);
|
|
2039
2559
|
if (e.selection.empty || "node" in e.selection) return;
|
|
2040
2560
|
let n = e.doc.resolve(C(e.doc, e.selection.from).posBeforeNode), r = e.doc.resolve(C(e.doc, e.selection.to).posBeforeNode), i = (r, i) => {
|
|
2041
2561
|
let a = n.posAtIndex(r, i), o = e.doc.resolve(a).nodeAfter;
|
|
2042
2562
|
if (!o) throw Error(`Error getting selection - node not found at position ${a}`);
|
|
2043
|
-
return
|
|
2563
|
+
return m(o, t);
|
|
2044
2564
|
}, a = [], o = n.sharedDepth(r.pos), s = n.index(o), c = r.index(o);
|
|
2045
2565
|
if (n.depth > o) {
|
|
2046
|
-
a.push(
|
|
2566
|
+
a.push(m(n.nodeAfter, t));
|
|
2047
2567
|
for (let e = n.depth; e > o; e--) if (n.node(e).type.isInGroup("childContainer")) {
|
|
2048
2568
|
let t = n.index(e) + 1, r = n.node(e).childCount;
|
|
2049
2569
|
for (let n = t; n < r; n++) a.push(i(n, e));
|
|
@@ -2053,34 +2573,34 @@ function Lr(e) {
|
|
|
2053
2573
|
if (a.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
2054
2574
|
return { blocks: a };
|
|
2055
2575
|
}
|
|
2056
|
-
function
|
|
2057
|
-
let
|
|
2058
|
-
if (
|
|
2059
|
-
let s = i
|
|
2060
|
-
if (!s) throw Error(`Block with ID ${
|
|
2061
|
-
let c =
|
|
2576
|
+
function vi(e, t, n) {
|
|
2577
|
+
let i = typeof t == "string" ? t : t.id, a = typeof n == "string" ? n : n.id, o = re(g(e));
|
|
2578
|
+
if (i === a) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);
|
|
2579
|
+
let s = r(i, e.doc);
|
|
2580
|
+
if (!s) throw Error(`Block with ID ${i} not found`);
|
|
2581
|
+
let c = r(a, e.doc);
|
|
2062
2582
|
if (!c) throw Error(`Block with ID ${a} not found`);
|
|
2063
|
-
let l =
|
|
2064
|
-
if (!l.isBlockContainer || d.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${
|
|
2583
|
+
let l = x(s), u = x(c), d = o.blockSchema[l.blockNoteType], f = o.blockSchema[u.blockNoteType];
|
|
2584
|
+
if (!l.isBlockContainer || d.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${i})`);
|
|
2065
2585
|
if (!u.isBlockContainer || f.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${a})`);
|
|
2066
2586
|
let p, m;
|
|
2067
2587
|
if (d.content === "table") {
|
|
2068
|
-
let e =
|
|
2588
|
+
let e = at.get(l.blockContent.node);
|
|
2069
2589
|
p = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
|
|
2070
2590
|
} else p = l.blockContent.beforePos + 1;
|
|
2071
2591
|
if (f.content === "table") {
|
|
2072
|
-
let t =
|
|
2592
|
+
let t = at.get(u.blockContent.node), n = u.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, u.blockContent.node) + 1;
|
|
2073
2593
|
m = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
2074
2594
|
} else m = u.blockContent.afterPos - 1;
|
|
2075
|
-
e.setSelection(
|
|
2595
|
+
e.setSelection(P.create(e.doc, p, m));
|
|
2076
2596
|
}
|
|
2077
|
-
function
|
|
2078
|
-
let n = g(e), r = t ?
|
|
2597
|
+
function yi(e, t = !1) {
|
|
2598
|
+
let n = g(e), r = t ? gi(e.doc, e.selection) : e.selection, i = r.$from, a = r.$to;
|
|
2079
2599
|
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
2080
2600
|
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
2081
2601
|
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
2082
2602
|
for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
|
|
2083
|
-
let o =
|
|
2603
|
+
let o = se(e.doc.slice(i.pos, a.pos, !0), n);
|
|
2084
2604
|
return {
|
|
2085
2605
|
_meta: {
|
|
2086
2606
|
startPos: i.pos,
|
|
@@ -2090,51 +2610,25 @@ function zr(e, t = !1) {
|
|
|
2090
2610
|
};
|
|
2091
2611
|
}
|
|
2092
2612
|
//#endregion
|
|
2093
|
-
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
2094
|
-
function Br(e) {
|
|
2095
|
-
let { bnBlock: t } = _(e), n = g(e.doc), r = e.doc.resolve(t.beforePos), i = r.nodeBefore, a = e.doc.resolve(t.afterPos).nodeAfter, o;
|
|
2096
|
-
return r.depth > 1 && (o = r.node(), o.type.isInGroup("bnBlock") || (o = r.node(r.depth - 1))), {
|
|
2097
|
-
block: y(t.node, n),
|
|
2098
|
-
prevBlock: i === null ? void 0 : y(i, n),
|
|
2099
|
-
nextBlock: a === null ? void 0 : y(a, n),
|
|
2100
|
-
parentBlock: o === void 0 ? void 0 : y(o, n)
|
|
2101
|
-
};
|
|
2102
|
-
}
|
|
2103
|
-
function Vr(e, t, n = "start") {
|
|
2104
|
-
let r = typeof t == "string" ? t : t.id, a = ee(g(e.doc)), o = i(r, e.doc);
|
|
2105
|
-
if (!o) throw Error(`Block with ID ${r} not found`);
|
|
2106
|
-
let s = S(o), c = a.blockSchema[s.blockNoteType].content;
|
|
2107
|
-
if (s.isBlockContainer) {
|
|
2108
|
-
let t = s.blockContent;
|
|
2109
|
-
if (c === "none") {
|
|
2110
|
-
e.setSelection(N.create(e.doc, t.beforePos));
|
|
2111
|
-
return;
|
|
2112
|
-
}
|
|
2113
|
-
if (c === "inline") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 1)) : e.setSelection(F.create(e.doc, t.afterPos - 1));
|
|
2114
|
-
else if (c === "table") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 4)) : e.setSelection(F.create(e.doc, t.afterPos - 4));
|
|
2115
|
-
else throw new u(c);
|
|
2116
|
-
} else Vr(e, (n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild).attrs.id, n);
|
|
2117
|
-
}
|
|
2118
|
-
//#endregion
|
|
2119
2613
|
//#region src/editor/managers/SelectionManager.ts
|
|
2120
|
-
var
|
|
2614
|
+
var bi = class {
|
|
2121
2615
|
constructor(e) {
|
|
2122
2616
|
this.editor = e;
|
|
2123
2617
|
}
|
|
2124
2618
|
getSelection() {
|
|
2125
|
-
return this.editor.transact((e) =>
|
|
2619
|
+
return this.editor.transact((e) => _i(e));
|
|
2126
2620
|
}
|
|
2127
2621
|
getSelectionCutBlocks(e = !1) {
|
|
2128
|
-
return this.editor.transact((t) =>
|
|
2622
|
+
return this.editor.transact((t) => yi(t, e));
|
|
2129
2623
|
}
|
|
2130
2624
|
setSelection(e, t) {
|
|
2131
|
-
return this.editor.transact((n) =>
|
|
2625
|
+
return this.editor.transact((n) => vi(n, e, t));
|
|
2132
2626
|
}
|
|
2133
2627
|
getTextCursorPosition() {
|
|
2134
|
-
return this.editor.transact((e) =>
|
|
2628
|
+
return this.editor.transact((e) => Hn(e));
|
|
2135
2629
|
}
|
|
2136
2630
|
setTextCursorPosition(e, t = "start") {
|
|
2137
|
-
return this.editor.transact((n) =>
|
|
2631
|
+
return this.editor.transact((n) => Un(n, e, t));
|
|
2138
2632
|
}
|
|
2139
2633
|
getSelectionBoundingBox() {
|
|
2140
2634
|
if (!this.editor.prosemirrorView) return;
|
|
@@ -2143,9 +2637,9 @@ var Hr = class {
|
|
|
2143
2637
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
2144
2638
|
if (e) return e.getBoundingClientRect();
|
|
2145
2639
|
}
|
|
2146
|
-
return
|
|
2640
|
+
return nt(this.editor.prosemirrorView, n, r).toJSON();
|
|
2147
2641
|
}
|
|
2148
|
-
},
|
|
2642
|
+
}, xi = class {
|
|
2149
2643
|
constructor(e) {
|
|
2150
2644
|
this.editor = e;
|
|
2151
2645
|
}
|
|
@@ -2223,7 +2717,7 @@ var Hr = class {
|
|
|
2223
2717
|
};
|
|
2224
2718
|
//#endregion
|
|
2225
2719
|
//#region src/api/blockManipulation/insertContentAt.ts
|
|
2226
|
-
function
|
|
2720
|
+
function Si(e, t, n, r = { updateSelection: !0 }) {
|
|
2227
2721
|
let { from: i, to: a } = typeof t == "number" ? {
|
|
2228
2722
|
from: t,
|
|
2229
2723
|
to: t
|
|
@@ -2237,21 +2731,21 @@ function Wr(e, t, n, r = { updateSelection: !0 }) {
|
|
|
2237
2731
|
let { parent: t } = e.doc.resolve(i);
|
|
2238
2732
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
2239
2733
|
}
|
|
2240
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2734
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && rt(e, e.steps.length - 1, -1), !0;
|
|
2241
2735
|
}
|
|
2242
2736
|
//#endregion
|
|
2243
2737
|
//#region src/editor/managers/StyleManager.ts
|
|
2244
|
-
var
|
|
2738
|
+
var Ci = class {
|
|
2245
2739
|
constructor(e) {
|
|
2246
2740
|
this.editor = e;
|
|
2247
2741
|
}
|
|
2248
|
-
insertInlineContent(e, { updateSelection:
|
|
2249
|
-
let
|
|
2742
|
+
insertInlineContent(e, { updateSelection: n = !1 } = {}) {
|
|
2743
|
+
let r = t(e, this.editor.pmSchema);
|
|
2250
2744
|
this.editor.transact((e) => {
|
|
2251
|
-
|
|
2745
|
+
Si(e, {
|
|
2252
2746
|
from: e.selection.from,
|
|
2253
2747
|
to: e.selection.to
|
|
2254
|
-
},
|
|
2748
|
+
}, r, { updateSelection: n });
|
|
2255
2749
|
});
|
|
2256
2750
|
}
|
|
2257
2751
|
getActiveStyles() {
|
|
@@ -2274,7 +2768,7 @@ var Gr = class {
|
|
|
2274
2768
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2275
2769
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
|
|
2276
2770
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
|
|
2277
|
-
else throw new
|
|
2771
|
+
else throw new w(e.propSchema);
|
|
2278
2772
|
}
|
|
2279
2773
|
}
|
|
2280
2774
|
removeStyles(e) {
|
|
@@ -2286,7 +2780,7 @@ var Gr = class {
|
|
|
2286
2780
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2287
2781
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2288
2782
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
|
|
2289
|
-
else throw new
|
|
2783
|
+
else throw new w(e.propSchema);
|
|
2290
2784
|
}
|
|
2291
2785
|
}
|
|
2292
2786
|
getSelectedText() {
|
|
@@ -2335,22 +2829,22 @@ var Gr = class {
|
|
|
2335
2829
|
};
|
|
2336
2830
|
//#endregion
|
|
2337
2831
|
//#region src/editor/transformPasted.ts
|
|
2338
|
-
function
|
|
2832
|
+
function wi(e) {
|
|
2339
2833
|
return qe(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
2340
2834
|
}
|
|
2341
|
-
function
|
|
2342
|
-
let n = t.nodes.hardBreak, r =
|
|
2835
|
+
function Ti(e, t) {
|
|
2836
|
+
let n = t.nodes.hardBreak, r = F.empty;
|
|
2343
2837
|
return e.forEach((e) => {
|
|
2344
|
-
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(
|
|
2838
|
+
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(Ti(e.content, t)), r = r.addToEnd(n.create()));
|
|
2345
2839
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
2346
2840
|
}
|
|
2347
|
-
function
|
|
2841
|
+
function Ei(e, t) {
|
|
2348
2842
|
let n = [];
|
|
2349
2843
|
return e.forEach((e, r, i) => {
|
|
2350
2844
|
i !== t && n.push(e);
|
|
2351
|
-
}),
|
|
2845
|
+
}), F.from(n);
|
|
2352
2846
|
}
|
|
2353
|
-
function
|
|
2847
|
+
function Di(e, t) {
|
|
2354
2848
|
let n = [];
|
|
2355
2849
|
for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow") if (n.length > 0 && n[n.length - 1].type.name === "table") {
|
|
2356
2850
|
let t = n[n.length - 1], i = t.copy(t.content.addToEnd(e.child(r)));
|
|
@@ -2360,34 +2854,46 @@ function Yr(e, t) {
|
|
|
2360
2854
|
n.push(i);
|
|
2361
2855
|
}
|
|
2362
2856
|
else n.push(e.child(r));
|
|
2363
|
-
return e =
|
|
2364
|
-
}
|
|
2365
|
-
function
|
|
2366
|
-
let n =
|
|
2367
|
-
|
|
2857
|
+
return e = F.from(n), e;
|
|
2858
|
+
}
|
|
2859
|
+
function Oi(e, t) {
|
|
2860
|
+
let n = F.from(e.content);
|
|
2861
|
+
n = Di(n, t.state.schema);
|
|
2862
|
+
let r = ki(n, t, e);
|
|
2863
|
+
if (r) return r;
|
|
2864
|
+
if (wi(t)) {
|
|
2368
2865
|
let e = !1;
|
|
2369
2866
|
if (n.descendants((t) => {
|
|
2370
2867
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
2371
|
-
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new
|
|
2868
|
+
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new I(Ti(n, t.state.schema), 0, 0);
|
|
2372
2869
|
}
|
|
2373
|
-
if (!
|
|
2870
|
+
if (!Ai(n, t)) return new I(n, e.openStart, e.openEnd);
|
|
2374
2871
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
2375
2872
|
let r = [n.child(e)];
|
|
2376
2873
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
2377
2874
|
let t = n.child(e + 1).child(0).child(0);
|
|
2378
|
-
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n =
|
|
2875
|
+
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n = Ei(n, e + 1));
|
|
2379
2876
|
}
|
|
2380
2877
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2381
2878
|
n = n.replaceChild(e, i);
|
|
2382
2879
|
}
|
|
2383
|
-
return new
|
|
2880
|
+
return new I(n, e.openStart, e.openEnd);
|
|
2881
|
+
}
|
|
2882
|
+
function ki(e, t, n) {
|
|
2883
|
+
if (wi(t) || t.dragging) return null;
|
|
2884
|
+
let r = _(t.state), i = r.isBlockContainer ? r.blockContent.node : null;
|
|
2885
|
+
if (!i || i.type.name === "paragraph" || i.type.spec.content !== "inline*" || i.childCount > 0) return null;
|
|
2886
|
+
let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
2887
|
+
if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
|
|
2888
|
+
let c = i.type.create(i.attrs, s.content), l = o.copy(o.content.replaceChild(0, c)), u = a.copy(a.content.replaceChild(0, l));
|
|
2889
|
+
return new I(e.replaceChild(0, u), n.openStart, n.openEnd);
|
|
2384
2890
|
}
|
|
2385
|
-
function
|
|
2891
|
+
function Ai(e, t) {
|
|
2386
2892
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2387
2893
|
if (n) {
|
|
2388
2894
|
if (r) return !1;
|
|
2389
2895
|
if (i) {
|
|
2390
|
-
let e =
|
|
2896
|
+
let e = _(t.state);
|
|
2391
2897
|
if (e.isBlockContainer) return e.blockContent.node.type.spec.content !== "tableRow+";
|
|
2392
2898
|
}
|
|
2393
2899
|
}
|
|
@@ -2395,11 +2901,11 @@ function Zr(e, t) {
|
|
|
2395
2901
|
}
|
|
2396
2902
|
//#endregion
|
|
2397
2903
|
//#region src/editor/BlockNoteEditor.ts
|
|
2398
|
-
var
|
|
2904
|
+
var ji = {
|
|
2399
2905
|
enableInputRules: !0,
|
|
2400
2906
|
enablePasteRules: !0,
|
|
2401
2907
|
enableCoreExtensions: !1
|
|
2402
|
-
},
|
|
2908
|
+
}, Mi = class e extends Fe {
|
|
2403
2909
|
pmSchema;
|
|
2404
2910
|
_tiptapEditor;
|
|
2405
2911
|
elementRenderer = null;
|
|
@@ -2426,7 +2932,7 @@ var Qr = {
|
|
|
2426
2932
|
} };
|
|
2427
2933
|
let t = {
|
|
2428
2934
|
defaultStyles: !0,
|
|
2429
|
-
schema: e.schema ||
|
|
2935
|
+
schema: e.schema || ce.create(),
|
|
2430
2936
|
...e,
|
|
2431
2937
|
placeholders: {
|
|
2432
2938
|
...this.dictionary.placeholders,
|
|
@@ -2444,11 +2950,11 @@ var Qr = {
|
|
|
2444
2950
|
}
|
|
2445
2951
|
};
|
|
2446
2952
|
}
|
|
2447
|
-
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new
|
|
2953
|
+
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Jt(this), this._extensionManager = new hi(this, t);
|
|
2448
2954
|
let n = this._extensionManager.getTiptapExtensions(), r = this._extensionManager.hasExtension("ySync") || this._extensionManager.hasExtension("liveblocksExtension");
|
|
2449
2955
|
r && t.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
|
|
2450
2956
|
let i = {
|
|
2451
|
-
...
|
|
2957
|
+
...ji,
|
|
2452
2958
|
...t._tiptapOptions,
|
|
2453
2959
|
element: null,
|
|
2454
2960
|
autofocus: t.autofocus ?? !1,
|
|
@@ -2461,7 +2967,7 @@ var Qr = {
|
|
|
2461
2967
|
...t.domAttributes?.editor,
|
|
2462
2968
|
class: s("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
|
|
2463
2969
|
},
|
|
2464
|
-
transformPasted:
|
|
2970
|
+
transformPasted: Oi
|
|
2465
2971
|
}
|
|
2466
2972
|
};
|
|
2467
2973
|
try {
|
|
@@ -2470,14 +2976,14 @@ var Qr = {
|
|
|
2470
2976
|
id: "initialBlockId"
|
|
2471
2977
|
}] : [{
|
|
2472
2978
|
type: "paragraph",
|
|
2473
|
-
id:
|
|
2979
|
+
id: u.options.generateID()
|
|
2474
2980
|
}]);
|
|
2475
2981
|
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + e);
|
|
2476
2982
|
let n = Qe(i.extensions), a = Ge({
|
|
2477
2983
|
type: "doc",
|
|
2478
2984
|
content: [{
|
|
2479
2985
|
type: "blockGroup",
|
|
2480
|
-
content: e.map((e) =>
|
|
2986
|
+
content: e.map((e) => y(e, n, this.schema.styleSchema).toJSON())
|
|
2481
2987
|
}]
|
|
2482
2988
|
}, n, i.parseOptions);
|
|
2483
2989
|
this._tiptapEditor = new Ue({
|
|
@@ -2487,16 +2993,16 @@ var Qr = {
|
|
|
2487
2993
|
} catch (e) {
|
|
2488
2994
|
throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
|
|
2489
2995
|
}
|
|
2490
|
-
let a,
|
|
2996
|
+
let a, o = this.pmSchema.nodes.doc.createAndFill;
|
|
2491
2997
|
this.pmSchema.nodes.doc.createAndFill = (...e) => {
|
|
2492
2998
|
if (a) return a;
|
|
2493
|
-
let t =
|
|
2999
|
+
let t = o.apply(this.pmSchema.nodes.doc, e), n = JSON.parse(JSON.stringify(t.toJSON()));
|
|
2494
3000
|
return n.content[0].content[0].attrs.id = "initialBlockId", a = Re.fromJSON(this.pmSchema, n), a;
|
|
2495
3001
|
}, this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
|
|
2496
3002
|
this.headless = !1;
|
|
2497
3003
|
}), this._tiptapEditor.on("unmount", () => {
|
|
2498
3004
|
this.headless = !0;
|
|
2499
|
-
}), this._blockManager = new
|
|
3005
|
+
}), this._blockManager = new qt(this), this._exportManager = new Vn(this), this._selectionManager = new bi(this), this._stateManager = new xi(this), this._styleManager = new Ci(this), this.emit("create");
|
|
2500
3006
|
}
|
|
2501
3007
|
_blockManager;
|
|
2502
3008
|
_eventManager;
|
|
@@ -2520,9 +3026,9 @@ var Qr = {
|
|
|
2520
3026
|
unregisterExtension = (...e) => this._extensionManager.unregisterExtension(...e);
|
|
2521
3027
|
registerExtension = (...e) => this._extensionManager.registerExtension(...e);
|
|
2522
3028
|
getExtension = ((...e) => this._extensionManager.getExtension(...e));
|
|
2523
|
-
mount = (e) => {
|
|
2524
|
-
let
|
|
2525
|
-
|
|
3029
|
+
mount = (e, t) => {
|
|
3030
|
+
let n = e.getRootNode(), r = typeof ShadowRoot < "u" && n instanceof ShadowRoot;
|
|
3031
|
+
(t?.portalTarget ?? e.parentElement ?? (r ? n : document.body)).appendChild(this.portalElement), this._tiptapEditor.mount({ mount: e });
|
|
2526
3032
|
};
|
|
2527
3033
|
unmount = () => {
|
|
2528
3034
|
this.portalElement?.remove(), this._tiptapEditor.unmount();
|
|
@@ -2592,7 +3098,7 @@ var Qr = {
|
|
|
2592
3098
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
2593
3099
|
}
|
|
2594
3100
|
onBeforeChange(e) {
|
|
2595
|
-
return this._extensionManager.getExtension(
|
|
3101
|
+
return this._extensionManager.getExtension(pe).subscribe(e);
|
|
2596
3102
|
}
|
|
2597
3103
|
getTextCursorPosition() {
|
|
2598
3104
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -2678,11 +3184,11 @@ var Qr = {
|
|
|
2678
3184
|
unnestBlock() {
|
|
2679
3185
|
this._blockManager.unnestBlock();
|
|
2680
3186
|
}
|
|
2681
|
-
moveBlocksUp() {
|
|
2682
|
-
return this._blockManager.moveBlocksUp();
|
|
3187
|
+
moveBlocksUp(e) {
|
|
3188
|
+
return this._blockManager.moveBlocksUp(e);
|
|
2683
3189
|
}
|
|
2684
|
-
moveBlocksDown() {
|
|
2685
|
-
return this._blockManager.moveBlocksDown();
|
|
3190
|
+
moveBlocksDown(e) {
|
|
3191
|
+
return this._blockManager.moveBlocksDown(e);
|
|
2686
3192
|
}
|
|
2687
3193
|
blocksToHTMLLossy(e = this.document) {
|
|
2688
3194
|
return this._exportManager.blocksToHTMLLossy(e);
|
|
@@ -2727,7 +3233,7 @@ var Qr = {
|
|
|
2727
3233
|
pasteMarkdown(e) {
|
|
2728
3234
|
return this._exportManager.pasteMarkdown(e);
|
|
2729
3235
|
}
|
|
2730
|
-
},
|
|
3236
|
+
}, Ni = class {
|
|
2731
3237
|
constructor(e, t, n) {
|
|
2732
3238
|
this.mappings = t, this.options = n;
|
|
2733
3239
|
}
|
|
@@ -2751,7 +3257,7 @@ var Qr = {
|
|
|
2751
3257
|
};
|
|
2752
3258
|
//#endregion
|
|
2753
3259
|
//#region src/exporter/mapping.ts
|
|
2754
|
-
function
|
|
3260
|
+
function Pi(e) {
|
|
2755
3261
|
return {
|
|
2756
3262
|
createBlockMapping: (e) => e,
|
|
2757
3263
|
createInlineContentMapping: (e) => e,
|
|
@@ -2760,7 +3266,7 @@ function ti(e) {
|
|
|
2760
3266
|
}
|
|
2761
3267
|
//#endregion
|
|
2762
3268
|
//#region src/util/combineByGroup.ts
|
|
2763
|
-
function
|
|
3269
|
+
function Fi(e, ...t) {
|
|
2764
3270
|
let n = [...e];
|
|
2765
3271
|
for (let e of t) for (let t of e) {
|
|
2766
3272
|
let e = n.findLastIndex((e) => e.group === t.group);
|
|
@@ -2769,6 +3275,6 @@ function ni(e, ...t) {
|
|
|
2769
3275
|
return n;
|
|
2770
3276
|
}
|
|
2771
3277
|
//#endregion
|
|
2772
|
-
export {
|
|
3278
|
+
export { L as _, gi as a, mt as b, zn as c, Gt as d, Kt as f, R as g, z as h, Mi as i, H as l, Dt as m, Pi as n, Gr as o, Wt as p, Ni as r, Bn as s, Fi as t, Ut as u, gt as v, pt as x, ht as y };
|
|
2773
3279
|
|
|
2774
|
-
//# sourceMappingURL=src-
|
|
3280
|
+
//# sourceMappingURL=src-DK_8q1j5.js.map
|