@cyte-editor/react 0.3.3 → 0.3.4
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/cyte-editor-react.cjs +4 -4
- package/dist/cyte-editor-react.js +812 -805
- package/package.json +6 -6
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as c, jsxs as
|
|
2
|
-
import Ot, { useRef as
|
|
1
|
+
import { jsx as c, jsxs as v, Fragment as Ft } from "react/jsx-runtime";
|
|
2
|
+
import Ot, { useRef as H, useState as D, useCallback as E, useEffect as _, useMemo as _e, useLayoutEffect as Sn, forwardRef as Mn, useImperativeHandle as cn } from "react";
|
|
3
3
|
import { EditorManager as Tn, I18nManager as Ve, toolbarItemDefs as _t, uploadFile as Ln, groupToolbarItems as Rn, getToolbarItemDef as En, adjustMenuPosition as Vt, ScrollSyncManager as Dn, showToast as yt, getHoverLineVisible as An, moveCursorToCell as Ze, restoreTableSelection as jt, clearSavedTableSelection as qt } from "@cyte-editor/core";
|
|
4
4
|
import { getLicenseStatus as In } from "@cyte-editor/license";
|
|
5
5
|
import { createPortal as tt } from "react-dom";
|
|
6
6
|
/*!
|
|
7
|
-
* CyteEditor React Adapter v0.3.
|
|
7
|
+
* CyteEditor React Adapter v0.3.4 (@cyte-editor/react)
|
|
8
8
|
* (c) 2026 CyteEditor — All Rights Reserved.
|
|
9
9
|
*
|
|
10
10
|
* Commercial Software — NOT Open Source.
|
|
11
11
|
* Licensed under the CyteEditor Commercial License.
|
|
12
12
|
* SEE LICENSE IN ./LICENSE | Full EULA: https://cyteeditor.com/eula
|
|
13
13
|
*
|
|
14
|
-
* Build:
|
|
14
|
+
* Build: 1c69305-dirty @ 2026-07-02T13:26:12.802Z
|
|
15
15
|
* Homepage: https://cyteeditor.com
|
|
16
16
|
* Contact: legal@cyteeditor.com (legal) / support@cyteeditor.com (support)
|
|
17
17
|
*
|
|
@@ -509,11 +509,11 @@ class xe {
|
|
|
509
509
|
break;
|
|
510
510
|
let d = this.ranges[l + s], p = this.ranges[l + i], b = a + d;
|
|
511
511
|
if (e <= b) {
|
|
512
|
-
let
|
|
512
|
+
let T = d ? e == a ? -1 : e == b ? 1 : t : t, m = a + o + (T < 0 ? 0 : p);
|
|
513
513
|
if (r)
|
|
514
|
-
return
|
|
515
|
-
let k = e == (t < 0 ? a : b) ? null : On(l / 3, e - a),
|
|
516
|
-
return (t < 0 ? e != a : e != b) && (
|
|
514
|
+
return m;
|
|
515
|
+
let k = e == (t < 0 ? a : b) ? null : On(l / 3, e - a), y = e == a ? gn : e == b ? mn : gt;
|
|
516
|
+
return (t < 0 ? e != a : e != b) && (y |= wn), new Gt(m, y, k);
|
|
517
517
|
}
|
|
518
518
|
o += p - d;
|
|
519
519
|
}
|
|
@@ -665,7 +665,7 @@ class We extends ye {
|
|
|
665
665
|
return ue.fromReplace(e, this.from, this.to, s);
|
|
666
666
|
}
|
|
667
667
|
invert() {
|
|
668
|
-
return new
|
|
668
|
+
return new Ke(this.from, this.to, this.mark);
|
|
669
669
|
}
|
|
670
670
|
map(e) {
|
|
671
671
|
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
|
|
@@ -692,7 +692,7 @@ class We extends ye {
|
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
694
|
ye.jsonID("addMark", We);
|
|
695
|
-
class
|
|
695
|
+
class Ke extends ye {
|
|
696
696
|
/**
|
|
697
697
|
Create a mark-removing step.
|
|
698
698
|
*/
|
|
@@ -708,10 +708,10 @@ class Ue extends ye {
|
|
|
708
708
|
}
|
|
709
709
|
map(e) {
|
|
710
710
|
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
|
|
711
|
-
return t.deleted && r.deleted || t.pos >= r.pos ? null : new
|
|
711
|
+
return t.deleted && r.deleted || t.pos >= r.pos ? null : new Ke(t.pos, r.pos, this.mark);
|
|
712
712
|
}
|
|
713
713
|
merge(e) {
|
|
714
|
-
return e instanceof
|
|
714
|
+
return e instanceof Ke && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new Ke(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
|
|
715
715
|
}
|
|
716
716
|
toJSON() {
|
|
717
717
|
return {
|
|
@@ -727,11 +727,11 @@ class Ue extends ye {
|
|
|
727
727
|
static fromJSON(e, t) {
|
|
728
728
|
if (typeof t.from != "number" || typeof t.to != "number")
|
|
729
729
|
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
|
|
730
|
-
return new
|
|
730
|
+
return new Ke(t.from, t.to, e.markFromJSON(t.mark));
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
-
ye.jsonID("removeMark",
|
|
734
|
-
class
|
|
733
|
+
ye.jsonID("removeMark", Ke);
|
|
734
|
+
class Ue extends ye {
|
|
735
735
|
/**
|
|
736
736
|
Create a node mark step.
|
|
737
737
|
*/
|
|
@@ -752,15 +752,15 @@ class Ke extends ye {
|
|
|
752
752
|
if (r.length == t.marks.length) {
|
|
753
753
|
for (let o = 0; o < t.marks.length; o++)
|
|
754
754
|
if (!t.marks[o].isInSet(r))
|
|
755
|
-
return new
|
|
756
|
-
return new
|
|
755
|
+
return new Ue(this.pos, t.marks[o]);
|
|
756
|
+
return new Ue(this.pos, this.mark);
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
759
|
return new lt(this.pos, this.mark);
|
|
760
760
|
}
|
|
761
761
|
map(e) {
|
|
762
762
|
let t = e.mapResult(this.pos, 1);
|
|
763
|
-
return t.deletedAfter ? null : new
|
|
763
|
+
return t.deletedAfter ? null : new Ue(t.pos, this.mark);
|
|
764
764
|
}
|
|
765
765
|
toJSON() {
|
|
766
766
|
return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
|
|
@@ -771,10 +771,10 @@ class Ke extends ye {
|
|
|
771
771
|
static fromJSON(e, t) {
|
|
772
772
|
if (typeof t.pos != "number")
|
|
773
773
|
throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
|
|
774
|
-
return new
|
|
774
|
+
return new Ue(t.pos, e.markFromJSON(t.mark));
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
|
-
ye.jsonID("addNodeMark",
|
|
777
|
+
ye.jsonID("addNodeMark", Ue);
|
|
778
778
|
class lt extends ye {
|
|
779
779
|
/**
|
|
780
780
|
Create a mark-removing step.
|
|
@@ -791,7 +791,7 @@ class lt extends ye {
|
|
|
791
791
|
}
|
|
792
792
|
invert(e) {
|
|
793
793
|
let t = e.nodeAt(this.pos);
|
|
794
|
-
return !t || !this.mark.isInSet(t.marks) ? this : new
|
|
794
|
+
return !t || !this.mark.isInSet(t.marks) ? this : new Ue(this.pos, this.mark);
|
|
795
795
|
}
|
|
796
796
|
map(e) {
|
|
797
797
|
let t = e.mapResult(this.pos, 1);
|
|
@@ -1560,8 +1560,8 @@ function Jn(n) {
|
|
|
1560
1560
|
var e = Fn && n.metaKey && n.shiftKey && !n.ctrlKey && !n.altKey || Pn && n.shiftKey && n.key && n.key.length == 1 || n.key == "Unidentified", t = !e && n.key || (n.shiftKey ? bt : He)[n.keyCode] || n.key || "Unidentified";
|
|
1561
1561
|
return t == "Esc" && (t = "Escape"), t == "Del" && (t = "Delete"), t == "Left" && (t = "ArrowLeft"), t == "Up" && (t = "ArrowUp"), t == "Right" && (t = "ArrowRight"), t == "Down" && (t = "ArrowDown"), t;
|
|
1562
1562
|
}
|
|
1563
|
-
const Wn = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform),
|
|
1564
|
-
function
|
|
1563
|
+
const Wn = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), Kn = typeof navigator < "u" && /Win/.test(navigator.platform);
|
|
1564
|
+
function Un(n) {
|
|
1565
1565
|
let e = n.split(/-(?!$)/), t = e[e.length - 1];
|
|
1566
1566
|
t == "Space" && (t = " ");
|
|
1567
1567
|
let r, o, s, i;
|
|
@@ -1585,7 +1585,7 @@ function Kn(n) {
|
|
|
1585
1585
|
function _n(n) {
|
|
1586
1586
|
let e = /* @__PURE__ */ Object.create(null);
|
|
1587
1587
|
for (let t in n)
|
|
1588
|
-
e[
|
|
1588
|
+
e[Un(t)] = n[t];
|
|
1589
1589
|
return e;
|
|
1590
1590
|
}
|
|
1591
1591
|
function Dt(n, e, t = !0) {
|
|
@@ -1604,7 +1604,7 @@ function Vn(n) {
|
|
|
1604
1604
|
return !0;
|
|
1605
1605
|
}
|
|
1606
1606
|
if ((r.altKey || r.metaKey || r.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
1607
|
-
!(
|
|
1607
|
+
!(Kn && r.ctrlKey && r.altKey) && (s = He[r.keyCode]) && s != o) {
|
|
1608
1608
|
let l = e[Dt(s, r)];
|
|
1609
1609
|
if (l && l(t.state, t.dispatch, t))
|
|
1610
1610
|
return !0;
|
|
@@ -1698,40 +1698,40 @@ function jn(n) {
|
|
|
1698
1698
|
for (let k = 0; ; k++) {
|
|
1699
1699
|
for (; o < r.length && r[o] != 0; ) o++;
|
|
1700
1700
|
if (k == b.childCount) break;
|
|
1701
|
-
const
|
|
1702
|
-
for (let
|
|
1703
|
-
if (
|
|
1701
|
+
const y = b.child(k), { colspan: S, rowspan: u, colwidth: h } = y.attrs;
|
|
1702
|
+
for (let x = 0; x < u; x++) {
|
|
1703
|
+
if (x + d >= t) {
|
|
1704
1704
|
(s || (s = [])).push({
|
|
1705
1705
|
type: "overlong_rowspan",
|
|
1706
1706
|
pos: p,
|
|
1707
|
-
n: u -
|
|
1707
|
+
n: u - x
|
|
1708
1708
|
});
|
|
1709
1709
|
break;
|
|
1710
1710
|
}
|
|
1711
|
-
const w = o +
|
|
1712
|
-
for (let
|
|
1713
|
-
r[w +
|
|
1711
|
+
const w = o + x * e;
|
|
1712
|
+
for (let f = 0; f < S; f++) {
|
|
1713
|
+
r[w + f] == 0 ? r[w + f] = p : (s || (s = [])).push({
|
|
1714
1714
|
type: "collision",
|
|
1715
1715
|
row: d,
|
|
1716
1716
|
pos: p,
|
|
1717
|
-
n:
|
|
1717
|
+
n: S - f
|
|
1718
1718
|
});
|
|
1719
|
-
const
|
|
1720
|
-
if (
|
|
1721
|
-
const $ = (w +
|
|
1722
|
-
P == null || P !=
|
|
1719
|
+
const N = h && h[f];
|
|
1720
|
+
if (N) {
|
|
1721
|
+
const $ = (w + f) % e * 2, P = i[$];
|
|
1722
|
+
P == null || P != N && i[$ + 1] == 1 ? (i[$] = N, i[$ + 1] = 1) : P == N && i[$ + 1]++;
|
|
1723
1723
|
}
|
|
1724
1724
|
}
|
|
1725
1725
|
}
|
|
1726
|
-
o +=
|
|
1726
|
+
o += S, p += y.nodeSize;
|
|
1727
1727
|
}
|
|
1728
|
-
const
|
|
1729
|
-
let
|
|
1730
|
-
for (; o <
|
|
1731
|
-
|
|
1728
|
+
const T = (d + 1) * e;
|
|
1729
|
+
let m = 0;
|
|
1730
|
+
for (; o < T; ) r[o++] == 0 && m++;
|
|
1731
|
+
m && (s || (s = [])).push({
|
|
1732
1732
|
type: "missing",
|
|
1733
1733
|
row: d,
|
|
1734
|
-
n:
|
|
1734
|
+
n: m
|
|
1735
1735
|
}), p++;
|
|
1736
1736
|
}
|
|
1737
1737
|
(e === 0 || t === 0) && (s || (s = [])).push({ type: "zero_sized" });
|
|
@@ -1788,7 +1788,7 @@ function Gn(n) {
|
|
|
1788
1788
|
for (let t = 0; t < n.colspan; t++) e.push(0);
|
|
1789
1789
|
return e;
|
|
1790
1790
|
}
|
|
1791
|
-
function
|
|
1791
|
+
function Kt(n) {
|
|
1792
1792
|
let e = n.cached.tableNodeTypes;
|
|
1793
1793
|
if (!e) {
|
|
1794
1794
|
e = n.cached.tableNodeTypes = {};
|
|
@@ -1851,8 +1851,8 @@ var Ie = class Ee extends ee {
|
|
|
1851
1851
|
const d = a.map((p) => {
|
|
1852
1852
|
const b = r.nodeAt(p);
|
|
1853
1853
|
if (!b) throw new RangeError(`No cell with offset ${p} found`);
|
|
1854
|
-
const
|
|
1855
|
-
return new yn(l.resolve(
|
|
1854
|
+
const T = s + p + 1;
|
|
1855
|
+
return new yn(l.resolve(T), l.resolve(T + b.content.size));
|
|
1856
1856
|
});
|
|
1857
1857
|
super(d[0].$from, d[0].$to, d), this.$anchorCell = e, this.$headCell = t;
|
|
1858
1858
|
}
|
|
@@ -1869,25 +1869,25 @@ var Ie = class Ee extends ee {
|
|
|
1869
1869
|
for (let a = o.top; a < o.bottom; a++) {
|
|
1870
1870
|
const d = [];
|
|
1871
1871
|
for (let p = a * t.width + o.left, b = o.left; b < o.right; b++, p++) {
|
|
1872
|
-
const
|
|
1873
|
-
if (s[
|
|
1874
|
-
s[
|
|
1875
|
-
const
|
|
1876
|
-
let k = e.nodeAt(
|
|
1877
|
-
if (!k) throw new RangeError(`No cell with offset ${
|
|
1878
|
-
const
|
|
1879
|
-
if (
|
|
1872
|
+
const T = t.map[p];
|
|
1873
|
+
if (s[T]) continue;
|
|
1874
|
+
s[T] = !0;
|
|
1875
|
+
const m = t.findCell(T);
|
|
1876
|
+
let k = e.nodeAt(T);
|
|
1877
|
+
if (!k) throw new RangeError(`No cell with offset ${T} found`);
|
|
1878
|
+
const y = o.left - m.left, S = m.right - o.right;
|
|
1879
|
+
if (y > 0 || S > 0) {
|
|
1880
1880
|
let u = k.attrs;
|
|
1881
|
-
if (
|
|
1881
|
+
if (y > 0 && (u = nn(u, 0, y)), S > 0 && (u = nn(u, u.colspan - S, S)), m.left < o.left) {
|
|
1882
1882
|
if (k = k.type.createAndFill(u), !k) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(u)}`);
|
|
1883
1883
|
} else k = k.type.create(u, k.content);
|
|
1884
1884
|
}
|
|
1885
|
-
if (
|
|
1885
|
+
if (m.top < o.top || m.bottom > o.bottom) {
|
|
1886
1886
|
const u = {
|
|
1887
1887
|
...k.attrs,
|
|
1888
|
-
rowspan: Math.min(
|
|
1888
|
+
rowspan: Math.min(m.bottom, o.bottom) - Math.max(m.top, o.top)
|
|
1889
1889
|
};
|
|
1890
|
-
|
|
1890
|
+
m.top < o.top ? k = k.type.createAndFill(u) : k = k.type.create(u, k.content);
|
|
1891
1891
|
}
|
|
1892
1892
|
d.push(k);
|
|
1893
1893
|
}
|
|
@@ -1980,7 +1980,7 @@ function tr(n) {
|
|
|
1980
1980
|
return function(e, t) {
|
|
1981
1981
|
if (!vn(e)) return !1;
|
|
1982
1982
|
if (t) {
|
|
1983
|
-
const r =
|
|
1983
|
+
const r = Kt(e.schema), o = Cn(e), s = e.tr, i = o.map.cellsInRect(n == "column" ? {
|
|
1984
1984
|
left: o.left,
|
|
1985
1985
|
top: 0,
|
|
1986
1986
|
right: o.right,
|
|
@@ -2011,11 +2011,11 @@ function rn(n, e, t) {
|
|
|
2011
2011
|
}
|
|
2012
2012
|
return !0;
|
|
2013
2013
|
}
|
|
2014
|
-
function
|
|
2014
|
+
function Ut(n, e) {
|
|
2015
2015
|
return e = e || { useDeprecatedLogic: !1 }, e.useDeprecatedLogic ? tr(n) : function(t, r) {
|
|
2016
2016
|
if (!vn(t)) return !1;
|
|
2017
2017
|
if (r) {
|
|
2018
|
-
const o =
|
|
2018
|
+
const o = Kt(t.schema), s = Cn(t), i = t.tr, l = rn("row", s, o), a = rn("column", s, o), d = (n === "column" ? l : n === "row" && a) ? 1 : 0, p = n == "column" ? {
|
|
2019
2019
|
left: 0,
|
|
2020
2020
|
top: d,
|
|
2021
2021
|
right: 1,
|
|
@@ -2026,22 +2026,22 @@ function Kt(n, e) {
|
|
|
2026
2026
|
right: s.map.width,
|
|
2027
2027
|
bottom: 1
|
|
2028
2028
|
} : s, b = n == "column" ? a ? o.cell : o.header_cell : n == "row" ? l ? o.cell : o.header_cell : o.cell;
|
|
2029
|
-
s.map.cellsInRect(p).forEach((
|
|
2030
|
-
const
|
|
2031
|
-
k && i.setNodeMarkup(
|
|
2029
|
+
s.map.cellsInRect(p).forEach((T) => {
|
|
2030
|
+
const m = T + s.tableStart, k = i.doc.nodeAt(m);
|
|
2031
|
+
k && i.setNodeMarkup(m, b, k.attrs);
|
|
2032
2032
|
}), r(i);
|
|
2033
2033
|
}
|
|
2034
2034
|
return !0;
|
|
2035
2035
|
};
|
|
2036
2036
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2037
|
+
Ut("row", { useDeprecatedLogic: !0 });
|
|
2038
|
+
Ut("column", { useDeprecatedLogic: !0 });
|
|
2039
|
+
Ut("cell", { useDeprecatedLogic: !0 });
|
|
2040
2040
|
function ht(n, e) {
|
|
2041
2041
|
const t = n.selection;
|
|
2042
2042
|
if (!(t instanceof Ie)) return !1;
|
|
2043
2043
|
if (e) {
|
|
2044
|
-
const r = n.tr, o =
|
|
2044
|
+
const r = n.tr, o = Kt(n.schema).cell.createAndFill().content;
|
|
2045
2045
|
t.forEachCell((s, i) => {
|
|
2046
2046
|
s.content.eq(o) || r.replace(r.mapping.map(i + 1), r.mapping.map(i + s.nodeSize - 1), new X(o, 0, 0));
|
|
2047
2047
|
}), r.docChanged && e(r);
|
|
@@ -2111,47 +2111,54 @@ function Nn(n, e, t) {
|
|
|
2111
2111
|
}
|
|
2112
2112
|
new Wt("tableColumnResizing");
|
|
2113
2113
|
function nr(n) {
|
|
2114
|
-
|
|
2114
|
+
var m, k;
|
|
2115
|
+
const e = H(null), t = H(null), [r, o] = D(!1), [s, i] = D(!1), [l, a] = D(!0), d = H(!1), p = H(n);
|
|
2115
2116
|
p.current = n;
|
|
2116
|
-
const b = E((
|
|
2117
|
+
const b = E((y, S) => {
|
|
2117
2118
|
if (!(d.current || !t.current)) {
|
|
2118
|
-
if (
|
|
2119
|
-
const
|
|
2120
|
-
if (
|
|
2121
|
-
t.current.setJSON(
|
|
2119
|
+
if (S !== void 0) {
|
|
2120
|
+
const u = JSON.stringify(t.current.getJSON()), h = JSON.stringify(S);
|
|
2121
|
+
if (u === h) return;
|
|
2122
|
+
t.current.setJSON(S);
|
|
2122
2123
|
return;
|
|
2123
2124
|
}
|
|
2124
|
-
if (
|
|
2125
|
-
if (
|
|
2126
|
-
t.current.setContent(
|
|
2125
|
+
if (y !== void 0) {
|
|
2126
|
+
if (y === t.current.getHTML()) return;
|
|
2127
|
+
t.current.setContent(y);
|
|
2127
2128
|
}
|
|
2128
2129
|
}
|
|
2129
2130
|
}, []);
|
|
2130
|
-
|
|
2131
|
-
var
|
|
2132
|
-
const
|
|
2133
|
-
if (!
|
|
2134
|
-
const
|
|
2135
|
-
return t.current =
|
|
2136
|
-
var
|
|
2137
|
-
a(
|
|
2131
|
+
_(() => {
|
|
2132
|
+
var u, h;
|
|
2133
|
+
const y = e.current;
|
|
2134
|
+
if (!y) return;
|
|
2135
|
+
const S = Tn.create(y, p.current.config);
|
|
2136
|
+
return t.current = S, a(S.isEmpty()), S.on("update", ({ html: x }) => {
|
|
2137
|
+
var w, f;
|
|
2138
|
+
a(S.isEmpty()), d.current = !0, (f = (w = p.current).onUpdate) == null || f.call(w, x, S.getJSON()), Promise.resolve().then(() => {
|
|
2138
2139
|
d.current = !1;
|
|
2139
2140
|
});
|
|
2140
|
-
}),
|
|
2141
|
-
var
|
|
2142
|
-
i(!0), (
|
|
2143
|
-
}),
|
|
2144
|
-
var
|
|
2145
|
-
i(!1), (
|
|
2146
|
-
}), o(!0), (
|
|
2147
|
-
|
|
2141
|
+
}), S.on("focus", ({ event: x }) => {
|
|
2142
|
+
var w, f;
|
|
2143
|
+
i(!0), (f = (w = p.current).onFocus) == null || f.call(w, x);
|
|
2144
|
+
}), S.on("blur", ({ event: x }) => {
|
|
2145
|
+
var w, f;
|
|
2146
|
+
i(!1), (f = (w = p.current).onBlur) == null || f.call(w, x);
|
|
2147
|
+
}), o(!0), (h = (u = p.current).onReady) == null || h.call(u, S), () => {
|
|
2148
|
+
S.destroy(), t.current = null, o(!1);
|
|
2148
2149
|
};
|
|
2149
|
-
}, []),
|
|
2150
|
-
const
|
|
2151
|
-
|
|
2152
|
-
}, [n.config.readonly, n.config.disabled]),
|
|
2150
|
+
}, []), _(() => {
|
|
2151
|
+
const y = t.current;
|
|
2152
|
+
y && n.config.readonly !== void 0 && y.setReadonly(n.config.readonly);
|
|
2153
|
+
}, [n.config.readonly, n.config.disabled]), _(() => {
|
|
2153
2154
|
n.config.locale && Ve.getInstance().setLocale(n.config.locale);
|
|
2154
|
-
}, [n.config.locale])
|
|
2155
|
+
}, [n.config.locale]);
|
|
2156
|
+
const T = H((m = n.config.license) == null ? void 0 : m.key);
|
|
2157
|
+
return _(() => {
|
|
2158
|
+
var S;
|
|
2159
|
+
const y = (S = n.config.license) == null ? void 0 : S.key;
|
|
2160
|
+
y !== T.current && (T.current = y, y && t.current && t.current.updateLicense(n.config.license));
|
|
2161
|
+
}, [(k = n.config.license) == null ? void 0 : k.key]), {
|
|
2155
2162
|
manager: t.current,
|
|
2156
2163
|
isReady: r,
|
|
2157
2164
|
isFocused: s,
|
|
@@ -2164,15 +2171,15 @@ function rr(n) {
|
|
|
2164
2171
|
const [e, t] = D({}), [r, o] = D({}), s = E(async () => {
|
|
2165
2172
|
if (!n) return;
|
|
2166
2173
|
const i = n.getEditor(), l = {}, a = {};
|
|
2167
|
-
for (const [
|
|
2168
|
-
|
|
2174
|
+
for (const [T, m] of Object.entries(_t))
|
|
2175
|
+
m.isActive && (l[T] = m.isActive(i)), m.isDisabled && (a[T] = m.isDisabled(i));
|
|
2169
2176
|
const d = In(), p = d === "valid" || d === "expiring_soon", b = await n.hasSnapshots();
|
|
2170
2177
|
if (a.compare = !b || !p, !p)
|
|
2171
|
-
for (const [
|
|
2172
|
-
|
|
2178
|
+
for (const [T, m] of Object.entries(_t))
|
|
2179
|
+
m.requiredTier && T !== "compare" && (a[T] = !0);
|
|
2173
2180
|
t(l), o(a);
|
|
2174
2181
|
}, [n]);
|
|
2175
|
-
return
|
|
2182
|
+
return _(() => {
|
|
2176
2183
|
if (n)
|
|
2177
2184
|
return n.on("selectionUpdate", s), n.on("update", s), n.on("transaction", s), n.on("snapshot-created", s), s(), () => {
|
|
2178
2185
|
n.off("selectionUpdate", s), n.off("update", s), n.off("transaction", s), n.off("snapshot-created", s);
|
|
@@ -2185,7 +2192,7 @@ function rr(n) {
|
|
|
2185
2192
|
}
|
|
2186
2193
|
function be() {
|
|
2187
2194
|
const n = Ve.getInstance(), [e, t] = D(0);
|
|
2188
|
-
|
|
2195
|
+
_(() => n.onChange(() => {
|
|
2189
2196
|
t((s) => s + 1);
|
|
2190
2197
|
}), [n]);
|
|
2191
2198
|
function r(o, s) {
|
|
@@ -2251,62 +2258,62 @@ const sr = ({
|
|
|
2251
2258
|
onCancel: l,
|
|
2252
2259
|
onClose: a
|
|
2253
2260
|
}) => {
|
|
2254
|
-
const { t: d } = be(), [p, b] = D(o || ""), [
|
|
2261
|
+
const { t: d } = be(), [p, b] = D(o || ""), [T, m] = D(!1), k = H(null), [y, S] = D(null), [u, h] = D(""), x = () => {
|
|
2255
2262
|
if (t && r)
|
|
2256
2263
|
try {
|
|
2257
|
-
const { from:
|
|
2264
|
+
const { from: C, to: A } = r, O = t.view.coordsAtPos(C), z = t.view.coordsAtPos(A);
|
|
2258
2265
|
if (O && z) {
|
|
2259
|
-
|
|
2266
|
+
S(new DOMRect(O.left, O.top, z.left - O.left, O.bottom - O.top));
|
|
2260
2267
|
return;
|
|
2261
2268
|
}
|
|
2262
2269
|
} catch {
|
|
2263
2270
|
}
|
|
2264
|
-
|
|
2271
|
+
S(e || null);
|
|
2265
2272
|
};
|
|
2266
|
-
|
|
2267
|
-
const
|
|
2268
|
-
n &&
|
|
2273
|
+
_(() => {
|
|
2274
|
+
const C = () => {
|
|
2275
|
+
n && x();
|
|
2269
2276
|
};
|
|
2270
|
-
return window.addEventListener("scroll",
|
|
2271
|
-
window.removeEventListener("scroll",
|
|
2277
|
+
return window.addEventListener("scroll", C, !0), window.addEventListener("resize", C), () => {
|
|
2278
|
+
window.removeEventListener("scroll", C, !0), window.removeEventListener("resize", C);
|
|
2272
2279
|
};
|
|
2273
|
-
}, [n, t, r, e]),
|
|
2274
|
-
n && (b(o || ""), h(""),
|
|
2275
|
-
var
|
|
2276
|
-
(
|
|
2280
|
+
}, [n, t, r, e]), _(() => {
|
|
2281
|
+
n && (b(o || ""), h(""), x(), setTimeout(() => {
|
|
2282
|
+
var C, A;
|
|
2283
|
+
(C = k.current) == null || C.focus(), (A = k.current) == null || A.select();
|
|
2277
2284
|
}, 0));
|
|
2278
2285
|
}, [n]);
|
|
2279
2286
|
const w = _e(() => {
|
|
2280
|
-
const
|
|
2281
|
-
if (!
|
|
2287
|
+
const C = y;
|
|
2288
|
+
if (!C) return {};
|
|
2282
2289
|
const A = 180, O = 8, z = window.innerHeight, G = window.innerWidth;
|
|
2283
|
-
let J =
|
|
2284
|
-
J + A > z && (J =
|
|
2285
|
-
let W =
|
|
2286
|
-
const
|
|
2287
|
-
return W +
|
|
2288
|
-
}, [
|
|
2290
|
+
let J = C.bottom + O, K = !1;
|
|
2291
|
+
J + A > z && (J = C.top - A - O, K = !0), m(K);
|
|
2292
|
+
let W = C.left + C.width / 2;
|
|
2293
|
+
const B = 320;
|
|
2294
|
+
return W + B / 2 > G && (W = G - B / 2 - 16), W < B / 2 + 16 && (W = B / 2 + 16), { top: `${J}px`, left: `${W}px` };
|
|
2295
|
+
}, [y]), f = (C) => {
|
|
2289
2296
|
try {
|
|
2290
|
-
const A = new URL(
|
|
2297
|
+
const A = new URL(C);
|
|
2291
2298
|
return A.protocol === "http:" || A.protocol === "https:";
|
|
2292
2299
|
} catch {
|
|
2293
2300
|
return !1;
|
|
2294
2301
|
}
|
|
2295
|
-
},
|
|
2296
|
-
const
|
|
2297
|
-
if (s &&
|
|
2302
|
+
}, N = () => {
|
|
2303
|
+
const C = p.trim();
|
|
2304
|
+
if (s && C === "") {
|
|
2298
2305
|
i(""), a();
|
|
2299
2306
|
return;
|
|
2300
2307
|
}
|
|
2301
|
-
if (!
|
|
2308
|
+
if (!C) {
|
|
2302
2309
|
h(d("link.urlRequired"));
|
|
2303
2310
|
return;
|
|
2304
2311
|
}
|
|
2305
|
-
if (!
|
|
2312
|
+
if (!f(C)) {
|
|
2306
2313
|
h(d("link.invalidUrl"));
|
|
2307
2314
|
return;
|
|
2308
2315
|
}
|
|
2309
|
-
i(
|
|
2316
|
+
i(C), a();
|
|
2310
2317
|
}, $ = () => {
|
|
2311
2318
|
i(""), a();
|
|
2312
2319
|
}, P = () => {
|
|
@@ -2316,25 +2323,25 @@ const sr = ({
|
|
|
2316
2323
|
"div",
|
|
2317
2324
|
{
|
|
2318
2325
|
style: { position: "fixed", top: 0, left: 0, right: 0, bottom: 0, zIndex: 9998, background: "transparent" },
|
|
2319
|
-
onMouseDown: (
|
|
2320
|
-
|
|
2326
|
+
onMouseDown: (C) => {
|
|
2327
|
+
C.target === C.currentTarget && P();
|
|
2321
2328
|
},
|
|
2322
|
-
children: /* @__PURE__ */
|
|
2329
|
+
children: /* @__PURE__ */ v(
|
|
2323
2330
|
"div",
|
|
2324
2331
|
{
|
|
2325
|
-
className: `tp-link-popover${
|
|
2332
|
+
className: `tp-link-popover${T ? " is-above" : ""}`,
|
|
2326
2333
|
style: w,
|
|
2327
|
-
onMouseDown: (
|
|
2328
|
-
onKeyDown: (
|
|
2329
|
-
|
|
2334
|
+
onMouseDown: (C) => C.stopPropagation(),
|
|
2335
|
+
onKeyDown: (C) => {
|
|
2336
|
+
C.key === "Enter" ? (C.preventDefault(), N()) : C.key === "Escape" && (C.preventDefault(), P());
|
|
2330
2337
|
},
|
|
2331
2338
|
children: [
|
|
2332
2339
|
/* @__PURE__ */ c("div", { className: "tp-popover-arrow" }),
|
|
2333
|
-
/* @__PURE__ */
|
|
2340
|
+
/* @__PURE__ */ v("div", { className: "tp-popover-content", children: [
|
|
2334
2341
|
/* @__PURE__ */ c("div", { className: "tp-popover-header", children: /* @__PURE__ */ c("span", { className: "tp-popover-title", children: d(s ? "link.editLink" : "link.insertLink") }) }),
|
|
2335
|
-
/* @__PURE__ */
|
|
2342
|
+
/* @__PURE__ */ v("div", { className: "tp-popover-body", children: [
|
|
2336
2343
|
/* @__PURE__ */ c("label", { className: "tp-popover-label", children: d("link.url") }),
|
|
2337
|
-
/* @__PURE__ */
|
|
2344
|
+
/* @__PURE__ */ v("div", { className: "tp-popover-input-row", children: [
|
|
2338
2345
|
/* @__PURE__ */ c(
|
|
2339
2346
|
"input",
|
|
2340
2347
|
{
|
|
@@ -2343,13 +2350,13 @@ const sr = ({
|
|
|
2343
2350
|
className: `tp-popover-input${u ? " is-error" : ""}`,
|
|
2344
2351
|
value: p,
|
|
2345
2352
|
placeholder: d("link.url"),
|
|
2346
|
-
onChange: (
|
|
2347
|
-
onKeyDown: (
|
|
2348
|
-
|
|
2353
|
+
onChange: (C) => b(C.target.value),
|
|
2354
|
+
onKeyDown: (C) => {
|
|
2355
|
+
C.key === "Enter" ? (C.preventDefault(), N()) : C.key === "Escape" && (C.preventDefault(), P());
|
|
2349
2356
|
}
|
|
2350
2357
|
}
|
|
2351
2358
|
),
|
|
2352
|
-
/* @__PURE__ */ c("button", { className: "tp-popover-btn-confirm", onClick:
|
|
2359
|
+
/* @__PURE__ */ c("button", { className: "tp-popover-btn-confirm", onClick: N, children: d("common.confirm") }),
|
|
2353
2360
|
s && /* @__PURE__ */ c("button", { className: "tp-popover-btn-unlink", onClick: $, children: d("link.unlink") })
|
|
2354
2361
|
] }),
|
|
2355
2362
|
u && /* @__PURE__ */ c("div", { className: "tp-link-error-message", children: u })
|
|
@@ -2361,27 +2368,27 @@ const sr = ({
|
|
|
2361
2368
|
}
|
|
2362
2369
|
) : null;
|
|
2363
2370
|
}, ir = "#b4d5fe", lr = ({ def: n, editor: e, active: t, disabled: r, onCustomClick: o }) => {
|
|
2364
|
-
const { t: s } = be(), [i, l] = D(!1), a =
|
|
2371
|
+
const { t: s } = be(), [i, l] = D(!1), a = H(null), d = H(null), p = H(""), b = H(!1), T = (u) => {
|
|
2365
2372
|
var h;
|
|
2366
2373
|
if (u.preventDefault(), n.name === "link") {
|
|
2367
|
-
const { from:
|
|
2368
|
-
if (
|
|
2369
|
-
if (a.current = { from:
|
|
2370
|
-
const
|
|
2371
|
-
p.current = ((h =
|
|
2374
|
+
const { from: x, to: w } = e.state.selection;
|
|
2375
|
+
if (x !== w || e.isActive("link")) {
|
|
2376
|
+
if (a.current = { from: x, to: w }, e.isActive("link")) {
|
|
2377
|
+
const f = e.state.selection.$head.marks().find((N) => N.type.name === "link");
|
|
2378
|
+
p.current = ((h = f == null ? void 0 : f.attrs) == null ? void 0 : h.href) || "", b.current = !0;
|
|
2372
2379
|
} else
|
|
2373
2380
|
p.current = "", b.current = !1;
|
|
2374
2381
|
if (!e.isActive("link")) {
|
|
2375
|
-
const
|
|
2376
|
-
if (
|
|
2377
|
-
const $ =
|
|
2382
|
+
const f = window.getSelection();
|
|
2383
|
+
if (f && f.rangeCount > 0) {
|
|
2384
|
+
const $ = f.getRangeAt(0).getBoundingClientRect();
|
|
2378
2385
|
$.width > 0 && $.height > 0 && (d.current = $);
|
|
2379
2386
|
}
|
|
2380
2387
|
}
|
|
2381
2388
|
}
|
|
2382
2389
|
}
|
|
2383
|
-
},
|
|
2384
|
-
var h,
|
|
2390
|
+
}, m = () => {
|
|
2391
|
+
var h, x;
|
|
2385
2392
|
const u = n.name;
|
|
2386
2393
|
if (u === "getHTML" || u === "getJSON" || u === "importWord" || u === "importMarkdown" || u === "exportWord" || u === "exportMarkdown" || u === "snapshot" || u === "compare" || u === "fullscreen") {
|
|
2387
2394
|
o == null || o(u);
|
|
@@ -2390,13 +2397,13 @@ const sr = ({
|
|
|
2390
2397
|
if (u === "link") {
|
|
2391
2398
|
if (e.isActive("link")) {
|
|
2392
2399
|
if (!a.current) {
|
|
2393
|
-
const { from:
|
|
2394
|
-
a.current = { from:
|
|
2400
|
+
const { from: f, to: N } = e.state.selection;
|
|
2401
|
+
a.current = { from: f, to: N };
|
|
2395
2402
|
}
|
|
2396
|
-
const w = e.state.selection.$head.marks().find((
|
|
2403
|
+
const w = e.state.selection.$head.marks().find((f) => f.type.name === "link");
|
|
2397
2404
|
if (p.current = ((h = w == null ? void 0 : w.attrs) == null ? void 0 : h.href) || "", b.current = !0, !d.current && a.current)
|
|
2398
2405
|
try {
|
|
2399
|
-
const { from:
|
|
2406
|
+
const { from: f, to: N } = a.current, $ = e.view.coordsAtPos(f), P = e.view.coordsAtPos(N);
|
|
2400
2407
|
$ && P && (d.current = new DOMRect(
|
|
2401
2408
|
$.left,
|
|
2402
2409
|
$.top,
|
|
@@ -2409,51 +2416,51 @@ const sr = ({
|
|
|
2409
2416
|
return;
|
|
2410
2417
|
}
|
|
2411
2418
|
if (!a.current) {
|
|
2412
|
-
const { from: w, to:
|
|
2413
|
-
if (w ===
|
|
2414
|
-
a.current = { from: w, to:
|
|
2419
|
+
const { from: w, to: f } = e.state.selection;
|
|
2420
|
+
if (w === f) return;
|
|
2421
|
+
a.current = { from: w, to: f };
|
|
2415
2422
|
}
|
|
2416
2423
|
if (p.current = "", b.current = !1, !d.current && a.current)
|
|
2417
2424
|
try {
|
|
2418
|
-
const { from: w, to:
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
$.left -
|
|
2423
|
-
|
|
2425
|
+
const { from: w, to: f } = a.current, N = e.view.coordsAtPos(w), $ = e.view.coordsAtPos(f);
|
|
2426
|
+
N && $ && (d.current = new DOMRect(
|
|
2427
|
+
N.left,
|
|
2428
|
+
N.top,
|
|
2429
|
+
$.left - N.left,
|
|
2430
|
+
N.bottom - N.top
|
|
2424
2431
|
));
|
|
2425
2432
|
} catch {
|
|
2426
2433
|
}
|
|
2427
2434
|
if (a.current) {
|
|
2428
|
-
const { from: w, to:
|
|
2429
|
-
e.chain().focus().setTextSelection({ from: w, to:
|
|
2435
|
+
const { from: w, to: f } = a.current;
|
|
2436
|
+
e.chain().focus().setTextSelection({ from: w, to: f }).setHighlight({ color: ir }).run();
|
|
2430
2437
|
}
|
|
2431
2438
|
l(!0);
|
|
2432
2439
|
return;
|
|
2433
2440
|
}
|
|
2434
|
-
(
|
|
2441
|
+
(x = n.command) == null || x.call(n, e);
|
|
2435
2442
|
}, k = (u) => {
|
|
2436
2443
|
if (a.current) {
|
|
2437
|
-
const { from: h, to:
|
|
2444
|
+
const { from: h, to: x } = a.current, w = e.chain().focus().setTextSelection({ from: h, to: x }).unsetHighlight();
|
|
2438
2445
|
u ? w.setLink({ href: u }).run() : w.unsetLink().run();
|
|
2439
2446
|
}
|
|
2440
2447
|
a.current = null, d.current = null, p.current = "", b.current = !1;
|
|
2441
|
-
},
|
|
2448
|
+
}, y = () => {
|
|
2442
2449
|
if (a.current) {
|
|
2443
2450
|
const { from: u, to: h } = a.current;
|
|
2444
2451
|
e.chain().focus().setTextSelection({ from: u, to: h }).unsetHighlight().run();
|
|
2445
2452
|
}
|
|
2446
2453
|
a.current = null, d.current = null, p.current = "", b.current = !1;
|
|
2447
|
-
},
|
|
2448
|
-
return /* @__PURE__ */
|
|
2454
|
+
}, S = n.name === "getHTML" || n.name === "getJSON";
|
|
2455
|
+
return /* @__PURE__ */ v(Ft, { children: [
|
|
2449
2456
|
/* @__PURE__ */ c(
|
|
2450
2457
|
"button",
|
|
2451
2458
|
{
|
|
2452
|
-
className: `tp-toolbar-btn${t ? " is-active" : ""}${
|
|
2459
|
+
className: `tp-toolbar-btn${t ? " is-active" : ""}${S ? " is-text-btn" : ""}`,
|
|
2453
2460
|
disabled: r,
|
|
2454
2461
|
title: s(n.titleKey),
|
|
2455
|
-
onMouseDown:
|
|
2456
|
-
onClick:
|
|
2462
|
+
onMouseDown: T,
|
|
2463
|
+
onClick: m,
|
|
2457
2464
|
children: n.name === "getHTML" ? /* @__PURE__ */ c("span", { className: "tp-toolbar-text", children: "HTML" }) : n.name === "getJSON" ? /* @__PURE__ */ c("span", { className: "tp-toolbar-text", children: "JSON" }) : /* @__PURE__ */ c("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: Be(n.name) } })
|
|
2458
2465
|
}
|
|
2459
2466
|
),
|
|
@@ -2467,7 +2474,7 @@ const sr = ({
|
|
|
2467
2474
|
initialUrl: p.current,
|
|
2468
2475
|
isEditing: b.current,
|
|
2469
2476
|
onConfirm: k,
|
|
2470
|
-
onCancel:
|
|
2477
|
+
onCancel: y,
|
|
2471
2478
|
onClose: () => l(!1)
|
|
2472
2479
|
}
|
|
2473
2480
|
)
|
|
@@ -2482,36 +2489,36 @@ const sr = ({
|
|
|
2482
2489
|
KaiTi: ["KaiTi", "楷体"],
|
|
2483
2490
|
楷体: ["KaiTi", "楷体"]
|
|
2484
2491
|
}, cr = ({ def: n, editor: e, active: t, disabled: r, onCustomClick: o }) => {
|
|
2485
|
-
var
|
|
2486
|
-
const { t: s } = be(), [i, l] = D(!1), [a, d] = D(0), p =
|
|
2492
|
+
var S;
|
|
2493
|
+
const { t: s } = be(), [i, l] = D(!1), [a, d] = D(0), p = H(null), b = _e(() => {
|
|
2487
2494
|
var u;
|
|
2488
2495
|
return (u = n.getCurrentValue) == null ? void 0 : u.call(n, e);
|
|
2489
|
-
}, [a, n, e]),
|
|
2490
|
-
const h = String(b),
|
|
2496
|
+
}, [a, n, e]), T = (u) => {
|
|
2497
|
+
const h = String(b), x = String(u);
|
|
2491
2498
|
if (n.name === "fontFamily") {
|
|
2492
|
-
const w = on[h],
|
|
2493
|
-
if (w) return w.includes(
|
|
2494
|
-
if (
|
|
2499
|
+
const w = on[h], f = on[x];
|
|
2500
|
+
if (w) return w.includes(x);
|
|
2501
|
+
if (f) return f.includes(h);
|
|
2495
2502
|
}
|
|
2496
|
-
return h ===
|
|
2497
|
-
},
|
|
2503
|
+
return h === x;
|
|
2504
|
+
}, m = (u) => {
|
|
2498
2505
|
const h = Number(u);
|
|
2499
2506
|
return h === 0 ? "tp-heading-preview-paragraph" : h >= 1 && h <= 6 ? `tp-heading-preview-h${h}` : "";
|
|
2500
2507
|
}, k = () => {
|
|
2501
2508
|
r || (l(!i), i || d((u) => u + 1));
|
|
2502
|
-
},
|
|
2509
|
+
}, y = (u) => {
|
|
2503
2510
|
var h;
|
|
2504
2511
|
n.isActionMenu ? o == null || o(String(u)) : (h = n.command) == null || h.call(n, e, u), l(!1);
|
|
2505
2512
|
};
|
|
2506
|
-
return
|
|
2507
|
-
const u = (
|
|
2508
|
-
p.current && !p.current.contains(
|
|
2509
|
-
}, h = () => d((
|
|
2513
|
+
return _(() => {
|
|
2514
|
+
const u = (x) => {
|
|
2515
|
+
p.current && !p.current.contains(x.target) && l(!1);
|
|
2516
|
+
}, h = () => d((x) => x + 1);
|
|
2510
2517
|
return document.addEventListener("pointerdown", u), e.on("transaction", h), () => {
|
|
2511
2518
|
document.removeEventListener("pointerdown", u), e.off("transaction", h);
|
|
2512
2519
|
};
|
|
2513
|
-
}, [e]), /* @__PURE__ */
|
|
2514
|
-
/* @__PURE__ */
|
|
2520
|
+
}, [e]), /* @__PURE__ */ v("div", { ref: p, className: "tp-toolbar-dropdown", children: [
|
|
2521
|
+
/* @__PURE__ */ v(
|
|
2515
2522
|
"button",
|
|
2516
2523
|
{
|
|
2517
2524
|
className: `tp-toolbar-dropdown-trigger${t ? " is-active" : ""}${r ? " is-disabled" : ""}`,
|
|
@@ -2526,12 +2533,12 @@ const sr = ({
|
|
|
2526
2533
|
]
|
|
2527
2534
|
}
|
|
2528
2535
|
),
|
|
2529
|
-
i && /* @__PURE__ */ c("div", { className: "tp-toolbar-dropdown-menu", children: (
|
|
2536
|
+
i && /* @__PURE__ */ c("div", { className: "tp-toolbar-dropdown-menu", children: (S = n.options) == null ? void 0 : S.map((u) => /* @__PURE__ */ c(
|
|
2530
2537
|
"button",
|
|
2531
2538
|
{
|
|
2532
|
-
className: `tp-toolbar-dropdown-item${
|
|
2539
|
+
className: `tp-toolbar-dropdown-item${T(u.value) ? " is-active" : ""}${n.name === "heading" ? " " + m(u.value) : ""}`,
|
|
2533
2540
|
onMouseDown: (h) => h.preventDefault(),
|
|
2534
|
-
onClick: () =>
|
|
2541
|
+
onClick: () => y(u.value),
|
|
2535
2542
|
children: u.labelKey ? s(u.labelKey) : u.label
|
|
2536
2543
|
},
|
|
2537
2544
|
String(u.value)
|
|
@@ -2599,43 +2606,43 @@ const sr = ({
|
|
|
2599
2606
|
"#073763",
|
|
2600
2607
|
"#7f6000"
|
|
2601
2608
|
], dr = ["#ff0000", "#ff5e00", "#ff9900", "#ffff00", "#00ff00", "#00a8a8", "#00ffff", "#0000ff", "#5f00ff", "#9900ff"], ur = ({ def: n, editor: e, disabled: t }) => {
|
|
2602
|
-
const { t: r } = be(), [o, s] = D(!1), i =
|
|
2603
|
-
const
|
|
2604
|
-
a((
|
|
2609
|
+
const { t: r } = be(), [o, s] = D(!1), i = H(null), [l, a] = D(""), [d, p] = D(""), b = n.name === "color", T = b ? l : d, m = () => {
|
|
2610
|
+
const S = e.getAttributes("textStyle");
|
|
2611
|
+
a((S == null ? void 0 : S.color) || "");
|
|
2605
2612
|
const u = e.getAttributes("highlight");
|
|
2606
2613
|
p((u == null ? void 0 : u.color) || "");
|
|
2607
2614
|
};
|
|
2608
|
-
|
|
2609
|
-
const
|
|
2615
|
+
_(() => {
|
|
2616
|
+
const S = (u) => {
|
|
2610
2617
|
i.current && !i.current.contains(u.target) && s(!1);
|
|
2611
2618
|
};
|
|
2612
|
-
return document.addEventListener("pointerdown",
|
|
2613
|
-
document.removeEventListener("pointerdown",
|
|
2619
|
+
return document.addEventListener("pointerdown", S), e.on("transaction", m), e.on("selectionUpdate", m), m(), () => {
|
|
2620
|
+
document.removeEventListener("pointerdown", S), e.off("transaction", m), e.off("selectionUpdate", m);
|
|
2614
2621
|
};
|
|
2615
2622
|
}, [e]);
|
|
2616
|
-
const k = (
|
|
2623
|
+
const k = (S) => {
|
|
2617
2624
|
var u;
|
|
2618
|
-
(u = n.command) == null || u.call(n, e,
|
|
2619
|
-
},
|
|
2620
|
-
var
|
|
2621
|
-
(
|
|
2625
|
+
(u = n.command) == null || u.call(n, e, S), setTimeout(m, 0), s(!1);
|
|
2626
|
+
}, y = () => {
|
|
2627
|
+
var S;
|
|
2628
|
+
(S = n.command) == null || S.call(n, e, void 0), p(""), s(!1);
|
|
2622
2629
|
};
|
|
2623
|
-
return /* @__PURE__ */
|
|
2624
|
-
/* @__PURE__ */
|
|
2630
|
+
return /* @__PURE__ */ v("div", { ref: i, className: "tp-toolbar-dropdown", children: [
|
|
2631
|
+
/* @__PURE__ */ v(
|
|
2625
2632
|
"button",
|
|
2626
2633
|
{
|
|
2627
2634
|
className: `tp-toolbar-dropdown-trigger${t ? " is-disabled" : ""}`,
|
|
2628
2635
|
title: r(n.titleKey),
|
|
2629
2636
|
disabled: t,
|
|
2630
|
-
onMouseDown: (
|
|
2637
|
+
onMouseDown: (S) => S.preventDefault(),
|
|
2631
2638
|
onClick: () => {
|
|
2632
2639
|
t || s(!o);
|
|
2633
2640
|
},
|
|
2634
2641
|
children: [
|
|
2635
|
-
/* @__PURE__ */ c("span", { className: b ? "tp-color-picker-icon" : "tp-bgcolor-picker-icon", children: b ? /* @__PURE__ */
|
|
2642
|
+
/* @__PURE__ */ c("span", { className: b ? "tp-color-picker-icon" : "tp-bgcolor-picker-icon", children: b ? /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2636
2643
|
/* @__PURE__ */ c("text", { x: "4", y: "17", fontSize: "24", fill: "currentColor", stroke: "none", fontFamily: "serif", fontWeight: "bold", children: "A" }),
|
|
2637
2644
|
/* @__PURE__ */ c("line", { x1: "4", y1: "22", x2: "20", y2: "22", strokeWidth: "5", stroke: l || "#000000" })
|
|
2638
|
-
] }) : /* @__PURE__ */
|
|
2645
|
+
] }) : /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2639
2646
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", fill: d || "transparent" }),
|
|
2640
2647
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2641
2648
|
/* @__PURE__ */ c("text", { x: "6", y: "17", fontSize: "16", fill: "currentColor", stroke: "none", fontFamily: "serif", fontWeight: "bold", children: "A" })
|
|
@@ -2644,28 +2651,28 @@ const sr = ({
|
|
|
2644
2651
|
]
|
|
2645
2652
|
}
|
|
2646
2653
|
),
|
|
2647
|
-
o && /* @__PURE__ */
|
|
2648
|
-
/* @__PURE__ */ c("button", { className: "tp-color-default-btn", onMouseDown: (
|
|
2649
|
-
/* @__PURE__ */ c("div", { className: "tp-color-grid tp-theme-colors", children: ar.map((
|
|
2654
|
+
o && /* @__PURE__ */ v("div", { className: "tp-color-picker-panel", children: [
|
|
2655
|
+
/* @__PURE__ */ c("button", { className: "tp-color-default-btn", onMouseDown: (S) => S.preventDefault(), onClick: y, children: r("common.default") }),
|
|
2656
|
+
/* @__PURE__ */ c("div", { className: "tp-color-grid tp-theme-colors", children: ar.map((S, u) => /* @__PURE__ */ c(
|
|
2650
2657
|
"button",
|
|
2651
2658
|
{
|
|
2652
|
-
className: `tp-color-swatch${
|
|
2653
|
-
style: { backgroundColor:
|
|
2654
|
-
title:
|
|
2659
|
+
className: `tp-color-swatch${T === S ? " tp-color-swatch-selected" : ""}`,
|
|
2660
|
+
style: { backgroundColor: S },
|
|
2661
|
+
title: S,
|
|
2655
2662
|
onMouseDown: (h) => h.preventDefault(),
|
|
2656
|
-
onClick: () => k(
|
|
2663
|
+
onClick: () => k(S)
|
|
2657
2664
|
},
|
|
2658
2665
|
`theme-${u}`
|
|
2659
2666
|
)) }),
|
|
2660
2667
|
/* @__PURE__ */ c("div", { className: "tp-color-section-label", children: r("common.standardColor") }),
|
|
2661
|
-
/* @__PURE__ */ c("div", { className: "tp-color-grid tp-standard-colors", children: dr.map((
|
|
2668
|
+
/* @__PURE__ */ c("div", { className: "tp-color-grid tp-standard-colors", children: dr.map((S, u) => /* @__PURE__ */ c(
|
|
2662
2669
|
"button",
|
|
2663
2670
|
{
|
|
2664
|
-
className: `tp-color-swatch${
|
|
2665
|
-
style: { backgroundColor:
|
|
2666
|
-
title:
|
|
2671
|
+
className: `tp-color-swatch${T === S ? " tp-color-swatch-selected" : ""}`,
|
|
2672
|
+
style: { backgroundColor: S },
|
|
2673
|
+
title: S,
|
|
2667
2674
|
onMouseDown: (h) => h.preventDefault(),
|
|
2668
|
-
onClick: () => k(
|
|
2675
|
+
onClick: () => k(S)
|
|
2669
2676
|
},
|
|
2670
2677
|
`std-${u}`
|
|
2671
2678
|
)) })
|
|
@@ -2680,82 +2687,82 @@ const sr = ({
|
|
|
2680
2687
|
initialTab: s,
|
|
2681
2688
|
onClose: i
|
|
2682
2689
|
}) => {
|
|
2683
|
-
const { t: l } = be(), [a, d] = D(s || "upload"), [p, b] = D(""), [
|
|
2684
|
-
|
|
2690
|
+
const { t: l } = be(), [a, d] = D(s || "upload"), [p, b] = D(""), [T, m] = D(!1), [k, y] = D(!1), [S, u] = D(0), [h, x] = D(""), w = H(null);
|
|
2691
|
+
_(() => (n ? (b(""), x(""), d(s || "upload"), u(0), document.body.style.overflow = "hidden") : document.body.style.overflow = "", () => {
|
|
2685
2692
|
document.body.style.overflow = "";
|
|
2686
2693
|
}), [n, s]);
|
|
2687
|
-
const
|
|
2694
|
+
const f = (C) => new Promise((A, O) => {
|
|
2688
2695
|
const z = new FileReader();
|
|
2689
|
-
z.onload = () => A(z.result), z.onerror = O, z.readAsDataURL(
|
|
2690
|
-
}),
|
|
2691
|
-
e.chain().focus().setImage({ src:
|
|
2692
|
-
}, $ = async (
|
|
2693
|
-
|
|
2696
|
+
z.onload = () => A(z.result), z.onerror = O, z.readAsDataURL(C);
|
|
2697
|
+
}), N = (C) => {
|
|
2698
|
+
e.chain().focus().setImage({ src: C }).run();
|
|
2699
|
+
}, $ = async (C) => {
|
|
2700
|
+
y(!0), u(0), x("");
|
|
2694
2701
|
try {
|
|
2695
2702
|
let A;
|
|
2696
|
-
o ? A = await o(
|
|
2703
|
+
o ? A = await o(C) : t ? A = await Ln(C, { url: t, headers: r, onProgress: u }) : A = await f(C), N(A), i();
|
|
2697
2704
|
} catch (A) {
|
|
2698
|
-
|
|
2705
|
+
x(A instanceof Error ? A.message : l("imageUpload.uploadFailed"));
|
|
2699
2706
|
} finally {
|
|
2700
|
-
|
|
2707
|
+
y(!1), u(0);
|
|
2701
2708
|
}
|
|
2702
2709
|
}, P = () => {
|
|
2703
|
-
const
|
|
2704
|
-
if (!
|
|
2705
|
-
|
|
2710
|
+
const C = p.trim();
|
|
2711
|
+
if (!C) {
|
|
2712
|
+
x(l("imageUpload.urlRequired"));
|
|
2706
2713
|
return;
|
|
2707
2714
|
}
|
|
2708
2715
|
try {
|
|
2709
|
-
new URL(
|
|
2716
|
+
new URL(C);
|
|
2710
2717
|
} catch {
|
|
2711
|
-
|
|
2718
|
+
x(l("imageUpload.invalidUrl"));
|
|
2712
2719
|
return;
|
|
2713
2720
|
}
|
|
2714
|
-
C
|
|
2721
|
+
N(C), i();
|
|
2715
2722
|
};
|
|
2716
|
-
return n ? /* @__PURE__ */ c("div", { className: "tp-image-upload-overlay", onMouseDown: (
|
|
2717
|
-
|
|
2718
|
-
}, children: /* @__PURE__ */
|
|
2719
|
-
/* @__PURE__ */
|
|
2723
|
+
return n ? /* @__PURE__ */ c("div", { className: "tp-image-upload-overlay", onMouseDown: (C) => {
|
|
2724
|
+
C.target === C.currentTarget && i();
|
|
2725
|
+
}, children: /* @__PURE__ */ v("div", { className: "tp-image-upload-dialog", onMouseDown: (C) => C.stopPropagation(), children: [
|
|
2726
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-header", children: [
|
|
2720
2727
|
/* @__PURE__ */ c("span", { className: "tp-dialog-title", children: l("image.upload") }),
|
|
2721
2728
|
/* @__PURE__ */ c("button", { className: "tp-dialog-close", onClick: i, children: "×" })
|
|
2722
2729
|
] }),
|
|
2723
|
-
/* @__PURE__ */
|
|
2730
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-tabs", children: [
|
|
2724
2731
|
/* @__PURE__ */ c("button", { className: `tp-tab-btn${a === "upload" ? " is-active" : ""}`, onClick: () => d("upload"), children: l("imageUpload.uploadLocal") }),
|
|
2725
2732
|
/* @__PURE__ */ c("button", { className: `tp-tab-btn${a === "url" ? " is-active" : ""}`, onClick: () => d("url"), children: l("imageUpload.inputUrl") })
|
|
2726
2733
|
] }),
|
|
2727
|
-
/* @__PURE__ */
|
|
2728
|
-
a === "upload" && /* @__PURE__ */
|
|
2734
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-body", children: [
|
|
2735
|
+
a === "upload" && /* @__PURE__ */ v("div", { className: "tp-upload-tab", children: [
|
|
2729
2736
|
/* @__PURE__ */ c(
|
|
2730
2737
|
"div",
|
|
2731
2738
|
{
|
|
2732
|
-
className: `tp-dropzone${
|
|
2733
|
-
onDragEnter: (
|
|
2734
|
-
|
|
2739
|
+
className: `tp-dropzone${T ? " is-dragging" : ""}${k ? " is-uploading" : ""}`,
|
|
2740
|
+
onDragEnter: (C) => {
|
|
2741
|
+
C.preventDefault(), m(!0);
|
|
2735
2742
|
},
|
|
2736
|
-
onDragLeave: (
|
|
2737
|
-
|
|
2743
|
+
onDragLeave: (C) => {
|
|
2744
|
+
C.preventDefault(), m(!1);
|
|
2738
2745
|
},
|
|
2739
|
-
onDragOver: (
|
|
2740
|
-
onDrop: (
|
|
2746
|
+
onDragOver: (C) => C.preventDefault(),
|
|
2747
|
+
onDrop: (C) => {
|
|
2741
2748
|
var O, z;
|
|
2742
|
-
|
|
2743
|
-
const A = (z = (O =
|
|
2744
|
-
A != null && A.type.startsWith("image/") ? $(A) :
|
|
2749
|
+
C.preventDefault(), m(!1);
|
|
2750
|
+
const A = (z = (O = C.dataTransfer) == null ? void 0 : O.files) == null ? void 0 : z[0];
|
|
2751
|
+
A != null && A.type.startsWith("image/") ? $(A) : x(l("imageUpload.invalidType"));
|
|
2745
2752
|
},
|
|
2746
2753
|
onClick: () => {
|
|
2747
|
-
var
|
|
2748
|
-
return (
|
|
2754
|
+
var C;
|
|
2755
|
+
return (C = w.current) == null ? void 0 : C.click();
|
|
2749
2756
|
},
|
|
2750
|
-
children: k ? /* @__PURE__ */
|
|
2751
|
-
/* @__PURE__ */ c("div", { className: "tp-progress-bar", children: /* @__PURE__ */ c("div", { className: "tp-progress-fill", style: { width:
|
|
2752
|
-
/* @__PURE__ */
|
|
2757
|
+
children: k ? /* @__PURE__ */ v("div", { className: "tp-upload-progress", children: [
|
|
2758
|
+
/* @__PURE__ */ c("div", { className: "tp-progress-bar", children: /* @__PURE__ */ c("div", { className: "tp-progress-fill", style: { width: S + "%" } }) }),
|
|
2759
|
+
/* @__PURE__ */ v("span", { className: "tp-progress-text", children: [
|
|
2753
2760
|
l("imageUpload.uploading"),
|
|
2754
2761
|
" ",
|
|
2755
|
-
|
|
2762
|
+
S,
|
|
2756
2763
|
"%"
|
|
2757
2764
|
] })
|
|
2758
|
-
] }) : /* @__PURE__ */
|
|
2765
|
+
] }) : /* @__PURE__ */ v("div", { className: "tp-dropzone-content", children: [
|
|
2759
2766
|
/* @__PURE__ */ c("span", { className: "tp-dropzone-icon", children: "📁" }),
|
|
2760
2767
|
/* @__PURE__ */ c("span", { className: "tp-dropzone-text", children: l("imageUpload.selectFile") }),
|
|
2761
2768
|
/* @__PURE__ */ c("span", { className: "tp-dropzone-hint", children: l("imageUpload.dragHint") })
|
|
@@ -2769,17 +2776,17 @@ const sr = ({
|
|
|
2769
2776
|
type: "file",
|
|
2770
2777
|
accept: "image/*",
|
|
2771
2778
|
style: { display: "none" },
|
|
2772
|
-
onChange: (
|
|
2779
|
+
onChange: (C) => {
|
|
2773
2780
|
var O;
|
|
2774
|
-
const A = (O =
|
|
2775
|
-
A && $(A),
|
|
2781
|
+
const A = (O = C.target.files) == null ? void 0 : O[0];
|
|
2782
|
+
A && $(A), C.target.value = "";
|
|
2776
2783
|
}
|
|
2777
2784
|
}
|
|
2778
2785
|
)
|
|
2779
2786
|
] }),
|
|
2780
|
-
a === "url" && /* @__PURE__ */
|
|
2787
|
+
a === "url" && /* @__PURE__ */ v("div", { className: "tp-url-tab", children: [
|
|
2781
2788
|
/* @__PURE__ */ c("label", { className: "tp-input-label", children: l("imageUpload.url") }),
|
|
2782
|
-
/* @__PURE__ */
|
|
2789
|
+
/* @__PURE__ */ v("div", { className: "tp-input-row", children: [
|
|
2783
2790
|
/* @__PURE__ */ c(
|
|
2784
2791
|
"input",
|
|
2785
2792
|
{
|
|
@@ -2787,9 +2794,9 @@ const sr = ({
|
|
|
2787
2794
|
type: "url",
|
|
2788
2795
|
value: p,
|
|
2789
2796
|
placeholder: l("imageUpload.placeholder"),
|
|
2790
|
-
onChange: (
|
|
2791
|
-
onKeyDown: (
|
|
2792
|
-
|
|
2797
|
+
onChange: (C) => b(C.target.value),
|
|
2798
|
+
onKeyDown: (C) => {
|
|
2799
|
+
C.key === "Enter" && P(), C.key === "Escape" && i();
|
|
2793
2800
|
}
|
|
2794
2801
|
}
|
|
2795
2802
|
),
|
|
@@ -2800,25 +2807,25 @@ const sr = ({
|
|
|
2800
2807
|
] })
|
|
2801
2808
|
] }) }) : null;
|
|
2802
2809
|
}, pr = ({ def: n, editor: e, manager: t, active: r, disabled: o }) => {
|
|
2803
|
-
var u, h,
|
|
2804
|
-
const { t: s } = be(), [i, l] = D(!1), [a, d] = D(!1), [p, b] = D("upload"),
|
|
2805
|
-
|
|
2806
|
-
const
|
|
2807
|
-
|
|
2810
|
+
var u, h, x, w;
|
|
2811
|
+
const { t: s } = be(), [i, l] = D(!1), [a, d] = D(!1), [p, b] = D("upload"), T = H(null), m = (u = t == null ? void 0 : t.getConfig().upload) == null ? void 0 : u.url, k = (h = t == null ? void 0 : t.getConfig().upload) == null ? void 0 : h.headers, y = (x = t == null ? void 0 : t.getConfig().upload) == null ? void 0 : x.onUpload;
|
|
2812
|
+
_(() => {
|
|
2813
|
+
const f = (N) => {
|
|
2814
|
+
T.current && !T.current.contains(N.target) && l(!1);
|
|
2808
2815
|
};
|
|
2809
|
-
return document.addEventListener("pointerdown",
|
|
2816
|
+
return document.addEventListener("pointerdown", f), () => document.removeEventListener("pointerdown", f);
|
|
2810
2817
|
}, []);
|
|
2811
|
-
const
|
|
2812
|
-
l(!1),
|
|
2818
|
+
const S = (f) => {
|
|
2819
|
+
l(!1), f === "upload" ? (b("upload"), d(!0)) : f === "url" && (b("url"), d(!0));
|
|
2813
2820
|
};
|
|
2814
|
-
return /* @__PURE__ */
|
|
2815
|
-
/* @__PURE__ */
|
|
2821
|
+
return /* @__PURE__ */ v("div", { ref: T, className: "tp-toolbar-dropdown", children: [
|
|
2822
|
+
/* @__PURE__ */ v(
|
|
2816
2823
|
"button",
|
|
2817
2824
|
{
|
|
2818
2825
|
className: `tp-toolbar-dropdown-trigger${r ? " is-active" : ""}${o ? " is-disabled" : ""}`,
|
|
2819
2826
|
title: s(n.titleKey),
|
|
2820
2827
|
disabled: o,
|
|
2821
|
-
onMouseDown: (
|
|
2828
|
+
onMouseDown: (f) => f.preventDefault(),
|
|
2822
2829
|
onClick: () => {
|
|
2823
2830
|
o || l(!i);
|
|
2824
2831
|
},
|
|
@@ -2828,66 +2835,66 @@ const sr = ({
|
|
|
2828
2835
|
]
|
|
2829
2836
|
}
|
|
2830
2837
|
),
|
|
2831
|
-
i && /* @__PURE__ */ c("div", { className: "tp-toolbar-dropdown-menu", children: (w = n.options) == null ? void 0 : w.map((
|
|
2838
|
+
i && /* @__PURE__ */ c("div", { className: "tp-toolbar-dropdown-menu", children: (w = n.options) == null ? void 0 : w.map((f) => /* @__PURE__ */ c(
|
|
2832
2839
|
"button",
|
|
2833
2840
|
{
|
|
2834
2841
|
className: "tp-toolbar-dropdown-item",
|
|
2835
|
-
onMouseDown: (
|
|
2836
|
-
onClick: () =>
|
|
2837
|
-
children:
|
|
2842
|
+
onMouseDown: (N) => N.preventDefault(),
|
|
2843
|
+
onClick: () => S(f.value),
|
|
2844
|
+
children: f.label
|
|
2838
2845
|
},
|
|
2839
|
-
String(
|
|
2846
|
+
String(f.value)
|
|
2840
2847
|
)) }),
|
|
2841
2848
|
/* @__PURE__ */ c(
|
|
2842
2849
|
hr,
|
|
2843
2850
|
{
|
|
2844
2851
|
visible: a,
|
|
2845
2852
|
editor: e,
|
|
2846
|
-
uploadUrl:
|
|
2853
|
+
uploadUrl: m,
|
|
2847
2854
|
uploadHeaders: k,
|
|
2848
|
-
onUpload:
|
|
2855
|
+
onUpload: y,
|
|
2849
2856
|
initialTab: p,
|
|
2850
2857
|
onClose: () => d(!1)
|
|
2851
2858
|
}
|
|
2852
2859
|
)
|
|
2853
2860
|
] });
|
|
2854
2861
|
}, fr = ({ visible: n, editor: e, onSuccess: t, onCancel: r, onClose: o }) => {
|
|
2855
|
-
const { t: s } = be(), [i, l] = D(""), [a, d] = D(""), p =
|
|
2856
|
-
|
|
2857
|
-
var
|
|
2858
|
-
return (
|
|
2862
|
+
const { t: s } = be(), [i, l] = D(""), [a, d] = D(""), p = H(null);
|
|
2863
|
+
_(() => (n ? (l(""), d(""), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
2864
|
+
var y;
|
|
2865
|
+
return (y = p.current) == null ? void 0 : y.focus();
|
|
2859
2866
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
2860
2867
|
document.body.style.overflow = "";
|
|
2861
2868
|
}), [n]);
|
|
2862
2869
|
const b = E(() => {
|
|
2863
|
-
const
|
|
2864
|
-
if (!
|
|
2870
|
+
const y = i.trim();
|
|
2871
|
+
if (!y) {
|
|
2865
2872
|
d(s("video.urlRequired"));
|
|
2866
2873
|
return;
|
|
2867
2874
|
}
|
|
2868
2875
|
try {
|
|
2869
|
-
new URL(
|
|
2876
|
+
new URL(y);
|
|
2870
2877
|
} catch {
|
|
2871
2878
|
d(s("video.invalidUrl"));
|
|
2872
2879
|
return;
|
|
2873
2880
|
}
|
|
2874
|
-
e.chain().focus().setVideo({ src:
|
|
2875
|
-
}, [i, e, s, t, o]),
|
|
2881
|
+
e.chain().focus().setVideo({ src: y }).run(), t == null || t(y), o();
|
|
2882
|
+
}, [i, e, s, t, o]), T = E(() => {
|
|
2876
2883
|
r == null || r(), o();
|
|
2877
|
-
}, [r, o]),
|
|
2878
|
-
|
|
2879
|
-
}, [
|
|
2880
|
-
|
|
2881
|
-
}, [b,
|
|
2884
|
+
}, [r, o]), m = E((y) => {
|
|
2885
|
+
y.target === y.currentTarget && T();
|
|
2886
|
+
}, [T]), k = E((y) => {
|
|
2887
|
+
y.key === "Enter" ? (y.preventDefault(), b()) : y.key === "Escape" && (y.preventDefault(), T());
|
|
2888
|
+
}, [b, T]);
|
|
2882
2889
|
return n ? tt(
|
|
2883
|
-
/* @__PURE__ */ c("div", { className: "tp-video-dialog-overlay", onMouseDown:
|
|
2884
|
-
/* @__PURE__ */
|
|
2890
|
+
/* @__PURE__ */ c("div", { className: "tp-video-dialog-overlay", onMouseDown: m, children: /* @__PURE__ */ v("div", { className: "tp-video-dialog", onMouseDown: (y) => y.stopPropagation(), onKeyDown: k, children: [
|
|
2891
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-header", children: [
|
|
2885
2892
|
/* @__PURE__ */ c("span", { className: "tp-dialog-title", children: s("video.title") }),
|
|
2886
|
-
/* @__PURE__ */ c("button", { className: "tp-dialog-close", onClick:
|
|
2893
|
+
/* @__PURE__ */ c("button", { className: "tp-dialog-close", onClick: T, children: "×" })
|
|
2887
2894
|
] }),
|
|
2888
|
-
/* @__PURE__ */
|
|
2895
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-body", children: [
|
|
2889
2896
|
/* @__PURE__ */ c("label", { className: "tp-input-label", children: s("video.url") }),
|
|
2890
|
-
/* @__PURE__ */
|
|
2897
|
+
/* @__PURE__ */ v("div", { className: "tp-input-row", children: [
|
|
2891
2898
|
/* @__PURE__ */ c(
|
|
2892
2899
|
"input",
|
|
2893
2900
|
{
|
|
@@ -2896,7 +2903,7 @@ const sr = ({
|
|
|
2896
2903
|
className: "tp-url-input",
|
|
2897
2904
|
placeholder: s("video.placeholder"),
|
|
2898
2905
|
value: i,
|
|
2899
|
-
onChange: (
|
|
2906
|
+
onChange: (y) => l(y.target.value),
|
|
2900
2907
|
onKeyDown: k
|
|
2901
2908
|
}
|
|
2902
2909
|
),
|
|
@@ -2912,7 +2919,7 @@ const sr = ({
|
|
|
2912
2919
|
const { t: o } = be(), [s, i] = D(!1), l = () => {
|
|
2913
2920
|
r || i(!0);
|
|
2914
2921
|
};
|
|
2915
|
-
return /* @__PURE__ */
|
|
2922
|
+
return /* @__PURE__ */ v("div", { className: "tp-toolbar-video-btn", children: [
|
|
2916
2923
|
/* @__PURE__ */ c(
|
|
2917
2924
|
"button",
|
|
2918
2925
|
{
|
|
@@ -2936,26 +2943,26 @@ const sr = ({
|
|
|
2936
2943
|
)
|
|
2937
2944
|
] });
|
|
2938
2945
|
}, gr = 10, wr = 10, yr = ({ def: n, editor: e, active: t, disabled: r }) => {
|
|
2939
|
-
const { t: o } = be(), [s, i] = D(!1), [l, a] = D({ row: 0, col: 0 }), d =
|
|
2946
|
+
const { t: o } = be(), [s, i] = D(!1), [l, a] = D({ row: 0, col: 0 }), d = H(null), p = () => {
|
|
2940
2947
|
r || (i(!s), a({ row: 0, col: 0 }));
|
|
2941
|
-
}, b = (
|
|
2942
|
-
a({ row:
|
|
2943
|
-
},
|
|
2944
|
-
e.chain().focus().insertTable({ rows:
|
|
2948
|
+
}, b = (m, k) => {
|
|
2949
|
+
a({ row: m, col: k });
|
|
2950
|
+
}, T = (m, k) => {
|
|
2951
|
+
e.chain().focus().insertTable({ rows: m, cols: k, withHeaderRow: !0 }).run(), i(!1), a({ row: 0, col: 0 });
|
|
2945
2952
|
};
|
|
2946
|
-
return
|
|
2947
|
-
const
|
|
2953
|
+
return _(() => {
|
|
2954
|
+
const m = (k) => {
|
|
2948
2955
|
d.current && !d.current.contains(k.target) && (i(!1), a({ row: 0, col: 0 }));
|
|
2949
2956
|
};
|
|
2950
|
-
return document.addEventListener("pointerdown",
|
|
2951
|
-
}, []), /* @__PURE__ */
|
|
2952
|
-
/* @__PURE__ */
|
|
2957
|
+
return document.addEventListener("pointerdown", m), () => document.removeEventListener("pointerdown", m);
|
|
2958
|
+
}, []), /* @__PURE__ */ v("div", { ref: d, className: "tp-toolbar-dropdown", children: [
|
|
2959
|
+
/* @__PURE__ */ v(
|
|
2953
2960
|
"button",
|
|
2954
2961
|
{
|
|
2955
2962
|
className: `tp-toolbar-dropdown-trigger${t ? " is-active" : ""}${r ? " is-disabled" : ""}`,
|
|
2956
2963
|
title: o(n.titleKey),
|
|
2957
2964
|
disabled: r,
|
|
2958
|
-
onMouseDown: (
|
|
2965
|
+
onMouseDown: (m) => m.preventDefault(),
|
|
2959
2966
|
onClick: p,
|
|
2960
2967
|
children: [
|
|
2961
2968
|
/* @__PURE__ */ c("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: Be(n.name) } }),
|
|
@@ -2963,16 +2970,16 @@ const sr = ({
|
|
|
2963
2970
|
]
|
|
2964
2971
|
}
|
|
2965
2972
|
),
|
|
2966
|
-
s && /* @__PURE__ */
|
|
2973
|
+
s && /* @__PURE__ */ v("div", { className: "tp-table-grid-dropdown", children: [
|
|
2967
2974
|
/* @__PURE__ */ c("div", { className: "tp-table-grid-header", children: l.row > 0 ? `${l.row} × ${l.col}` : o("table.insertHint") }),
|
|
2968
|
-
/* @__PURE__ */ c("div", { className: "tp-table-grid", children: Array.from({ length: gr }, (
|
|
2969
|
-
const u = k + 1, h =
|
|
2975
|
+
/* @__PURE__ */ c("div", { className: "tp-table-grid", children: Array.from({ length: gr }, (m, k) => /* @__PURE__ */ c("div", { className: "tp-table-grid-row", children: Array.from({ length: wr }, (y, S) => {
|
|
2976
|
+
const u = k + 1, h = S + 1;
|
|
2970
2977
|
return /* @__PURE__ */ c(
|
|
2971
2978
|
"div",
|
|
2972
2979
|
{
|
|
2973
2980
|
className: `tp-table-grid-cell${u <= l.row && h <= l.col ? " is-hovered" : ""}${u === l.row && h === l.col ? " is-selected" : ""}`,
|
|
2974
2981
|
onMouseEnter: () => b(u, h),
|
|
2975
|
-
onClick: () =>
|
|
2982
|
+
onClick: () => T(u, h)
|
|
2976
2983
|
},
|
|
2977
2984
|
`${u}-${h}`
|
|
2978
2985
|
);
|
|
@@ -2980,23 +2987,23 @@ const sr = ({
|
|
|
2980
2987
|
] })
|
|
2981
2988
|
] });
|
|
2982
2989
|
}, vr = ({ editor: n, disabled: e = !1 }) => {
|
|
2983
|
-
const { t } = be(), r =
|
|
2990
|
+
const { t } = be(), r = H("none"), [o, s] = D("none"), i = H([]), l = H(null), a = H(null), d = H(null), p = H(void 0), b = H(null), T = H(0), m = H(!1), k = o !== "none", y = E(() => {
|
|
2984
2991
|
const { from: A, to: O } = n.state.selection;
|
|
2985
2992
|
if (n.isActive("orderedList")) return "orderedList";
|
|
2986
2993
|
if (n.isActive("bulletList")) return "bulletList";
|
|
2987
2994
|
const z = Math.min(A + 1, O), G = n.state.doc.resolve(z);
|
|
2988
2995
|
if (G.parent.type.name === "listItem")
|
|
2989
|
-
for (let
|
|
2990
|
-
const W = G.node(
|
|
2996
|
+
for (let K = G.depth; K > 0; K--) {
|
|
2997
|
+
const W = G.node(K);
|
|
2991
2998
|
if (W.type.name === "orderedList") return "orderedList";
|
|
2992
2999
|
if (W.type.name === "bulletList") return "bulletList";
|
|
2993
3000
|
}
|
|
2994
3001
|
return null;
|
|
2995
|
-
}, [n]),
|
|
3002
|
+
}, [n]), S = E(() => {
|
|
2996
3003
|
const { from: A, to: O } = n.state.selection;
|
|
2997
3004
|
if (n.isActive("orderedList") || n.isActive("bulletList")) return;
|
|
2998
|
-
for (let
|
|
2999
|
-
if (n.isActive("heading", { level:
|
|
3005
|
+
for (let K = 1; K <= 6; K++)
|
|
3006
|
+
if (n.isActive("heading", { level: K })) return K;
|
|
3000
3007
|
const z = Math.min(A + 1, O);
|
|
3001
3008
|
if (n.state.doc.resolve(z).parent.type.name === "paragraph") return null;
|
|
3002
3009
|
}, [n]), u = E(() => {
|
|
@@ -3004,22 +3011,22 @@ const sr = ({
|
|
|
3004
3011
|
if (z) return !1;
|
|
3005
3012
|
const J = n.state.doc.resolve(Math.min(A + 1, O)).marks();
|
|
3006
3013
|
i.current = [...J];
|
|
3007
|
-
const
|
|
3008
|
-
l.current =
|
|
3014
|
+
const K = y();
|
|
3015
|
+
l.current = K;
|
|
3009
3016
|
const W = n.getAttributes("textStyle");
|
|
3010
3017
|
a.current = {
|
|
3011
3018
|
color: W.color,
|
|
3012
3019
|
fontFamily: W.fontFamily,
|
|
3013
3020
|
fontSize: W.fontSize
|
|
3014
3021
|
};
|
|
3015
|
-
const
|
|
3022
|
+
const B = n.getAttributes("paragraph"), F = n.getAttributes("heading");
|
|
3016
3023
|
d.current = {
|
|
3017
|
-
textAlign:
|
|
3018
|
-
lineHeight:
|
|
3019
|
-
}, p.current =
|
|
3020
|
-
const
|
|
3021
|
-
return
|
|
3022
|
-
}, [n,
|
|
3024
|
+
textAlign: B.textAlign || F.textAlign,
|
|
3025
|
+
lineHeight: B.lineHeight || F.lineHeight
|
|
3026
|
+
}, p.current = S();
|
|
3027
|
+
const V = J.length > 0, q = !!W.color || !!W.fontFamily || !!W.fontSize, re = !!d.current.textAlign || !!d.current.lineHeight;
|
|
3028
|
+
return V || q || re || K !== null || p.current !== void 0;
|
|
3029
|
+
}, [n, y, S]), h = E(() => {
|
|
3023
3030
|
if (!l.current) return;
|
|
3024
3031
|
const A = n.chain().focus();
|
|
3025
3032
|
switch (l.current) {
|
|
@@ -3030,7 +3037,7 @@ const sr = ({
|
|
|
3030
3037
|
n.isActive("bulletList") || (n.isActive("orderedList") && A.toggleOrderedList(), A.toggleBulletList().run());
|
|
3031
3038
|
break;
|
|
3032
3039
|
}
|
|
3033
|
-
}, [n]),
|
|
3040
|
+
}, [n]), x = E(() => {
|
|
3034
3041
|
if (p.current === void 0) return;
|
|
3035
3042
|
const A = n.chain().focus();
|
|
3036
3043
|
if (p.current === null)
|
|
@@ -3043,84 +3050,84 @@ const sr = ({
|
|
|
3043
3050
|
let { state: A } = n, { from: O, to: z, empty: G } = A.selection;
|
|
3044
3051
|
if (G) return !1;
|
|
3045
3052
|
const { schema: J } = A;
|
|
3046
|
-
if (l.current ? h() : p.current !== void 0 &&
|
|
3047
|
-
const
|
|
3048
|
-
d.current.textAlign &&
|
|
3053
|
+
if (l.current ? h() : p.current !== void 0 && x(), d.current) {
|
|
3054
|
+
const V = n.chain().focus();
|
|
3055
|
+
d.current.textAlign && V.setTextAlign(d.current.textAlign), d.current.lineHeight && V.setLineHeight(d.current.lineHeight), V.run();
|
|
3049
3056
|
}
|
|
3050
3057
|
A = n.state;
|
|
3051
|
-
const
|
|
3052
|
-
if (O =
|
|
3058
|
+
const K = A.selection;
|
|
3059
|
+
if (O = K.from, z = K.to, i.current.length === 0 && !a.current)
|
|
3053
3060
|
return l.current !== null || d.current !== null || p.current !== void 0;
|
|
3054
|
-
const W = A.tr,
|
|
3055
|
-
if (i.current.forEach((
|
|
3056
|
-
const q =
|
|
3057
|
-
["bold", "italic", "underline", "strike", "superscript", "subscript"].includes(q) &&
|
|
3061
|
+
const W = A.tr, B = [];
|
|
3062
|
+
if (i.current.forEach((V) => {
|
|
3063
|
+
const q = V.type.name;
|
|
3064
|
+
["bold", "italic", "underline", "strike", "superscript", "subscript"].includes(q) && B.push(V);
|
|
3058
3065
|
}), a.current) {
|
|
3059
|
-
const { color:
|
|
3060
|
-
if (
|
|
3066
|
+
const { color: V, fontFamily: q, fontSize: re } = a.current, oe = {};
|
|
3067
|
+
if (V && (oe.color = V), q && (oe.fontFamily = q), re && (oe.fontSize = re), Object.keys(oe).length > 0 && J.marks.textStyle) {
|
|
3061
3068
|
const Me = J.marks.textStyle.create(oe);
|
|
3062
|
-
|
|
3069
|
+
B.push(Me);
|
|
3063
3070
|
}
|
|
3064
3071
|
}
|
|
3065
|
-
const F = i.current.find((
|
|
3066
|
-
return F &&
|
|
3067
|
-
if (
|
|
3068
|
-
const re = Math.max(q, O), oe = Math.min(q +
|
|
3072
|
+
const F = i.current.find((V) => V.type.name === "highlight");
|
|
3073
|
+
return F && B.push(F), B.length === 0 || (A.doc.nodesBetween(O, z, (V, q) => {
|
|
3074
|
+
if (V.isText && q < z && q + V.nodeSize > O) {
|
|
3075
|
+
const re = Math.max(q, O), oe = Math.min(q + V.nodeSize, z);
|
|
3069
3076
|
["bold", "italic", "underline", "strike", "superscript", "subscript", "textStyle", "highlight"].forEach((se) => {
|
|
3070
3077
|
const ge = J.marks[se];
|
|
3071
|
-
ge &&
|
|
3072
|
-
}),
|
|
3078
|
+
ge && V.marks.some((pe) => pe.type === ge) && W.removeMark(re, oe, ge);
|
|
3079
|
+
}), B.forEach((se) => {
|
|
3073
3080
|
W.addMark(re, oe, se);
|
|
3074
3081
|
});
|
|
3075
3082
|
}
|
|
3076
3083
|
}), W.docChanged && n.view.dispatch(W)), !0;
|
|
3077
|
-
}, [n, h,
|
|
3084
|
+
}, [n, h, x]), f = E(() => {
|
|
3078
3085
|
r.current = "none", s("none"), i.current = [], l.current = null, a.current = null, d.current = null, p.current = void 0;
|
|
3079
|
-
}, []),
|
|
3086
|
+
}, []), N = E(() => {
|
|
3080
3087
|
if (r.current === "none") return;
|
|
3081
3088
|
const { empty: A } = n.state.selection;
|
|
3082
|
-
A || (w(), r.current === "single" &&
|
|
3083
|
-
}, [n, w,
|
|
3089
|
+
A || (w(), r.current === "single" && f());
|
|
3090
|
+
}, [n, w, f]), $ = E(() => {
|
|
3084
3091
|
if (r.current === "single" || r.current === "multiple") {
|
|
3085
|
-
|
|
3092
|
+
f();
|
|
3086
3093
|
return;
|
|
3087
3094
|
}
|
|
3088
3095
|
u() && (r.current = "single", s("single"));
|
|
3089
|
-
}, [u,
|
|
3096
|
+
}, [u, f]), P = E(() => {
|
|
3090
3097
|
if (r.current === "multiple") {
|
|
3091
|
-
|
|
3098
|
+
f();
|
|
3092
3099
|
return;
|
|
3093
3100
|
}
|
|
3094
3101
|
u() && (r.current = "multiple", s("multiple"));
|
|
3095
|
-
}, [u,
|
|
3096
|
-
e || (
|
|
3097
|
-
$(),
|
|
3098
|
-
}, 250) :
|
|
3102
|
+
}, [u, f]), C = E(() => {
|
|
3103
|
+
e || (T.current++, T.current === 1 ? b.current = window.setTimeout(() => {
|
|
3104
|
+
$(), T.current = 0, b.current = null;
|
|
3105
|
+
}, 250) : T.current === 2 && (b.current && (clearTimeout(b.current), b.current = null), P(), T.current = 0));
|
|
3099
3106
|
}, [$, P]);
|
|
3100
|
-
return
|
|
3101
|
-
e && (
|
|
3102
|
-
}, [e,
|
|
3107
|
+
return _(() => {
|
|
3108
|
+
e && (f(), b.current && (clearTimeout(b.current), b.current = null), T.current = 0);
|
|
3109
|
+
}, [e, f]), _(() => {
|
|
3103
3110
|
const A = (J) => {
|
|
3104
|
-
r.current === "none" || J.target.closest(".tp-toolbar-btn") || (
|
|
3111
|
+
r.current === "none" || J.target.closest(".tp-toolbar-btn") || (m.current = !0);
|
|
3105
3112
|
}, O = (J) => {
|
|
3106
|
-
!
|
|
3113
|
+
!m.current || (m.current = !1, r.current === "none") || J.target.closest(".tp-toolbar-btn") || requestAnimationFrame(() => N());
|
|
3107
3114
|
}, z = (J) => {
|
|
3108
|
-
J.key === "Escape" && r.current !== "none" &&
|
|
3115
|
+
J.key === "Escape" && r.current !== "none" && f();
|
|
3109
3116
|
}, G = (J) => {
|
|
3110
3117
|
if (r.current === "none") return;
|
|
3111
|
-
const
|
|
3112
|
-
J.shiftKey &&
|
|
3118
|
+
const K = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "PageUp", "PageDown"];
|
|
3119
|
+
J.shiftKey && K.includes(J.key) && N();
|
|
3113
3120
|
};
|
|
3114
3121
|
return document.addEventListener("mousedown", A), document.addEventListener("mouseup", O), document.addEventListener("keydown", z), document.addEventListener("keyup", G), () => {
|
|
3115
3122
|
document.removeEventListener("mousedown", A), document.removeEventListener("mouseup", O), document.removeEventListener("keydown", z), document.removeEventListener("keyup", G), b.current && clearTimeout(b.current);
|
|
3116
3123
|
};
|
|
3117
|
-
}, [
|
|
3124
|
+
}, [N, f]), /* @__PURE__ */ v(
|
|
3118
3125
|
"button",
|
|
3119
3126
|
{
|
|
3120
3127
|
className: `tp-toolbar-btn${k ? " is-active" : ""}${o === "multiple" ? " is-locked" : ""}${e ? " is-disabled" : ""}`,
|
|
3121
3128
|
disabled: e,
|
|
3122
3129
|
title: t("toolbar.formatPainter"),
|
|
3123
|
-
onClick:
|
|
3130
|
+
onClick: C,
|
|
3124
3131
|
style: { position: "relative" },
|
|
3125
3132
|
children: [
|
|
3126
3133
|
/* @__PURE__ */ c("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: Be("formatPainter") } }),
|
|
@@ -3136,47 +3143,47 @@ const sr = ({
|
|
|
3136
3143
|
{ type: "lower-alpha", lines: ["a.", "b.", "c."] },
|
|
3137
3144
|
{ type: "upper-alpha", lines: ["A.", "B.", "C."] }
|
|
3138
3145
|
], kr = ({ def: n, editor: e, active: t, disabled: r }) => {
|
|
3139
|
-
const { t: o } = be(), [s, i] = D(!1), [l, a] = D(0), d =
|
|
3140
|
-
const { state: w } = e,
|
|
3141
|
-
let
|
|
3142
|
-
for (let P =
|
|
3143
|
-
const
|
|
3144
|
-
|
|
3146
|
+
const { t: o } = be(), [s, i] = D(!1), [l, a] = D(0), d = H(null), p = () => {
|
|
3147
|
+
const { state: w } = e, f = w.selection.$from;
|
|
3148
|
+
let N = null, $ = 0;
|
|
3149
|
+
for (let P = f.depth; P >= 0; P--) {
|
|
3150
|
+
const C = f.node(P);
|
|
3151
|
+
C.type.name === "orderedList" && (N || (N = C), $++);
|
|
3145
3152
|
}
|
|
3146
|
-
return { node:
|
|
3153
|
+
return { node: N, depth: $ };
|
|
3147
3154
|
}, b = (() => {
|
|
3148
|
-
const { node: w, depth:
|
|
3149
|
-
return w && w.attrs.listStyleType ? w.attrs.listStyleType :
|
|
3150
|
-
})(),
|
|
3151
|
-
const { node: w } = p(),
|
|
3152
|
-
return
|
|
3153
|
-
})(),
|
|
3155
|
+
const { node: w, depth: f } = p();
|
|
3156
|
+
return w && w.attrs.listStyleType ? w.attrs.listStyleType : f <= 1 ? "decimal" : f === 2 ? "lower-alpha" : "lower-roman";
|
|
3157
|
+
})(), T = (() => {
|
|
3158
|
+
const { node: w } = p(), f = w == null ? void 0 : w.attrs.start;
|
|
3159
|
+
return f != null ? Number(f) : 1;
|
|
3160
|
+
})(), m = (() => {
|
|
3154
3161
|
const { node: w } = p();
|
|
3155
3162
|
return !!(w != null && w.attrs.reversed);
|
|
3156
3163
|
})(), k = E(() => {
|
|
3157
3164
|
var w;
|
|
3158
3165
|
(w = n.command) == null || w.call(n, e);
|
|
3159
|
-
}, [n, e]),
|
|
3166
|
+
}, [n, e]), y = E(() => {
|
|
3160
3167
|
r || i((w) => !w);
|
|
3161
|
-
}, [r]),
|
|
3168
|
+
}, [r]), S = E((w) => {
|
|
3162
3169
|
e.commands.createStyledOrderedList({ listStyleType: w }), e.commands.focus(), i(!1);
|
|
3163
3170
|
}, [e]), u = E((w) => {
|
|
3164
|
-
const
|
|
3165
|
-
isNaN(
|
|
3171
|
+
const f = parseInt(w.target.value, 10);
|
|
3172
|
+
isNaN(f) || e.commands.setOrderedListAttrs({ start: f });
|
|
3166
3173
|
}, [e]), h = E((w) => {
|
|
3167
3174
|
["Backspace", "Delete", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Tab", "Home", "End"].includes(w.key) || w.key === "-" || w.key === "Minus" || w.key >= "0" && w.key <= "9" || w.ctrlKey || w.metaKey || w.preventDefault();
|
|
3168
|
-
}, []),
|
|
3169
|
-
const w = !
|
|
3175
|
+
}, []), x = E(() => {
|
|
3176
|
+
const w = !m;
|
|
3170
3177
|
e.commands.setOrderedListAttrs({ reversed: w || null });
|
|
3171
|
-
}, [e,
|
|
3172
|
-
return
|
|
3173
|
-
const w = (
|
|
3174
|
-
d.current && !d.current.contains(
|
|
3175
|
-
},
|
|
3176
|
-
return document.addEventListener("pointerdown", w), e.on("transaction",
|
|
3177
|
-
document.removeEventListener("pointerdown", w), e.off("transaction",
|
|
3178
|
+
}, [e, m]);
|
|
3179
|
+
return _(() => {
|
|
3180
|
+
const w = (N) => {
|
|
3181
|
+
d.current && !d.current.contains(N.target) && i(!1);
|
|
3182
|
+
}, f = () => a((N) => N + 1);
|
|
3183
|
+
return document.addEventListener("pointerdown", w), e.on("transaction", f), () => {
|
|
3184
|
+
document.removeEventListener("pointerdown", w), e.off("transaction", f);
|
|
3178
3185
|
};
|
|
3179
|
-
}, [e]), /* @__PURE__ */
|
|
3186
|
+
}, [e]), /* @__PURE__ */ v("div", { ref: d, className: "tp-toolbar-split-btn", children: [
|
|
3180
3187
|
/* @__PURE__ */ c(
|
|
3181
3188
|
"button",
|
|
3182
3189
|
{
|
|
@@ -3194,48 +3201,48 @@ const sr = ({
|
|
|
3194
3201
|
className: `tp-toolbar-split-arrow${s ? " is-open" : ""}`,
|
|
3195
3202
|
disabled: r,
|
|
3196
3203
|
onMouseDown: (w) => w.preventDefault(),
|
|
3197
|
-
onClick:
|
|
3204
|
+
onClick: y,
|
|
3198
3205
|
children: "▾"
|
|
3199
3206
|
}
|
|
3200
3207
|
),
|
|
3201
|
-
s && /* @__PURE__ */
|
|
3208
|
+
s && /* @__PURE__ */ v("div", { className: "tp-ol-panel", children: [
|
|
3202
3209
|
/* @__PURE__ */ c("div", { className: "tp-ol-style-grid", children: br.map((w) => /* @__PURE__ */ c(
|
|
3203
3210
|
"button",
|
|
3204
3211
|
{
|
|
3205
3212
|
className: `tp-ol-style-item${b === w.type ? " is-active" : ""}`,
|
|
3206
|
-
onMouseDown: (
|
|
3207
|
-
onClick: () =>
|
|
3208
|
-
children: w.lines.map((
|
|
3209
|
-
/* @__PURE__ */ c("span", { className: "tp-ol-style-marker", children:
|
|
3213
|
+
onMouseDown: (f) => f.preventDefault(),
|
|
3214
|
+
onClick: () => S(w.type),
|
|
3215
|
+
children: w.lines.map((f, N) => /* @__PURE__ */ v("span", { className: "tp-ol-style-line", children: [
|
|
3216
|
+
/* @__PURE__ */ c("span", { className: "tp-ol-style-marker", children: f }),
|
|
3210
3217
|
/* @__PURE__ */ c("span", { className: "tp-ol-style-bar" })
|
|
3211
|
-
] },
|
|
3218
|
+
] }, N))
|
|
3212
3219
|
},
|
|
3213
3220
|
w.type
|
|
3214
3221
|
)) }),
|
|
3215
|
-
/* @__PURE__ */
|
|
3222
|
+
/* @__PURE__ */ v("div", { className: "tp-ol-properties", children: [
|
|
3216
3223
|
/* @__PURE__ */ c("div", { className: "tp-ol-prop-title", children: o("orderedList.properties") }),
|
|
3217
|
-
/* @__PURE__ */
|
|
3224
|
+
/* @__PURE__ */ v("div", { className: "tp-ol-prop-row", children: [
|
|
3218
3225
|
/* @__PURE__ */ c("label", { children: o("orderedList.startAt") }),
|
|
3219
3226
|
/* @__PURE__ */ c(
|
|
3220
3227
|
"input",
|
|
3221
3228
|
{
|
|
3222
3229
|
type: "number",
|
|
3223
3230
|
className: "tp-ol-start-input",
|
|
3224
|
-
defaultValue:
|
|
3231
|
+
defaultValue: T,
|
|
3225
3232
|
onChange: u,
|
|
3226
3233
|
onKeyDown: h,
|
|
3227
3234
|
onMouseDown: (w) => w.stopPropagation()
|
|
3228
3235
|
}
|
|
3229
3236
|
)
|
|
3230
3237
|
] }),
|
|
3231
|
-
/* @__PURE__ */
|
|
3238
|
+
/* @__PURE__ */ v("div", { className: "tp-ol-prop-row", children: [
|
|
3232
3239
|
/* @__PURE__ */ c("label", { children: o("orderedList.reversed") }),
|
|
3233
3240
|
/* @__PURE__ */ c(
|
|
3234
3241
|
"button",
|
|
3235
3242
|
{
|
|
3236
|
-
className: `tp-ol-toggle${
|
|
3243
|
+
className: `tp-ol-toggle${m ? " is-on" : ""}`,
|
|
3237
3244
|
onMouseDown: (w) => w.preventDefault(),
|
|
3238
|
-
onClick:
|
|
3245
|
+
onClick: x
|
|
3239
3246
|
}
|
|
3240
3247
|
)
|
|
3241
3248
|
] })
|
|
@@ -3248,30 +3255,30 @@ const sr = ({
|
|
|
3248
3255
|
{ type: "square", marker: "■" },
|
|
3249
3256
|
{ type: "none", marker: "—" }
|
|
3250
3257
|
], Cr = ({ def: n, editor: e, active: t, disabled: r }) => {
|
|
3251
|
-
const { t: o } = be(), [s, i] = D(!1), [l, a] = D(0), d =
|
|
3252
|
-
const { state: k } = e,
|
|
3253
|
-
let
|
|
3254
|
-
for (let h =
|
|
3255
|
-
const
|
|
3256
|
-
|
|
3258
|
+
const { t: o } = be(), [s, i] = D(!1), [l, a] = D(0), d = H(null), p = (() => {
|
|
3259
|
+
const { state: k } = e, y = k.selection.$from;
|
|
3260
|
+
let S = null, u = 0;
|
|
3261
|
+
for (let h = y.depth; h >= 0; h--) {
|
|
3262
|
+
const x = y.node(h);
|
|
3263
|
+
x.type.name === "bulletList" && (S || (S = x), u++);
|
|
3257
3264
|
}
|
|
3258
|
-
return
|
|
3265
|
+
return S && S.attrs.listStyleType ? S.attrs.listStyleType : u <= 1 ? "disc" : u === 2 ? "circle" : "square";
|
|
3259
3266
|
})(), b = E(() => {
|
|
3260
3267
|
var k;
|
|
3261
3268
|
(k = n.command) == null || k.call(n, e);
|
|
3262
|
-
}, [n, e]),
|
|
3269
|
+
}, [n, e]), T = E(() => {
|
|
3263
3270
|
r || i((k) => !k);
|
|
3264
|
-
}, [r]),
|
|
3271
|
+
}, [r]), m = E((k) => {
|
|
3265
3272
|
e.commands.createStyledBulletList({ listStyleType: k }), e.commands.focus(), i(!1);
|
|
3266
3273
|
}, [e]);
|
|
3267
|
-
return
|
|
3268
|
-
const k = (
|
|
3269
|
-
d.current && !d.current.contains(
|
|
3270
|
-
},
|
|
3271
|
-
return document.addEventListener("pointerdown", k), e.on("transaction",
|
|
3272
|
-
document.removeEventListener("pointerdown", k), e.off("transaction",
|
|
3274
|
+
return _(() => {
|
|
3275
|
+
const k = (S) => {
|
|
3276
|
+
d.current && !d.current.contains(S.target) && i(!1);
|
|
3277
|
+
}, y = () => a((S) => S + 1);
|
|
3278
|
+
return document.addEventListener("pointerdown", k), e.on("transaction", y), () => {
|
|
3279
|
+
document.removeEventListener("pointerdown", k), e.off("transaction", y);
|
|
3273
3280
|
};
|
|
3274
|
-
}, [e]), /* @__PURE__ */
|
|
3281
|
+
}, [e]), /* @__PURE__ */ v("div", { ref: d, className: "tp-toolbar-split-btn", children: [
|
|
3275
3282
|
/* @__PURE__ */ c(
|
|
3276
3283
|
"button",
|
|
3277
3284
|
{
|
|
@@ -3289,7 +3296,7 @@ const sr = ({
|
|
|
3289
3296
|
className: `tp-toolbar-split-arrow${s ? " is-open" : ""}`,
|
|
3290
3297
|
disabled: r,
|
|
3291
3298
|
onMouseDown: (k) => k.preventDefault(),
|
|
3292
|
-
onClick:
|
|
3299
|
+
onClick: T,
|
|
3293
3300
|
children: "▾"
|
|
3294
3301
|
}
|
|
3295
3302
|
),
|
|
@@ -3297,12 +3304,12 @@ const sr = ({
|
|
|
3297
3304
|
"button",
|
|
3298
3305
|
{
|
|
3299
3306
|
className: `tp-ol-style-item${p === k.type ? " is-active" : ""}`,
|
|
3300
|
-
onMouseDown: (
|
|
3301
|
-
onClick: () =>
|
|
3302
|
-
children: [0, 1, 2].map((
|
|
3307
|
+
onMouseDown: (y) => y.preventDefault(),
|
|
3308
|
+
onClick: () => m(k.type),
|
|
3309
|
+
children: [0, 1, 2].map((y) => /* @__PURE__ */ v("span", { className: "tp-ol-style-line", children: [
|
|
3303
3310
|
/* @__PURE__ */ c("span", { className: "tp-ul-style-marker", children: k.marker }),
|
|
3304
3311
|
/* @__PURE__ */ c("span", { className: "tp-ol-style-bar" })
|
|
3305
|
-
] },
|
|
3312
|
+
] }, y))
|
|
3306
3313
|
},
|
|
3307
3314
|
k.type
|
|
3308
3315
|
)) }) })
|
|
@@ -3332,22 +3339,22 @@ const Nr = ({
|
|
|
3332
3339
|
return;
|
|
3333
3340
|
}
|
|
3334
3341
|
i == null || i(u);
|
|
3335
|
-
}, [s, i]), b = (u) => o !== "normal" ? u === "getHTML" ? o === "html" : u === "getJSON" ? o === "json" : !1 : u === "getHTML" || u === "getJSON" ? !1 : t[u] ?? !1,
|
|
3336
|
-
function
|
|
3342
|
+
}, [s, i]), b = (u) => o !== "normal" ? u === "getHTML" ? o === "html" : u === "getJSON" ? o === "json" : !1 : u === "getHTML" || u === "getJSON" ? !1 : t[u] ?? !1, T = (u) => o !== "normal" ? u !== "getHTML" && u !== "getJSON" : r[u] ?? !1, m = _e(() => Rn(n), [n]), k = m.filter((u) => u.category === "meta-left" || u.category === "content"), y = m.filter((u) => u.category === "meta-io" || u.category === "meta-view");
|
|
3343
|
+
function S(u) {
|
|
3337
3344
|
const h = En(u);
|
|
3338
3345
|
if (!h) return null;
|
|
3339
|
-
const
|
|
3340
|
-
return u === "imageUpload" ? /* @__PURE__ */ c(pr, { def: h, editor:
|
|
3346
|
+
const x = d();
|
|
3347
|
+
return u === "imageUpload" ? /* @__PURE__ */ c(pr, { def: h, editor: x, manager: e, active: b(u), disabled: T(u) }, u) : u === "video" ? /* @__PURE__ */ c(mr, { def: h, editor: x, active: b(u), disabled: T(u) }, u) : u === "insertTable" ? /* @__PURE__ */ c(yr, { def: h, editor: x, active: b(u), disabled: T(u) }, u) : u === "formatPainter" ? /* @__PURE__ */ c(vr, { editor: x, disabled: T(u) }, u) : u === "orderedList" ? /* @__PURE__ */ c(kr, { def: h, editor: x, active: b(u), disabled: T(u) }, u) : u === "bulletList" ? /* @__PURE__ */ c(Cr, { def: h, editor: x, active: b(u), disabled: T(u) }, u) : h.type === "button" ? /* @__PURE__ */ c(lr, { def: h, editor: x, active: b(u), disabled: T(u), onCustomClick: p }, u) : h.type === "dropdown" ? /* @__PURE__ */ c(cr, { def: h, editor: x, active: b(u), disabled: T(u), onCustomClick: p }, u) : h.type === "color-picker" ? /* @__PURE__ */ c(ur, { def: h, editor: x, disabled: T(u) }, u) : null;
|
|
3341
3348
|
}
|
|
3342
|
-
return /* @__PURE__ */
|
|
3349
|
+
return /* @__PURE__ */ v("div", { className: "tp-toolbar", children: [
|
|
3343
3350
|
l,
|
|
3344
|
-
k.map((u, h) => /* @__PURE__ */
|
|
3351
|
+
k.map((u, h) => /* @__PURE__ */ v(Ot.Fragment, { children: [
|
|
3345
3352
|
h > 0 && /* @__PURE__ */ c(sn, {}),
|
|
3346
|
-
u.category !== "content" ? /* @__PURE__ */ c("div", { className: ln(u.category), children: u.items.map(
|
|
3353
|
+
u.category !== "content" ? /* @__PURE__ */ c("div", { className: ln(u.category), children: u.items.map(S) }) : /* @__PURE__ */ c(Ft, { children: u.items.map(S) })
|
|
3347
3354
|
] }, `g-${h}`)),
|
|
3348
|
-
|
|
3355
|
+
y.length > 0 && /* @__PURE__ */ c("div", { className: "tp-toolbar-right", children: y.map((u, h) => /* @__PURE__ */ v(Ot.Fragment, { children: [
|
|
3349
3356
|
h > 0 && /* @__PURE__ */ c(sn, {}),
|
|
3350
|
-
/* @__PURE__ */ c("div", { className: ln(u.category), children: u.items.map(
|
|
3357
|
+
/* @__PURE__ */ c("div", { className: ln(u.category), children: u.items.map(S) })
|
|
3351
3358
|
] }, `r-${h}`)) }),
|
|
3352
3359
|
a
|
|
3353
3360
|
] });
|
|
@@ -3359,39 +3366,39 @@ const Nr = ({
|
|
|
3359
3366
|
onVisibleChange: o,
|
|
3360
3367
|
onAction: s
|
|
3361
3368
|
}) => {
|
|
3362
|
-
const i =
|
|
3369
|
+
const i = H(null), [l, a] = D({ x: 0, y: 0 }), [d, p] = D(!1), [b, T] = D(!1), m = H({ x: 0, y: 0 }), k = Ve.getInstance(), y = (h) => k.t(h), S = E((h) => {
|
|
3363
3370
|
if (!i.current) return h;
|
|
3364
|
-
const
|
|
3365
|
-
return
|
|
3371
|
+
const x = i.current.getBoundingClientRect();
|
|
3372
|
+
return x.width === 0 || x.height === 0 ? h : Vt({
|
|
3366
3373
|
x: h.x,
|
|
3367
3374
|
y: h.y,
|
|
3368
|
-
width:
|
|
3369
|
-
height:
|
|
3375
|
+
width: x.width,
|
|
3376
|
+
height: x.height
|
|
3370
3377
|
});
|
|
3371
3378
|
}, []);
|
|
3372
|
-
|
|
3379
|
+
_(() => {
|
|
3373
3380
|
if (e) {
|
|
3374
3381
|
if (a({ x: t.x, y: t.y }), r) {
|
|
3375
3382
|
const h = r.getBoundingClientRect();
|
|
3376
|
-
|
|
3383
|
+
m.current = {
|
|
3377
3384
|
x: t.x - h.left,
|
|
3378
3385
|
y: t.y - h.top
|
|
3379
3386
|
};
|
|
3380
3387
|
}
|
|
3381
|
-
p(n.can().mergeCells()),
|
|
3388
|
+
p(n.can().mergeCells()), T(n.can().splitCell());
|
|
3382
3389
|
}
|
|
3383
3390
|
}, [e, t, r, n]), Sn(() => {
|
|
3384
3391
|
if (!e || !i.current) return;
|
|
3385
3392
|
const h = i.current.getBoundingClientRect();
|
|
3386
3393
|
if (h.width === 0 || h.height === 0) return;
|
|
3387
|
-
const
|
|
3394
|
+
const x = Vt({
|
|
3388
3395
|
x: l.x,
|
|
3389
3396
|
y: l.y,
|
|
3390
3397
|
width: h.width,
|
|
3391
3398
|
height: h.height
|
|
3392
3399
|
});
|
|
3393
|
-
(
|
|
3394
|
-
}, [e, l.x, l.y]),
|
|
3400
|
+
(x.x !== l.x || x.y !== l.y) && a({ x: x.x, y: x.y });
|
|
3401
|
+
}, [e, l.x, l.y]), _(() => {
|
|
3395
3402
|
const h = () => {
|
|
3396
3403
|
if (!e || !r) return;
|
|
3397
3404
|
const w = r.getBoundingClientRect();
|
|
@@ -3399,32 +3406,32 @@ const Nr = ({
|
|
|
3399
3406
|
o(!1);
|
|
3400
3407
|
return;
|
|
3401
3408
|
}
|
|
3402
|
-
const
|
|
3403
|
-
x: w.left +
|
|
3404
|
-
y: w.top +
|
|
3405
|
-
},
|
|
3406
|
-
a({ x:
|
|
3407
|
-
},
|
|
3409
|
+
const f = {
|
|
3410
|
+
x: w.left + m.current.x,
|
|
3411
|
+
y: w.top + m.current.y
|
|
3412
|
+
}, N = S(f);
|
|
3413
|
+
a({ x: N.x, y: N.y });
|
|
3414
|
+
}, x = () => {
|
|
3408
3415
|
e && h();
|
|
3409
3416
|
};
|
|
3410
|
-
return window.addEventListener("scroll",
|
|
3411
|
-
window.removeEventListener("scroll",
|
|
3417
|
+
return window.addEventListener("scroll", x, !0), window.addEventListener("wheel", x, { passive: !0 }), () => {
|
|
3418
|
+
window.removeEventListener("scroll", x, !0), window.removeEventListener("wheel", x);
|
|
3412
3419
|
};
|
|
3413
|
-
}, [e, r, o,
|
|
3420
|
+
}, [e, r, o, S]), _(() => {
|
|
3414
3421
|
const h = (w) => {
|
|
3415
3422
|
i.current && !i.current.contains(w.target) && o(!1);
|
|
3416
|
-
},
|
|
3423
|
+
}, x = (w) => {
|
|
3417
3424
|
w.key === "Escape" && o(!1);
|
|
3418
3425
|
};
|
|
3419
|
-
return document.addEventListener("click", h), document.addEventListener("keydown",
|
|
3420
|
-
document.removeEventListener("click", h), document.removeEventListener("keydown",
|
|
3426
|
+
return document.addEventListener("click", h), document.addEventListener("keydown", x), () => {
|
|
3427
|
+
document.removeEventListener("click", h), document.removeEventListener("keydown", x);
|
|
3421
3428
|
};
|
|
3422
3429
|
}, [o]);
|
|
3423
3430
|
const u = E((h) => {
|
|
3424
3431
|
s(h), o(!1);
|
|
3425
3432
|
}, [s, o]);
|
|
3426
3433
|
return e ? tt(
|
|
3427
|
-
/* @__PURE__ */
|
|
3434
|
+
/* @__PURE__ */ v(
|
|
3428
3435
|
"div",
|
|
3429
3436
|
{
|
|
3430
3437
|
ref: i,
|
|
@@ -3432,27 +3439,27 @@ const Nr = ({
|
|
|
3432
3439
|
style: { left: l.x, top: l.y },
|
|
3433
3440
|
onClick: (h) => h.stopPropagation(),
|
|
3434
3441
|
children: [
|
|
3435
|
-
/* @__PURE__ */
|
|
3436
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addRowBefore"), children:
|
|
3437
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addRowAfter"), children:
|
|
3438
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addColumnBefore"), children:
|
|
3439
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addColumnAfter"), children:
|
|
3442
|
+
/* @__PURE__ */ v("div", { className: "tp-table-menu-section", children: [
|
|
3443
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addRowBefore"), children: y("table.addRowBefore") }),
|
|
3444
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addRowAfter"), children: y("table.addRowAfter") }),
|
|
3445
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addColumnBefore"), children: y("table.addColumnBefore") }),
|
|
3446
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("addColumnAfter"), children: y("table.addColumnAfter") })
|
|
3440
3447
|
] }),
|
|
3441
3448
|
/* @__PURE__ */ c("div", { className: "tp-table-menu-divider" }),
|
|
3442
|
-
/* @__PURE__ */
|
|
3443
|
-
/* @__PURE__ */ c("div", { className: `tp-table-menu-item${d ? "" : " disabled"}`, onClick: () => d && u("mergeCells"), children:
|
|
3444
|
-
/* @__PURE__ */ c("div", { className: `tp-table-menu-item${b ? "" : " disabled"}`, onClick: () => b && u("splitCell"), children:
|
|
3449
|
+
/* @__PURE__ */ v("div", { className: "tp-table-menu-section", children: [
|
|
3450
|
+
/* @__PURE__ */ c("div", { className: `tp-table-menu-item${d ? "" : " disabled"}`, onClick: () => d && u("mergeCells"), children: y("table.mergeCells") }),
|
|
3451
|
+
/* @__PURE__ */ c("div", { className: `tp-table-menu-item${b ? "" : " disabled"}`, onClick: () => b && u("splitCell"), children: y("table.splitCell") })
|
|
3445
3452
|
] }),
|
|
3446
3453
|
/* @__PURE__ */ c("div", { className: "tp-table-menu-divider" }),
|
|
3447
|
-
/* @__PURE__ */
|
|
3448
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("deleteRow"), children:
|
|
3449
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("deleteColumn"), children:
|
|
3450
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item tp-table-menu-item-danger", onClick: () => u("deleteTable"), children:
|
|
3454
|
+
/* @__PURE__ */ v("div", { className: "tp-table-menu-section", children: [
|
|
3455
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("deleteRow"), children: y("table.deleteRow") }),
|
|
3456
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("deleteColumn"), children: y("table.deleteColumn") }),
|
|
3457
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item tp-table-menu-item-danger", onClick: () => u("deleteTable"), children: y("table.deleteTable") })
|
|
3451
3458
|
] }),
|
|
3452
3459
|
/* @__PURE__ */ c("div", { className: "tp-table-menu-divider" }),
|
|
3453
|
-
/* @__PURE__ */
|
|
3454
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("tableSettings"), children:
|
|
3455
|
-
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("cellSettings"), children:
|
|
3460
|
+
/* @__PURE__ */ v("div", { className: "tp-table-menu-section", children: [
|
|
3461
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("tableSettings"), children: y("table.tableSettings") }),
|
|
3462
|
+
/* @__PURE__ */ c("div", { className: "tp-table-menu-item", onClick: () => u("cellSettings"), children: y("table.cellSettings") })
|
|
3456
3463
|
] })
|
|
3457
3464
|
]
|
|
3458
3465
|
}
|
|
@@ -3595,7 +3602,7 @@ function Er(n, e, t) {
|
|
|
3595
3602
|
}
|
|
3596
3603
|
const kt = Mn(
|
|
3597
3604
|
({ value: n, onChange: e, placeholder: t, mode: r = "border", beforeOpen: o, onClose: s }, i) => {
|
|
3598
|
-
const [l, a] = D(!1), d =
|
|
3605
|
+
const [l, a] = D(!1), d = H(null), p = H(null), b = H(null), T = H(null), m = H(null), [k, y] = D(-1e4), [S, u] = D(-1e4), [h, x] = D(n), [w, f] = D(n), N = H(n), [$, P] = D("hex"), [C, A] = D({ h: 0, s: 100, v: 100 }), [O, z] = D({ r: 0, g: 0, b: 0 }), [G, J] = D({ h: 0, s: 0, l: 0 }), [K, W] = D(!1), [B, F] = D(!1), [V, q] = D(!1), re = E(() => {
|
|
3599
3606
|
let L = 0;
|
|
3600
3607
|
const I = 3, te = () => {
|
|
3601
3608
|
if (L >= I * 2) {
|
|
@@ -3610,18 +3617,18 @@ const kt = Mn(
|
|
|
3610
3617
|
triggerButtonFlash: re
|
|
3611
3618
|
}));
|
|
3612
3619
|
const oe = _e(() => r === "background" ? Tr : Mr, [r]), Me = w || "#d9d9d9", se = E((L) => {
|
|
3613
|
-
|
|
3620
|
+
x(L), f(L);
|
|
3614
3621
|
const I = Lr(L);
|
|
3615
3622
|
I && (z(I), J(It(I.r, I.g, I.b)), A($t(I.r, I.g, I.b)));
|
|
3616
3623
|
}, []), ge = E(() => {
|
|
3617
|
-
const L = Rr(
|
|
3618
|
-
z(L), J(It(L.r, L.g, L.b)),
|
|
3619
|
-
}, [
|
|
3620
|
-
|
|
3624
|
+
const L = Rr(C.h, C.s, C.v), I = At(L.r, L.g, L.b);
|
|
3625
|
+
z(L), J(It(L.r, L.g, L.b)), x(I), f(I);
|
|
3626
|
+
}, [C]);
|
|
3627
|
+
_(() => {
|
|
3621
3628
|
se(n);
|
|
3622
|
-
}, [n, se]),
|
|
3629
|
+
}, [n, se]), _(() => {
|
|
3623
3630
|
ge();
|
|
3624
|
-
}, [
|
|
3631
|
+
}, [C, ge]);
|
|
3625
3632
|
const pe = E((L) => {
|
|
3626
3633
|
let I = L.parentElement;
|
|
3627
3634
|
for (; I; ) {
|
|
@@ -3649,18 +3656,18 @@ const kt = Mn(
|
|
|
3649
3656
|
const ve = qe - fe.right - ae, we = fe.left - ae;
|
|
3650
3657
|
ve >= we ? (Pe = Math.max(ae, qe - Ge - ae), M = "right") : (Pe = ae, M = "left");
|
|
3651
3658
|
}
|
|
3652
|
-
Xe + $e > Ye - ae && (Xe = Math.max(ae, Ye - $e - ae)),
|
|
3653
|
-
let
|
|
3659
|
+
Xe + $e > Ye - ae && (Xe = Math.max(ae, Ye - $e - ae)), y(Xe), u(Pe), L.dataset.placement = M;
|
|
3660
|
+
let U = fe.top + fe.height / 2 - Xe - Nt;
|
|
3654
3661
|
const ce = ae, le = Math.max(ce, $e - at - ae);
|
|
3655
|
-
|
|
3662
|
+
U = Math.max(ce, Math.min(le, U)), L.style.setProperty("--triangle-top", `${U}px`);
|
|
3656
3663
|
}, [l]);
|
|
3657
|
-
|
|
3664
|
+
_(() => {
|
|
3658
3665
|
if (!l) return;
|
|
3659
3666
|
const L = requestAnimationFrame(Y), I = p.current, te = I ? pe(I) : null, he = () => requestAnimationFrame(Y);
|
|
3660
3667
|
return te && te.addEventListener("scroll", he, !0), () => {
|
|
3661
3668
|
cancelAnimationFrame(L), te && te.removeEventListener("scroll", he, !0);
|
|
3662
3669
|
};
|
|
3663
|
-
}, [l, Y, pe]),
|
|
3670
|
+
}, [l, Y, pe]), _(() => {
|
|
3664
3671
|
l && requestAnimationFrame(Y);
|
|
3665
3672
|
}, [$, l, Y]);
|
|
3666
3673
|
const ie = E(() => {
|
|
@@ -3668,47 +3675,47 @@ const kt = Mn(
|
|
|
3668
3675
|
s == null || s();
|
|
3669
3676
|
else {
|
|
3670
3677
|
if (o && o() === !1) return;
|
|
3671
|
-
|
|
3678
|
+
N.current = n, f(n), se(n);
|
|
3672
3679
|
}
|
|
3673
3680
|
a(!l);
|
|
3674
3681
|
}, [l, n, se, o, s]), j = E((L) => {
|
|
3675
3682
|
se(L);
|
|
3676
3683
|
}, [se]), Z = E((L) => {
|
|
3677
3684
|
const I = L.target.value;
|
|
3678
|
-
|
|
3685
|
+
x(I), (/^#[0-9A-Fa-f]{6}$/.test(I) || /^#[0-9A-Fa-f]{3}$/.test(I)) && se(I);
|
|
3679
3686
|
}, [se]), Ne = E(() => {
|
|
3680
|
-
h !== w && (/^#[0-9A-Fa-f]{6}$/.test(h) || /^#[0-9A-Fa-f]{3}$/.test(h) ? se(h) : (
|
|
3687
|
+
h !== w && (/^#[0-9A-Fa-f]{6}$/.test(h) || /^#[0-9A-Fa-f]{3}$/.test(h) ? se(h) : (x(w), se(w)));
|
|
3681
3688
|
}, [h, w, se]), nt = E(() => {
|
|
3682
3689
|
const L = At(O.r, O.g, O.b);
|
|
3683
|
-
|
|
3690
|
+
x(L), f(L), J(It(O.r, O.g, O.b)), A($t(O.r, O.g, O.b));
|
|
3684
3691
|
}, [O]), Re = E(() => {
|
|
3685
3692
|
const L = Er(G.h, G.s, G.l), I = At(L.r, L.g, L.b);
|
|
3686
|
-
|
|
3693
|
+
x(I), f(I), z(L), A($t(L.r, L.g, L.b));
|
|
3687
3694
|
}, [G]), ze = E((L) => {
|
|
3688
|
-
if (!
|
|
3689
|
-
const I =
|
|
3695
|
+
if (!T.current) return;
|
|
3696
|
+
const I = T.current.getBoundingClientRect();
|
|
3690
3697
|
let te = Math.max(0, Math.min(100, (L.clientX - I.left) / I.width * 100)), he = Math.max(0, Math.min(100, (L.clientY - I.top) / I.height * 100));
|
|
3691
3698
|
A((fe) => ({ ...fe, s: te, v: 100 - he }));
|
|
3692
3699
|
}, []), je = E((L) => {
|
|
3693
3700
|
W(!0), ze(L.nativeEvent);
|
|
3694
3701
|
}, [ze]), Fe = E((L) => {
|
|
3695
|
-
if (!
|
|
3696
|
-
const I =
|
|
3702
|
+
if (!m.current) return;
|
|
3703
|
+
const I = m.current.getBoundingClientRect();
|
|
3697
3704
|
let te = Math.max(0, Math.min(360, (L.clientX - I.left) / I.width * 360));
|
|
3698
3705
|
A((he) => ({ ...he, h: te }));
|
|
3699
3706
|
}, []), rt = E((L) => {
|
|
3700
3707
|
F(!0), Fe(L.nativeEvent);
|
|
3701
3708
|
}, [Fe]);
|
|
3702
|
-
|
|
3709
|
+
_(() => {
|
|
3703
3710
|
const L = (te) => {
|
|
3704
|
-
|
|
3711
|
+
K && ze(te), B && Fe(te);
|
|
3705
3712
|
}, I = () => {
|
|
3706
3713
|
W(!1), F(!1);
|
|
3707
3714
|
};
|
|
3708
3715
|
return document.addEventListener("mousemove", L), document.addEventListener("mouseup", I), () => {
|
|
3709
3716
|
document.removeEventListener("mousemove", L), document.removeEventListener("mouseup", I);
|
|
3710
3717
|
};
|
|
3711
|
-
}, [
|
|
3718
|
+
}, [K, B, ze, Fe]), _(() => {
|
|
3712
3719
|
const L = (te) => {
|
|
3713
3720
|
if (d.current && !d.current.contains(te.target) && l) {
|
|
3714
3721
|
const he = te.target, fe = he.closest ? he.closest(".tp-color-picker-input") : null;
|
|
@@ -3725,11 +3732,11 @@ const kt = Mn(
|
|
|
3725
3732
|
const Ct = E(() => {
|
|
3726
3733
|
e(w), a(!1), s == null || s();
|
|
3727
3734
|
}, [w, e, s]), g = E(() => {
|
|
3728
|
-
|
|
3735
|
+
f(N.current), se(N.current), a(!1), s == null || s();
|
|
3729
3736
|
}, [se, s]), ne = E((L) => {
|
|
3730
3737
|
L.stopPropagation();
|
|
3731
3738
|
}, []);
|
|
3732
|
-
return /* @__PURE__ */
|
|
3739
|
+
return /* @__PURE__ */ v("div", { ref: d, className: `tp-color-picker-input${l ? " tp-color-picker-input-open" : ""}`, onClick: ne, children: [
|
|
3733
3740
|
/* @__PURE__ */ c(
|
|
3734
3741
|
"button",
|
|
3735
3742
|
{
|
|
@@ -3754,30 +3761,30 @@ const kt = Mn(
|
|
|
3754
3761
|
onClick: ne
|
|
3755
3762
|
}
|
|
3756
3763
|
),
|
|
3757
|
-
l && /* @__PURE__ */
|
|
3764
|
+
l && /* @__PURE__ */ v("div", { ref: p, className: "tp-color-panel", style: { position: "fixed", top: `${k}px`, left: `${S}px` }, onClick: ne, children: [
|
|
3758
3765
|
/* @__PURE__ */ c(
|
|
3759
3766
|
"div",
|
|
3760
3767
|
{
|
|
3761
|
-
ref:
|
|
3768
|
+
ref: T,
|
|
3762
3769
|
className: "tp-sv-area",
|
|
3763
3770
|
style: {
|
|
3764
|
-
background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${
|
|
3771
|
+
background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${C.h}, 100%, 50%)`
|
|
3765
3772
|
},
|
|
3766
3773
|
onMouseDown: je,
|
|
3767
3774
|
children: /* @__PURE__ */ c(
|
|
3768
3775
|
"div",
|
|
3769
3776
|
{
|
|
3770
3777
|
className: "tp-sv-indicator",
|
|
3771
|
-
style: { left: `${
|
|
3778
|
+
style: { left: `${C.s}%`, top: `${100 - C.v}%` }
|
|
3772
3779
|
}
|
|
3773
3780
|
)
|
|
3774
3781
|
}
|
|
3775
3782
|
),
|
|
3776
|
-
/* @__PURE__ */ c("div", { ref:
|
|
3783
|
+
/* @__PURE__ */ c("div", { ref: m, className: "tp-hue-bar", onMouseDown: rt, children: /* @__PURE__ */ c(
|
|
3777
3784
|
"div",
|
|
3778
3785
|
{
|
|
3779
3786
|
className: "tp-hue-indicator",
|
|
3780
|
-
style: { left: `${
|
|
3787
|
+
style: { left: `${C.h / 360 * 100}%` }
|
|
3781
3788
|
}
|
|
3782
3789
|
) }),
|
|
3783
3790
|
/* @__PURE__ */ c("div", { className: "tp-color-section-label", children: "常用颜色" }),
|
|
@@ -3803,7 +3810,7 @@ const kt = Mn(
|
|
|
3803
3810
|
},
|
|
3804
3811
|
L
|
|
3805
3812
|
)) }),
|
|
3806
|
-
$ === "hex" && /* @__PURE__ */
|
|
3813
|
+
$ === "hex" && /* @__PURE__ */ v("div", { className: "tp-color-input-row", children: [
|
|
3807
3814
|
/* @__PURE__ */ c("label", { children: "HEX" }),
|
|
3808
3815
|
/* @__PURE__ */ c(
|
|
3809
3816
|
"input",
|
|
@@ -3819,7 +3826,7 @@ const kt = Mn(
|
|
|
3819
3826
|
}
|
|
3820
3827
|
)
|
|
3821
3828
|
] }),
|
|
3822
|
-
$ === "rgb" && /* @__PURE__ */
|
|
3829
|
+
$ === "rgb" && /* @__PURE__ */ v("div", { className: "tp-color-input-row tp-rgb-inline-row", children: [
|
|
3823
3830
|
/* @__PURE__ */ c("label", { children: "R" }),
|
|
3824
3831
|
/* @__PURE__ */ c("input", { type: "number", min: 0, max: 255, className: "tp-color-input-field", value: O.r, onChange: (L) => {
|
|
3825
3832
|
z((I) => ({ ...I, r: Number(L.target.value) })), setTimeout(nt, 0);
|
|
@@ -3833,7 +3840,7 @@ const kt = Mn(
|
|
|
3833
3840
|
z((I) => ({ ...I, b: Number(L.target.value) })), setTimeout(nt, 0);
|
|
3834
3841
|
}, onMouseDown: ne, onClick: ne })
|
|
3835
3842
|
] }),
|
|
3836
|
-
$ === "hsl" && /* @__PURE__ */
|
|
3843
|
+
$ === "hsl" && /* @__PURE__ */ v("div", { className: "tp-color-input-row tp-hsl-inline-row", children: [
|
|
3837
3844
|
/* @__PURE__ */ c("label", { children: "H" }),
|
|
3838
3845
|
/* @__PURE__ */ c("input", { type: "number", min: 0, max: 360, className: "tp-color-input-field", value: G.h, onChange: (L) => {
|
|
3839
3846
|
J((I) => ({ ...I, h: Number(L.target.value) })), setTimeout(Re, 0);
|
|
@@ -3850,12 +3857,12 @@ const kt = Mn(
|
|
|
3850
3857
|
}, onMouseDown: ne, onClick: ne }),
|
|
3851
3858
|
/* @__PURE__ */ c("span", { className: "tp-input-unit", children: "%" })
|
|
3852
3859
|
] }),
|
|
3853
|
-
/* @__PURE__ */
|
|
3860
|
+
/* @__PURE__ */ v("div", { className: "tp-color-footer-row", children: [
|
|
3854
3861
|
/* @__PURE__ */ c("div", { className: "tp-color-preview-label", children: "当前颜色" }),
|
|
3855
3862
|
/* @__PURE__ */ c("div", { className: "tp-color-preview-box", style: { backgroundColor: Me } }),
|
|
3856
|
-
/* @__PURE__ */
|
|
3857
|
-
/* @__PURE__ */ c("button", { type: "button", className: `tp-color-btn tp-color-btn-cancel${
|
|
3858
|
-
/* @__PURE__ */ c("button", { type: "button", className: `tp-color-btn tp-color-btn-confirm${
|
|
3863
|
+
/* @__PURE__ */ v("div", { className: "tp-color-actions", children: [
|
|
3864
|
+
/* @__PURE__ */ c("button", { type: "button", className: `tp-color-btn tp-color-btn-cancel${V ? " tp-color-btn-flash" : ""}`, title: "取消", onMouseDown: (L) => L.preventDefault(), onClick: g, children: "✕" }),
|
|
3865
|
+
/* @__PURE__ */ c("button", { type: "button", className: `tp-color-btn tp-color-btn-confirm${V ? " tp-color-btn-flash" : ""}`, title: "确认", onMouseDown: (L) => L.preventDefault(), onClick: Ct, children: "✓" })
|
|
3859
3866
|
] })
|
|
3860
3867
|
] })
|
|
3861
3868
|
] })
|
|
@@ -3864,15 +3871,15 @@ const kt = Mn(
|
|
|
3864
3871
|
);
|
|
3865
3872
|
kt.displayName = "ColorPickerInput";
|
|
3866
3873
|
const Dr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
3867
|
-
const r = Ve.getInstance(), o = (
|
|
3868
|
-
|
|
3874
|
+
const r = Ve.getInstance(), o = (m) => r.t(m), [s, i] = D({ borderColor: "#d9d9d9", borderWidth: 1 }), [l, a] = D("");
|
|
3875
|
+
_(() => {
|
|
3869
3876
|
if (e) {
|
|
3870
3877
|
document.body.style.overflow = "hidden";
|
|
3871
|
-
const { state:
|
|
3872
|
-
let
|
|
3873
|
-
|
|
3874
|
-
borderColor:
|
|
3875
|
-
borderWidth:
|
|
3878
|
+
const { state: m } = n, { $from: k } = m.selection;
|
|
3879
|
+
let y = null;
|
|
3880
|
+
m.doc.nodesBetween(k.start(), k.end(), (S) => S.type.name === "table" ? (y = S, !1) : !0), i(y ? {
|
|
3881
|
+
borderColor: y.attrs.borderColor || "#d9d9d9",
|
|
3882
|
+
borderWidth: y.attrs.borderWidth ? parseInt(y.attrs.borderWidth, 10) : 1
|
|
3876
3883
|
} : { borderColor: "#d9d9d9", borderWidth: 1 });
|
|
3877
3884
|
} else
|
|
3878
3885
|
document.body.style.overflow = "";
|
|
@@ -3882,9 +3889,9 @@ const Dr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
3882
3889
|
}, [e, n]);
|
|
3883
3890
|
const d = E(() => {
|
|
3884
3891
|
a("");
|
|
3885
|
-
}, []), p = E((
|
|
3892
|
+
}, []), p = E((m) => (a(m), !0), []), b = E(() => {
|
|
3886
3893
|
l || (n.commands.focus(), t(!1));
|
|
3887
|
-
}, [l, n, t]),
|
|
3894
|
+
}, [l, n, t]), T = E(() => {
|
|
3888
3895
|
l || (n.chain().focus().setTableBorder({
|
|
3889
3896
|
color: s.borderColor,
|
|
3890
3897
|
width: `${s.borderWidth}px`,
|
|
@@ -3892,21 +3899,21 @@ const Dr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
3892
3899
|
}).run(), t(!1));
|
|
3893
3900
|
}, [l, n, s, t]);
|
|
3894
3901
|
return e ? tt(
|
|
3895
|
-
/* @__PURE__ */ c("div", { className: "tp-modal-overlay", onMouseDown: (
|
|
3896
|
-
|
|
3897
|
-
}, children: /* @__PURE__ */
|
|
3898
|
-
/* @__PURE__ */
|
|
3902
|
+
/* @__PURE__ */ c("div", { className: "tp-modal-overlay", onMouseDown: (m) => {
|
|
3903
|
+
m.target === m.currentTarget && b();
|
|
3904
|
+
}, children: /* @__PURE__ */ v("div", { className: "tp-modal", onMouseDown: (m) => m.stopPropagation(), children: [
|
|
3905
|
+
/* @__PURE__ */ v("div", { className: "tp-modal-header", children: [
|
|
3899
3906
|
/* @__PURE__ */ c("h3", { className: "tp-modal-title", children: o("table.tableSettings") }),
|
|
3900
3907
|
/* @__PURE__ */ c("button", { className: "tp-modal-close", onClick: b, children: "×" })
|
|
3901
3908
|
] }),
|
|
3902
|
-
/* @__PURE__ */
|
|
3903
|
-
/* @__PURE__ */
|
|
3909
|
+
/* @__PURE__ */ v("div", { className: "tp-modal-body", children: [
|
|
3910
|
+
/* @__PURE__ */ v("div", { className: "tp-form-item", children: [
|
|
3904
3911
|
/* @__PURE__ */ c("label", { className: "tp-form-label", children: o("table.borderColor") }),
|
|
3905
3912
|
/* @__PURE__ */ c(
|
|
3906
3913
|
kt,
|
|
3907
3914
|
{
|
|
3908
3915
|
value: s.borderColor,
|
|
3909
|
-
onChange: (
|
|
3916
|
+
onChange: (m) => i((k) => ({ ...k, borderColor: m })),
|
|
3910
3917
|
mode: "border",
|
|
3911
3918
|
placeholder: "#d9d9d9",
|
|
3912
3919
|
beforeOpen: () => p("border"),
|
|
@@ -3914,9 +3921,9 @@ const Dr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
3914
3921
|
}
|
|
3915
3922
|
)
|
|
3916
3923
|
] }),
|
|
3917
|
-
/* @__PURE__ */
|
|
3924
|
+
/* @__PURE__ */ v("div", { className: "tp-form-item", children: [
|
|
3918
3925
|
/* @__PURE__ */ c("label", { className: "tp-form-label", children: o("table.borderWidth") }),
|
|
3919
|
-
/* @__PURE__ */
|
|
3926
|
+
/* @__PURE__ */ v("div", { className: "tp-input-with-suffix", children: [
|
|
3920
3927
|
/* @__PURE__ */ c(
|
|
3921
3928
|
"input",
|
|
3922
3929
|
{
|
|
@@ -3925,16 +3932,16 @@ const Dr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
3925
3932
|
min: 0,
|
|
3926
3933
|
max: 10,
|
|
3927
3934
|
value: s.borderWidth,
|
|
3928
|
-
onChange: (
|
|
3935
|
+
onChange: (m) => i((k) => ({ ...k, borderWidth: Number(m.target.value) }))
|
|
3929
3936
|
}
|
|
3930
3937
|
),
|
|
3931
3938
|
/* @__PURE__ */ c("span", { className: "tp-input-suffix", children: "px" })
|
|
3932
3939
|
] })
|
|
3933
3940
|
] })
|
|
3934
3941
|
] }),
|
|
3935
|
-
/* @__PURE__ */
|
|
3942
|
+
/* @__PURE__ */ v("div", { className: "tp-modal-footer", children: [
|
|
3936
3943
|
/* @__PURE__ */ c("button", { className: "tp-btn tp-btn-default", onClick: b, children: o("common.cancel") }),
|
|
3937
|
-
/* @__PURE__ */ c("button", { className: "tp-btn tp-btn-primary", onClick:
|
|
3944
|
+
/* @__PURE__ */ c("button", { className: "tp-btn tp-btn-primary", onClick: T, children: o("common.confirm") })
|
|
3938
3945
|
] })
|
|
3939
3946
|
] }) }),
|
|
3940
3947
|
document.body
|
|
@@ -4006,32 +4013,32 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4006
4013
|
backgroundColor: "#ffffff",
|
|
4007
4014
|
textAlign: "left",
|
|
4008
4015
|
verticalAlign: "top"
|
|
4009
|
-
}), [l, a] = D({ borderColor: "#d9d9d9", borderWidth: 1 }), [d, p] = D(""), b =
|
|
4010
|
-
const h = d === "border" ? b.current :
|
|
4016
|
+
}), [l, a] = D({ borderColor: "#d9d9d9", borderWidth: 1 }), [d, p] = D(""), b = H(null), T = H(null), m = E(() => {
|
|
4017
|
+
const h = d === "border" ? b.current : T.current;
|
|
4011
4018
|
h == null || h.triggerButtonFlash();
|
|
4012
|
-
}, [d]), k = E((h) => d && d !== h ? (
|
|
4013
|
-
const { state: h } = n, { selection:
|
|
4014
|
-
if ("$anchorCell" in
|
|
4015
|
-
const
|
|
4019
|
+
}, [d]), k = E((h) => d && d !== h ? (m(), !1) : (p(h), !0), [d, m]), y = E(() => {
|
|
4020
|
+
const { state: h } = n, { selection: x } = h;
|
|
4021
|
+
if ("$anchorCell" in x && x.$anchorCell) {
|
|
4022
|
+
const N = x.$anchorCell;
|
|
4016
4023
|
let $ = null;
|
|
4017
|
-
return h.doc.nodesBetween(
|
|
4024
|
+
return h.doc.nodesBetween(N.pos, N.pos + 1, (P) => P.type.name === "tableCell" || P.type.name === "tableHeader" ? ($ = P, !1) : !0), ($ == null ? void 0 : $.attrs) || null;
|
|
4018
4025
|
}
|
|
4019
|
-
const { $from: w } =
|
|
4020
|
-
let
|
|
4021
|
-
return h.doc.nodesBetween(w.pos, w.pos + 1, (
|
|
4026
|
+
const { $from: w } = x;
|
|
4027
|
+
let f = null;
|
|
4028
|
+
return h.doc.nodesBetween(w.pos, w.pos + 1, (N) => N.type.name === "tableCell" || N.type.name === "tableHeader" ? (f = N, !1) : !0), (f == null ? void 0 : f.attrs) || null;
|
|
4022
4029
|
}, [n]);
|
|
4023
|
-
|
|
4024
|
-
var h,
|
|
4030
|
+
_(() => {
|
|
4031
|
+
var h, x, w, f;
|
|
4025
4032
|
if (e) {
|
|
4026
4033
|
document.body.style.overflow = "hidden";
|
|
4027
|
-
const
|
|
4028
|
-
if (
|
|
4034
|
+
const N = y();
|
|
4035
|
+
if (N) {
|
|
4029
4036
|
const $ = {
|
|
4030
|
-
borderColor: ((
|
|
4031
|
-
borderWidth: (
|
|
4032
|
-
backgroundColor:
|
|
4033
|
-
textAlign:
|
|
4034
|
-
verticalAlign:
|
|
4037
|
+
borderColor: ((x = (h = N.borderLeft) == null ? void 0 : h.match(/#\w+/)) == null ? void 0 : x[0]) || "#d9d9d9",
|
|
4038
|
+
borderWidth: (f = (w = N.borderLeft) == null ? void 0 : w.match(/(\d+)px/)) != null && f[1] ? parseInt(N.borderLeft.match(/(\d+)px/)[1], 10) : 1,
|
|
4039
|
+
backgroundColor: N.backgroundColor || "#ffffff",
|
|
4040
|
+
textAlign: N.textAlign || "left",
|
|
4041
|
+
verticalAlign: N.verticalAlign || "middle"
|
|
4035
4042
|
};
|
|
4036
4043
|
i($), a({ borderColor: $.borderColor, borderWidth: $.borderWidth });
|
|
4037
4044
|
} else
|
|
@@ -4041,109 +4048,109 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4041
4048
|
return () => {
|
|
4042
4049
|
document.body.style.overflow = "";
|
|
4043
4050
|
};
|
|
4044
|
-
}, [e,
|
|
4045
|
-
const
|
|
4051
|
+
}, [e, y]);
|
|
4052
|
+
const S = E(() => {
|
|
4046
4053
|
d || (n.commands.focus(), t(!1));
|
|
4047
4054
|
}, [d, n, t]), u = E(() => {
|
|
4048
4055
|
if (d)
|
|
4049
4056
|
return;
|
|
4050
|
-
const { state: h, dispatch:
|
|
4057
|
+
const { state: h, dispatch: x } = n.view, { selection: w } = h, f = w, N = h.tr;
|
|
4051
4058
|
let $ = !1;
|
|
4052
|
-
const P = s.borderColor !== l.borderColor || s.borderWidth !== l.borderWidth,
|
|
4053
|
-
const re =
|
|
4054
|
-
if (
|
|
4055
|
-
const Me =
|
|
4059
|
+
const P = s.borderColor !== l.borderColor || s.borderWidth !== l.borderWidth, C = `${s.borderWidth}px solid ${s.borderColor}`, A = (K, W, B, F, V, q) => {
|
|
4060
|
+
const re = V + 1, oe = Or(K, B.row, B.col, F, q, C, s.backgroundColor, s.textAlign, s.verticalAlign, P);
|
|
4061
|
+
if (N.setNodeMarkup(W, null, oe), $ = !0, !P) return;
|
|
4062
|
+
const Me = K.attrs.colspan || 1, se = K.attrs.rowspan || 1, ge = "1px solid #d9d9d9", pe = /* @__PURE__ */ new Map();
|
|
4056
4063
|
for (let Y = 0; Y < F.height; Y++)
|
|
4057
4064
|
for (let ie = 0; ie < F.width; ie++) {
|
|
4058
4065
|
const j = F.map[Y * F.width + ie];
|
|
4059
4066
|
pe.has(j) || pe.set(j, { row: Y, col: ie });
|
|
4060
4067
|
}
|
|
4061
|
-
if (
|
|
4062
|
-
const Y = F.map[
|
|
4068
|
+
if (B.col > 0) {
|
|
4069
|
+
const Y = F.map[B.row * F.width + B.col - 1], ie = re + Y, j = N.doc.nodeAt(ie);
|
|
4063
4070
|
if (j && (j.type.name === "tableCell" || j.type.name === "tableHeader")) {
|
|
4064
4071
|
const Z = pe.get(Y);
|
|
4065
4072
|
if (Z && !Se(Z.row, Z.col, j.attrs.colspan || 1, j.attrs.rowspan || 1, F, "right")) {
|
|
4066
4073
|
const Ne = mt(j, Z.row, Z.col, F, q, ge, "right", oe.borderLeft);
|
|
4067
|
-
|
|
4074
|
+
N.setNodeMarkup(ie, null, Ne);
|
|
4068
4075
|
}
|
|
4069
4076
|
}
|
|
4070
4077
|
}
|
|
4071
|
-
if (
|
|
4072
|
-
const Y = F.map[(
|
|
4078
|
+
if (B.row > 0) {
|
|
4079
|
+
const Y = F.map[(B.row - 1) * F.width + B.col], ie = re + Y, j = N.doc.nodeAt(ie);
|
|
4073
4080
|
if (j && (j.type.name === "tableCell" || j.type.name === "tableHeader")) {
|
|
4074
4081
|
const Z = pe.get(Y);
|
|
4075
4082
|
if (Z && !Se(Z.row, Z.col, j.attrs.colspan || 1, j.attrs.rowspan || 1, F, "bottom")) {
|
|
4076
4083
|
const Ne = mt(j, Z.row, Z.col, F, q, ge, "bottom", oe.borderTop);
|
|
4077
|
-
|
|
4084
|
+
N.setNodeMarkup(ie, null, Ne);
|
|
4078
4085
|
}
|
|
4079
4086
|
}
|
|
4080
4087
|
}
|
|
4081
|
-
if (
|
|
4082
|
-
const Y = F.map[
|
|
4088
|
+
if (B.col + (K.attrs.colspan || 1) < F.width) {
|
|
4089
|
+
const Y = F.map[B.row * F.width + B.col + Me], ie = re + Y, j = N.doc.nodeAt(ie);
|
|
4083
4090
|
if (j && (j.type.name === "tableCell" || j.type.name === "tableHeader")) {
|
|
4084
4091
|
const Z = pe.get(Y);
|
|
4085
4092
|
if (Z && !Se(Z.row, Z.col, j.attrs.colspan || 1, j.attrs.rowspan || 1, F, "left")) {
|
|
4086
4093
|
const Ne = mt(j, Z.row, Z.col, F, q, ge, "left", oe.borderRight);
|
|
4087
|
-
|
|
4094
|
+
N.setNodeMarkup(ie, null, Ne);
|
|
4088
4095
|
}
|
|
4089
4096
|
}
|
|
4090
4097
|
}
|
|
4091
|
-
if (
|
|
4092
|
-
const Y = F.map[(
|
|
4098
|
+
if (B.row + (K.attrs.rowspan || 1) < F.height) {
|
|
4099
|
+
const Y = F.map[(B.row + se) * F.width + B.col], ie = re + Y, j = N.doc.nodeAt(ie);
|
|
4093
4100
|
if (j && (j.type.name === "tableCell" || j.type.name === "tableHeader")) {
|
|
4094
4101
|
const Z = pe.get(Y);
|
|
4095
4102
|
if (Z && !Se(Z.row, Z.col, j.attrs.colspan || 1, j.attrs.rowspan || 1, F, "top")) {
|
|
4096
4103
|
const Ne = mt(j, Z.row, Z.col, F, q, ge, "top", oe.borderBottom);
|
|
4097
|
-
|
|
4104
|
+
N.setNodeMarkup(ie, null, Ne);
|
|
4098
4105
|
}
|
|
4099
4106
|
}
|
|
4100
4107
|
}
|
|
4101
4108
|
}, { $from: O, $to: z } = w;
|
|
4102
4109
|
let G = -1, J = null;
|
|
4103
|
-
if (h.doc.nodesBetween(O.pos, z.pos, (
|
|
4104
|
-
const
|
|
4105
|
-
for (let
|
|
4110
|
+
if (h.doc.nodesBetween(O.pos, z.pos, (K, W) => K.type.name === "table" ? (G = W, J = K, !1) : !0), J && G >= 0) {
|
|
4111
|
+
const K = $r(J), W = Te.get(J), B = G + 1, F = /* @__PURE__ */ new Map();
|
|
4112
|
+
for (let V = 0; V < W.height; V++)
|
|
4106
4113
|
for (let q = 0; q < W.width; q++) {
|
|
4107
|
-
const re = W.map[
|
|
4108
|
-
F.has(re) || F.set(re, { row:
|
|
4114
|
+
const re = W.map[V * W.width + q];
|
|
4115
|
+
F.has(re) || F.set(re, { row: V, col: q });
|
|
4109
4116
|
}
|
|
4110
4117
|
if ("$anchorCell" in w && w.$anchorCell) {
|
|
4111
|
-
const
|
|
4118
|
+
const V = w.$anchorCell, q = w.$headCell, re = V.pos - B, oe = q.pos - B, Me = W.rectBetween(re, oe);
|
|
4112
4119
|
W.cellsInRect(Me).forEach((ge) => {
|
|
4113
|
-
const pe =
|
|
4120
|
+
const pe = B + ge, Y = h.doc.nodeAt(pe);
|
|
4114
4121
|
if (Y && (Y.type.name === "tableCell" || Y.type.name === "tableHeader")) {
|
|
4115
4122
|
const ie = F.get(ge);
|
|
4116
|
-
ie && A(Y, pe, ie, W, G,
|
|
4123
|
+
ie && A(Y, pe, ie, W, G, K);
|
|
4117
4124
|
}
|
|
4118
4125
|
});
|
|
4119
4126
|
} else
|
|
4120
|
-
h.doc.nodesBetween(O.pos, z.pos, (
|
|
4121
|
-
if (
|
|
4122
|
-
const re = q -
|
|
4123
|
-
oe && A(
|
|
4127
|
+
h.doc.nodesBetween(O.pos, z.pos, (V, q) => {
|
|
4128
|
+
if (V.type.name === "tableCell" || V.type.name === "tableHeader") {
|
|
4129
|
+
const re = q - B, oe = F.get(re);
|
|
4130
|
+
oe && A(V, q, oe, W, G, K);
|
|
4124
4131
|
}
|
|
4125
4132
|
return !0;
|
|
4126
4133
|
});
|
|
4127
4134
|
}
|
|
4128
|
-
$ &&
|
|
4135
|
+
$ && x && (N.setSelection(f.map(N.doc, N.mapping)), x(N), n.commands.focus()), t(!1);
|
|
4129
4136
|
}, [d, n, s, l, t]);
|
|
4130
4137
|
return e ? tt(
|
|
4131
4138
|
/* @__PURE__ */ c("div", { className: "tp-modal-overlay", onMouseDown: (h) => {
|
|
4132
|
-
h.target === h.currentTarget &&
|
|
4133
|
-
}, children: /* @__PURE__ */
|
|
4134
|
-
/* @__PURE__ */
|
|
4139
|
+
h.target === h.currentTarget && S();
|
|
4140
|
+
}, children: /* @__PURE__ */ v("div", { className: "tp-modal", onMouseDown: (h) => h.stopPropagation(), children: [
|
|
4141
|
+
/* @__PURE__ */ v("div", { className: "tp-modal-header", children: [
|
|
4135
4142
|
/* @__PURE__ */ c("h3", { className: "tp-modal-title", children: o("table.cellSettings") }),
|
|
4136
|
-
/* @__PURE__ */ c("button", { className: "tp-modal-close", onClick:
|
|
4143
|
+
/* @__PURE__ */ c("button", { className: "tp-modal-close", onClick: S, children: "×" })
|
|
4137
4144
|
] }),
|
|
4138
|
-
/* @__PURE__ */
|
|
4139
|
-
/* @__PURE__ */
|
|
4145
|
+
/* @__PURE__ */ v("div", { className: "tp-modal-body", children: [
|
|
4146
|
+
/* @__PURE__ */ v("div", { className: "tp-form-item", children: [
|
|
4140
4147
|
/* @__PURE__ */ c("label", { className: "tp-form-label", children: o("table.borderColor") }),
|
|
4141
4148
|
/* @__PURE__ */ c(
|
|
4142
4149
|
kt,
|
|
4143
4150
|
{
|
|
4144
4151
|
ref: b,
|
|
4145
4152
|
value: s.borderColor,
|
|
4146
|
-
onChange: (h) => i((
|
|
4153
|
+
onChange: (h) => i((x) => ({ ...x, borderColor: h })),
|
|
4147
4154
|
mode: "border",
|
|
4148
4155
|
placeholder: "#d9d9d9",
|
|
4149
4156
|
beforeOpen: () => k("border"),
|
|
@@ -4151,21 +4158,21 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4151
4158
|
}
|
|
4152
4159
|
)
|
|
4153
4160
|
] }),
|
|
4154
|
-
/* @__PURE__ */
|
|
4161
|
+
/* @__PURE__ */ v("div", { className: "tp-form-item", children: [
|
|
4155
4162
|
/* @__PURE__ */ c("label", { className: "tp-form-label", children: o("table.borderWidth") }),
|
|
4156
|
-
/* @__PURE__ */
|
|
4157
|
-
/* @__PURE__ */ c("input", { type: "number", className: "tp-text-input", min: 0, max: 10, value: s.borderWidth, onChange: (h) => i((
|
|
4163
|
+
/* @__PURE__ */ v("div", { className: "tp-input-with-suffix", children: [
|
|
4164
|
+
/* @__PURE__ */ c("input", { type: "number", className: "tp-text-input", min: 0, max: 10, value: s.borderWidth, onChange: (h) => i((x) => ({ ...x, borderWidth: Number(h.target.value) })) }),
|
|
4158
4165
|
/* @__PURE__ */ c("span", { className: "tp-input-suffix", children: "px" })
|
|
4159
4166
|
] })
|
|
4160
4167
|
] }),
|
|
4161
|
-
/* @__PURE__ */
|
|
4168
|
+
/* @__PURE__ */ v("div", { className: "tp-form-item", children: [
|
|
4162
4169
|
/* @__PURE__ */ c("label", { className: "tp-form-label", children: o("table.backgroundColor") }),
|
|
4163
4170
|
/* @__PURE__ */ c(
|
|
4164
4171
|
kt,
|
|
4165
4172
|
{
|
|
4166
|
-
ref:
|
|
4173
|
+
ref: T,
|
|
4167
4174
|
value: s.backgroundColor,
|
|
4168
|
-
onChange: (h) => i((
|
|
4175
|
+
onChange: (h) => i((x) => ({ ...x, backgroundColor: h })),
|
|
4169
4176
|
mode: "background",
|
|
4170
4177
|
placeholder: "transparent",
|
|
4171
4178
|
beforeOpen: () => k("background"),
|
|
@@ -4173,29 +4180,29 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4173
4180
|
}
|
|
4174
4181
|
)
|
|
4175
4182
|
] }),
|
|
4176
|
-
/* @__PURE__ */
|
|
4183
|
+
/* @__PURE__ */ v("div", { className: "tp-form-item", children: [
|
|
4177
4184
|
/* @__PURE__ */ c("label", { className: "tp-form-label", children: o("table.textAlign") }),
|
|
4178
|
-
/* @__PURE__ */ c("div", { className: "tp-align-options", children: Ar.map((h) => /* @__PURE__ */
|
|
4179
|
-
/* @__PURE__ */
|
|
4180
|
-
h.value === "left" && /* @__PURE__ */
|
|
4185
|
+
/* @__PURE__ */ c("div", { className: "tp-align-options", children: Ar.map((h) => /* @__PURE__ */ v("button", { className: `tp-align-btn${s.textAlign === h.value ? " active" : ""}`, onClick: () => i((x) => ({ ...x, textAlign: h.value })), children: [
|
|
4186
|
+
/* @__PURE__ */ v("span", { className: "tp-align-icon tp-align-icon-svg", children: [
|
|
4187
|
+
h.value === "left" && /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
4181
4188
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
4182
4189
|
/* @__PURE__ */ c("line", { x1: "6", y1: "8", x2: "14", y2: "8" }),
|
|
4183
4190
|
/* @__PURE__ */ c("line", { x1: "6", y1: "12", x2: "11", y2: "12" }),
|
|
4184
4191
|
/* @__PURE__ */ c("line", { x1: "6", y1: "16", x2: "16", y2: "16" })
|
|
4185
4192
|
] }),
|
|
4186
|
-
h.value === "center" && /* @__PURE__ */
|
|
4193
|
+
h.value === "center" && /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
4187
4194
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
4188
4195
|
/* @__PURE__ */ c("line", { x1: "7", y1: "8", x2: "17", y2: "8" }),
|
|
4189
4196
|
/* @__PURE__ */ c("line", { x1: "9", y1: "12", x2: "15", y2: "12" }),
|
|
4190
4197
|
/* @__PURE__ */ c("line", { x1: "8", y1: "16", x2: "16", y2: "16" })
|
|
4191
4198
|
] }),
|
|
4192
|
-
h.value === "right" && /* @__PURE__ */
|
|
4199
|
+
h.value === "right" && /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
4193
4200
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
4194
4201
|
/* @__PURE__ */ c("line", { x1: "10", y1: "8", x2: "18", y2: "8" }),
|
|
4195
4202
|
/* @__PURE__ */ c("line", { x1: "13", y1: "12", x2: "18", y2: "12" }),
|
|
4196
4203
|
/* @__PURE__ */ c("line", { x1: "8", y1: "16", x2: "18", y2: "16" })
|
|
4197
4204
|
] }),
|
|
4198
|
-
h.value === "justify" && /* @__PURE__ */
|
|
4205
|
+
h.value === "justify" && /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
4199
4206
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
4200
4207
|
/* @__PURE__ */ c("line", { x1: "6", y1: "8", x2: "18", y2: "8" }),
|
|
4201
4208
|
/* @__PURE__ */ c("line", { x1: "6", y1: "12", x2: "18", y2: "12" }),
|
|
@@ -4205,19 +4212,19 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4205
4212
|
/* @__PURE__ */ c("span", { className: "tp-align-label", children: o(h.labelKey) })
|
|
4206
4213
|
] }, h.value)) })
|
|
4207
4214
|
] }),
|
|
4208
|
-
/* @__PURE__ */
|
|
4215
|
+
/* @__PURE__ */ v("div", { className: "tp-form-item", children: [
|
|
4209
4216
|
/* @__PURE__ */ c("label", { className: "tp-form-label", children: o("table.verticalAlign") }),
|
|
4210
|
-
/* @__PURE__ */ c("div", { className: "tp-align-options", children: Ir.map((h) => /* @__PURE__ */
|
|
4211
|
-
/* @__PURE__ */
|
|
4212
|
-
h.value === "top" && /* @__PURE__ */
|
|
4217
|
+
/* @__PURE__ */ c("div", { className: "tp-align-options", children: Ir.map((h) => /* @__PURE__ */ v("button", { className: `tp-align-btn${s.verticalAlign === h.value ? " active" : ""}`, onClick: () => i((x) => ({ ...x, verticalAlign: h.value })), children: [
|
|
4218
|
+
/* @__PURE__ */ v("span", { className: "tp-align-icon tp-align-icon-svg", children: [
|
|
4219
|
+
h.value === "top" && /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
4213
4220
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
4214
4221
|
/* @__PURE__ */ c("line", { x1: "6", y1: "7", x2: "18", y2: "7" })
|
|
4215
4222
|
] }),
|
|
4216
|
-
h.value === "middle" && /* @__PURE__ */
|
|
4223
|
+
h.value === "middle" && /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
4217
4224
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
4218
4225
|
/* @__PURE__ */ c("line", { x1: "6", y1: "12", x2: "18", y2: "12" })
|
|
4219
4226
|
] }),
|
|
4220
|
-
h.value === "bottom" && /* @__PURE__ */
|
|
4227
|
+
h.value === "bottom" && /* @__PURE__ */ v("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
4221
4228
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
4222
4229
|
/* @__PURE__ */ c("line", { x1: "6", y1: "17", x2: "18", y2: "17" })
|
|
4223
4230
|
] })
|
|
@@ -4226,22 +4233,22 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4226
4233
|
] }, h.value)) })
|
|
4227
4234
|
] })
|
|
4228
4235
|
] }),
|
|
4229
|
-
/* @__PURE__ */
|
|
4230
|
-
/* @__PURE__ */ c("button", { className: "tp-btn tp-btn-default", onClick:
|
|
4236
|
+
/* @__PURE__ */ v("div", { className: "tp-modal-footer", children: [
|
|
4237
|
+
/* @__PURE__ */ c("button", { className: "tp-btn tp-btn-default", onClick: S, children: o("common.cancel") }),
|
|
4231
4238
|
/* @__PURE__ */ c("button", { className: "tp-btn tp-btn-primary", onClick: u, children: o("common.confirm") })
|
|
4232
4239
|
] })
|
|
4233
4240
|
] }) }),
|
|
4234
4241
|
document.body
|
|
4235
4242
|
) : null;
|
|
4236
4243
|
}, Br = ({ manager: n, visible: e, onVisibleChange: t }) => {
|
|
4237
|
-
const r = Ve.getInstance(), [o, s] = D([]), [i, l] = D(""), [a, d] = D(null), [p, b] = D(!1),
|
|
4244
|
+
const r = Ve.getInstance(), [o, s] = D([]), [i, l] = D(""), [a, d] = D(null), [p, b] = D(!1), T = H(null), m = H(null), k = H(null), y = E((f) => r.t(f) || f, [r]), S = E((f) => {
|
|
4238
4245
|
try {
|
|
4239
|
-
const
|
|
4240
|
-
return
|
|
4246
|
+
const N = new Date(f), P = (/* @__PURE__ */ new Date()).getTime() - N.getTime(), C = Math.floor(P / 6e4), A = Math.floor(P / 36e5), O = Math.floor(P / 864e5);
|
|
4247
|
+
return C < 1 ? "刚刚" : C < 60 ? `${C} 分钟前` : A < 24 ? `${A} 小时前` : O < 7 ? `${O} 天前` : N.toLocaleDateString() + " " + N.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
4241
4248
|
} catch {
|
|
4242
|
-
return
|
|
4249
|
+
return f;
|
|
4243
4250
|
}
|
|
4244
|
-
}, [
|
|
4251
|
+
}, [y]), u = E((f) => ({
|
|
4245
4252
|
blur: "失焦时",
|
|
4246
4253
|
baseline: "会话基线",
|
|
4247
4254
|
paste: "粘贴后",
|
|
@@ -4249,181 +4256,181 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4249
4256
|
manual: "手动创建",
|
|
4250
4257
|
interval: "定时快照",
|
|
4251
4258
|
imported: "快照注入"
|
|
4252
|
-
})[
|
|
4253
|
-
|
|
4259
|
+
})[f] || f, []), h = E((f, N) => `v${o.length - N}.0 - ${S(f.timestamp)} (${u(f.source)})${f.label ? ` - ${f.label}` : ""}`, [S, u, o]);
|
|
4260
|
+
_(() => {
|
|
4254
4261
|
if (!e) {
|
|
4255
4262
|
l(""), d(null);
|
|
4256
4263
|
return;
|
|
4257
4264
|
}
|
|
4258
|
-
let
|
|
4259
|
-
return b(!0), n.listVersions().then((
|
|
4260
|
-
|
|
4265
|
+
let f = !1;
|
|
4266
|
+
return b(!0), n.listVersions().then((N) => {
|
|
4267
|
+
f || (s(N), !i && N.length > 0 && l(N[0].id), b(!1));
|
|
4261
4268
|
}).catch(() => {
|
|
4262
|
-
|
|
4269
|
+
f || (s([]), b(!1));
|
|
4263
4270
|
}), () => {
|
|
4264
|
-
|
|
4271
|
+
f = !0;
|
|
4265
4272
|
};
|
|
4266
|
-
}, [e, n]),
|
|
4273
|
+
}, [e, n]), _(() => {
|
|
4267
4274
|
if (!i || !n) {
|
|
4268
4275
|
d(null);
|
|
4269
4276
|
return;
|
|
4270
4277
|
}
|
|
4271
4278
|
n.compareWithVersion(i).then(d).catch(() => d(null));
|
|
4272
|
-
}, [i, n]),
|
|
4273
|
-
var
|
|
4274
|
-
if (a &&
|
|
4275
|
-
(
|
|
4276
|
-
const $ = new Dn(
|
|
4279
|
+
}, [i, n]), _(() => {
|
|
4280
|
+
var f, N;
|
|
4281
|
+
if (a && T.current && m.current) {
|
|
4282
|
+
(f = k.current) == null || f.detach();
|
|
4283
|
+
const $ = new Dn(T.current, m.current);
|
|
4277
4284
|
$.attach();
|
|
4278
4285
|
const P = setTimeout(() => $.refresh(), 0);
|
|
4279
4286
|
return k.current = $, () => {
|
|
4280
4287
|
clearTimeout(P), $.detach();
|
|
4281
4288
|
};
|
|
4282
4289
|
} else
|
|
4283
|
-
(
|
|
4284
|
-
}, [a]),
|
|
4285
|
-
const
|
|
4286
|
-
|
|
4290
|
+
(N = k.current) == null || N.detach(), k.current = null;
|
|
4291
|
+
}, [a]), _(() => {
|
|
4292
|
+
const f = (N) => {
|
|
4293
|
+
N.key === "Escape" && e && t(!1);
|
|
4287
4294
|
};
|
|
4288
|
-
return document.addEventListener("keydown",
|
|
4295
|
+
return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
|
|
4289
4296
|
}, [e, t]);
|
|
4290
|
-
const
|
|
4291
|
-
const
|
|
4292
|
-
|
|
4293
|
-
const
|
|
4294
|
-
s(
|
|
4295
|
-
}, [n,
|
|
4297
|
+
const x = E(async () => {
|
|
4298
|
+
const f = await n.createSnapshot(y("compare.createSnapshot"));
|
|
4299
|
+
f ? yt(y("compare.snapshotCreated").replace("{time}", f.label || f.timestamp)) : yt({ message: y("compare.snapshotFailed"), type: "error" });
|
|
4300
|
+
const N = await n.listVersions();
|
|
4301
|
+
s(N);
|
|
4302
|
+
}, [n, y]), w = E(() => {
|
|
4296
4303
|
t(!1);
|
|
4297
4304
|
}, [t]);
|
|
4298
|
-
return e ? /* @__PURE__ */
|
|
4299
|
-
/* @__PURE__ */
|
|
4300
|
-
/* @__PURE__ */
|
|
4301
|
-
/* @__PURE__ */
|
|
4305
|
+
return e ? /* @__PURE__ */ v("div", { className: "cyte-compare-overlay", children: [
|
|
4306
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-header", children: [
|
|
4307
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-header__title", children: [
|
|
4308
|
+
/* @__PURE__ */ v("svg", { className: "cyte-compare-header__title-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4302
4309
|
/* @__PURE__ */ c("rect", { x: "3", y: "3", width: "7", height: "18", rx: "1" }),
|
|
4303
4310
|
/* @__PURE__ */ c("rect", { x: "14", y: "3", width: "7", height: "18", rx: "1" }),
|
|
4304
4311
|
/* @__PURE__ */ c("line", { x1: "10", y1: "8", x2: "14", y2: "8" }),
|
|
4305
4312
|
/* @__PURE__ */ c("line", { x1: "10", y1: "12", x2: "14", y2: "12" }),
|
|
4306
4313
|
/* @__PURE__ */ c("line", { x1: "10", y1: "16", x2: "14", y2: "16" })
|
|
4307
4314
|
] }),
|
|
4308
|
-
|
|
4315
|
+
y("compare.title")
|
|
4309
4316
|
] }),
|
|
4310
|
-
/* @__PURE__ */
|
|
4311
|
-
/* @__PURE__ */
|
|
4312
|
-
/* @__PURE__ */
|
|
4313
|
-
|
|
4317
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-header__actions", children: [
|
|
4318
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-version-selector", children: [
|
|
4319
|
+
/* @__PURE__ */ v("span", { className: "cyte-compare-version-selector__label", children: [
|
|
4320
|
+
y("compare.selectVersion"),
|
|
4314
4321
|
":"
|
|
4315
4322
|
] }),
|
|
4316
|
-
/* @__PURE__ */
|
|
4323
|
+
/* @__PURE__ */ v(
|
|
4317
4324
|
"select",
|
|
4318
4325
|
{
|
|
4319
4326
|
value: i,
|
|
4320
|
-
onChange: (
|
|
4327
|
+
onChange: (f) => l(f.target.value),
|
|
4321
4328
|
className: "cyte-compare-version-selector__select",
|
|
4322
4329
|
children: [
|
|
4323
|
-
/* @__PURE__ */ c("option", { value: "", disabled: !0, children:
|
|
4324
|
-
o.map((
|
|
4330
|
+
/* @__PURE__ */ c("option", { value: "", disabled: !0, children: y("compare.selectVersion") }),
|
|
4331
|
+
o.map((f, N) => /* @__PURE__ */ c("option", { value: f.id, children: h(f, N) }, f.id))
|
|
4325
4332
|
]
|
|
4326
4333
|
}
|
|
4327
4334
|
)
|
|
4328
4335
|
] }),
|
|
4329
|
-
/* @__PURE__ */ c("button", { className: "cyte-compare-btn--close", onClick: w, title:
|
|
4336
|
+
/* @__PURE__ */ c("button", { className: "cyte-compare-btn--close", onClick: w, title: y("compare.close"), children: "✕" })
|
|
4330
4337
|
] })
|
|
4331
4338
|
] }),
|
|
4332
|
-
a && /* @__PURE__ */
|
|
4333
|
-
/* @__PURE__ */
|
|
4334
|
-
/* @__PURE__ */
|
|
4339
|
+
a && /* @__PURE__ */ v("div", { className: "cyte-compare-stats", children: [
|
|
4340
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-stats__item", children: [
|
|
4341
|
+
/* @__PURE__ */ v("span", { className: "cyte-compare-stats__badge", children: [
|
|
4335
4342
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--added" }),
|
|
4336
4343
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__count cyte-compare-stats__count--added", children: a.stats.added })
|
|
4337
4344
|
] }),
|
|
4338
|
-
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children:
|
|
4345
|
+
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children: y("compare.statsAdded") })
|
|
4339
4346
|
] }),
|
|
4340
|
-
/* @__PURE__ */
|
|
4341
|
-
/* @__PURE__ */
|
|
4347
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-stats__item", children: [
|
|
4348
|
+
/* @__PURE__ */ v("span", { className: "cyte-compare-stats__badge", children: [
|
|
4342
4349
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--removed" }),
|
|
4343
4350
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__count cyte-compare-stats__count--removed", children: a.stats.removed })
|
|
4344
4351
|
] }),
|
|
4345
|
-
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children:
|
|
4352
|
+
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children: y("compare.statsRemoved") })
|
|
4346
4353
|
] }),
|
|
4347
|
-
/* @__PURE__ */
|
|
4348
|
-
/* @__PURE__ */
|
|
4354
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-stats__item", children: [
|
|
4355
|
+
/* @__PURE__ */ v("span", { className: "cyte-compare-stats__badge", children: [
|
|
4349
4356
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--modified" }),
|
|
4350
4357
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__count cyte-compare-stats__count--modified", children: a.stats.modified })
|
|
4351
4358
|
] }),
|
|
4352
|
-
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children:
|
|
4359
|
+
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children: y("compare.statsModified") })
|
|
4353
4360
|
] }),
|
|
4354
|
-
/* @__PURE__ */
|
|
4355
|
-
/* @__PURE__ */
|
|
4361
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-stats__item cyte-compare-stats__item--unchanged", children: [
|
|
4362
|
+
/* @__PURE__ */ v("span", { className: "cyte-compare-stats__badge", children: [
|
|
4356
4363
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--unchanged" }),
|
|
4357
4364
|
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__count", children: a.stats.unchanged })
|
|
4358
4365
|
] }),
|
|
4359
|
-
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children:
|
|
4366
|
+
/* @__PURE__ */ c("span", { className: "cyte-compare-stats__label", children: y("compare.statsUnchanged") })
|
|
4360
4367
|
] })
|
|
4361
4368
|
] }),
|
|
4362
|
-
/* @__PURE__ */
|
|
4363
|
-
o.length === 0 && !p && /* @__PURE__ */
|
|
4364
|
-
/* @__PURE__ */
|
|
4369
|
+
/* @__PURE__ */ v("div", { className: "cyte-compare-content", children: [
|
|
4370
|
+
o.length === 0 && !p && /* @__PURE__ */ v("div", { className: "cyte-compare-empty", children: [
|
|
4371
|
+
/* @__PURE__ */ v("svg", { className: "cyte-compare-empty__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
4365
4372
|
/* @__PURE__ */ c("circle", { cx: "12", cy: "12", r: "10" }),
|
|
4366
4373
|
/* @__PURE__ */ c("path", { d: "M8 12h8M12 8v8" })
|
|
4367
4374
|
] }),
|
|
4368
|
-
/* @__PURE__ */ c("div", { className: "cyte-compare-empty__text", children:
|
|
4369
|
-
/* @__PURE__ */ c("div", { className: "cyte-compare-empty__hint", children:
|
|
4370
|
-
/* @__PURE__ */ c("button", { className: "cyte-compare-btn cyte-compare-btn--primary cyte-compare-snapshot-btn", onClick:
|
|
4375
|
+
/* @__PURE__ */ c("div", { className: "cyte-compare-empty__text", children: y("compare.noVersions") }),
|
|
4376
|
+
/* @__PURE__ */ c("div", { className: "cyte-compare-empty__hint", children: y("compare.noVersionsHint") }),
|
|
4377
|
+
/* @__PURE__ */ c("button", { className: "cyte-compare-btn cyte-compare-btn--primary cyte-compare-snapshot-btn", onClick: x, children: y("compare.createSnapshot") })
|
|
4371
4378
|
] }),
|
|
4372
|
-
a && /* @__PURE__ */
|
|
4373
|
-
/* @__PURE__ */
|
|
4379
|
+
a && /* @__PURE__ */ v(Ft, { children: [
|
|
4380
|
+
/* @__PURE__ */ v("div", { ref: T, className: "cyte-compare-pane", children: [
|
|
4374
4381
|
/* @__PURE__ */ c("div", { className: "cyte-compare-pane__header", children: (() => {
|
|
4375
|
-
const
|
|
4376
|
-
return
|
|
4382
|
+
const f = o.findIndex((N) => N.id === i);
|
|
4383
|
+
return f === -1 ? y("compare.leftLabel") : `${y("compare.leftLabel")} - ${h(o[f], f)}`;
|
|
4377
4384
|
})() }),
|
|
4378
|
-
/* @__PURE__ */ c("div", { className: "cyte-compare-pane__body", children: a.left.map((
|
|
4385
|
+
/* @__PURE__ */ c("div", { className: "cyte-compare-pane__body", children: a.left.map((f) => /* @__PURE__ */ c(
|
|
4379
4386
|
"div",
|
|
4380
4387
|
{
|
|
4381
|
-
dangerouslySetInnerHTML: { __html:
|
|
4388
|
+
dangerouslySetInnerHTML: { __html: f.html }
|
|
4382
4389
|
},
|
|
4383
|
-
|
|
4390
|
+
f.key
|
|
4384
4391
|
)) })
|
|
4385
4392
|
] }),
|
|
4386
|
-
/* @__PURE__ */
|
|
4387
|
-
/* @__PURE__ */ c("div", { className: "cyte-compare-pane__header", children:
|
|
4388
|
-
/* @__PURE__ */ c("div", { className: "cyte-compare-pane__body", children: a.right.map((
|
|
4393
|
+
/* @__PURE__ */ v("div", { ref: m, className: "cyte-compare-pane", children: [
|
|
4394
|
+
/* @__PURE__ */ c("div", { className: "cyte-compare-pane__header", children: y("compare.rightLabel") }),
|
|
4395
|
+
/* @__PURE__ */ c("div", { className: "cyte-compare-pane__body", children: a.right.map((f) => /* @__PURE__ */ c(
|
|
4389
4396
|
"div",
|
|
4390
4397
|
{
|
|
4391
|
-
dangerouslySetInnerHTML: { __html:
|
|
4398
|
+
dangerouslySetInnerHTML: { __html: f.html }
|
|
4392
4399
|
},
|
|
4393
|
-
|
|
4400
|
+
f.key
|
|
4394
4401
|
)) })
|
|
4395
4402
|
] })
|
|
4396
4403
|
] }),
|
|
4397
|
-
o.length > 0 && !i && !a && /* @__PURE__ */ c("div", { className: "cyte-compare-empty", children: /* @__PURE__ */ c("div", { className: "cyte-compare-empty__text", children:
|
|
4404
|
+
o.length > 0 && !i && !a && /* @__PURE__ */ c("div", { className: "cyte-compare-empty", children: /* @__PURE__ */ c("div", { className: "cyte-compare-empty__text", children: y("compare.selectVersion") }) })
|
|
4398
4405
|
] })
|
|
4399
4406
|
] }) : null;
|
|
4400
4407
|
}, zr = ({ visible: n, defaultFilename: e, onConfirm: t, onCancel: r, onClose: o }) => {
|
|
4401
|
-
const { t: s } = be(), [i, l] = D(""), a =
|
|
4402
|
-
|
|
4403
|
-
var
|
|
4404
|
-
(
|
|
4408
|
+
const { t: s } = be(), [i, l] = D(""), a = H(null);
|
|
4409
|
+
_(() => (n ? (l(e || "document"), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
4410
|
+
var m, k;
|
|
4411
|
+
(m = a.current) == null || m.focus(), (k = a.current) == null || k.select();
|
|
4405
4412
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
4406
4413
|
document.body.style.overflow = "";
|
|
4407
4414
|
}), [n, e]);
|
|
4408
4415
|
const d = E(() => {
|
|
4409
|
-
const
|
|
4410
|
-
t(
|
|
4416
|
+
const m = i.trim() || "document";
|
|
4417
|
+
t(m), o();
|
|
4411
4418
|
}, [i, t, o]), p = E(() => {
|
|
4412
4419
|
r == null || r(), o();
|
|
4413
|
-
}, [r, o]), b = E((
|
|
4414
|
-
|
|
4415
|
-
}, [p]),
|
|
4416
|
-
|
|
4420
|
+
}, [r, o]), b = E((m) => {
|
|
4421
|
+
m.target === m.currentTarget && p();
|
|
4422
|
+
}, [p]), T = E((m) => {
|
|
4423
|
+
m.key === "Enter" ? (m.preventDefault(), d()) : m.key === "Escape" && (m.preventDefault(), p());
|
|
4417
4424
|
}, [d, p]);
|
|
4418
4425
|
return n ? tt(
|
|
4419
|
-
/* @__PURE__ */ c("div", { className: "tp-export-dialog-overlay", onMouseDown: b, children: /* @__PURE__ */
|
|
4420
|
-
/* @__PURE__ */
|
|
4426
|
+
/* @__PURE__ */ c("div", { className: "tp-export-dialog-overlay", onMouseDown: b, children: /* @__PURE__ */ v("div", { className: "tp-export-dialog", onMouseDown: (m) => m.stopPropagation(), onKeyDown: T, children: [
|
|
4427
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-header", children: [
|
|
4421
4428
|
/* @__PURE__ */ c("span", { className: "tp-dialog-title", children: s("toolbar.exportWord") }),
|
|
4422
4429
|
/* @__PURE__ */ c("button", { className: "tp-dialog-close", onClick: p, children: "×" })
|
|
4423
4430
|
] }),
|
|
4424
|
-
/* @__PURE__ */
|
|
4431
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-body", children: [
|
|
4425
4432
|
/* @__PURE__ */ c("label", { className: "tp-input-label", children: s("toolbar.exportWordFilename") }),
|
|
4426
|
-
/* @__PURE__ */
|
|
4433
|
+
/* @__PURE__ */ v("div", { className: "tp-input-row", children: [
|
|
4427
4434
|
/* @__PURE__ */ c(
|
|
4428
4435
|
"input",
|
|
4429
4436
|
{
|
|
@@ -4431,8 +4438,8 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4431
4438
|
type: "text",
|
|
4432
4439
|
className: "tp-filename-input",
|
|
4433
4440
|
value: i,
|
|
4434
|
-
onChange: (
|
|
4435
|
-
onKeyDown:
|
|
4441
|
+
onChange: (m) => l(m.target.value),
|
|
4442
|
+
onKeyDown: T
|
|
4436
4443
|
}
|
|
4437
4444
|
),
|
|
4438
4445
|
/* @__PURE__ */ c("span", { className: "tp-filename-suffix", children: ".docx" }),
|
|
@@ -4443,32 +4450,32 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4443
4450
|
document.body
|
|
4444
4451
|
) : null;
|
|
4445
4452
|
}, Fr = ({ visible: n, defaultFilename: e, onConfirm: t, onCancel: r, onClose: o }) => {
|
|
4446
|
-
const { t: s } = be(), [i, l] = D(""), a =
|
|
4447
|
-
|
|
4448
|
-
var
|
|
4449
|
-
(
|
|
4453
|
+
const { t: s } = be(), [i, l] = D(""), a = H(null);
|
|
4454
|
+
_(() => (n ? (l(e || "document"), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
4455
|
+
var m, k;
|
|
4456
|
+
(m = a.current) == null || m.focus(), (k = a.current) == null || k.select();
|
|
4450
4457
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
4451
4458
|
document.body.style.overflow = "";
|
|
4452
4459
|
}), [n, e]);
|
|
4453
4460
|
const d = E(() => {
|
|
4454
|
-
const
|
|
4455
|
-
t(
|
|
4461
|
+
const m = i.trim() || "document";
|
|
4462
|
+
t(m), o();
|
|
4456
4463
|
}, [i, t, o]), p = E(() => {
|
|
4457
4464
|
r == null || r(), o();
|
|
4458
|
-
}, [r, o]), b = E((
|
|
4459
|
-
|
|
4460
|
-
}, [p]),
|
|
4461
|
-
|
|
4465
|
+
}, [r, o]), b = E((m) => {
|
|
4466
|
+
m.target === m.currentTarget && p();
|
|
4467
|
+
}, [p]), T = E((m) => {
|
|
4468
|
+
m.key === "Enter" ? (m.preventDefault(), d()) : m.key === "Escape" && (m.preventDefault(), p());
|
|
4462
4469
|
}, [d, p]);
|
|
4463
4470
|
return n ? tt(
|
|
4464
|
-
/* @__PURE__ */ c("div", { className: "tp-export-dialog-overlay", onMouseDown: b, children: /* @__PURE__ */
|
|
4465
|
-
/* @__PURE__ */
|
|
4471
|
+
/* @__PURE__ */ c("div", { className: "tp-export-dialog-overlay", onMouseDown: b, children: /* @__PURE__ */ v("div", { className: "tp-export-dialog", onMouseDown: (m) => m.stopPropagation(), onKeyDown: T, children: [
|
|
4472
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-header", children: [
|
|
4466
4473
|
/* @__PURE__ */ c("span", { className: "tp-dialog-title", children: s("toolbar.exportMarkdown") }),
|
|
4467
4474
|
/* @__PURE__ */ c("button", { className: "tp-dialog-close", onClick: p, children: "×" })
|
|
4468
4475
|
] }),
|
|
4469
|
-
/* @__PURE__ */
|
|
4476
|
+
/* @__PURE__ */ v("div", { className: "tp-dialog-body", children: [
|
|
4470
4477
|
/* @__PURE__ */ c("label", { className: "tp-input-label", children: s("toolbar.exportMarkdownFilename") }),
|
|
4471
|
-
/* @__PURE__ */
|
|
4478
|
+
/* @__PURE__ */ v("div", { className: "tp-input-row", children: [
|
|
4472
4479
|
/* @__PURE__ */ c(
|
|
4473
4480
|
"input",
|
|
4474
4481
|
{
|
|
@@ -4476,8 +4483,8 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4476
4483
|
type: "text",
|
|
4477
4484
|
className: "tp-filename-input",
|
|
4478
4485
|
value: i,
|
|
4479
|
-
onChange: (
|
|
4480
|
-
onKeyDown:
|
|
4486
|
+
onChange: (m) => l(m.target.value),
|
|
4487
|
+
onKeyDown: T
|
|
4481
4488
|
}
|
|
4482
4489
|
),
|
|
4483
4490
|
/* @__PURE__ */ c("span", { className: "tp-filename-suffix", children: ".md" }),
|
|
@@ -4499,23 +4506,23 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4499
4506
|
placeholder: d,
|
|
4500
4507
|
toolbar: p,
|
|
4501
4508
|
readonly: b = !1,
|
|
4502
|
-
disabled:
|
|
4503
|
-
autofocus:
|
|
4509
|
+
disabled: T = !1,
|
|
4510
|
+
autofocus: m = !1,
|
|
4504
4511
|
locale: k,
|
|
4505
|
-
pasteMode:
|
|
4506
|
-
uploadUrl:
|
|
4512
|
+
pasteMode: y,
|
|
4513
|
+
uploadUrl: S,
|
|
4507
4514
|
onChange: u,
|
|
4508
4515
|
onFocus: h,
|
|
4509
|
-
onBlur:
|
|
4516
|
+
onBlur: x,
|
|
4510
4517
|
onReady: w,
|
|
4511
|
-
onViewModeChange:
|
|
4512
|
-
onToolbarClick:
|
|
4518
|
+
onViewModeChange: f,
|
|
4519
|
+
onToolbarClick: N,
|
|
4513
4520
|
onFullscreenChange: $,
|
|
4514
4521
|
toolbarRender: P
|
|
4515
|
-
} = n, [
|
|
4522
|
+
} = n, [C, A] = D("normal"), O = H(""), z = H(null), [G, J] = D(!1), [K, W] = D({ x: 0, y: 0 }), [B, F] = D(null), [V, q] = D(!1), [re, oe] = D(!1), [Me, se] = D(!1), [ge, pe] = D(!1), [Y, ie] = D("document"), [j, Z] = D(!1), [Ne, nt] = D("document"), [Re, ze] = D(!1), je = Ve.getInstance(), Fe = E((M) => je.t(M) || M, [je]), rt = _e(() => {
|
|
4516
4523
|
const R = { ...o || {} };
|
|
4517
|
-
return s !== void 0 && (R.height = s), i !== void 0 && (R.minHeight = i), l !== void 0 && (R.maxHeight = l), a !== void 0 && (R.autoHeight = a), d !== void 0 && (R.placeholder = d), p !== void 0 && (R.toolbar = p), b !== void 0 && (R.readonly = b),
|
|
4518
|
-
}, [o, s, i, l, a, d, p, b,
|
|
4524
|
+
return s !== void 0 && (R.height = s), i !== void 0 && (R.minHeight = i), l !== void 0 && (R.maxHeight = l), a !== void 0 && (R.autoHeight = a), d !== void 0 && (R.placeholder = d), p !== void 0 && (R.toolbar = p), b !== void 0 && (R.readonly = b), T !== void 0 && (R.disabled = T), m !== void 0 && (R.autofocus = m), k !== void 0 && (R.locale = k), y !== void 0 && (R.paste = { ...R.paste, mode: y }), S !== void 0 && (R.upload = { ...R.upload, url: S }), R;
|
|
4525
|
+
}, [o, s, i, l, a, d, p, b, T, m, k, y, S]), Ct = _e(() => rt.toolbar || [
|
|
4519
4526
|
// A: 历史操作
|
|
4520
4527
|
"undo",
|
|
4521
4528
|
"redo",
|
|
@@ -4573,39 +4580,39 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4573
4580
|
h == null || h(M);
|
|
4574
4581
|
},
|
|
4575
4582
|
onBlur(M) {
|
|
4576
|
-
|
|
4583
|
+
x == null || x(M);
|
|
4577
4584
|
},
|
|
4578
4585
|
onReady(M) {
|
|
4579
4586
|
t ? M.setContent(t) : r && M.setJSON(r), at(M), w == null || w(M);
|
|
4580
4587
|
}
|
|
4581
4588
|
}), { activeStates: fe, disabledStates: ot } = rr(g);
|
|
4582
|
-
|
|
4589
|
+
_(() => {
|
|
4583
4590
|
t !== void 0 && he(t);
|
|
4584
|
-
}, [t, he]),
|
|
4591
|
+
}, [t, he]), _(() => {
|
|
4585
4592
|
r !== void 0 && he(void 0, r);
|
|
4586
4593
|
}, [r, he]);
|
|
4587
4594
|
const qe = E((M) => {
|
|
4588
|
-
let R = "",
|
|
4595
|
+
let R = "", U = 0;
|
|
4589
4596
|
const ce = " ", ve = M.replace(/>\s+</g, "><").trim().split(/(<\/?[^>]+>)/g).filter((we) => we.trim() !== "");
|
|
4590
4597
|
for (let we = 0; we < ve.length; we++) {
|
|
4591
4598
|
const ke = ve[we];
|
|
4592
4599
|
if (ke.match(/^<\/\w/))
|
|
4593
|
-
|
|
4600
|
+
U = Math.max(0, U - 1), R += ce.repeat(U) + ke + `
|
|
4594
4601
|
`;
|
|
4595
4602
|
else if (ke.match(/^<\w[^>]*[^\/]>$/)) {
|
|
4596
|
-
R += ce.repeat(
|
|
4603
|
+
R += ce.repeat(U) + ke + `
|
|
4597
4604
|
`;
|
|
4598
4605
|
const de = ve[we + 1];
|
|
4599
|
-
de && !de.match(/^<\/\w/) &&
|
|
4606
|
+
de && !de.match(/^<\/\w/) && U++;
|
|
4600
4607
|
} else if (ke.match(/^<\w[^>]*\/>$/))
|
|
4601
|
-
R += ce.repeat(
|
|
4608
|
+
R += ce.repeat(U) + ke + `
|
|
4602
4609
|
`;
|
|
4603
4610
|
else if (ke.match(/^<\w/))
|
|
4604
|
-
R += ce.repeat(
|
|
4611
|
+
R += ce.repeat(U) + ke + `
|
|
4605
4612
|
`;
|
|
4606
4613
|
else {
|
|
4607
4614
|
const de = ke.trim();
|
|
4608
|
-
de && (R += ce.repeat(
|
|
4615
|
+
de && (R += ce.repeat(U) + de + `
|
|
4609
4616
|
`);
|
|
4610
4617
|
}
|
|
4611
4618
|
}
|
|
@@ -4613,43 +4620,43 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4613
4620
|
}, []), Ye = E((M) => {
|
|
4614
4621
|
if (!g) return;
|
|
4615
4622
|
const R = g.getEditor();
|
|
4616
|
-
if (
|
|
4623
|
+
if (C === M) {
|
|
4617
4624
|
ae();
|
|
4618
4625
|
return;
|
|
4619
4626
|
}
|
|
4620
|
-
|
|
4621
|
-
const
|
|
4622
|
-
R.commands.clearContent(), R.commands.insertContent({ type: "codeBlock", attrs: { language: M === "html" ? "html" : "json" }, content: [{ type: "text", text: ce }] }), A(M),
|
|
4623
|
-
}, [g,
|
|
4627
|
+
C !== "normal" ? ae() : (O.current = g.getHTML(), z.current = g.getJSON());
|
|
4628
|
+
const U = M === "html" ? g.getHTML() : JSON.stringify(g.getJSON(), null, 2), ce = M === "html" ? qe(U) : U;
|
|
4629
|
+
R.commands.clearContent(), R.commands.insertContent({ type: "codeBlock", attrs: { language: M === "html" ? "html" : "json" }, content: [{ type: "text", text: ce }] }), A(M), f == null || f(M);
|
|
4630
|
+
}, [g, C, qe, f]), ae = E(() => {
|
|
4624
4631
|
if (!g) return;
|
|
4625
4632
|
const M = g.getEditor();
|
|
4626
|
-
if (
|
|
4627
|
-
const R = M.getText(),
|
|
4633
|
+
if (C !== "normal") {
|
|
4634
|
+
const R = M.getText(), U = C;
|
|
4628
4635
|
if (R)
|
|
4629
4636
|
try {
|
|
4630
|
-
if (
|
|
4637
|
+
if (U === "html") {
|
|
4631
4638
|
const ce = document.createElement("div");
|
|
4632
4639
|
ce.innerHTML = R, M.commands.setContent(R);
|
|
4633
|
-
} else if (
|
|
4640
|
+
} else if (U === "json") {
|
|
4634
4641
|
const ce = JSON.parse(R);
|
|
4635
4642
|
M.commands.setContent(ce);
|
|
4636
4643
|
}
|
|
4637
4644
|
} catch {
|
|
4638
|
-
alert(
|
|
4645
|
+
alert(U === "html" ? "HTML 格式错误,请检查输入内容" : "JSON 格式错误,请检查输入内容");
|
|
4639
4646
|
return;
|
|
4640
4647
|
}
|
|
4641
4648
|
else
|
|
4642
4649
|
z.current ? M.commands.setContent(z.current) : O.current && M.commands.setContent(O.current);
|
|
4643
4650
|
} else
|
|
4644
4651
|
z.current ? M.commands.setContent(z.current) : O.current && M.commands.setContent(O.current);
|
|
4645
|
-
A("normal"),
|
|
4646
|
-
}, [g,
|
|
4652
|
+
A("normal"), f == null || f("normal");
|
|
4653
|
+
}, [g, C, f]), at = E((M) => {
|
|
4647
4654
|
const R = M.getEditor();
|
|
4648
|
-
R.view.dom.addEventListener("contextmenu", (
|
|
4649
|
-
const le =
|
|
4655
|
+
R.view.dom.addEventListener("contextmenu", (U) => {
|
|
4656
|
+
const le = U.target.closest("td, th");
|
|
4650
4657
|
if (!An())
|
|
4651
4658
|
if (le) {
|
|
4652
|
-
|
|
4659
|
+
U.preventDefault();
|
|
4653
4660
|
const ve = R.state.selection;
|
|
4654
4661
|
if ("$anchorCell" in ve) {
|
|
4655
4662
|
let Je = !1;
|
|
@@ -4660,19 +4667,19 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4660
4667
|
});
|
|
4661
4668
|
} catch {
|
|
4662
4669
|
}
|
|
4663
|
-
Je || Ze(R, le), W({ x:
|
|
4670
|
+
Je || Ze(R, le), W({ x: U.clientX, y: U.clientY }), F(le), J(!0);
|
|
4664
4671
|
return;
|
|
4665
4672
|
}
|
|
4666
4673
|
jt(R) || Ze(R, le);
|
|
4667
4674
|
const de = G;
|
|
4668
4675
|
de && J(!1), setTimeout(() => {
|
|
4669
|
-
W({ x:
|
|
4676
|
+
W({ x: U.clientX, y: U.clientY }), F(le), J(!0);
|
|
4670
4677
|
}, de ? 0 : 50);
|
|
4671
4678
|
} else
|
|
4672
4679
|
J(!1), F(null), qt();
|
|
4673
4680
|
});
|
|
4674
4681
|
}, [G]), Nt = E((M) => {
|
|
4675
|
-
if (
|
|
4682
|
+
if (N == null || N(M), M === "snapshot") {
|
|
4676
4683
|
g == null || g.createSnapshot().then((R) => {
|
|
4677
4684
|
R ? yt(je.t("compare.snapshotCreated", { time: R.label || R.timestamp })) : yt({ message: je.t("compare.snapshotFailed"), type: "error" });
|
|
4678
4685
|
});
|
|
@@ -4680,22 +4687,22 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4680
4687
|
}
|
|
4681
4688
|
if (M === "compare" && se(!0), M === "fullscreen" && $e(), M === "importWord") {
|
|
4682
4689
|
const R = document.createElement("input");
|
|
4683
|
-
R.type = "file", R.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", R.onchange = async (
|
|
4690
|
+
R.type = "file", R.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", R.onchange = async (U) => {
|
|
4684
4691
|
var le;
|
|
4685
|
-
const ce = (le =
|
|
4692
|
+
const ce = (le = U.target.files) == null ? void 0 : le[0];
|
|
4686
4693
|
ce && await (g == null ? void 0 : g.importWordFile(ce));
|
|
4687
4694
|
}, R.click();
|
|
4688
4695
|
}
|
|
4689
4696
|
if (M === "importMarkdown") {
|
|
4690
4697
|
const R = document.createElement("input");
|
|
4691
|
-
R.type = "file", R.accept = ".md,.markdown,text/markdown", R.onchange = async (
|
|
4698
|
+
R.type = "file", R.accept = ".md,.markdown,text/markdown", R.onchange = async (U) => {
|
|
4692
4699
|
var le;
|
|
4693
|
-
const ce = (le =
|
|
4700
|
+
const ce = (le = U.target.files) == null ? void 0 : le[0];
|
|
4694
4701
|
ce && await (g == null ? void 0 : g.importMarkdownFile(ce));
|
|
4695
4702
|
}, R.click();
|
|
4696
4703
|
}
|
|
4697
4704
|
M === "exportWord" && (ie((g == null ? void 0 : g.getDocumentTitle()) || "document"), pe(!0)), M === "exportMarkdown" && (nt((g == null ? void 0 : g.getDocumentTitle()) || "document"), Z(!0));
|
|
4698
|
-
}, [
|
|
4705
|
+
}, [N, g]), Ge = E((M) => {
|
|
4699
4706
|
if (!g) return;
|
|
4700
4707
|
const R = g.getEditor();
|
|
4701
4708
|
switch ("$anchorCell" in R.state.selection || (jt(R), qt()), M) {
|
|
@@ -4713,9 +4720,9 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4713
4720
|
break;
|
|
4714
4721
|
case "mergeCells":
|
|
4715
4722
|
R.chain().mergeCells().run(), setTimeout(() => {
|
|
4716
|
-
if (
|
|
4717
|
-
if (document.contains(
|
|
4718
|
-
Ze(R,
|
|
4723
|
+
if (B)
|
|
4724
|
+
if (document.contains(B))
|
|
4725
|
+
Ze(R, B);
|
|
4719
4726
|
else {
|
|
4720
4727
|
const { state: le } = R, { selection: ve } = le;
|
|
4721
4728
|
if ("$anchorCell" in ve) {
|
|
@@ -4729,7 +4736,7 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4729
4736
|
}, 0);
|
|
4730
4737
|
break;
|
|
4731
4738
|
case "splitCell": {
|
|
4732
|
-
const le =
|
|
4739
|
+
const le = B;
|
|
4733
4740
|
let ve = null;
|
|
4734
4741
|
if (le)
|
|
4735
4742
|
try {
|
|
@@ -4788,7 +4795,7 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4788
4795
|
oe(!0);
|
|
4789
4796
|
break;
|
|
4790
4797
|
}
|
|
4791
|
-
}, [g,
|
|
4798
|
+
}, [g, B]), $e = E(() => {
|
|
4792
4799
|
ze((M) => {
|
|
4793
4800
|
const R = !M;
|
|
4794
4801
|
return $ == null || $(R), R;
|
|
@@ -4815,9 +4822,9 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4815
4822
|
undo: () => g == null ? void 0 : g.undo(),
|
|
4816
4823
|
redo: () => g == null ? void 0 : g.redo(),
|
|
4817
4824
|
setReadonly: (M) => g == null ? void 0 : g.setReadonly(M),
|
|
4818
|
-
insertTable: (M, R,
|
|
4819
|
-
insertImage: (M, R,
|
|
4820
|
-
insertVideo: (M, R,
|
|
4825
|
+
insertTable: (M, R, U) => g == null ? void 0 : g.insertTable(M, R, U),
|
|
4826
|
+
insertImage: (M, R, U) => g == null ? void 0 : g.insertImage(M, R, U),
|
|
4827
|
+
insertVideo: (M, R, U) => g == null ? void 0 : g.insertVideo(M, R, U),
|
|
4821
4828
|
exportMarkdown: () => (g == null ? void 0 : g.exportMarkdown()) ?? "",
|
|
4822
4829
|
exportHTMLDocument: (M) => (g == null ? void 0 : g.exportHTMLDocument(M)) ?? "",
|
|
4823
4830
|
exportWordFile: (M) => (g == null ? void 0 : g.exportWordFile(M)) ?? Promise.resolve(),
|
|
@@ -4830,19 +4837,19 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4830
4837
|
addSnapshot: (M, R) => (g == null ? void 0 : g.addSnapshot(M, R)) ?? Promise.resolve(null),
|
|
4831
4838
|
toggleViewMode: Ye,
|
|
4832
4839
|
restoreOriginalContent: ae,
|
|
4833
|
-
getViewMode: () =>
|
|
4840
|
+
getViewMode: () => C,
|
|
4834
4841
|
toggleFullscreen: $e,
|
|
4835
4842
|
isFullscreen: () => Re
|
|
4836
|
-
}), [g, Ye, ae,
|
|
4843
|
+
}), [g, Ye, ae, C, $e, Re]), /* @__PURE__ */ v(
|
|
4837
4844
|
"div",
|
|
4838
4845
|
{
|
|
4839
|
-
className: `cyte-editor${
|
|
4846
|
+
className: `cyte-editor${T ? " is-disabled" : ""}${b ? " is-readonly" : ""}${L ? " is-focused" : ""}${I ? " is-empty" : ""}${a ? " is-auto-height" : ""}${a && l ? " is-auto-height-limited" : ""}${Re ? " is-fullscreen" : ""}`,
|
|
4840
4847
|
style: Pe,
|
|
4841
4848
|
onKeyDown: Xe,
|
|
4842
4849
|
children: [
|
|
4843
|
-
Re && /* @__PURE__ */
|
|
4844
|
-
/* @__PURE__ */
|
|
4845
|
-
/* @__PURE__ */
|
|
4850
|
+
Re && /* @__PURE__ */ v("div", { className: "cyte-fullscreen-header", children: [
|
|
4851
|
+
/* @__PURE__ */ v("div", { className: "cyte-fullscreen-header__title", children: [
|
|
4852
|
+
/* @__PURE__ */ v("svg", { className: "cyte-fullscreen-header__title-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4846
4853
|
/* @__PURE__ */ c("path", { d: "M8 4H4V8M4 4L10 10" }),
|
|
4847
4854
|
/* @__PURE__ */ c("path", { d: "M16 4H20V8M20 4L14 10" }),
|
|
4848
4855
|
/* @__PURE__ */ c("path", { d: "M4 16V20H8M4 20L10 14" }),
|
|
@@ -4850,7 +4857,7 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4850
4857
|
] }),
|
|
4851
4858
|
Fe("toolbar.fullscreenTitle")
|
|
4852
4859
|
] }),
|
|
4853
|
-
/* @__PURE__ */
|
|
4860
|
+
/* @__PURE__ */ v("button", { className: "cyte-fullscreen-header__close", onClick: $e, children: [
|
|
4854
4861
|
"✕ ",
|
|
4855
4862
|
Fe("toolbar.exitFullscreen")
|
|
4856
4863
|
] })
|
|
@@ -4862,7 +4869,7 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4862
4869
|
manager: g,
|
|
4863
4870
|
activeStates: fe,
|
|
4864
4871
|
disabledStates: ot,
|
|
4865
|
-
viewMode:
|
|
4872
|
+
viewMode: C,
|
|
4866
4873
|
onToggleViewMode: Ye,
|
|
4867
4874
|
onToolbarClick: Nt
|
|
4868
4875
|
}
|
|
@@ -4873,8 +4880,8 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4873
4880
|
{
|
|
4874
4881
|
editor: g.getEditor(),
|
|
4875
4882
|
visible: G,
|
|
4876
|
-
position:
|
|
4877
|
-
targetCell:
|
|
4883
|
+
position: K,
|
|
4884
|
+
targetCell: B,
|
|
4878
4885
|
onVisibleChange: J,
|
|
4879
4886
|
onAction: Ge
|
|
4880
4887
|
}
|
|
@@ -4883,7 +4890,7 @@ const Hr = ({ editor: n, visible: e, onVisibleChange: t }) => {
|
|
|
4883
4890
|
Dr,
|
|
4884
4891
|
{
|
|
4885
4892
|
editor: g.getEditor(),
|
|
4886
|
-
visible:
|
|
4893
|
+
visible: V,
|
|
4887
4894
|
onVisibleChange: q
|
|
4888
4895
|
}
|
|
4889
4896
|
),
|