@cyte-editor/react 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cyte-editor-react.cjs +4 -4
- package/dist/cyte-editor-react.js +277 -275
- package/package.json +6 -6
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx as e, jsxs as v, Fragment as Ze } from "react/jsx-runtime";
|
|
2
|
-
import Xe, { useRef as B, useState as
|
|
2
|
+
import Xe, { useRef as B, useState as H, useCallback as A, useEffect as K, useMemo as Te, useLayoutEffect as it, forwardRef as ct, useImperativeHandle as st } from "react";
|
|
3
3
|
import { TextSelection as at } from "@tiptap/pm/state";
|
|
4
4
|
import { TableMap as lt } from "@tiptap/pm/tables";
|
|
5
5
|
import { EditorManager as dt, I18nManager as De, toolbarItemDefs as Je, uploadFile as ut, groupToolbarItems as pt, getToolbarItemDef as ht, adjustMenuPosition as Qe, ScrollSyncManager as ft, showToast as je, getHoverLineVisible as mt, moveCursorToCell as $e, restoreTableSelection as et, clearSavedTableSelection as tt } from "@cyte-editor/core";
|
|
6
6
|
import { getLicenseStatus as gt } from "@cyte-editor/license";
|
|
7
7
|
import { createPortal as _e } from "react-dom";
|
|
8
8
|
/*!
|
|
9
|
-
* CyteEditor React Adapter v1.
|
|
9
|
+
* CyteEditor React Adapter v1.3.0 (@cyte-editor/react)
|
|
10
10
|
* (c) 2026 CyteEditor — All Rights Reserved.
|
|
11
11
|
*
|
|
12
12
|
* Commercial Software — NOT Open Source.
|
|
13
13
|
* Licensed under the CyteEditor Commercial License.
|
|
14
14
|
* SEE LICENSE IN ./LICENSE | Full EULA: https://cyteeditor.com/eula
|
|
15
15
|
*
|
|
16
|
-
* Build:
|
|
16
|
+
* Build: e84a4aa-dirty @ 2026-10-31T08:20:43.064Z
|
|
17
17
|
* Homepage: https://cyteeditor.com
|
|
18
18
|
* Contact: legal@cyteeditor.com (legal) / support@cyteeditor.com (support)
|
|
19
19
|
*
|
|
@@ -22,9 +22,9 @@ import { createPortal as _e } from "react-dom";
|
|
|
22
22
|
*/
|
|
23
23
|
function wt(t) {
|
|
24
24
|
var m, T;
|
|
25
|
-
const o = B(null), c = B(null), [p, i] =
|
|
25
|
+
const o = B(null), c = B(null), [p, i] = H(!1), [s, h] = H(!1), [d, u] = H(!0), f = B(!1), y = B(t);
|
|
26
26
|
y.current = t;
|
|
27
|
-
const N =
|
|
27
|
+
const N = A((w, M) => {
|
|
28
28
|
if (!(f.current || !c.current)) {
|
|
29
29
|
if (M !== void 0) {
|
|
30
30
|
const n = JSON.stringify(c.current.getJSON()), r = JSON.stringify(M);
|
|
@@ -72,24 +72,24 @@ function wt(t) {
|
|
|
72
72
|
manager: c.current,
|
|
73
73
|
isReady: p,
|
|
74
74
|
isFocused: s,
|
|
75
|
-
isEmpty:
|
|
75
|
+
isEmpty: d,
|
|
76
76
|
containerRef: o,
|
|
77
77
|
setContentFromProp: N
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
function vt(t) {
|
|
81
|
-
const [o, c] =
|
|
81
|
+
const [o, c] = H({}), [p, i] = H({}), s = A(async () => {
|
|
82
82
|
if (!t) return;
|
|
83
|
-
const h = t.getEditor(),
|
|
83
|
+
const h = t.getEditor(), d = {}, u = {};
|
|
84
84
|
for (const [S, m] of Object.entries(Je))
|
|
85
|
-
m.isActive && (
|
|
85
|
+
m.isActive && (d[S] = m.isActive(h)), m.isDisabled && (u[S] = m.isDisabled(h));
|
|
86
86
|
const f = gt(), y = f === "valid" || f === "expiring_soon", N = await t.hasSnapshots();
|
|
87
87
|
if (u.compare = !N || !y, !y)
|
|
88
88
|
for (const [S, m] of Object.entries(Je))
|
|
89
89
|
m.requiredTier && S !== "compare" && (u[S] = !0);
|
|
90
90
|
for (const [S, m] of Object.entries(Je))
|
|
91
91
|
m.requiresPlugin && !t.hasProPlugin(m.requiresPlugin) && (u[S] = !0);
|
|
92
|
-
c(
|
|
92
|
+
c(d), i(u);
|
|
93
93
|
}, [t]);
|
|
94
94
|
return K(() => {
|
|
95
95
|
if (t)
|
|
@@ -103,7 +103,7 @@ function vt(t) {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
function fe() {
|
|
106
|
-
const t = De.getInstance(), [o, c] =
|
|
106
|
+
const t = De.getInstance(), [o, c] = H(0);
|
|
107
107
|
K(() => t.onChange(() => {
|
|
108
108
|
c((s) => s + 1);
|
|
109
109
|
}), [t]);
|
|
@@ -156,7 +156,8 @@ const yt = {
|
|
|
156
156
|
import: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3h5a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5"/><polyline points="9 8 14 12 9 16"/><line x1="3" y1="12" x2="14" y2="12"/></svg>',
|
|
157
157
|
export: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h5"/><polyline points="16 8 21 12 16 16"/><line x1="10" y1="12" x2="21" y2="12"/></svg>',
|
|
158
158
|
formula: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"><text x="1" y="20" font-size="20" fill="currentColor" stroke="none" font-family="serif" font-weight="bold">Σ</text><text x="14" y="22" font-size="9" fill="currentColor" stroke="none" font-family="serif">x</text></svg>',
|
|
159
|
-
structure: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2.5 20 7 20 17 12 21.5 4 17 4 7"/><circle cx="12" cy="12" r="4"/></svg>'
|
|
159
|
+
structure: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2.5 20 7 20 17 12 21.5 4 17 4 7"/><circle cx="12" cy="12" r="4"/></svg>',
|
|
160
|
+
autoFormat: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 4V2"/><path d="M15 16v-2"/><path d="M8 9h2"/><path d="M20 9h2"/><path d="M17.8 11.8 19 13"/><path d="M17.8 6.2 19 5"/><path d="M3 21l9-9"/><path d="M12.2 6.2 11 5"/></svg>'
|
|
160
161
|
};
|
|
161
162
|
function ke(t) {
|
|
162
163
|
return yt[t] || "";
|
|
@@ -169,10 +170,10 @@ const bt = ({
|
|
|
169
170
|
initialUrl: i,
|
|
170
171
|
isEditing: s,
|
|
171
172
|
onConfirm: h,
|
|
172
|
-
onCancel:
|
|
173
|
+
onCancel: d,
|
|
173
174
|
onClose: u
|
|
174
175
|
}) => {
|
|
175
|
-
const { t: f } = fe(), [y, N] =
|
|
176
|
+
const { t: f } = fe(), [y, N] = H(i || ""), [S, m] = H(!1), T = B(null), [w, M] = H(null), [n, r] = H(""), k = () => {
|
|
176
177
|
if (c && p)
|
|
177
178
|
try {
|
|
178
179
|
const { from: b, to: E } = p, $ = c.view.coordsAtPos(b), P = c.view.coordsAtPos(E);
|
|
@@ -231,7 +232,7 @@ const bt = ({
|
|
|
231
232
|
}, _ = () => {
|
|
232
233
|
h(""), u();
|
|
233
234
|
}, V = () => {
|
|
234
|
-
|
|
235
|
+
d(), u();
|
|
235
236
|
};
|
|
236
237
|
return t ? /* @__PURE__ */ e(
|
|
237
238
|
"div",
|
|
@@ -282,7 +283,7 @@ const bt = ({
|
|
|
282
283
|
}
|
|
283
284
|
) : null;
|
|
284
285
|
}, xt = "#b4d5fe", kt = ({ def: t, editor: o, active: c, disabled: p, onCustomClick: i }) => {
|
|
285
|
-
const { t: s } = fe(), [h,
|
|
286
|
+
const { t: s } = fe(), [h, d] = H(!1), u = B(null), f = B(null), y = B(""), N = B(!1), S = (n) => {
|
|
286
287
|
var r;
|
|
287
288
|
if (n.preventDefault(), t.name === "link") {
|
|
288
289
|
const { from: k, to: g } = o.state.selection;
|
|
@@ -304,7 +305,7 @@ const bt = ({
|
|
|
304
305
|
}, m = () => {
|
|
305
306
|
var r, k;
|
|
306
307
|
const n = t.name;
|
|
307
|
-
if (n === "getHTML" || n === "getJSON" || n === "importWord" || n === "importMarkdown" || n === "exportWord" || n === "exportMarkdown" || n === "snapshot" || n === "compare" || n === "fullscreen") {
|
|
308
|
+
if (n === "getHTML" || n === "getJSON" || n === "importWord" || n === "importMarkdown" || n === "exportWord" || n === "exportMarkdown" || n === "snapshot" || n === "compare" || n === "fullscreen" || n === "autoFormat") {
|
|
308
309
|
i == null || i(n);
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
@@ -326,7 +327,7 @@ const bt = ({
|
|
|
326
327
|
));
|
|
327
328
|
} catch {
|
|
328
329
|
}
|
|
329
|
-
|
|
330
|
+
d(!0);
|
|
330
331
|
return;
|
|
331
332
|
}
|
|
332
333
|
if (!u.current) {
|
|
@@ -349,7 +350,7 @@ const bt = ({
|
|
|
349
350
|
const { from: g, to: l } = u.current;
|
|
350
351
|
o.chain().focus().setTextSelection({ from: g, to: l }).setHighlight({ color: xt }).run();
|
|
351
352
|
}
|
|
352
|
-
|
|
353
|
+
d(!0);
|
|
353
354
|
return;
|
|
354
355
|
}
|
|
355
356
|
(k = t.command) == null || k.call(t, o);
|
|
@@ -389,7 +390,7 @@ const bt = ({
|
|
|
389
390
|
isEditing: N.current,
|
|
390
391
|
onConfirm: T,
|
|
391
392
|
onCancel: w,
|
|
392
|
-
onClose: () =>
|
|
393
|
+
onClose: () => d(!1)
|
|
393
394
|
}
|
|
394
395
|
)
|
|
395
396
|
] });
|
|
@@ -404,7 +405,7 @@ const bt = ({
|
|
|
404
405
|
楷体: ["KaiTi", "楷体"]
|
|
405
406
|
}, Ct = ({ def: t, editor: o, active: c, disabled: p, onCustomClick: i }) => {
|
|
406
407
|
var M;
|
|
407
|
-
const { t: s } = fe(), [h,
|
|
408
|
+
const { t: s } = fe(), [h, d] = H(!1), [u, f] = H(0), y = B(null), N = Te(() => {
|
|
408
409
|
var n;
|
|
409
410
|
return (n = t.getCurrentValue) == null ? void 0 : n.call(t, o);
|
|
410
411
|
}, [u, t, o]), S = (n) => {
|
|
@@ -419,14 +420,14 @@ const bt = ({
|
|
|
419
420
|
const r = Number(n);
|
|
420
421
|
return r === 0 ? "tp-heading-preview-paragraph" : r >= 1 && r <= 6 ? `tp-heading-preview-h${r}` : "";
|
|
421
422
|
}, T = () => {
|
|
422
|
-
p || (
|
|
423
|
+
p || (d(!h), h || f((n) => n + 1));
|
|
423
424
|
}, w = (n) => {
|
|
424
425
|
var r;
|
|
425
|
-
t.isActionMenu ? i == null || i(String(n)) : (r = t.command) == null || r.call(t, o, n),
|
|
426
|
+
t.isActionMenu ? i == null || i(String(n)) : (r = t.command) == null || r.call(t, o, n), d(!1);
|
|
426
427
|
};
|
|
427
428
|
return K(() => {
|
|
428
429
|
const n = (k) => {
|
|
429
|
-
y.current && !y.current.contains(k.target) &&
|
|
430
|
+
y.current && !y.current.contains(k.target) && d(!1);
|
|
430
431
|
}, r = () => f((k) => k + 1);
|
|
431
432
|
return document.addEventListener("pointerdown", n), o.on("transaction", r), () => {
|
|
432
433
|
document.removeEventListener("pointerdown", n), o.off("transaction", r);
|
|
@@ -520,7 +521,7 @@ const bt = ({
|
|
|
520
521
|
"#073763",
|
|
521
522
|
"#7f6000"
|
|
522
523
|
], Mt = ["#ff0000", "#ff5e00", "#ff9900", "#ffff00", "#00ff00", "#00a8a8", "#00ffff", "#0000ff", "#5f00ff", "#9900ff"], Lt = ({ def: t, editor: o, disabled: c }) => {
|
|
523
|
-
const { t: p } = fe(), [i, s] =
|
|
524
|
+
const { t: p } = fe(), [i, s] = H(!1), h = B(null), [d, u] = H(""), [f, y] = H(""), N = t.name === "color", S = N ? d : f, m = () => {
|
|
524
525
|
const M = o.getAttributes("textStyle");
|
|
525
526
|
u((M == null ? void 0 : M.color) || "");
|
|
526
527
|
const n = o.getAttributes("highlight");
|
|
@@ -555,7 +556,7 @@ const bt = ({
|
|
|
555
556
|
children: [
|
|
556
557
|
/* @__PURE__ */ e("span", { className: N ? "tp-color-picker-icon" : "tp-bgcolor-picker-icon", children: N ? /* @__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: [
|
|
557
558
|
/* @__PURE__ */ e("text", { x: "4", y: "17", fontSize: "24", fill: "currentColor", stroke: "none", fontFamily: "serif", fontWeight: "bold", children: "A" }),
|
|
558
|
-
/* @__PURE__ */ e("line", { x1: "4", y1: "22", x2: "20", y2: "22", strokeWidth: "5", stroke:
|
|
559
|
+
/* @__PURE__ */ e("line", { x1: "4", y1: "22", x2: "20", y2: "22", strokeWidth: "5", stroke: d || "#000000" })
|
|
559
560
|
] }) : /* @__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: [
|
|
560
561
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", fill: f || "transparent" }),
|
|
561
562
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
@@ -601,7 +602,7 @@ const bt = ({
|
|
|
601
602
|
initialTab: s,
|
|
602
603
|
onClose: h
|
|
603
604
|
}) => {
|
|
604
|
-
const { t:
|
|
605
|
+
const { t: d } = fe(), [u, f] = H(s || "upload"), [y, N] = H(""), [S, m] = H(!1), [T, w] = H(!1), [M, n] = H(0), [r, k] = H(""), g = B(null);
|
|
605
606
|
K(() => (t ? (N(""), k(""), f(s || "upload"), n(0), document.body.style.overflow = "hidden") : document.body.style.overflow = "", () => {
|
|
606
607
|
document.body.style.overflow = "";
|
|
607
608
|
}), [t, s]);
|
|
@@ -616,20 +617,20 @@ const bt = ({
|
|
|
616
617
|
let E;
|
|
617
618
|
i ? E = await i(b) : c ? E = await ut(b, { url: c, headers: p, onProgress: n }) : E = await l(b), x(E), h();
|
|
618
619
|
} catch (E) {
|
|
619
|
-
k(E instanceof Error ? E.message :
|
|
620
|
+
k(E instanceof Error ? E.message : d("imageUpload.uploadFailed"));
|
|
620
621
|
} finally {
|
|
621
622
|
w(!1), n(0);
|
|
622
623
|
}
|
|
623
624
|
}, V = () => {
|
|
624
625
|
const b = y.trim();
|
|
625
626
|
if (!b) {
|
|
626
|
-
k(
|
|
627
|
+
k(d("imageUpload.urlRequired"));
|
|
627
628
|
return;
|
|
628
629
|
}
|
|
629
630
|
try {
|
|
630
631
|
new URL(b);
|
|
631
632
|
} catch {
|
|
632
|
-
k(
|
|
633
|
+
k(d("imageUpload.invalidUrl"));
|
|
633
634
|
return;
|
|
634
635
|
}
|
|
635
636
|
x(b), h();
|
|
@@ -638,12 +639,12 @@ const bt = ({
|
|
|
638
639
|
b.target === b.currentTarget && h();
|
|
639
640
|
}, children: /* @__PURE__ */ v("div", { className: "tp-image-upload-dialog", onMouseDown: (b) => b.stopPropagation(), children: [
|
|
640
641
|
/* @__PURE__ */ v("div", { className: "tp-dialog-header", children: [
|
|
641
|
-
/* @__PURE__ */ e("span", { className: "tp-dialog-title", children:
|
|
642
|
+
/* @__PURE__ */ e("span", { className: "tp-dialog-title", children: d("image.upload") }),
|
|
642
643
|
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick: h, children: "×" })
|
|
643
644
|
] }),
|
|
644
645
|
/* @__PURE__ */ v("div", { className: "tp-dialog-tabs", children: [
|
|
645
|
-
/* @__PURE__ */ e("button", { className: `tp-tab-btn${u === "upload" ? " is-active" : ""}`, onClick: () => f("upload"), children:
|
|
646
|
-
/* @__PURE__ */ e("button", { className: `tp-tab-btn${u === "url" ? " is-active" : ""}`, onClick: () => f("url"), children:
|
|
646
|
+
/* @__PURE__ */ e("button", { className: `tp-tab-btn${u === "upload" ? " is-active" : ""}`, onClick: () => f("upload"), children: d("imageUpload.uploadLocal") }),
|
|
647
|
+
/* @__PURE__ */ e("button", { className: `tp-tab-btn${u === "url" ? " is-active" : ""}`, onClick: () => f("url"), children: d("imageUpload.inputUrl") })
|
|
647
648
|
] }),
|
|
648
649
|
/* @__PURE__ */ v("div", { className: "tp-dialog-body", children: [
|
|
649
650
|
u === "upload" && /* @__PURE__ */ v("div", { className: "tp-upload-tab", children: [
|
|
@@ -662,7 +663,7 @@ const bt = ({
|
|
|
662
663
|
var $, P;
|
|
663
664
|
b.preventDefault(), m(!1);
|
|
664
665
|
const E = (P = ($ = b.dataTransfer) == null ? void 0 : $.files) == null ? void 0 : P[0];
|
|
665
|
-
E != null && E.type.startsWith("image/") ? _(E) : k(
|
|
666
|
+
E != null && E.type.startsWith("image/") ? _(E) : k(d("imageUpload.invalidType"));
|
|
666
667
|
},
|
|
667
668
|
onClick: () => {
|
|
668
669
|
var b;
|
|
@@ -671,15 +672,15 @@ const bt = ({
|
|
|
671
672
|
children: T ? /* @__PURE__ */ v("div", { className: "tp-upload-progress", children: [
|
|
672
673
|
/* @__PURE__ */ e("div", { className: "tp-progress-bar", children: /* @__PURE__ */ e("div", { className: "tp-progress-fill", style: { width: M + "%" } }) }),
|
|
673
674
|
/* @__PURE__ */ v("span", { className: "tp-progress-text", children: [
|
|
674
|
-
|
|
675
|
+
d("imageUpload.uploading"),
|
|
675
676
|
" ",
|
|
676
677
|
M,
|
|
677
678
|
"%"
|
|
678
679
|
] })
|
|
679
680
|
] }) : /* @__PURE__ */ v("div", { className: "tp-dropzone-content", children: [
|
|
680
681
|
/* @__PURE__ */ e("span", { className: "tp-dropzone-icon", children: "📁" }),
|
|
681
|
-
/* @__PURE__ */ e("span", { className: "tp-dropzone-text", children:
|
|
682
|
-
/* @__PURE__ */ e("span", { className: "tp-dropzone-hint", children:
|
|
682
|
+
/* @__PURE__ */ e("span", { className: "tp-dropzone-text", children: d("imageUpload.selectFile") }),
|
|
683
|
+
/* @__PURE__ */ e("span", { className: "tp-dropzone-hint", children: d("imageUpload.dragHint") })
|
|
683
684
|
] })
|
|
684
685
|
}
|
|
685
686
|
),
|
|
@@ -699,7 +700,7 @@ const bt = ({
|
|
|
699
700
|
)
|
|
700
701
|
] }),
|
|
701
702
|
u === "url" && /* @__PURE__ */ v("div", { className: "tp-url-tab", children: [
|
|
702
|
-
/* @__PURE__ */ e("label", { className: "tp-input-label", children:
|
|
703
|
+
/* @__PURE__ */ e("label", { className: "tp-input-label", children: d("imageUpload.url") }),
|
|
703
704
|
/* @__PURE__ */ v("div", { className: "tp-input-row", children: [
|
|
704
705
|
/* @__PURE__ */ e(
|
|
705
706
|
"input",
|
|
@@ -707,14 +708,14 @@ const bt = ({
|
|
|
707
708
|
className: "tp-url-input",
|
|
708
709
|
type: "url",
|
|
709
710
|
value: y,
|
|
710
|
-
placeholder:
|
|
711
|
+
placeholder: d("imageUpload.placeholder"),
|
|
711
712
|
onChange: (b) => N(b.target.value),
|
|
712
713
|
onKeyDown: (b) => {
|
|
713
714
|
b.key === "Enter" && V(), b.key === "Escape" && h();
|
|
714
715
|
}
|
|
715
716
|
}
|
|
716
717
|
),
|
|
717
|
-
/* @__PURE__ */ e("button", { className: "tp-confirm-btn", onClick: V, children:
|
|
718
|
+
/* @__PURE__ */ e("button", { className: "tp-confirm-btn", onClick: V, children: d("common.confirm") })
|
|
718
719
|
] })
|
|
719
720
|
] }),
|
|
720
721
|
r && /* @__PURE__ */ e("div", { className: "tp-error-message", children: r })
|
|
@@ -722,15 +723,15 @@ const bt = ({
|
|
|
722
723
|
] }) }) : null;
|
|
723
724
|
}, Dt = ({ def: t, editor: o, manager: c, active: p, disabled: i }) => {
|
|
724
725
|
var n, r, k, g;
|
|
725
|
-
const { t: s } = fe(), [h,
|
|
726
|
+
const { t: s } = fe(), [h, d] = H(!1), [u, f] = H(!1), [y, N] = H("upload"), S = B(null), m = (n = c == null ? void 0 : c.getConfig().upload) == null ? void 0 : n.url, T = (r = c == null ? void 0 : c.getConfig().upload) == null ? void 0 : r.headers, w = (k = c == null ? void 0 : c.getConfig().upload) == null ? void 0 : k.onUpload;
|
|
726
727
|
K(() => {
|
|
727
728
|
const l = (x) => {
|
|
728
|
-
S.current && !S.current.contains(x.target) &&
|
|
729
|
+
S.current && !S.current.contains(x.target) && d(!1);
|
|
729
730
|
};
|
|
730
731
|
return document.addEventListener("pointerdown", l), () => document.removeEventListener("pointerdown", l);
|
|
731
732
|
}, []);
|
|
732
733
|
const M = (l) => {
|
|
733
|
-
|
|
734
|
+
d(!1), l === "upload" ? (N("upload"), f(!0)) : l === "url" && (N("url"), f(!0));
|
|
734
735
|
};
|
|
735
736
|
return /* @__PURE__ */ v("div", { ref: S, className: "tp-toolbar-dropdown", children: [
|
|
736
737
|
/* @__PURE__ */ v(
|
|
@@ -741,7 +742,7 @@ const bt = ({
|
|
|
741
742
|
disabled: i,
|
|
742
743
|
onMouseDown: (l) => l.preventDefault(),
|
|
743
744
|
onClick: () => {
|
|
744
|
-
i ||
|
|
745
|
+
i || d(!h);
|
|
745
746
|
},
|
|
746
747
|
children: [
|
|
747
748
|
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: ke(t.name) } }),
|
|
@@ -773,14 +774,14 @@ const bt = ({
|
|
|
773
774
|
)
|
|
774
775
|
] });
|
|
775
776
|
}, St = ({ visible: t, editor: o, onSuccess: c, onCancel: p, onClose: i }) => {
|
|
776
|
-
const { t: s } = fe(), [h,
|
|
777
|
-
K(() => (t ? (
|
|
777
|
+
const { t: s } = fe(), [h, d] = H(""), [u, f] = H(""), y = B(null);
|
|
778
|
+
K(() => (t ? (d(""), f(""), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
778
779
|
var w;
|
|
779
780
|
return (w = y.current) == null ? void 0 : w.focus();
|
|
780
781
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
781
782
|
document.body.style.overflow = "";
|
|
782
783
|
}), [t]);
|
|
783
|
-
const N =
|
|
784
|
+
const N = A(() => {
|
|
784
785
|
const w = h.trim();
|
|
785
786
|
if (!w) {
|
|
786
787
|
f(s("video.urlRequired"));
|
|
@@ -793,11 +794,11 @@ const bt = ({
|
|
|
793
794
|
return;
|
|
794
795
|
}
|
|
795
796
|
o.chain().focus().setVideo({ src: w }).run(), c == null || c(w), i();
|
|
796
|
-
}, [h, o, s, c, i]), S =
|
|
797
|
+
}, [h, o, s, c, i]), S = A(() => {
|
|
797
798
|
p == null || p(), i();
|
|
798
|
-
}, [p, i]), m =
|
|
799
|
+
}, [p, i]), m = A((w) => {
|
|
799
800
|
w.target === w.currentTarget && S();
|
|
800
|
-
}, [S]), T =
|
|
801
|
+
}, [S]), T = A((w) => {
|
|
801
802
|
w.key === "Enter" ? (w.preventDefault(), N()) : w.key === "Escape" && (w.preventDefault(), S());
|
|
802
803
|
}, [N, S]);
|
|
803
804
|
return t ? _e(
|
|
@@ -817,7 +818,7 @@ const bt = ({
|
|
|
817
818
|
className: "tp-url-input",
|
|
818
819
|
placeholder: s("video.placeholder"),
|
|
819
820
|
value: h,
|
|
820
|
-
onChange: (w) =>
|
|
821
|
+
onChange: (w) => d(w.target.value),
|
|
821
822
|
onKeyDown: T
|
|
822
823
|
}
|
|
823
824
|
),
|
|
@@ -829,8 +830,8 @@ const bt = ({
|
|
|
829
830
|
] }) }),
|
|
830
831
|
document.body
|
|
831
832
|
) : null;
|
|
832
|
-
},
|
|
833
|
-
const { t: i } = fe(), [s, h] =
|
|
833
|
+
}, At = ({ def: t, editor: o, active: c, disabled: p }) => {
|
|
834
|
+
const { t: i } = fe(), [s, h] = H(!1), d = () => {
|
|
834
835
|
p || h(!0);
|
|
835
836
|
};
|
|
836
837
|
return /* @__PURE__ */ v("div", { className: "tp-toolbar-video-btn", children: [
|
|
@@ -841,7 +842,7 @@ const bt = ({
|
|
|
841
842
|
title: i(t.titleKey),
|
|
842
843
|
disabled: p,
|
|
843
844
|
onMouseDown: (u) => u.preventDefault(),
|
|
844
|
-
onClick:
|
|
845
|
+
onClick: d,
|
|
845
846
|
children: /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: ke(t.name) } })
|
|
846
847
|
}
|
|
847
848
|
),
|
|
@@ -856,8 +857,8 @@ const bt = ({
|
|
|
856
857
|
}
|
|
857
858
|
)
|
|
858
859
|
] });
|
|
859
|
-
},
|
|
860
|
-
const { t: i } = fe(), [s, h] =
|
|
860
|
+
}, Ht = 10, Et = 10, Rt = ({ def: t, editor: o, active: c, disabled: p }) => {
|
|
861
|
+
const { t: i } = fe(), [s, h] = H(!1), [d, u] = H({ row: 0, col: 0 }), f = B(null), y = () => {
|
|
861
862
|
p || (h(!s), u({ row: 0, col: 0 }));
|
|
862
863
|
}, N = (m, T) => {
|
|
863
864
|
u({ row: m, col: T });
|
|
@@ -885,13 +886,13 @@ const bt = ({
|
|
|
885
886
|
}
|
|
886
887
|
),
|
|
887
888
|
s && /* @__PURE__ */ v("div", { className: "tp-table-grid-dropdown", children: [
|
|
888
|
-
/* @__PURE__ */ e("div", { className: "tp-table-grid-header", children:
|
|
889
|
-
/* @__PURE__ */ e("div", { className: "tp-table-grid", children: Array.from({ length:
|
|
889
|
+
/* @__PURE__ */ e("div", { className: "tp-table-grid-header", children: d.row > 0 ? `${d.row} × ${d.col}` : i("table.insertHint") }),
|
|
890
|
+
/* @__PURE__ */ e("div", { className: "tp-table-grid", children: Array.from({ length: Ht }, (m, T) => /* @__PURE__ */ e("div", { className: "tp-table-grid-row", children: Array.from({ length: Et }, (w, M) => {
|
|
890
891
|
const n = T + 1, r = M + 1;
|
|
891
892
|
return /* @__PURE__ */ e(
|
|
892
893
|
"div",
|
|
893
894
|
{
|
|
894
|
-
className: `tp-table-grid-cell${n <=
|
|
895
|
+
className: `tp-table-grid-cell${n <= d.row && r <= d.col ? " is-hovered" : ""}${n === d.row && r === d.col ? " is-selected" : ""}`,
|
|
895
896
|
onMouseEnter: () => N(n, r),
|
|
896
897
|
onClick: () => S(n, r)
|
|
897
898
|
},
|
|
@@ -901,7 +902,7 @@ const bt = ({
|
|
|
901
902
|
] })
|
|
902
903
|
] });
|
|
903
904
|
}, $t = ({ editor: t, disabled: o = !1 }) => {
|
|
904
|
-
const { t: c } = fe(), p = B("none"), [i, s] =
|
|
905
|
+
const { t: c } = fe(), p = B("none"), [i, s] = H("none"), h = B([]), d = B(null), u = B(null), f = B(null), y = B(void 0), N = B(null), S = B(0), m = B(!1), T = i !== "none", w = A(() => {
|
|
905
906
|
const { from: E, to: $ } = t.state.selection;
|
|
906
907
|
if (t.isActive("orderedList")) return "orderedList";
|
|
907
908
|
if (t.isActive("bulletList")) return "bulletList";
|
|
@@ -913,20 +914,20 @@ const bt = ({
|
|
|
913
914
|
if (W.type.name === "bulletList") return "bulletList";
|
|
914
915
|
}
|
|
915
916
|
return null;
|
|
916
|
-
}, [t]), M =
|
|
917
|
+
}, [t]), M = A(() => {
|
|
917
918
|
const { from: E, to: $ } = t.state.selection;
|
|
918
919
|
if (t.isActive("orderedList") || t.isActive("bulletList")) return;
|
|
919
920
|
for (let j = 1; j <= 6; j++)
|
|
920
921
|
if (t.isActive("heading", { level: j })) return j;
|
|
921
922
|
const P = Math.min(E + 1, $);
|
|
922
923
|
if (t.state.doc.resolve(P).parent.type.name === "paragraph") return null;
|
|
923
|
-
}, [t]), n =
|
|
924
|
+
}, [t]), n = A(() => {
|
|
924
925
|
const { from: E, to: $, empty: P } = t.state.selection;
|
|
925
926
|
if (P) return !1;
|
|
926
927
|
const O = t.state.doc.resolve(Math.min(E + 1, $)).marks();
|
|
927
928
|
h.current = [...O];
|
|
928
929
|
const j = w();
|
|
929
|
-
|
|
930
|
+
d.current = j;
|
|
930
931
|
const W = t.getAttributes("textStyle");
|
|
931
932
|
u.current = {
|
|
932
933
|
color: W.color,
|
|
@@ -940,10 +941,10 @@ const bt = ({
|
|
|
940
941
|
}, y.current = M();
|
|
941
942
|
const z = O.length > 0, q = !!W.color || !!W.fontFamily || !!W.fontSize, ee = !!f.current.textAlign || !!f.current.lineHeight;
|
|
942
943
|
return z || q || ee || j !== null || y.current !== void 0;
|
|
943
|
-
}, [t, w, M]), r =
|
|
944
|
-
if (!
|
|
944
|
+
}, [t, w, M]), r = A(() => {
|
|
945
|
+
if (!d.current) return;
|
|
945
946
|
const E = t.chain().focus();
|
|
946
|
-
switch (
|
|
947
|
+
switch (d.current) {
|
|
947
948
|
case "orderedList":
|
|
948
949
|
t.isActive("orderedList") || (t.isActive("bulletList") && E.toggleBulletList(), E.toggleOrderedList().run());
|
|
949
950
|
break;
|
|
@@ -951,7 +952,7 @@ const bt = ({
|
|
|
951
952
|
t.isActive("bulletList") || (t.isActive("orderedList") && E.toggleOrderedList(), E.toggleBulletList().run());
|
|
952
953
|
break;
|
|
953
954
|
}
|
|
954
|
-
}, [t]), k =
|
|
955
|
+
}, [t]), k = A(() => {
|
|
955
956
|
if (y.current === void 0) return;
|
|
956
957
|
const E = t.chain().focus();
|
|
957
958
|
if (y.current === null)
|
|
@@ -960,18 +961,18 @@ const bt = ({
|
|
|
960
961
|
const { schema: $ } = t.state;
|
|
961
962
|
$.nodes.heading && E.setNode("heading", { level: y.current }).run();
|
|
962
963
|
}
|
|
963
|
-
}, [t]), g =
|
|
964
|
+
}, [t]), g = A(() => {
|
|
964
965
|
let { state: E } = t, { from: $, to: P, empty: G } = E.selection;
|
|
965
966
|
if (G) return !1;
|
|
966
967
|
const { schema: O } = E;
|
|
967
|
-
if (
|
|
968
|
+
if (d.current ? r() : y.current !== void 0 && k(), f.current) {
|
|
968
969
|
const z = t.chain().focus();
|
|
969
970
|
f.current.textAlign && z.setTextAlign(f.current.textAlign), f.current.lineHeight && z.setLineHeight(f.current.lineHeight), z.run();
|
|
970
971
|
}
|
|
971
972
|
E = t.state;
|
|
972
973
|
const j = E.selection;
|
|
973
974
|
if ($ = j.from, P = j.to, h.current.length === 0 && !u.current)
|
|
974
|
-
return
|
|
975
|
+
return d.current !== null || f.current !== null || y.current !== void 0;
|
|
975
976
|
const W = E.tr, I = [];
|
|
976
977
|
if (h.current.forEach((z) => {
|
|
977
978
|
const q = z.type.name;
|
|
@@ -995,25 +996,25 @@ const bt = ({
|
|
|
995
996
|
});
|
|
996
997
|
}
|
|
997
998
|
}), W.docChanged && t.view.dispatch(W)), !0;
|
|
998
|
-
}, [t, r, k]), l =
|
|
999
|
-
p.current = "none", s("none"), h.current = [],
|
|
1000
|
-
}, []), x =
|
|
999
|
+
}, [t, r, k]), l = A(() => {
|
|
1000
|
+
p.current = "none", s("none"), h.current = [], d.current = null, u.current = null, f.current = null, y.current = void 0;
|
|
1001
|
+
}, []), x = A(() => {
|
|
1001
1002
|
if (p.current === "none") return;
|
|
1002
1003
|
const { empty: E } = t.state.selection;
|
|
1003
1004
|
E || (g(), p.current === "single" && l());
|
|
1004
|
-
}, [t, g, l]), _ =
|
|
1005
|
+
}, [t, g, l]), _ = A(() => {
|
|
1005
1006
|
if (p.current === "single" || p.current === "multiple") {
|
|
1006
1007
|
l();
|
|
1007
1008
|
return;
|
|
1008
1009
|
}
|
|
1009
1010
|
n() && (p.current = "single", s("single"));
|
|
1010
|
-
}, [n, l]), V =
|
|
1011
|
+
}, [n, l]), V = A(() => {
|
|
1011
1012
|
if (p.current === "multiple") {
|
|
1012
1013
|
l();
|
|
1013
1014
|
return;
|
|
1014
1015
|
}
|
|
1015
1016
|
n() && (p.current = "multiple", s("multiple"));
|
|
1016
|
-
}, [n, l]), b =
|
|
1017
|
+
}, [n, l]), b = A(() => {
|
|
1017
1018
|
o || (S.current++, S.current === 1 ? N.current = window.setTimeout(() => {
|
|
1018
1019
|
_(), S.current = 0, N.current = null;
|
|
1019
1020
|
}, 250) : S.current === 2 && (N.current && (clearTimeout(N.current), N.current = null), V(), S.current = 0));
|
|
@@ -1057,7 +1058,7 @@ const bt = ({
|
|
|
1057
1058
|
{ type: "lower-alpha", lines: ["a.", "b.", "c."] },
|
|
1058
1059
|
{ type: "upper-alpha", lines: ["A.", "B.", "C."] }
|
|
1059
1060
|
], Bt = ({ def: t, editor: o, active: c, disabled: p }) => {
|
|
1060
|
-
const { t: i } = fe(), [s, h] =
|
|
1061
|
+
const { t: i } = fe(), [s, h] = H(!1), [d, u] = H(0), f = B(null), y = () => {
|
|
1061
1062
|
const { state: g } = o, l = g.selection.$from;
|
|
1062
1063
|
let x = null, _ = 0;
|
|
1063
1064
|
for (let V = l.depth; V >= 0; V--) {
|
|
@@ -1074,19 +1075,19 @@ const bt = ({
|
|
|
1074
1075
|
})(), m = (() => {
|
|
1075
1076
|
const { node: g } = y();
|
|
1076
1077
|
return !!(g != null && g.attrs.reversed);
|
|
1077
|
-
})(), T =
|
|
1078
|
+
})(), T = A(() => {
|
|
1078
1079
|
var g;
|
|
1079
1080
|
(g = t.command) == null || g.call(t, o);
|
|
1080
|
-
}, [t, o]), w =
|
|
1081
|
+
}, [t, o]), w = A(() => {
|
|
1081
1082
|
p || h((g) => !g);
|
|
1082
|
-
}, [p]), M =
|
|
1083
|
+
}, [p]), M = A((g) => {
|
|
1083
1084
|
o.commands.createStyledOrderedList({ listStyleType: g }), o.commands.focus(), h(!1);
|
|
1084
|
-
}, [o]), n =
|
|
1085
|
+
}, [o]), n = A((g) => {
|
|
1085
1086
|
const l = parseInt(g.target.value, 10);
|
|
1086
1087
|
isNaN(l) || o.commands.setOrderedListAttrs({ start: l });
|
|
1087
|
-
}, [o]), r =
|
|
1088
|
+
}, [o]), r = A((g) => {
|
|
1088
1089
|
["Backspace", "Delete", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Tab", "Home", "End"].includes(g.key) || g.key === "-" || g.key === "Minus" || g.key >= "0" && g.key <= "9" || g.ctrlKey || g.metaKey || g.preventDefault();
|
|
1089
|
-
}, []), k =
|
|
1090
|
+
}, []), k = A(() => {
|
|
1090
1091
|
const g = !m;
|
|
1091
1092
|
o.commands.setOrderedListAttrs({ reversed: g || null });
|
|
1092
1093
|
}, [o, m]);
|
|
@@ -1169,7 +1170,7 @@ const bt = ({
|
|
|
1169
1170
|
{ type: "square", marker: "■" },
|
|
1170
1171
|
{ type: "none", marker: "—" }
|
|
1171
1172
|
], Pt = ({ def: t, editor: o, active: c, disabled: p }) => {
|
|
1172
|
-
const { t: i } = fe(), [s, h] =
|
|
1173
|
+
const { t: i } = fe(), [s, h] = H(!1), [d, u] = H(0), f = B(null), y = (() => {
|
|
1173
1174
|
const { state: T } = o, w = T.selection.$from;
|
|
1174
1175
|
let M = null, n = 0;
|
|
1175
1176
|
for (let r = w.depth; r >= 0; r--) {
|
|
@@ -1177,12 +1178,12 @@ const bt = ({
|
|
|
1177
1178
|
k.type.name === "bulletList" && (M || (M = k), n++);
|
|
1178
1179
|
}
|
|
1179
1180
|
return M && M.attrs.listStyleType ? M.attrs.listStyleType : n <= 1 ? "disc" : n === 2 ? "circle" : "square";
|
|
1180
|
-
})(), N =
|
|
1181
|
+
})(), N = A(() => {
|
|
1181
1182
|
var T;
|
|
1182
1183
|
(T = t.command) == null || T.call(t, o);
|
|
1183
|
-
}, [t, o]), S =
|
|
1184
|
+
}, [t, o]), S = A(() => {
|
|
1184
1185
|
p || h((T) => !T);
|
|
1185
|
-
}, [p]), m =
|
|
1186
|
+
}, [p]), m = A((T) => {
|
|
1186
1187
|
o.commands.createStyledBulletList({ listStyleType: T }), o.commands.focus(), h(!1);
|
|
1187
1188
|
}, [o]);
|
|
1188
1189
|
return K(() => {
|
|
@@ -1240,10 +1241,10 @@ const Ft = ({
|
|
|
1240
1241
|
viewMode: i = "normal",
|
|
1241
1242
|
onToggleViewMode: s,
|
|
1242
1243
|
onToolbarClick: h,
|
|
1243
|
-
prepend:
|
|
1244
|
+
prepend: d,
|
|
1244
1245
|
append: u
|
|
1245
1246
|
}) => {
|
|
1246
|
-
const f = () => o.getEditor(), y =
|
|
1247
|
+
const f = () => o.getEditor(), y = A((n) => {
|
|
1247
1248
|
if (n === "getHTML") {
|
|
1248
1249
|
s == null || s("html");
|
|
1249
1250
|
return;
|
|
@@ -1258,10 +1259,10 @@ const Ft = ({
|
|
|
1258
1259
|
const r = ht(n);
|
|
1259
1260
|
if (!r) return null;
|
|
1260
1261
|
const k = f();
|
|
1261
|
-
return n === "imageUpload" ? /* @__PURE__ */ e(Dt, { def: r, editor: k, manager: o, active: N(n), disabled: S(n) }, n) : n === "video" ? /* @__PURE__ */ e(
|
|
1262
|
+
return n === "imageUpload" ? /* @__PURE__ */ e(Dt, { def: r, editor: k, manager: o, active: N(n), disabled: S(n) }, n) : n === "video" ? /* @__PURE__ */ e(At, { def: r, editor: k, active: N(n), disabled: S(n) }, n) : n === "insertTable" ? /* @__PURE__ */ e(Rt, { def: r, editor: k, active: N(n), disabled: S(n) }, n) : n === "formatPainter" ? /* @__PURE__ */ e($t, { editor: k, disabled: S(n) }, n) : n === "orderedList" ? /* @__PURE__ */ e(Bt, { def: r, editor: k, active: N(n), disabled: S(n) }, n) : n === "bulletList" ? /* @__PURE__ */ e(Pt, { def: r, editor: k, active: N(n), disabled: S(n) }, n) : r.type === "button" ? /* @__PURE__ */ e(kt, { def: r, editor: k, active: N(n), disabled: S(n), onCustomClick: y }, n) : r.type === "dropdown" ? /* @__PURE__ */ e(Ct, { def: r, editor: k, active: N(n), disabled: S(n), onCustomClick: y }, n) : r.type === "color-picker" ? /* @__PURE__ */ e(Lt, { def: r, editor: k, disabled: S(n) }, n) : null;
|
|
1262
1263
|
}
|
|
1263
1264
|
return /* @__PURE__ */ v("div", { className: "tp-toolbar", children: [
|
|
1264
|
-
|
|
1265
|
+
d,
|
|
1265
1266
|
T.map((n, r) => /* @__PURE__ */ v(Xe.Fragment, { children: [
|
|
1266
1267
|
r > 0 && /* @__PURE__ */ e(ot, {}),
|
|
1267
1268
|
n.category !== "content" ? /* @__PURE__ */ e("div", { className: rt(n.category), children: n.items.map(M) }) : /* @__PURE__ */ e(Ze, { children: n.items.map(M) })
|
|
@@ -1280,7 +1281,7 @@ const Ft = ({
|
|
|
1280
1281
|
onVisibleChange: i,
|
|
1281
1282
|
onAction: s
|
|
1282
1283
|
}) => {
|
|
1283
|
-
const h = B(null), [
|
|
1284
|
+
const h = B(null), [d, u] = H({ x: 0, y: 0 }), [f, y] = H(!1), [N, S] = H(!1), m = B({ x: 0, y: 0 }), T = De.getInstance(), w = (r) => T.t(r), M = A((r) => {
|
|
1284
1285
|
if (!h.current) return r;
|
|
1285
1286
|
const k = h.current.getBoundingClientRect();
|
|
1286
1287
|
return k.width === 0 || k.height === 0 ? r : Qe({
|
|
@@ -1306,13 +1307,13 @@ const Ft = ({
|
|
|
1306
1307
|
const r = h.current.getBoundingClientRect();
|
|
1307
1308
|
if (r.width === 0 || r.height === 0) return;
|
|
1308
1309
|
const k = Qe({
|
|
1309
|
-
x:
|
|
1310
|
-
y:
|
|
1310
|
+
x: d.x,
|
|
1311
|
+
y: d.y,
|
|
1311
1312
|
width: r.width,
|
|
1312
1313
|
height: r.height
|
|
1313
1314
|
});
|
|
1314
|
-
(k.x !==
|
|
1315
|
-
}, [o,
|
|
1315
|
+
(k.x !== d.x || k.y !== d.y) && u({ x: k.x, y: k.y });
|
|
1316
|
+
}, [o, d.x, d.y]), K(() => {
|
|
1316
1317
|
const r = () => {
|
|
1317
1318
|
if (!o || !p) return;
|
|
1318
1319
|
const g = p.getBoundingClientRect();
|
|
@@ -1341,7 +1342,7 @@ const Ft = ({
|
|
|
1341
1342
|
document.removeEventListener("click", r), document.removeEventListener("keydown", k);
|
|
1342
1343
|
};
|
|
1343
1344
|
}, [i]);
|
|
1344
|
-
const n =
|
|
1345
|
+
const n = A((r) => {
|
|
1345
1346
|
s(r), i(!1);
|
|
1346
1347
|
}, [s, i]);
|
|
1347
1348
|
return o ? _e(
|
|
@@ -1350,7 +1351,7 @@ const Ft = ({
|
|
|
1350
1351
|
{
|
|
1351
1352
|
ref: h,
|
|
1352
1353
|
className: "tp-table-context-menu",
|
|
1353
|
-
style: { left:
|
|
1354
|
+
style: { left: d.x, top: d.y },
|
|
1354
1355
|
onClick: (r) => r.stopPropagation(),
|
|
1355
1356
|
children: [
|
|
1356
1357
|
/* @__PURE__ */ v("div", { className: "tp-table-menu-section", children: [
|
|
@@ -1441,10 +1442,10 @@ function Ye(t, o, c) {
|
|
|
1441
1442
|
t /= 255, o /= 255, c /= 255;
|
|
1442
1443
|
const p = Math.max(t, o, c), i = Math.min(t, o, c);
|
|
1443
1444
|
let s = 0, h = 0;
|
|
1444
|
-
const
|
|
1445
|
+
const d = (p + i) / 2;
|
|
1445
1446
|
if (p !== i) {
|
|
1446
1447
|
const u = p - i;
|
|
1447
|
-
switch (h =
|
|
1448
|
+
switch (h = d > 0.5 ? u / (2 - p - i) : u / (p + i), p) {
|
|
1448
1449
|
case t:
|
|
1449
1450
|
s = ((o - c) / u + (o < c ? 6 : 0)) / 6;
|
|
1450
1451
|
break;
|
|
@@ -1456,46 +1457,46 @@ function Ye(t, o, c) {
|
|
|
1456
1457
|
break;
|
|
1457
1458
|
}
|
|
1458
1459
|
}
|
|
1459
|
-
return { h: Math.round(s * 360), s: Math.round(h * 100), l: Math.round(
|
|
1460
|
+
return { h: Math.round(s * 360), s: Math.round(h * 100), l: Math.round(d * 100) };
|
|
1460
1461
|
}
|
|
1461
1462
|
function Ge(t, o, c) {
|
|
1462
1463
|
t /= 255, o /= 255, c /= 255;
|
|
1463
1464
|
const p = Math.max(t, o, c), i = Math.min(t, o, c);
|
|
1464
1465
|
let s = 0;
|
|
1465
|
-
const h = p,
|
|
1466
|
+
const h = p, d = p - i, u = p === 0 ? 0 : d / p;
|
|
1466
1467
|
if (p !== i)
|
|
1467
1468
|
switch (p) {
|
|
1468
1469
|
case t:
|
|
1469
|
-
s = ((o - c) /
|
|
1470
|
+
s = ((o - c) / d + (o < c ? 6 : 0)) / 6;
|
|
1470
1471
|
break;
|
|
1471
1472
|
case o:
|
|
1472
|
-
s = ((c - t) /
|
|
1473
|
+
s = ((c - t) / d + 2) / 6;
|
|
1473
1474
|
break;
|
|
1474
1475
|
case c:
|
|
1475
|
-
s = ((t - o) /
|
|
1476
|
+
s = ((t - o) / d + 4) / 6;
|
|
1476
1477
|
break;
|
|
1477
1478
|
}
|
|
1478
1479
|
return { h: Math.round(s * 360), s: Math.round(u * 100), v: Math.round(h * 100) };
|
|
1479
1480
|
}
|
|
1480
1481
|
function Kt(t, o, c) {
|
|
1481
1482
|
o /= 100, c /= 100;
|
|
1482
|
-
const p = Math.floor(t / 60) % 6, i = t / 60 - Math.floor(t / 60), s = c * (1 - o), h = c * (1 - i * o),
|
|
1483
|
+
const p = Math.floor(t / 60) % 6, i = t / 60 - Math.floor(t / 60), s = c * (1 - o), h = c * (1 - i * o), d = c * (1 - (1 - i) * o);
|
|
1483
1484
|
let u = 0, f = 0, y = 0;
|
|
1484
1485
|
switch (p) {
|
|
1485
1486
|
case 0:
|
|
1486
|
-
u = c, f =
|
|
1487
|
+
u = c, f = d, y = s;
|
|
1487
1488
|
break;
|
|
1488
1489
|
case 1:
|
|
1489
1490
|
u = h, f = c, y = s;
|
|
1490
1491
|
break;
|
|
1491
1492
|
case 2:
|
|
1492
|
-
u = s, f = c, y =
|
|
1493
|
+
u = s, f = c, y = d;
|
|
1493
1494
|
break;
|
|
1494
1495
|
case 3:
|
|
1495
1496
|
u = s, f = h, y = c;
|
|
1496
1497
|
break;
|
|
1497
1498
|
case 4:
|
|
1498
|
-
u =
|
|
1499
|
+
u = d, f = s, y = c;
|
|
1499
1500
|
break;
|
|
1500
1501
|
case 5:
|
|
1501
1502
|
u = c, f = s, y = h;
|
|
@@ -1509,14 +1510,14 @@ function zt(t, o, c) {
|
|
|
1509
1510
|
if (o === 0)
|
|
1510
1511
|
p = i = s = c;
|
|
1511
1512
|
else {
|
|
1512
|
-
const h = (f, y, N) => (N < 0 && (N += 1), N > 1 && (N -= 1), N < 0.16666666666666666 ? f + (y - f) * 6 * N : N < 0.5 ? y : N < 0.6666666666666666 ? f + (y - f) * (0.6666666666666666 - N) * 6 : f),
|
|
1513
|
-
p = h(u,
|
|
1513
|
+
const h = (f, y, N) => (N < 0 && (N += 1), N > 1 && (N -= 1), N < 0.16666666666666666 ? f + (y - f) * 6 * N : N < 0.5 ? y : N < 0.6666666666666666 ? f + (y - f) * (0.6666666666666666 - N) * 6 : f), d = c < 0.5 ? c * (1 + o) : c + o - c * o, u = 2 * c - d;
|
|
1514
|
+
p = h(u, d, t + 1 / 3), i = h(u, d, t), s = h(u, d, t - 1 / 3);
|
|
1514
1515
|
}
|
|
1515
1516
|
return { r: Math.round(p * 255), g: Math.round(i * 255), b: Math.round(s * 255) };
|
|
1516
1517
|
}
|
|
1517
1518
|
const Ue = ct(
|
|
1518
1519
|
({ value: t, onChange: o, placeholder: c, mode: p = "border", beforeOpen: i, onClose: s }, h) => {
|
|
1519
|
-
const [
|
|
1520
|
+
const [d, u] = H(!1), f = B(null), y = B(null), N = B(null), S = B(null), m = B(null), [T, w] = H(-1e4), [M, n] = H(-1e4), [r, k] = H(t), [g, l] = H(t), x = B(t), [_, V] = H("hex"), [b, E] = H({ h: 0, s: 100, v: 100 }), [$, P] = H({ r: 0, g: 0, b: 0 }), [G, O] = H({ h: 0, s: 0, l: 0 }), [j, W] = H(!1), [I, F] = H(!1), [z, q] = H(!1), ee = A(() => {
|
|
1520
1521
|
let L = 0;
|
|
1521
1522
|
const R = 3, Z = () => {
|
|
1522
1523
|
if (L >= R * 2) {
|
|
@@ -1530,11 +1531,11 @@ const Ue = ct(
|
|
|
1530
1531
|
st(h, () => ({
|
|
1531
1532
|
triggerButtonFlash: ee
|
|
1532
1533
|
}));
|
|
1533
|
-
const te = Te(() => p === "background" ? jt : Wt, [p]), ve = g || "#d9d9d9", ne =
|
|
1534
|
+
const te = Te(() => p === "background" ? jt : Wt, [p]), ve = g || "#d9d9d9", ne = A((L) => {
|
|
1534
1535
|
k(L), l(L);
|
|
1535
1536
|
const R = Ut(L);
|
|
1536
1537
|
R && (P(R), O(Ye(R.r, R.g, R.b)), E(Ge(R.r, R.g, R.b)));
|
|
1537
|
-
}, []), ue =
|
|
1538
|
+
}, []), ue = A(() => {
|
|
1538
1539
|
const L = Kt(b.h, b.s, b.v), R = qe(L.r, L.g, L.b);
|
|
1539
1540
|
P(L), O(Ye(L.r, L.g, L.b)), k(R), l(R);
|
|
1540
1541
|
}, [b]);
|
|
@@ -1543,7 +1544,7 @@ const Ue = ct(
|
|
|
1543
1544
|
}, [t, ne]), K(() => {
|
|
1544
1545
|
ue();
|
|
1545
1546
|
}, [b, ue]);
|
|
1546
|
-
const ae =
|
|
1547
|
+
const ae = A((L) => {
|
|
1547
1548
|
let R = L.parentElement;
|
|
1548
1549
|
for (; R; ) {
|
|
1549
1550
|
const Z = window.getComputedStyle(R);
|
|
@@ -1552,72 +1553,72 @@ const Ue = ct(
|
|
|
1552
1553
|
R = R.parentElement;
|
|
1553
1554
|
}
|
|
1554
1555
|
return null;
|
|
1555
|
-
}, []), Y =
|
|
1556
|
-
if (!
|
|
1556
|
+
}, []), Y = A(() => {
|
|
1557
|
+
if (!d || !y.current || !N.current || !f.current) return;
|
|
1557
1558
|
const L = y.current, R = N.current, Z = f.current, ce = L.getBoundingClientRect(), de = R.getBoundingClientRect(), Pe = Z.getBoundingClientRect();
|
|
1558
1559
|
if (Pe.width === 0 && Pe.height === 0) {
|
|
1559
1560
|
requestAnimationFrame(Y);
|
|
1560
1561
|
return;
|
|
1561
1562
|
}
|
|
1562
|
-
const
|
|
1563
|
+
const Ae = window.innerWidth, He = window.innerHeight, le = 8, Oe = 10, ze = Oe / 2, Ee = ce.width || 260, be = ce.height || 348;
|
|
1563
1564
|
L.style.maxHeight = "", L.style.overflowY = "";
|
|
1564
1565
|
let Re = de.top, Me, C = "right";
|
|
1565
|
-
if (de.right + le + Ee <=
|
|
1566
|
+
if (de.right + le + Ee <= Ae - le)
|
|
1566
1567
|
Me = de.right + le, C = "right";
|
|
1567
1568
|
else if (de.left - Ee - le >= le)
|
|
1568
1569
|
Me = de.left - Ee - le, C = "left";
|
|
1569
1570
|
else {
|
|
1570
|
-
const he =
|
|
1571
|
-
he >= pe ? (Me = Math.max(le,
|
|
1571
|
+
const he = Ae - de.right - le, pe = de.left - le;
|
|
1572
|
+
he >= pe ? (Me = Math.max(le, Ae - Ee - le), C = "right") : (Me = le, C = "left");
|
|
1572
1573
|
}
|
|
1573
|
-
Re + be >
|
|
1574
|
+
Re + be > He - le && (Re = Math.max(le, He - be - le)), w(Re), n(Me), L.dataset.placement = C;
|
|
1574
1575
|
let U = de.top + de.height / 2 - Re - ze;
|
|
1575
1576
|
const se = le, re = Math.max(se, be - Oe - le);
|
|
1576
1577
|
U = Math.max(se, Math.min(re, U)), L.style.setProperty("--triangle-top", `${U}px`);
|
|
1577
|
-
}, [
|
|
1578
|
+
}, [d]);
|
|
1578
1579
|
K(() => {
|
|
1579
|
-
if (!
|
|
1580
|
+
if (!d) return;
|
|
1580
1581
|
const L = requestAnimationFrame(Y), R = y.current, Z = R ? ae(R) : null, ce = () => requestAnimationFrame(Y);
|
|
1581
1582
|
return Z && Z.addEventListener("scroll", ce, !0), () => {
|
|
1582
1583
|
cancelAnimationFrame(L), Z && Z.removeEventListener("scroll", ce, !0);
|
|
1583
1584
|
};
|
|
1584
|
-
}, [
|
|
1585
|
-
|
|
1586
|
-
}, [_,
|
|
1587
|
-
const oe =
|
|
1588
|
-
if (
|
|
1585
|
+
}, [d, Y, ae]), K(() => {
|
|
1586
|
+
d && requestAnimationFrame(Y);
|
|
1587
|
+
}, [_, d, Y]);
|
|
1588
|
+
const oe = A(() => {
|
|
1589
|
+
if (d)
|
|
1589
1590
|
s == null || s();
|
|
1590
1591
|
else {
|
|
1591
1592
|
if (i && i() === !1) return;
|
|
1592
1593
|
x.current = t, l(t), ne(t);
|
|
1593
1594
|
}
|
|
1594
|
-
u(!
|
|
1595
|
-
}, [
|
|
1595
|
+
u(!d);
|
|
1596
|
+
}, [d, t, ne, i, s]), J = A((L) => {
|
|
1596
1597
|
ne(L);
|
|
1597
|
-
}, [ne]), X =
|
|
1598
|
+
}, [ne]), X = A((L) => {
|
|
1598
1599
|
const R = L.target.value;
|
|
1599
1600
|
k(R), (/^#[0-9A-Fa-f]{6}$/.test(R) || /^#[0-9A-Fa-f]{3}$/.test(R)) && ne(R);
|
|
1600
|
-
}, [ne]), ge =
|
|
1601
|
+
}, [ne]), ge = A(() => {
|
|
1601
1602
|
r !== g && (/^#[0-9A-Fa-f]{6}$/.test(r) || /^#[0-9A-Fa-f]{3}$/.test(r) ? ne(r) : (k(g), ne(g)));
|
|
1602
|
-
}, [r, g, ne]), Be =
|
|
1603
|
+
}, [r, g, ne]), Be = A(() => {
|
|
1603
1604
|
const L = qe($.r, $.g, $.b);
|
|
1604
1605
|
k(L), l(L), O(Ye($.r, $.g, $.b)), E(Ge($.r, $.g, $.b));
|
|
1605
|
-
}, [$]), ye =
|
|
1606
|
+
}, [$]), ye = A(() => {
|
|
1606
1607
|
const L = zt(G.h, G.s, G.l), R = qe(L.r, L.g, L.b);
|
|
1607
1608
|
k(R), l(R), P(L), E(Ge(L.r, L.g, L.b));
|
|
1608
|
-
}, [G]), Ce =
|
|
1609
|
+
}, [G]), Ce = A((L) => {
|
|
1609
1610
|
if (!S.current) return;
|
|
1610
1611
|
const R = S.current.getBoundingClientRect();
|
|
1611
1612
|
let Z = Math.max(0, Math.min(100, (L.clientX - R.left) / R.width * 100)), ce = Math.max(0, Math.min(100, (L.clientY - R.top) / R.height * 100));
|
|
1612
1613
|
E((de) => ({ ...de, s: Z, v: 100 - ce }));
|
|
1613
|
-
}, []), Se =
|
|
1614
|
+
}, []), Se = A((L) => {
|
|
1614
1615
|
W(!0), Ce(L.nativeEvent);
|
|
1615
|
-
}, [Ce]), Ne =
|
|
1616
|
+
}, [Ce]), Ne = A((L) => {
|
|
1616
1617
|
if (!m.current) return;
|
|
1617
1618
|
const R = m.current.getBoundingClientRect();
|
|
1618
1619
|
let Z = Math.max(0, Math.min(360, (L.clientX - R.left) / R.width * 360));
|
|
1619
1620
|
E((ce) => ({ ...ce, h: Z }));
|
|
1620
|
-
}, []), Ie =
|
|
1621
|
+
}, []), Ie = A((L) => {
|
|
1621
1622
|
F(!0), Ne(L.nativeEvent);
|
|
1622
1623
|
}, [Ne]);
|
|
1623
1624
|
K(() => {
|
|
@@ -1631,26 +1632,26 @@ const Ue = ct(
|
|
|
1631
1632
|
};
|
|
1632
1633
|
}, [j, I, Ce, Ne]), K(() => {
|
|
1633
1634
|
const L = (Z) => {
|
|
1634
|
-
if (f.current && !f.current.contains(Z.target) &&
|
|
1635
|
+
if (f.current && !f.current.contains(Z.target) && d) {
|
|
1635
1636
|
const ce = Z.target, de = ce.closest ? ce.closest(".tp-color-picker-input") : null;
|
|
1636
1637
|
if (de && de !== f.current) return;
|
|
1637
1638
|
Z.stopPropagation(), Z.preventDefault(), ee();
|
|
1638
1639
|
}
|
|
1639
1640
|
}, R = () => {
|
|
1640
|
-
|
|
1641
|
+
d && requestAnimationFrame(Y);
|
|
1641
1642
|
};
|
|
1642
1643
|
return document.addEventListener("pointerdown", L, !0), window.addEventListener("resize", R), window.addEventListener("scroll", R, !0), () => {
|
|
1643
1644
|
document.removeEventListener("pointerdown", L, !0), window.removeEventListener("resize", R), window.removeEventListener("scroll", R, !0);
|
|
1644
1645
|
};
|
|
1645
|
-
}, [
|
|
1646
|
-
const Ke =
|
|
1646
|
+
}, [d, Y]);
|
|
1647
|
+
const Ke = A(() => {
|
|
1647
1648
|
o(g), u(!1), s == null || s();
|
|
1648
|
-
}, [g, o, s]),
|
|
1649
|
+
}, [g, o, s]), a = A(() => {
|
|
1649
1650
|
l(x.current), ne(x.current), u(!1), s == null || s();
|
|
1650
|
-
}, [ne, s]), Q =
|
|
1651
|
+
}, [ne, s]), Q = A((L) => {
|
|
1651
1652
|
L.stopPropagation();
|
|
1652
1653
|
}, []);
|
|
1653
|
-
return /* @__PURE__ */ v("div", { ref: f, className: `tp-color-picker-input${
|
|
1654
|
+
return /* @__PURE__ */ v("div", { ref: f, className: `tp-color-picker-input${d ? " tp-color-picker-input-open" : ""}`, onClick: Q, children: [
|
|
1654
1655
|
/* @__PURE__ */ e(
|
|
1655
1656
|
"button",
|
|
1656
1657
|
{
|
|
@@ -1675,7 +1676,7 @@ const Ue = ct(
|
|
|
1675
1676
|
onClick: Q
|
|
1676
1677
|
}
|
|
1677
1678
|
),
|
|
1678
|
-
|
|
1679
|
+
d && /* @__PURE__ */ v("div", { ref: y, className: "tp-color-panel", style: { position: "fixed", top: `${T}px`, left: `${M}px` }, onClick: Q, children: [
|
|
1679
1680
|
/* @__PURE__ */ e(
|
|
1680
1681
|
"div",
|
|
1681
1682
|
{
|
|
@@ -1775,7 +1776,7 @@ const Ue = ct(
|
|
|
1775
1776
|
/* @__PURE__ */ e("div", { className: "tp-color-preview-label", children: "当前颜色" }),
|
|
1776
1777
|
/* @__PURE__ */ e("div", { className: "tp-color-preview-box", style: { backgroundColor: ve } }),
|
|
1777
1778
|
/* @__PURE__ */ v("div", { className: "tp-color-actions", children: [
|
|
1778
|
-
/* @__PURE__ */ e("button", { type: "button", className: `tp-color-btn tp-color-btn-cancel${z ? " tp-color-btn-flash" : ""}`, title: "取消", onMouseDown: (L) => L.preventDefault(), onClick:
|
|
1779
|
+
/* @__PURE__ */ e("button", { type: "button", className: `tp-color-btn tp-color-btn-cancel${z ? " tp-color-btn-flash" : ""}`, title: "取消", onMouseDown: (L) => L.preventDefault(), onClick: a, children: "✕" }),
|
|
1779
1780
|
/* @__PURE__ */ e("button", { type: "button", className: `tp-color-btn tp-color-btn-confirm${z ? " tp-color-btn-flash" : ""}`, title: "确认", onMouseDown: (L) => L.preventDefault(), onClick: Ke, children: "✓" })
|
|
1780
1781
|
] })
|
|
1781
1782
|
] })
|
|
@@ -1785,7 +1786,7 @@ const Ue = ct(
|
|
|
1785
1786
|
);
|
|
1786
1787
|
Ue.displayName = "ColorPickerInput";
|
|
1787
1788
|
const Vt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
1788
|
-
const p = De.getInstance(), i = (m) => p.t(m), [s, h] =
|
|
1789
|
+
const p = De.getInstance(), i = (m) => p.t(m), [s, h] = H({ borderColor: "#d9d9d9", borderWidth: 1 }), [d, u] = H("");
|
|
1789
1790
|
K(() => {
|
|
1790
1791
|
if (o) {
|
|
1791
1792
|
document.body.style.overflow = "hidden";
|
|
@@ -1801,17 +1802,17 @@ const Vt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
1801
1802
|
document.body.style.overflow = "";
|
|
1802
1803
|
};
|
|
1803
1804
|
}, [o, t]);
|
|
1804
|
-
const f =
|
|
1805
|
+
const f = A(() => {
|
|
1805
1806
|
u("");
|
|
1806
|
-
}, []), y =
|
|
1807
|
-
|
|
1808
|
-
}, [
|
|
1809
|
-
|
|
1807
|
+
}, []), y = A((m) => (u(m), !0), []), N = A(() => {
|
|
1808
|
+
d || (t.commands.focus(), c(!1));
|
|
1809
|
+
}, [d, t, c]), S = A(() => {
|
|
1810
|
+
d || (t.chain().focus().setTableBorder({
|
|
1810
1811
|
color: s.borderColor,
|
|
1811
1812
|
width: `${s.borderWidth}px`,
|
|
1812
1813
|
style: "solid"
|
|
1813
1814
|
}).run(), c(!1));
|
|
1814
|
-
}, [
|
|
1815
|
+
}, [d, t, s, c]);
|
|
1815
1816
|
return o ? _e(
|
|
1816
1817
|
/* @__PURE__ */ e("div", { className: "tp-modal-overlay", onMouseDown: (m) => {
|
|
1817
1818
|
m.target === m.currentTarget && N();
|
|
@@ -1875,12 +1876,12 @@ function Yt(t) {
|
|
|
1875
1876
|
return `${o} ${c} ${p}`;
|
|
1876
1877
|
}
|
|
1877
1878
|
function we(t, o, c, p, i, s) {
|
|
1878
|
-
const h = t === 0,
|
|
1879
|
+
const h = t === 0, d = t + p >= i.height, u = o === 0, f = o + c >= i.width;
|
|
1879
1880
|
switch (s) {
|
|
1880
1881
|
case "top":
|
|
1881
1882
|
return h;
|
|
1882
1883
|
case "bottom":
|
|
1883
|
-
return
|
|
1884
|
+
return d;
|
|
1884
1885
|
case "left":
|
|
1885
1886
|
return u;
|
|
1886
1887
|
case "right":
|
|
@@ -1889,25 +1890,25 @@ function we(t, o, c, p, i, s) {
|
|
|
1889
1890
|
return !1;
|
|
1890
1891
|
}
|
|
1891
1892
|
}
|
|
1892
|
-
function We(t, o, c, p, i, s, h,
|
|
1893
|
+
function We(t, o, c, p, i, s, h, d) {
|
|
1893
1894
|
const u = t.attrs.colspan || 1, f = t.attrs.rowspan || 1, y = { ...t.attrs };
|
|
1894
1895
|
switch (h) {
|
|
1895
1896
|
case "left":
|
|
1896
|
-
y.borderLeft =
|
|
1897
|
+
y.borderLeft = d;
|
|
1897
1898
|
break;
|
|
1898
1899
|
case "right":
|
|
1899
|
-
y.borderRight =
|
|
1900
|
+
y.borderRight = d;
|
|
1900
1901
|
break;
|
|
1901
1902
|
case "top":
|
|
1902
|
-
y.borderTop =
|
|
1903
|
+
y.borderTop = d;
|
|
1903
1904
|
break;
|
|
1904
1905
|
case "bottom":
|
|
1905
|
-
y.borderBottom =
|
|
1906
|
+
y.borderBottom = d;
|
|
1906
1907
|
break;
|
|
1907
1908
|
}
|
|
1908
1909
|
return y.borderLeft || (y.borderLeft = we(o, c, u, f, p, "left") && i ? i : s), y.borderRight || (y.borderRight = we(o, c, u, f, p, "right") && i ? i : s), y.borderTop || (y.borderTop = we(o, c, u, f, p, "top") && i ? i : s), y.borderBottom || (y.borderBottom = we(o, c, u, f, p, "bottom") && i ? i : s), y;
|
|
1909
1910
|
}
|
|
1910
|
-
function Gt(t, o, c, p, i, s, h,
|
|
1911
|
+
function Gt(t, o, c, p, i, s, h, d, u, f) {
|
|
1911
1912
|
const y = t.attrs.colspan || 1, N = t.attrs.rowspan || 1;
|
|
1912
1913
|
return f ? {
|
|
1913
1914
|
...t.attrs,
|
|
@@ -1916,21 +1917,21 @@ function Gt(t, o, c, p, i, s, h, a, u, f) {
|
|
|
1916
1917
|
borderTop: we(o, c, y, N, p, "top") && i ? i : s,
|
|
1917
1918
|
borderBottom: we(o, c, y, N, p, "bottom") && i ? i : s,
|
|
1918
1919
|
backgroundColor: h,
|
|
1919
|
-
textAlign:
|
|
1920
|
+
textAlign: d,
|
|
1920
1921
|
verticalAlign: u
|
|
1921
|
-
} : { ...t.attrs, backgroundColor: h, textAlign:
|
|
1922
|
+
} : { ...t.attrs, backgroundColor: h, textAlign: d, verticalAlign: u };
|
|
1922
1923
|
}
|
|
1923
1924
|
const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
1924
|
-
const p = De.getInstance(), i = (r) => p.t(r), [s, h] =
|
|
1925
|
+
const p = De.getInstance(), i = (r) => p.t(r), [s, h] = H({
|
|
1925
1926
|
borderColor: "#d9d9d9",
|
|
1926
1927
|
borderWidth: 1,
|
|
1927
1928
|
backgroundColor: "#ffffff",
|
|
1928
1929
|
textAlign: "left",
|
|
1929
1930
|
verticalAlign: "top"
|
|
1930
|
-
}), [
|
|
1931
|
+
}), [d, u] = H({ borderColor: "#d9d9d9", borderWidth: 1 }), [f, y] = H(""), N = B(null), S = B(null), m = A(() => {
|
|
1931
1932
|
const r = f === "border" ? N.current : S.current;
|
|
1932
1933
|
r == null || r.triggerButtonFlash();
|
|
1933
|
-
}, [f]), T =
|
|
1934
|
+
}, [f]), T = A((r) => f && f !== r ? (m(), !1) : (y(r), !0), [f, m]), w = A(() => {
|
|
1934
1935
|
const { state: r } = t, { selection: k } = r;
|
|
1935
1936
|
if ("$anchorCell" in k && k.$anchorCell) {
|
|
1936
1937
|
const x = k.$anchorCell;
|
|
@@ -1963,14 +1964,14 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
1963
1964
|
document.body.style.overflow = "";
|
|
1964
1965
|
};
|
|
1965
1966
|
}, [o, w]);
|
|
1966
|
-
const M =
|
|
1967
|
+
const M = A(() => {
|
|
1967
1968
|
f || (t.commands.focus(), c(!1));
|
|
1968
|
-
}, [f, t, c]), n =
|
|
1969
|
+
}, [f, t, c]), n = A(() => {
|
|
1969
1970
|
if (f)
|
|
1970
1971
|
return;
|
|
1971
1972
|
const { state: r, dispatch: k } = t.view, { selection: g } = r, l = g, x = r.tr;
|
|
1972
1973
|
let _ = !1;
|
|
1973
|
-
const V = s.borderColor !==
|
|
1974
|
+
const V = s.borderColor !== d.borderColor || s.borderWidth !== d.borderWidth, b = `${s.borderWidth}px solid ${s.borderColor}`, E = (j, W, I, F, z, q) => {
|
|
1974
1975
|
const ee = z + 1, te = Gt(j, I.row, I.col, F, q, b, s.backgroundColor, s.textAlign, s.verticalAlign, V);
|
|
1975
1976
|
if (x.setNodeMarkup(W, null, te), _ = !0, !V) return;
|
|
1976
1977
|
const ve = j.attrs.colspan || 1, ne = j.attrs.rowspan || 1, ue = "1px solid #d9d9d9", ae = /* @__PURE__ */ new Map();
|
|
@@ -2047,7 +2048,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2047
2048
|
});
|
|
2048
2049
|
}
|
|
2049
2050
|
_ && k && (x.setSelection(l.map(x.doc, x.mapping)), k(x), t.commands.focus()), c(!1);
|
|
2050
|
-
}, [f, t, s,
|
|
2051
|
+
}, [f, t, s, d, c]);
|
|
2051
2052
|
return o ? _e(
|
|
2052
2053
|
/* @__PURE__ */ e("div", { className: "tp-modal-overlay", onMouseDown: (r) => {
|
|
2053
2054
|
r.target === r.currentTarget && M();
|
|
@@ -2155,14 +2156,14 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2155
2156
|
document.body
|
|
2156
2157
|
) : null;
|
|
2157
2158
|
}, Zt = ({ manager: t, visible: o, onVisibleChange: c }) => {
|
|
2158
|
-
const p = De.getInstance(), [i, s] =
|
|
2159
|
+
const p = De.getInstance(), [i, s] = H([]), [h, d] = H(""), [u, f] = H(null), [y, N] = H(!1), S = B(null), m = B(null), T = B(null), w = A((l, x) => p.t(l, x) || l, [p]), M = A((l) => {
|
|
2159
2160
|
try {
|
|
2160
2161
|
const x = new Date(l), V = (/* @__PURE__ */ new Date()).getTime() - x.getTime(), b = Math.floor(V / 6e4), E = Math.floor(V / 36e5), $ = Math.floor(V / 864e5);
|
|
2161
2162
|
return b < 1 ? w("compare.justNow") : b < 60 ? w("compare.minutesAgo", { n: String(b) }) : E < 24 ? w("compare.hoursAgo", { n: String(E) }) : $ < 7 ? w("compare.daysAgo", { n: String($) }) : x.toLocaleDateString() + " " + x.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
2162
2163
|
} catch {
|
|
2163
2164
|
return l;
|
|
2164
2165
|
}
|
|
2165
|
-
}, [w]), n =
|
|
2166
|
+
}, [w]), n = A((l) => {
|
|
2166
2167
|
const x = {
|
|
2167
2168
|
blur: "compare.sourceBlur",
|
|
2168
2169
|
baseline: "compare.sourceBaseline",
|
|
@@ -2173,15 +2174,15 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2173
2174
|
imported: "compare.sourceImported"
|
|
2174
2175
|
};
|
|
2175
2176
|
return x[l] ? w(x[l]) : l;
|
|
2176
|
-
}, [w]), r =
|
|
2177
|
+
}, [w]), r = A((l, x) => `v${i.length - x}.0 - ${M(l.timestamp)} (${n(l.source)})${l.label ? ` - ${l.label}` : ""}`, [M, n, i]);
|
|
2177
2178
|
K(() => {
|
|
2178
2179
|
if (!o) {
|
|
2179
|
-
|
|
2180
|
+
d(""), f(null);
|
|
2180
2181
|
return;
|
|
2181
2182
|
}
|
|
2182
2183
|
let l = !1;
|
|
2183
2184
|
return N(!0), t.listVersions().then((x) => {
|
|
2184
|
-
l || (s(x), !h && x.length > 0 &&
|
|
2185
|
+
l || (s(x), !h && x.length > 0 && d(x[0].id), N(!1));
|
|
2185
2186
|
}).catch(() => {
|
|
2186
2187
|
l || (s([]), N(!1));
|
|
2187
2188
|
}), () => {
|
|
@@ -2211,12 +2212,12 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2211
2212
|
};
|
|
2212
2213
|
return document.addEventListener("keydown", l), () => document.removeEventListener("keydown", l);
|
|
2213
2214
|
}, [o, c]);
|
|
2214
|
-
const k =
|
|
2215
|
+
const k = A(async () => {
|
|
2215
2216
|
const l = await t.createSnapshot(w("compare.createSnapshot"));
|
|
2216
2217
|
l ? je(w("compare.snapshotCreated").replace("{time}", l.label || l.timestamp)) : je({ message: w("compare.snapshotFailed"), type: "error" });
|
|
2217
2218
|
const x = await t.listVersions();
|
|
2218
2219
|
s(x);
|
|
2219
|
-
}, [t, w]), g =
|
|
2220
|
+
}, [t, w]), g = A(() => {
|
|
2220
2221
|
c(!1);
|
|
2221
2222
|
}, [c]);
|
|
2222
2223
|
return o ? /* @__PURE__ */ v("div", { className: "cyte-compare-overlay", children: [
|
|
@@ -2241,7 +2242,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2241
2242
|
"select",
|
|
2242
2243
|
{
|
|
2243
2244
|
value: h,
|
|
2244
|
-
onChange: (l) =>
|
|
2245
|
+
onChange: (l) => d(l.target.value),
|
|
2245
2246
|
className: "cyte-compare-version-selector__select",
|
|
2246
2247
|
children: [
|
|
2247
2248
|
/* @__PURE__ */ e("option", { value: "", disabled: !0, children: w("compare.selectVersion") }),
|
|
@@ -2322,21 +2323,21 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2322
2323
|
] })
|
|
2323
2324
|
] }) : null;
|
|
2324
2325
|
}, Qt = ({ visible: t, defaultFilename: o, onConfirm: c, onCancel: p, onClose: i }) => {
|
|
2325
|
-
const { t: s } = fe(), [h,
|
|
2326
|
-
K(() => (t ? (
|
|
2326
|
+
const { t: s } = fe(), [h, d] = H(""), u = B(null);
|
|
2327
|
+
K(() => (t ? (d(o || "document"), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
2327
2328
|
var m, T;
|
|
2328
2329
|
(m = u.current) == null || m.focus(), (T = u.current) == null || T.select();
|
|
2329
2330
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
2330
2331
|
document.body.style.overflow = "";
|
|
2331
2332
|
}), [t, o]);
|
|
2332
|
-
const f =
|
|
2333
|
+
const f = A(() => {
|
|
2333
2334
|
const m = h.trim() || "document";
|
|
2334
2335
|
c(m), i();
|
|
2335
|
-
}, [h, c, i]), y =
|
|
2336
|
+
}, [h, c, i]), y = A(() => {
|
|
2336
2337
|
p == null || p(), i();
|
|
2337
|
-
}, [p, i]), N =
|
|
2338
|
+
}, [p, i]), N = A((m) => {
|
|
2338
2339
|
m.target === m.currentTarget && y();
|
|
2339
|
-
}, [y]), S =
|
|
2340
|
+
}, [y]), S = A((m) => {
|
|
2340
2341
|
m.key === "Enter" ? (m.preventDefault(), f()) : m.key === "Escape" && (m.preventDefault(), y());
|
|
2341
2342
|
}, [f, y]);
|
|
2342
2343
|
return t ? _e(
|
|
@@ -2355,7 +2356,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2355
2356
|
type: "text",
|
|
2356
2357
|
className: "tp-filename-input",
|
|
2357
2358
|
value: h,
|
|
2358
|
-
onChange: (m) =>
|
|
2359
|
+
onChange: (m) => d(m.target.value),
|
|
2359
2360
|
onKeyDown: S
|
|
2360
2361
|
}
|
|
2361
2362
|
),
|
|
@@ -2367,21 +2368,21 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2367
2368
|
document.body
|
|
2368
2369
|
) : null;
|
|
2369
2370
|
}, en = ({ visible: t, defaultFilename: o, onConfirm: c, onCancel: p, onClose: i }) => {
|
|
2370
|
-
const { t: s } = fe(), [h,
|
|
2371
|
-
K(() => (t ? (
|
|
2371
|
+
const { t: s } = fe(), [h, d] = H(""), u = B(null);
|
|
2372
|
+
K(() => (t ? (d(o || "document"), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
2372
2373
|
var m, T;
|
|
2373
2374
|
(m = u.current) == null || m.focus(), (T = u.current) == null || T.select();
|
|
2374
2375
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
2375
2376
|
document.body.style.overflow = "";
|
|
2376
2377
|
}), [t, o]);
|
|
2377
|
-
const f =
|
|
2378
|
+
const f = A(() => {
|
|
2378
2379
|
const m = h.trim() || "document";
|
|
2379
2380
|
c(m), i();
|
|
2380
|
-
}, [h, c, i]), y =
|
|
2381
|
+
}, [h, c, i]), y = A(() => {
|
|
2381
2382
|
p == null || p(), i();
|
|
2382
|
-
}, [p, i]), N =
|
|
2383
|
+
}, [p, i]), N = A((m) => {
|
|
2383
2384
|
m.target === m.currentTarget && y();
|
|
2384
|
-
}, [y]), S =
|
|
2385
|
+
}, [y]), S = A((m) => {
|
|
2385
2386
|
m.key === "Enter" ? (m.preventDefault(), f()) : m.key === "Escape" && (m.preventDefault(), y());
|
|
2386
2387
|
}, [f, y]);
|
|
2387
2388
|
return t ? _e(
|
|
@@ -2400,7 +2401,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2400
2401
|
type: "text",
|
|
2401
2402
|
className: "tp-filename-input",
|
|
2402
2403
|
value: h,
|
|
2403
|
-
onChange: (m) =>
|
|
2404
|
+
onChange: (m) => d(m.target.value),
|
|
2404
2405
|
onKeyDown: S
|
|
2405
2406
|
}
|
|
2406
2407
|
),
|
|
@@ -2418,7 +2419,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2418
2419
|
config: i,
|
|
2419
2420
|
height: s = "300px",
|
|
2420
2421
|
minHeight: h,
|
|
2421
|
-
maxHeight:
|
|
2422
|
+
maxHeight: d,
|
|
2422
2423
|
autoHeight: u = !1,
|
|
2423
2424
|
placeholder: f,
|
|
2424
2425
|
toolbar: y,
|
|
@@ -2436,10 +2437,10 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2436
2437
|
onToolbarClick: x,
|
|
2437
2438
|
onFullscreenChange: _,
|
|
2438
2439
|
toolbarRender: V
|
|
2439
|
-
} = t, [b, E] =
|
|
2440
|
+
} = t, [b, E] = H("normal"), $ = B(""), P = B(null), [G, O] = H(!1), [j, W] = H({ x: 0, y: 0 }), [I, F] = H(null), [z, q] = H(!1), [ee, te] = H(!1), [ve, ne] = H(!1), [ue, ae] = H(!1), [Y, oe] = H("document"), [J, X] = H(!1), [ge, Be] = H("document"), [ye, Ce] = H(!1), Se = De.getInstance(), Ne = A((C) => Se.t(C) || C, [Se]), Ie = Te(() => {
|
|
2440
2441
|
const D = { ...i || {} };
|
|
2441
|
-
return s !== void 0 && (D.height = s), h !== void 0 && (D.minHeight = h),
|
|
2442
|
-
}, [i, s, h,
|
|
2442
|
+
return s !== void 0 && (D.height = s), h !== void 0 && (D.minHeight = h), d !== void 0 && (D.maxHeight = d), u !== void 0 && (D.autoHeight = u), f !== void 0 && (D.placeholder = f), y !== void 0 && (D.toolbar = y), N !== void 0 && (D.readonly = N), S !== void 0 && (D.disabled = S), m !== void 0 && (D.autofocus = m), T !== void 0 && (D.locale = T), w !== void 0 && (D.paste = { ...D.paste, mode: w }), M !== void 0 && (D.upload = { ...D.upload, url: M }), D;
|
|
2443
|
+
}, [i, s, h, d, u, f, y, N, S, m, T, w, M]), Ke = Te(() => Ie.toolbar || [
|
|
2443
2444
|
// A: 历史操作
|
|
2444
2445
|
"undo",
|
|
2445
2446
|
"redo",
|
|
@@ -2489,8 +2490,9 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2489
2490
|
// H: 视图/版本 (meta-view)
|
|
2490
2491
|
"fullscreen",
|
|
2491
2492
|
"snapshot",
|
|
2492
|
-
"compare"
|
|
2493
|
-
|
|
2493
|
+
"compare",
|
|
2494
|
+
"autoFormat"
|
|
2495
|
+
], [Ie.toolbar]), { manager: a, isReady: Q, isFocused: L, isEmpty: R, containerRef: Z, setContentFromProp: ce } = wt({
|
|
2494
2496
|
config: Ie,
|
|
2495
2497
|
onUpdate(C, D) {
|
|
2496
2498
|
n == null || n({ html: C, json: D });
|
|
@@ -2504,13 +2506,13 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2504
2506
|
onReady(C) {
|
|
2505
2507
|
c ? C.setContent(c) : p && C.setJSON(p), Oe(C), g == null || g(C);
|
|
2506
2508
|
}
|
|
2507
|
-
}), { activeStates: de, disabledStates: Pe } = vt(
|
|
2509
|
+
}), { activeStates: de, disabledStates: Pe } = vt(a);
|
|
2508
2510
|
K(() => {
|
|
2509
2511
|
c !== void 0 && ce(c);
|
|
2510
2512
|
}, [c, ce]), K(() => {
|
|
2511
2513
|
p !== void 0 && ce(void 0, p);
|
|
2512
2514
|
}, [p, ce]);
|
|
2513
|
-
const
|
|
2515
|
+
const Ae = A((C) => {
|
|
2514
2516
|
let D = "", U = 0;
|
|
2515
2517
|
const se = " ", he = C.replace(/>\s+</g, "><").trim().split(/(<\/?[^>]+>)/g).filter((pe) => pe.trim() !== "");
|
|
2516
2518
|
for (let pe = 0; pe < he.length; pe++) {
|
|
@@ -2536,19 +2538,19 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2536
2538
|
}
|
|
2537
2539
|
}
|
|
2538
2540
|
return D.trim();
|
|
2539
|
-
}, []),
|
|
2540
|
-
if (!
|
|
2541
|
-
const D =
|
|
2541
|
+
}, []), He = A((C) => {
|
|
2542
|
+
if (!a) return;
|
|
2543
|
+
const D = a.getEditor();
|
|
2542
2544
|
if (b === C) {
|
|
2543
2545
|
le();
|
|
2544
2546
|
return;
|
|
2545
2547
|
}
|
|
2546
|
-
b !== "normal" ? le() : ($.current =
|
|
2547
|
-
const U = C === "html" ?
|
|
2548
|
+
b !== "normal" ? le() : ($.current = a.getHTML(), P.current = a.getJSON());
|
|
2549
|
+
const U = C === "html" ? a.getHTML() : JSON.stringify(a.getJSON(), null, 2), se = C === "html" ? Ae(U) : U;
|
|
2548
2550
|
D.commands.clearContent(), D.commands.insertContent({ type: "codeBlock", attrs: { language: C === "html" ? "html" : "json" }, content: [{ type: "text", text: se }] }), E(C), l == null || l(C);
|
|
2549
|
-
}, [
|
|
2550
|
-
if (!
|
|
2551
|
-
const C =
|
|
2551
|
+
}, [a, b, Ae, l]), le = A(() => {
|
|
2552
|
+
if (!a) return;
|
|
2553
|
+
const C = a.getEditor();
|
|
2552
2554
|
if (b !== "normal") {
|
|
2553
2555
|
const D = C.getText(), U = b;
|
|
2554
2556
|
if (D)
|
|
@@ -2569,7 +2571,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2569
2571
|
} else
|
|
2570
2572
|
P.current ? C.commands.setContent(P.current) : $.current && C.commands.setContent($.current);
|
|
2571
2573
|
E("normal"), l == null || l("normal");
|
|
2572
|
-
}, [
|
|
2574
|
+
}, [a, b, l]), Oe = A((C) => {
|
|
2573
2575
|
const D = C.getEditor();
|
|
2574
2576
|
D.view.dom.addEventListener("contextmenu", (U) => {
|
|
2575
2577
|
const re = U.target.closest("td, th");
|
|
@@ -2597,19 +2599,19 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2597
2599
|
} else
|
|
2598
2600
|
O(!1), F(null), tt();
|
|
2599
2601
|
});
|
|
2600
|
-
}, [G]), ze =
|
|
2602
|
+
}, [G]), ze = A((C) => {
|
|
2601
2603
|
if (x == null || x(C), C === "snapshot") {
|
|
2602
|
-
|
|
2604
|
+
a == null || a.createSnapshot().then((D) => {
|
|
2603
2605
|
D ? je(Se.t("compare.snapshotCreated", { time: D.label || D.timestamp })) : je({ message: Se.t("compare.snapshotFailed"), type: "error" });
|
|
2604
2606
|
});
|
|
2605
2607
|
return;
|
|
2606
2608
|
}
|
|
2607
|
-
if (C === "compare" && ne(!0), C === "fullscreen" && be(), C === "importWord") {
|
|
2609
|
+
if (C === "compare" && ne(!0), C === "fullscreen" && be(), C === "autoFormat" && (a == null || a.toggleAutoFormatPanel()), C === "importWord") {
|
|
2608
2610
|
const D = document.createElement("input");
|
|
2609
2611
|
D.type = "file", D.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", D.onchange = async (U) => {
|
|
2610
2612
|
var re;
|
|
2611
2613
|
const se = (re = U.target.files) == null ? void 0 : re[0];
|
|
2612
|
-
se && await (
|
|
2614
|
+
se && await (a == null ? void 0 : a.importWordFile(se));
|
|
2613
2615
|
}, D.click();
|
|
2614
2616
|
}
|
|
2615
2617
|
if (C === "importMarkdown") {
|
|
@@ -2617,25 +2619,25 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2617
2619
|
D.type = "file", D.accept = ".md,.markdown,text/markdown", D.onchange = async (U) => {
|
|
2618
2620
|
var re;
|
|
2619
2621
|
const se = (re = U.target.files) == null ? void 0 : re[0];
|
|
2620
|
-
se && await (
|
|
2622
|
+
se && await (a == null ? void 0 : a.importMarkdownFile(se));
|
|
2621
2623
|
}, D.click();
|
|
2622
2624
|
}
|
|
2623
|
-
C === "exportWord" && (oe((
|
|
2624
|
-
}, [x,
|
|
2625
|
-
if (!
|
|
2626
|
-
const D =
|
|
2625
|
+
C === "exportWord" && (oe((a == null ? void 0 : a.getDocumentTitle()) || "document"), ae(!0)), C === "exportMarkdown" && (Be((a == null ? void 0 : a.getDocumentTitle()) || "document"), X(!0));
|
|
2626
|
+
}, [x, a]), Ee = A((C) => {
|
|
2627
|
+
if (!a) return;
|
|
2628
|
+
const D = a.getEditor();
|
|
2627
2629
|
switch ("$anchorCell" in D.state.selection || (et(D), tt()), C) {
|
|
2628
2630
|
case "addRowBefore":
|
|
2629
|
-
|
|
2631
|
+
a.addTableRowBefore();
|
|
2630
2632
|
break;
|
|
2631
2633
|
case "addRowAfter":
|
|
2632
|
-
|
|
2634
|
+
a.addTableRowAfter();
|
|
2633
2635
|
break;
|
|
2634
2636
|
case "addColumnBefore":
|
|
2635
|
-
|
|
2637
|
+
a.addTableColumnBefore();
|
|
2636
2638
|
break;
|
|
2637
2639
|
case "addColumnAfter":
|
|
2638
|
-
|
|
2640
|
+
a.addTableColumnAfter();
|
|
2639
2641
|
break;
|
|
2640
2642
|
case "mergeCells":
|
|
2641
2643
|
D.chain().mergeCells().run(), setTimeout(() => {
|
|
@@ -2699,13 +2701,13 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2699
2701
|
break;
|
|
2700
2702
|
}
|
|
2701
2703
|
case "deleteRow":
|
|
2702
|
-
|
|
2704
|
+
a.deleteTableRow();
|
|
2703
2705
|
break;
|
|
2704
2706
|
case "deleteColumn":
|
|
2705
|
-
|
|
2707
|
+
a.deleteTableColumn();
|
|
2706
2708
|
break;
|
|
2707
2709
|
case "deleteTable":
|
|
2708
|
-
|
|
2710
|
+
a.deleteTable();
|
|
2709
2711
|
break;
|
|
2710
2712
|
case "tableSettings":
|
|
2711
2713
|
q(!0);
|
|
@@ -2714,57 +2716,57 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2714
2716
|
te(!0);
|
|
2715
2717
|
break;
|
|
2716
2718
|
}
|
|
2717
|
-
}, [
|
|
2719
|
+
}, [a, I]), be = A(() => {
|
|
2718
2720
|
Ce((C) => {
|
|
2719
2721
|
const D = !C;
|
|
2720
2722
|
return _ == null || _(D), D;
|
|
2721
2723
|
});
|
|
2722
|
-
}, [_]), Re =
|
|
2724
|
+
}, [_]), Re = A((C) => {
|
|
2723
2725
|
C.key === "Escape" && ye && (Ce(!1), _ == null || _(!1));
|
|
2724
2726
|
}, [ye, _]), Me = Te(() => {
|
|
2725
2727
|
const C = {};
|
|
2726
|
-
return u ? (h && (C.minHeight = typeof h == "number" ? `${h}px` : h),
|
|
2727
|
-
}, [u, s, h,
|
|
2728
|
+
return u ? (h && (C.minHeight = typeof h == "number" ? `${h}px` : h), d && (C.maxHeight = typeof d == "number" ? `${d}px` : d)) : (s && (C.height = typeof s == "number" ? `${s}px` : s), h && (C.minHeight = typeof h == "number" ? `${h}px` : h)), C;
|
|
2729
|
+
}, [u, s, h, d]);
|
|
2728
2730
|
return st(o, () => ({
|
|
2729
|
-
getEditorManager: () =>
|
|
2730
|
-
getHTML: () => (
|
|
2731
|
-
getJSON: () => (
|
|
2732
|
-
getText: () => (
|
|
2733
|
-
setContent: (C) =>
|
|
2734
|
-
setJSON: (C) =>
|
|
2735
|
-
insertHTML: (C) =>
|
|
2736
|
-
insertText: (C) =>
|
|
2737
|
-
focus: () =>
|
|
2738
|
-
blur: () =>
|
|
2739
|
-
isEmpty: () => (
|
|
2740
|
-
clear: () =>
|
|
2741
|
-
undo: () =>
|
|
2742
|
-
redo: () =>
|
|
2743
|
-
setReadonly: (C) =>
|
|
2744
|
-
insertTable: (C, D, U) =>
|
|
2745
|
-
insertImage: (C, D, U) =>
|
|
2746
|
-
insertVideo: (C, D, U) =>
|
|
2747
|
-
exportMarkdown: () => (
|
|
2748
|
-
exportHTMLDocument: (C) => (
|
|
2731
|
+
getEditorManager: () => a,
|
|
2732
|
+
getHTML: () => (a == null ? void 0 : a.getHTML()) ?? "",
|
|
2733
|
+
getJSON: () => (a == null ? void 0 : a.getJSON()) ?? { type: "doc", content: [] },
|
|
2734
|
+
getText: () => (a == null ? void 0 : a.getText()) ?? "",
|
|
2735
|
+
setContent: (C) => a == null ? void 0 : a.setContent(C),
|
|
2736
|
+
setJSON: (C) => a == null ? void 0 : a.setJSON(C),
|
|
2737
|
+
insertHTML: (C) => a == null ? void 0 : a.insertHTML(C),
|
|
2738
|
+
insertText: (C) => a == null ? void 0 : a.insertText(C),
|
|
2739
|
+
focus: () => a == null ? void 0 : a.focus(),
|
|
2740
|
+
blur: () => a == null ? void 0 : a.blur(),
|
|
2741
|
+
isEmpty: () => (a == null ? void 0 : a.isEmpty()) ?? !0,
|
|
2742
|
+
clear: () => a == null ? void 0 : a.clear(),
|
|
2743
|
+
undo: () => a == null ? void 0 : a.undo(),
|
|
2744
|
+
redo: () => a == null ? void 0 : a.redo(),
|
|
2745
|
+
setReadonly: (C) => a == null ? void 0 : a.setReadonly(C),
|
|
2746
|
+
insertTable: (C, D, U) => a == null ? void 0 : a.insertTable(C, D, U),
|
|
2747
|
+
insertImage: (C, D, U) => a == null ? void 0 : a.insertImage(C, D, U),
|
|
2748
|
+
insertVideo: (C, D, U) => a == null ? void 0 : a.insertVideo(C, D, U),
|
|
2749
|
+
exportMarkdown: () => (a == null ? void 0 : a.exportMarkdown()) ?? "",
|
|
2750
|
+
exportHTMLDocument: (C) => (a == null ? void 0 : a.exportHTMLDocument(C)) ?? "",
|
|
2749
2751
|
exportWordFile: async (C) => {
|
|
2750
|
-
await (
|
|
2752
|
+
await (a == null ? void 0 : a.exportWordFile(C));
|
|
2751
2753
|
},
|
|
2752
|
-
exportMarkdownFile: (C) => (
|
|
2753
|
-
importMarkdown: (C) =>
|
|
2754
|
-
importHTMLFile: (C) => (
|
|
2755
|
-
importMarkdownFile: (C) => (
|
|
2756
|
-
importWordFile: (C) => (
|
|
2757
|
-
parseHTML: (C) =>
|
|
2758
|
-
addSnapshot: (C, D) => (
|
|
2759
|
-
toggleViewMode:
|
|
2754
|
+
exportMarkdownFile: (C) => (a == null ? void 0 : a.exportMarkdownFile(C)) ?? Promise.resolve(),
|
|
2755
|
+
importMarkdown: (C) => a == null ? void 0 : a.importMarkdown(C),
|
|
2756
|
+
importHTMLFile: (C) => (a == null ? void 0 : a.importHTMLFile(C)) ?? Promise.resolve(),
|
|
2757
|
+
importMarkdownFile: (C) => (a == null ? void 0 : a.importMarkdownFile(C)) ?? Promise.resolve(),
|
|
2758
|
+
importWordFile: (C) => (a == null ? void 0 : a.importWordFile(C)) ?? Promise.resolve({ messages: [] }),
|
|
2759
|
+
parseHTML: (C) => a == null ? void 0 : a.parseHTML(C),
|
|
2760
|
+
addSnapshot: (C, D) => (a == null ? void 0 : a.addSnapshot(C, D)) ?? Promise.resolve(null),
|
|
2761
|
+
toggleViewMode: He,
|
|
2760
2762
|
restoreOriginalContent: le,
|
|
2761
2763
|
getViewMode: () => b,
|
|
2762
2764
|
toggleFullscreen: be,
|
|
2763
2765
|
isFullscreen: () => ye
|
|
2764
|
-
}), [
|
|
2766
|
+
}), [a, He, le, b, be, ye]), /* @__PURE__ */ v(
|
|
2765
2767
|
"div",
|
|
2766
2768
|
{
|
|
2767
|
-
className: `cyte-editor${S ? " is-disabled" : ""}${N ? " is-readonly" : ""}${L ? " is-focused" : ""}${R ? " is-empty" : ""}${u ? " is-auto-height" : ""}${u &&
|
|
2769
|
+
className: `cyte-editor${S ? " is-disabled" : ""}${N ? " is-readonly" : ""}${L ? " is-focused" : ""}${R ? " is-empty" : ""}${u ? " is-auto-height" : ""}${u && d ? " is-auto-height-limited" : ""}${ye ? " is-fullscreen" : ""}`,
|
|
2768
2770
|
style: Me,
|
|
2769
2771
|
onKeyDown: Re,
|
|
2770
2772
|
children: [
|
|
@@ -2783,23 +2785,23 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2783
2785
|
Ne("toolbar.exitFullscreen")
|
|
2784
2786
|
] })
|
|
2785
2787
|
] }),
|
|
2786
|
-
V ? V({ manager:
|
|
2788
|
+
V ? V({ manager: a, activeStates: de, disabledStates: Pe, isReady: Q }) : Q && a && /* @__PURE__ */ e(
|
|
2787
2789
|
Ft,
|
|
2788
2790
|
{
|
|
2789
2791
|
items: Ke,
|
|
2790
|
-
manager:
|
|
2792
|
+
manager: a,
|
|
2791
2793
|
activeStates: de,
|
|
2792
2794
|
disabledStates: Pe,
|
|
2793
2795
|
viewMode: b,
|
|
2794
|
-
onToggleViewMode:
|
|
2796
|
+
onToggleViewMode: He,
|
|
2795
2797
|
onToolbarClick: ze
|
|
2796
2798
|
}
|
|
2797
2799
|
),
|
|
2798
2800
|
/* @__PURE__ */ e("div", { ref: Z, className: "tp-editor-content" }),
|
|
2799
|
-
Q &&
|
|
2801
|
+
Q && a && /* @__PURE__ */ e(
|
|
2800
2802
|
Ot,
|
|
2801
2803
|
{
|
|
2802
|
-
editor:
|
|
2804
|
+
editor: a.getEditor(),
|
|
2803
2805
|
visible: G,
|
|
2804
2806
|
position: j,
|
|
2805
2807
|
targetCell: I,
|
|
@@ -2807,26 +2809,26 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2807
2809
|
onAction: Ee
|
|
2808
2810
|
}
|
|
2809
2811
|
),
|
|
2810
|
-
Q &&
|
|
2812
|
+
Q && a && /* @__PURE__ */ e(
|
|
2811
2813
|
Vt,
|
|
2812
2814
|
{
|
|
2813
|
-
editor:
|
|
2815
|
+
editor: a.getEditor(),
|
|
2814
2816
|
visible: z,
|
|
2815
2817
|
onVisibleChange: q
|
|
2816
2818
|
}
|
|
2817
2819
|
),
|
|
2818
|
-
Q &&
|
|
2820
|
+
Q && a && /* @__PURE__ */ e(
|
|
2819
2821
|
Xt,
|
|
2820
2822
|
{
|
|
2821
|
-
editor:
|
|
2823
|
+
editor: a.getEditor(),
|
|
2822
2824
|
visible: ee,
|
|
2823
2825
|
onVisibleChange: te
|
|
2824
2826
|
}
|
|
2825
2827
|
),
|
|
2826
|
-
Q &&
|
|
2828
|
+
Q && a && /* @__PURE__ */ e(
|
|
2827
2829
|
Zt,
|
|
2828
2830
|
{
|
|
2829
|
-
manager:
|
|
2831
|
+
manager: a,
|
|
2830
2832
|
visible: ve,
|
|
2831
2833
|
onVisibleChange: ne
|
|
2832
2834
|
}
|
|
@@ -2836,7 +2838,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2836
2838
|
{
|
|
2837
2839
|
visible: ue,
|
|
2838
2840
|
defaultFilename: Y,
|
|
2839
|
-
onConfirm: (C) =>
|
|
2841
|
+
onConfirm: (C) => a == null ? void 0 : a.exportWordFile(C),
|
|
2840
2842
|
onClose: () => ae(!1)
|
|
2841
2843
|
}
|
|
2842
2844
|
),
|
|
@@ -2845,7 +2847,7 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2845
2847
|
{
|
|
2846
2848
|
visible: J,
|
|
2847
2849
|
defaultFilename: ge,
|
|
2848
|
-
onConfirm: (C) =>
|
|
2850
|
+
onConfirm: (C) => a == null ? void 0 : a.exportMarkdownFile(C),
|
|
2849
2851
|
onClose: () => X(!1)
|
|
2850
2852
|
}
|
|
2851
2853
|
)
|