@notectl/core 0.0.10 → 0.0.11
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/README.md +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/notectl-core.js +4 -4
- package/dist/notectl-core.js.map +1 -1
- package/dist/notectl-core.mjs +216 -181
- package/dist/notectl-core.mjs.map +1 -1
- package/package.json +1 -1
package/dist/notectl-core.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (o, t, e) =>
|
|
1
|
+
var En = Object.defineProperty;
|
|
2
|
+
var Bn = (o, t, e) => t in o ? En(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var h = (o, t, e) => Bn(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import Mt from "dompurify";
|
|
5
5
|
function pe(o, t, e) {
|
|
6
|
-
const n =
|
|
6
|
+
const n = z(o), r = [];
|
|
7
7
|
let i = 0;
|
|
8
8
|
for (const s of n) {
|
|
9
9
|
const l = T(s) ? 1 : s.text.length, c = i + l;
|
|
@@ -35,10 +35,10 @@ function qe(o) {
|
|
|
35
35
|
function Mn(o) {
|
|
36
36
|
return o.children.filter((t) => D(t));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function z(o) {
|
|
39
39
|
return o.children.filter((t) => D(t) || T(t));
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function B(o) {
|
|
42
42
|
return o.children.filter((t) => L(t));
|
|
43
43
|
}
|
|
44
44
|
function J() {
|
|
@@ -46,10 +46,10 @@ function J() {
|
|
|
46
46
|
}
|
|
47
47
|
function Gt(o) {
|
|
48
48
|
return {
|
|
49
|
-
children: o ?? [
|
|
49
|
+
children: o ?? [R("paragraph")]
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function R(o, t, e, n) {
|
|
53
53
|
return {
|
|
54
54
|
id: e ?? J(),
|
|
55
55
|
type: o,
|
|
@@ -72,21 +72,21 @@ function Li(o, t) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
function It(o) {
|
|
75
|
-
const t =
|
|
75
|
+
const t = z(o);
|
|
76
76
|
let e = "";
|
|
77
77
|
for (const n of t)
|
|
78
78
|
D(n) && (e += n.text);
|
|
79
79
|
return e;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
const t =
|
|
81
|
+
function O(o) {
|
|
82
|
+
const t = z(o);
|
|
83
83
|
let e = 0;
|
|
84
84
|
for (const n of t)
|
|
85
85
|
e += T(n) ? 1 : n.text.length;
|
|
86
86
|
return e;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const e =
|
|
88
|
+
function N(o, t) {
|
|
89
|
+
const e = z(o);
|
|
90
90
|
let n = 0;
|
|
91
91
|
for (const r of e) {
|
|
92
92
|
if (T(r)) {
|
|
@@ -163,7 +163,7 @@ function* Nn(o) {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
function ct(o, t) {
|
|
166
|
-
const e =
|
|
166
|
+
const e = z(o);
|
|
167
167
|
for (const { child: n, from: r } of Nn(e)) {
|
|
168
168
|
if (T(n)) {
|
|
169
169
|
if (t === r) return { kind: "inline", node: n };
|
|
@@ -637,7 +637,7 @@ function je(o, t) {
|
|
|
637
637
|
}
|
|
638
638
|
function Un(o, t) {
|
|
639
639
|
return et(o, t.blockId, (e) => {
|
|
640
|
-
const n =
|
|
640
|
+
const n = z(e), r = t.segments ? Xn(n, t.offset, t.segments) : Qn(n, t.offset, t.text, t.marks);
|
|
641
641
|
return {
|
|
642
642
|
...e,
|
|
643
643
|
children: at(e.children, X(r))
|
|
@@ -646,7 +646,7 @@ function Un(o, t) {
|
|
|
646
646
|
}
|
|
647
647
|
function Dn(o, t) {
|
|
648
648
|
return et(o, t.blockId, (e) => {
|
|
649
|
-
const n =
|
|
649
|
+
const n = z(e), r = jn(
|
|
650
650
|
n,
|
|
651
651
|
t.from,
|
|
652
652
|
t.to
|
|
@@ -662,7 +662,7 @@ function Wn(o, t) {
|
|
|
662
662
|
if (e !== -1) {
|
|
663
663
|
const n = o.children[e];
|
|
664
664
|
if (!n) return o;
|
|
665
|
-
const r =
|
|
665
|
+
const r = z(n), i = O(n), s = zt(
|
|
666
666
|
r,
|
|
667
667
|
0,
|
|
668
668
|
t.offset
|
|
@@ -673,7 +673,7 @@ function Wn(o, t) {
|
|
|
673
673
|
), c = {
|
|
674
674
|
...n,
|
|
675
675
|
children: X(s)
|
|
676
|
-
}, a =
|
|
676
|
+
}, a = R(
|
|
677
677
|
n.type,
|
|
678
678
|
X(l),
|
|
679
679
|
t.newBlockId,
|
|
@@ -688,7 +688,7 @@ function Wn(o, t) {
|
|
|
688
688
|
function Ye(o, t) {
|
|
689
689
|
const e = o.children.findIndex((i) => L(i) && i.id === t.blockId);
|
|
690
690
|
if (e !== -1) {
|
|
691
|
-
const i = o.children[e], s =
|
|
691
|
+
const i = o.children[e], s = z(i), l = O(i), c = zt(
|
|
692
692
|
s,
|
|
693
693
|
0,
|
|
694
694
|
t.offset
|
|
@@ -699,7 +699,7 @@ function Ye(o, t) {
|
|
|
699
699
|
), d = {
|
|
700
700
|
...i,
|
|
701
701
|
children: X(c)
|
|
702
|
-
}, u =
|
|
702
|
+
}, u = R(
|
|
703
703
|
i.type,
|
|
704
704
|
X(a),
|
|
705
705
|
t.newBlockId,
|
|
@@ -720,7 +720,7 @@ function Pn(o, t) {
|
|
|
720
720
|
if (e !== -1 && n !== -1) {
|
|
721
721
|
const r = o.children[e], i = o.children[n];
|
|
722
722
|
if (!r || !i) return o;
|
|
723
|
-
const s =
|
|
723
|
+
const s = z(r), l = z(i), c = X([
|
|
724
724
|
...s,
|
|
725
725
|
...l
|
|
726
726
|
]), a = { ...r, children: c };
|
|
@@ -741,7 +741,7 @@ function _e(o, t) {
|
|
|
741
741
|
(s) => L(s) && s.id === t.sourceBlockId
|
|
742
742
|
);
|
|
743
743
|
if (e !== -1 && n !== -1) {
|
|
744
|
-
const s = o.children[e], l = o.children[n], c =
|
|
744
|
+
const s = o.children[e], l = o.children[n], c = z(s), a = z(l), d = X([
|
|
745
745
|
...c,
|
|
746
746
|
...a
|
|
747
747
|
]), u = { ...s, children: d }, p = o.children.filter(
|
|
@@ -761,7 +761,7 @@ function _e(o, t) {
|
|
|
761
761
|
}
|
|
762
762
|
function Hn(o, t) {
|
|
763
763
|
return et(o, t.blockId, (e) => {
|
|
764
|
-
const n =
|
|
764
|
+
const n = z(e), r = tn(
|
|
765
765
|
n,
|
|
766
766
|
t.from,
|
|
767
767
|
t.to,
|
|
@@ -776,7 +776,7 @@ function Hn(o, t) {
|
|
|
776
776
|
}
|
|
777
777
|
function qn(o, t) {
|
|
778
778
|
return et(o, t.blockId, (e) => {
|
|
779
|
-
const n =
|
|
779
|
+
const n = z(e), r = tn(
|
|
780
780
|
n,
|
|
781
781
|
t.from,
|
|
782
782
|
t.to,
|
|
@@ -791,7 +791,7 @@ function qn(o, t) {
|
|
|
791
791
|
}
|
|
792
792
|
function Zn(o, t) {
|
|
793
793
|
return et(o, t.blockId, (e) => {
|
|
794
|
-
const n =
|
|
794
|
+
const n = z(e), r = Yn(
|
|
795
795
|
n,
|
|
796
796
|
t.offset,
|
|
797
797
|
t.node
|
|
@@ -804,7 +804,7 @@ function Zn(o, t) {
|
|
|
804
804
|
}
|
|
805
805
|
function Jn(o, t) {
|
|
806
806
|
return et(o, t.blockId, (e) => {
|
|
807
|
-
const n =
|
|
807
|
+
const n = z(e), r = _n(
|
|
808
808
|
n,
|
|
809
809
|
t.offset
|
|
810
810
|
);
|
|
@@ -816,7 +816,7 @@ function Jn(o, t) {
|
|
|
816
816
|
}
|
|
817
817
|
function Gn(o, t) {
|
|
818
818
|
return et(o, t.blockId, (e) => {
|
|
819
|
-
const n =
|
|
819
|
+
const n = z(e), r = $n(
|
|
820
820
|
n,
|
|
821
821
|
t.offset,
|
|
822
822
|
t.attrs
|
|
@@ -1235,7 +1235,7 @@ class so {
|
|
|
1235
1235
|
const i = $(r, t);
|
|
1236
1236
|
if (!i)
|
|
1237
1237
|
throw new Error(`Block "${t}" not found in working document.`);
|
|
1238
|
-
const l = It(i).slice(e, n), c =
|
|
1238
|
+
const l = It(i).slice(e, n), c = N(i, e), a = pe(i, e, n);
|
|
1239
1239
|
return this.deleteText(t, e, n, l, c, a);
|
|
1240
1240
|
}
|
|
1241
1241
|
/** Adds a split-block step. Updates workingDoc if available. */
|
|
@@ -1266,7 +1266,7 @@ class so {
|
|
|
1266
1266
|
const r = $(n, t);
|
|
1267
1267
|
if (!r)
|
|
1268
1268
|
throw new Error(`Target block "${t}" not found in working document.`);
|
|
1269
|
-
const i =
|
|
1269
|
+
const i = O(r);
|
|
1270
1270
|
return this.mergeBlocks(t, e, i);
|
|
1271
1271
|
}
|
|
1272
1272
|
/** Adds an add-mark step. Updates workingDoc if available. */
|
|
@@ -1378,7 +1378,7 @@ class so {
|
|
|
1378
1378
|
const i = $(r, t);
|
|
1379
1379
|
if (!i)
|
|
1380
1380
|
throw new Error(`Block "${t}" not found in working document.`);
|
|
1381
|
-
const s =
|
|
1381
|
+
const s = z(i);
|
|
1382
1382
|
let l = 0;
|
|
1383
1383
|
for (const c of s) {
|
|
1384
1384
|
if (T(c) && l === e) {
|
|
@@ -1497,7 +1497,7 @@ class gt {
|
|
|
1497
1497
|
function we(o, t) {
|
|
1498
1498
|
const e = $(o, t.blockId);
|
|
1499
1499
|
if (e) {
|
|
1500
|
-
const r =
|
|
1500
|
+
const r = O(e);
|
|
1501
1501
|
return t.offset > r ? lt(t.blockId, r, t.path) : t;
|
|
1502
1502
|
}
|
|
1503
1503
|
const n = o.children[0];
|
|
@@ -1646,7 +1646,7 @@ function rt(o, t) {
|
|
|
1646
1646
|
return s.insertNode(
|
|
1647
1647
|
n,
|
|
1648
1648
|
0,
|
|
1649
|
-
|
|
1649
|
+
R(
|
|
1650
1650
|
"paragraph",
|
|
1651
1651
|
[x("")],
|
|
1652
1652
|
c
|
|
@@ -1658,7 +1658,7 @@ function rt(o, t) {
|
|
|
1658
1658
|
if (l && L(l)) {
|
|
1659
1659
|
const c = bo(l);
|
|
1660
1660
|
if (c) {
|
|
1661
|
-
const a = o.getBlock(c), d = a ?
|
|
1661
|
+
const a = o.getBlock(c), d = a ? O(a) : 0;
|
|
1662
1662
|
s.setSelection(A(c, d));
|
|
1663
1663
|
}
|
|
1664
1664
|
} else {
|
|
@@ -1701,7 +1701,7 @@ function mt(o, t, e = go) {
|
|
|
1701
1701
|
if (I(r)) {
|
|
1702
1702
|
const u = o.getBlock(r.anchor.blockId);
|
|
1703
1703
|
if (!u) return null;
|
|
1704
|
-
const f = o.storedMarks ??
|
|
1704
|
+
const f = o.storedMarks ?? N(u, r.anchor.offset), g = G(f, t) ? f.filter((k) => k.type !== t) : [...f, n];
|
|
1705
1705
|
return o.transaction("command").setStoredMarks(g, o.storedMarks).setSelection(r).build();
|
|
1706
1706
|
}
|
|
1707
1707
|
const i = o.getBlockOrder(), s = W(r, i), l = o.transaction("command"), c = i.indexOf(s.from.blockId), a = i.indexOf(s.to.blockId), d = on(o, t);
|
|
@@ -1710,7 +1710,7 @@ function mt(o, t, e = go) {
|
|
|
1710
1710
|
if (!f) continue;
|
|
1711
1711
|
const p = o.getBlock(f);
|
|
1712
1712
|
if (!p) continue;
|
|
1713
|
-
const g =
|
|
1713
|
+
const g = O(p), k = u === c ? s.from.offset : 0, m = u === a ? s.to.offset : g;
|
|
1714
1714
|
k !== m && (d ? l.removeMark(f, k, m, n) : l.addMark(f, k, m, n));
|
|
1715
1715
|
}
|
|
1716
1716
|
return l.setSelection(r), l.build();
|
|
@@ -1724,7 +1724,7 @@ function on(o, t) {
|
|
|
1724
1724
|
if (!c) continue;
|
|
1725
1725
|
const a = o.getBlock(c);
|
|
1726
1726
|
if (!a) continue;
|
|
1727
|
-
const d =
|
|
1727
|
+
const d = O(a), u = l === i ? r.from.offset : 0, f = l === s ? r.to.offset : d;
|
|
1728
1728
|
if (!ko(a, u, f, t)) return !1;
|
|
1729
1729
|
}
|
|
1730
1730
|
return !0;
|
|
@@ -1732,7 +1732,7 @@ function on(o, t) {
|
|
|
1732
1732
|
function ko(o, t, e, n) {
|
|
1733
1733
|
if (t === e) return !1;
|
|
1734
1734
|
let r = 0;
|
|
1735
|
-
for (const i of
|
|
1735
|
+
for (const i of z(o))
|
|
1736
1736
|
if (D(i)) {
|
|
1737
1737
|
const s = r + i.text.length;
|
|
1738
1738
|
if (s > t && r < e && !G(i.marks, n))
|
|
@@ -1754,7 +1754,7 @@ function Zi(o, t) {
|
|
|
1754
1754
|
function vt(o, t, e = "input") {
|
|
1755
1755
|
const n = o.selection;
|
|
1756
1756
|
if (b(n))
|
|
1757
|
-
return
|
|
1757
|
+
return Bo(o, n, t, e);
|
|
1758
1758
|
const r = o.transaction(e), i = So(o);
|
|
1759
1759
|
I(n) || te(o, r);
|
|
1760
1760
|
const s = I(n) ? null : W(n, o.getBlockOrder()), l = s ? s.from.blockId : n.anchor.blockId, c = s ? s.from.offset : n.anchor.offset;
|
|
@@ -1786,7 +1786,7 @@ function yo(o) {
|
|
|
1786
1786
|
return bt(o);
|
|
1787
1787
|
const e = o.getBlock(t.anchor.blockId);
|
|
1788
1788
|
if (!e) return null;
|
|
1789
|
-
const n =
|
|
1789
|
+
const n = O(e);
|
|
1790
1790
|
return t.anchor.offset < n ? o.transaction("input").deleteTextAt(e.id, t.anchor.offset, t.anchor.offset + 1).setSelection(A(e.id, t.anchor.offset)).build() : $t(o);
|
|
1791
1791
|
}
|
|
1792
1792
|
function wo(o) {
|
|
@@ -1810,7 +1810,7 @@ function Io(o) {
|
|
|
1810
1810
|
return bt(o);
|
|
1811
1811
|
const e = o.getBlock(t.anchor.blockId);
|
|
1812
1812
|
if (!e) return null;
|
|
1813
|
-
const n =
|
|
1813
|
+
const n = O(e);
|
|
1814
1814
|
if (t.anchor.offset === n)
|
|
1815
1815
|
return $t(o);
|
|
1816
1816
|
const r = Co(e, t.anchor.offset);
|
|
@@ -1833,13 +1833,13 @@ function Ao(o) {
|
|
|
1833
1833
|
return bt(o);
|
|
1834
1834
|
const e = o.getBlock(t.anchor.blockId);
|
|
1835
1835
|
if (!e) return null;
|
|
1836
|
-
const n =
|
|
1836
|
+
const n = O(e);
|
|
1837
1837
|
return t.anchor.offset === n ? $t(o) : o.transaction("input").deleteTextAt(e.id, t.anchor.offset, n).setSelection(A(e.id, t.anchor.offset)).build();
|
|
1838
1838
|
}
|
|
1839
1839
|
function rn(o) {
|
|
1840
1840
|
const t = o.selection;
|
|
1841
1841
|
if (b(t))
|
|
1842
|
-
return
|
|
1842
|
+
return Eo(o, t);
|
|
1843
1843
|
const e = o.transaction("input");
|
|
1844
1844
|
I(t) || te(o, e);
|
|
1845
1845
|
const n = I(t) ? t.anchor.blockId : W(t, o.getBlockOrder()).from.blockId, r = I(t) ? t.anchor.offset : W(t, o.getBlockOrder()).from.offset, i = J();
|
|
@@ -1888,7 +1888,7 @@ function _t(o) {
|
|
|
1888
1888
|
}
|
|
1889
1889
|
const i = o.getBlock(r);
|
|
1890
1890
|
if (!i) return null;
|
|
1891
|
-
const s =
|
|
1891
|
+
const s = O(i);
|
|
1892
1892
|
return o.transaction("input").mergeBlocksAt(r, t.anchor.blockId).setSelection(A(r, s)).build();
|
|
1893
1893
|
}
|
|
1894
1894
|
function $t(o) {
|
|
@@ -1909,7 +1909,7 @@ function cn(o) {
|
|
|
1909
1909
|
const t = o.doc.children, e = t[0], n = t[t.length - 1];
|
|
1910
1910
|
if (!e || !n)
|
|
1911
1911
|
return o.transaction("command").setSelection(o.selection).build();
|
|
1912
|
-
const r =
|
|
1912
|
+
const r = O(n);
|
|
1913
1913
|
return o.transaction("command").setSelection(
|
|
1914
1914
|
Yt(
|
|
1915
1915
|
{ blockId: e.id, offset: 0 },
|
|
@@ -1925,7 +1925,7 @@ function At(o, t) {
|
|
|
1925
1925
|
return G(o.storedMarks, t);
|
|
1926
1926
|
const n = o.getBlock(e.anchor.blockId);
|
|
1927
1927
|
if (!n) return !1;
|
|
1928
|
-
const r =
|
|
1928
|
+
const r = N(n, e.anchor.offset);
|
|
1929
1929
|
return G(r, t);
|
|
1930
1930
|
}
|
|
1931
1931
|
return on(o, t);
|
|
@@ -1934,7 +1934,7 @@ function So(o) {
|
|
|
1934
1934
|
if (o.storedMarks) return o.storedMarks;
|
|
1935
1935
|
if (b(o.selection)) return [];
|
|
1936
1936
|
const t = o.getBlock(o.selection.anchor.blockId);
|
|
1937
|
-
return t ?
|
|
1937
|
+
return t ? N(t, o.selection.anchor.offset) : [];
|
|
1938
1938
|
}
|
|
1939
1939
|
function te(o, t) {
|
|
1940
1940
|
if (b(o.selection)) return;
|
|
@@ -1944,14 +1944,14 @@ function te(o, t) {
|
|
|
1944
1944
|
else {
|
|
1945
1945
|
const s = o.getBlock(n.from.blockId);
|
|
1946
1946
|
if (!s) return;
|
|
1947
|
-
const l =
|
|
1947
|
+
const l = O(s);
|
|
1948
1948
|
n.from.offset < l && t.deleteTextAt(n.from.blockId, n.from.offset, l), n.to.offset > 0 && t.deleteTextAt(n.to.blockId, 0, n.to.offset);
|
|
1949
1949
|
for (let c = r + 1; c < i; c++) {
|
|
1950
1950
|
const a = e[c];
|
|
1951
1951
|
if (!a) continue;
|
|
1952
1952
|
const d = o.getBlock(a);
|
|
1953
1953
|
if (!d) continue;
|
|
1954
|
-
const u =
|
|
1954
|
+
const u = O(d);
|
|
1955
1955
|
u > 0 && t.deleteTextAt(a, 0, u), t.mergeBlocksAt(n.from.blockId, a);
|
|
1956
1956
|
}
|
|
1957
1957
|
t.mergeBlocksAt(n.from.blockId, n.to.blockId);
|
|
@@ -1976,7 +1976,7 @@ function xo(o, t) {
|
|
|
1976
1976
|
return e + 1;
|
|
1977
1977
|
}
|
|
1978
1978
|
function Co(o, t) {
|
|
1979
|
-
const e =
|
|
1979
|
+
const e = O(o);
|
|
1980
1980
|
let n = t;
|
|
1981
1981
|
for (; n < e; ) {
|
|
1982
1982
|
const r = ct(o, n);
|
|
@@ -1998,7 +1998,7 @@ function To(o, t) {
|
|
|
1998
1998
|
const e = o;
|
|
1999
1999
|
return e === "bold" ? !t.bold : e === "italic" ? !t.italic : e === "underline" ? !t.underline : !1;
|
|
2000
2000
|
}
|
|
2001
|
-
function
|
|
2001
|
+
function Eo(o, t) {
|
|
2002
2002
|
const e = Z(o.doc, t.nodeId);
|
|
2003
2003
|
if (!e) return null;
|
|
2004
2004
|
const n = e.length > 1 ? e.slice(0, -1) : [], i = (n.length === 0 ? o.doc.children : (() => {
|
|
@@ -2010,14 +2010,14 @@ function Bo(o, t) {
|
|
|
2010
2010
|
return l.insertNode(
|
|
2011
2011
|
n,
|
|
2012
2012
|
i + 1,
|
|
2013
|
-
|
|
2013
|
+
R(
|
|
2014
2014
|
"paragraph",
|
|
2015
2015
|
[x("")],
|
|
2016
2016
|
s
|
|
2017
2017
|
)
|
|
2018
2018
|
), l.setSelection(A(s, 0)), l.build();
|
|
2019
2019
|
}
|
|
2020
|
-
function
|
|
2020
|
+
function Bo(o, t, e, n) {
|
|
2021
2021
|
const r = Z(o.doc, t.nodeId), i = r && r.length > 1 ? r.slice(0, -1) : [], s = i.length === 0 ? o.doc.children : (() => {
|
|
2022
2022
|
const u = o.getBlock(i[i.length - 1]);
|
|
2023
2023
|
return u ? u.children : [];
|
|
@@ -2025,7 +2025,7 @@ function Eo(o, t, e, n) {
|
|
|
2025
2025
|
return a.insertNode(
|
|
2026
2026
|
i,
|
|
2027
2027
|
d,
|
|
2028
|
-
|
|
2028
|
+
R(
|
|
2029
2029
|
"paragraph",
|
|
2030
2030
|
[x("")],
|
|
2031
2031
|
c
|
|
@@ -2044,7 +2044,7 @@ function Dt(o, t) {
|
|
|
2044
2044
|
const u = Z(o.doc, c) ?? [];
|
|
2045
2045
|
return o.transaction("input").setSelection(_(c, u)).build();
|
|
2046
2046
|
}
|
|
2047
|
-
const a = o.getBlock(c), d = a ?
|
|
2047
|
+
const a = o.getBlock(c), d = a ? O(a) : 0;
|
|
2048
2048
|
return o.transaction("input").setSelection(A(c, d)).build();
|
|
2049
2049
|
}
|
|
2050
2050
|
return null;
|
|
@@ -2063,7 +2063,7 @@ function Dt(o, t) {
|
|
|
2063
2063
|
if (!I(e)) return null;
|
|
2064
2064
|
const r = n.indexOf(e.anchor.blockId), i = o.getBlock(e.anchor.blockId);
|
|
2065
2065
|
if (!i) return null;
|
|
2066
|
-
const s =
|
|
2066
|
+
const s = O(i);
|
|
2067
2067
|
if ((t === "right" || t === "down") && e.anchor.offset === s && r < n.length - 1) {
|
|
2068
2068
|
const l = n[r + 1];
|
|
2069
2069
|
if (l && pt(o, l)) {
|
|
@@ -3169,7 +3169,7 @@ const er = {
|
|
|
3169
3169
|
4: "h4",
|
|
3170
3170
|
5: "h5",
|
|
3171
3171
|
6: "h6"
|
|
3172
|
-
},
|
|
3172
|
+
}, Et = {
|
|
3173
3173
|
1: "Heading 1",
|
|
3174
3174
|
2: "Heading 2",
|
|
3175
3175
|
3: "Heading 3",
|
|
@@ -3201,6 +3201,7 @@ class ji {
|
|
|
3201
3201
|
type: "title",
|
|
3202
3202
|
group: "block",
|
|
3203
3203
|
content: { allow: ["text"] },
|
|
3204
|
+
excludeMarks: ["fontSize"],
|
|
3204
3205
|
toDOM(e) {
|
|
3205
3206
|
const n = ot("h1", e.id);
|
|
3206
3207
|
return n.classList.add("notectl-title"), n;
|
|
@@ -3213,6 +3214,7 @@ class ji {
|
|
|
3213
3214
|
type: "subtitle",
|
|
3214
3215
|
group: "block",
|
|
3215
3216
|
content: { allow: ["text"] },
|
|
3217
|
+
excludeMarks: ["fontSize"],
|
|
3216
3218
|
toDOM(e) {
|
|
3217
3219
|
const n = ot("h2", e.id);
|
|
3218
3220
|
return n.classList.add("notectl-subtitle"), n;
|
|
@@ -3225,6 +3227,7 @@ class ji {
|
|
|
3225
3227
|
type: "heading",
|
|
3226
3228
|
group: "block",
|
|
3227
3229
|
content: { allow: ["text"] },
|
|
3230
|
+
excludeMarks: ["fontSize"],
|
|
3228
3231
|
attrs: {
|
|
3229
3232
|
level: { default: 1 }
|
|
3230
3233
|
},
|
|
@@ -3315,7 +3318,7 @@ class ji {
|
|
|
3315
3318
|
if (e.type === "subtitle") return Te;
|
|
3316
3319
|
if (e.type === "heading") {
|
|
3317
3320
|
const r = (n = e.attrs) == null ? void 0 : n.level;
|
|
3318
|
-
return r ?
|
|
3321
|
+
return r ? Et[r] ?? Et[1] : Et[1];
|
|
3319
3322
|
}
|
|
3320
3323
|
return wt;
|
|
3321
3324
|
}
|
|
@@ -3352,7 +3355,7 @@ class ji {
|
|
|
3352
3355
|
fontWeight: "500"
|
|
3353
3356
|
});
|
|
3354
3357
|
for (const d of this.config.levels)
|
|
3355
|
-
c(
|
|
3358
|
+
c(Et[d], s === d, `setHeading${d}`, {
|
|
3356
3359
|
fontSize: `${1.4 - d * 0.1}em`,
|
|
3357
3360
|
fontWeight: "600"
|
|
3358
3361
|
});
|
|
@@ -3390,8 +3393,40 @@ class ji {
|
|
|
3390
3393
|
setBlockType(t, e, n) {
|
|
3391
3394
|
const r = t.getState(), i = r.selection;
|
|
3392
3395
|
if (b(i)) return !1;
|
|
3393
|
-
const s = r.
|
|
3394
|
-
|
|
3396
|
+
const s = r.getBlock(i.anchor.blockId);
|
|
3397
|
+
if (!s) return !1;
|
|
3398
|
+
const l = r.transaction("command"), c = t.getSchemaRegistry().getNodeSpec(e);
|
|
3399
|
+
c != null && c.excludeMarks && c.excludeMarks.length > 0 && (this.stripExcludedMarks(l, s, c.excludeMarks), this.clearExcludedStoredMarks(l, r, c.excludeMarks));
|
|
3400
|
+
const a = l.setBlockType(i.anchor.blockId, e, n).setSelection(i).build();
|
|
3401
|
+
return t.dispatch(a), !0;
|
|
3402
|
+
}
|
|
3403
|
+
/**
|
|
3404
|
+
* Adds removeMark steps for each excluded mark type found
|
|
3405
|
+
* on the block's inline text content.
|
|
3406
|
+
*/
|
|
3407
|
+
stripExcludedMarks(t, e, n) {
|
|
3408
|
+
if (O(e) === 0) return;
|
|
3409
|
+
const i = new Set(n), s = z(e);
|
|
3410
|
+
let l = 0;
|
|
3411
|
+
for (const c of s)
|
|
3412
|
+
if (D(c)) {
|
|
3413
|
+
if (c.text.length > 0)
|
|
3414
|
+
for (const a of c.marks)
|
|
3415
|
+
i.has(a.type) && t.removeMark(e.id, l, l + c.text.length, a);
|
|
3416
|
+
l += c.text.length;
|
|
3417
|
+
} else
|
|
3418
|
+
l += 1;
|
|
3419
|
+
}
|
|
3420
|
+
/**
|
|
3421
|
+
* Clears excluded mark types from stored marks so that
|
|
3422
|
+
* subsequent typing does not reintroduce them.
|
|
3423
|
+
*/
|
|
3424
|
+
clearExcludedStoredMarks(t, e, n) {
|
|
3425
|
+
if (!e.storedMarks) return;
|
|
3426
|
+
const r = new Set(n), i = e.storedMarks.filter(
|
|
3427
|
+
(s) => !r.has(s.type)
|
|
3428
|
+
);
|
|
3429
|
+
i.length !== e.storedMarks.length && t.setStoredMarks(i.length > 0 ? i : null, e.storedMarks);
|
|
3395
3430
|
}
|
|
3396
3431
|
}
|
|
3397
3432
|
const nr = {
|
|
@@ -3472,12 +3507,12 @@ class Yi {
|
|
|
3472
3507
|
if (I(e)) {
|
|
3473
3508
|
const i = t.getBlock(e.anchor.blockId);
|
|
3474
3509
|
if (!i) return !1;
|
|
3475
|
-
const s =
|
|
3510
|
+
const s = N(i, e.anchor.offset);
|
|
3476
3511
|
return G(s, "link");
|
|
3477
3512
|
}
|
|
3478
3513
|
const n = t.getBlock(e.anchor.blockId);
|
|
3479
3514
|
if (!n) return !1;
|
|
3480
|
-
const r =
|
|
3515
|
+
const r = N(n, e.anchor.offset);
|
|
3481
3516
|
return G(r, "link");
|
|
3482
3517
|
}
|
|
3483
3518
|
toggleLink(t, e) {
|
|
@@ -4081,12 +4116,12 @@ class es {
|
|
|
4081
4116
|
}
|
|
4082
4117
|
const s = t.getBlock(e.anchor.blockId);
|
|
4083
4118
|
if (!s) return null;
|
|
4084
|
-
const c =
|
|
4119
|
+
const c = N(s, e.anchor.offset).find((a) => a.type === "textColor");
|
|
4085
4120
|
return c && Q(c, "textColor") ? c.attrs.color ?? null : null;
|
|
4086
4121
|
}
|
|
4087
4122
|
const n = t.getBlock(e.anchor.blockId);
|
|
4088
4123
|
if (!n) return null;
|
|
4089
|
-
const i =
|
|
4124
|
+
const i = N(n, e.anchor.offset).find((s) => s.type === "textColor");
|
|
4090
4125
|
return i && Q(i, "textColor") ? i.attrs.color ?? null : null;
|
|
4091
4126
|
}
|
|
4092
4127
|
// --- Color Application ---
|
|
@@ -4096,7 +4131,7 @@ class es {
|
|
|
4096
4131
|
if (I(r)) {
|
|
4097
4132
|
const u = e.getBlock(r.anchor.blockId);
|
|
4098
4133
|
if (!u) return !1;
|
|
4099
|
-
const g = [...(e.storedMarks ??
|
|
4134
|
+
const g = [...(e.storedMarks ?? N(u, r.anchor.offset)).filter((m) => m.type !== "textColor"), { type: "textColor", attrs: { color: n } }], k = e.transaction("command").setStoredMarks(g, e.storedMarks).setSelection(r).build();
|
|
4100
4135
|
return t.dispatch(k), !0;
|
|
4101
4136
|
}
|
|
4102
4137
|
const i = e.getBlockOrder(), s = W(r, i), l = e.transaction("command"), c = i.indexOf(s.from.blockId), a = i.indexOf(s.to.blockId), d = { type: "textColor", attrs: { color: n } };
|
|
@@ -4119,7 +4154,7 @@ class es {
|
|
|
4119
4154
|
if (I(n)) {
|
|
4120
4155
|
const a = e.getBlock(n.anchor.blockId);
|
|
4121
4156
|
if (!a) return !1;
|
|
4122
|
-
const d = e.storedMarks ??
|
|
4157
|
+
const d = e.storedMarks ?? N(a, n.anchor.offset);
|
|
4123
4158
|
if (!G(d, "textColor")) return !1;
|
|
4124
4159
|
const u = d.filter((p) => p.type !== "textColor"), f = e.transaction("command").setStoredMarks(u, e.storedMarks).setSelection(n).build();
|
|
4125
4160
|
return t.dispatch(f), !0;
|
|
@@ -4196,7 +4231,7 @@ class ns {
|
|
|
4196
4231
|
if (!l || l.type !== "paragraph") return null;
|
|
4197
4232
|
const c = e.doc.children.findIndex((d) => d.id === s.anchor.blockId);
|
|
4198
4233
|
if (c === -1) return null;
|
|
4199
|
-
const a =
|
|
4234
|
+
const a = R("paragraph");
|
|
4200
4235
|
return e.transaction("input").deleteTextAt(s.anchor.blockId, 0, i).setBlockType(s.anchor.blockId, "horizontal_rule").insertNode([], c + 1, a).setSelection(A(a.id, 0)).build();
|
|
4201
4236
|
}
|
|
4202
4237
|
});
|
|
@@ -4222,7 +4257,7 @@ class ns {
|
|
|
4222
4257
|
if (b(n) || !e.getBlock(n.anchor.blockId)) return !1;
|
|
4223
4258
|
const i = e.doc.children.findIndex((a) => a.id === n.anchor.blockId);
|
|
4224
4259
|
if (i === -1) return !1;
|
|
4225
|
-
const s =
|
|
4260
|
+
const s = R("horizontal_rule"), l = R("paragraph"), c = e.transaction("command").insertNode([], i + 1, s).insertNode([], i + 2, l).setSelection(A(l.id, 0)).build();
|
|
4226
4261
|
return t.dispatch(c), !0;
|
|
4227
4262
|
}
|
|
4228
4263
|
}
|
|
@@ -4234,7 +4269,7 @@ const mr = {
|
|
|
4234
4269
|
center: "Align Center",
|
|
4235
4270
|
right: "Align Right",
|
|
4236
4271
|
justify: "Justify"
|
|
4237
|
-
},
|
|
4272
|
+
}, Ee = {
|
|
4238
4273
|
left: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"/></svg>',
|
|
4239
4274
|
center: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/></svg>',
|
|
4240
4275
|
right: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/></svg>',
|
|
@@ -4279,7 +4314,7 @@ class os {
|
|
|
4279
4314
|
// --- Commands ---
|
|
4280
4315
|
registerCommands(t) {
|
|
4281
4316
|
for (const e of this.config.alignments)
|
|
4282
|
-
t.registerCommand(`align${
|
|
4317
|
+
t.registerCommand(`align${Be(e)}`, () => this.setAlignment(t, e));
|
|
4283
4318
|
}
|
|
4284
4319
|
// --- Keymaps ---
|
|
4285
4320
|
registerKeymaps(t) {
|
|
@@ -4290,13 +4325,13 @@ class os {
|
|
|
4290
4325
|
registerToolbarItem(t) {
|
|
4291
4326
|
const e = this.config.alignments.map((n) => ({
|
|
4292
4327
|
label: br[n],
|
|
4293
|
-
command: `align${
|
|
4294
|
-
icon:
|
|
4328
|
+
command: `align${Be(n)}`,
|
|
4329
|
+
icon: Ee[n]
|
|
4295
4330
|
}));
|
|
4296
4331
|
t.registerToolbarItem({
|
|
4297
4332
|
id: "text-alignment",
|
|
4298
4333
|
group: "block",
|
|
4299
|
-
icon:
|
|
4334
|
+
icon: Ee.left,
|
|
4300
4335
|
label: "Text Alignment",
|
|
4301
4336
|
tooltip: "Text Alignment",
|
|
4302
4337
|
command: "alignLeft",
|
|
@@ -4356,7 +4391,7 @@ function kr(o, t) {
|
|
|
4356
4391
|
const e = (n = t.attrs) == null ? void 0 : n.textAlign;
|
|
4357
4392
|
typeof e == "string" && e !== "left" && (o.style.textAlign = e);
|
|
4358
4393
|
}
|
|
4359
|
-
function
|
|
4394
|
+
function Be(o) {
|
|
4360
4395
|
return o.charAt(0).toUpperCase() + o.slice(1);
|
|
4361
4396
|
}
|
|
4362
4397
|
class rs {
|
|
@@ -4475,12 +4510,12 @@ class rs {
|
|
|
4475
4510
|
}
|
|
4476
4511
|
const s = t.getBlock(e.anchor.blockId);
|
|
4477
4512
|
if (!s) return null;
|
|
4478
|
-
const c =
|
|
4513
|
+
const c = N(s, e.anchor.offset).find((a) => a.type === "font");
|
|
4479
4514
|
return c && Q(c, "font") ? c.attrs.family ?? null : null;
|
|
4480
4515
|
}
|
|
4481
4516
|
const n = t.getBlock(e.anchor.blockId);
|
|
4482
4517
|
if (!n) return null;
|
|
4483
|
-
const i =
|
|
4518
|
+
const i = N(n, e.anchor.offset).find((s) => s.type === "font");
|
|
4484
4519
|
return i && Q(i, "font") ? i.attrs.family ?? null : null;
|
|
4485
4520
|
}
|
|
4486
4521
|
// --- Font Application ---
|
|
@@ -4490,7 +4525,7 @@ class rs {
|
|
|
4490
4525
|
if (I(r)) {
|
|
4491
4526
|
const u = e.getBlock(r.anchor.blockId);
|
|
4492
4527
|
if (!u) return !1;
|
|
4493
|
-
const g = [...(e.storedMarks ??
|
|
4528
|
+
const g = [...(e.storedMarks ?? N(u, r.anchor.offset)).filter((m) => m.type !== "font"), { type: "font", attrs: { family: n } }], k = e.transaction("command").setStoredMarks(g, e.storedMarks).setSelection(r).build();
|
|
4494
4529
|
return t.dispatch(k), !0;
|
|
4495
4530
|
}
|
|
4496
4531
|
const i = e.getBlockOrder(), s = W(r, i), l = e.transaction("command"), c = i.indexOf(s.from.blockId), a = i.indexOf(s.to.blockId), d = { type: "font", attrs: { family: n } };
|
|
@@ -4516,7 +4551,7 @@ class rs {
|
|
|
4516
4551
|
if (I(n)) {
|
|
4517
4552
|
const a = e.getBlock(n.anchor.blockId);
|
|
4518
4553
|
if (!a) return !1;
|
|
4519
|
-
const d = e.storedMarks ??
|
|
4554
|
+
const d = e.storedMarks ?? N(a, n.anchor.offset);
|
|
4520
4555
|
if (!G(d, "font")) return !1;
|
|
4521
4556
|
const u = d.filter((p) => p.type !== "font"), f = e.transaction("command").setStoredMarks(u, e.storedMarks).setSelection(n).build();
|
|
4522
4557
|
return t.dispatch(f), !0;
|
|
@@ -4749,12 +4784,12 @@ class is {
|
|
|
4749
4784
|
}
|
|
4750
4785
|
const s = t.getBlock(e.anchor.blockId);
|
|
4751
4786
|
if (!s) return null;
|
|
4752
|
-
const c =
|
|
4787
|
+
const c = N(s, e.anchor.offset).find((a) => a.type === "fontSize");
|
|
4753
4788
|
return c && Q(c, "fontSize") ? c.attrs.size ?? null : null;
|
|
4754
4789
|
}
|
|
4755
4790
|
const n = t.getBlock(e.anchor.blockId);
|
|
4756
4791
|
if (!n) return null;
|
|
4757
|
-
const i =
|
|
4792
|
+
const i = N(n, e.anchor.offset).find((s) => s.type === "fontSize");
|
|
4758
4793
|
return i && Q(i, "fontSize") ? i.attrs.size ?? null : null;
|
|
4759
4794
|
}
|
|
4760
4795
|
getActiveSizeNumeric(t) {
|
|
@@ -4770,7 +4805,7 @@ class is {
|
|
|
4770
4805
|
if (I(r)) {
|
|
4771
4806
|
const u = e.getBlock(r.anchor.blockId);
|
|
4772
4807
|
if (!u) return !1;
|
|
4773
|
-
const g = [...(e.storedMarks ??
|
|
4808
|
+
const g = [...(e.storedMarks ?? N(u, r.anchor.offset)).filter((m) => m.type !== "fontSize"), { type: "fontSize", attrs: { size: n } }], k = e.transaction("command").setStoredMarks(g, e.storedMarks).setSelection(r).build();
|
|
4774
4809
|
return t.dispatch(k), !0;
|
|
4775
4810
|
}
|
|
4776
4811
|
const i = e.getBlockOrder(), s = W(r, i), l = e.transaction("command"), c = i.indexOf(s.from.blockId), a = i.indexOf(s.to.blockId), d = { type: "fontSize", attrs: { size: n } };
|
|
@@ -4795,7 +4830,7 @@ class is {
|
|
|
4795
4830
|
if (I(n)) {
|
|
4796
4831
|
const a = e.getBlock(n.anchor.blockId);
|
|
4797
4832
|
if (!a) return !1;
|
|
4798
|
-
const d = e.storedMarks ??
|
|
4833
|
+
const d = e.storedMarks ?? N(a, n.anchor.offset);
|
|
4799
4834
|
if (!G(d, "fontSize")) return !1;
|
|
4800
4835
|
const u = d.filter((p) => p.type !== "fontSize"), f = e.transaction("command").setStoredMarks(u, e.storedMarks).setSelection(n).build();
|
|
4801
4836
|
return t.dispatch(f), !0;
|
|
@@ -4937,38 +4972,38 @@ function Cr(o, t) {
|
|
|
4937
4972
|
const i = [];
|
|
4938
4973
|
for (let s = 0; s < t; s++)
|
|
4939
4974
|
i.push(
|
|
4940
|
-
|
|
4975
|
+
R(
|
|
4941
4976
|
"table_cell",
|
|
4942
4977
|
[x("")],
|
|
4943
4978
|
J()
|
|
4944
4979
|
)
|
|
4945
4980
|
);
|
|
4946
4981
|
n.push(
|
|
4947
|
-
|
|
4982
|
+
R("table_row", i, J())
|
|
4948
4983
|
);
|
|
4949
4984
|
}
|
|
4950
|
-
return
|
|
4985
|
+
return R("table", n, e);
|
|
4951
4986
|
}
|
|
4952
4987
|
function ne(o) {
|
|
4953
4988
|
const t = [];
|
|
4954
4989
|
for (let e = 0; e < o; e++)
|
|
4955
4990
|
t.push(
|
|
4956
|
-
|
|
4991
|
+
R(
|
|
4957
4992
|
"table_cell",
|
|
4958
4993
|
[x("")],
|
|
4959
4994
|
J()
|
|
4960
4995
|
)
|
|
4961
4996
|
);
|
|
4962
|
-
return
|
|
4997
|
+
return R("table_row", t, J());
|
|
4963
4998
|
}
|
|
4964
4999
|
function un() {
|
|
4965
|
-
return
|
|
5000
|
+
return R(
|
|
4966
5001
|
"table_cell",
|
|
4967
5002
|
[x("")],
|
|
4968
5003
|
J()
|
|
4969
5004
|
);
|
|
4970
5005
|
}
|
|
4971
|
-
function
|
|
5006
|
+
function U(o, t) {
|
|
4972
5007
|
const e = o.getNodePath(t);
|
|
4973
5008
|
if (!e) return null;
|
|
4974
5009
|
let n = null, r = null;
|
|
@@ -4988,11 +5023,11 @@ function R(o, t) {
|
|
|
4988
5023
|
}
|
|
4989
5024
|
const c = o.getBlock(t);
|
|
4990
5025
|
if ((c == null ? void 0 : c.type) === "table_cell" && (s = t), !s || !l) return null;
|
|
4991
|
-
const a =
|
|
5026
|
+
const a = B(r), d = a.findIndex((m) => m.id === l);
|
|
4992
5027
|
if (d === -1) return null;
|
|
4993
5028
|
const u = a[d];
|
|
4994
5029
|
if (!u) return null;
|
|
4995
|
-
const f =
|
|
5030
|
+
const f = B(u), p = f.findIndex((m) => m.id === s);
|
|
4996
5031
|
if (p === -1) return null;
|
|
4997
5032
|
const g = f.length, k = a.length;
|
|
4998
5033
|
return {
|
|
@@ -5009,9 +5044,9 @@ function R(o, t) {
|
|
|
5009
5044
|
function dt(o, t, e, n) {
|
|
5010
5045
|
const r = o.getBlock(t);
|
|
5011
5046
|
if (!r) return null;
|
|
5012
|
-
const s =
|
|
5047
|
+
const s = B(r)[e];
|
|
5013
5048
|
if (!s) return null;
|
|
5014
|
-
const c =
|
|
5049
|
+
const c = B(s)[n];
|
|
5015
5050
|
return (c == null ? void 0 : c.id) ?? null;
|
|
5016
5051
|
}
|
|
5017
5052
|
function Fe(o, t) {
|
|
@@ -5042,39 +5077,39 @@ function fn(o, t, e) {
|
|
|
5042
5077
|
}
|
|
5043
5078
|
}
|
|
5044
5079
|
s === -1 && (s = n.doc.children.length - 1);
|
|
5045
|
-
const l = Cr(t, e), c =
|
|
5080
|
+
const l = Cr(t, e), c = R("paragraph"), a = s + 1, d = n.transaction("command").insertNode([], a, l).insertNode([], a + 1, c), u = B(l)[0], f = u ? B(u)[0] : void 0;
|
|
5046
5081
|
return f && d.setSelection(A(f.id, 0)), o.dispatch(d.build()), !0;
|
|
5047
5082
|
}
|
|
5048
5083
|
function Tr(o) {
|
|
5049
5084
|
const t = o.getState();
|
|
5050
5085
|
if (b(t.selection)) return !1;
|
|
5051
|
-
const e =
|
|
5086
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5052
5087
|
if (!e || !t.getBlock(e.tableId)) return !1;
|
|
5053
|
-
const r = ne(e.totalCols), i = t.transaction("command").insertNode([e.tableId], e.rowIndex, r), s =
|
|
5088
|
+
const r = ne(e.totalCols), i = t.transaction("command").insertNode([e.tableId], e.rowIndex, r), s = B(r)[0];
|
|
5054
5089
|
return s && i.setSelection(A(s.id, 0)), o.dispatch(i.build()), !0;
|
|
5055
5090
|
}
|
|
5056
5091
|
function hn(o) {
|
|
5057
5092
|
const t = o.getState();
|
|
5058
5093
|
if (b(t.selection)) return !1;
|
|
5059
|
-
const e =
|
|
5094
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5060
5095
|
if (!e) return !1;
|
|
5061
|
-
const n = ne(e.totalCols), r = t.transaction("command").insertNode([e.tableId], e.rowIndex + 1, n), i =
|
|
5096
|
+
const n = ne(e.totalCols), r = t.transaction("command").insertNode([e.tableId], e.rowIndex + 1, n), i = B(n)[0];
|
|
5062
5097
|
return i && r.setSelection(A(i.id, 0)), o.dispatch(r.build()), !0;
|
|
5063
5098
|
}
|
|
5064
|
-
function
|
|
5099
|
+
function Er(o) {
|
|
5065
5100
|
return pn(o, "left");
|
|
5066
5101
|
}
|
|
5067
|
-
function
|
|
5102
|
+
function Br(o) {
|
|
5068
5103
|
return pn(o, "right");
|
|
5069
5104
|
}
|
|
5070
5105
|
function pn(o, t) {
|
|
5071
5106
|
const e = o.getState();
|
|
5072
5107
|
if (b(e.selection)) return !1;
|
|
5073
|
-
const n =
|
|
5108
|
+
const n = U(e, e.selection.anchor.blockId);
|
|
5074
5109
|
if (!n) return !1;
|
|
5075
5110
|
const r = e.getBlock(n.tableId);
|
|
5076
5111
|
if (!r) return !1;
|
|
5077
|
-
const i =
|
|
5112
|
+
const i = B(r), s = t === "left" ? n.colIndex : n.colIndex + 1, l = e.transaction("command");
|
|
5078
5113
|
for (const c of i) {
|
|
5079
5114
|
const a = un();
|
|
5080
5115
|
l.insertNode([n.tableId, c.id], s, a);
|
|
@@ -5084,7 +5119,7 @@ function pn(o, t) {
|
|
|
5084
5119
|
function Mr(o) {
|
|
5085
5120
|
const t = o.getState();
|
|
5086
5121
|
if (b(t.selection)) return !1;
|
|
5087
|
-
const e =
|
|
5122
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5088
5123
|
if (!e) return !1;
|
|
5089
5124
|
if (e.totalRows <= 1)
|
|
5090
5125
|
return oe(o);
|
|
@@ -5099,13 +5134,13 @@ function Mr(o) {
|
|
|
5099
5134
|
function Lr(o) {
|
|
5100
5135
|
const t = o.getState();
|
|
5101
5136
|
if (b(t.selection)) return !1;
|
|
5102
|
-
const e =
|
|
5137
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5103
5138
|
if (!e) return !1;
|
|
5104
5139
|
if (e.totalCols <= 1)
|
|
5105
5140
|
return oe(o);
|
|
5106
5141
|
const n = t.getBlock(e.tableId);
|
|
5107
5142
|
if (!n) return !1;
|
|
5108
|
-
const r =
|
|
5143
|
+
const r = B(n), i = t.transaction("command");
|
|
5109
5144
|
for (let c = r.length - 1; c >= 0; c--) {
|
|
5110
5145
|
const a = r[c];
|
|
5111
5146
|
a && i.removeNode([e.tableId, a.id], e.colIndex);
|
|
@@ -5130,7 +5165,7 @@ function zr(o) {
|
|
|
5130
5165
|
const s = t.getBlock(e.nodeId);
|
|
5131
5166
|
return (s == null ? void 0 : s.type) === "table";
|
|
5132
5167
|
}
|
|
5133
|
-
const n =
|
|
5168
|
+
const n = U(t, e.anchor.blockId);
|
|
5134
5169
|
if (!n) return !1;
|
|
5135
5170
|
const r = t.getNodePath(n.tableId);
|
|
5136
5171
|
if (!r) return !1;
|
|
@@ -5138,7 +5173,7 @@ function zr(o) {
|
|
|
5138
5173
|
return o.dispatch(i), !0;
|
|
5139
5174
|
}
|
|
5140
5175
|
function Nr(o) {
|
|
5141
|
-
o.registerCommand("insertTable", () => fn(o, 3, 3)), o.registerCommand("addRowAbove", () => Tr(o)), o.registerCommand("addRowBelow", () => hn(o)), o.registerCommand("addColumnLeft", () =>
|
|
5176
|
+
o.registerCommand("insertTable", () => fn(o, 3, 3)), o.registerCommand("addRowAbove", () => Tr(o)), o.registerCommand("addRowBelow", () => hn(o)), o.registerCommand("addColumnLeft", () => Er(o)), o.registerCommand("addColumnRight", () => Br(o)), o.registerCommand("deleteRow", () => Mr(o)), o.registerCommand("deleteColumn", () => Lr(o)), o.registerCommand("selectTable", () => zr(o)), o.registerCommand("deleteTable", () => oe(o));
|
|
5142
5177
|
}
|
|
5143
5178
|
function gn(o, t) {
|
|
5144
5179
|
const e = o.doc.children.findIndex((s) => s.id === t);
|
|
@@ -5154,7 +5189,7 @@ function Fr(o) {
|
|
|
5154
5189
|
const e = o.getBlock(o.selection.nodeId);
|
|
5155
5190
|
return (e == null ? void 0 : e.type) !== "table" ? null : { tableId: e.id };
|
|
5156
5191
|
}
|
|
5157
|
-
const t =
|
|
5192
|
+
const t = U(o, o.selection.anchor.blockId);
|
|
5158
5193
|
return t ? { tableId: t.tableId } : null;
|
|
5159
5194
|
}
|
|
5160
5195
|
function Vr(o) {
|
|
@@ -5175,13 +5210,13 @@ function Vr(o) {
|
|
|
5175
5210
|
function Kr(o) {
|
|
5176
5211
|
const t = o.getState();
|
|
5177
5212
|
if (b(t.selection)) return !1;
|
|
5178
|
-
const e =
|
|
5213
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5179
5214
|
return e ? e.colIndex < e.totalCols - 1 ? tt(o, e.tableId, e.rowIndex, e.colIndex + 1) : e.rowIndex < e.totalRows - 1 ? tt(o, e.tableId, e.rowIndex + 1, 0) : (hn(o), !0) : !1;
|
|
5180
5215
|
}
|
|
5181
5216
|
function Or(o) {
|
|
5182
5217
|
const t = o.getState();
|
|
5183
5218
|
if (b(t.selection)) return !1;
|
|
5184
|
-
const e =
|
|
5219
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5185
5220
|
return e ? e.colIndex > 0 ? tt(o, e.tableId, e.rowIndex, e.colIndex - 1) : e.rowIndex > 0 ? tt(
|
|
5186
5221
|
o,
|
|
5187
5222
|
e.tableId,
|
|
@@ -5192,13 +5227,13 @@ function Or(o) {
|
|
|
5192
5227
|
function Rr(o) {
|
|
5193
5228
|
const t = o.getState();
|
|
5194
5229
|
if (b(t.selection)) return !1;
|
|
5195
|
-
const e =
|
|
5230
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5196
5231
|
return e ? e.rowIndex < e.totalRows - 1 ? tt(o, e.tableId, e.rowIndex + 1, e.colIndex) : !0 : !1;
|
|
5197
5232
|
}
|
|
5198
5233
|
function Ur(o) {
|
|
5199
5234
|
const t = o.getState(), e = t.selection;
|
|
5200
5235
|
if (b(e) || !I(e) || e.anchor.offset !== 0) return !1;
|
|
5201
|
-
const n =
|
|
5236
|
+
const n = U(t, e.anchor.blockId);
|
|
5202
5237
|
return !n || !(n.rowIndex === 0 && n.colIndex === 0) ? !1 : bn(o, n.tableId);
|
|
5203
5238
|
}
|
|
5204
5239
|
function Dr(o) {
|
|
@@ -5206,21 +5241,21 @@ function Dr(o) {
|
|
|
5206
5241
|
if (b(e) || !I(e)) return !1;
|
|
5207
5242
|
const n = t.getBlock(e.anchor.blockId);
|
|
5208
5243
|
if (!n) return !1;
|
|
5209
|
-
const r =
|
|
5244
|
+
const r = O(n);
|
|
5210
5245
|
if (e.anchor.offset !== r) return !1;
|
|
5211
|
-
const i =
|
|
5246
|
+
const i = U(t, e.anchor.blockId);
|
|
5212
5247
|
return !i || !(i.rowIndex === i.totalRows - 1 && i.colIndex === i.totalCols - 1) ? !1 : bn(o, i.tableId);
|
|
5213
5248
|
}
|
|
5214
5249
|
function Wr(o) {
|
|
5215
5250
|
const t = o.getState();
|
|
5216
5251
|
if (b(t.selection)) return !1;
|
|
5217
|
-
const e =
|
|
5252
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5218
5253
|
return e ? e.rowIndex >= e.totalRows - 1 ? mn(o) : tt(o, e.tableId, e.rowIndex + 1, e.colIndex) : !1;
|
|
5219
5254
|
}
|
|
5220
5255
|
function Pr(o) {
|
|
5221
5256
|
const t = o.getState();
|
|
5222
5257
|
if (b(t.selection)) return !1;
|
|
5223
|
-
const e =
|
|
5258
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5224
5259
|
return !e || e.rowIndex <= 0 ? !1 : tt(o, e.tableId, e.rowIndex - 1, e.colIndex);
|
|
5225
5260
|
}
|
|
5226
5261
|
function Hr(o) {
|
|
@@ -5228,15 +5263,15 @@ function Hr(o) {
|
|
|
5228
5263
|
if (b(e) || !I(e)) return !1;
|
|
5229
5264
|
const n = t.getBlock(e.anchor.blockId);
|
|
5230
5265
|
if (!n) return !1;
|
|
5231
|
-
const r =
|
|
5266
|
+
const r = O(n);
|
|
5232
5267
|
if (e.anchor.offset !== r) return !1;
|
|
5233
|
-
const i =
|
|
5268
|
+
const i = U(t, e.anchor.blockId);
|
|
5234
5269
|
return i ? i.colIndex < i.totalCols - 1 ? tt(o, i.tableId, i.rowIndex, i.colIndex + 1) : i.rowIndex < i.totalRows - 1 ? tt(o, i.tableId, i.rowIndex + 1, 0) : !0 : !1;
|
|
5235
5270
|
}
|
|
5236
5271
|
function qr(o) {
|
|
5237
5272
|
const t = o.getState(), e = t.selection;
|
|
5238
5273
|
if (b(e) || !I(e) || e.anchor.offset !== 0) return !1;
|
|
5239
|
-
const n =
|
|
5274
|
+
const n = U(t, e.anchor.blockId);
|
|
5240
5275
|
return n ? n.colIndex > 0 ? Ve(o, n.tableId, n.rowIndex, n.colIndex - 1) : n.rowIndex > 0 ? Ve(
|
|
5241
5276
|
o,
|
|
5242
5277
|
n.tableId,
|
|
@@ -5247,7 +5282,7 @@ function qr(o) {
|
|
|
5247
5282
|
function mn(o) {
|
|
5248
5283
|
const t = o.getState();
|
|
5249
5284
|
if (b(t.selection)) return !1;
|
|
5250
|
-
const e =
|
|
5285
|
+
const e = U(t, t.selection.anchor.blockId);
|
|
5251
5286
|
if (!e) return !1;
|
|
5252
5287
|
const n = e.tableIndex + 1;
|
|
5253
5288
|
if (n < t.doc.children.length) {
|
|
@@ -5269,7 +5304,7 @@ function Ve(o, t, e, n) {
|
|
|
5269
5304
|
if (!i) return !1;
|
|
5270
5305
|
const s = r.getBlock(i);
|
|
5271
5306
|
if (!s) return !1;
|
|
5272
|
-
const l =
|
|
5307
|
+
const l = O(s), c = r.transaction("command").setSelection(A(i, l)).build();
|
|
5273
5308
|
return o.dispatch(c), !0;
|
|
5274
5309
|
}
|
|
5275
5310
|
function bn(o, t) {
|
|
@@ -5370,7 +5405,7 @@ function Ft(o, t, e, n) {
|
|
|
5370
5405
|
e.set(o.id, c);
|
|
5371
5406
|
const a = t.getNodeSpec(o.type);
|
|
5372
5407
|
a != null && a.isVoid && c.dom.setAttribute("data-void", "true"), a != null && a.selectable && c.dom.setAttribute("data-selectable", "true");
|
|
5373
|
-
const d =
|
|
5408
|
+
const d = B(o);
|
|
5374
5409
|
for (const u of d) {
|
|
5375
5410
|
const f = ((s = c.getContentDOM) == null ? void 0 : s.call(c, u.id)) ?? c.contentDOM;
|
|
5376
5411
|
if (f) {
|
|
@@ -5391,7 +5426,7 @@ function Ft(o, t, e, n) {
|
|
|
5391
5426
|
if (qe(o))
|
|
5392
5427
|
re(c, o, t, r);
|
|
5393
5428
|
else {
|
|
5394
|
-
const a =
|
|
5429
|
+
const a = B(o);
|
|
5395
5430
|
for (const d of a) {
|
|
5396
5431
|
const u = Ft(d, t, e, n);
|
|
5397
5432
|
c.appendChild(u);
|
|
@@ -5403,7 +5438,7 @@ function Ft(o, t, e, n) {
|
|
|
5403
5438
|
return Zr(o, t, r);
|
|
5404
5439
|
}
|
|
5405
5440
|
function re(o, t, e, n) {
|
|
5406
|
-
const r =
|
|
5441
|
+
const r = z(t);
|
|
5407
5442
|
if (r.length === 1 && D(r[0]) && r[0].text === "") {
|
|
5408
5443
|
o.appendChild(document.createElement("br"));
|
|
5409
5444
|
return;
|
|
@@ -5566,15 +5601,15 @@ const vn = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewB
|
|
|
5566
5601
|
function Oe(o, t, e, n) {
|
|
5567
5602
|
const r = o(), i = r.getBlock(e);
|
|
5568
5603
|
if (!i) return;
|
|
5569
|
-
const s =
|
|
5604
|
+
const s = B(i), l = s[0] ? B(s[0]).length : 0;
|
|
5570
5605
|
if (l === 0) return;
|
|
5571
|
-
const c = ne(l), a =
|
|
5606
|
+
const c = ne(l), a = B(c)[0], d = r.transaction("command").insertNode([e], n, c);
|
|
5572
5607
|
a && d.setSelection(A(a.id, 0)), t(d.build());
|
|
5573
5608
|
}
|
|
5574
5609
|
function Re(o, t, e, n) {
|
|
5575
5610
|
const r = o(), i = r.getBlock(e);
|
|
5576
5611
|
if (!i) return;
|
|
5577
|
-
const s =
|
|
5612
|
+
const s = B(i), l = r.transaction("command");
|
|
5578
5613
|
for (const c of s) {
|
|
5579
5614
|
const a = un();
|
|
5580
5615
|
l.insertNode([e, c.id], n, a);
|
|
@@ -5584,7 +5619,7 @@ function Re(o, t, e, n) {
|
|
|
5584
5619
|
function _r(o, t, e, n) {
|
|
5585
5620
|
const r = o(), i = r.getBlock(e);
|
|
5586
5621
|
if (!i) return;
|
|
5587
|
-
if (
|
|
5622
|
+
if (B(i).length <= 1) {
|
|
5588
5623
|
ie(o, t, e);
|
|
5589
5624
|
return;
|
|
5590
5625
|
}
|
|
@@ -5594,8 +5629,8 @@ function _r(o, t, e, n) {
|
|
|
5594
5629
|
function $r(o, t, e, n) {
|
|
5595
5630
|
const r = o(), i = r.getBlock(e);
|
|
5596
5631
|
if (!i) return;
|
|
5597
|
-
const s =
|
|
5598
|
-
if ((s[0] ?
|
|
5632
|
+
const s = B(i);
|
|
5633
|
+
if ((s[0] ? B(s[0]).length : 0) <= 1) {
|
|
5599
5634
|
ie(o, t, e);
|
|
5600
5635
|
return;
|
|
5601
5636
|
}
|
|
@@ -5685,38 +5720,38 @@ function ti(o, t, e, n, r) {
|
|
|
5685
5720
|
});
|
|
5686
5721
|
F.observe(t), requestAnimationFrame(() => kt());
|
|
5687
5722
|
function V(w) {
|
|
5688
|
-
return
|
|
5723
|
+
return B(w).length;
|
|
5689
5724
|
}
|
|
5690
5725
|
function v(w) {
|
|
5691
|
-
const C =
|
|
5692
|
-
return C[0] ?
|
|
5726
|
+
const C = B(w);
|
|
5727
|
+
return C[0] ? B(C[0]).length : 0;
|
|
5693
5728
|
}
|
|
5694
5729
|
function P() {
|
|
5695
|
-
let w = 0, C = 0,
|
|
5696
|
-
for (;
|
|
5697
|
-
w +=
|
|
5730
|
+
let w = 0, C = 0, E = t;
|
|
5731
|
+
for (; E && E !== o; )
|
|
5732
|
+
w += E.offsetTop, C += E.offsetLeft, E = E.offsetParent;
|
|
5698
5733
|
return { top: w, left: C };
|
|
5699
5734
|
}
|
|
5700
5735
|
function q() {
|
|
5701
|
-
const w = t.querySelectorAll(":scope > tbody > tr"), C = t.offsetTop,
|
|
5736
|
+
const w = t.querySelectorAll(":scope > tbody > tr"), C = t.offsetTop, E = [];
|
|
5702
5737
|
for (let K = 1; K < w.length; K++) {
|
|
5703
5738
|
const j = w[K];
|
|
5704
|
-
j &&
|
|
5739
|
+
j && E.push({
|
|
5705
5740
|
position: j.offsetTop - C,
|
|
5706
5741
|
index: K
|
|
5707
5742
|
});
|
|
5708
5743
|
}
|
|
5709
|
-
return
|
|
5744
|
+
return E;
|
|
5710
5745
|
}
|
|
5711
5746
|
function Ot() {
|
|
5712
5747
|
if (l <= 1) return [];
|
|
5713
|
-
const C = t.offsetWidth / l,
|
|
5748
|
+
const C = t.offsetWidth / l, E = [];
|
|
5714
5749
|
for (let K = 1; K < l; K++)
|
|
5715
|
-
|
|
5750
|
+
E.push({
|
|
5716
5751
|
position: Math.round(C * K),
|
|
5717
5752
|
index: K
|
|
5718
5753
|
});
|
|
5719
|
-
return
|
|
5754
|
+
return E;
|
|
5720
5755
|
}
|
|
5721
5756
|
function kt() {
|
|
5722
5757
|
M(), Y(), le();
|
|
@@ -5724,34 +5759,34 @@ function ti(o, t, e, n, r) {
|
|
|
5724
5759
|
function M() {
|
|
5725
5760
|
const w = c.children;
|
|
5726
5761
|
if (w.length === 0) return;
|
|
5727
|
-
const C = t.offsetWidth,
|
|
5762
|
+
const C = t.offsetWidth, E = C / l;
|
|
5728
5763
|
for (let K = 0; K < w.length; K++) {
|
|
5729
5764
|
const j = w[K];
|
|
5730
|
-
j.style.left = `${Math.round(
|
|
5765
|
+
j.style.left = `${Math.round(E * K)}px`, j.style.width = `${Math.round(E)}px`;
|
|
5731
5766
|
}
|
|
5732
5767
|
c.style.width = `${C}px`;
|
|
5733
5768
|
}
|
|
5734
5769
|
function Y() {
|
|
5735
5770
|
const w = a.children;
|
|
5736
5771
|
if (w.length === 0) return;
|
|
5737
|
-
const C = t.querySelectorAll(":scope > tbody > tr"),
|
|
5772
|
+
const C = t.querySelectorAll(":scope > tbody > tr"), E = t.offsetTop;
|
|
5738
5773
|
let K = 0;
|
|
5739
5774
|
for (let j = 0; j < w.length; j++) {
|
|
5740
5775
|
const xt = w[j], it = C[j];
|
|
5741
5776
|
if (it) {
|
|
5742
|
-
const ut = it.offsetTop -
|
|
5777
|
+
const ut = it.offsetTop - E, Ct = it.offsetHeight;
|
|
5743
5778
|
xt.style.top = `${ut}px`, xt.style.height = `${Ct}px`, K = ut + Ct;
|
|
5744
5779
|
}
|
|
5745
5780
|
}
|
|
5746
5781
|
a.style.height = `${K}px`;
|
|
5747
5782
|
}
|
|
5748
5783
|
function le() {
|
|
5749
|
-
const w = P(), C = t.offsetHeight,
|
|
5750
|
-
f.style.width = `${
|
|
5784
|
+
const w = P(), C = t.offsetHeight, E = t.offsetWidth;
|
|
5785
|
+
f.style.width = `${E}px`, f.style.left = `${w.left}px`, p.style.height = `${C}px`, p.style.top = `${w.top}px`;
|
|
5751
5786
|
}
|
|
5752
5787
|
function ce(w) {
|
|
5753
|
-
const C = t.getBoundingClientRect(),
|
|
5754
|
-
if (!(
|
|
5788
|
+
const C = t.getBoundingClientRect(), E = w.clientX - C.left, K = w.clientY - C.top;
|
|
5789
|
+
if (!(E >= -ft && E <= C.width + ft && K >= -ft && K <= C.height + ft)) {
|
|
5755
5790
|
Rt();
|
|
5756
5791
|
return;
|
|
5757
5792
|
}
|
|
@@ -5764,7 +5799,7 @@ function ti(o, t, e, n, r) {
|
|
|
5764
5799
|
const Ct = Ot();
|
|
5765
5800
|
let Ut = Number.POSITIVE_INFINITY, Tt = null;
|
|
5766
5801
|
for (const yt of Ct) {
|
|
5767
|
-
const st = Math.abs(
|
|
5802
|
+
const st = Math.abs(E - yt.position);
|
|
5768
5803
|
st < Ut && st < ft && (Ut = st, Tt = yt);
|
|
5769
5804
|
}
|
|
5770
5805
|
ut && (!Tt || it <= Ut) ? (Cn(ut), ue()) : Tt ? (Tn(Tt), de()) : Rt();
|
|
@@ -5794,8 +5829,8 @@ function ti(o, t, e, n, r) {
|
|
|
5794
5829
|
function fe() {
|
|
5795
5830
|
c.innerHTML = "";
|
|
5796
5831
|
for (let w = 0; w < l; w++) {
|
|
5797
|
-
const C = Pe("ntbl-col-handle", w, (
|
|
5798
|
-
$r(n, r, i,
|
|
5832
|
+
const C = Pe("ntbl-col-handle", w, (E) => {
|
|
5833
|
+
$r(n, r, i, E);
|
|
5799
5834
|
});
|
|
5800
5835
|
c.appendChild(C);
|
|
5801
5836
|
}
|
|
@@ -5803,8 +5838,8 @@ function ti(o, t, e, n, r) {
|
|
|
5803
5838
|
function he() {
|
|
5804
5839
|
a.innerHTML = "";
|
|
5805
5840
|
for (let w = 0; w < s; w++) {
|
|
5806
|
-
const C = Pe("ntbl-row-handle", w, (
|
|
5807
|
-
_r(n, r, i,
|
|
5841
|
+
const C = Pe("ntbl-row-handle", w, (E) => {
|
|
5842
|
+
_r(n, r, i, E);
|
|
5808
5843
|
});
|
|
5809
5844
|
a.appendChild(C);
|
|
5810
5845
|
}
|
|
@@ -5812,8 +5847,8 @@ function ti(o, t, e, n, r) {
|
|
|
5812
5847
|
return {
|
|
5813
5848
|
update(w) {
|
|
5814
5849
|
i = w.id;
|
|
5815
|
-
const C = V(w),
|
|
5816
|
-
(C !== s ||
|
|
5850
|
+
const C = V(w), E = v(w);
|
|
5851
|
+
(C !== s || E !== l) && (s = C, l = E, fe(), he()), requestAnimationFrame(() => kt());
|
|
5817
5852
|
},
|
|
5818
5853
|
destroy() {
|
|
5819
5854
|
F.disconnect(), o.removeEventListener("mousemove", ce), o.removeEventListener("mouseleave", ae), c.remove(), a.remove(), d.remove(), u.remove(), f.remove(), p.remove(), g.remove();
|
|
@@ -5828,7 +5863,7 @@ function ei(o) {
|
|
|
5828
5863
|
i.className = "notectl-table-wrapper";
|
|
5829
5864
|
const s = document.createElement("table");
|
|
5830
5865
|
s.className = "notectl-table", s.setAttribute("role", "table");
|
|
5831
|
-
const l =
|
|
5866
|
+
const l = B(t), c = l.length, a = l[0] ? B(l[0]).length : 0;
|
|
5832
5867
|
s.setAttribute("aria-label", `Table with ${c} rows and ${a} columns`);
|
|
5833
5868
|
const d = document.createElement("tbody");
|
|
5834
5869
|
s.appendChild(d), i.appendChild(s), r.appendChild(i);
|
|
@@ -5847,7 +5882,7 @@ function ei(o) {
|
|
|
5847
5882
|
update(p) {
|
|
5848
5883
|
if (p.type !== "table") return !1;
|
|
5849
5884
|
r.setAttribute("data-block-id", p.id), r.setAttribute("data-selectable", "true");
|
|
5850
|
-
const g =
|
|
5885
|
+
const g = B(p), k = g.length, m = g[0] ? B(g[0]).length : 0;
|
|
5851
5886
|
return s.setAttribute(
|
|
5852
5887
|
"aria-label",
|
|
5853
5888
|
`Table with ${k} rows and ${m} columns`
|
|
@@ -5950,7 +5985,7 @@ function li(o, t) {
|
|
|
5950
5985
|
}
|
|
5951
5986
|
if (c.shiftKey) {
|
|
5952
5987
|
if (n) {
|
|
5953
|
-
const u = o.getState(), f = d.getAttribute("data-block-id"), p =
|
|
5988
|
+
const u = o.getState(), f = d.getAttribute("data-block-id"), p = U(u, f);
|
|
5954
5989
|
if (!p || p.tableId !== n.tableId) return;
|
|
5955
5990
|
c.preventDefault(), t.setSelectedRange({
|
|
5956
5991
|
tableId: n.tableId,
|
|
@@ -5962,7 +5997,7 @@ function li(o, t) {
|
|
|
5962
5997
|
}
|
|
5963
5998
|
} else {
|
|
5964
5999
|
t.setSelectedRange(null);
|
|
5965
|
-
const u = o.getState(), f = d.getAttribute("data-block-id"), p =
|
|
6000
|
+
const u = o.getState(), f = d.getAttribute("data-block-id"), p = U(u, f);
|
|
5966
6001
|
if (!p) return;
|
|
5967
6002
|
n = {
|
|
5968
6003
|
tableId: p.tableId,
|
|
@@ -5975,7 +6010,7 @@ function li(o, t) {
|
|
|
5975
6010
|
if (!r || !n) return;
|
|
5976
6011
|
const d = c.target.closest("td[data-block-id]");
|
|
5977
6012
|
if (!d) return;
|
|
5978
|
-
const u = o.getState(), f = d.getAttribute("data-block-id"), p =
|
|
6013
|
+
const u = o.getState(), f = d.getAttribute("data-block-id"), p = U(u, f);
|
|
5979
6014
|
!p || p.tableId !== n.tableId || (p.rowIndex !== n.row || p.colIndex !== n.col) && (c.preventDefault(), t.setSelectedRange({
|
|
5980
6015
|
tableId: n.tableId,
|
|
5981
6016
|
fromRow: n.row,
|
|
@@ -6240,12 +6275,12 @@ class cs {
|
|
|
6240
6275
|
}
|
|
6241
6276
|
const s = t.getBlock(e.anchor.blockId);
|
|
6242
6277
|
if (!s) return null;
|
|
6243
|
-
const c =
|
|
6278
|
+
const c = N(s, e.anchor.offset).find((a) => a.type === "highlight");
|
|
6244
6279
|
return c && Q(c, "highlight") ? c.attrs.color ?? null : null;
|
|
6245
6280
|
}
|
|
6246
6281
|
const n = t.getBlock(e.anchor.blockId);
|
|
6247
6282
|
if (!n) return null;
|
|
6248
|
-
const i =
|
|
6283
|
+
const i = N(n, e.anchor.offset).find((s) => s.type === "highlight");
|
|
6249
6284
|
return i && Q(i, "highlight") ? i.attrs.color ?? null : null;
|
|
6250
6285
|
}
|
|
6251
6286
|
// --- Highlight Application ---
|
|
@@ -6255,7 +6290,7 @@ class cs {
|
|
|
6255
6290
|
if (I(r)) {
|
|
6256
6291
|
const u = e.getBlock(r.anchor.blockId);
|
|
6257
6292
|
if (!u) return !1;
|
|
6258
|
-
const g = [...(e.storedMarks ??
|
|
6293
|
+
const g = [...(e.storedMarks ?? N(u, r.anchor.offset)).filter((m) => m.type !== "highlight"), { type: "highlight", attrs: { color: n } }], k = e.transaction("command").setStoredMarks(g, e.storedMarks).setSelection(r).build();
|
|
6259
6294
|
return t.dispatch(k), !0;
|
|
6260
6295
|
}
|
|
6261
6296
|
const i = e.getBlockOrder(), s = W(r, i), l = e.transaction("command"), c = i.indexOf(s.from.blockId), a = i.indexOf(s.to.blockId), d = { type: "highlight", attrs: { color: n } };
|
|
@@ -6280,7 +6315,7 @@ class cs {
|
|
|
6280
6315
|
if (I(n)) {
|
|
6281
6316
|
const a = e.getBlock(n.anchor.blockId);
|
|
6282
6317
|
if (!a) return !1;
|
|
6283
|
-
const d = e.storedMarks ??
|
|
6318
|
+
const d = e.storedMarks ?? N(a, n.anchor.offset);
|
|
6284
6319
|
if (!G(d, "highlight")) return !1;
|
|
6285
6320
|
const u = d.filter((p) => p.type !== "highlight"), f = e.transaction("command").setStoredMarks(u, e.storedMarks).setSelection(n).build();
|
|
6286
6321
|
return t.dispatch(f), !0;
|
|
@@ -8111,9 +8146,9 @@ const xi = `
|
|
|
8111
8146
|
flex: 1;
|
|
8112
8147
|
}
|
|
8113
8148
|
`;
|
|
8114
|
-
let
|
|
8149
|
+
let Bt = null;
|
|
8115
8150
|
function Ci() {
|
|
8116
|
-
return
|
|
8151
|
+
return Bt || (Bt = new CSSStyleSheet(), Bt.replaceSync(xi)), Bt;
|
|
8117
8152
|
}
|
|
8118
8153
|
class Ti extends HTMLElement {
|
|
8119
8154
|
constructor() {
|
|
@@ -8418,7 +8453,7 @@ class Ti extends HTMLElement {
|
|
|
8418
8453
|
return l && l !== "left" && (s = s.replace(/>/, ` style="text-align: ${l}">`)), s;
|
|
8419
8454
|
}
|
|
8420
8455
|
serializeInlineContent(e, n) {
|
|
8421
|
-
const r =
|
|
8456
|
+
const r = z(e), i = [];
|
|
8422
8457
|
for (const s of r)
|
|
8423
8458
|
if (T(s)) {
|
|
8424
8459
|
const l = n == null ? void 0 : n.getInlineNodeSpec(s.inlineType);
|
|
@@ -8467,7 +8502,7 @@ class Ti extends HTMLElement {
|
|
|
8467
8502
|
for (const S of Array.from(p.querySelectorAll("li"))) {
|
|
8468
8503
|
const F = this.parseElementToTextNodes(S, n);
|
|
8469
8504
|
a.push(
|
|
8470
|
-
|
|
8505
|
+
R("list_item", F, void 0, {
|
|
8471
8506
|
listType: y,
|
|
8472
8507
|
indent: 0,
|
|
8473
8508
|
checked: !1
|
|
@@ -8476,11 +8511,11 @@ class Ti extends HTMLElement {
|
|
|
8476
8511
|
}
|
|
8477
8512
|
continue;
|
|
8478
8513
|
}
|
|
8479
|
-
const k =
|
|
8514
|
+
const k = Ei(p, c);
|
|
8480
8515
|
if (k) {
|
|
8481
8516
|
const y = this.parseElementToTextNodes(p, n);
|
|
8482
8517
|
a.push(
|
|
8483
|
-
|
|
8518
|
+
R(
|
|
8484
8519
|
k.type,
|
|
8485
8520
|
y,
|
|
8486
8521
|
void 0,
|
|
@@ -8490,9 +8525,9 @@ class Ti extends HTMLElement {
|
|
|
8490
8525
|
continue;
|
|
8491
8526
|
}
|
|
8492
8527
|
const m = this.parseElementToTextNodes(p, n);
|
|
8493
|
-
a.push(
|
|
8528
|
+
a.push(R("paragraph", m));
|
|
8494
8529
|
} else f.nodeType === Node.TEXT_NODE && ((u = f.textContent) != null && u.trim()) && a.push(
|
|
8495
|
-
|
|
8530
|
+
R("paragraph", [x(f.textContent.trim())])
|
|
8496
8531
|
);
|
|
8497
8532
|
return a.length === 0 ? Gt() : Gt(a);
|
|
8498
8533
|
}
|
|
@@ -8523,7 +8558,7 @@ class Ti extends HTMLElement {
|
|
|
8523
8558
|
this.walkElement(d, c, r, i);
|
|
8524
8559
|
}
|
|
8525
8560
|
}
|
|
8526
|
-
function
|
|
8561
|
+
function Ei(o, t) {
|
|
8527
8562
|
const e = o.tagName.toLowerCase();
|
|
8528
8563
|
for (const n of t)
|
|
8529
8564
|
if (n.rule.tag === e) {
|
|
@@ -8577,7 +8612,7 @@ export {
|
|
|
8577
8612
|
On as canContain,
|
|
8578
8613
|
Ki as commandName,
|
|
8579
8614
|
ot as createBlockElement,
|
|
8580
|
-
|
|
8615
|
+
R as createBlockNode,
|
|
8581
8616
|
A as createCollapsedSelection,
|
|
8582
8617
|
Gt as createDocument,
|
|
8583
8618
|
ds as createEditor,
|
|
@@ -8595,14 +8630,14 @@ export {
|
|
|
8595
8630
|
$ as findNode,
|
|
8596
8631
|
Z as findNodePath,
|
|
8597
8632
|
Wi as findNodeWithPath,
|
|
8598
|
-
|
|
8633
|
+
U as findTableContext,
|
|
8599
8634
|
St as formatShortcut,
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8635
|
+
B as getBlockChildren,
|
|
8636
|
+
O as getBlockLength,
|
|
8637
|
+
N as getBlockMarksAtOffset,
|
|
8603
8638
|
It as getBlockText,
|
|
8604
8639
|
ct as getContentAtOffset,
|
|
8605
|
-
|
|
8640
|
+
z as getInlineChildren,
|
|
8606
8641
|
Mn as getTextChildren,
|
|
8607
8642
|
G as hasMark,
|
|
8608
8643
|
Gi as inlineDecoration,
|