@blocknote/core 0.12.0 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +958 -940
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/api/getCurrentBlockContentType.ts +14 -0
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +50 -21
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +1 -1
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +18 -5
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +7 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +18 -5
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +14 -5
- package/src/editor/BlockNoteEditor.ts +14 -14
- package/src/editor/editor.css +0 -1
- package/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.ts +14 -14
- package/src/extensions/{HyperlinkToolbar/HyperlinkToolbarPlugin.ts → LinkToolbar/LinkToolbarPlugin.ts} +87 -91
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +1 -1
- package/src/index.ts +2 -2
- package/types/src/api/getCurrentBlockContentType.d.ts +2 -0
- package/types/src/editor/BlockNoteEditor.d.ts +5 -5
- package/types/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.d.ts +6 -6
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +40 -0
- package/types/src/index.d.ts +2 -2
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +0 -38
package/dist/blocknote.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (n, t, e) => (
|
|
4
|
-
import { Slice as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { unified as
|
|
8
|
-
import { Extension as M, combineTransactionSteps as
|
|
9
|
-
import { Plugin as v, PluginKey as
|
|
1
|
+
var me = Object.defineProperty;
|
|
2
|
+
var fe = (n, t, e) => t in n ? me(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var d = (n, t, e) => (fe(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { Slice as U, Fragment as T, DOMSerializer as bt, DOMParser as ge, Node as be } from "prosemirror-model";
|
|
5
|
+
import zt from "rehype-parse";
|
|
6
|
+
import Vt from "rehype-stringify";
|
|
7
|
+
import { unified as kt } from "unified";
|
|
8
|
+
import { Extension as M, combineTransactionSteps as ke, getChangedRanges as ye, findChildrenInRange as we, Node as W, Mark as yt, InputRule as wt, callOrReturn as ve, getExtensionField as Ee, mergeAttributes as Se, selectionToInsertionEnd as Ce, isNodeSelection as xe, posToDOMRect as ft, getMarkRange as Mt, findParentNode as Te, findChildren as Bt, extensions as X, Editor as Me, createDocument as Be } from "@tiptap/core";
|
|
9
|
+
import { Plugin as v, PluginKey as x, Selection as ut, NodeSelection as it, TextSelection as ot, EditorState as Le } from "prosemirror-state";
|
|
10
10
|
import { v4 as Ie } from "uuid";
|
|
11
|
-
import { fromDom as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
11
|
+
import { fromDom as Lt } from "hast-util-from-dom";
|
|
12
|
+
import Ne from "@tiptap/extension-bold";
|
|
13
|
+
import Ae from "@tiptap/extension-code";
|
|
14
|
+
import Pe from "@tiptap/extension-italic";
|
|
15
15
|
import He from "@tiptap/extension-strike";
|
|
16
|
-
import
|
|
17
|
-
import { TableCell as
|
|
18
|
-
import { TableHeader as
|
|
19
|
-
import { TableRow as
|
|
20
|
-
import { columnResizing as
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import { DecorationSet as
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import { Dropcursor as
|
|
30
|
-
import { Gapcursor as
|
|
31
|
-
import { HardBreak as
|
|
32
|
-
import { History as
|
|
33
|
-
import { Link as
|
|
34
|
-
import { Text as
|
|
35
|
-
function
|
|
16
|
+
import De from "@tiptap/extension-underline";
|
|
17
|
+
import { TableCell as Oe } from "@tiptap/extension-table-cell";
|
|
18
|
+
import { TableHeader as _e } from "@tiptap/extension-table-header";
|
|
19
|
+
import { TableRow as Ue } from "@tiptap/extension-table-row";
|
|
20
|
+
import { columnResizing as Re, tableEditing as ze } from "prosemirror-tables";
|
|
21
|
+
import Ve from "rehype-remark";
|
|
22
|
+
import Ft from "remark-gfm";
|
|
23
|
+
import Fe from "remark-stringify";
|
|
24
|
+
import $e from "remark-parse";
|
|
25
|
+
import Ge, { defaultHandlers as je } from "remark-rehype";
|
|
26
|
+
import { DecorationSet as G, Decoration as j, EditorView as We } from "prosemirror-view";
|
|
27
|
+
import qe from "@tiptap/extension-collaboration";
|
|
28
|
+
import Ke from "@tiptap/extension-collaboration-cursor";
|
|
29
|
+
import { Dropcursor as Je } from "@tiptap/extension-dropcursor";
|
|
30
|
+
import { Gapcursor as Xe } from "@tiptap/extension-gapcursor";
|
|
31
|
+
import { HardBreak as Ye } from "@tiptap/extension-hard-break";
|
|
32
|
+
import { History as Qe } from "@tiptap/extension-history";
|
|
33
|
+
import { Link as Ze } from "@tiptap/extension-link";
|
|
34
|
+
import { Text as tn } from "@tiptap/extension-text";
|
|
35
|
+
function en(n, t = JSON.stringify) {
|
|
36
36
|
const e = {};
|
|
37
37
|
return n.filter((o) => {
|
|
38
38
|
const r = t(o);
|
|
39
39
|
return Object.prototype.hasOwnProperty.call(e, r) ? !1 : e[r] = !0;
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function nn(n) {
|
|
43
43
|
const t = n.filter(
|
|
44
44
|
(o, r) => n.indexOf(o) !== r
|
|
45
45
|
);
|
|
46
|
-
return
|
|
46
|
+
return en(t);
|
|
47
47
|
}
|
|
48
|
-
const
|
|
48
|
+
const Z = M.create({
|
|
49
49
|
name: "uniqueID",
|
|
50
50
|
// we’ll set a very high priority to make sure this runs first
|
|
51
51
|
// and is compatible with `appendTransaction` hooks of other extensions
|
|
@@ -114,51 +114,51 @@ const Q = M.create({
|
|
|
114
114
|
let n = null, t = !1;
|
|
115
115
|
return [
|
|
116
116
|
new v({
|
|
117
|
-
key: new
|
|
117
|
+
key: new x("uniqueID"),
|
|
118
118
|
appendTransaction: (e, o, r) => {
|
|
119
119
|
const i = e.some((f) => f.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && e.some((f) => {
|
|
120
|
-
let
|
|
121
|
-
return !(!((S = (
|
|
120
|
+
let k, S;
|
|
121
|
+
return !(!((S = (k = this.options).filterTransaction) === null || S === void 0) && S.call(k, f));
|
|
122
122
|
});
|
|
123
123
|
if (!i || s)
|
|
124
124
|
return;
|
|
125
|
-
const { tr: a } = r, { types: l, attributeName: c, generateID:
|
|
125
|
+
const { tr: a } = r, { types: l, attributeName: c, generateID: u } = this.options, p = ke(
|
|
126
126
|
o.doc,
|
|
127
127
|
e
|
|
128
|
-
), { mapping: m } =
|
|
129
|
-
if (ye(
|
|
130
|
-
const
|
|
128
|
+
), { mapping: m } = p;
|
|
129
|
+
if (ye(p).forEach(({ newRange: f }) => {
|
|
130
|
+
const k = we(
|
|
131
131
|
r.doc,
|
|
132
132
|
f,
|
|
133
133
|
(E) => l.includes(E.type.name)
|
|
134
|
-
), S =
|
|
135
|
-
|
|
136
|
-
let
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
const
|
|
140
|
-
if (o.doc.content.findDiffStart(
|
|
141
|
-
const
|
|
134
|
+
), S = k.map(({ node: E }) => E.attrs[c]).filter((E) => E !== null), B = nn(S);
|
|
135
|
+
k.forEach(({ node: E, pos: O }) => {
|
|
136
|
+
let V;
|
|
137
|
+
const J = (V = a.doc.nodeAt(O)) === null || V === void 0 ? void 0 : V.attrs[c];
|
|
138
|
+
if (J === null) {
|
|
139
|
+
const ct = o.doc.type.createAndFill().content;
|
|
140
|
+
if (o.doc.content.findDiffStart(ct) === null) {
|
|
141
|
+
const nt = JSON.parse(
|
|
142
142
|
JSON.stringify(r.doc.toJSON())
|
|
143
143
|
);
|
|
144
|
-
if (
|
|
145
|
-
a.setNodeMarkup(
|
|
144
|
+
if (nt.content[0].content[0].attrs.id = "initialBlockId", JSON.stringify(nt.content) === JSON.stringify(ct.toJSON())) {
|
|
145
|
+
a.setNodeMarkup(O, void 0, {
|
|
146
146
|
...E.attrs,
|
|
147
147
|
[c]: "initialBlockId"
|
|
148
148
|
});
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
a.setNodeMarkup(
|
|
152
|
+
a.setNodeMarkup(O, void 0, {
|
|
153
153
|
...E.attrs,
|
|
154
|
-
[c]:
|
|
154
|
+
[c]: u()
|
|
155
155
|
});
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
const { deleted: g } = m.invert().mapResult(
|
|
159
|
-
g && B.includes(
|
|
158
|
+
const { deleted: g } = m.invert().mapResult(O);
|
|
159
|
+
g && B.includes(J) && a.setNodeMarkup(O, void 0, {
|
|
160
160
|
...E.attrs,
|
|
161
|
-
[c]:
|
|
161
|
+
[c]: u()
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
164
|
}), !!a.steps.length)
|
|
@@ -214,9 +214,9 @@ const Q = M.create({
|
|
|
214
214
|
l.marks
|
|
215
215
|
);
|
|
216
216
|
a.push(c);
|
|
217
|
-
}),
|
|
217
|
+
}), T.from(a);
|
|
218
218
|
};
|
|
219
|
-
return t = !1, new
|
|
219
|
+
return t = !1, new U(
|
|
220
220
|
i(e.content),
|
|
221
221
|
e.openStart,
|
|
222
222
|
e.openEnd
|
|
@@ -227,7 +227,7 @@ const Q = M.create({
|
|
|
227
227
|
];
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
|
-
function
|
|
230
|
+
function $t(n) {
|
|
231
231
|
const t = n.attrs.id, e = n.firstChild, o = e.type, r = n.childCount === 2 ? n.lastChild.childCount : 0;
|
|
232
232
|
return {
|
|
233
233
|
id: t,
|
|
@@ -257,13 +257,13 @@ function b(n, t) {
|
|
|
257
257
|
break;
|
|
258
258
|
a -= 1, s = r.node(a);
|
|
259
259
|
}
|
|
260
|
-
const { id: l, contentNode: c, contentType:
|
|
260
|
+
const { id: l, contentNode: c, contentType: u, numChildBlocks: p } = $t(s), m = r.start(a), h = r.end(a);
|
|
261
261
|
return {
|
|
262
262
|
id: l,
|
|
263
263
|
node: s,
|
|
264
264
|
contentNode: c,
|
|
265
|
-
contentType:
|
|
266
|
-
numChildBlocks:
|
|
265
|
+
contentType: u,
|
|
266
|
+
numChildBlocks: p,
|
|
267
267
|
startPos: m,
|
|
268
268
|
endPos: h,
|
|
269
269
|
depth: a
|
|
@@ -272,18 +272,18 @@ function b(n, t) {
|
|
|
272
272
|
function It(n) {
|
|
273
273
|
return n.type === "link";
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function Gt(n) {
|
|
276
276
|
return typeof n != "string" && n.type === "link";
|
|
277
277
|
}
|
|
278
|
-
function
|
|
278
|
+
function Q(n) {
|
|
279
279
|
return typeof n != "string" && n.type === "text";
|
|
280
280
|
}
|
|
281
|
-
class
|
|
281
|
+
class A extends Error {
|
|
282
282
|
constructor(t) {
|
|
283
283
|
super(`Unreachable case: ${t}`);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function Nt(n, t, e) {
|
|
287
287
|
const o = [];
|
|
288
288
|
for (const [r, i] of Object.entries(n.styles)) {
|
|
289
289
|
const s = e[r];
|
|
@@ -294,16 +294,16 @@ function Lt(n, t, e) {
|
|
|
294
294
|
else if (s.propSchema === "string")
|
|
295
295
|
o.push(t.mark(r, { stringValue: i }));
|
|
296
296
|
else
|
|
297
|
-
throw new
|
|
297
|
+
throw new A(s.propSchema);
|
|
298
298
|
}
|
|
299
299
|
return n.text.split(/(\n)/g).filter((r) => r.length > 0).map((r) => r === `
|
|
300
300
|
` ? t.nodes.hardBreak.create() : t.text(r, o));
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function on(n, t, e) {
|
|
303
303
|
const o = t.marks.link.create({
|
|
304
304
|
href: n.href
|
|
305
305
|
});
|
|
306
|
-
return
|
|
306
|
+
return gt(n.content, t, e).map(
|
|
307
307
|
(r) => {
|
|
308
308
|
if (r.type.name === "text")
|
|
309
309
|
return r.mark([...r.marks, o]);
|
|
@@ -313,29 +313,29 @@ function nn(n, t, e) {
|
|
|
313
313
|
}
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function gt(n, t, e) {
|
|
317
317
|
const o = [];
|
|
318
318
|
if (typeof n == "string")
|
|
319
319
|
return o.push(
|
|
320
|
-
...
|
|
320
|
+
...Nt(
|
|
321
321
|
{ type: "text", text: n, styles: {} },
|
|
322
322
|
t,
|
|
323
323
|
e
|
|
324
324
|
)
|
|
325
325
|
), o;
|
|
326
326
|
for (const r of n)
|
|
327
|
-
o.push(...
|
|
327
|
+
o.push(...Nt(r, t, e));
|
|
328
328
|
return o;
|
|
329
329
|
}
|
|
330
|
-
function
|
|
330
|
+
function at(n, t, e) {
|
|
331
331
|
const o = [];
|
|
332
332
|
for (const r of n)
|
|
333
|
-
typeof r == "string" ? o.push(...
|
|
334
|
-
|
|
333
|
+
typeof r == "string" ? o.push(...gt(r, t, e)) : Gt(r) ? o.push(...on(r, t, e)) : Q(r) ? o.push(...gt([r], t, e)) : o.push(
|
|
334
|
+
Wt(r, t, e)
|
|
335
335
|
);
|
|
336
336
|
return o;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function jt(n, t, e) {
|
|
339
339
|
const o = [];
|
|
340
340
|
for (const r of n.rows) {
|
|
341
341
|
const i = [];
|
|
@@ -346,8 +346,8 @@ function Gt(n, t, e) {
|
|
|
346
346
|
else if (typeof a == "string")
|
|
347
347
|
l = t.nodes.tableParagraph.create({}, t.text(a));
|
|
348
348
|
else {
|
|
349
|
-
const
|
|
350
|
-
l = t.nodes.tableParagraph.create({},
|
|
349
|
+
const u = at(a, t, e);
|
|
350
|
+
l = t.nodes.tableParagraph.create({}, u);
|
|
351
351
|
}
|
|
352
352
|
const c = t.nodes.tableCell.create({}, l);
|
|
353
353
|
i.push(c);
|
|
@@ -357,7 +357,7 @@ function Gt(n, t, e) {
|
|
|
357
357
|
}
|
|
358
358
|
return o;
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function Wt(n, t, e) {
|
|
361
361
|
let o, r = n.type;
|
|
362
362
|
if (r === void 0 && (r = "paragraph"), !t.nodes[r])
|
|
363
363
|
throw new Error(`node type ${r} not found in schema`);
|
|
@@ -369,26 +369,26 @@ function jt(n, t, e) {
|
|
|
369
369
|
t.text(n.content)
|
|
370
370
|
);
|
|
371
371
|
else if (Array.isArray(n.content)) {
|
|
372
|
-
const i =
|
|
372
|
+
const i = at(n.content, t, e);
|
|
373
373
|
o = t.nodes[r].create(n.props, i);
|
|
374
374
|
} else if (n.content.type === "tableContent") {
|
|
375
|
-
const i =
|
|
375
|
+
const i = jt(n.content, t, e);
|
|
376
376
|
o = t.nodes[r].create(n.props, i);
|
|
377
377
|
} else
|
|
378
|
-
throw new
|
|
378
|
+
throw new A(n.content.type);
|
|
379
379
|
return o;
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function D(n, t, e) {
|
|
382
382
|
let o = n.id;
|
|
383
|
-
o === void 0 && (o =
|
|
384
|
-
const r =
|
|
383
|
+
o === void 0 && (o = Z.options.generateID());
|
|
384
|
+
const r = Wt(
|
|
385
385
|
n,
|
|
386
386
|
t,
|
|
387
387
|
e
|
|
388
388
|
), i = [];
|
|
389
389
|
if (n.children)
|
|
390
390
|
for (const a of n.children)
|
|
391
|
-
i.push(
|
|
391
|
+
i.push(D(a, t, e));
|
|
392
392
|
const s = t.nodes.blockGroup.create({}, i);
|
|
393
393
|
return t.nodes.blockContainer.create(
|
|
394
394
|
{
|
|
@@ -398,7 +398,7 @@ function P(n, t, e) {
|
|
|
398
398
|
i.length > 0 ? [r, s] : r
|
|
399
399
|
);
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function rn(n, t, e) {
|
|
402
402
|
const o = {
|
|
403
403
|
type: "tableContent",
|
|
404
404
|
rows: []
|
|
@@ -409,7 +409,7 @@ function on(n, t, e) {
|
|
|
409
409
|
};
|
|
410
410
|
r.content.forEach((s) => {
|
|
411
411
|
i.cells.push(
|
|
412
|
-
|
|
412
|
+
vt(
|
|
413
413
|
s.firstChild,
|
|
414
414
|
t,
|
|
415
415
|
e
|
|
@@ -418,13 +418,13 @@ function on(n, t, e) {
|
|
|
418
418
|
}), o.rows.push(i);
|
|
419
419
|
}), o;
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function vt(n, t, e) {
|
|
422
422
|
const o = [];
|
|
423
423
|
let r;
|
|
424
424
|
return n.content.forEach((i) => {
|
|
425
425
|
if (i.type.name === "hardBreak") {
|
|
426
426
|
if (r)
|
|
427
|
-
if (
|
|
427
|
+
if (Q(r))
|
|
428
428
|
r.text += `
|
|
429
429
|
`;
|
|
430
430
|
else if (It(r))
|
|
@@ -443,7 +443,7 @@ function wt(n, t, e) {
|
|
|
443
443
|
}
|
|
444
444
|
if (i.type.name !== "link" && i.type.name !== "text" && t[i.type.name]) {
|
|
445
445
|
r && (o.push(r), r = void 0), o.push(
|
|
446
|
-
|
|
446
|
+
qt(i, t, e)
|
|
447
447
|
);
|
|
448
448
|
return;
|
|
449
449
|
}
|
|
@@ -461,9 +461,9 @@ function wt(n, t, e) {
|
|
|
461
461
|
else if (c.propSchema === "string")
|
|
462
462
|
s[c.type] = l.attrs.stringValue;
|
|
463
463
|
else
|
|
464
|
-
throw new
|
|
464
|
+
throw new A(c.propSchema);
|
|
465
465
|
}
|
|
466
|
-
r ?
|
|
466
|
+
r ? Q(r) ? a ? (o.push(r), r = {
|
|
467
467
|
type: "link",
|
|
468
468
|
href: a.attrs.href,
|
|
469
469
|
content: [
|
|
@@ -514,7 +514,7 @@ function wt(n, t, e) {
|
|
|
514
514
|
};
|
|
515
515
|
}), r && o.push(r), o;
|
|
516
516
|
}
|
|
517
|
-
function
|
|
517
|
+
function qt(n, t, e) {
|
|
518
518
|
if (n.type.name === "text" || n.type.name === "link")
|
|
519
519
|
throw new Error("unexpected");
|
|
520
520
|
const o = {}, r = t[n.type.name];
|
|
@@ -525,7 +525,7 @@ function Wt(n, t, e) {
|
|
|
525
525
|
a in c && (o[a] = l);
|
|
526
526
|
}
|
|
527
527
|
let i;
|
|
528
|
-
return r.content === "styled" ? i =
|
|
528
|
+
return r.content === "styled" ? i = vt(
|
|
529
529
|
n,
|
|
530
530
|
t,
|
|
531
531
|
e
|
|
@@ -535,7 +535,7 @@ function Wt(n, t, e) {
|
|
|
535
535
|
content: i
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function y(n, t, e, o, r) {
|
|
539
539
|
if (n.type.name !== "blockContainer")
|
|
540
540
|
throw Error(
|
|
541
541
|
"Node must be of type blockContainer, but is of type" + n.type.name + "."
|
|
@@ -543,26 +543,26 @@ function k(n, t, e, o, r) {
|
|
|
543
543
|
const i = r == null ? void 0 : r.get(n);
|
|
544
544
|
if (i)
|
|
545
545
|
return i;
|
|
546
|
-
const s =
|
|
546
|
+
const s = $t(n);
|
|
547
547
|
let a = s.id;
|
|
548
|
-
a === null && (a =
|
|
548
|
+
a === null && (a = Z.options.generateID());
|
|
549
549
|
const l = {};
|
|
550
550
|
for (const [h, f] of Object.entries({
|
|
551
551
|
...n.attrs,
|
|
552
552
|
...s.contentNode.attrs
|
|
553
553
|
})) {
|
|
554
|
-
const
|
|
555
|
-
if (!
|
|
554
|
+
const k = t[s.contentType.name];
|
|
555
|
+
if (!k)
|
|
556
556
|
throw Error(
|
|
557
557
|
"Block is of an unrecognized type: " + s.contentType.name
|
|
558
558
|
);
|
|
559
|
-
const S =
|
|
559
|
+
const S = k.propSchema;
|
|
560
560
|
h in S && (l[h] = f);
|
|
561
561
|
}
|
|
562
|
-
const c = t[s.contentType.name],
|
|
562
|
+
const c = t[s.contentType.name], u = [];
|
|
563
563
|
for (let h = 0; h < s.numChildBlocks; h++)
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
u.push(
|
|
565
|
+
y(
|
|
566
566
|
n.lastChild.child(h),
|
|
567
567
|
t,
|
|
568
568
|
e,
|
|
@@ -570,40 +570,40 @@ function k(n, t, e, o, r) {
|
|
|
570
570
|
r
|
|
571
571
|
)
|
|
572
572
|
);
|
|
573
|
-
let
|
|
573
|
+
let p;
|
|
574
574
|
if (c.content === "inline")
|
|
575
|
-
|
|
575
|
+
p = vt(
|
|
576
576
|
s.contentNode,
|
|
577
577
|
e,
|
|
578
578
|
o
|
|
579
579
|
);
|
|
580
580
|
else if (c.content === "table")
|
|
581
|
-
|
|
581
|
+
p = rn(
|
|
582
582
|
s.contentNode,
|
|
583
583
|
e,
|
|
584
584
|
o
|
|
585
585
|
);
|
|
586
586
|
else if (c.content === "none")
|
|
587
|
-
|
|
587
|
+
p = void 0;
|
|
588
588
|
else
|
|
589
|
-
throw new
|
|
589
|
+
throw new A(c.content);
|
|
590
590
|
const m = {
|
|
591
591
|
id: a,
|
|
592
592
|
type: c.type,
|
|
593
593
|
props: l,
|
|
594
|
-
content:
|
|
595
|
-
children:
|
|
594
|
+
content: p,
|
|
595
|
+
children: u
|
|
596
596
|
};
|
|
597
597
|
return r == null || r.set(n, m), m;
|
|
598
598
|
}
|
|
599
|
-
function
|
|
599
|
+
function sn(n) {
|
|
600
600
|
return n.document || window.document;
|
|
601
601
|
}
|
|
602
|
-
const
|
|
602
|
+
const Kt = (n, t, e, o, r) => {
|
|
603
603
|
if (!e.nodes[n.type.name])
|
|
604
604
|
throw new Error("Serializer is missing a node type: " + n.type.name);
|
|
605
|
-
const { dom: i, contentDOM: s } =
|
|
606
|
-
|
|
605
|
+
const { dom: i, contentDOM: s } = bt.renderSpec(
|
|
606
|
+
sn(t),
|
|
607
607
|
e.nodes[n.type.name](n)
|
|
608
608
|
);
|
|
609
609
|
if (s) {
|
|
@@ -612,8 +612,8 @@ const qt = (n, t, e, o, r) => {
|
|
|
612
612
|
if (n.type.name === "blockContainer") {
|
|
613
613
|
const a = n.childCount > 0 && n.firstChild.type.spec.group === "blockContent" ? n.firstChild : void 0, l = n.childCount > 0 && n.lastChild.type.spec.group === "blockGroup" ? n.lastChild : void 0;
|
|
614
614
|
if (a !== void 0) {
|
|
615
|
-
const c = o.blockImplementations[a.type.name].implementation,
|
|
616
|
-
|
|
615
|
+
const c = o.blockImplementations[a.type.name].implementation, p = (r ? c.toExternalHTML : c.toInternalHTML)(
|
|
616
|
+
y(
|
|
617
617
|
n,
|
|
618
618
|
o.schema.blockSchema,
|
|
619
619
|
o.schema.inlineContentSchema,
|
|
@@ -622,19 +622,19 @@ const qt = (n, t, e, o, r) => {
|
|
|
622
622
|
),
|
|
623
623
|
o
|
|
624
624
|
);
|
|
625
|
-
if (
|
|
625
|
+
if (p.contentDOM !== void 0) {
|
|
626
626
|
if (n.isLeaf)
|
|
627
627
|
throw new RangeError(
|
|
628
628
|
"Content hole not allowed in a leaf node spec"
|
|
629
629
|
);
|
|
630
|
-
|
|
630
|
+
p.contentDOM.appendChild(
|
|
631
631
|
e.serializeFragment(a.content, t)
|
|
632
632
|
);
|
|
633
633
|
}
|
|
634
|
-
s.appendChild(
|
|
634
|
+
s.appendChild(p.dom);
|
|
635
635
|
}
|
|
636
636
|
l !== void 0 && e.serializeFragment(
|
|
637
|
-
|
|
637
|
+
T.from(l),
|
|
638
638
|
t,
|
|
639
639
|
s
|
|
640
640
|
);
|
|
@@ -642,11 +642,11 @@ const qt = (n, t, e, o, r) => {
|
|
|
642
642
|
e.serializeFragment(n.content, t, s);
|
|
643
643
|
}
|
|
644
644
|
return i;
|
|
645
|
-
},
|
|
645
|
+
}, Jt = (n, t) => {
|
|
646
646
|
const e = t.serializeFragment(n), o = document.createElement("div");
|
|
647
647
|
return o.appendChild(e), o.innerHTML;
|
|
648
648
|
};
|
|
649
|
-
function
|
|
649
|
+
function an(n) {
|
|
650
650
|
const t = /* @__PURE__ */ new Set([
|
|
651
651
|
...n.orderedListItemBlockTypes,
|
|
652
652
|
...n.unorderedListItemBlockTypes
|
|
@@ -658,12 +658,12 @@ function sn(n) {
|
|
|
658
658
|
}
|
|
659
659
|
let r = o.children.length, i;
|
|
660
660
|
for (let a = 0; a < r; a++) {
|
|
661
|
-
const c = o.children[a].children[0],
|
|
662
|
-
|
|
661
|
+
const c = o.children[a].children[0], u = c.children[0], p = c.children.length === 2 ? c.children[1] : null, m = t.has(
|
|
662
|
+
u.properties.dataContentType
|
|
663
663
|
), h = m ? n.orderedListItemBlockTypes.has(
|
|
664
|
-
|
|
664
|
+
u.properties.dataContentType
|
|
665
665
|
) ? "ol" : "ul" : null;
|
|
666
|
-
if (
|
|
666
|
+
if (p !== null && e(p), i && i.tagName !== h) {
|
|
667
667
|
o.children.splice(
|
|
668
668
|
a - i.children.length,
|
|
669
669
|
i.children.length,
|
|
@@ -673,19 +673,19 @@ function sn(n) {
|
|
|
673
673
|
a -= f, r -= f, i = void 0;
|
|
674
674
|
}
|
|
675
675
|
if (m) {
|
|
676
|
-
i || (i =
|
|
676
|
+
i || (i = Lt(
|
|
677
677
|
document.createElement(h)
|
|
678
678
|
));
|
|
679
|
-
const f =
|
|
679
|
+
const f = Lt(
|
|
680
680
|
document.createElement("li")
|
|
681
681
|
);
|
|
682
|
-
f.children.push(
|
|
683
|
-
} else if (
|
|
684
|
-
o.children.splice(a + 1, 0, ...
|
|
685
|
-
const f =
|
|
682
|
+
f.children.push(u.children[0]), p !== null && f.children.push(...p.children), i.children.push(f);
|
|
683
|
+
} else if (p !== null) {
|
|
684
|
+
o.children.splice(a + 1, 0, ...p.children), o.children[a] = u.children[0];
|
|
685
|
+
const f = p.children.length;
|
|
686
686
|
a += f, r += f;
|
|
687
687
|
} else
|
|
688
|
-
o.children[a] =
|
|
688
|
+
o.children[a] = u.children[0];
|
|
689
689
|
}
|
|
690
690
|
i && o.children.splice(
|
|
691
691
|
r - i.children.length,
|
|
@@ -695,24 +695,24 @@ function sn(n) {
|
|
|
695
695
|
};
|
|
696
696
|
return e;
|
|
697
697
|
}
|
|
698
|
-
const
|
|
699
|
-
const e =
|
|
700
|
-
return e.serializeNodeInner = (o, r) =>
|
|
698
|
+
const lt = (n, t) => {
|
|
699
|
+
const e = bt.fromSchema(n);
|
|
700
|
+
return e.serializeNodeInner = (o, r) => Kt(o, r, e, t, !0), e.exportProseMirrorFragment = (o) => kt().use(zt, { fragment: !0 }).use(an, {
|
|
701
701
|
orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
|
|
702
702
|
unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
|
|
703
|
-
}).use(
|
|
703
|
+
}).use(Vt).processSync(Jt(o, e)).value, e.exportBlocks = (o) => {
|
|
704
704
|
const r = o.map(
|
|
705
|
-
(s) =>
|
|
705
|
+
(s) => D(s, n, t.schema.styleSchema)
|
|
706
706
|
), i = n.nodes.blockGroup.create(null, r);
|
|
707
|
-
return e.exportProseMirrorFragment(
|
|
707
|
+
return e.exportProseMirrorFragment(T.from(i));
|
|
708
708
|
}, e;
|
|
709
|
-
},
|
|
710
|
-
const e =
|
|
711
|
-
return e.serializeNodeInner = (o, r) =>
|
|
709
|
+
}, Xt = (n, t) => {
|
|
710
|
+
const e = bt.fromSchema(n);
|
|
711
|
+
return e.serializeNodeInner = (o, r) => Kt(o, r, e, t, !1), e.serializeProseMirrorFragment = (o) => Jt(o, e), e.serializeBlocks = (o) => {
|
|
712
712
|
const r = o.map(
|
|
713
|
-
(s) =>
|
|
713
|
+
(s) => D(s, n, t.schema.styleSchema)
|
|
714
714
|
), i = n.nodes.blockGroup.create(null, r);
|
|
715
|
-
return e.serializeProseMirrorFragment(
|
|
715
|
+
return e.serializeProseMirrorFragment(T.from(i));
|
|
716
716
|
}, e;
|
|
717
717
|
}, Hr = async (n) => {
|
|
718
718
|
const t = new FormData();
|
|
@@ -723,24 +723,24 @@ const at = (n, t) => {
|
|
|
723
723
|
"tmpfiles.org/",
|
|
724
724
|
"tmpfiles.org/dl/"
|
|
725
725
|
);
|
|
726
|
-
},
|
|
727
|
-
function
|
|
728
|
-
return
|
|
726
|
+
}, ln = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
|
|
727
|
+
function F(n) {
|
|
728
|
+
return ln() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
|
|
729
729
|
}
|
|
730
|
-
function
|
|
730
|
+
function z(...n) {
|
|
731
731
|
return n.filter((t) => t).join(" ");
|
|
732
732
|
}
|
|
733
|
-
const
|
|
734
|
-
function
|
|
733
|
+
const Dr = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
734
|
+
function tt(n, t, e, o) {
|
|
735
735
|
const r = document.createElement("div");
|
|
736
|
-
r.className =
|
|
736
|
+
r.className = z(
|
|
737
737
|
"bn-block-content",
|
|
738
738
|
e.class
|
|
739
739
|
), r.setAttribute("data-content-type", n);
|
|
740
740
|
for (const [s, a] of Object.entries(e))
|
|
741
741
|
s !== "class" && r.setAttribute(s, a);
|
|
742
742
|
const i = document.createElement(t);
|
|
743
|
-
i.className =
|
|
743
|
+
i.className = z(
|
|
744
744
|
"bn-inline-content",
|
|
745
745
|
o.class
|
|
746
746
|
);
|
|
@@ -753,8 +753,8 @@ function Z(n, t, e, o) {
|
|
|
753
753
|
contentDOM: i
|
|
754
754
|
};
|
|
755
755
|
}
|
|
756
|
-
const
|
|
757
|
-
const e =
|
|
756
|
+
const At = (n, t) => {
|
|
757
|
+
const e = D(
|
|
758
758
|
n,
|
|
759
759
|
t._tiptapEditor.schema,
|
|
760
760
|
t.schema.styleSchema
|
|
@@ -780,13 +780,13 @@ const Nt = (n, t) => {
|
|
|
780
780
|
default: "left",
|
|
781
781
|
values: ["left", "center", "right", "justify"]
|
|
782
782
|
}
|
|
783
|
-
},
|
|
784
|
-
function
|
|
783
|
+
}, Yt = ["backgroundColor", "textColor"];
|
|
784
|
+
function st(n) {
|
|
785
785
|
return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
786
786
|
}
|
|
787
|
-
function
|
|
787
|
+
function Qt(n) {
|
|
788
788
|
const t = {};
|
|
789
|
-
return Object.entries(n).filter(([e, o]) => !
|
|
789
|
+
return Object.entries(n).filter(([e, o]) => !Yt.includes(e)).forEach(([e, o]) => {
|
|
790
790
|
t[e] = {
|
|
791
791
|
default: o.default,
|
|
792
792
|
keepOnSplit: !0,
|
|
@@ -794,7 +794,7 @@ function Yt(n) {
|
|
|
794
794
|
// value is the same as its default, we don't display an HTML
|
|
795
795
|
// attribute for it.
|
|
796
796
|
parseHTML: (r) => {
|
|
797
|
-
const i = r.getAttribute(
|
|
797
|
+
const i = r.getAttribute(st(e));
|
|
798
798
|
if (i === null)
|
|
799
799
|
return null;
|
|
800
800
|
if (typeof o.default == "boolean")
|
|
@@ -806,12 +806,12 @@ function Yt(n) {
|
|
|
806
806
|
return i;
|
|
807
807
|
},
|
|
808
808
|
renderHTML: (r) => r[e] !== o.default ? {
|
|
809
|
-
[
|
|
809
|
+
[st(e)]: r[e]
|
|
810
810
|
} : {}
|
|
811
811
|
};
|
|
812
812
|
}), t;
|
|
813
813
|
}
|
|
814
|
-
function
|
|
814
|
+
function cn(n, t, e, o) {
|
|
815
815
|
if (typeof n == "boolean")
|
|
816
816
|
throw new Error(
|
|
817
817
|
"Cannot find node position as getPos is a boolean, not a function."
|
|
@@ -826,13 +826,13 @@ function pt(n, t, e, o, r) {
|
|
|
826
826
|
if (r !== void 0)
|
|
827
827
|
for (const [s, a] of Object.entries(r))
|
|
828
828
|
s !== "class" && i.setAttribute(s, a);
|
|
829
|
-
i.className =
|
|
829
|
+
i.className = z(
|
|
830
830
|
"bn-block-content",
|
|
831
831
|
(r == null ? void 0 : r.class) || ""
|
|
832
832
|
), i.setAttribute("data-content-type", t);
|
|
833
833
|
for (const [s, a] of Object.entries(e))
|
|
834
|
-
!
|
|
835
|
-
return i.appendChild(n.dom), n.contentDOM !== void 0 && (n.contentDOM.className =
|
|
834
|
+
!Yt.includes(s) && a !== o[s].default && i.setAttribute(st(s), a);
|
|
835
|
+
return i.appendChild(n.dom), n.contentDOM !== void 0 && (n.contentDOM.className = z(
|
|
836
836
|
"bn-inline-content",
|
|
837
837
|
n.contentDOM.className
|
|
838
838
|
), n.contentDOM.setAttribute("data-editable", "")), {
|
|
@@ -840,17 +840,17 @@ function pt(n, t, e, o, r) {
|
|
|
840
840
|
dom: i
|
|
841
841
|
};
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
return
|
|
843
|
+
function q(n) {
|
|
844
|
+
return W.create(n);
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function Zt(n, t) {
|
|
847
847
|
return {
|
|
848
848
|
config: n,
|
|
849
849
|
implementation: t
|
|
850
850
|
};
|
|
851
851
|
}
|
|
852
|
-
function
|
|
853
|
-
return
|
|
852
|
+
function et(n, t, e) {
|
|
853
|
+
return Zt(
|
|
854
854
|
{
|
|
855
855
|
type: n.name,
|
|
856
856
|
content: n.config.content === "inline*" ? "inline" : n.config.content === "tableRow+" ? "table" : "none",
|
|
@@ -859,18 +859,18 @@ function tt(n, t, e) {
|
|
|
859
859
|
{
|
|
860
860
|
node: n,
|
|
861
861
|
requiredExtensions: e,
|
|
862
|
-
toInternalHTML:
|
|
863
|
-
toExternalHTML:
|
|
862
|
+
toInternalHTML: At,
|
|
863
|
+
toExternalHTML: At
|
|
864
864
|
// parse: () => undefined, // parse rules are in node already
|
|
865
865
|
}
|
|
866
866
|
);
|
|
867
867
|
}
|
|
868
|
-
function
|
|
868
|
+
function te(n) {
|
|
869
869
|
return Object.fromEntries(
|
|
870
870
|
Object.entries(n).map(([t, e]) => [t, e.config])
|
|
871
871
|
);
|
|
872
872
|
}
|
|
873
|
-
function
|
|
873
|
+
function dn(n, t) {
|
|
874
874
|
const e = [
|
|
875
875
|
{
|
|
876
876
|
tag: "[data-content-type=" + n.type + "]",
|
|
@@ -887,17 +887,17 @@ function cn(n, t) {
|
|
|
887
887
|
}
|
|
888
888
|
}), e;
|
|
889
889
|
}
|
|
890
|
-
function
|
|
891
|
-
const e =
|
|
890
|
+
function un(n, t) {
|
|
891
|
+
const e = q({
|
|
892
892
|
name: n.type,
|
|
893
893
|
content: n.content === "inline" ? "inline*" : "",
|
|
894
894
|
group: "blockContent",
|
|
895
895
|
selectable: !0,
|
|
896
896
|
addAttributes() {
|
|
897
|
-
return
|
|
897
|
+
return Qt(n.propSchema);
|
|
898
898
|
},
|
|
899
899
|
parseHTML() {
|
|
900
|
-
return
|
|
900
|
+
return dn(n, t.parse);
|
|
901
901
|
},
|
|
902
902
|
renderHTML() {
|
|
903
903
|
const o = document.createElement("div");
|
|
@@ -908,7 +908,7 @@ function dn(n, t) {
|
|
|
908
908
|
addNodeView() {
|
|
909
909
|
return ({ getPos: o }) => {
|
|
910
910
|
var l;
|
|
911
|
-
const r = this.options.editor, i =
|
|
911
|
+
const r = this.options.editor, i = cn(
|
|
912
912
|
o,
|
|
913
913
|
r,
|
|
914
914
|
this.editor,
|
|
@@ -928,7 +928,7 @@ function dn(n, t) {
|
|
|
928
928
|
throw new Error(
|
|
929
929
|
"Node name does not match block type. This is a bug in BlockNote."
|
|
930
930
|
);
|
|
931
|
-
return
|
|
931
|
+
return Zt(n, {
|
|
932
932
|
node: e,
|
|
933
933
|
toInternalHTML: (o, r) => {
|
|
934
934
|
var a;
|
|
@@ -960,9 +960,9 @@ function dn(n, t) {
|
|
|
960
960
|
});
|
|
961
961
|
}
|
|
962
962
|
function pn(n, t, e, o) {
|
|
963
|
-
return n.dom.setAttribute("data-inline-content-type", t), Object.entries(e).filter(([r, i]) => i !== o[r].default).map(([r, i]) => [
|
|
963
|
+
return n.dom.setAttribute("data-inline-content-type", t), Object.entries(e).filter(([r, i]) => i !== o[r].default).map(([r, i]) => [st(r), i]).forEach(([r, i]) => n.dom.setAttribute(r, i)), n.contentDOM !== void 0 && n.contentDOM.setAttribute("data-editable", ""), n;
|
|
964
964
|
}
|
|
965
|
-
function
|
|
965
|
+
function hn(n) {
|
|
966
966
|
return {
|
|
967
967
|
Backspace: ({ editor: t }) => {
|
|
968
968
|
const e = t.state.selection.$from;
|
|
@@ -970,14 +970,14 @@ function un(n) {
|
|
|
970
970
|
}
|
|
971
971
|
};
|
|
972
972
|
}
|
|
973
|
-
function
|
|
973
|
+
function mn(n, t) {
|
|
974
974
|
return {
|
|
975
975
|
config: n,
|
|
976
976
|
implementation: t
|
|
977
977
|
};
|
|
978
978
|
}
|
|
979
|
-
function
|
|
980
|
-
return
|
|
979
|
+
function fn(n, t) {
|
|
980
|
+
return mn(
|
|
981
981
|
{
|
|
982
982
|
type: n.name,
|
|
983
983
|
propSchema: t,
|
|
@@ -988,12 +988,12 @@ function mn(n, t) {
|
|
|
988
988
|
}
|
|
989
989
|
);
|
|
990
990
|
}
|
|
991
|
-
function
|
|
991
|
+
function ee(n) {
|
|
992
992
|
return Object.fromEntries(
|
|
993
993
|
Object.entries(n).map(([t, e]) => [t, e.config])
|
|
994
994
|
);
|
|
995
995
|
}
|
|
996
|
-
function
|
|
996
|
+
function gn(n) {
|
|
997
997
|
return [
|
|
998
998
|
{
|
|
999
999
|
tag: `[data-inline-content-type="${n.type}"]`,
|
|
@@ -1004,8 +1004,8 @@ function fn(n) {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
];
|
|
1006
1006
|
}
|
|
1007
|
-
function
|
|
1008
|
-
const e =
|
|
1007
|
+
function Or(n, t) {
|
|
1008
|
+
const e = W.create({
|
|
1009
1009
|
name: n.type,
|
|
1010
1010
|
inline: !0,
|
|
1011
1011
|
group: "inline",
|
|
@@ -1013,17 +1013,17 @@ function Dr(n, t) {
|
|
|
1013
1013
|
atom: n.content === "none",
|
|
1014
1014
|
content: n.content === "styled" ? "inline*" : "",
|
|
1015
1015
|
addAttributes() {
|
|
1016
|
-
return
|
|
1016
|
+
return Qt(n.propSchema);
|
|
1017
1017
|
},
|
|
1018
1018
|
addKeyboardShortcuts() {
|
|
1019
|
-
return
|
|
1019
|
+
return hn(n);
|
|
1020
1020
|
},
|
|
1021
1021
|
parseHTML() {
|
|
1022
|
-
return
|
|
1022
|
+
return gn(n);
|
|
1023
1023
|
},
|
|
1024
1024
|
renderHTML({ node: o }) {
|
|
1025
1025
|
const r = this.options.editor, i = t.render(
|
|
1026
|
-
|
|
1026
|
+
qt(
|
|
1027
1027
|
o,
|
|
1028
1028
|
r.schema.inlineContentSchema,
|
|
1029
1029
|
r.schema.styleSchema
|
|
@@ -1038,12 +1038,12 @@ function Dr(n, t) {
|
|
|
1038
1038
|
);
|
|
1039
1039
|
}
|
|
1040
1040
|
});
|
|
1041
|
-
return
|
|
1041
|
+
return fn(
|
|
1042
1042
|
e,
|
|
1043
1043
|
n.propSchema
|
|
1044
1044
|
);
|
|
1045
1045
|
}
|
|
1046
|
-
function
|
|
1046
|
+
function bn(n) {
|
|
1047
1047
|
return n === "boolean" ? {} : {
|
|
1048
1048
|
stringValue: {
|
|
1049
1049
|
default: void 0,
|
|
@@ -1055,17 +1055,17 @@ function gn(n) {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
};
|
|
1057
1057
|
}
|
|
1058
|
-
function
|
|
1058
|
+
function kn(n, t, e, o) {
|
|
1059
1059
|
return n.dom.setAttribute("data-style-type", t), o === "string" && n.dom.setAttribute("data-value", e), n.contentDOM !== void 0 && n.contentDOM.setAttribute("data-editable", ""), n;
|
|
1060
1060
|
}
|
|
1061
|
-
function
|
|
1061
|
+
function ne(n, t) {
|
|
1062
1062
|
return {
|
|
1063
1063
|
config: n,
|
|
1064
1064
|
implementation: t
|
|
1065
1065
|
};
|
|
1066
1066
|
}
|
|
1067
|
-
function
|
|
1068
|
-
return
|
|
1067
|
+
function _(n, t) {
|
|
1068
|
+
return ne(
|
|
1069
1069
|
{
|
|
1070
1070
|
type: n.name,
|
|
1071
1071
|
propSchema: t
|
|
@@ -1075,7 +1075,7 @@ function O(n, t) {
|
|
|
1075
1075
|
}
|
|
1076
1076
|
);
|
|
1077
1077
|
}
|
|
1078
|
-
function
|
|
1078
|
+
function oe(n) {
|
|
1079
1079
|
return Object.fromEntries(
|
|
1080
1080
|
Object.entries(n).map(([t, e]) => [t, e.config])
|
|
1081
1081
|
);
|
|
@@ -1091,11 +1091,11 @@ function yn(n) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
];
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1094
|
+
function _r(n, t) {
|
|
1095
1095
|
const e = yt.create({
|
|
1096
1096
|
name: n.type,
|
|
1097
1097
|
addAttributes() {
|
|
1098
|
-
return
|
|
1098
|
+
return bn(n.propSchema);
|
|
1099
1099
|
},
|
|
1100
1100
|
parseHTML() {
|
|
1101
1101
|
return yn(n);
|
|
@@ -1107,8 +1107,8 @@ function Or(n, t) {
|
|
|
1107
1107
|
else if (n.propSchema === "string")
|
|
1108
1108
|
r = t.render(o.attrs.stringValue);
|
|
1109
1109
|
else
|
|
1110
|
-
throw new
|
|
1111
|
-
return
|
|
1110
|
+
throw new A(n.propSchema);
|
|
1111
|
+
return kn(
|
|
1112
1112
|
r,
|
|
1113
1113
|
n.type,
|
|
1114
1114
|
o.attrs.stringValue,
|
|
@@ -1116,11 +1116,11 @@ function Or(n, t) {
|
|
|
1116
1116
|
);
|
|
1117
1117
|
}
|
|
1118
1118
|
});
|
|
1119
|
-
return
|
|
1119
|
+
return ne(n, {
|
|
1120
1120
|
mark: e
|
|
1121
1121
|
});
|
|
1122
1122
|
}
|
|
1123
|
-
const
|
|
1123
|
+
const wn = yt.create({
|
|
1124
1124
|
name: "backgroundColor",
|
|
1125
1125
|
addAttributes() {
|
|
1126
1126
|
return {
|
|
@@ -1146,10 +1146,10 @@ const kn = yt.create({
|
|
|
1146
1146
|
renderHTML({ HTMLAttributes: n }) {
|
|
1147
1147
|
return ["span", n, 0];
|
|
1148
1148
|
}
|
|
1149
|
-
}),
|
|
1150
|
-
|
|
1149
|
+
}), vn = _(
|
|
1150
|
+
wn,
|
|
1151
1151
|
"string"
|
|
1152
|
-
),
|
|
1152
|
+
), En = yt.create({
|
|
1153
1153
|
name: "textColor",
|
|
1154
1154
|
addAttributes() {
|
|
1155
1155
|
return {
|
|
@@ -1173,10 +1173,16 @@ const kn = yt.create({
|
|
|
1173
1173
|
renderHTML({ HTMLAttributes: n }) {
|
|
1174
1174
|
return ["span", n, 0];
|
|
1175
1175
|
}
|
|
1176
|
-
}),
|
|
1176
|
+
}), Sn = _(En, "string"), N = (n) => {
|
|
1177
|
+
const { contentType: t } = b(
|
|
1178
|
+
n.state.doc,
|
|
1179
|
+
n.state.selection.from
|
|
1180
|
+
);
|
|
1181
|
+
return t.spec.content;
|
|
1182
|
+
}, Cn = {
|
|
1177
1183
|
...w,
|
|
1178
1184
|
level: { default: 1, values: [1, 2, 3] }
|
|
1179
|
-
},
|
|
1185
|
+
}, xn = q({
|
|
1180
1186
|
name: "heading",
|
|
1181
1187
|
content: "inline*",
|
|
1182
1188
|
group: "blockContent",
|
|
@@ -1198,10 +1204,10 @@ const kn = yt.create({
|
|
|
1198
1204
|
},
|
|
1199
1205
|
addInputRules() {
|
|
1200
1206
|
return [
|
|
1201
|
-
...[1, 2, 3].map((n) => new
|
|
1207
|
+
...[1, 2, 3].map((n) => new wt({
|
|
1202
1208
|
find: new RegExp(`^(#{${n}})\\s$`),
|
|
1203
1209
|
handler: ({ state: t, chain: e, range: o }) => {
|
|
1204
|
-
e().BNUpdateBlock(t.selection.from, {
|
|
1210
|
+
N(this.editor) === "inline*" && e().BNUpdateBlock(t.selection.from, {
|
|
1205
1211
|
type: "heading",
|
|
1206
1212
|
props: {
|
|
1207
1213
|
level: n
|
|
@@ -1213,24 +1219,33 @@ const kn = yt.create({
|
|
|
1213
1219
|
},
|
|
1214
1220
|
addKeyboardShortcuts() {
|
|
1215
1221
|
return {
|
|
1216
|
-
"Mod-Alt-1": () => this.editor.commands.BNUpdateBlock(
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1222
|
+
"Mod-Alt-1": () => N(this.editor) !== "inline*" ? !0 : this.editor.commands.BNUpdateBlock(
|
|
1223
|
+
this.editor.state.selection.anchor,
|
|
1224
|
+
{
|
|
1225
|
+
type: "heading",
|
|
1226
|
+
props: {
|
|
1227
|
+
level: 1
|
|
1228
|
+
}
|
|
1220
1229
|
}
|
|
1221
|
-
|
|
1222
|
-
"Mod-Alt-2": () => this.editor.commands.BNUpdateBlock(
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1230
|
+
),
|
|
1231
|
+
"Mod-Alt-2": () => N(this.editor) !== "inline*" ? !0 : this.editor.commands.BNUpdateBlock(
|
|
1232
|
+
this.editor.state.selection.anchor,
|
|
1233
|
+
{
|
|
1234
|
+
type: "heading",
|
|
1235
|
+
props: {
|
|
1236
|
+
level: 2
|
|
1237
|
+
}
|
|
1226
1238
|
}
|
|
1227
|
-
|
|
1228
|
-
"Mod-Alt-3": () => this.editor.commands.BNUpdateBlock(
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1239
|
+
),
|
|
1240
|
+
"Mod-Alt-3": () => N(this.editor) !== "inline*" ? !0 : this.editor.commands.BNUpdateBlock(
|
|
1241
|
+
this.editor.state.selection.anchor,
|
|
1242
|
+
{
|
|
1243
|
+
type: "heading",
|
|
1244
|
+
props: {
|
|
1245
|
+
level: 3
|
|
1246
|
+
}
|
|
1232
1247
|
}
|
|
1233
|
-
|
|
1248
|
+
)
|
|
1234
1249
|
};
|
|
1235
1250
|
},
|
|
1236
1251
|
parseHTML() {
|
|
@@ -1260,7 +1275,7 @@ const kn = yt.create({
|
|
|
1260
1275
|
},
|
|
1261
1276
|
renderHTML({ node: n, HTMLAttributes: t }) {
|
|
1262
1277
|
var e, o;
|
|
1263
|
-
return
|
|
1278
|
+
return tt(
|
|
1264
1279
|
this.name,
|
|
1265
1280
|
`h${n.attrs.level}`,
|
|
1266
1281
|
{
|
|
@@ -1270,10 +1285,10 @@ const kn = yt.create({
|
|
|
1270
1285
|
((o = this.options.domAttributes) == null ? void 0 : o.inlineContent) || {}
|
|
1271
1286
|
);
|
|
1272
1287
|
}
|
|
1273
|
-
}), Tn =
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
),
|
|
1288
|
+
}), Tn = et(
|
|
1289
|
+
xn,
|
|
1290
|
+
Cn
|
|
1291
|
+
), Mn = {
|
|
1277
1292
|
textAlignment: w.textAlignment,
|
|
1278
1293
|
backgroundColor: w.backgroundColor,
|
|
1279
1294
|
// Image url.
|
|
@@ -1288,7 +1303,7 @@ const kn = yt.create({
|
|
|
1288
1303
|
width: {
|
|
1289
1304
|
default: 512
|
|
1290
1305
|
}
|
|
1291
|
-
},
|
|
1306
|
+
}, Pt = (n) => {
|
|
1292
1307
|
switch (n) {
|
|
1293
1308
|
case "left":
|
|
1294
1309
|
return "flex-start";
|
|
@@ -1299,9 +1314,9 @@ const kn = yt.create({
|
|
|
1299
1314
|
default:
|
|
1300
1315
|
return "flex-start";
|
|
1301
1316
|
}
|
|
1302
|
-
}, Ht = 64,
|
|
1317
|
+
}, Ht = 64, Bn = (n, t) => {
|
|
1303
1318
|
const e = document.createElement("div");
|
|
1304
|
-
e.className = "bn-image-block-content-wrapper", e.style.alignItems =
|
|
1319
|
+
e.className = "bn-image-block-content-wrapper", e.style.alignItems = Pt(
|
|
1305
1320
|
n.props.textAlignment
|
|
1306
1321
|
);
|
|
1307
1322
|
const o = document.createElement("div");
|
|
@@ -1321,28 +1336,28 @@ const kn = yt.create({
|
|
|
1321
1336
|
)}px`;
|
|
1322
1337
|
const c = document.createElement("div");
|
|
1323
1338
|
c.className = "bn-image-resize-handle", c.style.left = "4px";
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
const
|
|
1327
|
-
|
|
1339
|
+
const u = document.createElement("div");
|
|
1340
|
+
u.className = "bn-image-resize-handle", u.style.right = "4px";
|
|
1341
|
+
const p = document.createElement("p");
|
|
1342
|
+
p.className = "bn-image-caption", p.innerText = n.props.caption, p.style.padding = n.props.caption ? "4px" : "";
|
|
1328
1343
|
const m = () => {
|
|
1329
|
-
var
|
|
1330
|
-
const g = ((
|
|
1344
|
+
var dt;
|
|
1345
|
+
const g = ((dt = t.getSelection()) == null ? void 0 : dt.blocks) || [];
|
|
1331
1346
|
[t.getTextCursorPosition().block, ...g].find(
|
|
1332
|
-
(
|
|
1347
|
+
(nt) => nt.id === n.id
|
|
1333
1348
|
) !== void 0 ? (o.style.outline = "4px solid rgb(100, 160, 255)", s.style.outline = "4px solid rgb(100, 160, 255)") : (o.style.outline = "", s.style.outline = "");
|
|
1334
1349
|
};
|
|
1335
1350
|
t.onEditorContentChange(m), t.onEditorSelectionChange(m);
|
|
1336
1351
|
let h;
|
|
1337
1352
|
const f = (g) => {
|
|
1338
1353
|
if (!h) {
|
|
1339
|
-
!t.isEditable && a.contains(c) && a.contains(
|
|
1354
|
+
!t.isEditable && a.contains(c) && a.contains(u) && (a.removeChild(c), a.removeChild(u));
|
|
1340
1355
|
return;
|
|
1341
1356
|
}
|
|
1342
|
-
let
|
|
1343
|
-
|
|
1344
|
-
},
|
|
1345
|
-
(!g.target || !a.contains(g.target) || !t.isEditable) && a.contains(c) && a.contains(
|
|
1357
|
+
let L;
|
|
1358
|
+
Pt(n.props.textAlignment) === "center" ? h.handleUsed === "left" ? L = h.initialWidth + (h.initialClientX - g.clientX) * 2 : L = h.initialWidth + (g.clientX - h.initialClientX) * 2 : h.handleUsed === "left" ? L = h.initialWidth + h.initialClientX - g.clientX : L = h.initialWidth + g.clientX - h.initialClientX, L < Ht ? l.style.width = `${Ht}px` : L > t.domElement.firstElementChild.clientWidth ? l.style.width = `${t.domElement.firstElementChild.clientWidth}px` : l.style.width = `${L}px`;
|
|
1359
|
+
}, k = (g) => {
|
|
1360
|
+
(!g.target || !a.contains(g.target) || !t.isEditable) && a.contains(c) && a.contains(u) && (a.removeChild(c), a.removeChild(u)), h && (h = void 0, t.updateBlock(n, {
|
|
1346
1361
|
type: "image",
|
|
1347
1362
|
props: {
|
|
1348
1363
|
// Removes "px" from the end of the width string and converts to float.
|
|
@@ -1353,56 +1368,56 @@ const kn = yt.create({
|
|
|
1353
1368
|
g.preventDefault();
|
|
1354
1369
|
}, B = () => {
|
|
1355
1370
|
t._tiptapEditor.view.dispatch(
|
|
1356
|
-
t._tiptapEditor.state.tr.setMeta(t.
|
|
1371
|
+
t._tiptapEditor.state.tr.setMeta(t.imagePanel.plugin, {
|
|
1357
1372
|
block: n
|
|
1358
1373
|
})
|
|
1359
1374
|
);
|
|
1360
1375
|
}, E = () => {
|
|
1361
|
-
t.isEditable && (a.appendChild(c), a.appendChild(
|
|
1362
|
-
},
|
|
1363
|
-
g.relatedTarget === c || g.relatedTarget ===
|
|
1364
|
-
},
|
|
1365
|
-
g.preventDefault(), a.appendChild(c), a.appendChild(
|
|
1376
|
+
t.isEditable && (a.appendChild(c), a.appendChild(u));
|
|
1377
|
+
}, O = (g) => {
|
|
1378
|
+
g.relatedTarget === c || g.relatedTarget === u || h || t.isEditable && a.contains(c) && a.contains(u) && (a.removeChild(c), a.removeChild(u));
|
|
1379
|
+
}, V = (g) => {
|
|
1380
|
+
g.preventDefault(), a.appendChild(c), a.appendChild(u), h = {
|
|
1366
1381
|
handleUsed: "left",
|
|
1367
1382
|
initialWidth: n.props.width,
|
|
1368
1383
|
initialClientX: g.clientX
|
|
1369
1384
|
};
|
|
1370
|
-
},
|
|
1371
|
-
g.preventDefault(), a.appendChild(c), a.appendChild(
|
|
1385
|
+
}, J = (g) => {
|
|
1386
|
+
g.preventDefault(), a.appendChild(c), a.appendChild(u), h = {
|
|
1372
1387
|
handleUsed: "right",
|
|
1373
1388
|
initialWidth: n.props.width,
|
|
1374
1389
|
initialClientX: g.clientX
|
|
1375
1390
|
};
|
|
1376
1391
|
};
|
|
1377
|
-
return o.appendChild(r), o.appendChild(i), s.appendChild(a), a.appendChild(l), s.appendChild(
|
|
1392
|
+
return o.appendChild(r), o.appendChild(i), s.appendChild(a), a.appendChild(l), s.appendChild(p), n.props.url === "" ? e.appendChild(o) : e.appendChild(s), window.addEventListener("mousemove", f), window.addEventListener("mouseup", k), o.addEventListener("mousedown", S), o.addEventListener("click", B), l.addEventListener("mouseenter", E), l.addEventListener("mouseleave", O), c.addEventListener(
|
|
1378
1393
|
"mousedown",
|
|
1379
|
-
|
|
1380
|
-
),
|
|
1394
|
+
V
|
|
1395
|
+
), u.addEventListener(
|
|
1381
1396
|
"mousedown",
|
|
1382
|
-
|
|
1397
|
+
J
|
|
1383
1398
|
), {
|
|
1384
1399
|
dom: e,
|
|
1385
1400
|
destroy: () => {
|
|
1386
|
-
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup",
|
|
1401
|
+
window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", k), o.removeEventListener(
|
|
1387
1402
|
"mousedown",
|
|
1388
1403
|
S
|
|
1389
1404
|
), o.removeEventListener("click", B), c.removeEventListener(
|
|
1390
1405
|
"mousedown",
|
|
1391
|
-
|
|
1392
|
-
),
|
|
1406
|
+
V
|
|
1407
|
+
), u.removeEventListener(
|
|
1393
1408
|
"mousedown",
|
|
1394
|
-
|
|
1409
|
+
J
|
|
1395
1410
|
);
|
|
1396
1411
|
}
|
|
1397
1412
|
};
|
|
1398
|
-
},
|
|
1413
|
+
}, Ln = un(
|
|
1399
1414
|
{
|
|
1400
1415
|
type: "image",
|
|
1401
|
-
propSchema:
|
|
1416
|
+
propSchema: Mn,
|
|
1402
1417
|
content: "none"
|
|
1403
1418
|
},
|
|
1404
1419
|
{
|
|
1405
|
-
render:
|
|
1420
|
+
render: Bn,
|
|
1406
1421
|
toExternalHTML: (n) => {
|
|
1407
1422
|
if (n.props.url === "") {
|
|
1408
1423
|
const o = document.createElement("p");
|
|
@@ -1433,12 +1448,12 @@ const kn = yt.create({
|
|
|
1433
1448
|
};
|
|
1434
1449
|
}
|
|
1435
1450
|
}
|
|
1436
|
-
),
|
|
1451
|
+
), Et = (n) => {
|
|
1437
1452
|
const { node: t, contentType: e } = b(
|
|
1438
1453
|
n.state.doc,
|
|
1439
1454
|
n.state.selection.from
|
|
1440
1455
|
), o = n.state.selection.anchor === n.state.selection.head;
|
|
1441
|
-
return !e.name.
|
|
1456
|
+
return !(e.name === "bulletListItem" || e.name === "numberedListItem") || !o ? !1 : n.commands.first(({ state: r, chain: i, commands: s }) => [
|
|
1442
1457
|
() => (
|
|
1443
1458
|
// Changes list item block to a text block if the content is empty.
|
|
1444
1459
|
s.command(() => t.textContent.length === 0 ? s.BNUpdateBlock(r.selection.from, {
|
|
@@ -1454,17 +1469,17 @@ const kn = yt.create({
|
|
|
1454
1469
|
]);
|
|
1455
1470
|
}, In = {
|
|
1456
1471
|
...w
|
|
1457
|
-
},
|
|
1472
|
+
}, Nn = q({
|
|
1458
1473
|
name: "bulletListItem",
|
|
1459
1474
|
content: "inline*",
|
|
1460
1475
|
group: "blockContent",
|
|
1461
1476
|
addInputRules() {
|
|
1462
1477
|
return [
|
|
1463
1478
|
// Creates an unordered list when starting with "-", "+", or "*".
|
|
1464
|
-
new
|
|
1479
|
+
new wt({
|
|
1465
1480
|
find: new RegExp("^[-+*]\\s$"),
|
|
1466
1481
|
handler: ({ state: n, chain: t, range: e }) => {
|
|
1467
|
-
t().BNUpdateBlock(n.selection.from, {
|
|
1482
|
+
N(this.editor) === "inline*" && t().BNUpdateBlock(n.selection.from, {
|
|
1468
1483
|
type: "bulletListItem",
|
|
1469
1484
|
props: {}
|
|
1470
1485
|
}).deleteRange({ from: e.from, to: e.to });
|
|
@@ -1474,11 +1489,14 @@ const kn = yt.create({
|
|
|
1474
1489
|
},
|
|
1475
1490
|
addKeyboardShortcuts() {
|
|
1476
1491
|
return {
|
|
1477
|
-
Enter: () =>
|
|
1478
|
-
"Mod-Shift-8": () => this.editor.commands.BNUpdateBlock(
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1492
|
+
Enter: () => Et(this.editor),
|
|
1493
|
+
"Mod-Shift-8": () => N(this.editor) !== "inline*" ? !0 : this.editor.commands.BNUpdateBlock(
|
|
1494
|
+
this.editor.state.selection.anchor,
|
|
1495
|
+
{
|
|
1496
|
+
type: "bulletListItem",
|
|
1497
|
+
props: {}
|
|
1498
|
+
}
|
|
1499
|
+
)
|
|
1482
1500
|
};
|
|
1483
1501
|
},
|
|
1484
1502
|
parseHTML() {
|
|
@@ -1514,7 +1532,7 @@ const kn = yt.create({
|
|
|
1514
1532
|
},
|
|
1515
1533
|
renderHTML({ HTMLAttributes: n }) {
|
|
1516
1534
|
var t, e;
|
|
1517
|
-
return
|
|
1535
|
+
return tt(
|
|
1518
1536
|
this.name,
|
|
1519
1537
|
// We use a <p> tag, because for <li> tags we'd need a <ul> element to put
|
|
1520
1538
|
// them in to be semantically correct, which we can't have due to the
|
|
@@ -1527,11 +1545,11 @@ const kn = yt.create({
|
|
|
1527
1545
|
((e = this.options.domAttributes) == null ? void 0 : e.inlineContent) || {}
|
|
1528
1546
|
);
|
|
1529
1547
|
}
|
|
1530
|
-
}),
|
|
1531
|
-
|
|
1548
|
+
}), An = et(
|
|
1549
|
+
Nn,
|
|
1532
1550
|
In
|
|
1533
|
-
),
|
|
1534
|
-
key:
|
|
1551
|
+
), Pn = new x("numbered-list-indexing"), Hn = () => new v({
|
|
1552
|
+
key: Pn,
|
|
1535
1553
|
appendTransaction: (n, t, e) => {
|
|
1536
1554
|
const o = e.tr;
|
|
1537
1555
|
o.setMeta("numberedListIndexing", !0);
|
|
@@ -1560,9 +1578,9 @@ const kn = yt.create({
|
|
|
1560
1578
|
}
|
|
1561
1579
|
}), r ? o : null;
|
|
1562
1580
|
}
|
|
1563
|
-
}),
|
|
1581
|
+
}), Dn = {
|
|
1564
1582
|
...w
|
|
1565
|
-
},
|
|
1583
|
+
}, On = q({
|
|
1566
1584
|
name: "numberedListItem",
|
|
1567
1585
|
content: "inline*",
|
|
1568
1586
|
group: "blockContent",
|
|
@@ -1580,10 +1598,10 @@ const kn = yt.create({
|
|
|
1580
1598
|
addInputRules() {
|
|
1581
1599
|
return [
|
|
1582
1600
|
// Creates an ordered list when starting with "1.".
|
|
1583
|
-
new
|
|
1601
|
+
new wt({
|
|
1584
1602
|
find: new RegExp("^1\\.\\s$"),
|
|
1585
1603
|
handler: ({ state: n, chain: t, range: e }) => {
|
|
1586
|
-
t().BNUpdateBlock(n.selection.from, {
|
|
1604
|
+
N(this.editor) === "inline*" && t().BNUpdateBlock(n.selection.from, {
|
|
1587
1605
|
type: "numberedListItem",
|
|
1588
1606
|
props: {}
|
|
1589
1607
|
}).deleteRange({ from: e.from, to: e.to });
|
|
@@ -1593,11 +1611,14 @@ const kn = yt.create({
|
|
|
1593
1611
|
},
|
|
1594
1612
|
addKeyboardShortcuts() {
|
|
1595
1613
|
return {
|
|
1596
|
-
Enter: () =>
|
|
1597
|
-
"Mod-Shift-7": () => this.editor.commands.BNUpdateBlock(
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1614
|
+
Enter: () => Et(this.editor),
|
|
1615
|
+
"Mod-Shift-7": () => N(this.editor) !== "inline*" ? !0 : this.editor.commands.BNUpdateBlock(
|
|
1616
|
+
this.editor.state.selection.anchor,
|
|
1617
|
+
{
|
|
1618
|
+
type: "numberedListItem",
|
|
1619
|
+
props: {}
|
|
1620
|
+
}
|
|
1621
|
+
)
|
|
1601
1622
|
};
|
|
1602
1623
|
},
|
|
1603
1624
|
addProseMirrorPlugins() {
|
|
@@ -1638,7 +1659,7 @@ const kn = yt.create({
|
|
|
1638
1659
|
},
|
|
1639
1660
|
renderHTML({ HTMLAttributes: n }) {
|
|
1640
1661
|
var t, e;
|
|
1641
|
-
return
|
|
1662
|
+
return tt(
|
|
1642
1663
|
this.name,
|
|
1643
1664
|
// We use a <p> tag, because for <li> tags we'd need an <ol> element to
|
|
1644
1665
|
// put them in to be semantically correct, which we can't have due to the
|
|
@@ -1651,22 +1672,25 @@ const kn = yt.create({
|
|
|
1651
1672
|
((e = this.options.domAttributes) == null ? void 0 : e.inlineContent) || {}
|
|
1652
1673
|
);
|
|
1653
1674
|
}
|
|
1654
|
-
}),
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
),
|
|
1675
|
+
}), _n = et(
|
|
1676
|
+
On,
|
|
1677
|
+
Dn
|
|
1678
|
+
), Un = {
|
|
1658
1679
|
...w
|
|
1659
|
-
},
|
|
1680
|
+
}, Rn = q({
|
|
1660
1681
|
name: "paragraph",
|
|
1661
1682
|
content: "inline*",
|
|
1662
1683
|
group: "blockContent",
|
|
1663
1684
|
addKeyboardShortcuts() {
|
|
1664
1685
|
return {
|
|
1665
|
-
Enter: () =>
|
|
1666
|
-
"Mod-Alt-0": () => this.editor.commands.BNUpdateBlock(
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1686
|
+
Enter: () => Et(this.editor),
|
|
1687
|
+
"Mod-Alt-0": () => N(this.editor) !== "inline*" ? !0 : this.editor.commands.BNUpdateBlock(
|
|
1688
|
+
this.editor.state.selection.anchor,
|
|
1689
|
+
{
|
|
1690
|
+
type: "paragraph",
|
|
1691
|
+
props: {}
|
|
1692
|
+
}
|
|
1693
|
+
)
|
|
1670
1694
|
};
|
|
1671
1695
|
},
|
|
1672
1696
|
parseHTML() {
|
|
@@ -1681,7 +1705,7 @@ const kn = yt.create({
|
|
|
1681
1705
|
},
|
|
1682
1706
|
renderHTML({ HTMLAttributes: n }) {
|
|
1683
1707
|
var t, e;
|
|
1684
|
-
return
|
|
1708
|
+
return tt(
|
|
1685
1709
|
this.name,
|
|
1686
1710
|
"p",
|
|
1687
1711
|
{
|
|
@@ -1691,16 +1715,16 @@ const kn = yt.create({
|
|
|
1691
1715
|
((e = this.options.domAttributes) == null ? void 0 : e.inlineContent) || {}
|
|
1692
1716
|
);
|
|
1693
1717
|
}
|
|
1694
|
-
}),
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
),
|
|
1718
|
+
}), zn = et(
|
|
1719
|
+
Rn,
|
|
1720
|
+
Un
|
|
1721
|
+
), Vn = M.create({
|
|
1698
1722
|
name: "BlockNoteTableExtension",
|
|
1699
1723
|
addProseMirrorPlugins: () => [
|
|
1700
|
-
|
|
1724
|
+
Re({
|
|
1701
1725
|
cellMinWidth: 100
|
|
1702
1726
|
}),
|
|
1703
|
-
|
|
1727
|
+
ze()
|
|
1704
1728
|
],
|
|
1705
1729
|
addKeyboardShortcuts() {
|
|
1706
1730
|
return {
|
|
@@ -1721,14 +1745,14 @@ const kn = yt.create({
|
|
|
1721
1745
|
storage: n.storage
|
|
1722
1746
|
};
|
|
1723
1747
|
return {
|
|
1724
|
-
tableRole:
|
|
1725
|
-
|
|
1748
|
+
tableRole: ve(
|
|
1749
|
+
Ee(n, "tableRole", t)
|
|
1726
1750
|
)
|
|
1727
1751
|
};
|
|
1728
1752
|
}
|
|
1729
|
-
}),
|
|
1753
|
+
}), Fn = {
|
|
1730
1754
|
...w
|
|
1731
|
-
},
|
|
1755
|
+
}, $n = q({
|
|
1732
1756
|
name: "table",
|
|
1733
1757
|
content: "tableRow+",
|
|
1734
1758
|
group: "blockContent",
|
|
@@ -1739,7 +1763,7 @@ const kn = yt.create({
|
|
|
1739
1763
|
},
|
|
1740
1764
|
renderHTML({ HTMLAttributes: n }) {
|
|
1741
1765
|
var t, e;
|
|
1742
|
-
return
|
|
1766
|
+
return tt(
|
|
1743
1767
|
this.name,
|
|
1744
1768
|
"table",
|
|
1745
1769
|
{
|
|
@@ -1749,7 +1773,7 @@ const kn = yt.create({
|
|
|
1749
1773
|
((e = this.options.domAttributes) == null ? void 0 : e.inlineContent) || {}
|
|
1750
1774
|
);
|
|
1751
1775
|
}
|
|
1752
|
-
}),
|
|
1776
|
+
}), Gn = W.create({
|
|
1753
1777
|
name: "tableParagraph",
|
|
1754
1778
|
group: "tableContent",
|
|
1755
1779
|
content: "inline*",
|
|
@@ -1759,58 +1783,58 @@ const kn = yt.create({
|
|
|
1759
1783
|
renderHTML({ HTMLAttributes: n }) {
|
|
1760
1784
|
return [
|
|
1761
1785
|
"p",
|
|
1762
|
-
|
|
1786
|
+
Se(this.options.HTMLAttributes, n),
|
|
1763
1787
|
0
|
|
1764
1788
|
];
|
|
1765
1789
|
}
|
|
1766
|
-
}),
|
|
1790
|
+
}), jn = et(
|
|
1791
|
+
$n,
|
|
1767
1792
|
Fn,
|
|
1768
|
-
Vn,
|
|
1769
1793
|
[
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1794
|
+
Vn,
|
|
1795
|
+
Gn,
|
|
1796
|
+
_e.extend({
|
|
1773
1797
|
content: "tableContent"
|
|
1774
1798
|
}),
|
|
1775
|
-
|
|
1799
|
+
Oe.extend({
|
|
1776
1800
|
content: "tableContent"
|
|
1777
1801
|
}),
|
|
1778
|
-
|
|
1802
|
+
Ue
|
|
1779
1803
|
]
|
|
1780
|
-
),
|
|
1781
|
-
paragraph:
|
|
1804
|
+
), re = {
|
|
1805
|
+
paragraph: zn,
|
|
1782
1806
|
heading: Tn,
|
|
1783
|
-
bulletListItem:
|
|
1784
|
-
numberedListItem:
|
|
1785
|
-
image:
|
|
1786
|
-
table:
|
|
1787
|
-
},
|
|
1788
|
-
bold:
|
|
1789
|
-
italic:
|
|
1790
|
-
underline:
|
|
1791
|
-
strike:
|
|
1792
|
-
code:
|
|
1793
|
-
textColor:
|
|
1794
|
-
backgroundColor:
|
|
1795
|
-
},
|
|
1807
|
+
bulletListItem: An,
|
|
1808
|
+
numberedListItem: _n,
|
|
1809
|
+
image: Ln,
|
|
1810
|
+
table: jn
|
|
1811
|
+
}, Wn = te(re), ie = {
|
|
1812
|
+
bold: _(Ne, "boolean"),
|
|
1813
|
+
italic: _(Pe, "boolean"),
|
|
1814
|
+
underline: _(De, "boolean"),
|
|
1815
|
+
strike: _(He, "boolean"),
|
|
1816
|
+
code: _(Ae, "boolean"),
|
|
1817
|
+
textColor: Sn,
|
|
1818
|
+
backgroundColor: vn
|
|
1819
|
+
}, Ur = oe(ie), se = {
|
|
1796
1820
|
text: { config: "text", implementation: {} },
|
|
1797
1821
|
link: { config: "link", implementation: {} }
|
|
1798
|
-
},
|
|
1799
|
-
|
|
1822
|
+
}, Rr = ee(
|
|
1823
|
+
se
|
|
1800
1824
|
);
|
|
1801
|
-
function
|
|
1802
|
-
return n in t.schema.blockSchema && t.schema.blockSchema[n] ===
|
|
1825
|
+
function I(n, t) {
|
|
1826
|
+
return n in t.schema.blockSchema && t.schema.blockSchema[n] === Wn[n];
|
|
1803
1827
|
}
|
|
1804
|
-
function
|
|
1805
|
-
return t.type === n && t.type in e.schema.blockSchema &&
|
|
1828
|
+
function zr(n, t, e) {
|
|
1829
|
+
return t.type === n && t.type in e.schema.blockSchema && I(t.type, e);
|
|
1806
1830
|
}
|
|
1807
|
-
function
|
|
1831
|
+
function qn(n, t, e) {
|
|
1808
1832
|
return t in e.schema.blockSchema && n in e.schema.blockSchema[t].propSchema && e.schema.blockSchema[t].propSchema[n] === w[n];
|
|
1809
1833
|
}
|
|
1810
|
-
function
|
|
1811
|
-
return
|
|
1834
|
+
function Vr(n, t, e) {
|
|
1835
|
+
return qn(n, t.type, e);
|
|
1812
1836
|
}
|
|
1813
|
-
function
|
|
1837
|
+
function St(n, t) {
|
|
1814
1838
|
let e, o;
|
|
1815
1839
|
if (t.firstChild.descendants((r, i) => e ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== n ? !0 : (e = r, o = i + 1, !1)), e === void 0 || o === void 0)
|
|
1816
1840
|
throw Error("Could not find block in the editor with matching ID.");
|
|
@@ -1819,34 +1843,34 @@ function Et(n, t) {
|
|
|
1819
1843
|
posBeforeNode: o
|
|
1820
1844
|
};
|
|
1821
1845
|
}
|
|
1822
|
-
function
|
|
1846
|
+
function Kn(n, t, e = "before", o) {
|
|
1823
1847
|
const r = o._tiptapEditor, i = typeof t == "string" ? t : t.id, s = [];
|
|
1824
|
-
for (const
|
|
1848
|
+
for (const u of n)
|
|
1825
1849
|
s.push(
|
|
1826
|
-
|
|
1850
|
+
D(u, r.schema, o.schema.styleSchema)
|
|
1827
1851
|
);
|
|
1828
|
-
const { node: a, posBeforeNode: l } =
|
|
1852
|
+
const { node: a, posBeforeNode: l } = St(i, r.state.doc);
|
|
1829
1853
|
if (e === "before" && r.view.dispatch(
|
|
1830
1854
|
r.state.tr.insert(l, s)
|
|
1831
1855
|
), e === "after" && r.view.dispatch(
|
|
1832
1856
|
r.state.tr.insert(l + a.nodeSize, s)
|
|
1833
1857
|
), e === "nested" && a.childCount < 2) {
|
|
1834
|
-
const
|
|
1858
|
+
const u = r.state.schema.nodes.blockGroup.create(
|
|
1835
1859
|
{},
|
|
1836
1860
|
s
|
|
1837
1861
|
);
|
|
1838
1862
|
r.view.dispatch(
|
|
1839
1863
|
r.state.tr.insert(
|
|
1840
1864
|
l + a.firstChild.nodeSize + 1,
|
|
1841
|
-
|
|
1865
|
+
u
|
|
1842
1866
|
)
|
|
1843
1867
|
);
|
|
1844
1868
|
}
|
|
1845
1869
|
const c = [];
|
|
1846
|
-
for (const
|
|
1870
|
+
for (const u of s)
|
|
1847
1871
|
c.push(
|
|
1848
|
-
|
|
1849
|
-
|
|
1872
|
+
y(
|
|
1873
|
+
u,
|
|
1850
1874
|
o.schema.blockSchema,
|
|
1851
1875
|
o.schema.inlineContentSchema,
|
|
1852
1876
|
o.schema.styleSchema,
|
|
@@ -1855,11 +1879,11 @@ function qn(n, t, e = "before", o) {
|
|
|
1855
1879
|
);
|
|
1856
1880
|
return c;
|
|
1857
1881
|
}
|
|
1858
|
-
function
|
|
1859
|
-
const o = e._tiptapEditor, r = typeof n == "string" ? n : n.id, { posBeforeNode: i } =
|
|
1882
|
+
function Jn(n, t, e) {
|
|
1883
|
+
const o = e._tiptapEditor, r = typeof n == "string" ? n : n.id, { posBeforeNode: i } = St(r, o.state.doc);
|
|
1860
1884
|
o.commands.BNUpdateBlock(i + 1, t);
|
|
1861
1885
|
const s = o.state.doc.resolve(i + 1).node();
|
|
1862
|
-
return
|
|
1886
|
+
return y(
|
|
1863
1887
|
s,
|
|
1864
1888
|
e.schema.blockSchema,
|
|
1865
1889
|
e.schema.inlineContentSchema,
|
|
@@ -1867,7 +1891,7 @@ function Kn(n, t, e) {
|
|
|
1867
1891
|
e.blockCache
|
|
1868
1892
|
);
|
|
1869
1893
|
}
|
|
1870
|
-
function
|
|
1894
|
+
function ae(n, t, e) {
|
|
1871
1895
|
const o = t._tiptapEditor, r = o.state.tr, i = new Set(
|
|
1872
1896
|
n.map(
|
|
1873
1897
|
(l) => typeof l == "string" ? l : l.id
|
|
@@ -1880,7 +1904,7 @@ function se(n, t, e) {
|
|
|
1880
1904
|
if (l.type.name !== "blockContainer" || !i.has(l.attrs.id))
|
|
1881
1905
|
return !0;
|
|
1882
1906
|
s.push(
|
|
1883
|
-
|
|
1907
|
+
y(
|
|
1884
1908
|
l,
|
|
1885
1909
|
t.schema.blockSchema,
|
|
1886
1910
|
t.schema.inlineContentSchema,
|
|
@@ -1888,10 +1912,10 @@ function se(n, t, e) {
|
|
|
1888
1912
|
t.blockCache
|
|
1889
1913
|
)
|
|
1890
1914
|
), i.delete(l.attrs.id), a = (e == null ? void 0 : e(l, c, r, a)) || a;
|
|
1891
|
-
const p = r.doc.nodeSize;
|
|
1892
|
-
r.delete(c - a - 1, c - a + l.nodeSize + 1);
|
|
1893
1915
|
const u = r.doc.nodeSize;
|
|
1894
|
-
|
|
1916
|
+
r.delete(c - a - 1, c - a + l.nodeSize + 1);
|
|
1917
|
+
const p = r.doc.nodeSize;
|
|
1918
|
+
return a += u - p, !1;
|
|
1895
1919
|
}), i.size > 0) {
|
|
1896
1920
|
const l = [...i].join(`
|
|
1897
1921
|
`);
|
|
@@ -1901,31 +1925,31 @@ function se(n, t, e) {
|
|
|
1901
1925
|
}
|
|
1902
1926
|
return o.view.dispatch(r), s;
|
|
1903
1927
|
}
|
|
1904
|
-
function
|
|
1905
|
-
return
|
|
1928
|
+
function Xn(n, t) {
|
|
1929
|
+
return ae(n, t);
|
|
1906
1930
|
}
|
|
1907
|
-
function
|
|
1931
|
+
function Yn(n, t, e) {
|
|
1908
1932
|
const o = e._tiptapEditor, r = [];
|
|
1909
1933
|
for (const l of t)
|
|
1910
1934
|
r.push(
|
|
1911
|
-
|
|
1935
|
+
D(l, o.schema, e.schema.styleSchema)
|
|
1912
1936
|
);
|
|
1913
|
-
const i = typeof n[0] == "string" ? n[0] : n[0].id, s =
|
|
1937
|
+
const i = typeof n[0] == "string" ? n[0] : n[0].id, s = ae(
|
|
1914
1938
|
n,
|
|
1915
1939
|
e,
|
|
1916
|
-
(l, c,
|
|
1940
|
+
(l, c, u, p) => {
|
|
1917
1941
|
if (l.attrs.id === i) {
|
|
1918
|
-
const m =
|
|
1919
|
-
|
|
1920
|
-
const h =
|
|
1921
|
-
return
|
|
1942
|
+
const m = u.doc.nodeSize;
|
|
1943
|
+
u.insert(c, r);
|
|
1944
|
+
const h = u.doc.nodeSize;
|
|
1945
|
+
return p + m - h;
|
|
1922
1946
|
}
|
|
1923
|
-
return
|
|
1947
|
+
return p;
|
|
1924
1948
|
}
|
|
1925
1949
|
), a = [];
|
|
1926
1950
|
for (const l of r)
|
|
1927
1951
|
a.push(
|
|
1928
|
-
|
|
1952
|
+
y(
|
|
1929
1953
|
l,
|
|
1930
1954
|
e.schema.blockSchema,
|
|
1931
1955
|
e.schema.inlineContentSchema,
|
|
@@ -1935,18 +1959,18 @@ function Xn(n, t, e) {
|
|
|
1935
1959
|
);
|
|
1936
1960
|
return { insertedBlocks: a, removedBlocks: s };
|
|
1937
1961
|
}
|
|
1938
|
-
function
|
|
1962
|
+
function Qn(n, t, e, o = { updateSelection: !0 }) {
|
|
1939
1963
|
const r = e._tiptapEditor, i = r.state.tr;
|
|
1940
|
-
let { from: s, to: a } = typeof n == "number" ? { from: n, to: n } : { from: n.from, to: n.to }, l = !0, c = !0,
|
|
1941
|
-
if (t.forEach((
|
|
1942
|
-
|
|
1964
|
+
let { from: s, to: a } = typeof n == "number" ? { from: n, to: n } : { from: n.from, to: n.to }, l = !0, c = !0, u = "";
|
|
1965
|
+
if (t.forEach((p) => {
|
|
1966
|
+
p.check(), l && p.isText && p.marks.length === 0 ? u += p.text : l = !1, c = c ? p.isBlock : !1;
|
|
1943
1967
|
}), s === a && c) {
|
|
1944
|
-
const { parent:
|
|
1945
|
-
|
|
1968
|
+
const { parent: p } = i.doc.resolve(s);
|
|
1969
|
+
p.isTextblock && !p.type.spec.code && !p.childCount && (s -= 1, a += 1);
|
|
1946
1970
|
}
|
|
1947
|
-
return l ? i.insertText(
|
|
1971
|
+
return l ? i.insertText(u, s, a) : i.replaceWith(s, a, t), o.updateSelection && Ce(i, i.steps.length - 1, -1), r.view.dispatch(i), !0;
|
|
1948
1972
|
}
|
|
1949
|
-
function
|
|
1973
|
+
function Zn() {
|
|
1950
1974
|
const n = (t) => {
|
|
1951
1975
|
let e = t.children.length;
|
|
1952
1976
|
for (let o = 0; o < e; o++) {
|
|
@@ -1962,35 +1986,35 @@ function Qn() {
|
|
|
1962
1986
|
};
|
|
1963
1987
|
return n;
|
|
1964
1988
|
}
|
|
1965
|
-
function
|
|
1966
|
-
return
|
|
1989
|
+
function Ct(n) {
|
|
1990
|
+
return kt().use(zt, { fragment: !0 }).use(Zn).use(Ve).use(Ft).use(Fe).processSync(n).value;
|
|
1967
1991
|
}
|
|
1968
|
-
function
|
|
1969
|
-
const r =
|
|
1970
|
-
return
|
|
1992
|
+
function to(n, t, e) {
|
|
1993
|
+
const r = lt(t, e).exportBlocks(n);
|
|
1994
|
+
return Ct(r);
|
|
1971
1995
|
}
|
|
1972
|
-
function
|
|
1996
|
+
function eo(n) {
|
|
1973
1997
|
return Array.prototype.indexOf.call(n.parentElement.childNodes, n);
|
|
1974
1998
|
}
|
|
1975
|
-
function
|
|
1999
|
+
function no(n) {
|
|
1976
2000
|
return n.nodeType === 3 && !/\S/.test(n.nodeValue || "");
|
|
1977
2001
|
}
|
|
1978
|
-
function
|
|
2002
|
+
function oo(n) {
|
|
1979
2003
|
n.querySelectorAll("li > ul, li > ol").forEach((t) => {
|
|
1980
|
-
const e =
|
|
2004
|
+
const e = eo(t), o = t.parentElement, r = Array.from(o.childNodes).slice(
|
|
1981
2005
|
e + 1
|
|
1982
2006
|
);
|
|
1983
2007
|
t.remove(), r.forEach((i) => {
|
|
1984
2008
|
i.remove();
|
|
1985
2009
|
}), o.insertAdjacentElement("afterend", t), r.reverse().forEach((i) => {
|
|
1986
|
-
if (
|
|
2010
|
+
if (no(i))
|
|
1987
2011
|
return;
|
|
1988
2012
|
const s = document.createElement("li");
|
|
1989
2013
|
s.append(i), t.insertAdjacentElement("afterend", s);
|
|
1990
2014
|
}), o.childNodes.length === 0 && o.remove();
|
|
1991
2015
|
});
|
|
1992
2016
|
}
|
|
1993
|
-
function
|
|
2017
|
+
function ro(n) {
|
|
1994
2018
|
n.querySelectorAll("li + ul, li + ol").forEach((t) => {
|
|
1995
2019
|
var i, s;
|
|
1996
2020
|
const e = t.previousElementSibling, o = document.createElement("div");
|
|
@@ -2000,28 +2024,28 @@ function oo(n) {
|
|
|
2000
2024
|
r.append(o.nextElementSibling);
|
|
2001
2025
|
});
|
|
2002
2026
|
}
|
|
2003
|
-
let
|
|
2004
|
-
function
|
|
2005
|
-
return
|
|
2027
|
+
let Dt = null;
|
|
2028
|
+
function io() {
|
|
2029
|
+
return Dt || (Dt = document.implementation.createHTMLDocument("title"));
|
|
2006
2030
|
}
|
|
2007
|
-
function
|
|
2031
|
+
function le(n) {
|
|
2008
2032
|
if (typeof n == "string") {
|
|
2009
|
-
const t =
|
|
2033
|
+
const t = io().createElement("div");
|
|
2010
2034
|
t.innerHTML = n, n = t;
|
|
2011
2035
|
}
|
|
2012
|
-
return
|
|
2036
|
+
return oo(n), ro(n), n;
|
|
2013
2037
|
}
|
|
2014
|
-
async function
|
|
2015
|
-
const i =
|
|
2038
|
+
async function ce(n, t, e, o, r) {
|
|
2039
|
+
const i = le(n), a = ge.fromSchema(r).parse(i, {
|
|
2016
2040
|
topNode: r.nodes.blockGroup.create()
|
|
2017
2041
|
}), l = [];
|
|
2018
2042
|
for (let c = 0; c < a.childCount; c++)
|
|
2019
2043
|
l.push(
|
|
2020
|
-
|
|
2044
|
+
y(a.child(c), t, e, o)
|
|
2021
2045
|
);
|
|
2022
2046
|
return l;
|
|
2023
2047
|
}
|
|
2024
|
-
function
|
|
2048
|
+
function so(n, t) {
|
|
2025
2049
|
const e = t.value ? t.value + `
|
|
2026
2050
|
` : "", o = {};
|
|
2027
2051
|
t.lang && (o["data-language"] = t.lang);
|
|
@@ -2038,14 +2062,14 @@ function io(n, t) {
|
|
|
2038
2062
|
children: [r]
|
|
2039
2063
|
}, n.patch(t, r), r;
|
|
2040
2064
|
}
|
|
2041
|
-
function
|
|
2042
|
-
const i =
|
|
2065
|
+
function ao(n, t, e, o, r) {
|
|
2066
|
+
const i = kt().use($e).use(Ft).use(Ge, {
|
|
2043
2067
|
handlers: {
|
|
2044
|
-
...
|
|
2045
|
-
code:
|
|
2068
|
+
...je,
|
|
2069
|
+
code: so
|
|
2046
2070
|
}
|
|
2047
|
-
}).use(
|
|
2048
|
-
return
|
|
2071
|
+
}).use(Vt).processSync(n);
|
|
2072
|
+
return ce(
|
|
2049
2073
|
i.value,
|
|
2050
2074
|
t,
|
|
2051
2075
|
e,
|
|
@@ -2053,7 +2077,7 @@ function so(n, t, e, o, r) {
|
|
|
2053
2077
|
r
|
|
2054
2078
|
);
|
|
2055
2079
|
}
|
|
2056
|
-
class
|
|
2080
|
+
class K {
|
|
2057
2081
|
constructor() {
|
|
2058
2082
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2059
2083
|
d(this, "callbacks", {});
|
|
@@ -2073,7 +2097,7 @@ class q {
|
|
|
2073
2097
|
this.callbacks = {};
|
|
2074
2098
|
}
|
|
2075
2099
|
}
|
|
2076
|
-
class
|
|
2100
|
+
class lo {
|
|
2077
2101
|
constructor(t, e, o) {
|
|
2078
2102
|
d(this, "state");
|
|
2079
2103
|
d(this, "emitUpdate");
|
|
@@ -2124,20 +2148,20 @@ class ao {
|
|
|
2124
2148
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || a))
|
|
2125
2149
|
return;
|
|
2126
2150
|
this.prevWasEditable = this.editor.isEditable;
|
|
2127
|
-
const { ranges: l } = s, c = Math.min(...l.map((f) => f.$from.pos)),
|
|
2151
|
+
const { ranges: l } = s, c = Math.min(...l.map((f) => f.$from.pos)), u = Math.max(...l.map((f) => f.$to.pos)), p = (m = this.shouldShow) == null ? void 0 : m.call(this, {
|
|
2128
2152
|
view: t,
|
|
2129
2153
|
state: o,
|
|
2130
2154
|
from: c,
|
|
2131
|
-
to:
|
|
2155
|
+
to: u
|
|
2132
2156
|
});
|
|
2133
|
-
if (this.editor.isEditable && !this.preventShow && (
|
|
2157
|
+
if (this.editor.isEditable && !this.preventShow && (p || this.preventHide)) {
|
|
2134
2158
|
this.state = {
|
|
2135
2159
|
show: !0,
|
|
2136
2160
|
referencePos: this.getSelectionBoundingBox()
|
|
2137
2161
|
}, this.emitUpdate();
|
|
2138
2162
|
return;
|
|
2139
2163
|
}
|
|
2140
|
-
if ((h = this.state) != null && h.show && !this.preventHide && (!
|
|
2164
|
+
if ((h = this.state) != null && h.show && !this.preventHide && (!p || this.preventShow || !this.editor.isEditable)) {
|
|
2141
2165
|
this.state.show = !1, this.emitUpdate();
|
|
2142
2166
|
return;
|
|
2143
2167
|
}
|
|
@@ -2147,25 +2171,25 @@ class ao {
|
|
|
2147
2171
|
}
|
|
2148
2172
|
getSelectionBoundingBox() {
|
|
2149
2173
|
const { state: t } = this.pmView, { selection: e } = t, { ranges: o } = e, r = Math.min(...o.map((s) => s.$from.pos)), i = Math.max(...o.map((s) => s.$to.pos));
|
|
2150
|
-
if (
|
|
2174
|
+
if (xe(e)) {
|
|
2151
2175
|
const s = this.pmView.nodeDOM(r);
|
|
2152
2176
|
if (s)
|
|
2153
2177
|
return s.getBoundingClientRect();
|
|
2154
2178
|
}
|
|
2155
|
-
return
|
|
2179
|
+
return ft(this.pmView, r, i);
|
|
2156
2180
|
}
|
|
2157
2181
|
}
|
|
2158
|
-
const
|
|
2182
|
+
const co = new x(
|
|
2159
2183
|
"FormattingToolbarPlugin"
|
|
2160
2184
|
);
|
|
2161
|
-
class
|
|
2185
|
+
class uo extends K {
|
|
2162
2186
|
constructor(e) {
|
|
2163
2187
|
super();
|
|
2164
2188
|
d(this, "view");
|
|
2165
2189
|
d(this, "plugin");
|
|
2166
2190
|
this.plugin = new v({
|
|
2167
|
-
key:
|
|
2168
|
-
view: (o) => (this.view = new
|
|
2191
|
+
key: co,
|
|
2192
|
+
view: (o) => (this.view = new lo(e, o, (r) => {
|
|
2169
2193
|
this.emit("update", r);
|
|
2170
2194
|
}), this.view)
|
|
2171
2195
|
});
|
|
@@ -2181,24 +2205,18 @@ class po {
|
|
|
2181
2205
|
d(this, "menuUpdateTimer");
|
|
2182
2206
|
d(this, "startMenuUpdateTimer");
|
|
2183
2207
|
d(this, "stopMenuUpdateTimer");
|
|
2184
|
-
d(this, "
|
|
2185
|
-
d(this, "
|
|
2186
|
-
d(this, "
|
|
2187
|
-
d(this, "
|
|
2188
|
-
d(this, "
|
|
2189
|
-
d(this, "
|
|
2208
|
+
d(this, "mouseHoveredLinkMark");
|
|
2209
|
+
d(this, "mouseHoveredLinkMarkRange");
|
|
2210
|
+
d(this, "keyboardHoveredLinkMark");
|
|
2211
|
+
d(this, "keyboardHoveredLinkMarkRange");
|
|
2212
|
+
d(this, "linkMark");
|
|
2213
|
+
d(this, "linkMarkRange");
|
|
2190
2214
|
d(this, "mouseOverHandler", (t) => {
|
|
2191
|
-
if (this.
|
|
2192
|
-
const e = t.target, o = this.pmView.posAtDOM(e, 0) + 1, r = this.pmView.state.doc.resolve(
|
|
2193
|
-
o
|
|
2194
|
-
), i = r.marks();
|
|
2215
|
+
if (this.mouseHoveredLinkMark = void 0, this.mouseHoveredLinkMarkRange = void 0, this.stopMenuUpdateTimer(), t.target instanceof HTMLAnchorElement && t.target.nodeName === "A") {
|
|
2216
|
+
const e = t.target, o = this.pmView.posAtDOM(e, 0) + 1, r = this.pmView.state.doc.resolve(o), i = r.marks();
|
|
2195
2217
|
for (const s of i)
|
|
2196
2218
|
if (s.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2197
|
-
this.
|
|
2198
|
-
r,
|
|
2199
|
-
s.type,
|
|
2200
|
-
s.attrs
|
|
2201
|
-
) || void 0;
|
|
2219
|
+
this.mouseHoveredLinkMark = s, this.mouseHoveredLinkMarkRange = Mt(r, s.type, s.attrs) || void 0;
|
|
2202
2220
|
break;
|
|
2203
2221
|
}
|
|
2204
2222
|
}
|
|
@@ -2208,21 +2226,21 @@ class po {
|
|
|
2208
2226
|
var o;
|
|
2209
2227
|
const e = this.pmView.dom.parentElement;
|
|
2210
2228
|
// Toolbar is open.
|
|
2211
|
-
this.
|
|
2229
|
+
this.linkMark && // An element is clicked.
|
|
2212
2230
|
t && t.target && // The clicked element is not the editor.
|
|
2213
2231
|
!(e === t.target || e.contains(t.target)) && (o = this.state) != null && o.show && (this.state.show = !1, this.emitUpdate());
|
|
2214
2232
|
});
|
|
2215
2233
|
d(this, "scrollHandler", () => {
|
|
2216
2234
|
var t;
|
|
2217
|
-
this.
|
|
2235
|
+
this.linkMark !== void 0 && (t = this.state) != null && t.show && (this.state.referencePos = ft(
|
|
2218
2236
|
this.pmView,
|
|
2219
|
-
this.
|
|
2220
|
-
this.
|
|
2237
|
+
this.linkMarkRange.from,
|
|
2238
|
+
this.linkMarkRange.to
|
|
2221
2239
|
), this.emitUpdate());
|
|
2222
2240
|
});
|
|
2223
2241
|
this.editor = t, this.pmView = e, this.emitUpdate = () => {
|
|
2224
2242
|
if (!this.state)
|
|
2225
|
-
throw new Error("Attempting to update uninitialized
|
|
2243
|
+
throw new Error("Attempting to update uninitialized link toolbar");
|
|
2226
2244
|
o(this.state);
|
|
2227
2245
|
}, this.startMenuUpdateTimer = () => {
|
|
2228
2246
|
this.menuUpdateTimer = setTimeout(() => {
|
|
@@ -2230,26 +2248,26 @@ class po {
|
|
|
2230
2248
|
}, 250);
|
|
2231
2249
|
}, this.stopMenuUpdateTimer = () => (this.menuUpdateTimer && (clearTimeout(this.menuUpdateTimer), this.menuUpdateTimer = void 0), !1), this.pmView.dom.addEventListener("mouseover", this.mouseOverHandler), document.addEventListener("click", this.clickHandler, !0), document.addEventListener("scroll", this.scrollHandler);
|
|
2232
2250
|
}
|
|
2233
|
-
|
|
2251
|
+
editLink(t, e) {
|
|
2234
2252
|
var r;
|
|
2235
2253
|
const o = this.pmView.state.tr.insertText(
|
|
2236
2254
|
e,
|
|
2237
|
-
this.
|
|
2238
|
-
this.
|
|
2255
|
+
this.linkMarkRange.from,
|
|
2256
|
+
this.linkMarkRange.to
|
|
2239
2257
|
);
|
|
2240
2258
|
o.addMark(
|
|
2241
|
-
this.
|
|
2242
|
-
this.
|
|
2259
|
+
this.linkMarkRange.from,
|
|
2260
|
+
this.linkMarkRange.from + e.length,
|
|
2243
2261
|
this.pmView.state.schema.mark("link", { href: t })
|
|
2244
2262
|
), this.pmView.dispatch(o), this.pmView.focus(), (r = this.state) != null && r.show && (this.state.show = !1, this.emitUpdate());
|
|
2245
2263
|
}
|
|
2246
|
-
|
|
2264
|
+
deleteLink() {
|
|
2247
2265
|
var t;
|
|
2248
2266
|
this.pmView.dispatch(
|
|
2249
2267
|
this.pmView.state.tr.removeMark(
|
|
2250
|
-
this.
|
|
2251
|
-
this.
|
|
2252
|
-
this.
|
|
2268
|
+
this.linkMarkRange.from,
|
|
2269
|
+
this.linkMarkRange.to,
|
|
2270
|
+
this.linkMark.type
|
|
2253
2271
|
).setMeta("preventAutolink", !0)
|
|
2254
2272
|
), this.pmView.focus(), (t = this.state) != null && t.show && (this.state.show = !1, this.emitUpdate());
|
|
2255
2273
|
}
|
|
@@ -2257,12 +2275,12 @@ class po {
|
|
|
2257
2275
|
var e;
|
|
2258
2276
|
if (!this.pmView.hasFocus())
|
|
2259
2277
|
return;
|
|
2260
|
-
const t = this.
|
|
2261
|
-
if (this.
|
|
2278
|
+
const t = this.linkMark;
|
|
2279
|
+
if (this.linkMark = void 0, this.linkMarkRange = void 0, this.keyboardHoveredLinkMark = void 0, this.keyboardHoveredLinkMarkRange = void 0, this.pmView.state.selection.empty) {
|
|
2262
2280
|
const o = this.pmView.state.selection.$from.marks();
|
|
2263
2281
|
for (const r of o)
|
|
2264
2282
|
if (r.type.name === this.pmView.state.schema.mark("link").type.name) {
|
|
2265
|
-
this.
|
|
2283
|
+
this.keyboardHoveredLinkMark = r, this.keyboardHoveredLinkMarkRange = Mt(
|
|
2266
2284
|
this.pmView.state.selection.$from,
|
|
2267
2285
|
r.type,
|
|
2268
2286
|
r.attrs
|
|
@@ -2270,23 +2288,23 @@ class po {
|
|
|
2270
2288
|
break;
|
|
2271
2289
|
}
|
|
2272
2290
|
}
|
|
2273
|
-
if (this.
|
|
2291
|
+
if (this.mouseHoveredLinkMark && (this.linkMark = this.mouseHoveredLinkMark, this.linkMarkRange = this.mouseHoveredLinkMarkRange), this.keyboardHoveredLinkMark && (this.linkMark = this.keyboardHoveredLinkMark, this.linkMarkRange = this.keyboardHoveredLinkMarkRange), this.linkMark && this.editor.isEditable) {
|
|
2274
2292
|
this.state = {
|
|
2275
2293
|
show: !0,
|
|
2276
|
-
referencePos:
|
|
2294
|
+
referencePos: ft(
|
|
2277
2295
|
this.pmView,
|
|
2278
|
-
this.
|
|
2279
|
-
this.
|
|
2296
|
+
this.linkMarkRange.from,
|
|
2297
|
+
this.linkMarkRange.to
|
|
2280
2298
|
),
|
|
2281
|
-
url: this.
|
|
2299
|
+
url: this.linkMark.attrs.href,
|
|
2282
2300
|
text: this.pmView.state.doc.textBetween(
|
|
2283
|
-
this.
|
|
2284
|
-
this.
|
|
2301
|
+
this.linkMarkRange.from,
|
|
2302
|
+
this.linkMarkRange.to
|
|
2285
2303
|
)
|
|
2286
2304
|
}, this.emitUpdate();
|
|
2287
2305
|
return;
|
|
2288
2306
|
}
|
|
2289
|
-
if ((e = this.state) != null && e.show && t && (!this.
|
|
2307
|
+
if ((e = this.state) != null && e.show && t && (!this.linkMark || !this.editor.isEditable)) {
|
|
2290
2308
|
this.state.show = !1, this.emitUpdate();
|
|
2291
2309
|
return;
|
|
2292
2310
|
}
|
|
@@ -2295,46 +2313,46 @@ class po {
|
|
|
2295
2313
|
this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
|
|
2296
2314
|
}
|
|
2297
2315
|
}
|
|
2298
|
-
const
|
|
2299
|
-
|
|
2300
|
-
);
|
|
2301
|
-
class ho extends q {
|
|
2316
|
+
const ho = new x("LinkToolbarPlugin");
|
|
2317
|
+
class mo extends K {
|
|
2302
2318
|
constructor(e) {
|
|
2303
2319
|
super();
|
|
2304
2320
|
d(this, "view");
|
|
2305
2321
|
d(this, "plugin");
|
|
2306
2322
|
/**
|
|
2307
|
-
* Edit the currently hovered
|
|
2323
|
+
* Edit the currently hovered link.
|
|
2308
2324
|
*/
|
|
2309
|
-
d(this, "
|
|
2310
|
-
this.view.
|
|
2325
|
+
d(this, "editLink", (e, o) => {
|
|
2326
|
+
this.view.editLink(e, o);
|
|
2311
2327
|
});
|
|
2312
2328
|
/**
|
|
2313
|
-
* Delete the currently hovered
|
|
2329
|
+
* Delete the currently hovered link.
|
|
2314
2330
|
*/
|
|
2315
|
-
d(this, "
|
|
2316
|
-
this.view.
|
|
2331
|
+
d(this, "deleteLink", () => {
|
|
2332
|
+
this.view.deleteLink();
|
|
2317
2333
|
});
|
|
2318
2334
|
/**
|
|
2319
|
-
* When hovering on/off
|
|
2320
|
-
*
|
|
2335
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
2336
|
+
* open & close with a delay.
|
|
2321
2337
|
*
|
|
2322
|
-
* This function starts the delay timer, and should be used for when the mouse
|
|
2338
|
+
* This function starts the delay timer, and should be used for when the mouse
|
|
2339
|
+
* cursor enters the link toolbar.
|
|
2323
2340
|
*/
|
|
2324
2341
|
d(this, "startHideTimer", () => {
|
|
2325
2342
|
this.view.startMenuUpdateTimer();
|
|
2326
2343
|
});
|
|
2327
2344
|
/**
|
|
2328
|
-
* When hovering on/off
|
|
2329
|
-
*
|
|
2345
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
2346
|
+
* open & close with a delay.
|
|
2330
2347
|
*
|
|
2331
|
-
* This function stops the delay timer, and should be used for when the mouse
|
|
2348
|
+
* This function stops the delay timer, and should be used for when the mouse
|
|
2349
|
+
* cursor exits the link toolbar.
|
|
2332
2350
|
*/
|
|
2333
2351
|
d(this, "stopHideTimer", () => {
|
|
2334
2352
|
this.view.stopMenuUpdateTimer();
|
|
2335
2353
|
});
|
|
2336
2354
|
this.plugin = new v({
|
|
2337
|
-
key:
|
|
2355
|
+
key: ho,
|
|
2338
2356
|
view: (o) => (this.view = new po(e, o, (r) => {
|
|
2339
2357
|
this.emit("update", r);
|
|
2340
2358
|
}), this.view)
|
|
@@ -2344,97 +2362,8 @@ class ho extends q {
|
|
|
2344
2362
|
return this.on("update", e);
|
|
2345
2363
|
}
|
|
2346
2364
|
}
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
d(this, "state");
|
|
2350
|
-
d(this, "emitUpdate");
|
|
2351
|
-
d(this, "prevWasEditable", null);
|
|
2352
|
-
d(this, "mouseDownHandler", () => {
|
|
2353
|
-
var t;
|
|
2354
|
-
(t = this.state) != null && t.show && (this.state.show = !1, this.emitUpdate());
|
|
2355
|
-
});
|
|
2356
|
-
// For dragging the whole editor.
|
|
2357
|
-
d(this, "dragstartHandler", () => {
|
|
2358
|
-
var t;
|
|
2359
|
-
(t = this.state) != null && t.show && (this.state.show = !1, this.emitUpdate());
|
|
2360
|
-
});
|
|
2361
|
-
d(this, "blurHandler", (t) => {
|
|
2362
|
-
var o;
|
|
2363
|
-
const e = this.pmView.dom.parentElement;
|
|
2364
|
-
// An element is clicked.
|
|
2365
|
-
t && t.relatedTarget && // Element is inside the editor.
|
|
2366
|
-
(e === t.relatedTarget || e.contains(t.relatedTarget)) || (o = this.state) != null && o.show && (this.state.show = !1, this.emitUpdate());
|
|
2367
|
-
});
|
|
2368
|
-
d(this, "scrollHandler", () => {
|
|
2369
|
-
var t;
|
|
2370
|
-
if ((t = this.state) != null && t.show) {
|
|
2371
|
-
const e = document.querySelector(
|
|
2372
|
-
`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`
|
|
2373
|
-
);
|
|
2374
|
-
this.state.referencePos = e.getBoundingClientRect(), this.emitUpdate();
|
|
2375
|
-
}
|
|
2376
|
-
});
|
|
2377
|
-
this.pluginKey = t, this.pmView = e, this.emitUpdate = () => {
|
|
2378
|
-
if (!this.state)
|
|
2379
|
-
throw new Error("Attempting to update uninitialized image toolbar");
|
|
2380
|
-
o(this.state);
|
|
2381
|
-
}, e.dom.addEventListener("mousedown", this.mouseDownHandler), e.dom.addEventListener("dragstart", this.dragstartHandler), e.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2382
|
-
}
|
|
2383
|
-
update(t, e) {
|
|
2384
|
-
var r, i;
|
|
2385
|
-
const o = this.pluginKey.getState(t.state);
|
|
2386
|
-
if (!((r = this.state) != null && r.show) && o.block) {
|
|
2387
|
-
const s = document.querySelector(
|
|
2388
|
-
`[data-node-type="blockContainer"][data-id="${o.block.id}"]`
|
|
2389
|
-
);
|
|
2390
|
-
this.state = {
|
|
2391
|
-
show: !0,
|
|
2392
|
-
referencePos: s.getBoundingClientRect(),
|
|
2393
|
-
block: o.block
|
|
2394
|
-
}, this.emitUpdate();
|
|
2395
|
-
return;
|
|
2396
|
-
}
|
|
2397
|
-
(!t.state.selection.eq(e.selection) || !t.state.doc.eq(e.doc)) && (i = this.state) != null && i.show && (this.state.show = !1, this.emitUpdate());
|
|
2398
|
-
}
|
|
2399
|
-
destroy() {
|
|
2400
|
-
this.pmView.dom.removeEventListener("mousedown", this.mouseDownHandler), this.pmView.dom.removeEventListener("dragstart", this.dragstartHandler), this.pmView.dom.removeEventListener("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
const ut = new T("ImageToolbarPlugin");
|
|
2404
|
-
class fo extends q {
|
|
2405
|
-
constructor(e) {
|
|
2406
|
-
super();
|
|
2407
|
-
d(this, "view");
|
|
2408
|
-
d(this, "plugin");
|
|
2409
|
-
this.plugin = new v({
|
|
2410
|
-
key: ut,
|
|
2411
|
-
view: (o) => (this.view = new mo(
|
|
2412
|
-
// editor,
|
|
2413
|
-
ut,
|
|
2414
|
-
o,
|
|
2415
|
-
(r) => {
|
|
2416
|
-
this.emit("update", r);
|
|
2417
|
-
}
|
|
2418
|
-
), this.view),
|
|
2419
|
-
state: {
|
|
2420
|
-
init: () => ({
|
|
2421
|
-
block: void 0
|
|
2422
|
-
}),
|
|
2423
|
-
apply: (o) => {
|
|
2424
|
-
var i;
|
|
2425
|
-
return {
|
|
2426
|
-
block: (i = o.getMeta(ut)) == null ? void 0 : i.block
|
|
2427
|
-
};
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
});
|
|
2431
|
-
}
|
|
2432
|
-
onUpdate(e) {
|
|
2433
|
-
return this.on("update", e);
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
const go = Te((n) => n.type.name === "blockContainer");
|
|
2437
|
-
class bo {
|
|
2365
|
+
const fo = Te((n) => n.type.name === "blockContainer");
|
|
2366
|
+
class go {
|
|
2438
2367
|
constructor(t, e) {
|
|
2439
2368
|
d(this, "state");
|
|
2440
2369
|
d(this, "emitUpdate");
|
|
@@ -2451,7 +2380,7 @@ class bo {
|
|
|
2451
2380
|
d(this, "closeMenu", () => {
|
|
2452
2381
|
this.editor._tiptapEditor.view.dispatch(
|
|
2453
2382
|
this.editor._tiptapEditor.view.state.tr.setMeta(
|
|
2454
|
-
|
|
2383
|
+
R,
|
|
2455
2384
|
null
|
|
2456
2385
|
)
|
|
2457
2386
|
);
|
|
@@ -2469,7 +2398,7 @@ class bo {
|
|
|
2469
2398
|
}, document.addEventListener("scroll", this.handleScroll);
|
|
2470
2399
|
}
|
|
2471
2400
|
update(t, e) {
|
|
2472
|
-
const o =
|
|
2401
|
+
const o = R.getState(e), r = R.getState(
|
|
2473
2402
|
t.state
|
|
2474
2403
|
), i = o === void 0 && r !== void 0, s = o !== void 0 && r === void 0;
|
|
2475
2404
|
if (!i && !(o !== void 0 && r !== void 0) && !s)
|
|
@@ -2491,8 +2420,8 @@ class bo {
|
|
|
2491
2420
|
document.removeEventListener("scroll", this.handleScroll);
|
|
2492
2421
|
}
|
|
2493
2422
|
}
|
|
2494
|
-
const
|
|
2495
|
-
class
|
|
2423
|
+
const R = new x("SuggestionMenuPlugin");
|
|
2424
|
+
class bo extends K {
|
|
2496
2425
|
constructor(e) {
|
|
2497
2426
|
super();
|
|
2498
2427
|
d(this, "view");
|
|
@@ -2511,8 +2440,8 @@ class yo extends q {
|
|
|
2511
2440
|
d(this, "clearQuery", () => this.view.clearQuery());
|
|
2512
2441
|
const o = this.triggerCharacters;
|
|
2513
2442
|
this.plugin = new v({
|
|
2514
|
-
key:
|
|
2515
|
-
view: () => (this.view = new
|
|
2443
|
+
key: R,
|
|
2444
|
+
view: () => (this.view = new go(
|
|
2516
2445
|
e,
|
|
2517
2446
|
(r, i) => {
|
|
2518
2447
|
this.emit(`update ${r}`, i);
|
|
@@ -2526,7 +2455,7 @@ class yo extends q {
|
|
|
2526
2455
|
apply(r, i, s, a) {
|
|
2527
2456
|
if (r.getMeta("orderedListIndexing") !== void 0)
|
|
2528
2457
|
return i;
|
|
2529
|
-
const l = r.getMeta(
|
|
2458
|
+
const l = r.getMeta(R);
|
|
2530
2459
|
if (typeof l == "object" && l !== null && i === void 0)
|
|
2531
2460
|
return {
|
|
2532
2461
|
triggerCharacter: l.triggerCharacter,
|
|
@@ -2557,7 +2486,7 @@ class yo extends q {
|
|
|
2557
2486
|
handleKeyDown(r, i) {
|
|
2558
2487
|
const s = this.getState(r.state);
|
|
2559
2488
|
return o.includes(i.key) && s === void 0 ? (i.preventDefault(), r.dispatch(
|
|
2560
|
-
r.state.tr.insertText(i.key).scrollIntoView().setMeta(
|
|
2489
|
+
r.state.tr.insertText(i.key).scrollIntoView().setMeta(R, {
|
|
2561
2490
|
triggerCharacter: i.key
|
|
2562
2491
|
})
|
|
2563
2492
|
), !0) : !1;
|
|
@@ -2568,10 +2497,10 @@ class yo extends q {
|
|
|
2568
2497
|
if (i === void 0)
|
|
2569
2498
|
return null;
|
|
2570
2499
|
if (!i.fromUserInput) {
|
|
2571
|
-
const s =
|
|
2500
|
+
const s = fo(r.selection);
|
|
2572
2501
|
if (s)
|
|
2573
|
-
return
|
|
2574
|
-
|
|
2502
|
+
return G.create(r.doc, [
|
|
2503
|
+
j.node(
|
|
2575
2504
|
s.pos,
|
|
2576
2505
|
s.pos + s.node.nodeSize,
|
|
2577
2506
|
{
|
|
@@ -2582,8 +2511,8 @@ class yo extends q {
|
|
|
2582
2511
|
)
|
|
2583
2512
|
]);
|
|
2584
2513
|
}
|
|
2585
|
-
return
|
|
2586
|
-
|
|
2514
|
+
return G.create(r.doc, [
|
|
2515
|
+
j.inline(
|
|
2587
2516
|
i.queryStartPos - i.triggerCharacter.length,
|
|
2588
2517
|
i.queryStartPos,
|
|
2589
2518
|
{
|
|
@@ -2601,10 +2530,10 @@ class yo extends q {
|
|
|
2601
2530
|
return this.triggerCharacters.includes(e) || this.addTriggerCharacter(e), this.on(`update ${e}`, o);
|
|
2602
2531
|
}
|
|
2603
2532
|
}
|
|
2604
|
-
function
|
|
2533
|
+
function Fr(n, t) {
|
|
2605
2534
|
n.suggestionMenus.addTriggerCharacter(t);
|
|
2606
2535
|
}
|
|
2607
|
-
class
|
|
2536
|
+
class $ extends ut {
|
|
2608
2537
|
constructor(e, o) {
|
|
2609
2538
|
super(e, o);
|
|
2610
2539
|
d(this, "nodes");
|
|
@@ -2615,13 +2544,13 @@ class F extends dt {
|
|
|
2615
2544
|
});
|
|
2616
2545
|
}
|
|
2617
2546
|
static create(e, o, r = o) {
|
|
2618
|
-
return new
|
|
2547
|
+
return new $(e.resolve(o), e.resolve(r));
|
|
2619
2548
|
}
|
|
2620
2549
|
content() {
|
|
2621
|
-
return new
|
|
2550
|
+
return new U(T.from(this.nodes), 0, 0);
|
|
2622
2551
|
}
|
|
2623
2552
|
eq(e) {
|
|
2624
|
-
if (!(e instanceof
|
|
2553
|
+
if (!(e instanceof $) || this.nodes.length !== e.nodes.length || this.from !== e.from || this.to !== e.to)
|
|
2625
2554
|
return !1;
|
|
2626
2555
|
for (let o = 0; o < this.nodes.length; o++)
|
|
2627
2556
|
if (!this.nodes[o].eq(e.nodes[o]))
|
|
@@ -2630,7 +2559,7 @@ class F extends dt {
|
|
|
2630
2559
|
}
|
|
2631
2560
|
map(e, o) {
|
|
2632
2561
|
const r = o.mapResult(this.from), i = o.mapResult(this.to);
|
|
2633
|
-
return i.deleted ?
|
|
2562
|
+
return i.deleted ? ut.near(e.resolve(r.pos)) : r.deleted ? ut.near(e.resolve(i.pos)) : new $(
|
|
2634
2563
|
e.resolve(r.pos),
|
|
2635
2564
|
e.resolve(i.pos)
|
|
2636
2565
|
);
|
|
@@ -2640,7 +2569,7 @@ class F extends dt {
|
|
|
2640
2569
|
}
|
|
2641
2570
|
}
|
|
2642
2571
|
let H;
|
|
2643
|
-
function
|
|
2572
|
+
function xt(n, t) {
|
|
2644
2573
|
var r;
|
|
2645
2574
|
if (!t.dom.isConnected)
|
|
2646
2575
|
return;
|
|
@@ -2656,14 +2585,14 @@ function Ct(n, t) {
|
|
|
2656
2585
|
}
|
|
2657
2586
|
}
|
|
2658
2587
|
function ko(n, t) {
|
|
2659
|
-
const e =
|
|
2588
|
+
const e = xt(n, t);
|
|
2660
2589
|
if (e && e.node.nodeType === 1) {
|
|
2661
2590
|
const o = t.docView, r = o.nearestDesc(e.node, !0);
|
|
2662
2591
|
return !r || r === o ? null : r.posBefore;
|
|
2663
2592
|
}
|
|
2664
2593
|
return null;
|
|
2665
2594
|
}
|
|
2666
|
-
function
|
|
2595
|
+
function yo(n, t) {
|
|
2667
2596
|
let e, o;
|
|
2668
2597
|
const r = t.resolve(n.from).node().type.spec.group === "blockContent", i = t.resolve(n.to).node().type.spec.group === "blockContent", s = Math.min(n.$anchor.depth, n.$head.depth);
|
|
2669
2598
|
if (r && i) {
|
|
@@ -2673,9 +2602,9 @@ function wo(n, t) {
|
|
|
2673
2602
|
e = n.from, o = n.to;
|
|
2674
2603
|
return { from: e, to: o };
|
|
2675
2604
|
}
|
|
2676
|
-
function
|
|
2605
|
+
function Ot(n, t, e = t) {
|
|
2677
2606
|
t === e && (e += n.state.doc.resolve(t + 1).node().nodeSize);
|
|
2678
|
-
const o = n.domAtPos(t).node.cloneNode(!0), r = n.domAtPos(t).node, i = (
|
|
2607
|
+
const o = n.domAtPos(t).node.cloneNode(!0), r = n.domAtPos(t).node, i = (u, p) => Array.prototype.indexOf.call(u.children, p), s = i(
|
|
2679
2608
|
r,
|
|
2680
2609
|
// Expects from position to be just before the first selected block.
|
|
2681
2610
|
n.domAtPos(t + 1).node.parentElement
|
|
@@ -2684,18 +2613,18 @@ function Dt(n, t, e = t) {
|
|
|
2684
2613
|
// Expects to position to be just after the last selected block.
|
|
2685
2614
|
n.domAtPos(e - 1).node.parentElement
|
|
2686
2615
|
);
|
|
2687
|
-
for (let
|
|
2688
|
-
(
|
|
2689
|
-
|
|
2616
|
+
for (let u = r.childElementCount - 1; u >= 0; u--)
|
|
2617
|
+
(u > a || u < s) && o.removeChild(o.children[u]);
|
|
2618
|
+
de(), H = o;
|
|
2690
2619
|
const c = n.dom.className.split(" ").filter(
|
|
2691
|
-
(
|
|
2620
|
+
(u) => u !== "ProseMirror" && u !== "bn-root" && u !== "bn-editor"
|
|
2692
2621
|
).join(" ");
|
|
2693
2622
|
H.className = H.className + " bn-drag-preview " + c, document.body.appendChild(H);
|
|
2694
2623
|
}
|
|
2695
|
-
function
|
|
2624
|
+
function de() {
|
|
2696
2625
|
H !== void 0 && (document.body.removeChild(H), H = void 0);
|
|
2697
2626
|
}
|
|
2698
|
-
function
|
|
2627
|
+
function wo(n, t) {
|
|
2699
2628
|
if (!n.dataTransfer)
|
|
2700
2629
|
return;
|
|
2701
2630
|
const e = t.prosemirrorView, o = e.dom.getBoundingClientRect(), r = {
|
|
@@ -2704,21 +2633,21 @@ function vo(n, t) {
|
|
|
2704
2633
|
top: n.clientY
|
|
2705
2634
|
}, i = ko(r, e);
|
|
2706
2635
|
if (i != null) {
|
|
2707
|
-
const s = e.state.selection, a = e.state.doc, { from: l, to: c } =
|
|
2708
|
-
|
|
2709
|
-
e.state.tr.setSelection(
|
|
2710
|
-
),
|
|
2711
|
-
e.state.tr.setSelection(
|
|
2712
|
-
),
|
|
2713
|
-
const m = e.state.selection.content(), h = t._tiptapEditor.schema,
|
|
2636
|
+
const s = e.state.selection, a = e.state.doc, { from: l, to: c } = yo(s, a), u = l <= i && i < c, p = s.$anchor.node() !== s.$head.node() || s instanceof $;
|
|
2637
|
+
u && p ? (e.dispatch(
|
|
2638
|
+
e.state.tr.setSelection($.create(a, l, c))
|
|
2639
|
+
), Ot(e, l, c)) : (e.dispatch(
|
|
2640
|
+
e.state.tr.setSelection(it.create(e.state.doc, i))
|
|
2641
|
+
), Ot(e, i));
|
|
2642
|
+
const m = e.state.selection.content(), h = t._tiptapEditor.schema, k = Xt(h, t).serializeProseMirrorFragment(
|
|
2714
2643
|
m.content
|
|
2715
|
-
), B =
|
|
2644
|
+
), B = lt(h, t).exportProseMirrorFragment(
|
|
2716
2645
|
m.content
|
|
2717
|
-
), E =
|
|
2718
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("blocknote/html",
|
|
2646
|
+
), E = Ct(B);
|
|
2647
|
+
n.dataTransfer.clearData(), n.dataTransfer.setData("blocknote/html", k), n.dataTransfer.setData("text/html", B), n.dataTransfer.setData("text/plain", E), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(H, 0, 0), e.dragging = { slice: m, move: !0 };
|
|
2719
2648
|
}
|
|
2720
2649
|
}
|
|
2721
|
-
class
|
|
2650
|
+
class vo {
|
|
2722
2651
|
constructor(t, e, o) {
|
|
2723
2652
|
d(this, "state");
|
|
2724
2653
|
d(this, "emitUpdate");
|
|
@@ -2779,7 +2708,7 @@ class Eo {
|
|
|
2779
2708
|
this.state && !this.state.show && (this.state.show = !0, this.emitUpdate(this.state)), this.menuFrozen = !1;
|
|
2780
2709
|
});
|
|
2781
2710
|
d(this, "onMouseMove", (t) => {
|
|
2782
|
-
var c,
|
|
2711
|
+
var c, u, p, m, h;
|
|
2783
2712
|
if (this.menuFrozen)
|
|
2784
2713
|
return;
|
|
2785
2714
|
const e = this.pmView.dom.firstChild.getBoundingClientRect(), o = this.pmView.dom.getBoundingClientRect(), r = t.clientX >= o.left && t.clientX <= o.right && t.clientY >= o.top && t.clientY <= o.bottom, i = this.pmView.dom.parentElement;
|
|
@@ -2797,12 +2726,12 @@ class Eo {
|
|
|
2797
2726
|
left: e.left + e.width / 2,
|
|
2798
2727
|
// take middle of editor
|
|
2799
2728
|
top: t.clientY
|
|
2800
|
-
}, a =
|
|
2729
|
+
}, a = xt(s, this.pmView);
|
|
2801
2730
|
if (!a || !this.editor.isEditable) {
|
|
2802
|
-
(
|
|
2731
|
+
(u = this.state) != null && u.show && (this.state.show = !1, this.emitUpdate(this.state));
|
|
2803
2732
|
return;
|
|
2804
2733
|
}
|
|
2805
|
-
if ((
|
|
2734
|
+
if ((p = this.state) != null && p.show && ((m = this.hoveredBlock) != null && m.hasAttribute("data-id")) && ((h = this.hoveredBlock) == null ? void 0 : h.getAttribute("data-id")) === a.id)
|
|
2806
2735
|
return;
|
|
2807
2736
|
this.hoveredBlock = a.node;
|
|
2808
2737
|
const l = a.node.firstChild;
|
|
@@ -2861,20 +2790,20 @@ class Eo {
|
|
|
2861
2790
|
return;
|
|
2862
2791
|
const { contentNode: i, startPos: s, endPos: a } = r;
|
|
2863
2792
|
if (i.type.spec.content !== "inline*" || i.textContent.length !== 0) {
|
|
2864
|
-
const c = a + 1,
|
|
2865
|
-
this.editor._tiptapEditor.chain().BNCreateBlock(c).setTextSelection(
|
|
2793
|
+
const c = a + 1, u = c + 2;
|
|
2794
|
+
this.editor._tiptapEditor.chain().BNCreateBlock(c).setTextSelection(u).run();
|
|
2866
2795
|
} else
|
|
2867
2796
|
this.editor._tiptapEditor.commands.setTextSelection(s + 1);
|
|
2868
2797
|
this.pmView.focus(), this.pmView.dispatch(
|
|
2869
|
-
this.pmView.state.tr.scrollIntoView().setMeta(
|
|
2798
|
+
this.pmView.state.tr.scrollIntoView().setMeta(R, {
|
|
2870
2799
|
triggerCharacter: "/",
|
|
2871
2800
|
fromUserInput: !1
|
|
2872
2801
|
})
|
|
2873
2802
|
);
|
|
2874
2803
|
}
|
|
2875
2804
|
}
|
|
2876
|
-
const
|
|
2877
|
-
class
|
|
2805
|
+
const Eo = new x("SideMenuPlugin");
|
|
2806
|
+
class So extends K {
|
|
2878
2807
|
constructor(e) {
|
|
2879
2808
|
super();
|
|
2880
2809
|
d(this, "view");
|
|
@@ -2888,12 +2817,12 @@ class Co extends q {
|
|
|
2888
2817
|
* Handles drag & drop events for blocks.
|
|
2889
2818
|
*/
|
|
2890
2819
|
d(this, "blockDragStart", (e) => {
|
|
2891
|
-
this.view.isDragging = !0,
|
|
2820
|
+
this.view.isDragging = !0, wo(e, this.editor);
|
|
2892
2821
|
});
|
|
2893
2822
|
/**
|
|
2894
2823
|
* Handles drag & drop events for blocks.
|
|
2895
2824
|
*/
|
|
2896
|
-
d(this, "blockDragEnd", () =>
|
|
2825
|
+
d(this, "blockDragEnd", () => de());
|
|
2897
2826
|
/**
|
|
2898
2827
|
* Freezes the side menu. When frozen, the side menu will stay
|
|
2899
2828
|
* attached to the same block regardless of which block is hovered by the
|
|
@@ -2907,8 +2836,8 @@ class Co extends q {
|
|
|
2907
2836
|
*/
|
|
2908
2837
|
d(this, "unfreezeMenu", () => this.view.menuFrozen = !1);
|
|
2909
2838
|
this.editor = e, this.plugin = new v({
|
|
2910
|
-
key:
|
|
2911
|
-
view: (o) => (this.view = new
|
|
2839
|
+
key: Eo,
|
|
2840
|
+
view: (o) => (this.view = new vo(e, o, (r) => {
|
|
2912
2841
|
this.emit("update", r);
|
|
2913
2842
|
}), this.view)
|
|
2914
2843
|
});
|
|
@@ -2917,29 +2846,118 @@ class Co extends q {
|
|
|
2917
2846
|
return this.on("update", e);
|
|
2918
2847
|
}
|
|
2919
2848
|
}
|
|
2849
|
+
class Co {
|
|
2850
|
+
constructor(t, e, o) {
|
|
2851
|
+
d(this, "state");
|
|
2852
|
+
d(this, "emitUpdate");
|
|
2853
|
+
d(this, "prevWasEditable", null);
|
|
2854
|
+
d(this, "mouseDownHandler", () => {
|
|
2855
|
+
var t;
|
|
2856
|
+
(t = this.state) != null && t.show && (this.state.show = !1, this.emitUpdate());
|
|
2857
|
+
});
|
|
2858
|
+
// For dragging the whole editor.
|
|
2859
|
+
d(this, "dragstartHandler", () => {
|
|
2860
|
+
var t;
|
|
2861
|
+
(t = this.state) != null && t.show && (this.state.show = !1, this.emitUpdate());
|
|
2862
|
+
});
|
|
2863
|
+
d(this, "blurHandler", (t) => {
|
|
2864
|
+
var o;
|
|
2865
|
+
const e = this.pmView.dom.parentElement;
|
|
2866
|
+
// An element is clicked.
|
|
2867
|
+
t && t.relatedTarget && // Element is inside the editor.
|
|
2868
|
+
(e === t.relatedTarget || e.contains(t.relatedTarget)) || (o = this.state) != null && o.show && (this.state.show = !1, this.emitUpdate());
|
|
2869
|
+
});
|
|
2870
|
+
d(this, "scrollHandler", () => {
|
|
2871
|
+
var t;
|
|
2872
|
+
if ((t = this.state) != null && t.show) {
|
|
2873
|
+
const e = document.querySelector(
|
|
2874
|
+
`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`
|
|
2875
|
+
);
|
|
2876
|
+
this.state.referencePos = e.getBoundingClientRect(), this.emitUpdate();
|
|
2877
|
+
}
|
|
2878
|
+
});
|
|
2879
|
+
this.pluginKey = t, this.pmView = e, this.emitUpdate = () => {
|
|
2880
|
+
if (!this.state)
|
|
2881
|
+
throw new Error("Attempting to update uninitialized image panel");
|
|
2882
|
+
o(this.state);
|
|
2883
|
+
}, e.dom.addEventListener("mousedown", this.mouseDownHandler), e.dom.addEventListener("dragstart", this.dragstartHandler), e.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2884
|
+
}
|
|
2885
|
+
update(t, e) {
|
|
2886
|
+
var r, i;
|
|
2887
|
+
const o = this.pluginKey.getState(t.state);
|
|
2888
|
+
if (!((r = this.state) != null && r.show) && o.block) {
|
|
2889
|
+
const s = document.querySelector(
|
|
2890
|
+
`[data-node-type="blockContainer"][data-id="${o.block.id}"]`
|
|
2891
|
+
);
|
|
2892
|
+
this.state = {
|
|
2893
|
+
show: !0,
|
|
2894
|
+
referencePos: s.getBoundingClientRect(),
|
|
2895
|
+
block: o.block
|
|
2896
|
+
}, this.emitUpdate();
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
(!t.state.selection.eq(e.selection) || !t.state.doc.eq(e.doc)) && (i = this.state) != null && i.show && (this.state.show = !1, this.emitUpdate());
|
|
2900
|
+
}
|
|
2901
|
+
destroy() {
|
|
2902
|
+
this.pmView.dom.removeEventListener("mousedown", this.mouseDownHandler), this.pmView.dom.removeEventListener("dragstart", this.dragstartHandler), this.pmView.dom.removeEventListener("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
const ht = new x("ImagePanelPlugin");
|
|
2906
|
+
class xo extends K {
|
|
2907
|
+
constructor(e) {
|
|
2908
|
+
super();
|
|
2909
|
+
d(this, "view");
|
|
2910
|
+
d(this, "plugin");
|
|
2911
|
+
this.plugin = new v({
|
|
2912
|
+
key: ht,
|
|
2913
|
+
view: (o) => (this.view = new Co(
|
|
2914
|
+
// editor,
|
|
2915
|
+
ht,
|
|
2916
|
+
o,
|
|
2917
|
+
(r) => {
|
|
2918
|
+
this.emit("update", r);
|
|
2919
|
+
}
|
|
2920
|
+
), this.view),
|
|
2921
|
+
state: {
|
|
2922
|
+
init: () => ({
|
|
2923
|
+
block: void 0
|
|
2924
|
+
}),
|
|
2925
|
+
apply: (o) => {
|
|
2926
|
+
var i;
|
|
2927
|
+
return {
|
|
2928
|
+
block: (i = o.getMeta(ht)) == null ? void 0 : i.block
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
});
|
|
2933
|
+
}
|
|
2934
|
+
onUpdate(e) {
|
|
2935
|
+
return this.on("update", e);
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2920
2938
|
let C;
|
|
2921
|
-
function
|
|
2939
|
+
function _t() {
|
|
2922
2940
|
C || (C = document.createElement("div"), C.innerHTML = "_", C.style.opacity = "0", C.style.height = "1px", C.style.width = "1px", document.body.appendChild(C));
|
|
2923
2941
|
}
|
|
2924
2942
|
function To() {
|
|
2925
2943
|
C && (document.body.removeChild(C), C = void 0);
|
|
2926
2944
|
}
|
|
2927
|
-
function
|
|
2945
|
+
function rt(n) {
|
|
2928
2946
|
return Array.prototype.indexOf.call(n.parentElement.childNodes, n);
|
|
2929
2947
|
}
|
|
2930
|
-
function
|
|
2948
|
+
function Mo(n) {
|
|
2931
2949
|
for (; n && n.nodeName !== "TD" && n.nodeName !== "TH"; )
|
|
2932
2950
|
n = n.classList && n.classList.contains("ProseMirror") ? null : n.parentNode;
|
|
2933
2951
|
return n;
|
|
2934
2952
|
}
|
|
2935
|
-
function
|
|
2953
|
+
function Bo(n) {
|
|
2936
2954
|
n.forEach((t) => {
|
|
2937
2955
|
const e = document.getElementsByClassName(t);
|
|
2938
2956
|
for (let o = 0; o < e.length; o++)
|
|
2939
2957
|
e[o].style.visibility = "hidden";
|
|
2940
2958
|
});
|
|
2941
2959
|
}
|
|
2942
|
-
class
|
|
2960
|
+
class Lo {
|
|
2943
2961
|
constructor(t, e, o) {
|
|
2944
2962
|
d(this, "state");
|
|
2945
2963
|
d(this, "emitUpdate");
|
|
@@ -2951,12 +2969,12 @@ class Bo {
|
|
|
2951
2969
|
var c;
|
|
2952
2970
|
if (this.menuFrozen)
|
|
2953
2971
|
return;
|
|
2954
|
-
const e =
|
|
2972
|
+
const e = Mo(t.target);
|
|
2955
2973
|
if (!e || !this.editor.isEditable) {
|
|
2956
2974
|
(c = this.state) != null && c.show && (this.state.show = !1, this.emitUpdate());
|
|
2957
2975
|
return;
|
|
2958
2976
|
}
|
|
2959
|
-
const o =
|
|
2977
|
+
const o = rt(e), r = rt(e.parentElement), i = e.getBoundingClientRect(), s = e.parentElement.parentElement.getBoundingClientRect(), a = xt(i, this.pmView);
|
|
2960
2978
|
if (!a)
|
|
2961
2979
|
throw new Error(
|
|
2962
2980
|
"Found table cell element, but could not find surrounding blockContent element."
|
|
@@ -2964,13 +2982,13 @@ class Bo {
|
|
|
2964
2982
|
if (this.tableId = a.id, this.state !== void 0 && this.state.show && this.tableId === a.id && this.state.rowIndex === r && this.state.colIndex === o)
|
|
2965
2983
|
return;
|
|
2966
2984
|
let l;
|
|
2967
|
-
return this.editor._tiptapEditor.state.doc.descendants((
|
|
2968
|
-
|
|
2985
|
+
return this.editor._tiptapEditor.state.doc.descendants((u, p) => typeof l < "u" ? !1 : u.type.name !== "blockContainer" || u.attrs.id !== a.id ? !0 : (l = y(
|
|
2986
|
+
u,
|
|
2969
2987
|
this.editor.schema.blockSchema,
|
|
2970
2988
|
this.editor.schema.inlineContentSchema,
|
|
2971
2989
|
this.editor.schema.styleSchema,
|
|
2972
2990
|
this.editor.blockCache
|
|
2973
|
-
), this.tablePos =
|
|
2991
|
+
), this.tablePos = p + 1, !1)), this.state = {
|
|
2974
2992
|
show: !0,
|
|
2975
2993
|
referencePosCell: i,
|
|
2976
2994
|
referencePosTable: s,
|
|
@@ -2984,7 +3002,7 @@ class Bo {
|
|
|
2984
3002
|
var m;
|
|
2985
3003
|
if (((m = this.state) == null ? void 0 : m.draggingState) === void 0)
|
|
2986
3004
|
return;
|
|
2987
|
-
t.preventDefault(), t.dataTransfer.dropEffect = "move",
|
|
3005
|
+
t.preventDefault(), t.dataTransfer.dropEffect = "move", Bo([
|
|
2988
3006
|
"column-resize-handle",
|
|
2989
3007
|
"prosemirror-dropcursor-block",
|
|
2990
3008
|
"prosemirror-dropcursor-inline"
|
|
@@ -3007,11 +3025,11 @@ class Bo {
|
|
|
3007
3025
|
);
|
|
3008
3026
|
const r = o[0];
|
|
3009
3027
|
let i = !1;
|
|
3010
|
-
const s =
|
|
3028
|
+
const s = rt(r.parentElement), a = rt(r), l = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, u = (this.state.draggingState.draggedCellOrientation === "row" ? s : a) !== l;
|
|
3011
3029
|
(this.state.rowIndex !== s || this.state.colIndex !== a) && (this.state.rowIndex = s, this.state.colIndex = a, this.state.referencePosCell = r.getBoundingClientRect(), i = !0);
|
|
3012
|
-
const
|
|
3013
|
-
this.state.draggingState.mousePos !==
|
|
3014
|
-
this.pmView.state.tr.setMeta(
|
|
3030
|
+
const p = this.state.draggingState.draggedCellOrientation === "row" ? e.top : e.left;
|
|
3031
|
+
this.state.draggingState.mousePos !== p && (this.state.draggingState.mousePos = p, i = !0), i && this.emitUpdate(), u && this.pmView.dispatch(
|
|
3032
|
+
this.pmView.state.tr.setMeta(Y, !0)
|
|
3015
3033
|
);
|
|
3016
3034
|
});
|
|
3017
3035
|
d(this, "dropHandler", (t) => {
|
|
@@ -3059,8 +3077,8 @@ class Bo {
|
|
|
3059
3077
|
this.pmView.dom.removeEventListener("mousedown", this.mouseMoveHandler), document.removeEventListener("dragover", this.dragOverHandler), document.removeEventListener("drop", this.dropHandler), document.removeEventListener("scroll", this.scrollHandler);
|
|
3060
3078
|
}
|
|
3061
3079
|
}
|
|
3062
|
-
const
|
|
3063
|
-
class Io extends
|
|
3080
|
+
const Y = new x("TableHandlesPlugin");
|
|
3081
|
+
class Io extends K {
|
|
3064
3082
|
constructor(e) {
|
|
3065
3083
|
super();
|
|
3066
3084
|
d(this, "view");
|
|
@@ -3079,13 +3097,13 @@ class Io extends q {
|
|
|
3079
3097
|
originalIndex: this.view.state.colIndex,
|
|
3080
3098
|
mousePos: e.clientX
|
|
3081
3099
|
}, this.view.emitUpdate(), this.editor._tiptapEditor.view.dispatch(
|
|
3082
|
-
this.editor._tiptapEditor.state.tr.setMeta(
|
|
3100
|
+
this.editor._tiptapEditor.state.tr.setMeta(Y, {
|
|
3083
3101
|
draggedCellOrientation: this.view.state.draggingState.draggedCellOrientation,
|
|
3084
3102
|
originalIndex: this.view.state.colIndex,
|
|
3085
3103
|
newIndex: this.view.state.colIndex,
|
|
3086
3104
|
tablePos: this.view.tablePos
|
|
3087
3105
|
})
|
|
3088
|
-
),
|
|
3106
|
+
), _t(), e.dataTransfer.setDragImage(C, 0, 0), e.dataTransfer.effectAllowed = "move";
|
|
3089
3107
|
});
|
|
3090
3108
|
/**
|
|
3091
3109
|
* Callback that should be set on the `dragStart` event for whichever element
|
|
@@ -3101,13 +3119,13 @@ class Io extends q {
|
|
|
3101
3119
|
originalIndex: this.view.state.rowIndex,
|
|
3102
3120
|
mousePos: e.clientY
|
|
3103
3121
|
}, this.view.emitUpdate(), this.editor._tiptapEditor.view.dispatch(
|
|
3104
|
-
this.editor._tiptapEditor.state.tr.setMeta(
|
|
3122
|
+
this.editor._tiptapEditor.state.tr.setMeta(Y, {
|
|
3105
3123
|
draggedCellOrientation: this.view.state.draggingState.draggedCellOrientation,
|
|
3106
3124
|
originalIndex: this.view.state.rowIndex,
|
|
3107
3125
|
newIndex: this.view.state.rowIndex,
|
|
3108
3126
|
tablePos: this.view.tablePos
|
|
3109
3127
|
})
|
|
3110
|
-
),
|
|
3128
|
+
), _t(), e.dataTransfer.setDragImage(C, 0, 0), e.dataTransfer.effectAllowed = "copyMove";
|
|
3111
3129
|
});
|
|
3112
3130
|
/**
|
|
3113
3131
|
* Callback that should be set on the `dragEnd` event for both the element
|
|
@@ -3119,7 +3137,7 @@ class Io extends q {
|
|
|
3119
3137
|
"Attempted to drag table row, but no table block was hovered prior."
|
|
3120
3138
|
);
|
|
3121
3139
|
this.view.state.draggingState = void 0, this.view.emitUpdate(), this.editor._tiptapEditor.view.dispatch(
|
|
3122
|
-
this.editor._tiptapEditor.state.tr.setMeta(
|
|
3140
|
+
this.editor._tiptapEditor.state.tr.setMeta(Y, null)
|
|
3123
3141
|
), To();
|
|
3124
3142
|
});
|
|
3125
3143
|
/**
|
|
@@ -3137,8 +3155,8 @@ class Io extends q {
|
|
|
3137
3155
|
this.view.menuFrozen = !1;
|
|
3138
3156
|
});
|
|
3139
3157
|
this.editor = e, this.plugin = new v({
|
|
3140
|
-
key:
|
|
3141
|
-
view: (o) => (this.view = new
|
|
3158
|
+
key: Y,
|
|
3159
|
+
view: (o) => (this.view = new Lo(e, o, (r) => {
|
|
3142
3160
|
this.emit("update", r);
|
|
3143
3161
|
}), this.view),
|
|
3144
3162
|
// We use decorations to render the drop cursor when dragging a table row
|
|
@@ -3149,19 +3167,19 @@ class Io extends q {
|
|
|
3149
3167
|
return;
|
|
3150
3168
|
const r = this.view.state.draggingState.draggedCellOrientation === "row" ? this.view.state.rowIndex : this.view.state.colIndex, i = [];
|
|
3151
3169
|
if (r === this.view.state.draggingState.originalIndex)
|
|
3152
|
-
return
|
|
3170
|
+
return G.create(o.doc, i);
|
|
3153
3171
|
const s = o.doc.resolve(this.view.tablePos + 1), a = s.node();
|
|
3154
3172
|
if (this.view.state.draggingState.draggedCellOrientation === "row") {
|
|
3155
3173
|
const l = o.doc.resolve(
|
|
3156
3174
|
s.posAtIndex(r) + 1
|
|
3157
3175
|
), c = l.node();
|
|
3158
|
-
for (let
|
|
3159
|
-
const
|
|
3160
|
-
l.posAtIndex(
|
|
3161
|
-
), m =
|
|
3176
|
+
for (let u = 0; u < c.childCount; u++) {
|
|
3177
|
+
const p = o.doc.resolve(
|
|
3178
|
+
l.posAtIndex(u) + 1
|
|
3179
|
+
), m = p.node(), h = p.pos + (r > this.view.state.draggingState.originalIndex ? m.nodeSize - 2 : 0);
|
|
3162
3180
|
i.push(
|
|
3163
3181
|
// The widget is a small bar which spans the width of the cell.
|
|
3164
|
-
|
|
3182
|
+
j.widget(h, () => {
|
|
3165
3183
|
const f = document.createElement("div");
|
|
3166
3184
|
return f.className = "bn-table-drop-cursor", f.style.left = "0", f.style.right = "0", r > this.view.state.draggingState.originalIndex ? f.style.bottom = "-2px" : f.style.top = "-3px", f.style.height = "4px", f;
|
|
3167
3185
|
})
|
|
@@ -3171,18 +3189,18 @@ class Io extends q {
|
|
|
3171
3189
|
for (let l = 0; l < a.childCount; l++) {
|
|
3172
3190
|
const c = o.doc.resolve(
|
|
3173
3191
|
s.posAtIndex(l) + 1
|
|
3174
|
-
),
|
|
3192
|
+
), u = o.doc.resolve(
|
|
3175
3193
|
c.posAtIndex(r) + 1
|
|
3176
|
-
),
|
|
3194
|
+
), p = u.node(), m = u.pos + (r > this.view.state.draggingState.originalIndex ? p.nodeSize - 2 : 0);
|
|
3177
3195
|
i.push(
|
|
3178
3196
|
// The widget is a small bar which spans the height of the cell.
|
|
3179
|
-
|
|
3197
|
+
j.widget(m, () => {
|
|
3180
3198
|
const h = document.createElement("div");
|
|
3181
3199
|
return h.className = "bn-table-drop-cursor", h.style.top = "0", h.style.bottom = "0", r > this.view.state.draggingState.originalIndex ? h.style.right = "-2px" : h.style.left = "-3px", h.style.width = "4px", h;
|
|
3182
3200
|
})
|
|
3183
3201
|
);
|
|
3184
3202
|
}
|
|
3185
|
-
return
|
|
3203
|
+
return G.create(o.doc, i);
|
|
3186
3204
|
}
|
|
3187
3205
|
}
|
|
3188
3206
|
});
|
|
@@ -3191,17 +3209,17 @@ class Io extends q {
|
|
|
3191
3209
|
return this.on("update", e);
|
|
3192
3210
|
}
|
|
3193
3211
|
}
|
|
3194
|
-
function
|
|
3195
|
-
const e = n.state.selection.content().content, r =
|
|
3212
|
+
function Ut(n, t) {
|
|
3213
|
+
const e = n.state.selection.content().content, r = Xt(
|
|
3196
3214
|
n.state.schema,
|
|
3197
3215
|
t
|
|
3198
|
-
).serializeProseMirrorFragment(e), s =
|
|
3216
|
+
).serializeProseMirrorFragment(e), s = lt(
|
|
3199
3217
|
n.state.schema,
|
|
3200
3218
|
t
|
|
3201
|
-
).exportProseMirrorFragment(e), a =
|
|
3219
|
+
).exportProseMirrorFragment(e), a = Ct(s);
|
|
3202
3220
|
return { internalHTML: r, externalHTML: s, plainText: a };
|
|
3203
3221
|
}
|
|
3204
|
-
const
|
|
3222
|
+
const No = (n) => M.create({
|
|
3205
3223
|
name: "copyToClipboard",
|
|
3206
3224
|
addProseMirrorPlugins() {
|
|
3207
3225
|
return [
|
|
@@ -3211,12 +3229,12 @@ const Lo = (n) => M.create({
|
|
|
3211
3229
|
copy(t, e) {
|
|
3212
3230
|
e.preventDefault(), e.clipboardData.clearData(), "node" in t.state.selection && t.state.selection.node.type.spec.group === "blockContent" && t.dispatch(
|
|
3213
3231
|
t.state.tr.setSelection(
|
|
3214
|
-
new
|
|
3232
|
+
new it(
|
|
3215
3233
|
t.state.doc.resolve(t.state.selection.from - 1)
|
|
3216
3234
|
)
|
|
3217
3235
|
)
|
|
3218
3236
|
);
|
|
3219
|
-
const { internalHTML: o, externalHTML: r, plainText: i } =
|
|
3237
|
+
const { internalHTML: o, externalHTML: r, plainText: i } = Ut(t, n);
|
|
3220
3238
|
return e.clipboardData.setData("blocknote/html", o), e.clipboardData.setData("text/html", r), e.clipboardData.setData("text/plain", i), !0;
|
|
3221
3239
|
},
|
|
3222
3240
|
// This is for the use-case in which only a block without content
|
|
@@ -3227,12 +3245,12 @@ const Lo = (n) => M.create({
|
|
|
3227
3245
|
return;
|
|
3228
3246
|
t.dispatch(
|
|
3229
3247
|
t.state.tr.setSelection(
|
|
3230
|
-
new
|
|
3248
|
+
new it(
|
|
3231
3249
|
t.state.doc.resolve(t.state.selection.from - 1)
|
|
3232
3250
|
)
|
|
3233
3251
|
)
|
|
3234
3252
|
), e.preventDefault(), e.dataTransfer.clearData();
|
|
3235
|
-
const { internalHTML: o, externalHTML: r, plainText: i } =
|
|
3253
|
+
const { internalHTML: o, externalHTML: r, plainText: i } = Ut(t, n);
|
|
3236
3254
|
return e.dataTransfer.setData("blocknote/html", o), e.dataTransfer.setData("text/html", r), e.dataTransfer.setData("text/plain", i), !0;
|
|
3237
3255
|
}
|
|
3238
3256
|
}
|
|
@@ -3240,11 +3258,11 @@ const Lo = (n) => M.create({
|
|
|
3240
3258
|
})
|
|
3241
3259
|
];
|
|
3242
3260
|
}
|
|
3243
|
-
}),
|
|
3261
|
+
}), Ao = [
|
|
3244
3262
|
"blocknote/html",
|
|
3245
3263
|
"text/html",
|
|
3246
3264
|
"text/plain"
|
|
3247
|
-
],
|
|
3265
|
+
], Po = (n) => M.create({
|
|
3248
3266
|
name: "pasteFromClipboard",
|
|
3249
3267
|
addProseMirrorPlugins() {
|
|
3250
3268
|
return [
|
|
@@ -3254,14 +3272,14 @@ const Lo = (n) => M.create({
|
|
|
3254
3272
|
paste(t, e) {
|
|
3255
3273
|
e.preventDefault();
|
|
3256
3274
|
let o = null;
|
|
3257
|
-
for (const r of
|
|
3275
|
+
for (const r of Ao)
|
|
3258
3276
|
if (e.clipboardData.types.includes(r)) {
|
|
3259
3277
|
o = r;
|
|
3260
3278
|
break;
|
|
3261
3279
|
}
|
|
3262
3280
|
if (o !== null) {
|
|
3263
3281
|
let r = e.clipboardData.getData(o);
|
|
3264
|
-
o === "text/html" && (r =
|
|
3282
|
+
o === "text/html" && (r = le(
|
|
3265
3283
|
r.trim()
|
|
3266
3284
|
).innerHTML), n._tiptapEditor.view.pasteHTML(r);
|
|
3267
3285
|
}
|
|
@@ -3290,7 +3308,7 @@ const Lo = (n) => M.create({
|
|
|
3290
3308
|
}
|
|
3291
3309
|
];
|
|
3292
3310
|
}
|
|
3293
|
-
}),
|
|
3311
|
+
}), Do = new x("blocknote-placeholder"), Oo = M.create({
|
|
3294
3312
|
name: "placeholder",
|
|
3295
3313
|
addOptions() {
|
|
3296
3314
|
return {
|
|
@@ -3306,7 +3324,7 @@ const Lo = (n) => M.create({
|
|
|
3306
3324
|
const n = this.options.placeholders;
|
|
3307
3325
|
return [
|
|
3308
3326
|
new v({
|
|
3309
|
-
key:
|
|
3327
|
+
key: Do,
|
|
3310
3328
|
view: () => {
|
|
3311
3329
|
const t = document.createElement("style");
|
|
3312
3330
|
document.head.appendChild(t);
|
|
@@ -3345,16 +3363,16 @@ const Lo = (n) => M.create({
|
|
|
3345
3363
|
const i = o.$anchor, s = i.parent;
|
|
3346
3364
|
if (s.content.size > 0)
|
|
3347
3365
|
return null;
|
|
3348
|
-
const a = i.before(), l =
|
|
3366
|
+
const a = i.before(), l = j.node(a, a + s.nodeSize, {
|
|
3349
3367
|
"data-is-empty-and-focused": "true"
|
|
3350
3368
|
});
|
|
3351
|
-
return
|
|
3369
|
+
return G.create(e, [l]);
|
|
3352
3370
|
}
|
|
3353
3371
|
}
|
|
3354
3372
|
})
|
|
3355
3373
|
];
|
|
3356
3374
|
}
|
|
3357
|
-
}),
|
|
3375
|
+
}), _o = M.create({
|
|
3358
3376
|
name: "textAlignment",
|
|
3359
3377
|
addGlobalAttributes() {
|
|
3360
3378
|
return [
|
|
@@ -3374,7 +3392,7 @@ const Lo = (n) => M.create({
|
|
|
3374
3392
|
}
|
|
3375
3393
|
];
|
|
3376
3394
|
}
|
|
3377
|
-
}),
|
|
3395
|
+
}), Uo = M.create({
|
|
3378
3396
|
name: "blockTextColor",
|
|
3379
3397
|
addGlobalAttributes() {
|
|
3380
3398
|
return [
|
|
@@ -3392,19 +3410,19 @@ const Lo = (n) => M.create({
|
|
|
3392
3410
|
}
|
|
3393
3411
|
];
|
|
3394
3412
|
}
|
|
3395
|
-
}),
|
|
3413
|
+
}), Ro = M.create({
|
|
3396
3414
|
name: "trailingNode",
|
|
3397
3415
|
addProseMirrorPlugins() {
|
|
3398
|
-
const n = new
|
|
3416
|
+
const n = new x(this.name);
|
|
3399
3417
|
return [
|
|
3400
3418
|
new v({
|
|
3401
3419
|
key: n,
|
|
3402
3420
|
appendTransaction: (t, e, o) => {
|
|
3403
|
-
const { doc: r, tr: i, schema: s } = o, a = n.getState(o), l = r.content.size - 2, c = s.nodes.blockContainer,
|
|
3421
|
+
const { doc: r, tr: i, schema: s } = o, a = n.getState(o), l = r.content.size - 2, c = s.nodes.blockContainer, u = s.nodes.paragraph;
|
|
3404
3422
|
if (a)
|
|
3405
3423
|
return i.insert(
|
|
3406
3424
|
l,
|
|
3407
|
-
c.create(void 0,
|
|
3425
|
+
c.create(void 0, u.create())
|
|
3408
3426
|
);
|
|
3409
3427
|
},
|
|
3410
3428
|
state: {
|
|
@@ -3427,14 +3445,14 @@ const Lo = (n) => M.create({
|
|
|
3427
3445
|
})
|
|
3428
3446
|
];
|
|
3429
3447
|
}
|
|
3430
|
-
}),
|
|
3431
|
-
key:
|
|
3448
|
+
}), zo = new x("non-editable-block"), Vo = () => new v({
|
|
3449
|
+
key: zo,
|
|
3432
3450
|
props: {
|
|
3433
3451
|
handleKeyDown: (n, t) => {
|
|
3434
3452
|
"node" in n.state.selection && t.key.length === 1 && !t.ctrlKey && !t.altKey && !t.metaKey && !t.shiftKey && t.preventDefault();
|
|
3435
3453
|
}
|
|
3436
3454
|
}
|
|
3437
|
-
}),
|
|
3455
|
+
}), Rt = new x("previous-blocks"), Fo = {
|
|
3438
3456
|
// Numbered List Items
|
|
3439
3457
|
index: "index",
|
|
3440
3458
|
// Headings
|
|
@@ -3443,17 +3461,17 @@ const Lo = (n) => M.create({
|
|
|
3443
3461
|
type: "type",
|
|
3444
3462
|
depth: "depth",
|
|
3445
3463
|
"depth-change": "depth-change"
|
|
3446
|
-
},
|
|
3464
|
+
}, $o = () => {
|
|
3447
3465
|
let n;
|
|
3448
3466
|
return new v({
|
|
3449
|
-
key:
|
|
3467
|
+
key: Rt,
|
|
3450
3468
|
view(t) {
|
|
3451
3469
|
return {
|
|
3452
3470
|
update: async (e, o) => {
|
|
3453
3471
|
var r;
|
|
3454
3472
|
((r = this.key) == null ? void 0 : r.getState(e.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
3455
3473
|
e.dispatch(
|
|
3456
|
-
e.state.tr.setMeta(
|
|
3474
|
+
e.state.tr.setMeta(Rt, { clearUpdate: !0 })
|
|
3457
3475
|
);
|
|
3458
3476
|
}, 0));
|
|
3459
3477
|
},
|
|
@@ -3476,12 +3494,12 @@ const Lo = (n) => M.create({
|
|
|
3476
3494
|
apply(t, e, o, r) {
|
|
3477
3495
|
if (e.currentTransactionOldBlockAttrs = {}, e.updatedBlocks.clear(), !t.docChanged || o.doc.eq(r.doc))
|
|
3478
3496
|
return e;
|
|
3479
|
-
const i = {}, s =
|
|
3497
|
+
const i = {}, s = Bt(o.doc, (c) => c.attrs.id), a = new Map(
|
|
3480
3498
|
s.map((c) => [c.node.attrs.id, c])
|
|
3481
|
-
), l =
|
|
3499
|
+
), l = Bt(r.doc, (c) => c.attrs.id);
|
|
3482
3500
|
for (const c of l) {
|
|
3483
|
-
const
|
|
3484
|
-
if (
|
|
3501
|
+
const u = a.get(c.node.attrs.id), p = u == null ? void 0 : u.node.firstChild, m = c.node.firstChild;
|
|
3502
|
+
if (u && p && m) {
|
|
3485
3503
|
const h = {
|
|
3486
3504
|
index: m.attrs.index,
|
|
3487
3505
|
level: m.attrs.level,
|
|
@@ -3489,10 +3507,10 @@ const Lo = (n) => M.create({
|
|
|
3489
3507
|
depth: r.doc.resolve(c.pos).depth
|
|
3490
3508
|
};
|
|
3491
3509
|
let f = {
|
|
3492
|
-
index:
|
|
3493
|
-
level:
|
|
3494
|
-
type:
|
|
3495
|
-
depth: o.doc.resolve(
|
|
3510
|
+
index: p.attrs.index,
|
|
3511
|
+
level: p.attrs.level,
|
|
3512
|
+
type: p.type.name,
|
|
3513
|
+
depth: o.doc.resolve(u.pos).depth
|
|
3496
3514
|
};
|
|
3497
3515
|
i[c.node.attrs.id] = f, t.getMeta("numberedListIndexing") && (c.node.attrs.id in e.prevTransactionOldBlockAttrs && (f = e.prevTransactionOldBlockAttrs[c.node.attrs.id]), h.type === "numberedListItem" && (f.index = h.index)), e.currentTransactionOldBlockAttrs[c.node.attrs.id] = f, JSON.stringify(f) !== JSON.stringify(h) && (f["depth-change"] = f.depth - h.depth, e.updatedBlocks.add(c.node.attrs.id));
|
|
3498
3516
|
}
|
|
@@ -3510,23 +3528,23 @@ const Lo = (n) => M.create({
|
|
|
3510
3528
|
if (!r.attrs.id || !e.updatedBlocks.has(r.attrs.id))
|
|
3511
3529
|
return;
|
|
3512
3530
|
const s = e.currentTransactionOldBlockAttrs[r.attrs.id], a = {};
|
|
3513
|
-
for (const [c,
|
|
3514
|
-
a["data-prev-" +
|
|
3515
|
-
const l =
|
|
3531
|
+
for (const [c, u] of Object.entries(s))
|
|
3532
|
+
a["data-prev-" + Fo[c]] = u || "none";
|
|
3533
|
+
const l = j.node(i, i + r.nodeSize, {
|
|
3516
3534
|
...a
|
|
3517
3535
|
});
|
|
3518
3536
|
o.push(l);
|
|
3519
|
-
}),
|
|
3537
|
+
}), G.create(t.doc, o);
|
|
3520
3538
|
}
|
|
3521
3539
|
}
|
|
3522
3540
|
});
|
|
3523
|
-
},
|
|
3541
|
+
}, Go = {
|
|
3524
3542
|
blockColor: "data-block-color",
|
|
3525
3543
|
blockStyle: "data-block-style",
|
|
3526
3544
|
id: "data-id",
|
|
3527
3545
|
depth: "data-depth",
|
|
3528
3546
|
depthChange: "data-depth-change"
|
|
3529
|
-
},
|
|
3547
|
+
}, jo = W.create({
|
|
3530
3548
|
name: "blockContainer",
|
|
3531
3549
|
group: "blockContainer",
|
|
3532
3550
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
@@ -3542,7 +3560,7 @@ const Lo = (n) => M.create({
|
|
|
3542
3560
|
if (typeof n == "string")
|
|
3543
3561
|
return !1;
|
|
3544
3562
|
const t = {};
|
|
3545
|
-
for (const [e, o] of Object.entries(
|
|
3563
|
+
for (const [e, o] of Object.entries(Go))
|
|
3546
3564
|
n.getAttribute(o) && (t[e] = n.getAttribute(o));
|
|
3547
3565
|
return n.getAttribute("data-node-type") === "blockContainer" ? t : !1;
|
|
3548
3566
|
}
|
|
@@ -3559,7 +3577,7 @@ const Lo = (n) => M.create({
|
|
|
3559
3577
|
...((r = this.options.domAttributes) == null ? void 0 : r.block) || {},
|
|
3560
3578
|
...n
|
|
3561
3579
|
}, o = document.createElement("div");
|
|
3562
|
-
o.className =
|
|
3580
|
+
o.className = z("bn-block", e.class), o.setAttribute("data-node-type", this.name);
|
|
3563
3581
|
for (const [i, s] of Object.entries(e))
|
|
3564
3582
|
i !== "class" && o.setAttribute(i, s);
|
|
3565
3583
|
return t.appendChild(o), {
|
|
@@ -3593,7 +3611,7 @@ const Lo = (n) => M.create({
|
|
|
3593
3611
|
const m = [];
|
|
3594
3612
|
for (const h of t.children)
|
|
3595
3613
|
m.push(
|
|
3596
|
-
|
|
3614
|
+
D(
|
|
3597
3615
|
h,
|
|
3598
3616
|
e.schema,
|
|
3599
3617
|
this.options.editor.schema.styleSchema
|
|
@@ -3602,36 +3620,36 @@ const Lo = (n) => M.create({
|
|
|
3602
3620
|
a.childCount === 2 ? e.tr.replace(
|
|
3603
3621
|
i + l.nodeSize + 1,
|
|
3604
3622
|
s - 1,
|
|
3605
|
-
new
|
|
3623
|
+
new U(T.from(m), 0, 0)
|
|
3606
3624
|
) : e.tr.insert(
|
|
3607
3625
|
i + l.nodeSize,
|
|
3608
3626
|
e.schema.nodes.blockGroup.create({}, m)
|
|
3609
3627
|
);
|
|
3610
3628
|
}
|
|
3611
|
-
const c = l.type.name,
|
|
3612
|
-
let
|
|
3629
|
+
const c = l.type.name, u = t.type || c;
|
|
3630
|
+
let p = "keep";
|
|
3613
3631
|
if (t.content)
|
|
3614
3632
|
if (typeof t.content == "string")
|
|
3615
|
-
|
|
3633
|
+
p = [e.schema.text(t.content)];
|
|
3616
3634
|
else if (Array.isArray(t.content))
|
|
3617
|
-
|
|
3635
|
+
p = at(
|
|
3618
3636
|
t.content,
|
|
3619
3637
|
e.schema,
|
|
3620
3638
|
this.options.editor.schema.styleSchema
|
|
3621
3639
|
);
|
|
3622
3640
|
else if (t.content.type === "tableContent")
|
|
3623
|
-
|
|
3641
|
+
p = jt(
|
|
3624
3642
|
t.content,
|
|
3625
3643
|
e.schema,
|
|
3626
3644
|
this.options.editor.schema.styleSchema
|
|
3627
3645
|
);
|
|
3628
3646
|
else
|
|
3629
|
-
throw new
|
|
3647
|
+
throw new A(t.content.type);
|
|
3630
3648
|
else {
|
|
3631
|
-
const m = e.schema.nodes[c].spec.content, h = e.schema.nodes[
|
|
3632
|
-
m === "" || h !== m && (
|
|
3649
|
+
const m = e.schema.nodes[c].spec.content, h = e.schema.nodes[u].spec.content;
|
|
3650
|
+
m === "" || h !== m && (p = []);
|
|
3633
3651
|
}
|
|
3634
|
-
|
|
3652
|
+
p === "keep" ? e.tr.setNodeMarkup(
|
|
3635
3653
|
i,
|
|
3636
3654
|
t.type === void 0 ? void 0 : e.schema.nodes[t.type],
|
|
3637
3655
|
{
|
|
@@ -3641,19 +3659,19 @@ const Lo = (n) => M.create({
|
|
|
3641
3659
|
) : e.tr.replaceWith(
|
|
3642
3660
|
i,
|
|
3643
3661
|
s,
|
|
3644
|
-
e.schema.nodes[
|
|
3662
|
+
e.schema.nodes[u].create(
|
|
3645
3663
|
{
|
|
3646
3664
|
...l.attrs,
|
|
3647
3665
|
...t.props
|
|
3648
3666
|
},
|
|
3649
|
-
|
|
3667
|
+
p
|
|
3650
3668
|
)
|
|
3651
3669
|
).setSelection(
|
|
3652
|
-
e.schema.nodes[
|
|
3670
|
+
e.schema.nodes[u].spec.content === "" ? new it(e.tr.doc.resolve(i)) : e.schema.nodes[u].spec.content === "inline*" ? new ot(e.tr.doc.resolve(i)) : (
|
|
3653
3671
|
// Need to offset the position as we have to get through the
|
|
3654
3672
|
// `tableRow` and `tableCell` nodes to get to the
|
|
3655
3673
|
// `tableParagraph` node we want to set the selection in.
|
|
3656
|
-
new
|
|
3674
|
+
new ot(e.tr.doc.resolve(i + 4))
|
|
3657
3675
|
)
|
|
3658
3676
|
), e.tr.setNodeMarkup(i - 1, void 0, {
|
|
3659
3677
|
...a.attrs,
|
|
@@ -3686,25 +3704,25 @@ const Lo = (n) => M.create({
|
|
|
3686
3704
|
const i = b(
|
|
3687
3705
|
t.doc,
|
|
3688
3706
|
n + 1
|
|
3689
|
-
), { node: s, contentNode: a, startPos: l, endPos: c, depth:
|
|
3707
|
+
), { node: s, contentNode: a, startPos: l, endPos: c, depth: u } = i;
|
|
3690
3708
|
if (s.childCount === 2) {
|
|
3691
3709
|
const h = t.doc.resolve(
|
|
3692
3710
|
l + a.nodeSize + 1
|
|
3693
|
-
), f = t.doc.resolve(c - 1),
|
|
3694
|
-
e && t.tr.lift(
|
|
3711
|
+
), f = t.doc.resolve(c - 1), k = h.blockRange(f);
|
|
3712
|
+
e && t.tr.lift(k, u - 1);
|
|
3695
3713
|
}
|
|
3696
|
-
let
|
|
3714
|
+
let p = n - 1, m = b(t.doc, p);
|
|
3697
3715
|
for (; m.numChildBlocks > 0; )
|
|
3698
|
-
if (
|
|
3716
|
+
if (p--, m = b(t.doc, p), m === void 0)
|
|
3699
3717
|
return !1;
|
|
3700
3718
|
return e && (e(
|
|
3701
3719
|
t.tr.deleteRange(l, l + a.nodeSize).replace(
|
|
3702
|
-
|
|
3720
|
+
p - 1,
|
|
3703
3721
|
l,
|
|
3704
|
-
new
|
|
3722
|
+
new U(a.content, 0, 0)
|
|
3705
3723
|
).scrollIntoView()
|
|
3706
3724
|
), t.tr.setSelection(
|
|
3707
|
-
new
|
|
3725
|
+
new ot(t.doc.resolve(p - 1))
|
|
3708
3726
|
)), !0;
|
|
3709
3727
|
},
|
|
3710
3728
|
// Splits a block at a given position. Content after the position is moved to a new block below, at the same
|
|
@@ -3713,12 +3731,12 @@ const Lo = (n) => M.create({
|
|
|
3713
3731
|
const r = b(e.doc, n);
|
|
3714
3732
|
if (r === void 0)
|
|
3715
3733
|
return !1;
|
|
3716
|
-
const { contentNode: i, contentType: s, startPos: a, endPos: l, depth: c } = r,
|
|
3734
|
+
const { contentNode: i, contentType: s, startPos: a, endPos: l, depth: c } = r, u = e.doc.cut(a + 1, n), p = e.doc.cut(n, l - 1), m = e.schema.nodes.blockContainer.createAndFill(), h = l + 1, f = h + 2;
|
|
3717
3735
|
return o && (e.tr.insert(h, m), e.tr.replace(
|
|
3718
3736
|
f,
|
|
3719
3737
|
f + 1,
|
|
3720
|
-
|
|
3721
|
-
|
|
3738
|
+
p.content.size > 0 ? new U(
|
|
3739
|
+
T.from(p),
|
|
3722
3740
|
c + 2,
|
|
3723
3741
|
c + 2
|
|
3724
3742
|
) : void 0
|
|
@@ -3728,12 +3746,12 @@ const Lo = (n) => M.create({
|
|
|
3728
3746
|
e.schema.node(s).type,
|
|
3729
3747
|
i.attrs
|
|
3730
3748
|
), e.tr.setSelection(
|
|
3731
|
-
new
|
|
3749
|
+
new ot(e.doc.resolve(f))
|
|
3732
3750
|
), e.tr.replace(
|
|
3733
3751
|
a + 1,
|
|
3734
3752
|
l - 1,
|
|
3735
|
-
|
|
3736
|
-
|
|
3753
|
+
u.content.size > 0 ? new U(
|
|
3754
|
+
T.from(u),
|
|
3737
3755
|
c + 2,
|
|
3738
3756
|
c + 2
|
|
3739
3757
|
) : void 0
|
|
@@ -3742,7 +3760,7 @@ const Lo = (n) => M.create({
|
|
|
3742
3760
|
};
|
|
3743
3761
|
},
|
|
3744
3762
|
addProseMirrorPlugins() {
|
|
3745
|
-
return [
|
|
3763
|
+
return [$o(), Vo()];
|
|
3746
3764
|
},
|
|
3747
3765
|
addKeyboardShortcuts() {
|
|
3748
3766
|
return {
|
|
@@ -3776,8 +3794,8 @@ const Lo = (n) => M.create({
|
|
|
3776
3794
|
const { depth: i, startPos: s } = b(
|
|
3777
3795
|
r.doc,
|
|
3778
3796
|
r.selection.from
|
|
3779
|
-
), a = r.selection.from === s + 1, l = r.selection.empty, c = s === 2,
|
|
3780
|
-
return !c && a && l && i === 2 ? o.BNMergeBlocks(
|
|
3797
|
+
), a = r.selection.from === s + 1, l = r.selection.empty, c = s === 2, u = s - 1;
|
|
3798
|
+
return !c && a && l && i === 2 ? o.BNMergeBlocks(u) : !1;
|
|
3781
3799
|
})
|
|
3782
3800
|
]),
|
|
3783
3801
|
Delete: () => this.editor.commands.first(({ commands: o }) => [
|
|
@@ -3790,8 +3808,8 @@ const Lo = (n) => M.create({
|
|
|
3790
3808
|
const { node: i, depth: s, endPos: a } = b(
|
|
3791
3809
|
r.doc,
|
|
3792
3810
|
r.selection.from
|
|
3793
|
-
), l = a === r.doc.nodeSize - 4, c = r.selection.from === a - 1,
|
|
3794
|
-
if (!l && c &&
|
|
3811
|
+
), l = a === r.doc.nodeSize - 4, c = r.selection.from === a - 1, u = r.selection.empty, p = i.childCount === 2;
|
|
3812
|
+
if (!l && c && u && !p) {
|
|
3795
3813
|
let m = s, h = a + 2, f = r.doc.resolve(h).depth;
|
|
3796
3814
|
for (; f < m; )
|
|
3797
3815
|
m = f, h += 2, f = r.doc.resolve(h).depth;
|
|
@@ -3807,8 +3825,8 @@ const Lo = (n) => M.create({
|
|
|
3807
3825
|
const { node: i, depth: s } = b(
|
|
3808
3826
|
r.doc,
|
|
3809
3827
|
r.selection.from
|
|
3810
|
-
), a = r.selection.$anchor.parentOffset === 0, l = r.selection.anchor === r.selection.head, c = i.textContent.length === 0,
|
|
3811
|
-
return a && l && c &&
|
|
3828
|
+
), a = r.selection.$anchor.parentOffset === 0, l = r.selection.anchor === r.selection.head, c = i.textContent.length === 0, u = s > 2;
|
|
3829
|
+
return a && l && c && u ? o.liftListItem("blockContainer") : !1;
|
|
3812
3830
|
}),
|
|
3813
3831
|
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
3814
3832
|
// empty & at the start of the block.
|
|
@@ -3816,10 +3834,10 @@ const Lo = (n) => M.create({
|
|
|
3816
3834
|
const { node: s, endPos: a } = b(
|
|
3817
3835
|
r.doc,
|
|
3818
3836
|
r.selection.from
|
|
3819
|
-
), l = r.selection.$anchor.parentOffset === 0, c = r.selection.anchor === r.selection.head,
|
|
3820
|
-
if (l && c &&
|
|
3821
|
-
const
|
|
3822
|
-
return i().BNCreateBlock(
|
|
3837
|
+
), l = r.selection.$anchor.parentOffset === 0, c = r.selection.anchor === r.selection.head, u = s.textContent.length === 0;
|
|
3838
|
+
if (l && c && u) {
|
|
3839
|
+
const p = a + 1, m = p + 2;
|
|
3840
|
+
return i().BNCreateBlock(p).setTextSelection(m).run(), !0;
|
|
3823
3841
|
}
|
|
3824
3842
|
return !1;
|
|
3825
3843
|
}),
|
|
@@ -3839,7 +3857,7 @@ const Lo = (n) => M.create({
|
|
|
3839
3857
|
"Shift-Tab": () => (this.editor.commands.liftListItem("blockContainer"), !0)
|
|
3840
3858
|
};
|
|
3841
3859
|
}
|
|
3842
|
-
}),
|
|
3860
|
+
}), Wo = W.create({
|
|
3843
3861
|
name: "blockGroup",
|
|
3844
3862
|
group: "blockGroup",
|
|
3845
3863
|
content: "blockContainer+",
|
|
@@ -3857,7 +3875,7 @@ const Lo = (n) => M.create({
|
|
|
3857
3875
|
...((o = this.options.domAttributes) == null ? void 0 : o.blockGroup) || {},
|
|
3858
3876
|
...n
|
|
3859
3877
|
}, e = document.createElement("div");
|
|
3860
|
-
e.className =
|
|
3878
|
+
e.className = z(
|
|
3861
3879
|
"bn-block-group",
|
|
3862
3880
|
t.class
|
|
3863
3881
|
), e.setAttribute("data-node-type", "blockGroup");
|
|
@@ -3868,45 +3886,45 @@ const Lo = (n) => M.create({
|
|
|
3868
3886
|
contentDOM: e
|
|
3869
3887
|
};
|
|
3870
3888
|
}
|
|
3871
|
-
}),
|
|
3889
|
+
}), qo = W.create({
|
|
3872
3890
|
name: "doc",
|
|
3873
3891
|
topNode: !0,
|
|
3874
3892
|
content: "blockGroup"
|
|
3875
|
-
}),
|
|
3893
|
+
}), Ko = (n) => {
|
|
3876
3894
|
var e;
|
|
3877
3895
|
const t = [
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3896
|
+
X.ClipboardTextSerializer,
|
|
3897
|
+
X.Commands,
|
|
3898
|
+
X.Editable,
|
|
3899
|
+
X.FocusEvents,
|
|
3900
|
+
X.Tabindex,
|
|
3883
3901
|
// DevTools,
|
|
3884
|
-
|
|
3902
|
+
Xe,
|
|
3885
3903
|
// DropCursor,
|
|
3886
|
-
|
|
3904
|
+
Oo.configure({
|
|
3887
3905
|
// TODO: This shorthand is kind of ugly
|
|
3888
3906
|
...n.placeholders !== void 0 ? { placeholders: n.placeholders } : {}
|
|
3889
3907
|
}),
|
|
3890
|
-
|
|
3908
|
+
Z.configure({
|
|
3891
3909
|
types: ["blockContainer"]
|
|
3892
3910
|
}),
|
|
3893
|
-
|
|
3911
|
+
Ye,
|
|
3894
3912
|
// Comments,
|
|
3895
3913
|
// basics:
|
|
3896
|
-
|
|
3914
|
+
tn,
|
|
3897
3915
|
// marks:
|
|
3898
|
-
|
|
3916
|
+
Ze,
|
|
3899
3917
|
...Object.values(n.styleSpecs).map((o) => o.implementation.mark),
|
|
3900
|
-
|
|
3918
|
+
Uo,
|
|
3901
3919
|
Ho,
|
|
3902
|
-
|
|
3920
|
+
_o,
|
|
3903
3921
|
// nodes
|
|
3904
|
-
|
|
3905
|
-
|
|
3922
|
+
qo,
|
|
3923
|
+
jo.configure({
|
|
3906
3924
|
editor: n.editor,
|
|
3907
3925
|
domAttributes: n.domAttributes
|
|
3908
3926
|
}),
|
|
3909
|
-
|
|
3927
|
+
Wo.configure({
|
|
3910
3928
|
domAttributes: n.domAttributes
|
|
3911
3929
|
}),
|
|
3912
3930
|
...Object.values(n.inlineContentSpecs).filter((o) => o.config !== "link" && o.config !== "text").map((o) => o.implementation.node.configure({
|
|
@@ -3926,16 +3944,16 @@ const Lo = (n) => M.create({
|
|
|
3926
3944
|
domAttributes: n.domAttributes
|
|
3927
3945
|
})
|
|
3928
3946
|
]),
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3947
|
+
No(n.editor),
|
|
3948
|
+
Po(n.editor),
|
|
3949
|
+
Je.configure({ width: 5, color: "#ddeeff" }),
|
|
3932
3950
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
3933
3951
|
// should be handled before Enter handlers in other components like splitListItem
|
|
3934
|
-
|
|
3952
|
+
Ro
|
|
3935
3953
|
];
|
|
3936
3954
|
if (n.collaboration) {
|
|
3937
3955
|
if (t.push(
|
|
3938
|
-
|
|
3956
|
+
qe.configure({
|
|
3939
3957
|
fragment: n.collaboration.fragment
|
|
3940
3958
|
})
|
|
3941
3959
|
), (e = n.collaboration.provider) != null && e.awareness) {
|
|
@@ -3948,7 +3966,7 @@ const Lo = (n) => M.create({
|
|
|
3948
3966
|
return i.insertBefore(a, null), i.insertBefore(s, null), i.insertBefore(l, null), i;
|
|
3949
3967
|
};
|
|
3950
3968
|
t.push(
|
|
3951
|
-
|
|
3969
|
+
Ke.configure({
|
|
3952
3970
|
user: n.collaboration.user,
|
|
3953
3971
|
render: n.collaboration.renderCursor || o,
|
|
3954
3972
|
provider: n.collaboration.provider
|
|
@@ -3956,23 +3974,23 @@ const Lo = (n) => M.create({
|
|
|
3956
3974
|
);
|
|
3957
3975
|
}
|
|
3958
3976
|
} else
|
|
3959
|
-
t.push(
|
|
3977
|
+
t.push(Qe);
|
|
3960
3978
|
return t;
|
|
3961
3979
|
};
|
|
3962
|
-
function
|
|
3980
|
+
function Jo(n, t) {
|
|
3963
3981
|
const e = [];
|
|
3964
3982
|
return n.forEach((o, r, i) => {
|
|
3965
3983
|
i !== t && e.push(o);
|
|
3966
|
-
}),
|
|
3984
|
+
}), T.from(e);
|
|
3967
3985
|
}
|
|
3968
|
-
function
|
|
3969
|
-
let e =
|
|
3986
|
+
function Xo(n, t) {
|
|
3987
|
+
let e = T.from(n.content);
|
|
3970
3988
|
for (let o = 0; o < e.childCount; o++)
|
|
3971
3989
|
if (e.child(o).type.spec.group === "blockContent") {
|
|
3972
3990
|
const r = [e.child(o)];
|
|
3973
3991
|
if (o + 1 < e.childCount && e.child(o + 1).type.spec.group === "blockGroup") {
|
|
3974
3992
|
const s = e.child(o + 1).child(0).child(0);
|
|
3975
|
-
(s.type.name === "bulletListItem" || s.type.name === "numberedListItem") && (r.push(e.child(o + 1)), e =
|
|
3993
|
+
(s.type.name === "bulletListItem" || s.type.name === "numberedListItem") && (r.push(e.child(o + 1)), e = Jo(e, o + 1));
|
|
3976
3994
|
}
|
|
3977
3995
|
const i = t.state.schema.nodes.blockContainer.create(
|
|
3978
3996
|
void 0,
|
|
@@ -3980,7 +3998,7 @@ function Jo(n, t) {
|
|
|
3980
3998
|
);
|
|
3981
3999
|
e = e.replaceChild(o, i);
|
|
3982
4000
|
}
|
|
3983
|
-
return new
|
|
4001
|
+
return new U(e, n.openStart, n.openEnd);
|
|
3984
4002
|
}
|
|
3985
4003
|
class Tt {
|
|
3986
4004
|
constructor(t) {
|
|
@@ -3994,15 +4012,15 @@ class Tt {
|
|
|
3994
4012
|
d(this, "BlockNoteEditor", "only for types");
|
|
3995
4013
|
d(this, "Block", "only for types");
|
|
3996
4014
|
d(this, "PartialBlock", "only for types");
|
|
3997
|
-
this.blockSpecs = (t == null ? void 0 : t.blockSpecs) ||
|
|
4015
|
+
this.blockSpecs = (t == null ? void 0 : t.blockSpecs) || re, this.inlineContentSpecs = (t == null ? void 0 : t.inlineContentSpecs) || se, this.styleSpecs = (t == null ? void 0 : t.styleSpecs) || ie, this.blockSchema = te(this.blockSpecs), this.inlineContentSchema = ee(
|
|
3998
4016
|
this.inlineContentSpecs
|
|
3999
|
-
), this.styleSchema =
|
|
4017
|
+
), this.styleSchema = oe(this.styleSpecs);
|
|
4000
4018
|
}
|
|
4001
4019
|
static create(t) {
|
|
4002
4020
|
return new Tt(t);
|
|
4003
4021
|
}
|
|
4004
4022
|
}
|
|
4005
|
-
class
|
|
4023
|
+
class Yo extends Me {
|
|
4006
4024
|
constructor(e, o) {
|
|
4007
4025
|
super({ ...e, content: void 0 });
|
|
4008
4026
|
d(this, "_state");
|
|
@@ -4020,15 +4038,15 @@ class Xo extends xe {
|
|
|
4020
4038
|
r.nodes.doc.createAndFill = (...l) => {
|
|
4021
4039
|
if (i)
|
|
4022
4040
|
return i;
|
|
4023
|
-
const c = s.apply(r.nodes.doc, l),
|
|
4024
|
-
return
|
|
4041
|
+
const c = s.apply(r.nodes.doc, l), u = JSON.parse(JSON.stringify(c.toJSON()));
|
|
4042
|
+
return u.content[0].content[0].attrs.id = "initialBlockId", i = be.fromJSON(r, u), i;
|
|
4025
4043
|
};
|
|
4026
4044
|
let a;
|
|
4027
4045
|
try {
|
|
4028
4046
|
const l = e == null ? void 0 : e.content.map(
|
|
4029
|
-
(c) =>
|
|
4047
|
+
(c) => D(c, this.schema, o).toJSON()
|
|
4030
4048
|
);
|
|
4031
|
-
a =
|
|
4049
|
+
a = Be(
|
|
4032
4050
|
{
|
|
4033
4051
|
type: "doc",
|
|
4034
4052
|
content: [
|
|
@@ -4049,7 +4067,7 @@ class Xo extends xe {
|
|
|
4049
4067
|
"Error creating document from blocks passed as `initialContent`:\n" + +JSON.stringify(e.content)
|
|
4050
4068
|
);
|
|
4051
4069
|
}
|
|
4052
|
-
this._state =
|
|
4070
|
+
this._state = Le.create({
|
|
4053
4071
|
doc: a,
|
|
4054
4072
|
schema: this.schema
|
|
4055
4073
|
// selection: selection || undefined,
|
|
@@ -4065,7 +4083,7 @@ class Xo extends xe {
|
|
|
4065
4083
|
*/
|
|
4066
4084
|
createViewAlternative() {
|
|
4067
4085
|
queueMicrotask(() => {
|
|
4068
|
-
this.view = new
|
|
4086
|
+
this.view = new We(this.options.element, {
|
|
4069
4087
|
...this.options.editorProps,
|
|
4070
4088
|
// @ts-ignore
|
|
4071
4089
|
dispatchTransaction: this.dispatchTransaction.bind(this),
|
|
@@ -4078,12 +4096,12 @@ class Xo extends xe {
|
|
|
4078
4096
|
});
|
|
4079
4097
|
}
|
|
4080
4098
|
}
|
|
4081
|
-
const
|
|
4099
|
+
const Qo = {
|
|
4082
4100
|
enableInputRules: !0,
|
|
4083
4101
|
enablePasteRules: !0,
|
|
4084
4102
|
enableCoreExtensions: !1
|
|
4085
4103
|
};
|
|
4086
|
-
class
|
|
4104
|
+
class ue {
|
|
4087
4105
|
constructor(t) {
|
|
4088
4106
|
d(this, "_tiptapEditor");
|
|
4089
4107
|
d(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
@@ -4092,13 +4110,13 @@ class de {
|
|
|
4092
4110
|
d(this, "inlineContentImplementations");
|
|
4093
4111
|
d(this, "styleImplementations");
|
|
4094
4112
|
d(this, "formattingToolbar");
|
|
4095
|
-
d(this, "
|
|
4113
|
+
d(this, "linkToolbar");
|
|
4096
4114
|
d(this, "sideMenu");
|
|
4097
4115
|
d(this, "suggestionMenus");
|
|
4098
|
-
d(this, "
|
|
4116
|
+
d(this, "imagePanel");
|
|
4099
4117
|
d(this, "tableHandles");
|
|
4100
4118
|
d(this, "uploadFile");
|
|
4101
|
-
var l, c,
|
|
4119
|
+
var l, c, u, p, m, h, f, k;
|
|
4102
4120
|
this.options = t;
|
|
4103
4121
|
const e = t;
|
|
4104
4122
|
if (e.onEditorContentChange)
|
|
@@ -4122,8 +4140,8 @@ class de {
|
|
|
4122
4140
|
schema: t.schema || Tt.create(),
|
|
4123
4141
|
...t
|
|
4124
4142
|
};
|
|
4125
|
-
this.schema = o.schema, this.blockImplementations = o.schema.blockSpecs, this.inlineContentImplementations = o.schema.inlineContentSpecs, this.styleImplementations = o.schema.styleSpecs, this.formattingToolbar = new
|
|
4126
|
-
const r =
|
|
4143
|
+
this.schema = o.schema, this.blockImplementations = o.schema.blockSpecs, this.inlineContentImplementations = o.schema.inlineContentSpecs, this.styleImplementations = o.schema.styleSpecs, this.formattingToolbar = new uo(this), this.linkToolbar = new mo(this), this.sideMenu = new So(this), this.suggestionMenus = new bo(this), I("image", this) && (this.imagePanel = new xo(this)), I("table", this) && (this.tableHandles = new Io(this));
|
|
4144
|
+
const r = Ko({
|
|
4127
4145
|
editor: this,
|
|
4128
4146
|
placeholders: o.placeholders,
|
|
4129
4147
|
domAttributes: o.domAttributes || {},
|
|
@@ -4136,10 +4154,10 @@ class de {
|
|
|
4136
4154
|
name: "BlockNoteUIExtension",
|
|
4137
4155
|
addProseMirrorPlugins: () => [
|
|
4138
4156
|
this.formattingToolbar.plugin,
|
|
4139
|
-
this.
|
|
4157
|
+
this.linkToolbar.plugin,
|
|
4140
4158
|
this.sideMenu.plugin,
|
|
4141
4159
|
this.suggestionMenus.plugin,
|
|
4142
|
-
...this.
|
|
4160
|
+
...this.imagePanel ? [this.imagePanel.plugin] : [],
|
|
4143
4161
|
...this.tableHandles ? [this.tableHandles.plugin] : []
|
|
4144
4162
|
]
|
|
4145
4163
|
});
|
|
@@ -4154,7 +4172,7 @@ class de {
|
|
|
4154
4172
|
] : [
|
|
4155
4173
|
{
|
|
4156
4174
|
type: "paragraph",
|
|
4157
|
-
id:
|
|
4175
|
+
id: Z.options.generateID()
|
|
4158
4176
|
}
|
|
4159
4177
|
]);
|
|
4160
4178
|
if (!Array.isArray(s) || s.length === 0)
|
|
@@ -4162,31 +4180,31 @@ class de {
|
|
|
4162
4180
|
"initialContent must be a non-empty array of blocks, received: " + s
|
|
4163
4181
|
);
|
|
4164
4182
|
const a = {
|
|
4165
|
-
...
|
|
4183
|
+
...Qo,
|
|
4166
4184
|
...o._tiptapOptions,
|
|
4167
4185
|
content: s,
|
|
4168
4186
|
extensions: o.enableBlockNoteExtensions === !1 ? ((l = o._tiptapOptions) == null ? void 0 : l.extensions) || [] : [...((c = o._tiptapOptions) == null ? void 0 : c.extensions) || [], ...r],
|
|
4169
4187
|
editorProps: {
|
|
4170
|
-
...(
|
|
4188
|
+
...(u = o._tiptapOptions) == null ? void 0 : u.editorProps,
|
|
4171
4189
|
attributes: {
|
|
4172
|
-
...(m = (
|
|
4190
|
+
...(m = (p = o._tiptapOptions) == null ? void 0 : p.editorProps) == null ? void 0 : m.attributes,
|
|
4173
4191
|
...(h = o.domAttributes) == null ? void 0 : h.editor,
|
|
4174
|
-
class:
|
|
4192
|
+
class: z(
|
|
4175
4193
|
"bn-editor",
|
|
4176
4194
|
o.defaultStyles ? "bn-default-styles" : "",
|
|
4177
|
-
((
|
|
4195
|
+
((k = (f = o.domAttributes) == null ? void 0 : f.editor) == null ? void 0 : k.class) || ""
|
|
4178
4196
|
)
|
|
4179
4197
|
},
|
|
4180
|
-
transformPasted:
|
|
4198
|
+
transformPasted: Xo
|
|
4181
4199
|
}
|
|
4182
4200
|
};
|
|
4183
|
-
this._tiptapEditor = new
|
|
4201
|
+
this._tiptapEditor = new Yo(
|
|
4184
4202
|
a,
|
|
4185
4203
|
this.schema.styleSchema
|
|
4186
4204
|
);
|
|
4187
4205
|
}
|
|
4188
4206
|
static create(t = {}) {
|
|
4189
|
-
return new
|
|
4207
|
+
return new ue(t);
|
|
4190
4208
|
}
|
|
4191
4209
|
/**
|
|
4192
4210
|
* Mount the editor to a parent DOM element. Call mount(undefined) to clean up
|
|
@@ -4221,7 +4239,7 @@ class de {
|
|
|
4221
4239
|
get document() {
|
|
4222
4240
|
const t = [];
|
|
4223
4241
|
return this._tiptapEditor.state.doc.firstChild.descendants((e) => (t.push(
|
|
4224
|
-
|
|
4242
|
+
y(
|
|
4225
4243
|
e,
|
|
4226
4244
|
this.schema.blockSchema,
|
|
4227
4245
|
this.schema.inlineContentSchema,
|
|
@@ -4238,7 +4256,7 @@ class de {
|
|
|
4238
4256
|
getBlock(t) {
|
|
4239
4257
|
const e = typeof t == "string" ? t : t.id;
|
|
4240
4258
|
let o;
|
|
4241
|
-
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== e ? !0 : (o =
|
|
4259
|
+
return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== e ? !0 : (o = y(
|
|
4242
4260
|
r,
|
|
4243
4261
|
this.schema.blockSchema,
|
|
4244
4262
|
this.schema.inlineContentSchema,
|
|
@@ -4293,21 +4311,21 @@ class de {
|
|
|
4293
4311
|
i > 0 && (a = this._tiptapEditor.state.doc.resolve(o - 2).node());
|
|
4294
4312
|
let l;
|
|
4295
4313
|
return i < s - 1 && (l = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
|
|
4296
|
-
block:
|
|
4314
|
+
block: y(
|
|
4297
4315
|
t,
|
|
4298
4316
|
this.schema.blockSchema,
|
|
4299
4317
|
this.schema.inlineContentSchema,
|
|
4300
4318
|
this.schema.styleSchema,
|
|
4301
4319
|
this.blockCache
|
|
4302
4320
|
),
|
|
4303
|
-
prevBlock: a === void 0 ? void 0 :
|
|
4321
|
+
prevBlock: a === void 0 ? void 0 : y(
|
|
4304
4322
|
a,
|
|
4305
4323
|
this.schema.blockSchema,
|
|
4306
4324
|
this.schema.inlineContentSchema,
|
|
4307
4325
|
this.schema.styleSchema,
|
|
4308
4326
|
this.blockCache
|
|
4309
4327
|
),
|
|
4310
|
-
nextBlock: l === void 0 ? void 0 :
|
|
4328
|
+
nextBlock: l === void 0 ? void 0 : y(
|
|
4311
4329
|
l,
|
|
4312
4330
|
this.schema.blockSchema,
|
|
4313
4331
|
this.schema.inlineContentSchema,
|
|
@@ -4323,7 +4341,7 @@ class de {
|
|
|
4323
4341
|
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
4324
4342
|
*/
|
|
4325
4343
|
setTextCursorPosition(t, e = "start") {
|
|
4326
|
-
const o = typeof t == "string" ? t : t.id, { posBeforeNode: r } =
|
|
4344
|
+
const o = typeof t == "string" ? t : t.id, { posBeforeNode: r } = St(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = b(
|
|
4327
4345
|
this._tiptapEditor.state.doc,
|
|
4328
4346
|
r + 2
|
|
4329
4347
|
), a = this.schema.blockSchema[s.type.name].content;
|
|
@@ -4340,7 +4358,7 @@ class de {
|
|
|
4340
4358
|
i + s.nodeSize - 4
|
|
4341
4359
|
);
|
|
4342
4360
|
else
|
|
4343
|
-
throw new
|
|
4361
|
+
throw new A(a);
|
|
4344
4362
|
}
|
|
4345
4363
|
/**
|
|
4346
4364
|
* Gets a snapshot of the current selection.
|
|
@@ -4350,7 +4368,7 @@ class de {
|
|
|
4350
4368
|
return;
|
|
4351
4369
|
const t = [];
|
|
4352
4370
|
return this._tiptapEditor.state.doc.descendants((e, o) => e.type.spec.group !== "blockContent" || o + e.nodeSize < this._tiptapEditor.state.selection.from || o > this._tiptapEditor.state.selection.to ? !0 : (t.push(
|
|
4353
|
-
|
|
4371
|
+
y(
|
|
4354
4372
|
this._tiptapEditor.state.doc.resolve(o).node(),
|
|
4355
4373
|
this.schema.blockSchema,
|
|
4356
4374
|
this.schema.inlineContentSchema,
|
|
@@ -4371,7 +4389,7 @@ class de {
|
|
|
4371
4389
|
* @param editable True to make the editor editable, or false to lock it.
|
|
4372
4390
|
*/
|
|
4373
4391
|
set isEditable(t) {
|
|
4374
|
-
this._tiptapEditor.setEditable(t);
|
|
4392
|
+
this._tiptapEditor.options.editable !== t && this._tiptapEditor.setEditable(t);
|
|
4375
4393
|
}
|
|
4376
4394
|
/**
|
|
4377
4395
|
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
@@ -4382,7 +4400,7 @@ class de {
|
|
|
4382
4400
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
4383
4401
|
*/
|
|
4384
4402
|
insertBlocks(t, e, o = "before") {
|
|
4385
|
-
return
|
|
4403
|
+
return Kn(t, e, o, this);
|
|
4386
4404
|
}
|
|
4387
4405
|
/**
|
|
4388
4406
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
@@ -4392,14 +4410,14 @@ class de {
|
|
|
4392
4410
|
* @param update A partial block which defines how the existing block should be changed.
|
|
4393
4411
|
*/
|
|
4394
4412
|
updateBlock(t, e) {
|
|
4395
|
-
return
|
|
4413
|
+
return Jn(t, e, this);
|
|
4396
4414
|
}
|
|
4397
4415
|
/**
|
|
4398
4416
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
4399
4417
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
4400
4418
|
*/
|
|
4401
4419
|
removeBlocks(t) {
|
|
4402
|
-
return
|
|
4420
|
+
return Xn(t, this);
|
|
4403
4421
|
}
|
|
4404
4422
|
/**
|
|
4405
4423
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
@@ -4409,7 +4427,7 @@ class de {
|
|
|
4409
4427
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
4410
4428
|
*/
|
|
4411
4429
|
replaceBlocks(t, e) {
|
|
4412
|
-
return
|
|
4430
|
+
return Yn(t, e, this);
|
|
4413
4431
|
}
|
|
4414
4432
|
/**
|
|
4415
4433
|
* Insert a piece of content at the current cursor position.
|
|
@@ -4417,12 +4435,12 @@ class de {
|
|
|
4417
4435
|
* @param content can be a string, or array of partial inline content elements
|
|
4418
4436
|
*/
|
|
4419
4437
|
insertInlineContent(t) {
|
|
4420
|
-
const e =
|
|
4438
|
+
const e = at(
|
|
4421
4439
|
t,
|
|
4422
4440
|
this._tiptapEditor.schema,
|
|
4423
4441
|
this.schema.styleSchema
|
|
4424
4442
|
);
|
|
4425
|
-
|
|
4443
|
+
Qn(
|
|
4426
4444
|
{
|
|
4427
4445
|
from: this._tiptapEditor.state.selection.from,
|
|
4428
4446
|
to: this._tiptapEditor.state.selection.to
|
|
@@ -4461,7 +4479,7 @@ class de {
|
|
|
4461
4479
|
else if (r.propSchema === "string")
|
|
4462
4480
|
this._tiptapEditor.commands.setMark(e, { stringValue: o });
|
|
4463
4481
|
else
|
|
4464
|
-
throw new
|
|
4482
|
+
throw new A(r.propSchema);
|
|
4465
4483
|
}
|
|
4466
4484
|
}
|
|
4467
4485
|
/**
|
|
@@ -4488,7 +4506,7 @@ class de {
|
|
|
4488
4506
|
else if (r.propSchema === "string")
|
|
4489
4507
|
this._tiptapEditor.commands.toggleMark(e, { stringValue: o });
|
|
4490
4508
|
else
|
|
4491
|
-
throw new
|
|
4509
|
+
throw new A(r.propSchema);
|
|
4492
4510
|
}
|
|
4493
4511
|
}
|
|
4494
4512
|
/**
|
|
@@ -4561,7 +4579,7 @@ class de {
|
|
|
4561
4579
|
* @returns The blocks, serialized as an HTML string.
|
|
4562
4580
|
*/
|
|
4563
4581
|
async blocksToHTMLLossy(t = this.document) {
|
|
4564
|
-
return
|
|
4582
|
+
return lt(
|
|
4565
4583
|
this._tiptapEditor.schema,
|
|
4566
4584
|
this
|
|
4567
4585
|
).exportBlocks(t);
|
|
@@ -4574,7 +4592,7 @@ class de {
|
|
|
4574
4592
|
* @returns The blocks parsed from the HTML string.
|
|
4575
4593
|
*/
|
|
4576
4594
|
async tryParseHTMLToBlocks(t) {
|
|
4577
|
-
return
|
|
4595
|
+
return ce(
|
|
4578
4596
|
t,
|
|
4579
4597
|
this.schema.blockSchema,
|
|
4580
4598
|
this.schema.inlineContentSchema,
|
|
@@ -4589,7 +4607,7 @@ class de {
|
|
|
4589
4607
|
* @returns The blocks, serialized as a Markdown string.
|
|
4590
4608
|
*/
|
|
4591
4609
|
async blocksToMarkdownLossy(t = this.document) {
|
|
4592
|
-
return
|
|
4610
|
+
return to(t, this._tiptapEditor.schema, this);
|
|
4593
4611
|
}
|
|
4594
4612
|
/**
|
|
4595
4613
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
@@ -4599,7 +4617,7 @@ class de {
|
|
|
4599
4617
|
* @returns The blocks parsed from the Markdown string.
|
|
4600
4618
|
*/
|
|
4601
4619
|
async tryParseMarkdownToBlocks(t) {
|
|
4602
|
-
return
|
|
4620
|
+
return ao(
|
|
4603
4621
|
t,
|
|
4604
4622
|
this.schema.blockSchema,
|
|
4605
4623
|
this.schema.inlineContentSchema,
|
|
@@ -4646,101 +4664,101 @@ class de {
|
|
|
4646
4664
|
};
|
|
4647
4665
|
}
|
|
4648
4666
|
}
|
|
4649
|
-
function
|
|
4667
|
+
function Zo(n) {
|
|
4650
4668
|
let t = n.getTextCursorPosition().block, e = n.schema.blockSchema[t.type].content;
|
|
4651
4669
|
for (; e === "none"; )
|
|
4652
4670
|
t = n.getTextCursorPosition().nextBlock, e = n.schema.blockSchema[t.type].content, n.setTextCursorPosition(t, "end");
|
|
4653
4671
|
}
|
|
4654
|
-
function
|
|
4672
|
+
function P(n, t) {
|
|
4655
4673
|
const e = n.getTextCursorPosition().block;
|
|
4656
4674
|
if (e.content === void 0)
|
|
4657
4675
|
throw new Error("Slash Menu open in a block that doesn't contain content.");
|
|
4658
|
-
Array.isArray(e.content) && (e.content.length === 1 &&
|
|
4676
|
+
Array.isArray(e.content) && (e.content.length === 1 && Q(e.content[0]) && e.content[0].type === "text" && e.content[0].text === "/" || e.content.length === 0) ? n.updateBlock(e, t) : (n.insertBlocks([t], e, "after"), n.setTextCursorPosition(
|
|
4659
4677
|
n.getTextCursorPosition().nextBlock,
|
|
4660
4678
|
"end"
|
|
4661
4679
|
));
|
|
4662
4680
|
const o = n.getTextCursorPosition().block;
|
|
4663
|
-
return
|
|
4681
|
+
return Zo(n), o;
|
|
4664
4682
|
}
|
|
4665
|
-
function
|
|
4683
|
+
function $r(n) {
|
|
4666
4684
|
const t = [];
|
|
4667
|
-
return
|
|
4685
|
+
return I("heading", n) && t.push(
|
|
4668
4686
|
{
|
|
4669
4687
|
title: "Heading 1",
|
|
4670
4688
|
onItemClick: () => {
|
|
4671
|
-
|
|
4689
|
+
P(n, {
|
|
4672
4690
|
type: "heading",
|
|
4673
4691
|
props: { level: 1 }
|
|
4674
4692
|
});
|
|
4675
4693
|
},
|
|
4676
4694
|
subtext: "Used for a top-level heading",
|
|
4677
|
-
badge:
|
|
4695
|
+
badge: F("Mod-Alt-1"),
|
|
4678
4696
|
aliases: ["h", "heading1", "h1"],
|
|
4679
4697
|
group: "Headings"
|
|
4680
4698
|
},
|
|
4681
4699
|
{
|
|
4682
4700
|
title: "Heading 2",
|
|
4683
4701
|
onItemClick: () => {
|
|
4684
|
-
|
|
4702
|
+
P(n, {
|
|
4685
4703
|
type: "heading",
|
|
4686
4704
|
props: { level: 2 }
|
|
4687
4705
|
});
|
|
4688
4706
|
},
|
|
4689
4707
|
subtext: "Used for key sections",
|
|
4690
|
-
badge:
|
|
4708
|
+
badge: F("Mod-Alt-2"),
|
|
4691
4709
|
aliases: ["h2", "heading2", "subheading"],
|
|
4692
4710
|
group: "Headings"
|
|
4693
4711
|
},
|
|
4694
4712
|
{
|
|
4695
4713
|
title: "Heading 3",
|
|
4696
4714
|
onItemClick: () => {
|
|
4697
|
-
|
|
4715
|
+
P(n, {
|
|
4698
4716
|
type: "heading",
|
|
4699
4717
|
props: { level: 3 }
|
|
4700
4718
|
});
|
|
4701
4719
|
},
|
|
4702
4720
|
subtext: "Used for subsections and group headings",
|
|
4703
|
-
badge:
|
|
4721
|
+
badge: F("Mod-Alt-3"),
|
|
4704
4722
|
aliases: ["h3", "heading3", "subheading"],
|
|
4705
4723
|
group: "Headings"
|
|
4706
4724
|
}
|
|
4707
|
-
),
|
|
4725
|
+
), I("numberedListItem", n) && t.push({
|
|
4708
4726
|
title: "Numbered List",
|
|
4709
4727
|
onItemClick: () => {
|
|
4710
|
-
|
|
4728
|
+
P(n, {
|
|
4711
4729
|
type: "numberedListItem"
|
|
4712
4730
|
});
|
|
4713
4731
|
},
|
|
4714
4732
|
subtext: "Used to display a numbered list",
|
|
4715
|
-
badge:
|
|
4733
|
+
badge: F("Mod-Shift-7"),
|
|
4716
4734
|
aliases: ["ol", "li", "list", "numberedlist", "numbered list"],
|
|
4717
4735
|
group: "Basic blocks"
|
|
4718
|
-
}),
|
|
4736
|
+
}), I("bulletListItem", n) && t.push({
|
|
4719
4737
|
title: "Bullet List",
|
|
4720
4738
|
onItemClick: () => {
|
|
4721
|
-
|
|
4739
|
+
P(n, {
|
|
4722
4740
|
type: "bulletListItem"
|
|
4723
4741
|
});
|
|
4724
4742
|
},
|
|
4725
4743
|
subtext: "Used to display an unordered list",
|
|
4726
|
-
badge:
|
|
4744
|
+
badge: F("Mod-Shift-8"),
|
|
4727
4745
|
aliases: ["ul", "li", "list", "bulletlist", "bullet list"],
|
|
4728
4746
|
group: "Basic blocks"
|
|
4729
|
-
}),
|
|
4747
|
+
}), I("paragraph", n) && t.push({
|
|
4730
4748
|
title: "Paragraph",
|
|
4731
4749
|
onItemClick: () => {
|
|
4732
|
-
|
|
4750
|
+
P(n, {
|
|
4733
4751
|
type: "paragraph"
|
|
4734
4752
|
});
|
|
4735
4753
|
},
|
|
4736
4754
|
subtext: "Used for the body of your document",
|
|
4737
|
-
badge:
|
|
4755
|
+
badge: F("Mod-Alt-0"),
|
|
4738
4756
|
aliases: ["p", "paragraph"],
|
|
4739
4757
|
group: "Basic blocks"
|
|
4740
|
-
}),
|
|
4758
|
+
}), I("table", n) && t.push({
|
|
4741
4759
|
title: "Table",
|
|
4742
4760
|
onItemClick: () => {
|
|
4743
|
-
|
|
4761
|
+
P(n, {
|
|
4744
4762
|
type: "table",
|
|
4745
4763
|
content: {
|
|
4746
4764
|
type: "tableContent",
|
|
@@ -4759,14 +4777,14 @@ function Fr(n) {
|
|
|
4759
4777
|
aliases: ["table"],
|
|
4760
4778
|
group: "Advanced",
|
|
4761
4779
|
badge: void 0
|
|
4762
|
-
}),
|
|
4780
|
+
}), I("image", n) && t.push({
|
|
4763
4781
|
title: "Image",
|
|
4764
4782
|
onItemClick: () => {
|
|
4765
|
-
const e =
|
|
4783
|
+
const e = P(n, {
|
|
4766
4784
|
type: "image"
|
|
4767
4785
|
});
|
|
4768
4786
|
n.prosemirrorView.dispatch(
|
|
4769
|
-
n._tiptapEditor.state.tr.setMeta(n.
|
|
4787
|
+
n._tiptapEditor.state.tr.setMeta(n.imagePanel.plugin, {
|
|
4770
4788
|
block: e
|
|
4771
4789
|
})
|
|
4772
4790
|
);
|
|
@@ -4786,14 +4804,14 @@ function Fr(n) {
|
|
|
4786
4804
|
group: "Media"
|
|
4787
4805
|
}), t;
|
|
4788
4806
|
}
|
|
4789
|
-
function
|
|
4807
|
+
function Gr(n, t) {
|
|
4790
4808
|
return n.filter(
|
|
4791
4809
|
({ title: e, aliases: o }) => e.toLowerCase().startsWith(t.toLowerCase()) || o && o.filter(
|
|
4792
4810
|
(r) => r.toLowerCase().startsWith(t.toLowerCase())
|
|
4793
4811
|
).length !== 0
|
|
4794
4812
|
);
|
|
4795
4813
|
}
|
|
4796
|
-
function
|
|
4814
|
+
function mt(n = "") {
|
|
4797
4815
|
return typeof n == "string" ? [
|
|
4798
4816
|
{
|
|
4799
4817
|
type: "text",
|
|
@@ -4803,21 +4821,21 @@ function ht(n = "") {
|
|
|
4803
4821
|
] : n;
|
|
4804
4822
|
}
|
|
4805
4823
|
function pe(n) {
|
|
4806
|
-
return typeof n == "string" ?
|
|
4824
|
+
return typeof n == "string" ? mt(n) : Array.isArray(n) ? n.flatMap((t) => typeof t == "string" ? mt(t) : Gt(t) ? {
|
|
4807
4825
|
...t,
|
|
4808
|
-
content:
|
|
4809
|
-
} :
|
|
4826
|
+
content: mt(t.content)
|
|
4827
|
+
} : Q(t) ? t : {
|
|
4810
4828
|
props: {},
|
|
4811
4829
|
...t,
|
|
4812
4830
|
content: pe(t.content)
|
|
4813
4831
|
}) : n;
|
|
4814
4832
|
}
|
|
4815
|
-
function
|
|
4833
|
+
function jr(n, t) {
|
|
4816
4834
|
return t.map(
|
|
4817
|
-
(e) =>
|
|
4835
|
+
(e) => he(n, e)
|
|
4818
4836
|
);
|
|
4819
4837
|
}
|
|
4820
|
-
function
|
|
4838
|
+
function he(n, t) {
|
|
4821
4839
|
const e = {
|
|
4822
4840
|
id: "",
|
|
4823
4841
|
type: t.type,
|
|
@@ -4833,96 +4851,96 @@ function ue(n, t) {
|
|
|
4833
4851
|
), {
|
|
4834
4852
|
...e,
|
|
4835
4853
|
content: pe(e.content),
|
|
4836
|
-
children: e.children.map((o) =>
|
|
4854
|
+
children: e.children.map((o) => he(n, o))
|
|
4837
4855
|
};
|
|
4838
4856
|
}
|
|
4839
|
-
function Zo(n) {
|
|
4840
|
-
n.id || (n.id = Q.options.generateID()), n.children && tr(n.children);
|
|
4841
|
-
}
|
|
4842
4857
|
function tr(n) {
|
|
4858
|
+
n.id || (n.id = Z.options.generateID()), n.children && er(n.children);
|
|
4859
|
+
}
|
|
4860
|
+
function er(n) {
|
|
4843
4861
|
for (const t of n)
|
|
4844
|
-
|
|
4862
|
+
tr(t);
|
|
4845
4863
|
}
|
|
4846
4864
|
export {
|
|
4847
|
-
|
|
4865
|
+
ue as BlockNoteEditor,
|
|
4848
4866
|
Tt as BlockNoteSchema,
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
mo as
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4867
|
+
uo as FormattingToolbarProsemirrorPlugin,
|
|
4868
|
+
lo as FormattingToolbarView,
|
|
4869
|
+
xo as ImagePanelProsemirrorPlugin,
|
|
4870
|
+
Co as ImagePanelView,
|
|
4871
|
+
mo as LinkToolbarProsemirrorPlugin,
|
|
4872
|
+
So as SideMenuProsemirrorPlugin,
|
|
4873
|
+
vo as SideMenuView,
|
|
4874
|
+
bo as SuggestionMenuProseMirrorPlugin,
|
|
4857
4875
|
Io as TableHandlesProsemirrorPlugin,
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4876
|
+
Lo as TableHandlesView,
|
|
4877
|
+
Z as UniqueID,
|
|
4878
|
+
A as UnreachableCaseError,
|
|
4879
|
+
tr as addIdsToBlock,
|
|
4880
|
+
er as addIdsToBlocks,
|
|
4863
4881
|
pn as addInlineContentAttributes,
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4882
|
+
hn as addInlineContentKeyboardShortcuts,
|
|
4883
|
+
kn as addStyleAttributes,
|
|
4884
|
+
D as blockToNode,
|
|
4885
|
+
st as camelToDataKebab,
|
|
4886
|
+
Vr as checkBlockHasDefaultProp,
|
|
4887
|
+
zr as checkBlockIsDefaultType,
|
|
4888
|
+
qn as checkBlockTypeHasDefaultProp,
|
|
4889
|
+
I as checkDefaultBlockTypeInSchema,
|
|
4890
|
+
vt as contentNodeToInlineContent,
|
|
4891
|
+
un as createBlockSpec,
|
|
4892
|
+
et as createBlockSpecFromStronglyTypedTiptapNode,
|
|
4893
|
+
lt as createExternalHTMLExporter,
|
|
4894
|
+
Or as createInlineContentSpec,
|
|
4895
|
+
fn as createInlineContentSpecFromTipTapNode,
|
|
4896
|
+
Zt as createInternalBlockSpec,
|
|
4897
|
+
Xt as createInternalHTMLSerializer,
|
|
4898
|
+
mn as createInternalInlineContentSpec,
|
|
4899
|
+
ne as createInternalStyleSpec,
|
|
4900
|
+
q as createStronglyTypedTiptapNode,
|
|
4901
|
+
_r as createStyleSpec,
|
|
4902
|
+
_ as createStyleSpecFromTipTapMark,
|
|
4903
|
+
Fr as createSuggestionMenu,
|
|
4904
|
+
Wn as defaultBlockSchema,
|
|
4905
|
+
re as defaultBlockSpecs,
|
|
4906
|
+
Rr as defaultInlineContentSchema,
|
|
4907
|
+
se as defaultInlineContentSpecs,
|
|
4890
4908
|
w as defaultProps,
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4909
|
+
Ur as defaultStyleSchema,
|
|
4910
|
+
ie as defaultStyleSpecs,
|
|
4911
|
+
Gr as filterSuggestionItems,
|
|
4912
|
+
F as formatKeyboardShortcut,
|
|
4913
|
+
co as formattingToolbarPluginKey,
|
|
4914
|
+
cn as getBlockFromPos,
|
|
4915
|
+
Ko as getBlockNoteExtensions,
|
|
4916
|
+
te as getBlockSchemaFromSpecs,
|
|
4917
|
+
$r as getDefaultSlashMenuItems,
|
|
4918
|
+
xt as getDraggableBlockFromCoords,
|
|
4919
|
+
gn as getInlineContentParseRules,
|
|
4920
|
+
ee as getInlineContentSchemaFromSpecs,
|
|
4921
|
+
dn as getParseRules,
|
|
4904
4922
|
yn as getStyleParseRules,
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
an as isAppleOS,
|
|
4923
|
+
oe as getStyleSchemaFromSpecs,
|
|
4924
|
+
Yt as inheritedProps,
|
|
4925
|
+
at as inlineContentToNodes,
|
|
4926
|
+
P as insertOrUpdateBlock,
|
|
4927
|
+
ln as isAppleOS,
|
|
4911
4928
|
It as isLinkInlineContent,
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4929
|
+
Gt as isPartialLinkInlineContent,
|
|
4930
|
+
Dr as isSafari,
|
|
4931
|
+
Q as isStyledTextInlineContent,
|
|
4932
|
+
ho as linkToolbarPluginKey,
|
|
4933
|
+
z as mergeCSSClasses,
|
|
4934
|
+
y as nodeToBlock,
|
|
4935
|
+
qt as nodeToCustomInlineContent,
|
|
4936
|
+
he as partialBlockToBlockForTesting,
|
|
4937
|
+
jr as partialBlocksToBlocksForTesting,
|
|
4938
|
+
Qt as propsToAttributes,
|
|
4939
|
+
Eo as sideMenuPluginKey,
|
|
4940
|
+
bn as stylePropsToAttributes,
|
|
4941
|
+
R as suggestionMenuPluginKey,
|
|
4942
|
+
jt as tableContentToNodes,
|
|
4943
|
+
Y as tableHandlesPluginKey,
|
|
4926
4944
|
Hr as uploadToTmpFilesDotOrg_DEV_ONLY,
|
|
4927
4945
|
pt as wrapInBlockStructure
|
|
4928
4946
|
};
|