@blocknote/core 0.54.2 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -1
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -1
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/blocks-DLgTreVu.cjs +12 -0
- package/dist/blocks-DLgTreVu.cjs.map +1 -0
- package/dist/{blocks-Dol85hpH.js → blocks-DaEUT0O1.js} +346 -340
- package/dist/blocks-DaEUT0O1.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +1 -1
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +62 -36
- package/dist/comments.js.map +1 -1
- package/dist/{en-uzHzj6eH.js → en-BAn9gxr-.js} +5 -2
- package/dist/{en-uzHzj6eH.js.map → en-BAn9gxr-.js.map} +1 -1
- package/dist/{en-BuzSuuTq.cjs → en-CHnrV5l8.cjs} +2 -2
- package/dist/{en-BuzSuuTq.cjs.map → en-CHnrV5l8.cjs.map} +1 -1
- package/dist/{extensions-D6JcJCwd.js → extensions-B1JQURVF.js} +221 -221
- package/dist/extensions-B1JQURVF.js.map +1 -0
- package/dist/{extensions-B7Rsp_Ft.cjs → extensions-CZkqKzJO.cjs} +3 -3
- package/dist/extensions-CZkqKzJO.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +2 -2
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +89 -23
- package/dist/locales.js.map +1 -1
- package/dist/{src-Buuo5l7X.js → src-D5w0XAHX.js} +702 -640
- package/dist/src-D5w0XAHX.js.map +1 -0
- package/dist/{src-C54Ok9E0.cjs → src-th5uZEvx.cjs} +8 -8
- package/dist/src-th5uZEvx.cjs.map +1 -0
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.js +3 -3
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +12 -12
- package/src/comments/CommentEditorSubmitExtension.test.ts +141 -0
- package/src/comments/CommentEditorSubmitExtension.ts +56 -0
- package/src/comments/extension.ts +8 -0
- package/src/comments/index.ts +1 -0
- package/src/editor/BlockNoteEditor.ts +94 -41
- package/src/editor/BlockNoteExtension.ts +6 -1
- package/src/editor/managers/EventManager.browser.test.ts +334 -0
- package/src/editor/managers/EventManager.ts +128 -31
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +88 -1
- package/src/editor/managers/ExtensionManager/index.ts +30 -7
- package/src/editor/managers/StyleManager.browser.test.ts +122 -0
- package/src/editor/managers/StyleManager.test.ts +98 -0
- package/src/editor/managers/StyleManager.ts +31 -15
- package/src/editor/managers/index.ts +1 -0
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +23 -0
- package/src/extensions/SideMenu/SideMenu.ts +15 -0
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +3 -1
- package/src/i18n/locales/ar.ts +1 -0
- package/src/i18n/locales/de.ts +1 -0
- package/src/i18n/locales/en.ts +1 -0
- package/src/i18n/locales/es.ts +1 -0
- package/src/i18n/locales/fa.ts +1 -0
- package/src/i18n/locales/fr.ts +1 -0
- package/src/i18n/locales/he.ts +1 -0
- package/src/i18n/locales/hr.ts +1 -0
- package/src/i18n/locales/is.ts +1 -0
- package/src/i18n/locales/it.ts +1 -0
- package/src/i18n/locales/ja.ts +1 -0
- package/src/i18n/locales/ko.ts +1 -0
- package/src/i18n/locales/nl.ts +1 -0
- package/src/i18n/locales/no.ts +1 -0
- package/src/i18n/locales/pl.ts +1 -0
- package/src/i18n/locales/pt.ts +1 -0
- package/src/i18n/locales/ru.ts +1 -0
- package/src/i18n/locales/sk.ts +1 -0
- package/src/i18n/locales/uk.ts +1 -0
- package/src/i18n/locales/uz.ts +1 -0
- package/src/i18n/locales/vi.ts +1 -0
- package/src/i18n/locales/zh-tw.ts +1 -0
- package/src/i18n/locales/zh.ts +1 -0
- package/src/index.ts +1 -0
- package/src/util/browser.ts +24 -0
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
- package/types/src/comments/CommentEditorSubmitExtension.d.ts +19 -0
- package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +1 -0
- package/types/src/comments/extension.d.ts +7 -0
- package/types/src/comments/index.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +52 -19
- package/types/src/editor/BlockNoteExtension.d.ts +3 -0
- package/types/src/editor/managers/EventManager.browser.test.d.ts +1 -0
- package/types/src/editor/managers/EventManager.d.ts +55 -0
- package/types/src/editor/managers/StyleManager.browser.test.d.ts +1 -0
- package/types/src/editor/managers/StyleManager.d.ts +4 -2
- package/types/src/editor/managers/StyleManager.test.d.ts +1 -0
- package/types/src/editor/managers/index.d.ts +1 -0
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +3 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +1 -0
- package/types/src/i18n/locales/en.d.ts +1 -0
- package/types/src/i18n/locales/fa.d.ts +1 -0
- package/types/src/i18n/locales/sk.d.ts +1 -0
- package/types/src/index.d.ts +1 -0
- package/types/src/util/browser.d.ts +2 -0
- package/dist/blocks-CTB_5Vyj.cjs +0 -12
- package/dist/blocks-CTB_5Vyj.cjs.map +0 -1
- package/dist/blocks-Dol85hpH.js.map +0 -1
- package/dist/extensions-B7Rsp_Ft.cjs.map +0 -1
- package/dist/extensions-D6JcJCwd.js.map +0 -1
- package/dist/src-Buuo5l7X.js.map +0 -1
- package/dist/src-C54Ok9E0.cjs.map +0 -1
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as
|
|
3
|
-
import { A as
|
|
4
|
-
import { r as
|
|
5
|
-
import { t as
|
|
6
|
-
import { DOMParser as
|
|
7
|
-
import { ReplaceAroundStep as
|
|
8
|
-
import { Editor as
|
|
9
|
-
import { NodeSelection as
|
|
10
|
-
import { DOMParser as
|
|
11
|
-
import { CellSelection as
|
|
12
|
-
import { Plugin as
|
|
13
|
-
import { digestString as
|
|
14
|
-
import { InputRule as
|
|
15
|
-
import {
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Gapcursor as
|
|
1
|
+
import { At as e, Cn as t, Ct as n, En as r, Ft as i, It as a, Lt as o, Mt as s, Nt as c, O as l, On as u, Pn as d, Sn as f, Tn as p, Tt as m, Un as h, W as g, Wn as _, Yt as ee, an as te, bn as ne, bt as re, er as ie, f as ae, gn as oe, in as se, ir as v, jn as y, jt as ce, m as le, nr as ue, or as de, rn as fe, rr as b, sr as x, t as pe, tr as S, wn as C, xn as me } from "./blocks-DaEUT0O1.js";
|
|
2
|
+
import { o as he, r as ge, t as _e } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
|
+
import { A as ve, C as ye, F as be, M as xe, N as Se, O as Ce, P as we, S as Te, T as Ee, b as De, c as Oe, g as ke, h as Ae, k as je, m as Me, s as Ne, w as Pe, x as Fe, y as Ie } from "./extensions-B1JQURVF.js";
|
|
4
|
+
import { r as Le } from "./UserStore-C4TzkGEn.js";
|
|
5
|
+
import { t as Re } from "./en-BAn9gxr-.js";
|
|
6
|
+
import { DOMParser as ze, DOMSerializer as Be, Fragment as w, NodeRange as Ve, Slice as T } from "prosemirror-model";
|
|
7
|
+
import { ReplaceAroundStep as E, ReplaceStep as He, canJoin as Ue, liftTarget as We } from "prosemirror-transform";
|
|
8
|
+
import { Editor as Ge, Extension as D, Mark as Ke, Node as O, combineTransactionSteps as qe, createDocument as Je, extensions as k, findChildrenInRange as Ye, findParentNodeClosestToPos as Xe, getAttributes as Ze, getChangedRanges as Qe, getMarkRange as $e, getMarksBetween as et, getSchema as tt, isNodeSelection as nt, markPasteRule as rt, mergeAttributes as A, posToDOMRect as it, selectionToInsertionEnd as at } from "@tiptap/core";
|
|
9
|
+
import { NodeSelection as j, Plugin as M, TextSelection as N } from "prosemirror-state";
|
|
10
|
+
import { DOMParser as ot, Fragment as P, Slice as F } from "@tiptap/pm/model";
|
|
11
|
+
import { CellSelection as I, TableMap as st } from "prosemirror-tables";
|
|
12
|
+
import { Plugin as ct, PluginKey as lt } from "@tiptap/pm/state";
|
|
13
|
+
import { digestString as ut } from "lib0/hash/fnv1a";
|
|
14
|
+
import { InputRule as dt, inputRules as ft } from "@handlewithcare/prosemirror-inputrules";
|
|
15
|
+
import { keydownHandler as pt } from "@tiptap/pm/keymap";
|
|
16
|
+
import { Text as mt } from "@tiptap/extension-text";
|
|
17
|
+
import { Gapcursor as ht } from "@tiptap/extensions/gap-cursor";
|
|
18
18
|
//#region src/schema/blocks/types.ts
|
|
19
|
-
function
|
|
19
|
+
function gt(e) {
|
|
20
20
|
return typeof e == "string" ? e : e.map((e) => typeof e == "string" ? e : e.text).join("");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/schema/inlineContent/createSpec.ts
|
|
24
|
-
function
|
|
24
|
+
function _t(e) {
|
|
25
25
|
return e.matches("[data-editable]") ? e : e.querySelector("[data-editable]") || e;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function vt(e, t) {
|
|
28
|
+
return ot.fromSchema(t).parse(e, {
|
|
29
29
|
topNode: t.nodes.paragraph.create(),
|
|
30
30
|
preserveWhitespace: !0
|
|
31
31
|
}).content;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function yt(e, t) {
|
|
34
34
|
let n = [];
|
|
35
35
|
return e.forEach((e) => {
|
|
36
36
|
if (e.isText) n.push(e);
|
|
@@ -38,21 +38,21 @@ function _t(e, t) {
|
|
|
38
38
|
let r = e.type === t.linebreakReplacement ? "\n" : e.textContent;
|
|
39
39
|
r && n.push(t.text(r, e.marks));
|
|
40
40
|
}
|
|
41
|
-
}),
|
|
41
|
+
}), P.fromArray(n);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function bt(e, t, n) {
|
|
44
44
|
let r = e.content === "plain" || n && e.content === "styled" ? (t) => (r, i) => {
|
|
45
45
|
let a = n?.({
|
|
46
46
|
el: r,
|
|
47
47
|
schema: i
|
|
48
48
|
});
|
|
49
|
-
if (a !== void 0) return e.content === "plain" ?
|
|
50
|
-
let o =
|
|
51
|
-
return e.content === "plain" ?
|
|
49
|
+
if (a !== void 0) return e.content === "plain" ? yt(a, i) : a;
|
|
50
|
+
let o = vt(t(r), i);
|
|
51
|
+
return e.content === "plain" ? yt(o, i) : o;
|
|
52
52
|
} : void 0, i = [{
|
|
53
53
|
tag: `[data-inline-content-type="${e.type}"]`,
|
|
54
|
-
contentElement: (e) =>
|
|
55
|
-
getContent: r ? (e, t) => r(
|
|
54
|
+
contentElement: (e) => _t(e),
|
|
55
|
+
getContent: r ? (e, t) => r(_t)(e, t) : void 0
|
|
56
56
|
}];
|
|
57
57
|
return t && i.push({
|
|
58
58
|
tag: "*",
|
|
@@ -65,8 +65,8 @@ function vt(e, t, n) {
|
|
|
65
65
|
getContent: r ? (e, t) => r((e) => e)(e, t) : void 0
|
|
66
66
|
}), i;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
let n =
|
|
68
|
+
function xt(e, t) {
|
|
69
|
+
let n = O.create({
|
|
70
70
|
name: e.type,
|
|
71
71
|
inline: !0,
|
|
72
72
|
group: "inline",
|
|
@@ -76,60 +76,60 @@ function yt(e, t) {
|
|
|
76
76
|
code: t.meta?.code,
|
|
77
77
|
content: e.content === "styled" ? "inline*" : e.content === "plain" ? "text*" : "",
|
|
78
78
|
marks() {
|
|
79
|
-
return e.content === "plain" ?
|
|
79
|
+
return e.content === "plain" ? he(this.editor) : void 0;
|
|
80
80
|
},
|
|
81
81
|
addAttributes() {
|
|
82
|
-
return
|
|
82
|
+
return oe(e.propSchema);
|
|
83
83
|
},
|
|
84
84
|
addKeyboardShortcuts() {
|
|
85
|
-
return
|
|
85
|
+
return se(e);
|
|
86
86
|
},
|
|
87
87
|
parseHTML() {
|
|
88
|
-
return
|
|
88
|
+
return bt(e, t.parse, t.parseContent);
|
|
89
89
|
},
|
|
90
90
|
renderHTML({ node: n }) {
|
|
91
91
|
let r = this.options.editor, i = t.render.call({
|
|
92
92
|
renderType: "dom",
|
|
93
93
|
props: void 0
|
|
94
|
-
},
|
|
95
|
-
return
|
|
94
|
+
}, p(n, r.schema.inlineContentSchema, r.schema.styleSchema), () => {}, r, n, () => void 0);
|
|
95
|
+
return fe(i, e.type, n.attrs, e.propSchema);
|
|
96
96
|
},
|
|
97
97
|
addNodeView() {
|
|
98
98
|
return (n) => {
|
|
99
|
-
let { node: r, getPos: i } = n,
|
|
99
|
+
let { node: r, getPos: i } = n, o = this.options.editor, s = t.render.call({
|
|
100
100
|
renderType: "nodeView",
|
|
101
101
|
props: n
|
|
102
|
-
},
|
|
103
|
-
let t =
|
|
104
|
-
n &&
|
|
105
|
-
},
|
|
106
|
-
return
|
|
102
|
+
}, p(r, o.schema.inlineContentSchema, o.schema.styleSchema), (e) => {
|
|
103
|
+
let t = a([e], o.pmSchema), n = i();
|
|
104
|
+
n && o.transact((e) => e.replaceWith(n, n + r.nodeSize, t));
|
|
105
|
+
}, o, r, i), c = fe(s, e.type, r.attrs, e.propSchema);
|
|
106
|
+
return d(c), c;
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
return
|
|
110
|
+
return te(n, e.propSchema, {
|
|
111
111
|
...t,
|
|
112
112
|
toExternalHTML: t.toExternalHTML,
|
|
113
113
|
render(n, r, i) {
|
|
114
|
-
let
|
|
115
|
-
return
|
|
114
|
+
let o = a([n], i.pmSchema)[0], s = t.render(n, r, i, o, () => void 0);
|
|
115
|
+
return fe(s, e.type, n.props, e.propSchema);
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
|
|
121
|
-
function
|
|
122
|
-
let
|
|
123
|
-
let t =
|
|
121
|
+
function L(e, t, n, r = "before") {
|
|
122
|
+
let a = typeof n == "string" ? n : n.id, o = y(e), s = t.map((e) => {
|
|
123
|
+
let t = i(e, o);
|
|
124
124
|
return t.check(), t;
|
|
125
|
-
}),
|
|
126
|
-
if (!
|
|
127
|
-
let
|
|
128
|
-
return r === "after" && (
|
|
125
|
+
}), l = c(a, e.doc);
|
|
126
|
+
if (!l) throw Error(`Block with ID ${a} not found`);
|
|
127
|
+
let u = l.posBeforeNode;
|
|
128
|
+
return r === "after" && (u += l.node.nodeSize), e.step(new He(u, u, new T(w.from(s), 0, 0))), s.map((t) => C(t, e.doc));
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
|
|
132
|
-
function
|
|
132
|
+
function R(e) {
|
|
133
133
|
if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
134
134
|
let t = e.firstChild;
|
|
135
135
|
if (!t) throw Error("Invalid column: does not have child node.");
|
|
@@ -137,50 +137,50 @@ function z(e) {
|
|
|
137
137
|
if (!n) throw Error("Invalid blockContainer: does not have child node.");
|
|
138
138
|
return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function St(e, t) {
|
|
141
141
|
let n = e.doc.resolve(t), r = n.nodeAfter;
|
|
142
142
|
if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
143
143
|
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
144
144
|
let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
|
|
145
145
|
if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
146
|
-
|
|
146
|
+
R(i) && e.delete(r, r + i.nodeSize);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
149
|
+
function z(e, t) {
|
|
150
|
+
St(e, t);
|
|
151
151
|
let n = e.doc.resolve(t).nodeAfter;
|
|
152
152
|
if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
153
153
|
if (n.childCount > 2) return;
|
|
154
154
|
if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
|
|
155
155
|
let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
|
|
156
156
|
if (!i || !o) throw Error("Invalid columnList: does not contain children.");
|
|
157
|
-
let s =
|
|
157
|
+
let s = R(i), c = R(o);
|
|
158
158
|
if (s && c) {
|
|
159
159
|
e.delete(t, t + n.nodeSize);
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
if (s) {
|
|
163
|
-
e.step(new
|
|
163
|
+
e.step(new E(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, T.empty, 0, !1));
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
if (c) {
|
|
167
|
-
e.step(new
|
|
167
|
+
e.step(new E(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, T.empty, 0, !1));
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
|
|
173
|
-
function
|
|
174
|
-
let
|
|
175
|
-
let t =
|
|
173
|
+
function B(e, t, n, r = {}) {
|
|
174
|
+
let a = y(e), o = n.map((e) => {
|
|
175
|
+
let t = i(e, a);
|
|
176
176
|
return t.check(), t;
|
|
177
177
|
}), s = new Set(t.map((e) => typeof e == "string" ? e : e.id)), c = [], l = /* @__PURE__ */ new Set(), u = typeof t[0] == "string" ? t[0] : t[0].id, d = 0;
|
|
178
178
|
if (e.doc.descendants((t, r) => {
|
|
179
179
|
if (s.size === 0) return !1;
|
|
180
180
|
if (!t.type.isInGroup("bnBlock")) return !0;
|
|
181
|
-
let i =
|
|
181
|
+
let i = x(t, e.doc);
|
|
182
182
|
if (!s.has(i)) return !0;
|
|
183
|
-
if (c.push(
|
|
183
|
+
if (c.push(C(t, e.doc)), s.delete(i), n.length > 0 && i === u) {
|
|
184
184
|
let t = e.doc.nodeSize;
|
|
185
185
|
e.insert(r, o);
|
|
186
186
|
let n = e.doc.nodeSize;
|
|
@@ -194,30 +194,30 @@ function V(e, t, n, r = {}) {
|
|
|
194
194
|
let e = [...s].join("\n");
|
|
195
195
|
throw Error("Blocks with the following IDs could not be found in the editor: " + e);
|
|
196
196
|
}
|
|
197
|
-
return r.fixColumns !== !1 && l.forEach((t) =>
|
|
198
|
-
insertedBlocks: o.map((t) =>
|
|
197
|
+
return r.fixColumns !== !1 && l.forEach((t) => z(e, t)), {
|
|
198
|
+
insertedBlocks: o.map((t) => C(t, e.doc)),
|
|
199
199
|
removedBlocks: c
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
|
|
204
|
-
function
|
|
205
|
-
let
|
|
204
|
+
function Ct(e, t, n, r, i) {
|
|
205
|
+
let s;
|
|
206
206
|
if (!t) throw Error("blockContent is required");
|
|
207
|
-
if (typeof t == "string")
|
|
208
|
-
else if (Array.isArray(t))
|
|
209
|
-
else if (t.type === "tableContent")
|
|
210
|
-
else throw new
|
|
211
|
-
let
|
|
212
|
-
for (let t of
|
|
207
|
+
if (typeof t == "string") s = a([t], e.pmSchema, r);
|
|
208
|
+
else if (Array.isArray(t)) s = a(t, e.pmSchema, r);
|
|
209
|
+
else if (t.type === "tableContent") s = o(t, e.pmSchema);
|
|
210
|
+
else throw new _(t.type);
|
|
211
|
+
let c = (i?.document ?? document).createDocumentFragment();
|
|
212
|
+
for (let t of s) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
213
213
|
let r = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
214
214
|
if (r) {
|
|
215
|
-
let a =
|
|
215
|
+
let a = p(t, e.schema.inlineContentSchema, e.schema.styleSchema), o = r.render.call({
|
|
216
216
|
renderType: "dom",
|
|
217
217
|
props: void 0
|
|
218
218
|
}, a, () => {}, e);
|
|
219
219
|
if (o) {
|
|
220
|
-
if (
|
|
220
|
+
if (c.appendChild(o.dom), o.contentDOM) {
|
|
221
221
|
let e = n.serializeFragment(t.content, i);
|
|
222
222
|
o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(e);
|
|
223
223
|
}
|
|
@@ -230,17 +230,17 @@ function St(e, t, n, r, i) {
|
|
|
230
230
|
let t = e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, e);
|
|
231
231
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
232
232
|
} else {
|
|
233
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
233
|
+
let e = r.type.spec.toDOM(r, !0), t = Be.renderSpec(document, e);
|
|
234
234
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
235
235
|
}
|
|
236
|
-
|
|
236
|
+
c.appendChild(n);
|
|
237
237
|
} else {
|
|
238
|
-
let e = n.serializeFragment(
|
|
239
|
-
|
|
238
|
+
let e = n.serializeFragment(w.from([t]), i);
|
|
239
|
+
c.appendChild(e);
|
|
240
240
|
}
|
|
241
|
-
return
|
|
241
|
+
return c;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function wt(e, t, n, r) {
|
|
244
244
|
let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
|
|
245
245
|
for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
|
|
246
246
|
let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
|
|
@@ -252,12 +252,12 @@ function Ct(e, t, n, r) {
|
|
|
252
252
|
children: o
|
|
253
253
|
}, e);
|
|
254
254
|
if (s.contentDOM && t.content) {
|
|
255
|
-
let i =
|
|
255
|
+
let i = Ct(e, t.content, n, t.type, r);
|
|
256
256
|
s.contentDOM.appendChild(i);
|
|
257
257
|
}
|
|
258
258
|
if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
|
|
259
259
|
if (t.children && t.children.length > 0) {
|
|
260
|
-
let i =
|
|
260
|
+
let i = Tt(e, t.children, n, r);
|
|
261
261
|
s.contentDOM?.append(i);
|
|
262
262
|
}
|
|
263
263
|
return s.dom;
|
|
@@ -266,59 +266,59 @@ function Ct(e, t, n, r) {
|
|
|
266
266
|
id: t.id,
|
|
267
267
|
...a
|
|
268
268
|
}));
|
|
269
|
-
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(
|
|
269
|
+
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(Et(e, t.children, n, r)), c.dom;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function Tt(e, t, n, r) {
|
|
272
272
|
let i = (r?.document ?? document).createDocumentFragment();
|
|
273
273
|
for (let a of t) {
|
|
274
|
-
let t =
|
|
274
|
+
let t = wt(e, a, n, r);
|
|
275
275
|
i.appendChild(t);
|
|
276
276
|
}
|
|
277
277
|
return i;
|
|
278
278
|
}
|
|
279
|
-
var
|
|
280
|
-
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o =
|
|
279
|
+
var Et = (e, t, n, r) => {
|
|
280
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = Tt(e, t, n, r);
|
|
281
281
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
282
|
-
},
|
|
282
|
+
}, Dt = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
|
|
283
283
|
let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
|
|
284
284
|
if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
|
|
285
285
|
else {
|
|
286
286
|
let n = t.getAttribute("data-index");
|
|
287
287
|
e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
|
|
288
288
|
}
|
|
289
|
-
}), e),
|
|
289
|
+
}), e), Ot = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
290
290
|
e.disabled = !0;
|
|
291
|
-
}), e),
|
|
291
|
+
}), e), kt = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
|
|
292
292
|
e.setAttribute("data-show-children", "true");
|
|
293
|
-
}), e), kt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
294
|
-
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
295
293
|
}), e), At = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
294
|
+
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
295
|
+
}), e), jt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
296
296
|
let t = document.createElement("div");
|
|
297
297
|
t.className = "tableWrapper";
|
|
298
298
|
let n = document.createElement("div");
|
|
299
299
|
n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
|
|
300
|
-
}), e),
|
|
300
|
+
}), e), Mt = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
|
|
301
301
|
let t = document.createElement("span");
|
|
302
302
|
t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
|
|
303
|
-
}), e),
|
|
304
|
-
let n =
|
|
305
|
-
Et,
|
|
303
|
+
}), e), Nt = (e, t) => {
|
|
304
|
+
let n = Be.fromSchema(e), r = [
|
|
306
305
|
Dt,
|
|
307
306
|
Ot,
|
|
308
307
|
kt,
|
|
309
308
|
At,
|
|
310
|
-
jt
|
|
309
|
+
jt,
|
|
310
|
+
Mt
|
|
311
311
|
];
|
|
312
312
|
return { serializeBlocks: (e, i) => {
|
|
313
|
-
let a =
|
|
313
|
+
let a = Et(t, e, n, i);
|
|
314
314
|
for (let e of r) a = e(a);
|
|
315
315
|
return a.outerHTML;
|
|
316
316
|
} };
|
|
317
|
-
},
|
|
317
|
+
}, Pt = (e) => {
|
|
318
318
|
let t = 0;
|
|
319
319
|
for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n);
|
|
320
320
|
return Math.abs(t);
|
|
321
|
-
},
|
|
321
|
+
}, V = [
|
|
322
322
|
{
|
|
323
323
|
light: "#fff0c2",
|
|
324
324
|
dark: "#8a6d1a"
|
|
@@ -339,20 +339,20 @@ var Tt = (e, t, n, r) => {
|
|
|
339
339
|
light: "#bef3ff",
|
|
340
340
|
dark: "#0a7a8a"
|
|
341
341
|
}
|
|
342
|
-
],
|
|
343
|
-
if (!t || t.length === 0) return
|
|
342
|
+
], Ft = (e) => V[Pt(e) % V.length], It = (e, t) => {
|
|
343
|
+
if (!t || t.length === 0) return V[0];
|
|
344
344
|
let n = t[0], r = e.getUser(n);
|
|
345
345
|
return r?.color && r.colorLight ? {
|
|
346
346
|
light: r.colorLight,
|
|
347
347
|
dark: r.color
|
|
348
|
-
} :
|
|
349
|
-
},
|
|
350
|
-
let t =
|
|
348
|
+
} : Ft(n);
|
|
349
|
+
}, Lt = (e) => ut(e).toString(16).padStart(8, "0"), Rt = (e) => {
|
|
350
|
+
let t = Lt(e);
|
|
351
351
|
return {
|
|
352
352
|
light: `--user-color-${t}-light`,
|
|
353
353
|
dark: `--user-color-${t}-dark`
|
|
354
354
|
};
|
|
355
|
-
},
|
|
355
|
+
}, H = class {
|
|
356
356
|
callbacks = {};
|
|
357
357
|
on(e, t) {
|
|
358
358
|
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
@@ -371,90 +371,90 @@ var Tt = (e, t, n, r) => {
|
|
|
371
371
|
};
|
|
372
372
|
//#endregion
|
|
373
373
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
374
|
-
function
|
|
374
|
+
function zt(e) {
|
|
375
375
|
return e.transact((e) => {
|
|
376
|
-
let t =
|
|
377
|
-
if (e.selection instanceof
|
|
376
|
+
let t = ue(e, e.selection.anchor), n = x(t.bnBlock.node, e.doc);
|
|
377
|
+
if (e.selection instanceof I) return {
|
|
378
378
|
type: "cell",
|
|
379
379
|
anchorBlockId: n,
|
|
380
380
|
anchorCellOffset: e.selection.$anchorCell.pos - t.bnBlock.beforePos,
|
|
381
381
|
headCellOffset: e.selection.$headCell.pos - t.bnBlock.beforePos
|
|
382
382
|
};
|
|
383
|
-
if (e.selection instanceof
|
|
383
|
+
if (e.selection instanceof j) return {
|
|
384
384
|
type: "node",
|
|
385
385
|
anchorBlockId: n
|
|
386
386
|
};
|
|
387
387
|
{
|
|
388
|
-
let r =
|
|
388
|
+
let r = ue(e, e.selection.head);
|
|
389
389
|
return {
|
|
390
390
|
type: "text",
|
|
391
391
|
anchorBlockId: n,
|
|
392
|
-
headBlockId:
|
|
392
|
+
headBlockId: x(r.bnBlock.node, e.doc),
|
|
393
393
|
anchorOffset: e.selection.anchor - t.bnBlock.beforePos,
|
|
394
394
|
headOffset: e.selection.head - r.bnBlock.beforePos
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
|
-
function
|
|
400
|
-
let n =
|
|
399
|
+
function Bt(e, t) {
|
|
400
|
+
let n = c(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
401
401
|
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
402
402
|
let r;
|
|
403
|
-
if (t.type === "cell") r =
|
|
404
|
-
else if (t.type === "node") r =
|
|
403
|
+
if (t.type === "cell") r = I.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
|
|
404
|
+
else if (t.type === "node") r = j.create(e.doc, n + 1);
|
|
405
405
|
else {
|
|
406
|
-
let i =
|
|
406
|
+
let i = c(t.headBlockId, e.doc)?.posBeforeNode;
|
|
407
407
|
if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
408
|
-
r =
|
|
408
|
+
r = N.create(e.doc, n + t.anchorOffset, i + t.headOffset);
|
|
409
409
|
}
|
|
410
410
|
e.setSelection(r);
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function Vt(e) {
|
|
413
413
|
return e.flatMap((e) => e.type === "column" ? e.children : [e]);
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function U(e, t, n, r) {
|
|
416
416
|
e.transact((e) => {
|
|
417
|
-
|
|
417
|
+
B(e, t, [], { fixColumns: !1 }), L(e, Vt(t), n, r);
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function Ht(e, t, n) {
|
|
421
421
|
e.transact((r) => {
|
|
422
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
423
|
-
|
|
422
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = zt(e);
|
|
423
|
+
U(e, i, t, n), Bt(r, a);
|
|
424
424
|
});
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function Ut(e) {
|
|
427
427
|
return !e || e.type !== "columnList";
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function Wt(e, t, n) {
|
|
430
430
|
let r, i;
|
|
431
431
|
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;
|
|
432
432
|
let a = e.getParentBlock(r);
|
|
433
|
-
return
|
|
433
|
+
return Ut(a) ? {
|
|
434
434
|
referenceBlock: r,
|
|
435
435
|
placement: i
|
|
436
|
-
} :
|
|
436
|
+
} : Wt(e, i === "after" ? r : e.getPrevBlock(r), a);
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function Gt(e, t, n) {
|
|
439
439
|
let r, i;
|
|
440
440
|
if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
|
|
441
441
|
let a = e.getParentBlock(r);
|
|
442
|
-
return
|
|
442
|
+
return Ut(a) ? {
|
|
443
443
|
referenceBlock: r,
|
|
444
444
|
placement: i
|
|
445
|
-
} :
|
|
445
|
+
} : Gt(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function Kt(e, t) {
|
|
448
448
|
e.transact(() => {
|
|
449
449
|
let n;
|
|
450
450
|
if (t) {
|
|
451
451
|
if (n = e.getBlock(t), !n) return;
|
|
452
452
|
} else n = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block;
|
|
453
|
-
let r =
|
|
454
|
-
r && (t ?
|
|
453
|
+
let r = Wt(e, e.getPrevBlock(n), e.getParentBlock(n));
|
|
454
|
+
r && (t ? U(e, [n], r.referenceBlock, r.placement) : Ht(e, r.referenceBlock, r.placement));
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
|
-
function
|
|
457
|
+
function qt(e, t) {
|
|
458
458
|
e.transact(() => {
|
|
459
459
|
let n;
|
|
460
460
|
if (t) {
|
|
@@ -463,101 +463,101 @@ function Kt(e, t) {
|
|
|
463
463
|
let t = e.getSelection();
|
|
464
464
|
n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block;
|
|
465
465
|
}
|
|
466
|
-
let r =
|
|
467
|
-
r && (t ?
|
|
466
|
+
let r = Gt(e, e.getNextBlock(n), e.getParentBlock(n));
|
|
467
|
+
r && (t ? U(e, [n], r.referenceBlock, r.placement) : Ht(e, r.referenceBlock, r.placement));
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
//#endregion
|
|
471
471
|
//#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
|
|
472
|
-
function
|
|
472
|
+
function Jt(e, t, n) {
|
|
473
473
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
474
474
|
if (!a) return !1;
|
|
475
475
|
let o = a.startIndex;
|
|
476
476
|
if (o === 0) return !1;
|
|
477
477
|
let s = a.parent.child(o - 1);
|
|
478
478
|
if (s.type !== t) return !1;
|
|
479
|
-
let c = s.lastChild && s.lastChild.type === n, l =
|
|
480
|
-
return e.step(new
|
|
479
|
+
let c = s.lastChild && s.lastChild.type === n, l = w.from(c ? t.create() : null), u = new T(w.from(t.create(null, w.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
|
|
480
|
+
return e.step(new E(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
|
|
481
481
|
}
|
|
482
|
-
function
|
|
483
|
-
return e.transact((t) =>
|
|
482
|
+
function Yt(e) {
|
|
483
|
+
return e.transact((t) => Jt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
function Xt(e, t, n, r) {
|
|
486
486
|
let i = r.end, a = r.$to.end(r.depth);
|
|
487
487
|
if (i < a) {
|
|
488
488
|
let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
|
|
489
|
-
e.step(new
|
|
489
|
+
e.step(new E(i - (s ? 2 : 1), a, i, a, new T(w.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new Ve(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
|
|
490
490
|
}
|
|
491
|
-
let o =
|
|
491
|
+
let o = We(r);
|
|
492
492
|
if (o == null) return !1;
|
|
493
493
|
e.lift(r, o);
|
|
494
494
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
495
|
-
return
|
|
495
|
+
return Ue(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
496
496
|
}
|
|
497
|
-
function
|
|
497
|
+
function W(e, t, n) {
|
|
498
498
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
499
|
-
return a ? r.node(a.depth - 1).type === t &&
|
|
500
|
-
}
|
|
501
|
-
function Xt(e) {
|
|
502
|
-
return e.transact((t) => G(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
499
|
+
return a ? r.node(a.depth - 1).type === t && Xt(e, t, n, a) : !1;
|
|
503
500
|
}
|
|
504
501
|
function Zt(e) {
|
|
502
|
+
return e.transact((t) => W(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
503
|
+
}
|
|
504
|
+
function Qt(e) {
|
|
505
505
|
return e.transact((e) => {
|
|
506
|
-
let { bnBlock: t } =
|
|
506
|
+
let { bnBlock: t } = v(e);
|
|
507
507
|
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
508
508
|
});
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function $t(e) {
|
|
511
511
|
return e.transact((e) => {
|
|
512
|
-
let { bnBlock: t } =
|
|
512
|
+
let { bnBlock: t } = v(e);
|
|
513
513
|
return e.doc.resolve(t.beforePos).depth > 1;
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
//#endregion
|
|
517
517
|
//#region src/api/blockManipulation/getBlock/getBlock.ts
|
|
518
|
-
function $t(e, t) {
|
|
519
|
-
let n = typeof t == "string" ? t : t.id, r = u(n, e);
|
|
520
|
-
if (r) return T(r.node, e);
|
|
521
|
-
}
|
|
522
518
|
function en(e, t) {
|
|
523
|
-
let n = typeof t == "string" ? t : t.id, r =
|
|
519
|
+
let n = typeof t == "string" ? t : t.id, r = c(n, e);
|
|
520
|
+
if (r) return C(r.node, e);
|
|
521
|
+
}
|
|
522
|
+
function tn(e, t) {
|
|
523
|
+
let n = typeof t == "string" ? t : t.id, r = c(n, e);
|
|
524
524
|
if (!r) return;
|
|
525
525
|
let i = e.resolve(r.posBeforeNode).nodeBefore;
|
|
526
|
-
if (i) return
|
|
526
|
+
if (i) return C(i, e);
|
|
527
527
|
}
|
|
528
|
-
function
|
|
529
|
-
let n = typeof t == "string" ? t : t.id, r =
|
|
528
|
+
function nn(e, t) {
|
|
529
|
+
let n = typeof t == "string" ? t : t.id, r = c(n, e);
|
|
530
530
|
if (!r) return;
|
|
531
531
|
let i = e.resolve(r.posBeforeNode + r.node.nodeSize).nodeAfter;
|
|
532
|
-
if (i) return
|
|
532
|
+
if (i) return C(i, e);
|
|
533
533
|
}
|
|
534
|
-
function
|
|
535
|
-
let n = typeof t == "string" ? t : t.id, r =
|
|
534
|
+
function rn(e, t) {
|
|
535
|
+
let n = typeof t == "string" ? t : t.id, r = c(n, e);
|
|
536
536
|
if (!r) return;
|
|
537
537
|
let i = e.resolve(r.posBeforeNode), a = i.node(), o = i.node(-1), s = o.type.name === "doc" ? void 0 : a.type.name === "blockGroup" ? o : a;
|
|
538
|
-
if (s) return
|
|
538
|
+
if (s) return C(s, e);
|
|
539
539
|
}
|
|
540
540
|
//#endregion
|
|
541
541
|
//#region src/editor/managers/BlockManager.ts
|
|
542
|
-
var
|
|
542
|
+
var an = class {
|
|
543
543
|
editor;
|
|
544
544
|
constructor(e) {
|
|
545
545
|
this.editor = e;
|
|
546
546
|
}
|
|
547
547
|
get document() {
|
|
548
|
-
return this.editor.transact((e) =>
|
|
548
|
+
return this.editor.transact((e) => t(e.doc));
|
|
549
549
|
}
|
|
550
550
|
getBlock(e) {
|
|
551
|
-
return this.editor.transact((t) =>
|
|
551
|
+
return this.editor.transact((t) => en(t.doc, e));
|
|
552
552
|
}
|
|
553
553
|
getPrevBlock(e) {
|
|
554
|
-
return this.editor.transact((t) =>
|
|
554
|
+
return this.editor.transact((t) => tn(t.doc, e));
|
|
555
555
|
}
|
|
556
556
|
getNextBlock(e) {
|
|
557
|
-
return this.editor.transact((t) =>
|
|
557
|
+
return this.editor.transact((t) => nn(t.doc, e));
|
|
558
558
|
}
|
|
559
559
|
getParentBlock(e) {
|
|
560
|
-
return this.editor.transact((t) =>
|
|
560
|
+
return this.editor.transact((t) => rn(t.doc, e));
|
|
561
561
|
}
|
|
562
562
|
forEachBlock(e, t = !1) {
|
|
563
563
|
let n = this.document.slice();
|
|
@@ -569,36 +569,36 @@ var rn = class {
|
|
|
569
569
|
r(n);
|
|
570
570
|
}
|
|
571
571
|
insertBlocks(e, t, n = "before") {
|
|
572
|
-
return this.editor.transact((r) =>
|
|
572
|
+
return this.editor.transact((r) => L(r, e, t, n));
|
|
573
573
|
}
|
|
574
|
-
updateBlock(
|
|
575
|
-
return this.editor.transact((r) =>
|
|
574
|
+
updateBlock(t, n) {
|
|
575
|
+
return this.editor.transact((r) => e(r, t, n));
|
|
576
576
|
}
|
|
577
577
|
removeBlocks(e) {
|
|
578
|
-
return this.editor.transact((t) =>
|
|
578
|
+
return this.editor.transact((t) => B(t, e, []).removedBlocks);
|
|
579
579
|
}
|
|
580
580
|
replaceBlocks(e, t) {
|
|
581
|
-
return this.editor.transact((n) =>
|
|
581
|
+
return this.editor.transact((n) => B(n, e, t));
|
|
582
582
|
}
|
|
583
583
|
canNestBlock() {
|
|
584
|
-
return
|
|
584
|
+
return Qt(this.editor);
|
|
585
585
|
}
|
|
586
586
|
nestBlock() {
|
|
587
|
-
|
|
587
|
+
Yt(this.editor);
|
|
588
588
|
}
|
|
589
589
|
canUnnestBlock() {
|
|
590
|
-
return
|
|
590
|
+
return $t(this.editor);
|
|
591
591
|
}
|
|
592
592
|
unnestBlock() {
|
|
593
|
-
|
|
593
|
+
Zt(this.editor);
|
|
594
594
|
}
|
|
595
595
|
moveBlocksUp(e) {
|
|
596
|
-
return
|
|
596
|
+
return Kt(this.editor, e);
|
|
597
597
|
}
|
|
598
598
|
moveBlocksDown(e) {
|
|
599
|
-
return
|
|
599
|
+
return qt(this.editor, e);
|
|
600
600
|
}
|
|
601
|
-
},
|
|
601
|
+
}, on = class extends H {
|
|
602
602
|
editor;
|
|
603
603
|
constructor(e) {
|
|
604
604
|
super(), this.editor = e, e.on("create", () => {
|
|
@@ -613,66 +613,96 @@ var rn = class {
|
|
|
613
613
|
editor: e,
|
|
614
614
|
transaction: t
|
|
615
615
|
});
|
|
616
|
+
}), e._tiptapEditor.on("focus", ({ event: t }) => {
|
|
617
|
+
this.emit("onFocusChange", {
|
|
618
|
+
editor: e,
|
|
619
|
+
focused: !0,
|
|
620
|
+
event: t
|
|
621
|
+
});
|
|
622
|
+
}), e._tiptapEditor.on("blur", ({ event: t }) => {
|
|
623
|
+
this.emit("onFocusChange", {
|
|
624
|
+
editor: e,
|
|
625
|
+
focused: !1,
|
|
626
|
+
event: t
|
|
627
|
+
});
|
|
616
628
|
}), e._tiptapEditor.on("mount", () => {
|
|
617
629
|
this.emit("onMount", { editor: e });
|
|
618
630
|
}), e._tiptapEditor.on("unmount", () => {
|
|
619
631
|
this.emit("onUnmount", { editor: e });
|
|
620
632
|
});
|
|
633
|
+
let t;
|
|
634
|
+
this.onMount(() => {
|
|
635
|
+
t = this.attachUIFocusTracker();
|
|
636
|
+
}), this.onUnmount(() => {
|
|
637
|
+
t && t();
|
|
638
|
+
});
|
|
621
639
|
});
|
|
622
640
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
641
|
+
attachUIFocusTracker() {
|
|
642
|
+
if (typeof document > "u") return () => {};
|
|
643
|
+
let e = this.editor.isFocused({ includeEditorUI: !0 }), t, n = (t) => {
|
|
644
|
+
let n = this.editor.isFocused({ includeEditorUI: !0 });
|
|
645
|
+
n !== e && (e = n, this.emit("onFocusChangeWithinUI", {
|
|
646
|
+
editor: this.editor,
|
|
647
|
+
focused: n,
|
|
648
|
+
event: t
|
|
649
|
+
}));
|
|
650
|
+
}, r = (e) => n(e), i = (e) => {
|
|
651
|
+
clearTimeout(t), t = setTimeout(() => n(e));
|
|
628
652
|
};
|
|
629
|
-
return
|
|
630
|
-
|
|
653
|
+
return document.addEventListener("focusin", r, !0), document.addEventListener("focusout", i, !0), () => {
|
|
654
|
+
clearTimeout(t), document.removeEventListener("focusin", r, !0), document.removeEventListener("focusout", i, !0);
|
|
631
655
|
};
|
|
632
656
|
}
|
|
657
|
+
onChange(e, t = !0) {
|
|
658
|
+
return this.on("onChange", ({ transaction: n, appendedTransactions: r }) => {
|
|
659
|
+
!t && sn(n) || e(this.editor, { getChanges() {
|
|
660
|
+
return we(n, r);
|
|
661
|
+
} });
|
|
662
|
+
});
|
|
663
|
+
}
|
|
633
664
|
onSelectionChange(e, t = !1) {
|
|
634
|
-
|
|
635
|
-
!t &&
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
665
|
+
return this.on("onSelectionChange", ({ transaction: n }) => {
|
|
666
|
+
!t && sn(n) || e(this.editor);
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
onFocusChange(e, t) {
|
|
670
|
+
return this.on(t?.includeEditorUI ? "onFocusChangeWithinUI" : "onFocusChange", ({ focused: t, event: n }) => e(this.editor, {
|
|
671
|
+
focused: t,
|
|
672
|
+
event: n
|
|
673
|
+
}));
|
|
640
674
|
}
|
|
641
675
|
onMount(e) {
|
|
642
|
-
return this.on("onMount", e)
|
|
643
|
-
this.off("onMount", e);
|
|
644
|
-
};
|
|
676
|
+
return this.on("onMount", e);
|
|
645
677
|
}
|
|
646
678
|
onUnmount(e) {
|
|
647
|
-
return this.on("onUnmount", e)
|
|
648
|
-
this.off("onUnmount", e);
|
|
649
|
-
};
|
|
679
|
+
return this.on("onUnmount", e);
|
|
650
680
|
}
|
|
651
681
|
};
|
|
652
|
-
function
|
|
682
|
+
function sn(e) {
|
|
653
683
|
return !!e.getMeta("y-sync$");
|
|
654
684
|
}
|
|
655
685
|
//#endregion
|
|
656
686
|
//#region src/api/parsers/html/util/nestedLists.ts
|
|
657
|
-
function
|
|
687
|
+
function cn(e) {
|
|
658
688
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
659
689
|
}
|
|
660
|
-
function
|
|
690
|
+
function ln(e) {
|
|
661
691
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
662
692
|
}
|
|
663
|
-
function
|
|
693
|
+
function un(e) {
|
|
664
694
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
665
|
-
let t =
|
|
695
|
+
let t = cn(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
|
|
666
696
|
e.remove(), r.forEach((e) => {
|
|
667
697
|
e.remove();
|
|
668
698
|
}), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
|
|
669
|
-
if (
|
|
699
|
+
if (ln(t)) return;
|
|
670
700
|
let n = document.createElement("li");
|
|
671
701
|
n.append(t), e.insertAdjacentElement("afterend", n);
|
|
672
702
|
}), n.childNodes.length === 0 && n.remove();
|
|
673
703
|
});
|
|
674
704
|
}
|
|
675
|
-
function
|
|
705
|
+
function dn(e) {
|
|
676
706
|
e.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
677
707
|
let t = e.previousElementSibling, n = document.createElement("div");
|
|
678
708
|
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
@@ -680,25 +710,25 @@ function un(e) {
|
|
|
680
710
|
for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
|
|
681
711
|
});
|
|
682
712
|
}
|
|
683
|
-
var
|
|
684
|
-
function
|
|
685
|
-
return
|
|
713
|
+
var fn = null;
|
|
714
|
+
function pn() {
|
|
715
|
+
return fn ||= document.implementation.createHTMLDocument("title");
|
|
686
716
|
}
|
|
687
|
-
function
|
|
717
|
+
function mn(e) {
|
|
688
718
|
if (typeof e == "string") {
|
|
689
|
-
let t =
|
|
719
|
+
let t = pn().createElement("div");
|
|
690
720
|
t.innerHTML = e, e = t;
|
|
691
721
|
}
|
|
692
|
-
return
|
|
722
|
+
return un(e), dn(e), e;
|
|
693
723
|
}
|
|
694
724
|
//#endregion
|
|
695
725
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
696
|
-
function
|
|
726
|
+
function hn(e) {
|
|
697
727
|
let t = e.ownerDocument.createTreeWalker(e, 128), n;
|
|
698
728
|
for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
|
|
699
729
|
return !1;
|
|
700
730
|
}
|
|
701
|
-
function
|
|
731
|
+
function gn(e) {
|
|
702
732
|
let t = /* @__PURE__ */ new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
703
733
|
let r = n.parentElement;
|
|
704
734
|
for (; r && r !== e;) {
|
|
@@ -710,12 +740,12 @@ function hn(e) {
|
|
|
710
740
|
for (; i = n.nextNode();) r.push(i);
|
|
711
741
|
for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
712
742
|
}
|
|
713
|
-
function
|
|
714
|
-
|
|
743
|
+
function _n(e) {
|
|
744
|
+
hn(e) || gn(e);
|
|
715
745
|
}
|
|
716
746
|
//#endregion
|
|
717
747
|
//#region src/api/parsers/html/parseHTML.ts
|
|
718
|
-
function
|
|
748
|
+
function vn(e) {
|
|
719
749
|
let t = [];
|
|
720
750
|
for (let n of e) if (n.type === "text") {
|
|
721
751
|
let e = n.text.split("").join("");
|
|
@@ -725,80 +755,80 @@ function _n(e) {
|
|
|
725
755
|
});
|
|
726
756
|
} else Array.isArray(n.content) ? t.push({
|
|
727
757
|
...n,
|
|
728
|
-
content:
|
|
758
|
+
content: vn(n.content)
|
|
729
759
|
}) : t.push(n);
|
|
730
760
|
return t;
|
|
731
761
|
}
|
|
732
|
-
function
|
|
733
|
-
for (let t of e) Array.isArray(t.content) && (t.content =
|
|
762
|
+
function yn(e) {
|
|
763
|
+
for (let t of e) Array.isArray(t.content) && (t.content = vn(t.content)), t.children.length > 0 && yn(t.children);
|
|
734
764
|
}
|
|
735
|
-
function
|
|
736
|
-
let n =
|
|
737
|
-
|
|
738
|
-
let r =
|
|
739
|
-
for (let e = 0; e < r.childCount; e++) i.push(
|
|
740
|
-
return
|
|
765
|
+
function G(e, t) {
|
|
766
|
+
let n = mn(e);
|
|
767
|
+
_n(n);
|
|
768
|
+
let r = ze.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
|
|
769
|
+
for (let e = 0; e < r.childCount; e++) i.push(C(r.child(e), r));
|
|
770
|
+
return yn(i), i;
|
|
741
771
|
}
|
|
742
772
|
//#endregion
|
|
743
773
|
//#region src/api/parsers/markdown/markdownToHtml.ts
|
|
744
|
-
function
|
|
774
|
+
function K(e) {
|
|
745
775
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
746
776
|
}
|
|
747
|
-
function
|
|
777
|
+
function bn(e) {
|
|
748
778
|
return e ? /\w/.test(e) : !1;
|
|
749
779
|
}
|
|
750
|
-
function
|
|
780
|
+
function q(e, t, n) {
|
|
751
781
|
let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
|
|
752
|
-
return
|
|
782
|
+
return bn(r) && bn(i);
|
|
753
783
|
}
|
|
754
|
-
function
|
|
784
|
+
function xn(e, t) {
|
|
755
785
|
if (e[t] !== "\\" || t + 1 >= e.length) return null;
|
|
756
786
|
let n = e[t + 1];
|
|
757
787
|
return n === "\n" ? {
|
|
758
788
|
html: "<br>\n",
|
|
759
789
|
end: t + 2
|
|
760
790
|
} : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
|
|
761
|
-
html:
|
|
791
|
+
html: K(n),
|
|
762
792
|
end: t + 2
|
|
763
793
|
} : null;
|
|
764
794
|
}
|
|
765
|
-
function xn(e, t) {
|
|
766
|
-
return e[t] === "`" ? Ln(e, t) : null;
|
|
767
|
-
}
|
|
768
795
|
function Sn(e, t) {
|
|
769
|
-
return e[t]
|
|
796
|
+
return e[t] === "`" ? Rn(e, t) : null;
|
|
770
797
|
}
|
|
771
798
|
function Cn(e, t) {
|
|
772
|
-
return e[t]
|
|
799
|
+
return e[t] !== "!" || e[t + 1] !== "[" ? null : zn(e, t);
|
|
773
800
|
}
|
|
774
801
|
function wn(e, t) {
|
|
775
|
-
return e[t]
|
|
802
|
+
return e[t] === "[" ? Bn(e, t) : null;
|
|
776
803
|
}
|
|
777
804
|
function Tn(e, t) {
|
|
778
|
-
return e[t]
|
|
805
|
+
return e[t] !== "~" || e[t + 1] !== "~" ? null : Y(e, t, "~~", "<del>", "</del>");
|
|
779
806
|
}
|
|
780
807
|
function En(e, t) {
|
|
781
|
-
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !
|
|
808
|
+
return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !q(e, t, 3) ? Y(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>") : null;
|
|
782
809
|
}
|
|
783
810
|
function Dn(e, t) {
|
|
784
|
-
return e[t] === "*" || e[t] === "_" && !
|
|
811
|
+
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !q(e, t, 2) ? Y(e, t, e.substring(t, t + 2), "<strong>", "</strong>") : null;
|
|
785
812
|
}
|
|
786
813
|
function On(e, t) {
|
|
814
|
+
return e[t] === "*" || e[t] === "_" && !q(e, t, 1) ? Y(e, t, e[t], "<em>", "</em>") : null;
|
|
815
|
+
}
|
|
816
|
+
function kn(e, t) {
|
|
787
817
|
return e[t] === "\n" ? {
|
|
788
818
|
html: "<br>\n",
|
|
789
819
|
end: t + 1
|
|
790
820
|
} : null;
|
|
791
821
|
}
|
|
792
|
-
var
|
|
793
|
-
function
|
|
822
|
+
var An = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, jn = /^<!--[\s\S]*?-->/, Mn = /^<!\[CDATA\[[\s\S]*?\]\]>/, Nn = /^<\?[\s\S]*?\?>/, Pn = /^<![A-Za-z][\s\S]*?>/;
|
|
823
|
+
function Fn(e, t) {
|
|
794
824
|
if (e[t] !== "<") return null;
|
|
795
825
|
let n = e.substring(t);
|
|
796
826
|
for (let e of [
|
|
797
|
-
An,
|
|
798
827
|
jn,
|
|
799
828
|
Mn,
|
|
800
829
|
Nn,
|
|
801
|
-
|
|
830
|
+
Pn,
|
|
831
|
+
An
|
|
802
832
|
]) {
|
|
803
833
|
let r = n.match(e);
|
|
804
834
|
if (r) return {
|
|
@@ -808,8 +838,7 @@ function Pn(e, t) {
|
|
|
808
838
|
}
|
|
809
839
|
return null;
|
|
810
840
|
}
|
|
811
|
-
var
|
|
812
|
-
bn,
|
|
841
|
+
var In = /* @__PURE__ */ new Set("\\`![~*_\n<"), Ln = [
|
|
813
842
|
xn,
|
|
814
843
|
Sn,
|
|
815
844
|
Cn,
|
|
@@ -817,10 +846,11 @@ var Fn = /* @__PURE__ */ new Set("\\`![~*_\n<"), In = [
|
|
|
817
846
|
Tn,
|
|
818
847
|
En,
|
|
819
848
|
Dn,
|
|
820
|
-
|
|
821
|
-
|
|
849
|
+
On,
|
|
850
|
+
Fn,
|
|
851
|
+
kn
|
|
822
852
|
];
|
|
823
|
-
function
|
|
853
|
+
function J(e) {
|
|
824
854
|
let t = "", n = 0;
|
|
825
855
|
for (; n < e.length;) {
|
|
826
856
|
if (e[n] === "\n" && n >= 2 && e[n - 1] === " " && e[n - 2] === " ") {
|
|
@@ -828,7 +858,7 @@ function Y(e) {
|
|
|
828
858
|
continue;
|
|
829
859
|
}
|
|
830
860
|
let r = !1;
|
|
831
|
-
if (
|
|
861
|
+
if (In.has(e[n])) for (let i of Ln) {
|
|
832
862
|
let a = i(e, n);
|
|
833
863
|
if (a) {
|
|
834
864
|
t += a.html, n = a.end, r = !0;
|
|
@@ -837,13 +867,13 @@ function Y(e) {
|
|
|
837
867
|
}
|
|
838
868
|
if (!r) {
|
|
839
869
|
let r = n;
|
|
840
|
-
for (n++; n < e.length && !
|
|
841
|
-
t +=
|
|
870
|
+
for (n++; n < e.length && !In.has(e[n]);) n++;
|
|
871
|
+
t += K(e.substring(r, n));
|
|
842
872
|
}
|
|
843
873
|
}
|
|
844
874
|
return t;
|
|
845
875
|
}
|
|
846
|
-
function
|
|
876
|
+
function Rn(e, t) {
|
|
847
877
|
let n = 0, r = t;
|
|
848
878
|
for (; r < e.length && e[r] === "`";) n++, r++;
|
|
849
879
|
let i = r;
|
|
@@ -853,46 +883,46 @@ function Ln(e, t) {
|
|
|
853
883
|
if (t === n) {
|
|
854
884
|
let t = e.substring(r, a);
|
|
855
885
|
return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t[t.length - 1] === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
|
|
856
|
-
html: `<code>${
|
|
886
|
+
html: `<code>${K(t)}</code>`,
|
|
857
887
|
end: i
|
|
858
888
|
};
|
|
859
889
|
}
|
|
860
890
|
} else i++;
|
|
861
891
|
return null;
|
|
862
892
|
}
|
|
863
|
-
function
|
|
864
|
-
let n =
|
|
893
|
+
function zn(e, t) {
|
|
894
|
+
let n = Vn(e, t + 1);
|
|
865
895
|
if (n === -1) return null;
|
|
866
896
|
let r = t + 2;
|
|
867
897
|
if (e[n + 1] !== "(") return null;
|
|
868
|
-
let i = n + 2, a =
|
|
898
|
+
let i = n + 2, a = Hn(e, i - 1);
|
|
869
899
|
if (a === -1) return null;
|
|
870
|
-
let o = e.substring(r, n), { url: s, title: c } =
|
|
871
|
-
if (
|
|
900
|
+
let o = e.substring(r, n), { url: s, title: c } = Un(e.substring(i, a));
|
|
901
|
+
if (ne(s)) {
|
|
872
902
|
let e = o || c;
|
|
873
903
|
return {
|
|
874
|
-
html: `<video src="${
|
|
904
|
+
html: `<video src="${K(s)}"${e ? ` data-name="${K(e)}"` : ""} data-url="${K(s)}" controls></video>`,
|
|
875
905
|
end: a + 1
|
|
876
906
|
};
|
|
877
907
|
}
|
|
878
|
-
let l = c === void 0 ? "" : ` title="${
|
|
908
|
+
let l = c === void 0 ? "" : ` title="${K(c)}"`;
|
|
879
909
|
return {
|
|
880
|
-
html: `<img src="${
|
|
910
|
+
html: `<img src="${K(s)}" alt="${K(o)}"${l}>`,
|
|
881
911
|
end: a + 1
|
|
882
912
|
};
|
|
883
913
|
}
|
|
884
|
-
function
|
|
885
|
-
let n = t + 1, r =
|
|
914
|
+
function Bn(e, t) {
|
|
915
|
+
let n = t + 1, r = Vn(e, t);
|
|
886
916
|
if (r === -1 || e[r + 1] !== "(") return null;
|
|
887
|
-
let i = r + 2, a =
|
|
917
|
+
let i = r + 2, a = Hn(e, r + 1);
|
|
888
918
|
if (a === -1) return null;
|
|
889
|
-
let o = e.substring(n, r), { url: s, title: c } =
|
|
919
|
+
let o = e.substring(n, r), { url: s, title: c } = Un(e.substring(i, a)), l = c === void 0 ? "" : ` title="${K(c)}"`;
|
|
890
920
|
return {
|
|
891
|
-
html: `<a href="${
|
|
921
|
+
html: `<a href="${K(s)}"${l}>${J(o)}</a>`,
|
|
892
922
|
end: a + 1
|
|
893
923
|
};
|
|
894
924
|
}
|
|
895
|
-
function
|
|
925
|
+
function Vn(e, t) {
|
|
896
926
|
let n = 0;
|
|
897
927
|
for (let r = t; r < e.length; r++) {
|
|
898
928
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -903,7 +933,7 @@ function Bn(e, t) {
|
|
|
903
933
|
}
|
|
904
934
|
return -1;
|
|
905
935
|
}
|
|
906
|
-
function
|
|
936
|
+
function Hn(e, t) {
|
|
907
937
|
let n = 0;
|
|
908
938
|
for (let r = t; r < e.length; r++) {
|
|
909
939
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -914,7 +944,7 @@ function Vn(e, t) {
|
|
|
914
944
|
}
|
|
915
945
|
return -1;
|
|
916
946
|
}
|
|
917
|
-
function
|
|
947
|
+
function Un(e) {
|
|
918
948
|
e = e.trim();
|
|
919
949
|
let t, n;
|
|
920
950
|
if (e.startsWith("<")) {
|
|
@@ -944,7 +974,7 @@ function Hn(e) {
|
|
|
944
974
|
title: r
|
|
945
975
|
};
|
|
946
976
|
}
|
|
947
|
-
function
|
|
977
|
+
function Y(e, t, n, r, i) {
|
|
948
978
|
let a = n.length, o = t + a;
|
|
949
979
|
if (o >= e.length || e[o] === " " || e[o] === " ") return null;
|
|
950
980
|
let s = o;
|
|
@@ -968,7 +998,7 @@ function X(e, t, n, r, i) {
|
|
|
968
998
|
continue;
|
|
969
999
|
}
|
|
970
1000
|
return {
|
|
971
|
-
html: r +
|
|
1001
|
+
html: r + J(t) + i,
|
|
972
1002
|
end: s + a
|
|
973
1003
|
};
|
|
974
1004
|
}
|
|
@@ -976,13 +1006,13 @@ function X(e, t, n, r, i) {
|
|
|
976
1006
|
}
|
|
977
1007
|
return null;
|
|
978
1008
|
}
|
|
979
|
-
var
|
|
980
|
-
function
|
|
1009
|
+
var Wn = /* @__PURE__ */ 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("."));
|
|
1010
|
+
function Gn(e) {
|
|
981
1011
|
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
|
|
982
1012
|
let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
983
|
-
return t ?
|
|
1013
|
+
return t ? Wn.has(t[1].toLowerCase()) : !1;
|
|
984
1014
|
}
|
|
985
|
-
function
|
|
1015
|
+
function Kn(e) {
|
|
986
1016
|
let t = e.split("\n"), n = [], r = 0, i = !0;
|
|
987
1017
|
for (; r < t.length;) {
|
|
988
1018
|
let e = t[r];
|
|
@@ -1041,7 +1071,7 @@ function Gn(e) {
|
|
|
1041
1071
|
continue;
|
|
1042
1072
|
}
|
|
1043
1073
|
}
|
|
1044
|
-
let s =
|
|
1074
|
+
let s = qn(t, r);
|
|
1045
1075
|
if (s) {
|
|
1046
1076
|
n.push(s.token), r = s.nextLine, i = !1;
|
|
1047
1077
|
continue;
|
|
@@ -1097,7 +1127,7 @@ function Gn(e) {
|
|
|
1097
1127
|
}), i = !1;
|
|
1098
1128
|
continue;
|
|
1099
1129
|
}
|
|
1100
|
-
if (
|
|
1130
|
+
if (Gn(e)) {
|
|
1101
1131
|
let e = [];
|
|
1102
1132
|
for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
|
|
1103
1133
|
n.push({
|
|
@@ -1109,7 +1139,7 @@ function Gn(e) {
|
|
|
1109
1139
|
let l = [e];
|
|
1110
1140
|
for (r++; r < t.length;) {
|
|
1111
1141
|
let e = t[r];
|
|
1112
|
-
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) ||
|
|
1142
|
+
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) || Gn(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
|
|
1113
1143
|
l.push(e), r++;
|
|
1114
1144
|
}
|
|
1115
1145
|
n.push({
|
|
@@ -1119,15 +1149,15 @@ function Gn(e) {
|
|
|
1119
1149
|
}
|
|
1120
1150
|
return n;
|
|
1121
1151
|
}
|
|
1122
|
-
function
|
|
1152
|
+
function qn(e, t) {
|
|
1123
1153
|
if (t + 1 >= e.length) return null;
|
|
1124
1154
|
let n = e[t], r = e[t + 1];
|
|
1125
1155
|
if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
|
|
1126
|
-
let i =
|
|
1156
|
+
let i = Jn(n), a = Yn(r), o = [], s = t + 2;
|
|
1127
1157
|
for (; s < e.length;) {
|
|
1128
1158
|
let t = e[s];
|
|
1129
1159
|
if (!t.includes("|")) break;
|
|
1130
|
-
o.push(
|
|
1160
|
+
o.push(Jn(t)), s++;
|
|
1131
1161
|
}
|
|
1132
1162
|
return {
|
|
1133
1163
|
token: {
|
|
@@ -1139,37 +1169,37 @@ function Kn(e, t) {
|
|
|
1139
1169
|
nextLine: s
|
|
1140
1170
|
};
|
|
1141
1171
|
}
|
|
1142
|
-
function
|
|
1172
|
+
function Jn(e) {
|
|
1143
1173
|
let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
|
|
1144
1174
|
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];
|
|
1145
1175
|
return i.push(a.trim()), i;
|
|
1146
1176
|
}
|
|
1147
|
-
function
|
|
1148
|
-
return
|
|
1177
|
+
function Yn(e) {
|
|
1178
|
+
return Jn(e).map((e) => {
|
|
1149
1179
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
1150
1180
|
return n && r ? "center" : r ? "right" : n ? "left" : null;
|
|
1151
1181
|
});
|
|
1152
1182
|
}
|
|
1153
|
-
function
|
|
1183
|
+
function Xn(e) {
|
|
1154
1184
|
let t = "", n = 0;
|
|
1155
1185
|
for (; n < e.length;) {
|
|
1156
1186
|
let r = e[n];
|
|
1157
1187
|
switch (r.type) {
|
|
1158
1188
|
case "heading": {
|
|
1159
1189
|
let e = r;
|
|
1160
|
-
t += `<h${e.level}>${
|
|
1190
|
+
t += `<h${e.level}>${J(e.content)}</h${e.level}>`, n++;
|
|
1161
1191
|
break;
|
|
1162
1192
|
}
|
|
1163
1193
|
case "paragraph":
|
|
1164
|
-
t += `<p>${
|
|
1194
|
+
t += `<p>${J(r.content)}</p>`, n++;
|
|
1165
1195
|
break;
|
|
1166
1196
|
case "codeBlock": {
|
|
1167
|
-
let e = r, i = e.language ? ` data-language="${
|
|
1168
|
-
t += `<pre><code${i}>${
|
|
1197
|
+
let e = r, i = e.language ? ` data-language="${K(e.language)}"` : "";
|
|
1198
|
+
t += `<pre><code${i}>${K(e.code)}</code></pre>`, n++;
|
|
1169
1199
|
break;
|
|
1170
1200
|
}
|
|
1171
1201
|
case "blockquote": {
|
|
1172
|
-
let e =
|
|
1202
|
+
let e = Xn(Kn(r.content));
|
|
1173
1203
|
t += `<blockquote>${e}</blockquote>`, n++;
|
|
1174
1204
|
break;
|
|
1175
1205
|
}
|
|
@@ -1177,12 +1207,12 @@ function Yn(e) {
|
|
|
1177
1207
|
t += "<hr>", n++;
|
|
1178
1208
|
break;
|
|
1179
1209
|
case "listItem": {
|
|
1180
|
-
let r =
|
|
1210
|
+
let r = Zn(e, n);
|
|
1181
1211
|
t += r.html, n = r.nextIndex;
|
|
1182
1212
|
break;
|
|
1183
1213
|
}
|
|
1184
1214
|
case "table":
|
|
1185
|
-
t +=
|
|
1215
|
+
t += $n(r), n++;
|
|
1186
1216
|
break;
|
|
1187
1217
|
case "rawHtml":
|
|
1188
1218
|
t += r.content, n++;
|
|
@@ -1192,10 +1222,10 @@ function Yn(e) {
|
|
|
1192
1222
|
}
|
|
1193
1223
|
return t;
|
|
1194
1224
|
}
|
|
1195
|
-
function
|
|
1225
|
+
function Zn(e, t) {
|
|
1196
1226
|
let n = "", r = t, i = null;
|
|
1197
1227
|
for (; r < e.length && e[r].type === "listItem";) {
|
|
1198
|
-
let t = e[r], a =
|
|
1228
|
+
let t = e[r], a = Qn(t.listType);
|
|
1199
1229
|
if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
|
|
1200
1230
|
if (a === "ordered") {
|
|
1201
1231
|
let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
|
|
@@ -1205,11 +1235,11 @@ function Xn(e, t) {
|
|
|
1205
1235
|
}
|
|
1206
1236
|
if (t.listType === "task") {
|
|
1207
1237
|
let e = t.checked ? " checked" : "";
|
|
1208
|
-
n += `<li><input type="checkbox" disabled${e}><p>${
|
|
1209
|
-
} else n += `<li><p>${
|
|
1238
|
+
n += `<li><input type="checkbox" disabled${e}><p>${J(t.content)}</p>`;
|
|
1239
|
+
} else n += `<li><p>${J(t.content)}</p>`;
|
|
1210
1240
|
if (t.childContent) {
|
|
1211
|
-
let e =
|
|
1212
|
-
n +=
|
|
1241
|
+
let e = Kn(t.childContent);
|
|
1242
|
+
n += Xn(e);
|
|
1213
1243
|
}
|
|
1214
1244
|
n += "</li>", r++;
|
|
1215
1245
|
}
|
|
@@ -1218,16 +1248,16 @@ function Xn(e, t) {
|
|
|
1218
1248
|
nextIndex: r
|
|
1219
1249
|
};
|
|
1220
1250
|
}
|
|
1221
|
-
function
|
|
1251
|
+
function Qn(e) {
|
|
1222
1252
|
return e === "ordered" ? "ordered" : "bullet";
|
|
1223
1253
|
}
|
|
1224
|
-
function
|
|
1254
|
+
function $n(e) {
|
|
1225
1255
|
let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
|
|
1226
1256
|
if (!n) {
|
|
1227
1257
|
t += "<thead><tr>";
|
|
1228
1258
|
for (let n = 0; n < r; n++) {
|
|
1229
1259
|
let r = e.alignments[n], i = r ? ` align="${r}"` : "";
|
|
1230
|
-
t += `<th${i}>${
|
|
1260
|
+
t += `<th${i}>${J(e.headers[n])}</th>`;
|
|
1231
1261
|
}
|
|
1232
1262
|
t += "</tr></thead>";
|
|
1233
1263
|
}
|
|
@@ -1237,7 +1267,7 @@ function Qn(e) {
|
|
|
1237
1267
|
t += "<tr>";
|
|
1238
1268
|
for (let i = 0; i < r; i++) {
|
|
1239
1269
|
let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
|
|
1240
|
-
t += `<td${o}>${
|
|
1270
|
+
t += `<td${o}>${J(r)}</td>`;
|
|
1241
1271
|
}
|
|
1242
1272
|
t += "</tr>";
|
|
1243
1273
|
}
|
|
@@ -1245,38 +1275,38 @@ function Qn(e) {
|
|
|
1245
1275
|
}
|
|
1246
1276
|
return t += "</table>", t;
|
|
1247
1277
|
}
|
|
1248
|
-
function
|
|
1249
|
-
return
|
|
1278
|
+
function er(e) {
|
|
1279
|
+
return Xn(Kn(e));
|
|
1250
1280
|
}
|
|
1251
1281
|
//#endregion
|
|
1252
1282
|
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
1253
|
-
function
|
|
1254
|
-
return
|
|
1283
|
+
function tr(e) {
|
|
1284
|
+
return er(e);
|
|
1255
1285
|
}
|
|
1256
|
-
function
|
|
1257
|
-
return
|
|
1286
|
+
function nr(e, t) {
|
|
1287
|
+
return G(tr(e), t);
|
|
1258
1288
|
}
|
|
1259
1289
|
//#endregion
|
|
1260
1290
|
//#region src/editor/managers/ExportManager.ts
|
|
1261
|
-
var
|
|
1291
|
+
var rr = class {
|
|
1262
1292
|
editor;
|
|
1263
1293
|
constructor(e) {
|
|
1264
1294
|
this.editor = e;
|
|
1265
1295
|
}
|
|
1266
1296
|
blocksToHTMLLossy(e = this.editor.document) {
|
|
1267
|
-
return
|
|
1297
|
+
return be(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
1268
1298
|
}
|
|
1269
1299
|
blocksToFullHTML(e = this.editor.document) {
|
|
1270
|
-
return
|
|
1300
|
+
return Nt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
1271
1301
|
}
|
|
1272
1302
|
tryParseHTMLToBlocks(e) {
|
|
1273
|
-
return
|
|
1303
|
+
return G(e, this.editor.pmSchema);
|
|
1274
1304
|
}
|
|
1275
1305
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
1276
|
-
return
|
|
1306
|
+
return De(e, this.editor.pmSchema, this.editor, {});
|
|
1277
1307
|
}
|
|
1278
1308
|
tryParseMarkdownToBlocks(e) {
|
|
1279
|
-
return
|
|
1309
|
+
return nr(e, this.editor.pmSchema);
|
|
1280
1310
|
}
|
|
1281
1311
|
pasteHTML(e, t = !1) {
|
|
1282
1312
|
let n = e;
|
|
@@ -1290,42 +1320,42 @@ var nr = class {
|
|
|
1290
1320
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
1291
1321
|
}
|
|
1292
1322
|
pasteMarkdown(e) {
|
|
1293
|
-
let t =
|
|
1323
|
+
let t = tr(e);
|
|
1294
1324
|
return this.pasteHTML(t);
|
|
1295
1325
|
}
|
|
1296
1326
|
};
|
|
1297
1327
|
//#endregion
|
|
1298
1328
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1299
|
-
function
|
|
1300
|
-
let { bnBlock: t } =
|
|
1329
|
+
function ir(e) {
|
|
1330
|
+
let { bnBlock: t } = v(e), n = e.doc.resolve(t.beforePos), r = n.nodeBefore, i = e.doc.resolve(t.afterPos).nodeAfter, a;
|
|
1301
1331
|
return n.depth > 1 && (a = n.node(), a.type.isInGroup("bnBlock") || (a = n.node(n.depth - 1))), {
|
|
1302
|
-
block:
|
|
1303
|
-
prevBlock: r === null ? void 0 :
|
|
1304
|
-
nextBlock: i === null ? void 0 :
|
|
1305
|
-
parentBlock: a === void 0 ? void 0 :
|
|
1332
|
+
block: C(t.node, e.doc),
|
|
1333
|
+
prevBlock: r === null ? void 0 : C(r, e.doc),
|
|
1334
|
+
nextBlock: i === null ? void 0 : C(i, e.doc),
|
|
1335
|
+
parentBlock: a === void 0 ? void 0 : C(a, e.doc)
|
|
1306
1336
|
};
|
|
1307
1337
|
}
|
|
1308
|
-
function
|
|
1309
|
-
let
|
|
1310
|
-
if (!
|
|
1311
|
-
let
|
|
1312
|
-
if (
|
|
1313
|
-
let
|
|
1314
|
-
if (
|
|
1315
|
-
|
|
1338
|
+
function ar(e, t, n = "start") {
|
|
1339
|
+
let r = typeof t == "string" ? t : t.id, i = y(e.doc), a = u(i), o = c(r, e.doc);
|
|
1340
|
+
if (!o) throw Error(`Block with ID ${r} not found`);
|
|
1341
|
+
let s = S(o), l = a.blockSchema[s.blockNoteType].content;
|
|
1342
|
+
if (s.isBlockContainer) {
|
|
1343
|
+
let t = s.blockContent;
|
|
1344
|
+
if (l === "none") {
|
|
1345
|
+
e.setSelection(j.create(e.doc, t.beforePos));
|
|
1316
1346
|
return;
|
|
1317
1347
|
}
|
|
1318
|
-
if (
|
|
1319
|
-
else if (
|
|
1320
|
-
else throw new
|
|
1348
|
+
if (l === "inline" || l === "plain") n === "start" ? e.setSelection(N.create(e.doc, t.beforePos + 1)) : e.setSelection(N.create(e.doc, t.afterPos - 1));
|
|
1349
|
+
else if (l === "table") n === "start" ? e.setSelection(N.create(e.doc, t.beforePos + 4)) : e.setSelection(N.create(e.doc, t.afterPos - 4));
|
|
1350
|
+
else throw new _(l);
|
|
1321
1351
|
} else {
|
|
1322
|
-
let
|
|
1323
|
-
|
|
1352
|
+
let t = n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild;
|
|
1353
|
+
ar(e, x(t, e.doc), n);
|
|
1324
1354
|
}
|
|
1325
1355
|
}
|
|
1326
1356
|
//#endregion
|
|
1327
1357
|
//#region src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
|
|
1328
|
-
var
|
|
1358
|
+
var or = [
|
|
1329
1359
|
"vscode-editor-data",
|
|
1330
1360
|
"blocknote/html",
|
|
1331
1361
|
"text/markdown",
|
|
@@ -1335,21 +1365,21 @@ var ar = [
|
|
|
1335
1365
|
];
|
|
1336
1366
|
//#endregion
|
|
1337
1367
|
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
1338
|
-
function
|
|
1368
|
+
function sr(e, t) {
|
|
1339
1369
|
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
1340
1370
|
return e === t;
|
|
1341
1371
|
}
|
|
1342
|
-
function
|
|
1372
|
+
function cr(e, t) {
|
|
1343
1373
|
let n = e.split("/"), r = t.split("/");
|
|
1344
1374
|
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
1345
1375
|
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
1346
1376
|
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
1347
1377
|
}
|
|
1348
|
-
function
|
|
1378
|
+
function lr(e, t, n, r = "after") {
|
|
1349
1379
|
let i;
|
|
1350
1380
|
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
1351
1381
|
}
|
|
1352
|
-
async function
|
|
1382
|
+
async function ur(e, t) {
|
|
1353
1383
|
if (!t.uploadFile) {
|
|
1354
1384
|
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
1355
1385
|
return;
|
|
@@ -1357,7 +1387,7 @@ async function lr(e, t) {
|
|
|
1357
1387
|
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
1358
1388
|
if (n === null) return;
|
|
1359
1389
|
let r = null;
|
|
1360
|
-
for (let e of
|
|
1390
|
+
for (let e of or) if (n.types.includes(e)) {
|
|
1361
1391
|
r = e;
|
|
1362
1392
|
break;
|
|
1363
1393
|
}
|
|
@@ -1369,7 +1399,7 @@ async function lr(e, t) {
|
|
|
1369
1399
|
let r = "file";
|
|
1370
1400
|
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
1371
1401
|
let a = t.startsWith("."), o = i[n].getAsFile();
|
|
1372
|
-
if (o && (!a && o.type &&
|
|
1402
|
+
if (o && (!a && o.type && cr(i[n].type, t) || a && sr("." + o.name.split(".").pop(), t))) {
|
|
1373
1403
|
r = e.config.type;
|
|
1374
1404
|
break;
|
|
1375
1405
|
}
|
|
@@ -1382,7 +1412,7 @@ async function lr(e, t) {
|
|
|
1382
1412
|
}, i;
|
|
1383
1413
|
if (e.type === "paste") {
|
|
1384
1414
|
let e = t.getTextCursorPosition().block;
|
|
1385
|
-
i =
|
|
1415
|
+
i = lr(t, e, n);
|
|
1386
1416
|
} else if (e.type === "drop") {
|
|
1387
1417
|
let r = {
|
|
1388
1418
|
left: e.clientX,
|
|
@@ -1390,8 +1420,8 @@ async function lr(e, t) {
|
|
|
1390
1420
|
}, a = t.prosemirrorView.posAtCoords(r);
|
|
1391
1421
|
if (!a) return;
|
|
1392
1422
|
i = t.transact((e) => {
|
|
1393
|
-
let i =
|
|
1394
|
-
if (c) return
|
|
1423
|
+
let i = ue(e, a.pos), o = x(i.bnBlock.node, e.doc), s = (t.domElement?.querySelector(`[data-id="${o}"]`))?.getBoundingClientRect(), c = t.getBlock(o);
|
|
1424
|
+
if (c) return lr(t, c, n, s && (s.top + s.bottom) / 2 > r.top ? "before" : "after");
|
|
1395
1425
|
});
|
|
1396
1426
|
} else return;
|
|
1397
1427
|
if (!i) return;
|
|
@@ -1403,23 +1433,23 @@ async function lr(e, t) {
|
|
|
1403
1433
|
}
|
|
1404
1434
|
//#endregion
|
|
1405
1435
|
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
1406
|
-
var
|
|
1436
|
+
var dr = (e) => D.create({
|
|
1407
1437
|
name: "dropFile",
|
|
1408
1438
|
addProseMirrorPlugins() {
|
|
1409
|
-
return [new
|
|
1439
|
+
return [new M({ props: { handleDOMEvents: { drop(t, n) {
|
|
1410
1440
|
if (!e.isEditable) return;
|
|
1411
1441
|
let r = null;
|
|
1412
|
-
for (let e of
|
|
1442
|
+
for (let e of or) if (n.dataTransfer.types.includes(e)) {
|
|
1413
1443
|
r = e;
|
|
1414
1444
|
break;
|
|
1415
1445
|
}
|
|
1416
|
-
return r === null || r === "Files" && (
|
|
1446
|
+
return r === null || r === "Files" && (ur(n, e), !0);
|
|
1417
1447
|
} } } })];
|
|
1418
1448
|
}
|
|
1419
|
-
}),
|
|
1449
|
+
}), fr = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, pr = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, mr = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, hr = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, gr = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, _r = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, vr = /\n{2} {0,3}-{2,48}\n{2}/, yr = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, br = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, xr = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, Sr = /^\s*\|(.+\|)+\s*$/m, Cr = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, wr = /^\s*\|(.+\|)+\s*$/m, Tr = (e) => fr.test(e) || pr.test(e) || mr.test(e) || hr.test(e) || gr.test(e) || _r.test(e) || vr.test(e) || yr.test(e) || br.test(e) || xr.test(e) || Sr.test(e) || Cr.test(e) || wr.test(e);
|
|
1420
1450
|
//#endregion
|
|
1421
1451
|
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
1422
|
-
function
|
|
1452
|
+
function Er(e, t) {
|
|
1423
1453
|
let { schema: n } = t.state;
|
|
1424
1454
|
if (!e.clipboardData) return !1;
|
|
1425
1455
|
let r = e.clipboardData.getData("text/plain");
|
|
@@ -1429,39 +1459,39 @@ function Tr(e, t) {
|
|
|
1429
1459
|
}
|
|
1430
1460
|
//#endregion
|
|
1431
1461
|
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
1432
|
-
function
|
|
1462
|
+
function Dr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
1433
1463
|
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
1434
1464
|
let n = e.clipboardData?.getData("text/plain");
|
|
1435
1465
|
if (n) return t.pasteText(n), !0;
|
|
1436
1466
|
}
|
|
1437
1467
|
let i;
|
|
1438
|
-
for (let t of
|
|
1468
|
+
for (let t of or) if (e.clipboardData.types.includes(t)) {
|
|
1439
1469
|
i = t;
|
|
1440
1470
|
break;
|
|
1441
1471
|
}
|
|
1442
1472
|
if (!i) return !0;
|
|
1443
1473
|
if (i === "vscode-editor-data") {
|
|
1444
|
-
if (
|
|
1474
|
+
if (Er(e, t.prosemirrorView)) return !0;
|
|
1445
1475
|
i = "text/plain";
|
|
1446
1476
|
}
|
|
1447
|
-
if (i === "Files") return
|
|
1477
|
+
if (i === "Files") return ur(e, t), !0;
|
|
1448
1478
|
let a = e.clipboardData.getData(i);
|
|
1449
1479
|
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
1450
1480
|
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
1451
1481
|
if (n) {
|
|
1452
1482
|
let n = e.clipboardData.getData("text/plain");
|
|
1453
|
-
if (
|
|
1483
|
+
if (Tr(n)) return t.pasteMarkdown(n), !0;
|
|
1454
1484
|
}
|
|
1455
1485
|
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
1456
1486
|
}
|
|
1457
|
-
var
|
|
1487
|
+
var Or = (e, t) => D.create({
|
|
1458
1488
|
name: "pasteFromClipboard",
|
|
1459
1489
|
addProseMirrorPlugins() {
|
|
1460
|
-
return [new
|
|
1490
|
+
return [new M({ props: { handleDOMEvents: { paste(n, r) {
|
|
1461
1491
|
if (r.preventDefault(), e.isEditable) return t({
|
|
1462
1492
|
event: r,
|
|
1463
1493
|
editor: e,
|
|
1464
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) =>
|
|
1494
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Dr({
|
|
1465
1495
|
event: r,
|
|
1466
1496
|
editor: e,
|
|
1467
1497
|
prioritizeMarkdownOverHTML: t,
|
|
@@ -1473,37 +1503,37 @@ var Dr = (e, t) => k.create({
|
|
|
1473
1503
|
});
|
|
1474
1504
|
//#endregion
|
|
1475
1505
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1476
|
-
function
|
|
1477
|
-
let r = !1, i = e.state.selection instanceof
|
|
1506
|
+
function kr(e, t, n) {
|
|
1507
|
+
let r = !1, i = e.state.selection instanceof I;
|
|
1478
1508
|
if (!i) {
|
|
1479
1509
|
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
1480
1510
|
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
1481
1511
|
r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
|
|
1482
1512
|
}
|
|
1483
|
-
let a, o =
|
|
1513
|
+
let a, o = be(e.state.schema, n);
|
|
1484
1514
|
if (i) {
|
|
1485
1515
|
t.firstChild?.type.name === "table" && (t = t.firstChild.content);
|
|
1486
|
-
let e =
|
|
1516
|
+
let e = f(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1487
1517
|
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
1488
1518
|
} else if (r) {
|
|
1489
|
-
let e =
|
|
1519
|
+
let e = me(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1490
1520
|
a = o.exportInlineContent(e, {});
|
|
1491
1521
|
} else {
|
|
1492
|
-
let e =
|
|
1522
|
+
let e = Ie(t);
|
|
1493
1523
|
a = o.exportBlocks(e, {});
|
|
1494
1524
|
}
|
|
1495
1525
|
return a;
|
|
1496
1526
|
}
|
|
1497
|
-
function
|
|
1498
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new
|
|
1499
|
-
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i =
|
|
1527
|
+
function Ar(e, t) {
|
|
1528
|
+
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new j(t.doc.resolve(e.state.selection.from - 1))));
|
|
1529
|
+
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = kr(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.blockImplementations[s];
|
|
1500
1530
|
return {
|
|
1501
1531
|
clipboardHTML: n,
|
|
1502
1532
|
externalHTML: i,
|
|
1503
|
-
markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) :
|
|
1533
|
+
markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) : Fe(i)
|
|
1504
1534
|
};
|
|
1505
1535
|
}
|
|
1506
|
-
var
|
|
1536
|
+
var jr = (e) => {
|
|
1507
1537
|
if (e.state.selection.empty) return !0;
|
|
1508
1538
|
let t = window.getSelection();
|
|
1509
1539
|
if (t && !t.isCollapsed) {
|
|
@@ -1514,37 +1544,37 @@ var Ar = (e) => {
|
|
|
1514
1544
|
}
|
|
1515
1545
|
}
|
|
1516
1546
|
return !1;
|
|
1517
|
-
},
|
|
1547
|
+
}, Mr = (e, t, n) => {
|
|
1518
1548
|
n.preventDefault(), n.clipboardData.clearData();
|
|
1519
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1549
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = Ar(t, e);
|
|
1520
1550
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
1521
|
-
},
|
|
1551
|
+
}, Nr = (e) => D.create({
|
|
1522
1552
|
name: "copyToClipboard",
|
|
1523
1553
|
addProseMirrorPlugins() {
|
|
1524
|
-
return [new
|
|
1554
|
+
return [new M({ props: { handleDOMEvents: {
|
|
1525
1555
|
copy(t, n) {
|
|
1526
|
-
return
|
|
1556
|
+
return jr(t) || Mr(e, t, n), !0;
|
|
1527
1557
|
},
|
|
1528
1558
|
cut(t, n) {
|
|
1529
|
-
return
|
|
1559
|
+
return jr(t) ? !0 : (Mr(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
1530
1560
|
},
|
|
1531
1561
|
dragstart(t, n) {
|
|
1532
1562
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
1533
|
-
e.transact((e) => e.setSelection(new
|
|
1534
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1563
|
+
e.transact((e) => e.setSelection(new j(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
1564
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = Ar(t, e);
|
|
1535
1565
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
1536
1566
|
}
|
|
1537
1567
|
} } })];
|
|
1538
1568
|
}
|
|
1539
|
-
}),
|
|
1569
|
+
}), Pr = D.create({
|
|
1540
1570
|
name: "blockBackgroundColor",
|
|
1541
1571
|
addGlobalAttributes() {
|
|
1542
1572
|
return [{
|
|
1543
1573
|
types: ["tableCell", "tableHeader"],
|
|
1544
|
-
attributes: { backgroundColor:
|
|
1574
|
+
attributes: { backgroundColor: n() }
|
|
1545
1575
|
}];
|
|
1546
1576
|
}
|
|
1547
|
-
}),
|
|
1577
|
+
}), Fr = O.create({
|
|
1548
1578
|
name: "hardBreak",
|
|
1549
1579
|
inline: !0,
|
|
1550
1580
|
group: "inline",
|
|
@@ -1555,33 +1585,33 @@ var Ar = (e) => {
|
|
|
1555
1585
|
return [{ tag: "br" }];
|
|
1556
1586
|
},
|
|
1557
1587
|
renderHTML({ HTMLAttributes: e }) {
|
|
1558
|
-
return ["br",
|
|
1588
|
+
return ["br", A(this.options.HTMLAttributes, e)];
|
|
1559
1589
|
},
|
|
1560
1590
|
renderText() {
|
|
1561
1591
|
return "\n";
|
|
1562
1592
|
}
|
|
1563
|
-
}),
|
|
1593
|
+
}), Ir = (e, t) => {
|
|
1564
1594
|
let n = e.resolve(t), r = n.depth - 1;
|
|
1565
1595
|
if (r < 1) return;
|
|
1566
1596
|
let i = n.before(r), a = e.resolve(i).nodeAfter;
|
|
1567
|
-
if (a) return a.type.spec.group?.includes("bnBlock") ?
|
|
1568
|
-
},
|
|
1597
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? b(e.resolve(i)) : Ir(e, i);
|
|
1598
|
+
}, X = (e, t) => {
|
|
1569
1599
|
let n = e.resolve(t), r = n.index();
|
|
1570
1600
|
if (r === 0) return;
|
|
1571
1601
|
let i = n.posAtIndex(r - 1);
|
|
1572
|
-
return
|
|
1573
|
-
},
|
|
1602
|
+
return b(e.resolve(i));
|
|
1603
|
+
}, Z = (e, t) => {
|
|
1574
1604
|
let n = e.resolve(t), r = n.index();
|
|
1575
1605
|
if (r === n.node().childCount - 1) return;
|
|
1576
1606
|
let i = n.posAtIndex(r + 1);
|
|
1577
|
-
return
|
|
1578
|
-
},
|
|
1607
|
+
return b(e.resolve(i));
|
|
1608
|
+
}, Lr = (e, t) => {
|
|
1579
1609
|
for (; t.childContainer;) {
|
|
1580
1610
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
1581
|
-
t =
|
|
1611
|
+
t = b(e.resolve(r));
|
|
1582
1612
|
}
|
|
1583
1613
|
return t;
|
|
1584
|
-
},
|
|
1614
|
+
}, Rr = (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*", zr = (e, t, n, r) => {
|
|
1585
1615
|
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`);
|
|
1586
1616
|
if (r.childContainer) {
|
|
1587
1617
|
let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
|
|
@@ -1595,66 +1625,66 @@ var Ar = (e) => {
|
|
|
1595
1625
|
t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
|
|
1596
1626
|
}
|
|
1597
1627
|
return !0;
|
|
1598
|
-
},
|
|
1599
|
-
let r = t.doc.resolve(e), i =
|
|
1628
|
+
}, Br = (e) => ({ state: t, dispatch: n }) => {
|
|
1629
|
+
let r = t.doc.resolve(e), i = b(r), a = X(t.doc, i.bnBlock.beforePos);
|
|
1600
1630
|
if (!a) return !1;
|
|
1601
|
-
let o =
|
|
1602
|
-
return
|
|
1603
|
-
},
|
|
1631
|
+
let o = Lr(t.doc, a);
|
|
1632
|
+
return Rr(o, i) ? zr(t, n, o, i) : !1;
|
|
1633
|
+
}, Vr = D.create({
|
|
1604
1634
|
priority: 50,
|
|
1605
1635
|
addKeyboardShortcuts() {
|
|
1606
1636
|
let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1607
1637
|
() => t.deleteSelection(),
|
|
1608
1638
|
() => t.undoInputRule(),
|
|
1609
1639
|
() => t.command(({ state: e }) => {
|
|
1610
|
-
let n =
|
|
1640
|
+
let n = v(e);
|
|
1611
1641
|
if (!n.isBlockContainer) return !1;
|
|
1612
1642
|
let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
|
|
1613
|
-
return r && !i ? t.command(
|
|
1643
|
+
return r && !i ? t.command(ce(n.bnBlock.beforePos, {
|
|
1614
1644
|
type: "paragraph",
|
|
1615
1645
|
props: {}
|
|
1616
1646
|
})) : !1;
|
|
1617
1647
|
}),
|
|
1618
1648
|
() => t.command(({ state: e, tr: t }) => {
|
|
1619
|
-
let n =
|
|
1649
|
+
let n = v(e);
|
|
1620
1650
|
if (!n.isBlockContainer) return !1;
|
|
1621
1651
|
let { blockContent: r } = n;
|
|
1622
|
-
return e.selection.from === r.beforePos + 1 &&
|
|
1652
|
+
return e.selection.from === r.beforePos + 1 && W(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup);
|
|
1623
1653
|
}),
|
|
1624
1654
|
() => t.command(({ state: t }) => {
|
|
1625
|
-
let n =
|
|
1655
|
+
let n = v(t);
|
|
1626
1656
|
if (!n.isBlockContainer) return !1;
|
|
1627
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1657
|
+
let { bnBlock: r, blockContent: i } = n, a = X(t.doc, n.bnBlock.beforePos);
|
|
1628
1658
|
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
1629
1659
|
let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
|
|
1630
|
-
return o && s ? e().command(
|
|
1660
|
+
return o && s ? e().command(Br(c)).scrollIntoView().run() : !1;
|
|
1631
1661
|
}),
|
|
1632
1662
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1633
|
-
let r =
|
|
1663
|
+
let r = v(e);
|
|
1634
1664
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1635
|
-
let i =
|
|
1665
|
+
let i = X(e.doc, r.bnBlock.beforePos);
|
|
1636
1666
|
if (!i || i.isBlockContainer) return !1;
|
|
1637
1667
|
if (n) {
|
|
1638
1668
|
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
1639
|
-
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(
|
|
1669
|
+
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(N.near(t.doc.resolve(n.pos + 1))), !0;
|
|
1640
1670
|
}
|
|
1641
1671
|
return !1;
|
|
1642
1672
|
}),
|
|
1643
1673
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1644
|
-
let r =
|
|
1674
|
+
let r = v(e);
|
|
1645
1675
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1646
1676
|
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1647
1677
|
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1648
1678
|
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
1649
|
-
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos),
|
|
1679
|
+
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), z(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(N.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(N.near(t.doc.resolve(o.pos))))), !0;
|
|
1650
1680
|
}),
|
|
1651
1681
|
() => t.command(({ state: t }) => {
|
|
1652
|
-
let n =
|
|
1682
|
+
let n = v(t);
|
|
1653
1683
|
if (!n.isBlockContainer) return !1;
|
|
1654
1684
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1655
|
-
let r =
|
|
1685
|
+
let r = X(t.doc, n.bnBlock.beforePos);
|
|
1656
1686
|
if (!r) return !1;
|
|
1657
|
-
let i =
|
|
1687
|
+
let i = Lr(t.doc, r);
|
|
1658
1688
|
if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
|
|
1659
1689
|
let a = e();
|
|
1660
1690
|
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1673,11 +1703,11 @@ var Ar = (e) => {
|
|
|
1673
1703
|
return !1;
|
|
1674
1704
|
}),
|
|
1675
1705
|
() => t.command(({ state: t }) => {
|
|
1676
|
-
let n =
|
|
1706
|
+
let n = v(t);
|
|
1677
1707
|
if (!n.isBlockContainer) return !1;
|
|
1678
|
-
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a =
|
|
1708
|
+
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = X(t.doc, n.bnBlock.beforePos);
|
|
1679
1709
|
if (a && r && i) {
|
|
1680
|
-
let r =
|
|
1710
|
+
let r = Lr(t.doc, a);
|
|
1681
1711
|
if (!r.isBlockContainer) return !1;
|
|
1682
1712
|
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1683
1713
|
from: n.bnBlock.beforePos,
|
|
@@ -1692,13 +1722,13 @@ var Ar = (e) => {
|
|
|
1692
1722
|
]), t = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1693
1723
|
() => t.deleteSelection(),
|
|
1694
1724
|
() => t.command(({ state: t }) => {
|
|
1695
|
-
let n =
|
|
1725
|
+
let n = v(t);
|
|
1696
1726
|
if (!n.isBlockContainer || !n.childContainer) return !1;
|
|
1697
|
-
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s =
|
|
1727
|
+
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s = b(t.doc.resolve(i.beforePos + 1));
|
|
1698
1728
|
if (!s.isBlockContainer) return !1;
|
|
1699
1729
|
if (a && o) {
|
|
1700
1730
|
let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
|
|
1701
|
-
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content ||
|
|
1731
|
+
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || w.empty).deleteRange(i.node.childCount === 1 ? {
|
|
1702
1732
|
from: i.beforePos,
|
|
1703
1733
|
to: i.afterPos
|
|
1704
1734
|
} : {
|
|
@@ -1709,50 +1739,50 @@ var Ar = (e) => {
|
|
|
1709
1739
|
return !1;
|
|
1710
1740
|
}),
|
|
1711
1741
|
() => t.command(({ state: t }) => {
|
|
1712
|
-
let n =
|
|
1742
|
+
let n = v(t);
|
|
1713
1743
|
if (!n.isBlockContainer) return !1;
|
|
1714
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1744
|
+
let { bnBlock: r, blockContent: i } = n, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1715
1745
|
if (!a || !a.isBlockContainer) return !1;
|
|
1716
1746
|
let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
|
|
1717
|
-
return o && s ? e().command(
|
|
1747
|
+
return o && s ? e().command(Br(c)).scrollIntoView().run() : !1;
|
|
1718
1748
|
}),
|
|
1719
1749
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1720
|
-
let r =
|
|
1750
|
+
let r = v(e);
|
|
1721
1751
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1722
|
-
let i =
|
|
1752
|
+
let i = Z(e.doc, r.bnBlock.beforePos);
|
|
1723
1753
|
if (!i || i.isBlockContainer) return !1;
|
|
1724
1754
|
if (n) {
|
|
1725
1755
|
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
1726
|
-
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize),
|
|
1756
|
+
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), z(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(N.near(t.doc.resolve(n.pos))), !0;
|
|
1727
1757
|
}
|
|
1728
1758
|
return !1;
|
|
1729
1759
|
}),
|
|
1730
1760
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1731
|
-
let r =
|
|
1761
|
+
let r = v(e);
|
|
1732
1762
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1733
1763
|
let i = t.doc.resolve(r.bnBlock.afterPos);
|
|
1734
1764
|
if (i.nodeAfter || i.node().type.name !== "column") return !1;
|
|
1735
1765
|
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1736
1766
|
if (n) {
|
|
1737
|
-
let e = o.pos === s - 1 ? s : o.pos + 1, n =
|
|
1738
|
-
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos),
|
|
1767
|
+
let e = o.pos === s - 1 ? s : o.pos + 1, n = b(t.doc.resolve(e));
|
|
1768
|
+
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), z(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(N.near(t.doc.resolve(e)));
|
|
1739
1769
|
}
|
|
1740
1770
|
return !0;
|
|
1741
1771
|
}),
|
|
1742
1772
|
() => t.command(({ state: t }) => {
|
|
1743
|
-
let n =
|
|
1773
|
+
let n = v(t);
|
|
1744
1774
|
if (!n.isBlockContainer) return !1;
|
|
1745
1775
|
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1746
1776
|
if (i && a) {
|
|
1747
1777
|
let i = (e, t) => {
|
|
1748
|
-
let n =
|
|
1778
|
+
let n = Z(e, t);
|
|
1749
1779
|
if (n) return n;
|
|
1750
|
-
let r =
|
|
1780
|
+
let r = Ir(e, t);
|
|
1751
1781
|
if (r) return i(e, r.bnBlock.beforePos);
|
|
1752
1782
|
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1753
1783
|
if (!a || !a.isBlockContainer) return !1;
|
|
1754
1784
|
let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
|
|
1755
|
-
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content ||
|
|
1785
|
+
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || w.empty).deleteRange({
|
|
1756
1786
|
from: a.bnBlock.beforePos,
|
|
1757
1787
|
to: a.bnBlock.afterPos
|
|
1758
1788
|
}).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
@@ -1760,10 +1790,10 @@ var Ar = (e) => {
|
|
|
1760
1790
|
return !1;
|
|
1761
1791
|
}),
|
|
1762
1792
|
() => t.command(({ state: t }) => {
|
|
1763
|
-
let n =
|
|
1793
|
+
let n = v(t);
|
|
1764
1794
|
if (!n.isBlockContainer) return !1;
|
|
1765
1795
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1766
|
-
let r =
|
|
1796
|
+
let r = Z(t.doc, n.bnBlock.beforePos);
|
|
1767
1797
|
if (!r || !r.isBlockContainer) return !1;
|
|
1768
1798
|
let i = e();
|
|
1769
1799
|
if (r.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1778,9 +1808,9 @@ var Ar = (e) => {
|
|
|
1778
1808
|
return !1;
|
|
1779
1809
|
}),
|
|
1780
1810
|
() => t.command(({ state: t }) => {
|
|
1781
|
-
let n =
|
|
1811
|
+
let n = v(t);
|
|
1782
1812
|
if (!n.isBlockContainer) return !1;
|
|
1783
|
-
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a =
|
|
1813
|
+
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1784
1814
|
if (!a || !a.isBlockContainer) return !1;
|
|
1785
1815
|
if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
|
|
1786
1816
|
let t = a.bnBlock.node.lastChild.content;
|
|
@@ -1793,13 +1823,13 @@ var Ar = (e) => {
|
|
|
1793
1823
|
})
|
|
1794
1824
|
]), n = (e = !1) => this.editor.commands.first(({ commands: t, tr: n }) => [
|
|
1795
1825
|
() => t.command(({ state: e, tr: t }) => {
|
|
1796
|
-
let n =
|
|
1826
|
+
let n = v(e);
|
|
1797
1827
|
if (!n.isBlockContainer) return !1;
|
|
1798
1828
|
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;
|
|
1799
|
-
return o && s && c && a > 1 ?
|
|
1829
|
+
return o && s && c && a > 1 ? W(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1800
1830
|
}),
|
|
1801
1831
|
() => t.command(({ state: t }) => {
|
|
1802
|
-
let r =
|
|
1832
|
+
let r = v(t), i = this.options.editor.schema.blockSpecs[r.blockNoteType], a = i?.implementation?.meta?.hardBreakShortcut ?? "shift+enter";
|
|
1803
1833
|
if (a === "none") return !1;
|
|
1804
1834
|
if (a === "shift+enter" && e || a === "enter") {
|
|
1805
1835
|
if (i?.config?.content === "plain") return n.insertText("\n", n.selection.head), !0;
|
|
@@ -1809,24 +1839,24 @@ var Ar = (e) => {
|
|
|
1809
1839
|
return !1;
|
|
1810
1840
|
}),
|
|
1811
1841
|
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
1812
|
-
let r =
|
|
1842
|
+
let r = v(e);
|
|
1813
1843
|
if (!r.isBlockContainer) return !1;
|
|
1814
1844
|
let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
|
|
1815
1845
|
if (o && s && c) {
|
|
1816
1846
|
let a = i.afterPos, o = a + 2;
|
|
1817
1847
|
if (t) {
|
|
1818
1848
|
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
|
|
1819
|
-
n.insert(a, t).setSelection(new
|
|
1849
|
+
n.insert(a, t).setSelection(new N(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
|
|
1820
1850
|
}
|
|
1821
1851
|
return !0;
|
|
1822
1852
|
}
|
|
1823
1853
|
return !1;
|
|
1824
1854
|
}),
|
|
1825
1855
|
() => t.command(({ state: e, chain: t }) => {
|
|
1826
|
-
let n =
|
|
1856
|
+
let n = v(e);
|
|
1827
1857
|
if (!n.isBlockContainer) return !1;
|
|
1828
1858
|
let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
|
|
1829
|
-
return r.node.childCount !== 0 && (t().deleteSelection().command(
|
|
1859
|
+
return r.node.childCount !== 0 && (t().deleteSelection().command(g(e.selection.from, i, i)).scrollIntoView().run(), !0);
|
|
1830
1860
|
})
|
|
1831
1861
|
]);
|
|
1832
1862
|
return {
|
|
@@ -1834,8 +1864,8 @@ var Ar = (e) => {
|
|
|
1834
1864
|
Delete: t,
|
|
1835
1865
|
Enter: () => n(),
|
|
1836
1866
|
"Shift-Enter": () => n(!0),
|
|
1837
|
-
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1838
|
-
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1867
|
+
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(le)?.store.state || this.options.editor.getExtension(re)?.store.state !== void 0) ? !1 : Yt(this.options.editor),
|
|
1868
|
+
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(le)?.store.state || this.options.editor.getExtension(re)?.store.state !== void 0) ? !1 : Zt(this.options.editor),
|
|
1839
1869
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1840
1870
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1841
1871
|
"Mod-z": () => this.options.editor.undo(),
|
|
@@ -1843,7 +1873,7 @@ var Ar = (e) => {
|
|
|
1843
1873
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1844
1874
|
};
|
|
1845
1875
|
}
|
|
1846
|
-
}),
|
|
1876
|
+
}), Hr = D.create({
|
|
1847
1877
|
name: "textAlignment",
|
|
1848
1878
|
addGlobalAttributes() {
|
|
1849
1879
|
return [{
|
|
@@ -1855,7 +1885,7 @@ var Ar = (e) => {
|
|
|
1855
1885
|
} }
|
|
1856
1886
|
}];
|
|
1857
1887
|
}
|
|
1858
|
-
}),
|
|
1888
|
+
}), Ur = D.create({
|
|
1859
1889
|
name: "blockTextColor",
|
|
1860
1890
|
addGlobalAttributes() {
|
|
1861
1891
|
return [{
|
|
@@ -1864,13 +1894,13 @@ var Ar = (e) => {
|
|
|
1864
1894
|
"tableCell",
|
|
1865
1895
|
"tableHeader"
|
|
1866
1896
|
],
|
|
1867
|
-
attributes: { textColor:
|
|
1897
|
+
attributes: { textColor: m() }
|
|
1868
1898
|
}];
|
|
1869
1899
|
}
|
|
1870
|
-
}),
|
|
1900
|
+
}), Wr = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
1871
1901
|
//#endregion
|
|
1872
1902
|
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
1873
|
-
function
|
|
1903
|
+
function Gr(e) {
|
|
1874
1904
|
let t = [], n = [], r = 0;
|
|
1875
1905
|
for (; r < e.length;) {
|
|
1876
1906
|
let i = 0;
|
|
@@ -1884,59 +1914,59 @@ function Wr(e) {
|
|
|
1884
1914
|
}
|
|
1885
1915
|
return t;
|
|
1886
1916
|
}
|
|
1887
|
-
var
|
|
1888
|
-
function
|
|
1917
|
+
var Kr = new Set(Gr(Wr)), qr = /* @__PURE__ */ new Set(["localhost"]), Jr = /[.,;:!?"']+$/, Yr = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Xr = /mailto:[^\s]+/g, Zr = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Qr = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
1918
|
+
function $r(e) {
|
|
1889
1919
|
let t = e, n = !0;
|
|
1890
1920
|
for (; n;) {
|
|
1891
1921
|
n = !1;
|
|
1892
1922
|
let e = t;
|
|
1893
|
-
t = t.replace(
|
|
1923
|
+
t = t.replace(Jr, ""), t !== e && (n = !0);
|
|
1894
1924
|
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
1895
|
-
let i =
|
|
1896
|
-
if (
|
|
1925
|
+
let i = ei(t, e);
|
|
1926
|
+
if (ei(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
1897
1927
|
else break;
|
|
1898
1928
|
}
|
|
1899
1929
|
}
|
|
1900
1930
|
return t;
|
|
1901
1931
|
}
|
|
1902
|
-
function
|
|
1932
|
+
function ei(e, t) {
|
|
1903
1933
|
let n = 0;
|
|
1904
1934
|
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
1905
1935
|
return n;
|
|
1906
1936
|
}
|
|
1907
|
-
function
|
|
1937
|
+
function ti(e) {
|
|
1908
1938
|
let t = e.split(".");
|
|
1909
1939
|
return t[t.length - 1].toLowerCase();
|
|
1910
1940
|
}
|
|
1911
|
-
function
|
|
1912
|
-
let t =
|
|
1913
|
-
return
|
|
1941
|
+
function ni(e) {
|
|
1942
|
+
let t = ti(e);
|
|
1943
|
+
return Kr.has(t);
|
|
1914
1944
|
}
|
|
1915
|
-
function
|
|
1945
|
+
function ri(e, t, n) {
|
|
1916
1946
|
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
1917
1947
|
}
|
|
1918
|
-
function
|
|
1948
|
+
function ii(e, t) {
|
|
1919
1949
|
if (!e) return [];
|
|
1920
1950
|
let n = t?.defaultProtocol || "http", r = [];
|
|
1921
|
-
for (let t of e.matchAll(
|
|
1951
|
+
for (let t of e.matchAll(Yr)) r.push({
|
|
1922
1952
|
type: "url",
|
|
1923
1953
|
value: t[0],
|
|
1924
1954
|
start: t.index,
|
|
1925
1955
|
end: t.index + t[0].length
|
|
1926
1956
|
});
|
|
1927
|
-
for (let t of e.matchAll(
|
|
1957
|
+
for (let t of e.matchAll(Xr)) r.push({
|
|
1928
1958
|
type: "url",
|
|
1929
1959
|
value: t[0],
|
|
1930
1960
|
start: t.index,
|
|
1931
1961
|
end: t.index + t[0].length
|
|
1932
1962
|
});
|
|
1933
|
-
for (let t of e.matchAll(
|
|
1963
|
+
for (let t of e.matchAll(Zr)) r.push({
|
|
1934
1964
|
type: "email",
|
|
1935
1965
|
value: t[0],
|
|
1936
1966
|
start: t.index,
|
|
1937
1967
|
end: t.index + t[0].length
|
|
1938
1968
|
});
|
|
1939
|
-
for (let t of e.matchAll(
|
|
1969
|
+
for (let t of e.matchAll(Qr)) r.push({
|
|
1940
1970
|
type: "url",
|
|
1941
1971
|
value: t[0],
|
|
1942
1972
|
start: t.index,
|
|
@@ -1947,18 +1977,18 @@ function ri(e, t) {
|
|
|
1947
1977
|
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
1948
1978
|
let o = [];
|
|
1949
1979
|
for (let e of i) {
|
|
1950
|
-
let t =
|
|
1980
|
+
let t = $r(e.value);
|
|
1951
1981
|
if (!t) continue;
|
|
1952
1982
|
let r = e.start, i = r + t.length;
|
|
1953
1983
|
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
1954
1984
|
let e = new URL("http://" + t).hostname;
|
|
1955
|
-
if (!
|
|
1985
|
+
if (!ni(e)) continue;
|
|
1956
1986
|
}
|
|
1957
1987
|
if (e.type === "email") {
|
|
1958
1988
|
let e = t.split("@")[1];
|
|
1959
|
-
if (!
|
|
1989
|
+
if (!ni(e)) continue;
|
|
1960
1990
|
}
|
|
1961
|
-
let a =
|
|
1991
|
+
let a = ri(t, e.type, n);
|
|
1962
1992
|
o.push({
|
|
1963
1993
|
type: e.type,
|
|
1964
1994
|
value: t,
|
|
@@ -1970,7 +2000,7 @@ function ri(e, t) {
|
|
|
1970
2000
|
}
|
|
1971
2001
|
return o;
|
|
1972
2002
|
}
|
|
1973
|
-
function
|
|
2003
|
+
function ai(e, t = "http") {
|
|
1974
2004
|
if (!e) return [$(e, 0, 0)];
|
|
1975
2005
|
for (let [n, r] of [
|
|
1976
2006
|
["(", ")"],
|
|
@@ -1978,7 +2008,7 @@ function ii(e, t = "http") {
|
|
|
1978
2008
|
["{", "}"]
|
|
1979
2009
|
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
1980
2010
|
let i = e.slice(1, -1);
|
|
1981
|
-
if (
|
|
2011
|
+
if (Q(i)) return [
|
|
1982
2012
|
$(n, 0, 1),
|
|
1983
2013
|
oi(i, 1, 1 + i.length, t),
|
|
1984
2014
|
$(r, 1 + i.length, e.length)
|
|
@@ -1986,16 +2016,16 @@ function ii(e, t = "http") {
|
|
|
1986
2016
|
}
|
|
1987
2017
|
if (e.endsWith(".") && e.length > 1) {
|
|
1988
2018
|
let n = e.slice(0, -1);
|
|
1989
|
-
if (
|
|
2019
|
+
if (Q(n)) return [oi(n, 0, n.length, t), $(".", n.length, e.length)];
|
|
1990
2020
|
}
|
|
1991
|
-
return
|
|
2021
|
+
return Q(e) ? [oi(e, 0, e.length, t)] : [$(e, 0, e.length)];
|
|
1992
2022
|
}
|
|
1993
|
-
function
|
|
1994
|
-
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) ||
|
|
2023
|
+
function Q(e) {
|
|
2024
|
+
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || qr.has(e.toLowerCase())) return !0;
|
|
1995
2025
|
let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
|
|
1996
2026
|
if (t) {
|
|
1997
2027
|
let e = t[1].toLowerCase();
|
|
1998
|
-
if (
|
|
2028
|
+
if (Kr.has(e)) return !0;
|
|
1999
2029
|
}
|
|
2000
2030
|
return !1;
|
|
2001
2031
|
}
|
|
@@ -2005,7 +2035,7 @@ function oi(e, t, n, r) {
|
|
|
2005
2035
|
type: i,
|
|
2006
2036
|
value: e,
|
|
2007
2037
|
isLink: !0,
|
|
2008
|
-
href:
|
|
2038
|
+
href: ri(e, i, r),
|
|
2009
2039
|
start: t,
|
|
2010
2040
|
end: n
|
|
2011
2041
|
};
|
|
@@ -2029,14 +2059,14 @@ function di(e) {
|
|
|
2029
2059
|
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
2030
2060
|
}
|
|
2031
2061
|
function fi(e) {
|
|
2032
|
-
return new
|
|
2033
|
-
key: new
|
|
2062
|
+
return new ct({
|
|
2063
|
+
key: new lt("autolink"),
|
|
2034
2064
|
appendTransaction: (t, n, r) => {
|
|
2035
2065
|
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
2036
2066
|
if (!i || a) return;
|
|
2037
|
-
let { tr: o } = r, s =
|
|
2038
|
-
if (
|
|
2039
|
-
let n =
|
|
2067
|
+
let { tr: o } = r, s = qe(n.doc, [...t]);
|
|
2068
|
+
if (Qe(s).forEach(({ newRange: t }) => {
|
|
2069
|
+
let n = Ye(r.doc, t, (e) => e.isTextblock), i, a;
|
|
2040
2070
|
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
2041
2071
|
else if (n.length) {
|
|
2042
2072
|
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
@@ -2048,14 +2078,14 @@ function fi(e) {
|
|
|
2048
2078
|
if (t.length <= 0) return;
|
|
2049
2079
|
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
2050
2080
|
if (!n) return;
|
|
2051
|
-
let c =
|
|
2081
|
+
let c = ai(n, e.defaultProtocol);
|
|
2052
2082
|
if (!di(c)) return;
|
|
2053
2083
|
c.filter((e) => e.isLink).map((e) => ({
|
|
2054
2084
|
...e,
|
|
2055
2085
|
from: s + e.start + 1,
|
|
2056
2086
|
to: s + e.end + 1
|
|
2057
2087
|
})).filter((e) => !r.schema.marks.code || !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code)).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
|
|
2058
|
-
|
|
2088
|
+
et(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
|
|
2059
2089
|
});
|
|
2060
2090
|
}
|
|
2061
2091
|
}), o.steps.length) return o;
|
|
@@ -2065,8 +2095,8 @@ function fi(e) {
|
|
|
2065
2095
|
//#endregion
|
|
2066
2096
|
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
2067
2097
|
function pi(e) {
|
|
2068
|
-
return new
|
|
2069
|
-
key: new
|
|
2098
|
+
return new ct({
|
|
2099
|
+
key: new lt("handleClickLink"),
|
|
2070
2100
|
props: { handleClick: (t, n, r) => {
|
|
2071
2101
|
if (r.button !== 0 || !t.editable) return !1;
|
|
2072
2102
|
let i = null;
|
|
@@ -2082,7 +2112,7 @@ function pi(e) {
|
|
|
2082
2112
|
if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
|
|
2083
2113
|
return e.onClick(r, e.editor) ?? !0;
|
|
2084
2114
|
}
|
|
2085
|
-
let a =
|
|
2115
|
+
let a = Ze(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
|
|
2086
2116
|
return o ? (window.open(o, s), !0) : !1;
|
|
2087
2117
|
} }
|
|
2088
2118
|
});
|
|
@@ -2090,8 +2120,8 @@ function pi(e) {
|
|
|
2090
2120
|
//#endregion
|
|
2091
2121
|
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
2092
2122
|
function mi(e) {
|
|
2093
|
-
return new
|
|
2094
|
-
key: new
|
|
2123
|
+
return new ct({
|
|
2124
|
+
key: new lt("handlePasteLink"),
|
|
2095
2125
|
props: { handlePaste: (t, n, r) => {
|
|
2096
2126
|
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
2097
2127
|
if (c) return !1;
|
|
@@ -2099,7 +2129,7 @@ function mi(e) {
|
|
|
2099
2129
|
r.content.forEach((e) => {
|
|
2100
2130
|
l += e.textContent;
|
|
2101
2131
|
});
|
|
2102
|
-
let u =
|
|
2132
|
+
let u = ii(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
2103
2133
|
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
2104
2134
|
} }
|
|
2105
2135
|
});
|
|
@@ -2118,7 +2148,7 @@ function vi(e) {
|
|
|
2118
2148
|
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
2119
2149
|
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
2120
2150
|
}
|
|
2121
|
-
var yi =
|
|
2151
|
+
var yi = Ke.create({
|
|
2122
2152
|
name: "link",
|
|
2123
2153
|
keepOnSplit: !1,
|
|
2124
2154
|
exitable: !0,
|
|
@@ -2157,11 +2187,11 @@ var yi = We.create({
|
|
|
2157
2187
|
renderHTML({ HTMLAttributes: e }) {
|
|
2158
2188
|
return this.options.isValidLink(e.href) ? [
|
|
2159
2189
|
"a",
|
|
2160
|
-
|
|
2190
|
+
A(e, this.options.HTMLAttributes),
|
|
2161
2191
|
0
|
|
2162
2192
|
] : [
|
|
2163
2193
|
"a",
|
|
2164
|
-
|
|
2194
|
+
A({
|
|
2165
2195
|
...e,
|
|
2166
2196
|
href: ""
|
|
2167
2197
|
}, this.options.HTMLAttributes),
|
|
@@ -2170,11 +2200,11 @@ var yi = We.create({
|
|
|
2170
2200
|
},
|
|
2171
2201
|
addPasteRules() {
|
|
2172
2202
|
let e = this.options.isValidLink;
|
|
2173
|
-
return [
|
|
2203
|
+
return [rt({
|
|
2174
2204
|
find: (t) => {
|
|
2175
2205
|
let n = [];
|
|
2176
2206
|
if (t) {
|
|
2177
|
-
let r =
|
|
2207
|
+
let r = ii(t, { defaultProtocol: hi }).filter((t) => t.isLink && e(t.value));
|
|
2178
2208
|
for (let e of r) vi(e.value) && n.push({
|
|
2179
2209
|
text: e.value,
|
|
2180
2210
|
data: { href: e.href },
|
|
@@ -2207,7 +2237,7 @@ var yi = We.create({
|
|
|
2207
2237
|
isValidLink: this.options.isValidLink
|
|
2208
2238
|
})), e;
|
|
2209
2239
|
}
|
|
2210
|
-
}), bi =
|
|
2240
|
+
}), bi = _e(({ editor: e, options: t }) => ({
|
|
2211
2241
|
key: "link",
|
|
2212
2242
|
tiptapExtensions: [yi.configure({
|
|
2213
2243
|
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
@@ -2221,14 +2251,14 @@ var yi = We.create({
|
|
|
2221
2251
|
id: "data-id",
|
|
2222
2252
|
depth: "data-depth",
|
|
2223
2253
|
depthChange: "data-depth-change"
|
|
2224
|
-
}, Si =
|
|
2254
|
+
}, Si = O.create({
|
|
2225
2255
|
name: "blockContainer",
|
|
2226
2256
|
group: "blockGroupChild bnBlock",
|
|
2227
2257
|
content: "blockContent blockGroup?",
|
|
2228
2258
|
priority: 50,
|
|
2229
2259
|
defining: !0,
|
|
2230
2260
|
marks() {
|
|
2231
|
-
return
|
|
2261
|
+
return l(this.editor);
|
|
2232
2262
|
},
|
|
2233
2263
|
parseHTML() {
|
|
2234
2264
|
return [{
|
|
@@ -2252,19 +2282,19 @@ var yi = We.create({
|
|
|
2252
2282
|
...this.options.domAttributes?.block || {},
|
|
2253
2283
|
...e
|
|
2254
2284
|
}, r = document.createElement("div");
|
|
2255
|
-
r.className =
|
|
2285
|
+
r.className = h("bn-block", n.class), r.setAttribute("data-node-type", this.name);
|
|
2256
2286
|
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2257
2287
|
return t.appendChild(r), {
|
|
2258
2288
|
dom: t,
|
|
2259
2289
|
contentDOM: r
|
|
2260
2290
|
};
|
|
2261
2291
|
}
|
|
2262
|
-
}), Ci =
|
|
2292
|
+
}), Ci = O.create({
|
|
2263
2293
|
name: "blockGroup",
|
|
2264
2294
|
group: "childContainer",
|
|
2265
2295
|
content: "blockGroupChild+",
|
|
2266
2296
|
marks() {
|
|
2267
|
-
return
|
|
2297
|
+
return l(this.editor);
|
|
2268
2298
|
},
|
|
2269
2299
|
parseHTML() {
|
|
2270
2300
|
return [{
|
|
@@ -2277,32 +2307,32 @@ var yi = We.create({
|
|
|
2277
2307
|
...this.options.domAttributes?.blockGroup || {},
|
|
2278
2308
|
...e
|
|
2279
2309
|
}, n = document.createElement("div");
|
|
2280
|
-
n.className =
|
|
2310
|
+
n.className = h("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
|
|
2281
2311
|
for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
|
|
2282
2312
|
return {
|
|
2283
2313
|
dom: n,
|
|
2284
2314
|
contentDOM: n
|
|
2285
2315
|
};
|
|
2286
2316
|
}
|
|
2287
|
-
}), wi =
|
|
2317
|
+
}), wi = O.create({
|
|
2288
2318
|
name: "doc",
|
|
2289
2319
|
topNode: !0,
|
|
2290
2320
|
content: "blockGroup",
|
|
2291
2321
|
marks() {
|
|
2292
|
-
return
|
|
2322
|
+
return l(this.editor);
|
|
2293
2323
|
}
|
|
2294
2324
|
});
|
|
2295
2325
|
//#endregion
|
|
2296
2326
|
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
2297
2327
|
function Ti(e, t) {
|
|
2298
2328
|
return [
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2329
|
+
k.ClipboardTextSerializer,
|
|
2330
|
+
k.Commands,
|
|
2331
|
+
k.Editable,
|
|
2332
|
+
k.FocusEvents,
|
|
2333
|
+
k.Tabindex,
|
|
2334
|
+
ht,
|
|
2335
|
+
ie.configure({
|
|
2306
2336
|
types: [
|
|
2307
2337
|
"blockContainer",
|
|
2308
2338
|
"columnList",
|
|
@@ -2311,22 +2341,22 @@ function Ti(e, t) {
|
|
|
2311
2341
|
setIdAttribute: t.setIdAttribute,
|
|
2312
2342
|
isWithinEditor: e.isWithinEditor
|
|
2313
2343
|
}),
|
|
2314
|
-
|
|
2315
|
-
|
|
2344
|
+
Fr,
|
|
2345
|
+
mt,
|
|
2316
2346
|
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
2347
|
+
Ur,
|
|
2348
|
+
Pr,
|
|
2317
2349
|
Hr,
|
|
2318
|
-
|
|
2319
|
-
Vr,
|
|
2320
|
-
k.create({
|
|
2350
|
+
D.create({
|
|
2321
2351
|
name: "OverrideEscape",
|
|
2322
|
-
addKeyboardShortcuts: () => ({ Escape: () => !e.getExtension(
|
|
2352
|
+
addKeyboardShortcuts: () => ({ Escape: () => !e.getExtension(ae)?.shown() && (e.blur(), !0) })
|
|
2323
2353
|
}),
|
|
2324
2354
|
wi,
|
|
2325
2355
|
Si.configure({
|
|
2326
2356
|
editor: e,
|
|
2327
2357
|
domAttributes: t.domAttributes
|
|
2328
2358
|
}),
|
|
2329
|
-
|
|
2359
|
+
Vr.configure({
|
|
2330
2360
|
editor: e,
|
|
2331
2361
|
tabBehavior: t.tabBehavior
|
|
2332
2362
|
}),
|
|
@@ -2336,36 +2366,36 @@ function Ti(e, t) {
|
|
|
2336
2366
|
editor: e,
|
|
2337
2367
|
domAttributes: t.domAttributes
|
|
2338
2368
|
})] : []]),
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2369
|
+
Nr(e),
|
|
2370
|
+
Or(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
2371
|
+
dr(e)
|
|
2342
2372
|
];
|
|
2343
2373
|
}
|
|
2344
2374
|
function Ei(e, t) {
|
|
2345
2375
|
let n = [
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2376
|
+
Se(),
|
|
2377
|
+
xe(t),
|
|
2378
|
+
re(t),
|
|
2379
|
+
le(t),
|
|
2350
2380
|
bi({
|
|
2351
2381
|
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
2352
2382
|
onClick: t.links?.onClick,
|
|
2353
2383
|
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
2354
2384
|
}),
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
Oe(),
|
|
2385
|
+
Ce(t),
|
|
2386
|
+
Ee(),
|
|
2387
|
+
Pe(t),
|
|
2388
|
+
Le(t),
|
|
2389
|
+
ke(t),
|
|
2361
2390
|
Ae(),
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2391
|
+
Me(),
|
|
2392
|
+
ae(t),
|
|
2393
|
+
ve(),
|
|
2394
|
+
je(),
|
|
2395
|
+
ye(),
|
|
2396
|
+
...t.trailingBlock === !1 ? [] : [Ne()]
|
|
2367
2397
|
];
|
|
2368
|
-
return "table" in e.schema.blockSpecs && n.push(
|
|
2398
|
+
return "table" in e.schema.blockSpecs && n.push(Oe(t)), t.animations !== !1 && n.push(Te()), n;
|
|
2369
2399
|
}
|
|
2370
2400
|
//#endregion
|
|
2371
2401
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
@@ -2409,7 +2439,7 @@ var Di = class {
|
|
|
2409
2439
|
}
|
|
2410
2440
|
if (!this.extensions.some((e) => e.key === n.key)) {
|
|
2411
2441
|
if (typeof e == "function") {
|
|
2412
|
-
let e = n[
|
|
2442
|
+
let e = n[ge];
|
|
2413
2443
|
typeof e == "function" && this.extensionFactories.set(e, n);
|
|
2414
2444
|
}
|
|
2415
2445
|
if (this.extensions.push(n), n.blockNoteExtensions) for (let e of n.blockNoteExtensions) this.addExtension(e, n.key);
|
|
@@ -2462,7 +2492,7 @@ var Di = class {
|
|
|
2462
2492
|
this.editor.prosemirrorView.updateState(n);
|
|
2463
2493
|
}
|
|
2464
2494
|
getTiptapExtensions() {
|
|
2465
|
-
let e = Ti(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t =
|
|
2495
|
+
let e = Ti(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = ee(this.extensions.map((e) => {
|
|
2466
2496
|
let t = this.blockNoteExtensionDependents.get(e.key);
|
|
2467
2497
|
return t?.size ? {
|
|
2468
2498
|
key: e.key,
|
|
@@ -2472,21 +2502,21 @@ var Di = class {
|
|
|
2472
2502
|
for (let r of this.extensions) {
|
|
2473
2503
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
2474
2504
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
2475
|
-
a.length && e.push(
|
|
2505
|
+
a.length && e.push(D.create({
|
|
2476
2506
|
name: r.key,
|
|
2477
2507
|
priority: i,
|
|
2478
2508
|
addProseMirrorPlugins: () => a
|
|
2479
2509
|
})), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
|
|
2480
2510
|
}
|
|
2481
|
-
e.push(
|
|
2511
|
+
e.push(D.create({
|
|
2482
2512
|
name: "blocknote-input-rules",
|
|
2483
2513
|
addProseMirrorPlugins() {
|
|
2484
2514
|
let e = [];
|
|
2485
2515
|
Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
|
|
2486
2516
|
e.push(...n.get(t));
|
|
2487
2517
|
});
|
|
2488
|
-
let t =
|
|
2489
|
-
return [t, new
|
|
2518
|
+
let t = ft({ rules: e });
|
|
2519
|
+
return [t, new M({ props: { handleKeyDown(e, n) {
|
|
2490
2520
|
if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
|
|
2491
2521
|
let { $cursor: r } = e.state.selection;
|
|
2492
2522
|
return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
|
|
@@ -2498,10 +2528,11 @@ var Di = class {
|
|
|
2498
2528
|
}
|
|
2499
2529
|
getProsemirrorPluginsFromExtension(e) {
|
|
2500
2530
|
let t = [...e.prosemirrorPlugins ?? []], n = [];
|
|
2501
|
-
|
|
2531
|
+
if (!e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length) return {
|
|
2502
2532
|
plugins: t,
|
|
2503
2533
|
inputRules: n
|
|
2504
|
-
}
|
|
2534
|
+
};
|
|
2535
|
+
if (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new dt(e.find, (t, n, r, i) => {
|
|
2505
2536
|
let a = e.replace({
|
|
2506
2537
|
match: n,
|
|
2507
2538
|
range: {
|
|
@@ -2511,14 +2542,32 @@ var Di = class {
|
|
|
2511
2542
|
editor: this.editor
|
|
2512
2543
|
});
|
|
2513
2544
|
if (a) {
|
|
2514
|
-
let e = t.tr, n =
|
|
2515
|
-
return !n.isBlockContainer || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline" ? null : (e.deleteRange(r, i),
|
|
2545
|
+
let e = t.tr, n = v(e);
|
|
2546
|
+
return !n.isBlockContainer || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline" ? null : (e.deleteRange(r, i), s(e, n.bnBlock.beforePos, a), ar(e, x(n.bnBlock.node, e.doc), "start"), e);
|
|
2516
2547
|
}
|
|
2517
2548
|
return null;
|
|
2518
|
-
}, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length
|
|
2549
|
+
}, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length) {
|
|
2550
|
+
let n, r = pt(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => {
|
|
2551
|
+
if (!n) throw Error("Keyboard shortcut called outside handleKeyDown");
|
|
2552
|
+
return t({
|
|
2553
|
+
editor: this.editor,
|
|
2554
|
+
event: n
|
|
2555
|
+
});
|
|
2556
|
+
}])));
|
|
2557
|
+
t.push(new M({ props: { handleKeyDown: (e, t) => {
|
|
2558
|
+
let i = n;
|
|
2559
|
+
n = t;
|
|
2560
|
+
try {
|
|
2561
|
+
return r(e, t);
|
|
2562
|
+
} finally {
|
|
2563
|
+
n = i;
|
|
2564
|
+
}
|
|
2565
|
+
} } }));
|
|
2566
|
+
}
|
|
2567
|
+
return {
|
|
2519
2568
|
plugins: t,
|
|
2520
2569
|
inputRules: n
|
|
2521
|
-
}
|
|
2570
|
+
};
|
|
2522
2571
|
}
|
|
2523
2572
|
getExtensions() {
|
|
2524
2573
|
return new Map(this.extensions.map((e) => [e.key, e]));
|
|
@@ -2561,13 +2610,13 @@ function Oi(e, t) {
|
|
|
2561
2610
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
2562
2611
|
function ki(e) {
|
|
2563
2612
|
if (e.selection.empty || "node" in e.selection) return;
|
|
2564
|
-
let t = e.doc.resolve(
|
|
2613
|
+
let t = e.doc.resolve(de(e.doc, e.selection.from).posBeforeNode), n = e.doc.resolve(de(e.doc, e.selection.to).posBeforeNode), r = (n, r) => {
|
|
2565
2614
|
let i = t.posAtIndex(n, r), a = e.doc.resolve(i).nodeAfter;
|
|
2566
2615
|
if (!a) throw Error(`Error getting selection - node not found at position ${i}`);
|
|
2567
|
-
return
|
|
2616
|
+
return C(a, e.doc);
|
|
2568
2617
|
}, i = [], a = t.sharedDepth(n.pos), o = t.index(a), s = n.index(a);
|
|
2569
2618
|
if (t.depth > a) {
|
|
2570
|
-
i.push(
|
|
2619
|
+
i.push(C(t.nodeAfter, e.doc));
|
|
2571
2620
|
for (let e = t.depth; e > a; e--) if (t.node(e).type.isInGroup("childContainer")) {
|
|
2572
2621
|
let n = t.index(e) + 1, a = t.node(e).childCount;
|
|
2573
2622
|
for (let t = n; t < a; t++) i.push(r(t, e));
|
|
@@ -2577,37 +2626,37 @@ function ki(e) {
|
|
|
2577
2626
|
if (i.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
2578
2627
|
return { blocks: i };
|
|
2579
2628
|
}
|
|
2580
|
-
function Ai(t, n
|
|
2581
|
-
let
|
|
2582
|
-
if (
|
|
2583
|
-
let
|
|
2584
|
-
if (!
|
|
2585
|
-
let l =
|
|
2586
|
-
if (!l) throw Error(`Block with ID ${
|
|
2587
|
-
let d =
|
|
2588
|
-
if (!d.isBlockContainer ||
|
|
2589
|
-
if (!
|
|
2590
|
-
let
|
|
2591
|
-
if (
|
|
2629
|
+
function Ai(e, t, n) {
|
|
2630
|
+
let r = typeof t == "string" ? t : t.id, i = typeof n == "string" ? n : n.id, a = y(e), o = u(a);
|
|
2631
|
+
if (r === i) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);
|
|
2632
|
+
let s = c(r, e.doc);
|
|
2633
|
+
if (!s) throw Error(`Block with ID ${r} not found`);
|
|
2634
|
+
let l = c(i, e.doc);
|
|
2635
|
+
if (!l) throw Error(`Block with ID ${i} not found`);
|
|
2636
|
+
let d = S(s), f = S(l), p = o.blockSchema[d.blockNoteType], m = o.blockSchema[f.blockNoteType];
|
|
2637
|
+
if (!d.isBlockContainer || p.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${r})`);
|
|
2638
|
+
if (!f.isBlockContainer || m.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${i})`);
|
|
2639
|
+
let h, g;
|
|
2640
|
+
if (p.content === "table") {
|
|
2592
2641
|
let e = st.get(d.blockContent.node);
|
|
2593
|
-
|
|
2594
|
-
} else
|
|
2595
|
-
if (
|
|
2596
|
-
let
|
|
2597
|
-
|
|
2598
|
-
} else
|
|
2599
|
-
|
|
2642
|
+
h = d.blockContent.beforePos + e.positionAt(0, 0, d.blockContent.node) + 1 + 2;
|
|
2643
|
+
} else h = d.blockContent.beforePos + 1;
|
|
2644
|
+
if (m.content === "table") {
|
|
2645
|
+
let t = st.get(f.blockContent.node), n = f.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, f.blockContent.node) + 1;
|
|
2646
|
+
g = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
2647
|
+
} else g = f.blockContent.afterPos - 1;
|
|
2648
|
+
e.setSelection(N.create(e.doc, h, g));
|
|
2600
2649
|
}
|
|
2601
2650
|
function ji(e, t = !1) {
|
|
2602
|
-
let n = t ? Oi(e.doc, e.selection) : e.selection,
|
|
2651
|
+
let n = t ? Oi(e.doc, e.selection) : e.selection, i = n.$from, a = n.$to;
|
|
2603
2652
|
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
2604
2653
|
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
2605
|
-
for (;
|
|
2606
|
-
for (;
|
|
2607
|
-
let o =
|
|
2654
|
+
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
2655
|
+
for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
|
|
2656
|
+
let o = r(e.doc.slice(i.pos, a.pos, !0));
|
|
2608
2657
|
return {
|
|
2609
2658
|
_meta: {
|
|
2610
|
-
startPos:
|
|
2659
|
+
startPos: i.pos,
|
|
2611
2660
|
endPos: a.pos
|
|
2612
2661
|
},
|
|
2613
2662
|
...o
|
|
@@ -2630,19 +2679,19 @@ var Mi = class {
|
|
|
2630
2679
|
return this.editor.transact((n) => Ai(n, e, t));
|
|
2631
2680
|
}
|
|
2632
2681
|
getTextCursorPosition() {
|
|
2633
|
-
return this.editor.transact((e) =>
|
|
2682
|
+
return this.editor.transact((e) => ir(e));
|
|
2634
2683
|
}
|
|
2635
2684
|
setTextCursorPosition(e, t = "start") {
|
|
2636
|
-
return this.editor.transact((n) =>
|
|
2685
|
+
return this.editor.transact((n) => ar(n, e, t));
|
|
2637
2686
|
}
|
|
2638
2687
|
getSelectionBoundingBox() {
|
|
2639
2688
|
if (!this.editor.prosemirrorView) return;
|
|
2640
2689
|
let { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((e) => e.$from.pos)), r = Math.max(...t.map((e) => e.$to.pos));
|
|
2641
|
-
if (
|
|
2690
|
+
if (nt(e)) {
|
|
2642
2691
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
2643
2692
|
if (e) return e.getBoundingClientRect();
|
|
2644
2693
|
}
|
|
2645
|
-
return
|
|
2694
|
+
return it(this.editor.prosemirrorView, n, r).toJSON();
|
|
2646
2695
|
}
|
|
2647
2696
|
}, Ni = class {
|
|
2648
2697
|
editor;
|
|
@@ -2737,7 +2786,7 @@ function Pi(e, t, n, r = { updateSelection: !0 }) {
|
|
|
2737
2786
|
let { parent: t } = e.doc.resolve(i);
|
|
2738
2787
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
2739
2788
|
}
|
|
2740
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2789
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && at(e, e.steps.length - 1, -1), !0;
|
|
2741
2790
|
}
|
|
2742
2791
|
//#endregion
|
|
2743
2792
|
//#region src/editor/managers/StyleManager.ts
|
|
@@ -2747,7 +2796,7 @@ var Fi = class {
|
|
|
2747
2796
|
this.editor = e;
|
|
2748
2797
|
}
|
|
2749
2798
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2750
|
-
let n =
|
|
2799
|
+
let n = a(e, this.editor.pmSchema);
|
|
2751
2800
|
this.editor.transact((e) => {
|
|
2752
2801
|
Pi(e, {
|
|
2753
2802
|
from: e.selection.from,
|
|
@@ -2757,7 +2806,7 @@ var Fi = class {
|
|
|
2757
2806
|
}
|
|
2758
2807
|
getActiveStyles() {
|
|
2759
2808
|
return this.editor.transact((e) => {
|
|
2760
|
-
let t = {}, n = e.selection.$to.marks();
|
|
2809
|
+
let t = {}, n = e.selection.empty && e.storedMarks || e.selection.$to.marks();
|
|
2761
2810
|
for (let e of n) {
|
|
2762
2811
|
let n = this.editor.schema.styleSchema[e.type.name];
|
|
2763
2812
|
if (!n) {
|
|
@@ -2775,7 +2824,7 @@ var Fi = class {
|
|
|
2775
2824
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2776
2825
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
|
|
2777
2826
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
|
|
2778
|
-
else throw new
|
|
2827
|
+
else throw new _(e.propSchema);
|
|
2779
2828
|
}
|
|
2780
2829
|
}
|
|
2781
2830
|
removeStyles(e) {
|
|
@@ -2787,7 +2836,7 @@ var Fi = class {
|
|
|
2787
2836
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2788
2837
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2789
2838
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
|
|
2790
|
-
else throw new
|
|
2839
|
+
else throw new _(e.propSchema);
|
|
2791
2840
|
}
|
|
2792
2841
|
}
|
|
2793
2842
|
getSelectedText() {
|
|
@@ -2795,19 +2844,19 @@ var Fi = class {
|
|
|
2795
2844
|
}
|
|
2796
2845
|
getLinkMarkAtPos(e) {
|
|
2797
2846
|
return this.editor.transact((t) => {
|
|
2798
|
-
let n =
|
|
2847
|
+
let n = this.editor.pmSchema.marks.link, r = $e(t.doc.resolve(e), n);
|
|
2799
2848
|
if (!r) return;
|
|
2800
|
-
let i =
|
|
2849
|
+
let i = t.doc.nodeAt(r.from)?.marks.find((e) => e.type === n);
|
|
2801
2850
|
if (i) return {
|
|
2802
|
-
href:
|
|
2803
|
-
from:
|
|
2804
|
-
to:
|
|
2805
|
-
text: t.doc.textBetween(
|
|
2851
|
+
href: i.attrs.href,
|
|
2852
|
+
from: r.from,
|
|
2853
|
+
to: r.to,
|
|
2854
|
+
text: t.doc.textBetween(r.from, r.to)
|
|
2806
2855
|
};
|
|
2807
2856
|
});
|
|
2808
2857
|
}
|
|
2809
2858
|
getSelectedLinkUrl() {
|
|
2810
|
-
return this.editor.transact((e) =>
|
|
2859
|
+
return this.editor.transact((e) => (e.doc.nodeAt(e.selection.from)?.marks.find((e) => e.type.name === "link"))?.attrs.href);
|
|
2811
2860
|
}
|
|
2812
2861
|
createLink(e, t) {
|
|
2813
2862
|
e !== "" && this.editor.transact((n) => {
|
|
@@ -2817,7 +2866,7 @@ var Fi = class {
|
|
|
2817
2866
|
}
|
|
2818
2867
|
editLink(e, t, n = this.editor.transact((e) => e.selection.anchor)) {
|
|
2819
2868
|
this.editor.transact((r) => {
|
|
2820
|
-
let { from: i, to: a } = this.getLinkMarkAtPos(n
|
|
2869
|
+
let { from: i, to: a } = this.getLinkMarkAtPos(n) || {
|
|
2821
2870
|
from: r.selection.from,
|
|
2822
2871
|
to: r.selection.to
|
|
2823
2872
|
}, o = this.editor.pmSchema.mark("link", { href: e });
|
|
@@ -2826,7 +2875,7 @@ var Fi = class {
|
|
|
2826
2875
|
}
|
|
2827
2876
|
deleteLink(e = this.editor.transact((e) => e.selection.anchor)) {
|
|
2828
2877
|
this.editor.transact((t) => {
|
|
2829
|
-
let { from: n, to: r } = this.getLinkMarkAtPos(e
|
|
2878
|
+
let { from: n, to: r } = this.getLinkMarkAtPos(e) || {
|
|
2830
2879
|
from: t.selection.from,
|
|
2831
2880
|
to: t.selection.to
|
|
2832
2881
|
};
|
|
@@ -2837,10 +2886,10 @@ var Fi = class {
|
|
|
2837
2886
|
//#endregion
|
|
2838
2887
|
//#region src/editor/transformPasted.ts
|
|
2839
2888
|
function Ii(e) {
|
|
2840
|
-
return
|
|
2889
|
+
return Xe(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
2841
2890
|
}
|
|
2842
2891
|
function Li(e, t) {
|
|
2843
|
-
let n = t.nodes.hardBreak, r =
|
|
2892
|
+
let n = t.nodes.hardBreak, r = P.empty;
|
|
2844
2893
|
return e.forEach((e) => {
|
|
2845
2894
|
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(Li(e.content, t)), r = r.addToEnd(n.create()));
|
|
2846
2895
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
@@ -2849,7 +2898,7 @@ function Ri(e, t) {
|
|
|
2849
2898
|
let n = [];
|
|
2850
2899
|
return e.forEach((e, r, i) => {
|
|
2851
2900
|
i !== t && n.push(e);
|
|
2852
|
-
}),
|
|
2901
|
+
}), P.from(n);
|
|
2853
2902
|
}
|
|
2854
2903
|
function zi(e, t) {
|
|
2855
2904
|
let n = [];
|
|
@@ -2862,10 +2911,10 @@ function zi(e, t) {
|
|
|
2862
2911
|
n.push(i);
|
|
2863
2912
|
}
|
|
2864
2913
|
} else n.push(e.child(r));
|
|
2865
|
-
return e =
|
|
2914
|
+
return e = P.from(n), e;
|
|
2866
2915
|
}
|
|
2867
2916
|
function Bi(e, t) {
|
|
2868
|
-
let n =
|
|
2917
|
+
let n = P.from(e.content);
|
|
2869
2918
|
n = zi(n, t.state.schema);
|
|
2870
2919
|
let r = Vi(n, t, e);
|
|
2871
2920
|
if (r) return r;
|
|
@@ -2873,9 +2922,9 @@ function Bi(e, t) {
|
|
|
2873
2922
|
let e = !1;
|
|
2874
2923
|
if (n.descendants((t) => {
|
|
2875
2924
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
2876
|
-
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new
|
|
2925
|
+
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new F(Li(n, t.state.schema), 0, 0);
|
|
2877
2926
|
}
|
|
2878
|
-
if (!Hi(n, t)) return new
|
|
2927
|
+
if (!Hi(n, t)) return new F(n, e.openStart, e.openEnd);
|
|
2879
2928
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
2880
2929
|
let r = [n.child(e)];
|
|
2881
2930
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
@@ -2885,23 +2934,23 @@ function Bi(e, t) {
|
|
|
2885
2934
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2886
2935
|
n = n.replaceChild(e, i);
|
|
2887
2936
|
}
|
|
2888
|
-
return new
|
|
2937
|
+
return new F(n, e.openStart, e.openEnd);
|
|
2889
2938
|
}
|
|
2890
2939
|
function Vi(e, t, n) {
|
|
2891
2940
|
if (Ii(t) || t.dragging) return null;
|
|
2892
|
-
let r =
|
|
2941
|
+
let r = v(t.state), i = r.isBlockContainer ? r.blockContent.node : null;
|
|
2893
2942
|
if (!i || i.type.name === "paragraph" || i.type.spec.content !== "inline*" || i.childCount > 0) return null;
|
|
2894
2943
|
let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
2895
2944
|
if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
|
|
2896
2945
|
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));
|
|
2897
|
-
return new
|
|
2946
|
+
return new F(e.replaceChild(0, u), n.openStart, n.openEnd);
|
|
2898
2947
|
}
|
|
2899
2948
|
function Hi(e, t) {
|
|
2900
2949
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2901
2950
|
if (n) {
|
|
2902
2951
|
if (r) return !1;
|
|
2903
2952
|
if (i) {
|
|
2904
|
-
let e =
|
|
2953
|
+
let e = v(t.state);
|
|
2905
2954
|
if (e.isBlockContainer) return e.blockContent.node.type.spec.content !== "tableRow+";
|
|
2906
2955
|
}
|
|
2907
2956
|
}
|
|
@@ -2913,7 +2962,7 @@ var Ui = {
|
|
|
2913
2962
|
enableInputRules: !0,
|
|
2914
2963
|
enablePasteRules: !0,
|
|
2915
2964
|
enableCoreExtensions: !1
|
|
2916
|
-
}, Wi = class e extends
|
|
2965
|
+
}, Wi = class e extends H {
|
|
2917
2966
|
options;
|
|
2918
2967
|
pmSchema;
|
|
2919
2968
|
_tiptapEditor;
|
|
@@ -2933,7 +2982,7 @@ var Ui = {
|
|
|
2933
2982
|
return new e(t ?? {});
|
|
2934
2983
|
}
|
|
2935
2984
|
constructor(e) {
|
|
2936
|
-
super(), this.options = e, this.dictionary = e.dictionary ||
|
|
2985
|
+
super(), this.options = e, this.dictionary = e.dictionary || Re, this.settings = { tables: {
|
|
2937
2986
|
splitCells: e?.tables?.splitCells ?? !1,
|
|
2938
2987
|
cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
|
|
2939
2988
|
cellTextColor: e?.tables?.cellTextColor ?? !1,
|
|
@@ -2941,7 +2990,7 @@ var Ui = {
|
|
|
2941
2990
|
} };
|
|
2942
2991
|
let t = {
|
|
2943
2992
|
defaultStyles: !0,
|
|
2944
|
-
schema: e.schema ||
|
|
2993
|
+
schema: e.schema || pe.create(),
|
|
2945
2994
|
...e,
|
|
2946
2995
|
placeholders: {
|
|
2947
2996
|
...this.dictionary.placeholders,
|
|
@@ -2959,7 +3008,7 @@ var Ui = {
|
|
|
2959
3008
|
}
|
|
2960
3009
|
};
|
|
2961
3010
|
}
|
|
2962
|
-
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new
|
|
3011
|
+
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new on(this), this._extensionManager = new Di(this, t);
|
|
2963
3012
|
let n = this._extensionManager.getTiptapExtensions(), r = {
|
|
2964
3013
|
...Ui,
|
|
2965
3014
|
...t._tiptapOptions,
|
|
@@ -2978,7 +3027,7 @@ var Ui = {
|
|
|
2978
3027
|
tabIndex: "0",
|
|
2979
3028
|
...t._tiptapOptions?.editorProps?.attributes,
|
|
2980
3029
|
...t.domAttributes?.editor,
|
|
2981
|
-
class:
|
|
3030
|
+
class: h("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
|
|
2982
3031
|
},
|
|
2983
3032
|
transformPasted: Bi
|
|
2984
3033
|
}
|
|
@@ -2986,19 +3035,19 @@ var Ui = {
|
|
|
2986
3035
|
try {
|
|
2987
3036
|
let e = t.initialContent || [{
|
|
2988
3037
|
type: "paragraph",
|
|
2989
|
-
id:
|
|
3038
|
+
id: ie.options.generateID()
|
|
2990
3039
|
}];
|
|
2991
3040
|
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + JSON.stringify(e));
|
|
2992
|
-
let n =
|
|
3041
|
+
let n = tt(r.extensions);
|
|
2993
3042
|
n.cached.blockNoteEditor = this;
|
|
2994
|
-
let
|
|
3043
|
+
let a = e.map((e) => i(e, n, this.schema.styleSchema).toJSON()), o = Je({
|
|
2995
3044
|
type: "doc",
|
|
2996
3045
|
content: [{
|
|
2997
3046
|
type: "blockGroup",
|
|
2998
|
-
content:
|
|
3047
|
+
content: a
|
|
2999
3048
|
}]
|
|
3000
3049
|
}, n, r.parseOptions);
|
|
3001
|
-
this._tiptapEditor = new
|
|
3050
|
+
this._tiptapEditor = new Ge({
|
|
3002
3051
|
...r,
|
|
3003
3052
|
content: o.toJSON()
|
|
3004
3053
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
@@ -3009,7 +3058,7 @@ var Ui = {
|
|
|
3009
3058
|
this.headless = !1;
|
|
3010
3059
|
}), this._tiptapEditor.on("unmount", () => {
|
|
3011
3060
|
this.headless = !0;
|
|
3012
|
-
}), this._blockManager = new
|
|
3061
|
+
}), this._blockManager = new an(this), this._exportManager = new rr(this), this._selectionManager = new Mi(this), this._stateManager = new Ni(this), this._styleManager = new Fi(this), this.emit("create");
|
|
3013
3062
|
}
|
|
3014
3063
|
_blockManager;
|
|
3015
3064
|
_eventManager;
|
|
@@ -3034,12 +3083,11 @@ var Ui = {
|
|
|
3034
3083
|
registerExtension = (...e) => this._extensionManager.registerExtension(...e);
|
|
3035
3084
|
replaceExtension = (...e) => this._extensionManager.replaceExtension(...e);
|
|
3036
3085
|
getExtension = ((e) => this._extensionManager.getExtension(e));
|
|
3037
|
-
mount = (e
|
|
3038
|
-
|
|
3039
|
-
(t?.portalTarget ?? e.parentElement ?? (r ? n : document.body)).appendChild(this.portalElement), this._tiptapEditor.mount({ mount: e });
|
|
3086
|
+
mount = (e) => {
|
|
3087
|
+
this._tiptapEditor.mount({ mount: e });
|
|
3040
3088
|
};
|
|
3041
3089
|
unmount = () => {
|
|
3042
|
-
this.
|
|
3090
|
+
this._tiptapEditor.unmount();
|
|
3043
3091
|
};
|
|
3044
3092
|
get prosemirrorState() {
|
|
3045
3093
|
return this._stateManager.prosemirrorState;
|
|
@@ -3050,14 +3098,25 @@ var Ui = {
|
|
|
3050
3098
|
get domElement() {
|
|
3051
3099
|
if (!this.headless) return this.prosemirrorView?.dom;
|
|
3052
3100
|
}
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3101
|
+
_portalElements = /* @__PURE__ */ new Map();
|
|
3102
|
+
registerPortalElement = (e) => {
|
|
3103
|
+
this._portalElements.set(e, (this._portalElements.get(e) ?? 0) + 1);
|
|
3104
|
+
};
|
|
3105
|
+
unregisterPortalElement = (e) => {
|
|
3106
|
+
let t = this._portalElements.get(e);
|
|
3107
|
+
t !== void 0 && (t <= 1 ? this._portalElements.delete(e) : this._portalElements.set(e, t - 1));
|
|
3108
|
+
};
|
|
3109
|
+
isWithinEditor = (e) => {
|
|
3110
|
+
if (this.domElement?.parentElement?.contains(e)) return !0;
|
|
3111
|
+
for (let t of this._portalElements.keys()) if (t.contains(e)) return !0;
|
|
3112
|
+
return !1;
|
|
3113
|
+
};
|
|
3114
|
+
isFocused(e) {
|
|
3115
|
+
if (this.headless) return !1;
|
|
3116
|
+
let t = this.prosemirrorView?.hasFocus() || !1;
|
|
3117
|
+
if (!e?.includeEditorUI) return t;
|
|
3118
|
+
let n = typeof document < "u" ? document.activeElement : null;
|
|
3119
|
+
return t || !!n && this.isWithinEditor(n);
|
|
3061
3120
|
}
|
|
3062
3121
|
headless = !0;
|
|
3063
3122
|
focus() {
|
|
@@ -3106,7 +3165,7 @@ var Ui = {
|
|
|
3106
3165
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
3107
3166
|
}
|
|
3108
3167
|
onBeforeChange(e) {
|
|
3109
|
-
return this._extensionManager.getExtension(
|
|
3168
|
+
return this._extensionManager.getExtension(Se).subscribe(e);
|
|
3110
3169
|
}
|
|
3111
3170
|
getTextCursorPosition() {
|
|
3112
3171
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -3219,6 +3278,9 @@ var Ui = {
|
|
|
3219
3278
|
onSelectionChange(e, t) {
|
|
3220
3279
|
return this._eventManager.onSelectionChange(e, t);
|
|
3221
3280
|
}
|
|
3281
|
+
onFocusChange(e, t) {
|
|
3282
|
+
return this._eventManager.onFocusChange(e, t);
|
|
3283
|
+
}
|
|
3222
3284
|
onMount(e) {
|
|
3223
3285
|
return this._eventManager.onMount(e);
|
|
3224
3286
|
}
|
|
@@ -3248,7 +3310,7 @@ var Ui = {
|
|
|
3248
3310
|
this.mappings = t, this.options = n;
|
|
3249
3311
|
}
|
|
3250
3312
|
get dictionary() {
|
|
3251
|
-
return this.options.dictionary?.exporter ??
|
|
3313
|
+
return this.options.dictionary?.exporter ?? Re.exporter;
|
|
3252
3314
|
}
|
|
3253
3315
|
async resolveFile(e) {
|
|
3254
3316
|
if (!this.options?.resolveFileUrl) return this.fetchBlob(e);
|
|
@@ -3312,6 +3374,6 @@ function Yi(e, ...t) {
|
|
|
3312
3374
|
return n;
|
|
3313
3375
|
}
|
|
3314
3376
|
//#endregion
|
|
3315
|
-
export {
|
|
3377
|
+
export { gt as A, B as C, L as D, St as E, xt as O, Nt as S, R as T, It as _, Gi as a, V as b, Ar as c, G as d, en as f, H as g, tn as h, qi as i, bt as k, nr as l, rn as m, Ji as n, Wi as o, nn as p, Ki as r, Oi as s, Yi as t, tr as u, Lt as v, z as w, Rt as x, Ft as y };
|
|
3316
3378
|
|
|
3317
|
-
//# sourceMappingURL=src-
|
|
3379
|
+
//# sourceMappingURL=src-D5w0XAHX.js.map
|