@blocknote/core 0.9.2 → 0.9.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 +158 -141
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +4 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/src/extensions/Blocks/nodes/BlockContainer.ts +36 -12
- package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +2 -0
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +2 -0
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +2 -0
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +13 -1
- package/types/src/extensions/Blocks/NonEditableBlockPlugin.d.ts +2 -0
- package/types/src/extensions/Blocks/api/defaultProps.d.ts +14 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/Image.d.ts +6 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.d.ts +37 -0
- package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +36 -0
- package/types/src/extensions/Blocks/nodes/TableCell.d.ts +0 -5
- package/types/src/extensions/Blocks/nodes/TableRow.d.ts +0 -5
package/dist/blocknote.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var Pt = Object.defineProperty;
|
|
2
2
|
var Ot = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
-
var
|
|
3
|
+
var p = (n, e, t) => (Ot(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
import { Extension as T, Mark as lt, Node as U, InputRule as K, mergeAttributes as A, combineTransactionSteps as Dt, getChangedRanges as Rt, findChildrenInRange as Vt, findChildren as tt, findParentNode as zt, extensions as L, isTextSelection as Ut, isNodeSelection as Ft, posToDOMRect as q, getMarkRange as et, Editor as Gt } from "@tiptap/core";
|
|
5
5
|
import { Bold as $t } from "@tiptap/extension-bold";
|
|
6
6
|
import { Code as jt } from "@tiptap/extension-code";
|
|
@@ -67,14 +67,14 @@ function k(n, e) {
|
|
|
67
67
|
break;
|
|
68
68
|
l -= 1, s = r.node(l);
|
|
69
69
|
}
|
|
70
|
-
const { id: a, contentNode: d, contentType: c, numChildBlocks: h } = pt(s),
|
|
70
|
+
const { id: a, contentNode: d, contentType: c, numChildBlocks: h } = pt(s), u = r.start(l), f = r.end(l);
|
|
71
71
|
return {
|
|
72
72
|
id: a,
|
|
73
73
|
node: s,
|
|
74
74
|
contentNode: d,
|
|
75
75
|
contentType: c,
|
|
76
76
|
numChildBlocks: h,
|
|
77
|
-
startPos:
|
|
77
|
+
startPos: u,
|
|
78
78
|
endPos: f,
|
|
79
79
|
depth: l
|
|
80
80
|
};
|
|
@@ -248,22 +248,22 @@ function Zo(n) {
|
|
|
248
248
|
const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, h = s.getBlock(c);
|
|
249
249
|
if (h.type !== n.type)
|
|
250
250
|
throw new Error("Block type does not match");
|
|
251
|
-
const
|
|
252
|
-
if ("contentDOM" in
|
|
251
|
+
const u = n.render(h, s);
|
|
252
|
+
if ("contentDOM" in u) {
|
|
253
253
|
const g = ((m = this.options.domAttributes) == null ? void 0 : m.inlineContent) || {};
|
|
254
254
|
for (const [b, C] of Object.entries(
|
|
255
255
|
g
|
|
256
256
|
))
|
|
257
|
-
b !== "class" &&
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
b !== "class" && u.contentDOM.setAttribute(b, C);
|
|
258
|
+
u.contentDOM.className = v(
|
|
259
|
+
u.contentDOM.className,
|
|
260
260
|
y.inlineContent,
|
|
261
261
|
g.class
|
|
262
262
|
);
|
|
263
263
|
}
|
|
264
|
-
return r.appendChild(
|
|
264
|
+
return r.appendChild(u.dom), "contentDOM" in u ? {
|
|
265
265
|
dom: r,
|
|
266
|
-
contentDOM:
|
|
266
|
+
contentDOM: u.contentDOM
|
|
267
267
|
} : {
|
|
268
268
|
dom: r
|
|
269
269
|
};
|
|
@@ -334,6 +334,7 @@ const Se = O({
|
|
|
334
334
|
return [
|
|
335
335
|
"div",
|
|
336
336
|
A(e, {
|
|
337
|
+
...t,
|
|
337
338
|
class: v(
|
|
338
339
|
y.blockContent,
|
|
339
340
|
t.class
|
|
@@ -343,6 +344,7 @@ const Se = O({
|
|
|
343
344
|
[
|
|
344
345
|
"h" + n.attrs.level,
|
|
345
346
|
{
|
|
347
|
+
...o,
|
|
346
348
|
class: v(
|
|
347
349
|
y.inlineContent,
|
|
348
350
|
o.class
|
|
@@ -426,6 +428,7 @@ const Se = O({
|
|
|
426
428
|
return [
|
|
427
429
|
"div",
|
|
428
430
|
A(n, {
|
|
431
|
+
...e,
|
|
429
432
|
class: v(
|
|
430
433
|
y.blockContent,
|
|
431
434
|
e.class
|
|
@@ -435,6 +438,7 @@ const Se = O({
|
|
|
435
438
|
[
|
|
436
439
|
"p",
|
|
437
440
|
{
|
|
441
|
+
...t,
|
|
438
442
|
class: v(
|
|
439
443
|
y.inlineContent,
|
|
440
444
|
t.class
|
|
@@ -457,12 +461,12 @@ const Se = O({
|
|
|
457
461
|
if (d === void 0)
|
|
458
462
|
return;
|
|
459
463
|
if (!a) {
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
464
|
+
const u = k(o.doc, s - 2);
|
|
465
|
+
if (u === void 0)
|
|
462
466
|
return;
|
|
463
|
-
if (!(d.depth !==
|
|
464
|
-
const m =
|
|
465
|
-
if (
|
|
467
|
+
if (!(d.depth !== u.depth)) {
|
|
468
|
+
const m = u.contentNode;
|
|
469
|
+
if (u.contentType.name === "numberedListItem") {
|
|
466
470
|
const C = m.attrs.index;
|
|
467
471
|
l = (parseInt(C) + 1).toString();
|
|
468
472
|
}
|
|
@@ -545,6 +549,7 @@ const Se = O({
|
|
|
545
549
|
return [
|
|
546
550
|
"div",
|
|
547
551
|
A(n, {
|
|
552
|
+
...e,
|
|
548
553
|
class: v(
|
|
549
554
|
y.blockContent,
|
|
550
555
|
e.class
|
|
@@ -556,6 +561,7 @@ const Se = O({
|
|
|
556
561
|
[
|
|
557
562
|
"p",
|
|
558
563
|
{
|
|
564
|
+
...t,
|
|
559
565
|
class: v(
|
|
560
566
|
y.inlineContent,
|
|
561
567
|
t.class
|
|
@@ -732,7 +738,7 @@ const F = T.create({
|
|
|
732
738
|
const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h = Dt(
|
|
733
739
|
o.doc,
|
|
734
740
|
t
|
|
735
|
-
), { mapping:
|
|
741
|
+
), { mapping: u } = h;
|
|
736
742
|
if (Rt(h).forEach(({ newRange: m }) => {
|
|
737
743
|
const g = Vt(
|
|
738
744
|
r.doc,
|
|
@@ -749,7 +755,7 @@ const F = T.create({
|
|
|
749
755
|
});
|
|
750
756
|
return;
|
|
751
757
|
}
|
|
752
|
-
const { deleted: Lt } =
|
|
758
|
+
const { deleted: Lt } = u.invert().mapResult(R);
|
|
753
759
|
Lt && C.includes(Q) && l.setNodeMarkup(R, void 0, {
|
|
754
760
|
...M.attrs,
|
|
755
761
|
[d]: c()
|
|
@@ -990,12 +996,12 @@ function E(n, e, t) {
|
|
|
990
996
|
...n.attrs,
|
|
991
997
|
...r.contentNode.attrs
|
|
992
998
|
})) {
|
|
993
|
-
const
|
|
994
|
-
if (!
|
|
999
|
+
const u = e[r.contentType.name];
|
|
1000
|
+
if (!u)
|
|
995
1001
|
throw Error(
|
|
996
1002
|
"Block is of an unrecognized type: " + r.contentType.name
|
|
997
1003
|
);
|
|
998
|
-
const f =
|
|
1004
|
+
const f = u.propSchema;
|
|
999
1005
|
c in f ? s[c] = h : c !== "id" && !(c in P) && console.warn("Block has an unrecognized attribute: " + c);
|
|
1000
1006
|
}
|
|
1001
1007
|
const l = He(r.contentNode), a = [];
|
|
@@ -1058,12 +1064,12 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1058
1064
|
s.map((d) => [d.node.attrs.id, d])
|
|
1059
1065
|
), a = tt(r.doc, (d) => d.attrs.id);
|
|
1060
1066
|
for (const d of a) {
|
|
1061
|
-
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild,
|
|
1062
|
-
if (c && h &&
|
|
1067
|
+
const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, u = d.node.firstChild;
|
|
1068
|
+
if (c && h && u) {
|
|
1063
1069
|
const f = {
|
|
1064
|
-
index:
|
|
1065
|
-
level:
|
|
1066
|
-
type:
|
|
1070
|
+
index: u.attrs.index,
|
|
1071
|
+
level: u.attrs.level,
|
|
1072
|
+
type: u.type.name,
|
|
1067
1073
|
depth: r.doc.resolve(d.pos).depth
|
|
1068
1074
|
};
|
|
1069
1075
|
let m = {
|
|
@@ -1173,27 +1179,35 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1173
1179
|
const { startPos: i, endPos: s, node: l, contentNode: a } = r;
|
|
1174
1180
|
if (o) {
|
|
1175
1181
|
if (e.children !== void 0) {
|
|
1176
|
-
const
|
|
1177
|
-
for (const
|
|
1178
|
-
|
|
1182
|
+
const f = [];
|
|
1183
|
+
for (const m of e.children)
|
|
1184
|
+
f.push(D(m, t.schema));
|
|
1179
1185
|
l.childCount === 2 ? t.tr.replace(
|
|
1180
1186
|
i + a.nodeSize + 1,
|
|
1181
1187
|
s - 1,
|
|
1182
|
-
new x(_.from(
|
|
1188
|
+
new x(_.from(f), 0, 0)
|
|
1183
1189
|
) : t.tr.insert(
|
|
1184
1190
|
i + a.nodeSize,
|
|
1185
|
-
t.schema.nodes.blockGroup.create({},
|
|
1191
|
+
t.schema.nodes.blockGroup.create({}, f)
|
|
1186
1192
|
);
|
|
1187
1193
|
}
|
|
1188
1194
|
if (e.content !== void 0) {
|
|
1189
|
-
let
|
|
1190
|
-
typeof e.content == "string" ?
|
|
1195
|
+
let f = [];
|
|
1196
|
+
typeof e.content == "string" ? f.push(t.schema.text(e.content)) : f = Tt(e.content, t.schema), t.tr.replace(
|
|
1191
1197
|
i + 1,
|
|
1192
1198
|
i + a.nodeSize - 1,
|
|
1193
|
-
new x(_.from(
|
|
1199
|
+
new x(_.from(f), 0, 0)
|
|
1194
1200
|
);
|
|
1195
1201
|
}
|
|
1196
|
-
t.
|
|
1202
|
+
const d = a.type.name, c = e.type || d, h = t.schema.nodes[d].spec.content, u = t.schema.nodes[c].spec.content;
|
|
1203
|
+
h === "inline*" && u === "" ? t.tr.replaceWith(
|
|
1204
|
+
i,
|
|
1205
|
+
s,
|
|
1206
|
+
t.schema.nodes[c].create({
|
|
1207
|
+
...a.attrs,
|
|
1208
|
+
...e.props
|
|
1209
|
+
})
|
|
1210
|
+
) : t.tr.setNodeMarkup(
|
|
1197
1211
|
i,
|
|
1198
1212
|
e.type === void 0 ? void 0 : t.schema.nodes[e.type],
|
|
1199
1213
|
{
|
|
@@ -1238,9 +1252,9 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1238
1252
|
), m = e.doc.resolve(d - 1), g = f.blockRange(m);
|
|
1239
1253
|
t && e.tr.lift(g, c - 1);
|
|
1240
1254
|
}
|
|
1241
|
-
let h = n - 1,
|
|
1242
|
-
for (;
|
|
1243
|
-
if (h--,
|
|
1255
|
+
let h = n - 1, u = k(e.doc, h);
|
|
1256
|
+
for (; u.numChildBlocks > 0; )
|
|
1257
|
+
if (h--, u = k(e.doc, h), u === void 0)
|
|
1244
1258
|
return !1;
|
|
1245
1259
|
return t && (t(
|
|
1246
1260
|
e.tr.deleteRange(a, a + l.nodeSize).replace(
|
|
@@ -1258,8 +1272,8 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1258
1272
|
const r = k(t.doc, n);
|
|
1259
1273
|
if (r === void 0)
|
|
1260
1274
|
return !1;
|
|
1261
|
-
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), h = t.doc.cut(n, a - 1),
|
|
1262
|
-
return o && (t.tr.insert(f,
|
|
1275
|
+
const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), h = t.doc.cut(n, a - 1), u = t.schema.nodes.blockContainer.createAndFill(), f = a + 1, m = f + 2;
|
|
1276
|
+
return o && (t.tr.insert(f, u), t.tr.replace(
|
|
1263
1277
|
m,
|
|
1264
1278
|
m + 1,
|
|
1265
1279
|
h.content.size > 0 ? new x(
|
|
@@ -1448,7 +1462,7 @@ const st = new S("previous-blocks"), Ne = {
|
|
|
1448
1462
|
class G {
|
|
1449
1463
|
constructor() {
|
|
1450
1464
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1451
|
-
|
|
1465
|
+
p(this, "callbacks", {});
|
|
1452
1466
|
}
|
|
1453
1467
|
on(e, t) {
|
|
1454
1468
|
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
@@ -1471,10 +1485,10 @@ const Ue = zt(
|
|
|
1471
1485
|
class Fe {
|
|
1472
1486
|
constructor(e, t, o = () => {
|
|
1473
1487
|
}) {
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1488
|
+
p(this, "suggestionsMenuState");
|
|
1489
|
+
p(this, "updateSuggestionsMenu");
|
|
1490
|
+
p(this, "pluginState");
|
|
1491
|
+
p(this, "handleScroll", () => {
|
|
1478
1492
|
var e;
|
|
1479
1493
|
if ((e = this.suggestionsMenuState) != null && e.show) {
|
|
1480
1494
|
const t = document.querySelector(
|
|
@@ -1562,13 +1576,13 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1562
1576
|
};
|
|
1563
1577
|
if (!d.active)
|
|
1564
1578
|
return d;
|
|
1565
|
-
const
|
|
1566
|
-
if (
|
|
1579
|
+
const u = { ...d };
|
|
1580
|
+
if (u.items = r(
|
|
1567
1581
|
h.doc.textBetween(
|
|
1568
1582
|
d.queryStartPos,
|
|
1569
1583
|
h.selection.from
|
|
1570
1584
|
)
|
|
1571
|
-
),
|
|
1585
|
+
), u.notFoundCount = 0, u.items.length === 0 && (u.notFoundCount = Math.max(
|
|
1572
1586
|
0,
|
|
1573
1587
|
d.notFoundCount + (h.selection.from - c.selection.from)
|
|
1574
1588
|
)), // Highlighting text should hide the menu.
|
|
@@ -1578,14 +1592,14 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1578
1592
|
a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
|
|
1579
1593
|
d.active && h.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
|
|
1580
1594
|
// the menu.
|
|
1581
|
-
|
|
1595
|
+
u.notFoundCount > 3)
|
|
1582
1596
|
return Y();
|
|
1583
1597
|
if (((b = a.getMeta(t)) == null ? void 0 : b.selectedItemIndexChanged) !== void 0) {
|
|
1584
1598
|
let C = a.getMeta(t).selectedItemIndexChanged;
|
|
1585
|
-
C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0),
|
|
1599
|
+
C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0), u.keyboardHoveredItemIndex = C;
|
|
1586
1600
|
} else
|
|
1587
|
-
c.selection.from !== h.selection.from && (
|
|
1588
|
-
return
|
|
1601
|
+
c.selection.from !== h.selection.from && (u.keyboardHoveredItemIndex = 0);
|
|
1602
|
+
return u;
|
|
1589
1603
|
}
|
|
1590
1604
|
},
|
|
1591
1605
|
props: {
|
|
@@ -1602,7 +1616,7 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1602
1616
|
return !1;
|
|
1603
1617
|
const {
|
|
1604
1618
|
triggerCharacter: h,
|
|
1605
|
-
queryStartPos:
|
|
1619
|
+
queryStartPos: u,
|
|
1606
1620
|
items: f,
|
|
1607
1621
|
keyboardHoveredItemIndex: m
|
|
1608
1622
|
} = t.getState(a.state);
|
|
@@ -1615,7 +1629,7 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1615
1629
|
selectedItemIndexChanged: m + 1
|
|
1616
1630
|
})
|
|
1617
1631
|
), !0) : d.key === "Enter" ? (l(a), n._tiptapEditor.chain().focus().deleteRange({
|
|
1618
|
-
from:
|
|
1632
|
+
from: u - h.length,
|
|
1619
1633
|
to: n._tiptapEditor.state.selection.from
|
|
1620
1634
|
}).run(), i({
|
|
1621
1635
|
item: f[m],
|
|
@@ -1624,10 +1638,10 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1624
1638
|
},
|
|
1625
1639
|
// Setup decorator on the currently active suggestion.
|
|
1626
1640
|
decorations(a) {
|
|
1627
|
-
const { active: d, decorationId: c, queryStartPos: h, triggerCharacter:
|
|
1641
|
+
const { active: d, decorationId: c, queryStartPos: h, triggerCharacter: u } = this.getState(a);
|
|
1628
1642
|
if (!d)
|
|
1629
1643
|
return null;
|
|
1630
|
-
if (
|
|
1644
|
+
if (u === "") {
|
|
1631
1645
|
const f = Ue(a.selection);
|
|
1632
1646
|
if (f)
|
|
1633
1647
|
return z.create(a.doc, [
|
|
@@ -1644,7 +1658,7 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1644
1658
|
}
|
|
1645
1659
|
return z.create(a.doc, [
|
|
1646
1660
|
V.inline(
|
|
1647
|
-
h -
|
|
1661
|
+
h - u.length,
|
|
1648
1662
|
h,
|
|
1649
1663
|
{
|
|
1650
1664
|
nodeName: "span",
|
|
@@ -1670,8 +1684,8 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
|
|
|
1670
1684
|
class $e extends G {
|
|
1671
1685
|
constructor(t, o) {
|
|
1672
1686
|
super();
|
|
1673
|
-
|
|
1674
|
-
|
|
1687
|
+
p(this, "plugin");
|
|
1688
|
+
p(this, "itemCallback");
|
|
1675
1689
|
const r = Ge(
|
|
1676
1690
|
t,
|
|
1677
1691
|
(i) => {
|
|
@@ -1719,10 +1733,10 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1719
1733
|
if ((d || !this.options.showOnlyCurrent) && c) {
|
|
1720
1734
|
const h = [this.options.emptyNodeClass];
|
|
1721
1735
|
this.editor.isEmpty && h.push(this.options.emptyEditorClass), d && h.push(this.options.hasAnchorClass), (o == null ? void 0 : o.triggerCharacter) === "" && (o != null && o.active) && h.push(this.options.isFilterClass);
|
|
1722
|
-
const
|
|
1736
|
+
const u = V.node(a, a + l.nodeSize, {
|
|
1723
1737
|
class: h.join(" ")
|
|
1724
1738
|
});
|
|
1725
|
-
s.push(
|
|
1739
|
+
s.push(u);
|
|
1726
1740
|
}
|
|
1727
1741
|
return this.options.includeChildren;
|
|
1728
1742
|
}), z.create(e, s);
|
|
@@ -1850,7 +1864,10 @@ const je = new S("blocknote-placeholder"), qe = T.create({
|
|
|
1850
1864
|
throw new Error("Expected blockGroup");
|
|
1851
1865
|
if (o = o.lastChild, !o || o.type.name !== "blockContainer")
|
|
1852
1866
|
throw new Error("Expected blockContainer");
|
|
1853
|
-
|
|
1867
|
+
const r = o.firstChild;
|
|
1868
|
+
if (!r)
|
|
1869
|
+
throw new Error("Expected blockContent");
|
|
1870
|
+
return o.nodeSize > 4 || r.type.spec.content !== "inline*";
|
|
1854
1871
|
}
|
|
1855
1872
|
}
|
|
1856
1873
|
})
|
|
@@ -2027,10 +2044,10 @@ function eo(n) {
|
|
|
2027
2044
|
for (let s = 0; s < r; s++) {
|
|
2028
2045
|
const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, h = e.has(
|
|
2029
2046
|
d.properties.dataContentType
|
|
2030
|
-
),
|
|
2047
|
+
), u = h ? n.orderedListItemBlockTypes.has(
|
|
2031
2048
|
d.properties.dataContentType
|
|
2032
2049
|
) ? "ol" : "ul" : null;
|
|
2033
|
-
if (c !== null && t(c), i && i.tagName !==
|
|
2050
|
+
if (c !== null && t(c), i && i.tagName !== u) {
|
|
2034
2051
|
o.children.splice(
|
|
2035
2052
|
s - i.children.length,
|
|
2036
2053
|
i.children.length,
|
|
@@ -2041,7 +2058,7 @@ function eo(n) {
|
|
|
2041
2058
|
}
|
|
2042
2059
|
if (h) {
|
|
2043
2060
|
i || (i = nt(
|
|
2044
|
-
document.createElement(
|
|
2061
|
+
document.createElement(u)
|
|
2045
2062
|
));
|
|
2046
2063
|
const f = nt(
|
|
2047
2064
|
document.createElement("li")
|
|
@@ -2112,30 +2129,30 @@ async function ro(n, e, t) {
|
|
|
2112
2129
|
}
|
|
2113
2130
|
class io {
|
|
2114
2131
|
constructor(e, t, o) {
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2132
|
+
p(this, "formattingToolbarState");
|
|
2133
|
+
p(this, "updateFormattingToolbar");
|
|
2134
|
+
p(this, "preventHide", !1);
|
|
2135
|
+
p(this, "preventShow", !1);
|
|
2136
|
+
p(this, "prevWasEditable", null);
|
|
2137
|
+
p(this, "shouldShow", ({ view: e, state: t, from: o, to: r }) => {
|
|
2121
2138
|
const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length && Ut(t.selection);
|
|
2122
2139
|
return !(!e.hasFocus() || l || a);
|
|
2123
2140
|
});
|
|
2124
|
-
|
|
2141
|
+
p(this, "viewMousedownHandler", () => {
|
|
2125
2142
|
this.preventShow = !0;
|
|
2126
2143
|
});
|
|
2127
|
-
|
|
2144
|
+
p(this, "viewMouseupHandler", () => {
|
|
2128
2145
|
this.preventShow = !1, setTimeout(() => this.update(this.pmView));
|
|
2129
2146
|
});
|
|
2130
2147
|
// For dragging the whole editor.
|
|
2131
|
-
|
|
2148
|
+
p(this, "dragstartHandler", () => {
|
|
2132
2149
|
var e;
|
|
2133
2150
|
(e = this.formattingToolbarState) != null && e.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2134
2151
|
});
|
|
2135
|
-
|
|
2152
|
+
p(this, "focusHandler", () => {
|
|
2136
2153
|
setTimeout(() => this.update(this.pmView));
|
|
2137
2154
|
});
|
|
2138
|
-
|
|
2155
|
+
p(this, "blurHandler", (e) => {
|
|
2139
2156
|
var o;
|
|
2140
2157
|
if (this.preventHide) {
|
|
2141
2158
|
this.preventHide = !1;
|
|
@@ -2146,7 +2163,7 @@ class io {
|
|
|
2146
2163
|
e && e.relatedTarget && // Element is inside the editor.
|
|
2147
2164
|
(t === e.relatedTarget || t.contains(e.relatedTarget)) || (o = this.formattingToolbarState) != null && o.show && (this.formattingToolbarState.show = !1, this.updateFormattingToolbar());
|
|
2148
2165
|
});
|
|
2149
|
-
|
|
2166
|
+
p(this, "scrollHandler", () => {
|
|
2150
2167
|
var e;
|
|
2151
2168
|
(e = this.formattingToolbarState) != null && e.show && (this.formattingToolbarState.referencePos = this.getSelectionBoundingBox(), this.updateFormattingToolbar());
|
|
2152
2169
|
});
|
|
@@ -2159,12 +2176,12 @@ class io {
|
|
|
2159
2176
|
}, t.dom.addEventListener("mousedown", this.viewMousedownHandler), t.dom.addEventListener("mouseup", this.viewMouseupHandler), t.dom.addEventListener("dragstart", this.dragstartHandler), t.dom.addEventListener("focus", this.focusHandler), t.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
|
|
2160
2177
|
}
|
|
2161
2178
|
update(e, t) {
|
|
2162
|
-
var
|
|
2179
|
+
var u, f;
|
|
2163
2180
|
const { state: o, composing: r } = e, { doc: i, selection: s } = o, l = t && t.doc.eq(i) && t.selection.eq(s);
|
|
2164
2181
|
if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
|
|
2165
2182
|
return;
|
|
2166
2183
|
this.prevWasEditable = this.editor.isEditable;
|
|
2167
|
-
const { ranges: a } = s, d = Math.min(...a.map((m) => m.$from.pos)), c = Math.max(...a.map((m) => m.$to.pos)), h = (
|
|
2184
|
+
const { ranges: a } = s, d = Math.min(...a.map((m) => m.$from.pos)), c = Math.max(...a.map((m) => m.$to.pos)), h = (u = this.shouldShow) == null ? void 0 : u.call(this, {
|
|
2168
2185
|
view: e,
|
|
2169
2186
|
state: o,
|
|
2170
2187
|
from: d,
|
|
@@ -2201,8 +2218,8 @@ const so = new S(
|
|
|
2201
2218
|
class ao extends G {
|
|
2202
2219
|
constructor(t) {
|
|
2203
2220
|
super();
|
|
2204
|
-
|
|
2205
|
-
|
|
2221
|
+
p(this, "view");
|
|
2222
|
+
p(this, "plugin");
|
|
2206
2223
|
this.plugin = new w({
|
|
2207
2224
|
key: so,
|
|
2208
2225
|
view: (o) => (this.view = new io(t, o, (r) => {
|
|
@@ -2216,18 +2233,18 @@ class ao extends G {
|
|
|
2216
2233
|
}
|
|
2217
2234
|
class lo {
|
|
2218
2235
|
constructor(e, t, o) {
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2236
|
+
p(this, "hyperlinkToolbarState");
|
|
2237
|
+
p(this, "updateHyperlinkToolbar");
|
|
2238
|
+
p(this, "menuUpdateTimer");
|
|
2239
|
+
p(this, "startMenuUpdateTimer");
|
|
2240
|
+
p(this, "stopMenuUpdateTimer");
|
|
2241
|
+
p(this, "mouseHoveredHyperlinkMark");
|
|
2242
|
+
p(this, "mouseHoveredHyperlinkMarkRange");
|
|
2243
|
+
p(this, "keyboardHoveredHyperlinkMark");
|
|
2244
|
+
p(this, "keyboardHoveredHyperlinkMarkRange");
|
|
2245
|
+
p(this, "hyperlinkMark");
|
|
2246
|
+
p(this, "hyperlinkMarkRange");
|
|
2247
|
+
p(this, "mouseOverHandler", (e) => {
|
|
2231
2248
|
if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), e.target instanceof HTMLAnchorElement && e.target.nodeName === "A") {
|
|
2232
2249
|
const t = e.target, o = this.pmView.posAtDOM(t, 0) + 1, r = this.pmView.state.doc.resolve(
|
|
2233
2250
|
o
|
|
@@ -2244,7 +2261,7 @@ class lo {
|
|
|
2244
2261
|
}
|
|
2245
2262
|
return this.startMenuUpdateTimer(), !1;
|
|
2246
2263
|
});
|
|
2247
|
-
|
|
2264
|
+
p(this, "clickHandler", (e) => {
|
|
2248
2265
|
var o;
|
|
2249
2266
|
const t = this.pmView.dom.parentElement;
|
|
2250
2267
|
// Toolbar is open.
|
|
@@ -2252,7 +2269,7 @@ class lo {
|
|
|
2252
2269
|
e && e.target && // The clicked element is not the editor.
|
|
2253
2270
|
!(t === e.target || t.contains(e.target)) && (o = this.hyperlinkToolbarState) != null && o.show && (this.hyperlinkToolbarState.show = !1, this.updateHyperlinkToolbar());
|
|
2254
2271
|
});
|
|
2255
|
-
|
|
2272
|
+
p(this, "scrollHandler", () => {
|
|
2256
2273
|
var e;
|
|
2257
2274
|
this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos = q(
|
|
2258
2275
|
this.pmView,
|
|
@@ -2341,18 +2358,18 @@ const co = new S(
|
|
|
2341
2358
|
class uo extends G {
|
|
2342
2359
|
constructor(t) {
|
|
2343
2360
|
super();
|
|
2344
|
-
|
|
2345
|
-
|
|
2361
|
+
p(this, "view");
|
|
2362
|
+
p(this, "plugin");
|
|
2346
2363
|
/**
|
|
2347
2364
|
* Edit the currently hovered hyperlink.
|
|
2348
2365
|
*/
|
|
2349
|
-
|
|
2366
|
+
p(this, "editHyperlink", (t, o) => {
|
|
2350
2367
|
this.view.editHyperlink(t, o);
|
|
2351
2368
|
});
|
|
2352
2369
|
/**
|
|
2353
2370
|
* Delete the currently hovered hyperlink.
|
|
2354
2371
|
*/
|
|
2355
|
-
|
|
2372
|
+
p(this, "deleteHyperlink", () => {
|
|
2356
2373
|
this.view.deleteHyperlink();
|
|
2357
2374
|
});
|
|
2358
2375
|
/**
|
|
@@ -2361,7 +2378,7 @@ class uo extends G {
|
|
|
2361
2378
|
*
|
|
2362
2379
|
* This function starts the delay timer, and should be used for when the mouse cursor enters the hyperlink toolbar.
|
|
2363
2380
|
*/
|
|
2364
|
-
|
|
2381
|
+
p(this, "startHideTimer", () => {
|
|
2365
2382
|
this.view.startMenuUpdateTimer();
|
|
2366
2383
|
});
|
|
2367
2384
|
/**
|
|
@@ -2370,7 +2387,7 @@ class uo extends G {
|
|
|
2370
2387
|
*
|
|
2371
2388
|
* This function stops the delay timer, and should be used for when the mouse cursor exits the hyperlink toolbar.
|
|
2372
2389
|
*/
|
|
2373
|
-
|
|
2390
|
+
p(this, "stopHideTimer", () => {
|
|
2374
2391
|
this.view.stopMenuUpdateTimer();
|
|
2375
2392
|
});
|
|
2376
2393
|
this.plugin = new w({
|
|
@@ -2387,7 +2404,7 @@ class uo extends G {
|
|
|
2387
2404
|
class N extends j {
|
|
2388
2405
|
constructor(t, o) {
|
|
2389
2406
|
super(t, o);
|
|
2390
|
-
|
|
2407
|
+
p(this, "nodes");
|
|
2391
2408
|
const r = t.node();
|
|
2392
2409
|
this.nodes = [], t.doc.nodesBetween(t.pos, o.pos, (i, s, l) => {
|
|
2393
2410
|
if (l !== null && l.eq(r))
|
|
@@ -2491,26 +2508,26 @@ function mo(n, e) {
|
|
|
2491
2508
|
), at(e, l, a)) : (e.dispatch(
|
|
2492
2509
|
e.state.tr.setSelection(re.create(e.state.doc, r))
|
|
2493
2510
|
), at(e, r));
|
|
2494
|
-
const h = e.state.selection.content(), { dom:
|
|
2495
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html",
|
|
2511
|
+
const h = e.state.selection.content(), { dom: u, text: f } = po(e, h);
|
|
2512
|
+
n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", u.innerHTML), n.dataTransfer.setData("text/plain", f), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(B, 0, 0), e.dragging = { slice: h, move: !0 };
|
|
2496
2513
|
}
|
|
2497
2514
|
}
|
|
2498
2515
|
class ko {
|
|
2499
2516
|
constructor(e, t, o) {
|
|
2500
|
-
|
|
2517
|
+
p(this, "sideMenuState");
|
|
2501
2518
|
// When true, the drag handle with be anchored at the same level as root elements
|
|
2502
2519
|
// When false, the drag handle with be just to the left of the element
|
|
2503
2520
|
// TODO: Is there any case where we want this to be false?
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2521
|
+
p(this, "horizontalPosAnchoredAtRoot");
|
|
2522
|
+
p(this, "horizontalPosAnchor");
|
|
2523
|
+
p(this, "hoveredBlock");
|
|
2507
2524
|
// Used to check if currently dragged content comes from this editor instance.
|
|
2508
|
-
|
|
2509
|
-
|
|
2525
|
+
p(this, "isDragging", !1);
|
|
2526
|
+
p(this, "menuFrozen", !1);
|
|
2510
2527
|
/**
|
|
2511
2528
|
* Sets isDragging when dragging text.
|
|
2512
2529
|
*/
|
|
2513
|
-
|
|
2530
|
+
p(this, "onDragStart", () => {
|
|
2514
2531
|
this.isDragging = !0;
|
|
2515
2532
|
});
|
|
2516
2533
|
/**
|
|
@@ -2518,7 +2535,7 @@ class ko {
|
|
|
2518
2535
|
* we dispatch a fake event, so that we can still drop the content
|
|
2519
2536
|
* when dragging / dropping to the side of the editor
|
|
2520
2537
|
*/
|
|
2521
|
-
|
|
2538
|
+
p(this, "onDrop", (e) => {
|
|
2522
2539
|
if (this.editor._tiptapEditor.commands.blur(), e.synthetic || !this.isDragging)
|
|
2523
2540
|
return;
|
|
2524
2541
|
const t = this.pmView.posAtCoords({
|
|
@@ -2535,7 +2552,7 @@ class ko {
|
|
|
2535
2552
|
* we dispatch a fake event, so that we can still drop the content
|
|
2536
2553
|
* when dragging / dropping to the side of the editor
|
|
2537
2554
|
*/
|
|
2538
|
-
|
|
2555
|
+
p(this, "onDragOver", (e) => {
|
|
2539
2556
|
if (e.synthetic || !this.isDragging)
|
|
2540
2557
|
return;
|
|
2541
2558
|
const t = this.pmView.posAtCoords({
|
|
@@ -2547,12 +2564,12 @@ class ko {
|
|
|
2547
2564
|
o.clientX = r.left + r.width / 2, o.clientY = e.clientY, o.dataTransfer = e.dataTransfer, o.preventDefault = () => e.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
|
|
2548
2565
|
}
|
|
2549
2566
|
});
|
|
2550
|
-
|
|
2567
|
+
p(this, "onKeyDown", (e) => {
|
|
2551
2568
|
var t;
|
|
2552
2569
|
(t = this.sideMenuState) != null && t.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
|
|
2553
2570
|
});
|
|
2554
|
-
|
|
2555
|
-
var d, c, h,
|
|
2571
|
+
p(this, "onMouseMove", (e) => {
|
|
2572
|
+
var d, c, h, u, f;
|
|
2556
2573
|
if (this.menuFrozen)
|
|
2557
2574
|
return;
|
|
2558
2575
|
const t = this.pmView.dom.firstChild.getBoundingClientRect(), o = this.pmView.dom.getBoundingClientRect(), r = e.clientX >= o.left && e.clientX <= o.right && e.clientY >= o.top && e.clientY <= o.bottom, i = this.pmView.dom.parentElement;
|
|
@@ -2575,7 +2592,7 @@ class ko {
|
|
|
2575
2592
|
(c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
|
|
2576
2593
|
return;
|
|
2577
2594
|
}
|
|
2578
|
-
if ((h = this.sideMenuState) != null && h.show && ((
|
|
2595
|
+
if ((h = this.sideMenuState) != null && h.show && ((u = this.hoveredBlock) != null && u.hasAttribute("data-id")) && ((f = this.hoveredBlock) == null ? void 0 : f.getAttribute("data-id")) === l.id)
|
|
2579
2596
|
return;
|
|
2580
2597
|
this.hoveredBlock = l.node;
|
|
2581
2598
|
const a = l.node.firstChild;
|
|
@@ -2595,7 +2612,7 @@ class ko {
|
|
|
2595
2612
|
}, this.updateSideMenu(this.sideMenuState);
|
|
2596
2613
|
}
|
|
2597
2614
|
});
|
|
2598
|
-
|
|
2615
|
+
p(this, "onScroll", () => {
|
|
2599
2616
|
var e;
|
|
2600
2617
|
if ((e = this.sideMenuState) != null && e.show) {
|
|
2601
2618
|
const o = this.hoveredBlock.firstChild.getBoundingClientRect();
|
|
@@ -2647,35 +2664,35 @@ const go = new S("SideMenuPlugin");
|
|
|
2647
2664
|
class bo extends G {
|
|
2648
2665
|
constructor(t) {
|
|
2649
2666
|
super();
|
|
2650
|
-
|
|
2651
|
-
|
|
2667
|
+
p(this, "sideMenuView");
|
|
2668
|
+
p(this, "plugin");
|
|
2652
2669
|
/**
|
|
2653
2670
|
* If the block is empty, opens the slash menu. If the block has content,
|
|
2654
2671
|
* creates a new block below and opens the slash menu in it.
|
|
2655
2672
|
*/
|
|
2656
|
-
|
|
2673
|
+
p(this, "addBlock", () => this.sideMenuView.addBlock());
|
|
2657
2674
|
/**
|
|
2658
2675
|
* Handles drag & drop events for blocks.
|
|
2659
2676
|
*/
|
|
2660
|
-
|
|
2677
|
+
p(this, "blockDragStart", (t) => {
|
|
2661
2678
|
this.sideMenuView.isDragging = !0, mo(t, this.editor.prosemirrorView);
|
|
2662
2679
|
});
|
|
2663
2680
|
/**
|
|
2664
2681
|
* Handles drag & drop events for blocks.
|
|
2665
2682
|
*/
|
|
2666
|
-
|
|
2683
|
+
p(this, "blockDragEnd", () => Nt());
|
|
2667
2684
|
/**
|
|
2668
2685
|
* Freezes the side menu. When frozen, the side menu will stay
|
|
2669
2686
|
* attached to the same block regardless of which block is hovered by the
|
|
2670
2687
|
* mouse cursor.
|
|
2671
2688
|
*/
|
|
2672
|
-
|
|
2689
|
+
p(this, "freezeMenu", () => this.sideMenuView.menuFrozen = !0);
|
|
2673
2690
|
/**
|
|
2674
2691
|
* Unfreezes the side menu. When frozen, the side menu will stay
|
|
2675
2692
|
* attached to the same block regardless of which block is hovered by the
|
|
2676
2693
|
* mouse cursor.
|
|
2677
2694
|
*/
|
|
2678
|
-
|
|
2695
|
+
p(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
|
|
2679
2696
|
this.editor = t, this.plugin = new w({
|
|
2680
2697
|
key: go,
|
|
2681
2698
|
view: (o) => (this.sideMenuView = new ko(
|
|
@@ -2745,14 +2762,14 @@ const yo = (n = St) => {
|
|
|
2745
2762
|
};
|
|
2746
2763
|
class Qo {
|
|
2747
2764
|
constructor(e = {}) {
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2765
|
+
p(this, "_tiptapEditor");
|
|
2766
|
+
p(this, "blockCache", /* @__PURE__ */ new WeakMap());
|
|
2767
|
+
p(this, "schema");
|
|
2768
|
+
p(this, "ready", !1);
|
|
2769
|
+
p(this, "sideMenu");
|
|
2770
|
+
p(this, "formattingToolbar");
|
|
2771
|
+
p(this, "slashMenu");
|
|
2772
|
+
p(this, "hyperlinkToolbar");
|
|
2756
2773
|
var l, a, d, c, h;
|
|
2757
2774
|
this.options = e;
|
|
2758
2775
|
const t = {
|
|
@@ -2793,26 +2810,26 @@ class Qo {
|
|
|
2793
2810
|
...vo,
|
|
2794
2811
|
...t._tiptapOptions,
|
|
2795
2812
|
onCreate: () => {
|
|
2796
|
-
var
|
|
2797
|
-
(
|
|
2813
|
+
var u;
|
|
2814
|
+
(u = t.onEditorReady) == null || u.call(t, this), this.ready = !0;
|
|
2798
2815
|
},
|
|
2799
|
-
onBeforeCreate(
|
|
2816
|
+
onBeforeCreate(u) {
|
|
2800
2817
|
if (!i)
|
|
2801
2818
|
return;
|
|
2802
|
-
const f =
|
|
2819
|
+
const f = u.editor.schema, m = i.map((b) => D(b, f)), g = f.node(
|
|
2803
2820
|
"doc",
|
|
2804
2821
|
void 0,
|
|
2805
2822
|
f.node("blockGroup", void 0, m)
|
|
2806
2823
|
);
|
|
2807
|
-
|
|
2824
|
+
u.editor.options.content = g.toJSON();
|
|
2808
2825
|
},
|
|
2809
2826
|
onUpdate: () => {
|
|
2810
|
-
var
|
|
2811
|
-
this.ready && ((
|
|
2827
|
+
var u;
|
|
2828
|
+
this.ready && ((u = t.onEditorContentChange) == null || u.call(t, this));
|
|
2812
2829
|
},
|
|
2813
2830
|
onSelectionUpdate: () => {
|
|
2814
|
-
var
|
|
2815
|
-
this.ready && ((
|
|
2831
|
+
var u;
|
|
2832
|
+
this.ready && ((u = t.onTextCursorPositionChange) == null || u.call(t, this));
|
|
2816
2833
|
},
|
|
2817
2834
|
editable: e.editable === void 0 ? !0 : e.editable,
|
|
2818
2835
|
extensions: t.enableBlockNoteExtensions === !1 ? (l = t._tiptapOptions) == null ? void 0 : l.extensions : [...((a = t._tiptapOptions) == null ? void 0 : a.extensions) || [], ...o],
|