@cyte-editor/react 1.3.0 → 1.4.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 +8 -8
- package/dist/cyte-editor-react.js +1574 -1523
- package/dist/style.css +1 -1
- package/package.json +6 -6
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { TextSelection as
|
|
4
|
-
import { TableMap as
|
|
5
|
-
import { EditorManager as
|
|
6
|
-
import { getLicenseStatus as
|
|
1
|
+
import { jsx as e, jsxs as w, Fragment as nt } from "react/jsx-runtime";
|
|
2
|
+
import tt, { useRef as B, useState as A, useCallback as S, useEffect as z, useMemo as Me, useLayoutEffect as pt, forwardRef as ht, useImperativeHandle as at } from "react";
|
|
3
|
+
import { TextSelection as ft } from "@tiptap/pm/state";
|
|
4
|
+
import { TableMap as dt } from "@tiptap/pm/tables";
|
|
5
|
+
import { EditorManager as mt, I18nManager as Le, toolbarItemDefs as Xe, uploadFile as gt, installToolbarPanelPlacement as wt, groupToolbarItems as vt, getToolbarItemDef as yt, adjustMenuPosition as bt, getVisualBand as xt, ScrollSyncManager as kt, showToast as qe, installTableTouchHandle as Ct, getHoverLineVisible as Ke, installContextMenuTouchTracking as Nt, isTouchOriginatedContextMenu as Mt, moveCursorToCell as je, syncTableSelectionForCell as rt, clearSavedTableSelection as lt, restoreTableSelection as Lt, getCurrentTableCell as Ve, beginTableRangeSelection as Tt, selectTableAll as Dt, selectTableColumn as St, selectTableRow as Ht } from "@cyte-editor/core";
|
|
6
|
+
import { getLicenseStatus as At } 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.4.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: 1851043-dirty @ 2026-12-05T08:07:11.684Z
|
|
17
17
|
* Homepage: https://cyteeditor.com
|
|
18
18
|
* Contact: legal@cyteeditor.com (legal) / support@cyteeditor.com (support)
|
|
19
19
|
*
|
|
20
20
|
* UNAUTHORIZED COPYING, MODIFICATION, REDISTRIBUTION,
|
|
21
21
|
* REVERSE-ENGINEERING OR REMOVAL OF THIS NOTICE IS STRICTLY PROHIBITED.
|
|
22
22
|
*/
|
|
23
|
-
function
|
|
24
|
-
var
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
if (!(f.current || !
|
|
23
|
+
function Et(t) {
|
|
24
|
+
var p, T;
|
|
25
|
+
const r = B(null), a = B(null), [h, c] = A(!1), [s, m] = A(!1), [d, u] = A(!0), f = B(!1), v = B(t);
|
|
26
|
+
v.current = t;
|
|
27
|
+
const L = S((b, M) => {
|
|
28
|
+
if (!(f.current || !a.current)) {
|
|
29
29
|
if (M !== void 0) {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
30
|
+
const g = JSON.stringify(a.current.getJSON()), o = JSON.stringify(M);
|
|
31
|
+
if (g === o) return;
|
|
32
|
+
a.current.setJSON(M);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
36
|
-
if (
|
|
37
|
-
|
|
35
|
+
if (b !== void 0) {
|
|
36
|
+
if (b === a.current.getHTML()) return;
|
|
37
|
+
a.current.setContent(b);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}, []);
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
45
|
-
const M =
|
|
46
|
-
return
|
|
47
|
-
var
|
|
48
|
-
u(M.isEmpty()), f.current = !0, (l = (
|
|
41
|
+
z(() => {
|
|
42
|
+
var g, o;
|
|
43
|
+
const b = r.current;
|
|
44
|
+
if (!b) return;
|
|
45
|
+
const M = mt.create(b, v.current.config);
|
|
46
|
+
return a.current = M, u(M.isEmpty()), M.on("update", ({ html: x }) => {
|
|
47
|
+
var i, l;
|
|
48
|
+
u(M.isEmpty()), f.current = !0, (l = (i = v.current).onUpdate) == null || l.call(i, x, M.getJSON()), Promise.resolve().then(() => {
|
|
49
49
|
f.current = !1;
|
|
50
50
|
});
|
|
51
|
-
}), M.on("focus", ({ event:
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
}), M.on("blur", ({ event:
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
M.destroy(),
|
|
51
|
+
}), M.on("focus", ({ event: x }) => {
|
|
52
|
+
var i, l;
|
|
53
|
+
m(!0), (l = (i = v.current).onFocus) == null || l.call(i, x);
|
|
54
|
+
}), M.on("blur", ({ event: x }) => {
|
|
55
|
+
var i, l;
|
|
56
|
+
m(!1), (l = (i = v.current).onBlur) == null || l.call(i, x);
|
|
57
|
+
}), c(!0), (o = (g = v.current).onReady) == null || o.call(g, M), () => {
|
|
58
|
+
M.destroy(), a.current = null, c(!1);
|
|
59
59
|
};
|
|
60
|
-
}, []),
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
}, [t.config.readonly, t.config.disabled]),
|
|
64
|
-
t.config.locale &&
|
|
60
|
+
}, []), z(() => {
|
|
61
|
+
const b = a.current;
|
|
62
|
+
b && t.config.readonly !== void 0 && b.setReadonly(t.config.readonly);
|
|
63
|
+
}, [t.config.readonly, t.config.disabled]), z(() => {
|
|
64
|
+
t.config.locale && Le.getInstance().setLocale(t.config.locale);
|
|
65
65
|
}, [t.config.locale]);
|
|
66
|
-
const
|
|
67
|
-
return
|
|
66
|
+
const H = B((p = t.config.license) == null ? void 0 : p.key);
|
|
67
|
+
return z(() => {
|
|
68
68
|
var M;
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const b = (M = t.config.license) == null ? void 0 : M.key;
|
|
70
|
+
b !== H.current && (H.current = b, b && a.current && a.current.updateLicense(t.config.license));
|
|
71
71
|
}, [(T = t.config.license) == null ? void 0 : T.key]), {
|
|
72
|
-
manager:
|
|
73
|
-
isReady:
|
|
72
|
+
manager: a.current,
|
|
73
|
+
isReady: h,
|
|
74
74
|
isFocused: s,
|
|
75
75
|
isEmpty: d,
|
|
76
|
-
containerRef:
|
|
77
|
-
setContentFromProp:
|
|
76
|
+
containerRef: r,
|
|
77
|
+
setContentFromProp: L
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
const [
|
|
80
|
+
function Rt(t) {
|
|
81
|
+
const [r, a] = A({}), [h, c] = A({}), s = S(async () => {
|
|
82
82
|
if (!t) return;
|
|
83
|
-
const
|
|
84
|
-
for (const [
|
|
85
|
-
|
|
86
|
-
const f =
|
|
87
|
-
if (u.compare = !
|
|
88
|
-
for (const [
|
|
89
|
-
|
|
90
|
-
for (const [
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
const m = t.getEditor(), d = {}, u = {};
|
|
84
|
+
for (const [H, p] of Object.entries(Xe))
|
|
85
|
+
p.isActive && (d[H] = p.isActive(m)), p.isDisabled && (u[H] = p.isDisabled(m));
|
|
86
|
+
const f = At(), v = f === "valid" || f === "expiring_soon", L = await t.hasSnapshots();
|
|
87
|
+
if (u.compare = !L || !v, !v)
|
|
88
|
+
for (const [H, p] of Object.entries(Xe))
|
|
89
|
+
p.requiredTier && H !== "compare" && (u[H] = !0);
|
|
90
|
+
for (const [H, p] of Object.entries(Xe))
|
|
91
|
+
p.requiresPlugin && !t.hasProPlugin(p.requiresPlugin) && (u[H] = !0);
|
|
92
|
+
a(d), c(u);
|
|
93
93
|
}, [t]);
|
|
94
|
-
return
|
|
94
|
+
return z(() => {
|
|
95
95
|
if (t)
|
|
96
96
|
return t.on("selectionUpdate", s), t.on("update", s), t.on("transaction", s), t.on("snapshot-created", s), s(), () => {
|
|
97
97
|
t.off("selectionUpdate", s), t.off("update", s), t.off("transaction", s), t.off("snapshot-created", s);
|
|
98
98
|
};
|
|
99
99
|
}, [t, s]), {
|
|
100
|
-
activeStates:
|
|
101
|
-
disabledStates:
|
|
100
|
+
activeStates: r,
|
|
101
|
+
disabledStates: h,
|
|
102
102
|
refresh: s
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
function fe() {
|
|
106
|
-
const t =
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const t = Le.getInstance(), [r, a] = A(0);
|
|
107
|
+
z(() => t.onChange(() => {
|
|
108
|
+
a((s) => s + 1);
|
|
109
109
|
}), [t]);
|
|
110
|
-
function
|
|
111
|
-
return t.t(
|
|
110
|
+
function h(c, s) {
|
|
111
|
+
return t.t(c, s);
|
|
112
112
|
}
|
|
113
113
|
return {
|
|
114
|
-
t:
|
|
114
|
+
t: h,
|
|
115
115
|
locale: t.getLocale()
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
const
|
|
118
|
+
const $t = {
|
|
119
119
|
undo: '<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="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',
|
|
120
120
|
redo: '<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="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/></svg>',
|
|
121
121
|
bold: '<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="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/></svg>',
|
|
@@ -159,122 +159,122 @@ const yt = {
|
|
|
159
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
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>'
|
|
161
161
|
};
|
|
162
|
-
function
|
|
163
|
-
return
|
|
162
|
+
function be(t) {
|
|
163
|
+
return $t[t] || "";
|
|
164
164
|
}
|
|
165
|
-
const
|
|
165
|
+
const _t = ({
|
|
166
166
|
visible: t,
|
|
167
|
-
targetRect:
|
|
168
|
-
editor:
|
|
169
|
-
savedSelection:
|
|
170
|
-
initialUrl:
|
|
167
|
+
targetRect: r,
|
|
168
|
+
editor: a,
|
|
169
|
+
savedSelection: h,
|
|
170
|
+
initialUrl: c,
|
|
171
171
|
isEditing: s,
|
|
172
|
-
onConfirm:
|
|
172
|
+
onConfirm: m,
|
|
173
173
|
onCancel: d,
|
|
174
174
|
onClose: u
|
|
175
175
|
}) => {
|
|
176
|
-
const { t: f } = fe(), [
|
|
177
|
-
if (
|
|
176
|
+
const { t: f } = fe(), [v, L] = A(c || ""), [H, p] = A(!1), T = B(null), [b, M] = A(null), [g, o] = A(""), x = () => {
|
|
177
|
+
if (a && h)
|
|
178
178
|
try {
|
|
179
|
-
const { from:
|
|
180
|
-
if (
|
|
181
|
-
M(new DOMRect(
|
|
179
|
+
const { from: k, to: D } = h, E = a.view.coordsAtPos(k), P = a.view.coordsAtPos(D);
|
|
180
|
+
if (E && P) {
|
|
181
|
+
M(new DOMRect(E.left, E.top, P.left - E.left, E.bottom - E.top));
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
184
|
} catch {
|
|
185
185
|
}
|
|
186
|
-
M(
|
|
186
|
+
M(r || null);
|
|
187
187
|
};
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
t &&
|
|
188
|
+
z(() => {
|
|
189
|
+
const k = () => {
|
|
190
|
+
t && x();
|
|
191
191
|
};
|
|
192
|
-
return window.addEventListener("scroll",
|
|
193
|
-
window.removeEventListener("scroll",
|
|
192
|
+
return window.addEventListener("scroll", k, !0), window.addEventListener("resize", k), () => {
|
|
193
|
+
window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k);
|
|
194
194
|
};
|
|
195
|
-
}, [t,
|
|
196
|
-
t && (
|
|
197
|
-
var
|
|
198
|
-
(
|
|
195
|
+
}, [t, a, h, r]), z(() => {
|
|
196
|
+
t && (L(c || ""), o(""), x(), setTimeout(() => {
|
|
197
|
+
var k, D;
|
|
198
|
+
(k = T.current) == null || k.focus(), (D = T.current) == null || D.select();
|
|
199
199
|
}, 0));
|
|
200
200
|
}, [t]);
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
204
|
-
const
|
|
205
|
-
let O =
|
|
206
|
-
O +
|
|
207
|
-
let
|
|
208
|
-
const
|
|
209
|
-
return
|
|
210
|
-
}, [
|
|
201
|
+
const i = Me(() => {
|
|
202
|
+
const k = b;
|
|
203
|
+
if (!k) return {};
|
|
204
|
+
const D = 180, E = 8, P = window.innerHeight, V = window.innerWidth;
|
|
205
|
+
let O = k.bottom + E, K = !1;
|
|
206
|
+
O + D > P && (O = k.top - D - E, K = !0), p(K);
|
|
207
|
+
let j = k.left + k.width / 2;
|
|
208
|
+
const _ = 320;
|
|
209
|
+
return j + _ / 2 > V && (j = V - _ / 2 - 16), j < _ / 2 + 16 && (j = _ / 2 + 16), { top: `${O}px`, left: `${j}px` };
|
|
210
|
+
}, [b]), l = (k) => {
|
|
211
211
|
try {
|
|
212
|
-
const
|
|
213
|
-
return
|
|
212
|
+
const D = new URL(k);
|
|
213
|
+
return D.protocol === "http:" || D.protocol === "https:";
|
|
214
214
|
} catch {
|
|
215
215
|
return !1;
|
|
216
216
|
}
|
|
217
|
-
},
|
|
218
|
-
const
|
|
219
|
-
if (s &&
|
|
220
|
-
|
|
217
|
+
}, y = () => {
|
|
218
|
+
const k = v.trim();
|
|
219
|
+
if (s && k === "") {
|
|
220
|
+
m(""), u();
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
if (!
|
|
224
|
-
|
|
223
|
+
if (!k) {
|
|
224
|
+
o(f("link.urlRequired"));
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
|
-
if (!l(
|
|
228
|
-
|
|
227
|
+
if (!l(k)) {
|
|
228
|
+
o(f("link.invalidUrl"));
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
},
|
|
231
|
+
m(k), u();
|
|
232
|
+
}, $ = () => {
|
|
233
|
+
m(""), u();
|
|
234
|
+
}, W = () => {
|
|
235
235
|
d(), u();
|
|
236
236
|
};
|
|
237
237
|
return t ? /* @__PURE__ */ e(
|
|
238
238
|
"div",
|
|
239
239
|
{
|
|
240
240
|
style: { position: "fixed", top: 0, left: 0, right: 0, bottom: 0, zIndex: 9998, background: "transparent" },
|
|
241
|
-
onMouseDown: (
|
|
242
|
-
|
|
241
|
+
onMouseDown: (k) => {
|
|
242
|
+
k.target === k.currentTarget && W();
|
|
243
243
|
},
|
|
244
|
-
children: /* @__PURE__ */
|
|
244
|
+
children: /* @__PURE__ */ w(
|
|
245
245
|
"div",
|
|
246
246
|
{
|
|
247
|
-
className: `tp-link-popover${
|
|
248
|
-
style:
|
|
249
|
-
onMouseDown: (
|
|
250
|
-
onKeyDown: (
|
|
251
|
-
|
|
247
|
+
className: `tp-link-popover${H ? " is-above" : ""}`,
|
|
248
|
+
style: i,
|
|
249
|
+
onMouseDown: (k) => k.stopPropagation(),
|
|
250
|
+
onKeyDown: (k) => {
|
|
251
|
+
k.key === "Enter" ? (k.preventDefault(), y()) : k.key === "Escape" && (k.preventDefault(), W());
|
|
252
252
|
},
|
|
253
253
|
children: [
|
|
254
254
|
/* @__PURE__ */ e("div", { className: "tp-popover-arrow" }),
|
|
255
|
-
/* @__PURE__ */
|
|
255
|
+
/* @__PURE__ */ w("div", { className: "tp-popover-content", children: [
|
|
256
256
|
/* @__PURE__ */ e("div", { className: "tp-popover-header", children: /* @__PURE__ */ e("span", { className: "tp-popover-title", children: f(s ? "link.editLink" : "link.insertLink") }) }),
|
|
257
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ w("div", { className: "tp-popover-body", children: [
|
|
258
258
|
/* @__PURE__ */ e("label", { className: "tp-popover-label", children: f("link.url") }),
|
|
259
|
-
/* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ w("div", { className: "tp-popover-input-row", children: [
|
|
260
260
|
/* @__PURE__ */ e(
|
|
261
261
|
"input",
|
|
262
262
|
{
|
|
263
263
|
ref: T,
|
|
264
264
|
type: "url",
|
|
265
|
-
className: `tp-popover-input${
|
|
266
|
-
value:
|
|
265
|
+
className: `tp-popover-input${g ? " is-error" : ""}`,
|
|
266
|
+
value: v,
|
|
267
267
|
placeholder: f("link.url"),
|
|
268
|
-
onChange: (
|
|
269
|
-
onKeyDown: (
|
|
270
|
-
|
|
268
|
+
onChange: (k) => L(k.target.value),
|
|
269
|
+
onKeyDown: (k) => {
|
|
270
|
+
k.key === "Enter" ? (k.preventDefault(), y()) : k.key === "Escape" && (k.preventDefault(), W());
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
),
|
|
274
|
-
/* @__PURE__ */ e("button", { className: "tp-popover-btn-confirm", onClick:
|
|
275
|
-
s && /* @__PURE__ */ e("button", { className: "tp-popover-btn-unlink", onClick:
|
|
274
|
+
/* @__PURE__ */ e("button", { className: "tp-popover-btn-confirm", onClick: y, children: f("common.confirm") }),
|
|
275
|
+
s && /* @__PURE__ */ e("button", { className: "tp-popover-btn-unlink", onClick: $, children: f("link.unlink") })
|
|
276
276
|
] }),
|
|
277
|
-
|
|
277
|
+
g && /* @__PURE__ */ e("div", { className: "tp-link-error-message", children: g })
|
|
278
278
|
] })
|
|
279
279
|
] })
|
|
280
280
|
]
|
|
@@ -282,48 +282,48 @@ const bt = ({
|
|
|
282
282
|
)
|
|
283
283
|
}
|
|
284
284
|
) : null;
|
|
285
|
-
},
|
|
286
|
-
const { t: s } = fe(), [
|
|
287
|
-
var
|
|
288
|
-
if (
|
|
289
|
-
const { from:
|
|
290
|
-
if (
|
|
291
|
-
if (u.current = { from:
|
|
292
|
-
const l =
|
|
293
|
-
|
|
285
|
+
}, Bt = "#b4d5fe", Pt = ({ def: t, editor: r, active: a, disabled: h, onCustomClick: c }) => {
|
|
286
|
+
const { t: s } = fe(), [m, d] = A(!1), u = B(null), f = B(null), v = B(""), L = B(!1), H = (g) => {
|
|
287
|
+
var o;
|
|
288
|
+
if (g.preventDefault(), t.name === "link") {
|
|
289
|
+
const { from: x, to: i } = r.state.selection;
|
|
290
|
+
if (x !== i || r.isActive("link")) {
|
|
291
|
+
if (u.current = { from: x, to: i }, r.isActive("link")) {
|
|
292
|
+
const l = r.state.selection.$head.marks().find((y) => y.type.name === "link");
|
|
293
|
+
v.current = ((o = l == null ? void 0 : l.attrs) == null ? void 0 : o.href) || "", L.current = !0;
|
|
294
294
|
} else
|
|
295
|
-
|
|
296
|
-
if (!
|
|
295
|
+
v.current = "", L.current = !1;
|
|
296
|
+
if (!r.isActive("link")) {
|
|
297
297
|
const l = window.getSelection();
|
|
298
298
|
if (l && l.rangeCount > 0) {
|
|
299
|
-
const
|
|
300
|
-
|
|
299
|
+
const $ = l.getRangeAt(0).getBoundingClientRect();
|
|
300
|
+
$.width > 0 && $.height > 0 && (f.current = $);
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
},
|
|
306
|
-
var
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
|
|
305
|
+
}, p = () => {
|
|
306
|
+
var o, x;
|
|
307
|
+
const g = t.name;
|
|
308
|
+
if (g === "getHTML" || g === "getJSON" || g === "importWord" || g === "importMarkdown" || g === "exportWord" || g === "exportMarkdown" || g === "snapshot" || g === "compare" || g === "fullscreen" || g === "autoFormat") {
|
|
309
|
+
c == null || c(g);
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
|
-
if (
|
|
313
|
-
if (
|
|
312
|
+
if (g === "link") {
|
|
313
|
+
if (r.isActive("link")) {
|
|
314
314
|
if (!u.current) {
|
|
315
|
-
const { from: l, to:
|
|
316
|
-
u.current = { from: l, to:
|
|
315
|
+
const { from: l, to: y } = r.state.selection;
|
|
316
|
+
u.current = { from: l, to: y };
|
|
317
317
|
}
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
318
|
+
const i = r.state.selection.$head.marks().find((l) => l.type.name === "link");
|
|
319
|
+
if (v.current = ((o = i == null ? void 0 : i.attrs) == null ? void 0 : o.href) || "", L.current = !0, !f.current && u.current)
|
|
320
320
|
try {
|
|
321
|
-
const { from: l, to:
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
321
|
+
const { from: l, to: y } = u.current, $ = r.view.coordsAtPos(l), W = r.view.coordsAtPos(y);
|
|
322
|
+
$ && W && (f.current = new DOMRect(
|
|
323
|
+
$.left,
|
|
324
|
+
$.top,
|
|
325
|
+
W.left - $.left,
|
|
326
|
+
W.bottom - $.top
|
|
327
327
|
));
|
|
328
328
|
} catch {
|
|
329
329
|
}
|
|
@@ -331,70 +331,70 @@ const bt = ({
|
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
if (!u.current) {
|
|
334
|
-
const { from:
|
|
335
|
-
if (
|
|
336
|
-
u.current = { from:
|
|
334
|
+
const { from: i, to: l } = r.state.selection;
|
|
335
|
+
if (i === l) return;
|
|
336
|
+
u.current = { from: i, to: l };
|
|
337
337
|
}
|
|
338
|
-
if (
|
|
338
|
+
if (v.current = "", L.current = !1, !f.current && u.current)
|
|
339
339
|
try {
|
|
340
|
-
const { from:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
340
|
+
const { from: i, to: l } = u.current, y = r.view.coordsAtPos(i), $ = r.view.coordsAtPos(l);
|
|
341
|
+
y && $ && (f.current = new DOMRect(
|
|
342
|
+
y.left,
|
|
343
|
+
y.top,
|
|
344
|
+
$.left - y.left,
|
|
345
|
+
y.bottom - y.top
|
|
346
346
|
));
|
|
347
347
|
} catch {
|
|
348
348
|
}
|
|
349
349
|
if (u.current) {
|
|
350
|
-
const { from:
|
|
351
|
-
|
|
350
|
+
const { from: i, to: l } = u.current;
|
|
351
|
+
r.chain().focus().setTextSelection({ from: i, to: l }).setHighlight({ color: Bt }).run();
|
|
352
352
|
}
|
|
353
353
|
d(!0);
|
|
354
354
|
return;
|
|
355
355
|
}
|
|
356
|
-
(
|
|
357
|
-
}, T = (
|
|
356
|
+
(x = t.command) == null || x.call(t, r);
|
|
357
|
+
}, T = (g) => {
|
|
358
358
|
if (u.current) {
|
|
359
|
-
const { from:
|
|
360
|
-
|
|
359
|
+
const { from: o, to: x } = u.current, i = r.chain().focus().setTextSelection({ from: o, to: x }).unsetHighlight();
|
|
360
|
+
g ? i.setLink({ href: g }).run() : i.unsetLink().run();
|
|
361
361
|
}
|
|
362
|
-
u.current = null, f.current = null,
|
|
363
|
-
},
|
|
362
|
+
u.current = null, f.current = null, v.current = "", L.current = !1;
|
|
363
|
+
}, b = () => {
|
|
364
364
|
if (u.current) {
|
|
365
|
-
const { from:
|
|
366
|
-
|
|
365
|
+
const { from: g, to: o } = u.current;
|
|
366
|
+
r.chain().focus().setTextSelection({ from: g, to: o }).unsetHighlight().run();
|
|
367
367
|
}
|
|
368
|
-
u.current = null, f.current = null,
|
|
368
|
+
u.current = null, f.current = null, v.current = "", L.current = !1;
|
|
369
369
|
}, M = t.name === "getHTML" || t.name === "getJSON";
|
|
370
|
-
return /* @__PURE__ */
|
|
370
|
+
return /* @__PURE__ */ w(nt, { children: [
|
|
371
371
|
/* @__PURE__ */ e(
|
|
372
372
|
"button",
|
|
373
373
|
{
|
|
374
|
-
className: `tp-toolbar-btn${
|
|
375
|
-
disabled:
|
|
374
|
+
className: `tp-toolbar-btn${a ? " is-active" : ""}${M ? " is-text-btn" : ""}`,
|
|
375
|
+
disabled: h,
|
|
376
376
|
title: s(t.titleKey),
|
|
377
|
-
onMouseDown:
|
|
378
|
-
onClick:
|
|
379
|
-
children: t.name === "getHTML" ? /* @__PURE__ */ e("span", { className: "tp-toolbar-text", children: "HTML" }) : t.name === "getJSON" ? /* @__PURE__ */ e("span", { className: "tp-toolbar-text", children: "JSON" }) : /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
377
|
+
onMouseDown: H,
|
|
378
|
+
onClick: p,
|
|
379
|
+
children: t.name === "getHTML" ? /* @__PURE__ */ e("span", { className: "tp-toolbar-text", children: "HTML" }) : t.name === "getJSON" ? /* @__PURE__ */ e("span", { className: "tp-toolbar-text", children: "JSON" }) : /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be(t.name) } })
|
|
380
380
|
}
|
|
381
381
|
),
|
|
382
382
|
/* @__PURE__ */ e(
|
|
383
|
-
|
|
383
|
+
_t,
|
|
384
384
|
{
|
|
385
|
-
visible:
|
|
385
|
+
visible: m,
|
|
386
386
|
targetRect: f.current,
|
|
387
|
-
editor:
|
|
387
|
+
editor: r,
|
|
388
388
|
savedSelection: u.current,
|
|
389
|
-
initialUrl:
|
|
390
|
-
isEditing:
|
|
389
|
+
initialUrl: v.current,
|
|
390
|
+
isEditing: L.current,
|
|
391
391
|
onConfirm: T,
|
|
392
|
-
onCancel:
|
|
392
|
+
onCancel: b,
|
|
393
393
|
onClose: () => d(!1)
|
|
394
394
|
}
|
|
395
395
|
)
|
|
396
396
|
] });
|
|
397
|
-
},
|
|
397
|
+
}, st = {
|
|
398
398
|
SimSun: ["SimSun", "宋体"],
|
|
399
399
|
宋体: ["SimSun", "宋体"],
|
|
400
400
|
"Microsoft YaHei": ["Microsoft YaHei", "微软雅黑"],
|
|
@@ -403,63 +403,63 @@ const bt = ({
|
|
|
403
403
|
黑体: ["SimHei", "黑体"],
|
|
404
404
|
KaiTi: ["KaiTi", "楷体"],
|
|
405
405
|
楷体: ["KaiTi", "楷体"]
|
|
406
|
-
},
|
|
406
|
+
}, It = ({ def: t, editor: r, active: a, disabled: h, onCustomClick: c }) => {
|
|
407
407
|
var M;
|
|
408
|
-
const { t: s } = fe(), [
|
|
409
|
-
var
|
|
410
|
-
return (
|
|
411
|
-
}, [u, t,
|
|
412
|
-
const
|
|
408
|
+
const { t: s } = fe(), [m, d] = A(!1), [u, f] = A(0), v = B(null), L = Me(() => {
|
|
409
|
+
var g;
|
|
410
|
+
return (g = t.getCurrentValue) == null ? void 0 : g.call(t, r);
|
|
411
|
+
}, [u, t, r]), H = (g) => {
|
|
412
|
+
const o = String(L), x = String(g);
|
|
413
413
|
if (t.name === "fontFamily") {
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
if (l) return l.includes(
|
|
414
|
+
const i = st[o], l = st[x];
|
|
415
|
+
if (i) return i.includes(x);
|
|
416
|
+
if (l) return l.includes(o);
|
|
417
417
|
}
|
|
418
|
-
return
|
|
419
|
-
},
|
|
420
|
-
const
|
|
421
|
-
return
|
|
418
|
+
return o === x;
|
|
419
|
+
}, p = (g) => {
|
|
420
|
+
const o = Number(g);
|
|
421
|
+
return o === 0 ? "tp-heading-preview-paragraph" : o >= 1 && o <= 6 ? `tp-heading-preview-h${o}` : "";
|
|
422
422
|
}, T = () => {
|
|
423
|
-
|
|
424
|
-
},
|
|
425
|
-
var
|
|
426
|
-
t.isActionMenu ?
|
|
423
|
+
h || (d(!m), m || f((g) => g + 1));
|
|
424
|
+
}, b = (g) => {
|
|
425
|
+
var o;
|
|
426
|
+
t.isActionMenu ? c == null || c(String(g)) : (o = t.command) == null || o.call(t, r, g), d(!1);
|
|
427
427
|
};
|
|
428
|
-
return
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
},
|
|
432
|
-
return document.addEventListener("pointerdown",
|
|
433
|
-
document.removeEventListener("pointerdown",
|
|
428
|
+
return z(() => {
|
|
429
|
+
const g = (x) => {
|
|
430
|
+
v.current && !v.current.contains(x.target) && d(!1);
|
|
431
|
+
}, o = () => f((x) => x + 1);
|
|
432
|
+
return document.addEventListener("pointerdown", g), r.on("transaction", o), () => {
|
|
433
|
+
document.removeEventListener("pointerdown", g), r.off("transaction", o);
|
|
434
434
|
};
|
|
435
|
-
}, [
|
|
436
|
-
/* @__PURE__ */
|
|
435
|
+
}, [r]), /* @__PURE__ */ w("div", { ref: v, className: "tp-toolbar-dropdown", children: [
|
|
436
|
+
/* @__PURE__ */ w(
|
|
437
437
|
"button",
|
|
438
438
|
{
|
|
439
|
-
className: `tp-toolbar-dropdown-trigger${
|
|
439
|
+
className: `tp-toolbar-dropdown-trigger${a ? " is-active" : ""}${h ? " is-disabled" : ""}`,
|
|
440
440
|
title: s(t.tooltipKey || t.titleKey),
|
|
441
|
-
disabled:
|
|
442
|
-
onMouseDown: (
|
|
441
|
+
disabled: h,
|
|
442
|
+
onMouseDown: (g) => g.preventDefault(),
|
|
443
443
|
onClick: T,
|
|
444
444
|
children: [
|
|
445
|
-
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
445
|
+
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be(t.name) } }),
|
|
446
446
|
!t.hideLabel && /* @__PURE__ */ e("span", { className: "tp-toolbar-dropdown-label", children: s(t.titleKey) }),
|
|
447
447
|
/* @__PURE__ */ e("span", { className: "tp-toolbar-dropdown-arrow", children: "▾" })
|
|
448
448
|
]
|
|
449
449
|
}
|
|
450
450
|
),
|
|
451
|
-
|
|
451
|
+
m && /* @__PURE__ */ e("div", { className: "tp-toolbar-dropdown-menu", children: (M = t.options) == null ? void 0 : M.map((g) => /* @__PURE__ */ e(
|
|
452
452
|
"button",
|
|
453
453
|
{
|
|
454
|
-
className: `tp-toolbar-dropdown-item${
|
|
455
|
-
onMouseDown: (
|
|
456
|
-
onClick: () =>
|
|
457
|
-
children:
|
|
454
|
+
className: `tp-toolbar-dropdown-item${H(g.value) ? " is-active" : ""}${t.name === "heading" ? " " + p(g.value) : ""}`,
|
|
455
|
+
onMouseDown: (o) => o.preventDefault(),
|
|
456
|
+
onClick: () => b(g.value),
|
|
457
|
+
children: g.labelKey ? s(g.labelKey) : g.label
|
|
458
458
|
},
|
|
459
|
-
String(
|
|
459
|
+
String(g.value)
|
|
460
460
|
)) })
|
|
461
461
|
] });
|
|
462
|
-
},
|
|
462
|
+
}, Ft = [
|
|
463
463
|
"#ffffff",
|
|
464
464
|
"#f3f3f3",
|
|
465
465
|
"#fce5cd",
|
|
@@ -520,44 +520,44 @@ const bt = ({
|
|
|
520
520
|
"#20124d",
|
|
521
521
|
"#073763",
|
|
522
522
|
"#7f6000"
|
|
523
|
-
],
|
|
524
|
-
const { t:
|
|
525
|
-
const M =
|
|
523
|
+
], Ot = ["#ff0000", "#ff5e00", "#ff9900", "#ffff00", "#00ff00", "#00a8a8", "#00ffff", "#0000ff", "#5f00ff", "#9900ff"], Wt = ({ def: t, editor: r, disabled: a }) => {
|
|
524
|
+
const { t: h } = fe(), [c, s] = A(!1), m = B(null), [d, u] = A(""), [f, v] = A(""), L = t.name === "color", H = L ? d : f, p = () => {
|
|
525
|
+
const M = r.getAttributes("textStyle");
|
|
526
526
|
u((M == null ? void 0 : M.color) || "");
|
|
527
|
-
const
|
|
528
|
-
|
|
527
|
+
const g = r.getAttributes("highlight");
|
|
528
|
+
v((g == null ? void 0 : g.color) || "");
|
|
529
529
|
};
|
|
530
|
-
|
|
531
|
-
const M = (
|
|
532
|
-
|
|
530
|
+
z(() => {
|
|
531
|
+
const M = (g) => {
|
|
532
|
+
m.current && !m.current.contains(g.target) && s(!1);
|
|
533
533
|
};
|
|
534
|
-
return document.addEventListener("pointerdown", M),
|
|
535
|
-
document.removeEventListener("pointerdown", M),
|
|
534
|
+
return document.addEventListener("pointerdown", M), r.on("transaction", p), r.on("selectionUpdate", p), p(), () => {
|
|
535
|
+
document.removeEventListener("pointerdown", M), r.off("transaction", p), r.off("selectionUpdate", p);
|
|
536
536
|
};
|
|
537
|
-
}, [
|
|
537
|
+
}, [r]);
|
|
538
538
|
const T = (M) => {
|
|
539
|
-
var
|
|
540
|
-
(
|
|
541
|
-
},
|
|
539
|
+
var g;
|
|
540
|
+
(g = t.command) == null || g.call(t, r, M), setTimeout(p, 0), s(!1);
|
|
541
|
+
}, b = () => {
|
|
542
542
|
var M;
|
|
543
|
-
(M = t.command) == null || M.call(t,
|
|
543
|
+
(M = t.command) == null || M.call(t, r, void 0), v(""), s(!1);
|
|
544
544
|
};
|
|
545
|
-
return /* @__PURE__ */
|
|
546
|
-
/* @__PURE__ */
|
|
545
|
+
return /* @__PURE__ */ w("div", { ref: m, className: "tp-toolbar-dropdown", children: [
|
|
546
|
+
/* @__PURE__ */ w(
|
|
547
547
|
"button",
|
|
548
548
|
{
|
|
549
|
-
className: `tp-toolbar-dropdown-trigger${
|
|
550
|
-
title:
|
|
551
|
-
disabled:
|
|
549
|
+
className: `tp-toolbar-dropdown-trigger${a ? " is-disabled" : ""}`,
|
|
550
|
+
title: h(t.titleKey),
|
|
551
|
+
disabled: a,
|
|
552
552
|
onMouseDown: (M) => M.preventDefault(),
|
|
553
553
|
onClick: () => {
|
|
554
|
-
|
|
554
|
+
a || s(!c);
|
|
555
555
|
},
|
|
556
556
|
children: [
|
|
557
|
-
/* @__PURE__ */ e("span", { className:
|
|
557
|
+
/* @__PURE__ */ e("span", { className: L ? "tp-color-picker-icon" : "tp-bgcolor-picker-icon", children: L ? /* @__PURE__ */ w("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: [
|
|
558
558
|
/* @__PURE__ */ e("text", { x: "4", y: "17", fontSize: "24", fill: "currentColor", stroke: "none", fontFamily: "serif", fontWeight: "bold", children: "A" }),
|
|
559
559
|
/* @__PURE__ */ e("line", { x1: "4", y1: "22", x2: "20", y2: "22", strokeWidth: "5", stroke: d || "#000000" })
|
|
560
|
-
] }) : /* @__PURE__ */
|
|
560
|
+
] }) : /* @__PURE__ */ w("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: [
|
|
561
561
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", fill: f || "transparent" }),
|
|
562
562
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
563
563
|
/* @__PURE__ */ e("text", { x: "6", y: "17", fontSize: "16", fill: "currentColor", stroke: "none", fontFamily: "serif", fontWeight: "bold", children: "A" })
|
|
@@ -566,118 +566,118 @@ const bt = ({
|
|
|
566
566
|
]
|
|
567
567
|
}
|
|
568
568
|
),
|
|
569
|
-
|
|
570
|
-
/* @__PURE__ */ e("button", { className: "tp-color-default-btn", onMouseDown: (M) => M.preventDefault(), onClick:
|
|
571
|
-
/* @__PURE__ */ e("div", { className: "tp-color-grid tp-theme-colors", children:
|
|
569
|
+
c && /* @__PURE__ */ w("div", { className: "tp-color-picker-panel", children: [
|
|
570
|
+
/* @__PURE__ */ e("button", { className: "tp-color-default-btn", onMouseDown: (M) => M.preventDefault(), onClick: b, children: h("common.default") }),
|
|
571
|
+
/* @__PURE__ */ e("div", { className: "tp-color-grid tp-theme-colors", children: Ft.map((M, g) => /* @__PURE__ */ e(
|
|
572
572
|
"button",
|
|
573
573
|
{
|
|
574
|
-
className: `tp-color-swatch${
|
|
574
|
+
className: `tp-color-swatch${H === M ? " tp-color-swatch-selected" : ""}`,
|
|
575
575
|
style: { backgroundColor: M },
|
|
576
576
|
title: M,
|
|
577
|
-
onMouseDown: (
|
|
577
|
+
onMouseDown: (o) => o.preventDefault(),
|
|
578
578
|
onClick: () => T(M)
|
|
579
579
|
},
|
|
580
|
-
`theme-${
|
|
580
|
+
`theme-${g}`
|
|
581
581
|
)) }),
|
|
582
|
-
/* @__PURE__ */ e("div", { className: "tp-color-section-label", children:
|
|
583
|
-
/* @__PURE__ */ e("div", { className: "tp-color-grid tp-standard-colors", children:
|
|
582
|
+
/* @__PURE__ */ e("div", { className: "tp-color-section-label", children: h("common.standardColor") }),
|
|
583
|
+
/* @__PURE__ */ e("div", { className: "tp-color-grid tp-standard-colors", children: Ot.map((M, g) => /* @__PURE__ */ e(
|
|
584
584
|
"button",
|
|
585
585
|
{
|
|
586
|
-
className: `tp-color-swatch${
|
|
586
|
+
className: `tp-color-swatch${H === M ? " tp-color-swatch-selected" : ""}`,
|
|
587
587
|
style: { backgroundColor: M },
|
|
588
588
|
title: M,
|
|
589
|
-
onMouseDown: (
|
|
589
|
+
onMouseDown: (o) => o.preventDefault(),
|
|
590
590
|
onClick: () => T(M)
|
|
591
591
|
},
|
|
592
|
-
`std-${
|
|
592
|
+
`std-${g}`
|
|
593
593
|
)) })
|
|
594
594
|
] })
|
|
595
595
|
] });
|
|
596
|
-
},
|
|
596
|
+
}, it = () => /* @__PURE__ */ e("div", { className: "tp-toolbar-separator" }), jt = ({
|
|
597
597
|
visible: t,
|
|
598
|
-
editor:
|
|
599
|
-
uploadUrl:
|
|
600
|
-
uploadHeaders:
|
|
601
|
-
onUpload:
|
|
598
|
+
editor: r,
|
|
599
|
+
uploadUrl: a,
|
|
600
|
+
uploadHeaders: h,
|
|
601
|
+
onUpload: c,
|
|
602
602
|
initialTab: s,
|
|
603
|
-
onClose:
|
|
603
|
+
onClose: m
|
|
604
604
|
}) => {
|
|
605
|
-
const { t: d } = fe(), [u, f] =
|
|
606
|
-
|
|
605
|
+
const { t: d } = fe(), [u, f] = A(s || "upload"), [v, L] = A(""), [H, p] = A(!1), [T, b] = A(!1), [M, g] = A(0), [o, x] = A(""), i = B(null);
|
|
606
|
+
z(() => (t ? (L(""), x(""), f(s || "upload"), g(0), document.body.style.overflow = "hidden") : document.body.style.overflow = "", () => {
|
|
607
607
|
document.body.style.overflow = "";
|
|
608
608
|
}), [t, s]);
|
|
609
|
-
const l = (
|
|
609
|
+
const l = (k) => new Promise((D, E) => {
|
|
610
610
|
const P = new FileReader();
|
|
611
|
-
P.onload = () =>
|
|
612
|
-
}),
|
|
613
|
-
|
|
614
|
-
},
|
|
615
|
-
|
|
611
|
+
P.onload = () => D(P.result), P.onerror = E, P.readAsDataURL(k);
|
|
612
|
+
}), y = (k) => {
|
|
613
|
+
r.chain().focus().setImage({ src: k }).run();
|
|
614
|
+
}, $ = async (k) => {
|
|
615
|
+
b(!0), g(0), x("");
|
|
616
616
|
try {
|
|
617
|
-
let
|
|
618
|
-
|
|
619
|
-
} catch (
|
|
620
|
-
|
|
617
|
+
let D;
|
|
618
|
+
c ? D = await c(k) : a ? D = await gt(k, { url: a, headers: h, onProgress: g }) : D = await l(k), y(D), m();
|
|
619
|
+
} catch (D) {
|
|
620
|
+
x(D instanceof Error ? D.message : d("imageUpload.uploadFailed"));
|
|
621
621
|
} finally {
|
|
622
|
-
|
|
622
|
+
b(!1), g(0);
|
|
623
623
|
}
|
|
624
|
-
},
|
|
625
|
-
const
|
|
626
|
-
if (!
|
|
627
|
-
|
|
624
|
+
}, W = () => {
|
|
625
|
+
const k = v.trim();
|
|
626
|
+
if (!k) {
|
|
627
|
+
x(d("imageUpload.urlRequired"));
|
|
628
628
|
return;
|
|
629
629
|
}
|
|
630
630
|
try {
|
|
631
|
-
new URL(
|
|
631
|
+
new URL(k);
|
|
632
632
|
} catch {
|
|
633
|
-
|
|
633
|
+
x(d("imageUpload.invalidUrl"));
|
|
634
634
|
return;
|
|
635
635
|
}
|
|
636
|
-
|
|
636
|
+
y(k), m();
|
|
637
637
|
};
|
|
638
|
-
return t ? /* @__PURE__ */ e("div", { className: "tp-image-upload-overlay", onMouseDown: (
|
|
639
|
-
|
|
640
|
-
}, children: /* @__PURE__ */
|
|
641
|
-
/* @__PURE__ */
|
|
638
|
+
return t ? /* @__PURE__ */ e("div", { className: "tp-image-upload-overlay", onMouseDown: (k) => {
|
|
639
|
+
k.target === k.currentTarget && m();
|
|
640
|
+
}, children: /* @__PURE__ */ w("div", { className: "tp-image-upload-dialog", onMouseDown: (k) => k.stopPropagation(), children: [
|
|
641
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-header", children: [
|
|
642
642
|
/* @__PURE__ */ e("span", { className: "tp-dialog-title", children: d("image.upload") }),
|
|
643
|
-
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick:
|
|
643
|
+
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick: m, children: "×" })
|
|
644
644
|
] }),
|
|
645
|
-
/* @__PURE__ */
|
|
645
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-tabs", children: [
|
|
646
646
|
/* @__PURE__ */ e("button", { className: `tp-tab-btn${u === "upload" ? " is-active" : ""}`, onClick: () => f("upload"), children: d("imageUpload.uploadLocal") }),
|
|
647
647
|
/* @__PURE__ */ e("button", { className: `tp-tab-btn${u === "url" ? " is-active" : ""}`, onClick: () => f("url"), children: d("imageUpload.inputUrl") })
|
|
648
648
|
] }),
|
|
649
|
-
/* @__PURE__ */
|
|
650
|
-
u === "upload" && /* @__PURE__ */
|
|
649
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-body", children: [
|
|
650
|
+
u === "upload" && /* @__PURE__ */ w("div", { className: "tp-upload-tab", children: [
|
|
651
651
|
/* @__PURE__ */ e(
|
|
652
652
|
"div",
|
|
653
653
|
{
|
|
654
|
-
className: `tp-dropzone${
|
|
655
|
-
onDragEnter: (
|
|
656
|
-
|
|
654
|
+
className: `tp-dropzone${H ? " is-dragging" : ""}${T ? " is-uploading" : ""}`,
|
|
655
|
+
onDragEnter: (k) => {
|
|
656
|
+
k.preventDefault(), p(!0);
|
|
657
657
|
},
|
|
658
|
-
onDragLeave: (
|
|
659
|
-
|
|
658
|
+
onDragLeave: (k) => {
|
|
659
|
+
k.preventDefault(), p(!1);
|
|
660
660
|
},
|
|
661
|
-
onDragOver: (
|
|
662
|
-
onDrop: (
|
|
663
|
-
var
|
|
664
|
-
|
|
665
|
-
const
|
|
666
|
-
|
|
661
|
+
onDragOver: (k) => k.preventDefault(),
|
|
662
|
+
onDrop: (k) => {
|
|
663
|
+
var E, P;
|
|
664
|
+
k.preventDefault(), p(!1);
|
|
665
|
+
const D = (P = (E = k.dataTransfer) == null ? void 0 : E.files) == null ? void 0 : P[0];
|
|
666
|
+
D != null && D.type.startsWith("image/") ? $(D) : x(d("imageUpload.invalidType"));
|
|
667
667
|
},
|
|
668
668
|
onClick: () => {
|
|
669
|
-
var
|
|
670
|
-
return (
|
|
669
|
+
var k;
|
|
670
|
+
return (k = i.current) == null ? void 0 : k.click();
|
|
671
671
|
},
|
|
672
|
-
children: T ? /* @__PURE__ */
|
|
672
|
+
children: T ? /* @__PURE__ */ w("div", { className: "tp-upload-progress", children: [
|
|
673
673
|
/* @__PURE__ */ e("div", { className: "tp-progress-bar", children: /* @__PURE__ */ e("div", { className: "tp-progress-fill", style: { width: M + "%" } }) }),
|
|
674
|
-
/* @__PURE__ */
|
|
674
|
+
/* @__PURE__ */ w("span", { className: "tp-progress-text", children: [
|
|
675
675
|
d("imageUpload.uploading"),
|
|
676
676
|
" ",
|
|
677
677
|
M,
|
|
678
678
|
"%"
|
|
679
679
|
] })
|
|
680
|
-
] }) : /* @__PURE__ */
|
|
680
|
+
] }) : /* @__PURE__ */ w("div", { className: "tp-dropzone-content", children: [
|
|
681
681
|
/* @__PURE__ */ e("span", { className: "tp-dropzone-icon", children: "📁" }),
|
|
682
682
|
/* @__PURE__ */ e("span", { className: "tp-dropzone-text", children: d("imageUpload.selectFile") }),
|
|
683
683
|
/* @__PURE__ */ e("span", { className: "tp-dropzone-hint", children: d("imageUpload.dragHint") })
|
|
@@ -687,142 +687,142 @@ const bt = ({
|
|
|
687
687
|
/* @__PURE__ */ e(
|
|
688
688
|
"input",
|
|
689
689
|
{
|
|
690
|
-
ref:
|
|
690
|
+
ref: i,
|
|
691
691
|
type: "file",
|
|
692
692
|
accept: "image/*",
|
|
693
693
|
style: { display: "none" },
|
|
694
|
-
onChange: (
|
|
695
|
-
var
|
|
696
|
-
const
|
|
697
|
-
|
|
694
|
+
onChange: (k) => {
|
|
695
|
+
var E;
|
|
696
|
+
const D = (E = k.target.files) == null ? void 0 : E[0];
|
|
697
|
+
D && $(D), k.target.value = "";
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
700
|
)
|
|
701
701
|
] }),
|
|
702
|
-
u === "url" && /* @__PURE__ */
|
|
702
|
+
u === "url" && /* @__PURE__ */ w("div", { className: "tp-url-tab", children: [
|
|
703
703
|
/* @__PURE__ */ e("label", { className: "tp-input-label", children: d("imageUpload.url") }),
|
|
704
|
-
/* @__PURE__ */
|
|
704
|
+
/* @__PURE__ */ w("div", { className: "tp-input-row", children: [
|
|
705
705
|
/* @__PURE__ */ e(
|
|
706
706
|
"input",
|
|
707
707
|
{
|
|
708
708
|
className: "tp-url-input",
|
|
709
709
|
type: "url",
|
|
710
|
-
value:
|
|
710
|
+
value: v,
|
|
711
711
|
placeholder: d("imageUpload.placeholder"),
|
|
712
|
-
onChange: (
|
|
713
|
-
onKeyDown: (
|
|
714
|
-
|
|
712
|
+
onChange: (k) => L(k.target.value),
|
|
713
|
+
onKeyDown: (k) => {
|
|
714
|
+
k.key === "Enter" && W(), k.key === "Escape" && m();
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
),
|
|
718
|
-
/* @__PURE__ */ e("button", { className: "tp-confirm-btn", onClick:
|
|
718
|
+
/* @__PURE__ */ e("button", { className: "tp-confirm-btn", onClick: W, children: d("common.confirm") })
|
|
719
719
|
] })
|
|
720
720
|
] }),
|
|
721
|
-
|
|
721
|
+
o && /* @__PURE__ */ e("div", { className: "tp-error-message", children: o })
|
|
722
722
|
] })
|
|
723
723
|
] }) }) : null;
|
|
724
|
-
},
|
|
725
|
-
var
|
|
726
|
-
const { t: s } = fe(), [
|
|
727
|
-
|
|
728
|
-
const l = (
|
|
729
|
-
|
|
724
|
+
}, Ut = ({ def: t, editor: r, manager: a, active: h, disabled: c }) => {
|
|
725
|
+
var g, o, x, i;
|
|
726
|
+
const { t: s } = fe(), [m, d] = A(!1), [u, f] = A(!1), [v, L] = A("upload"), H = B(null), p = (g = a == null ? void 0 : a.getConfig().upload) == null ? void 0 : g.url, T = (o = a == null ? void 0 : a.getConfig().upload) == null ? void 0 : o.headers, b = (x = a == null ? void 0 : a.getConfig().upload) == null ? void 0 : x.onUpload;
|
|
727
|
+
z(() => {
|
|
728
|
+
const l = (y) => {
|
|
729
|
+
H.current && !H.current.contains(y.target) && d(!1);
|
|
730
730
|
};
|
|
731
731
|
return document.addEventListener("pointerdown", l), () => document.removeEventListener("pointerdown", l);
|
|
732
732
|
}, []);
|
|
733
733
|
const M = (l) => {
|
|
734
|
-
d(!1), l === "upload" ? (
|
|
734
|
+
d(!1), l === "upload" ? (L("upload"), f(!0)) : l === "url" && (L("url"), f(!0));
|
|
735
735
|
};
|
|
736
|
-
return /* @__PURE__ */
|
|
737
|
-
/* @__PURE__ */
|
|
736
|
+
return /* @__PURE__ */ w("div", { ref: H, className: "tp-toolbar-dropdown", children: [
|
|
737
|
+
/* @__PURE__ */ w(
|
|
738
738
|
"button",
|
|
739
739
|
{
|
|
740
|
-
className: `tp-toolbar-dropdown-trigger${
|
|
740
|
+
className: `tp-toolbar-dropdown-trigger${h ? " is-active" : ""}${c ? " is-disabled" : ""}`,
|
|
741
741
|
title: s(t.titleKey),
|
|
742
|
-
disabled:
|
|
742
|
+
disabled: c,
|
|
743
743
|
onMouseDown: (l) => l.preventDefault(),
|
|
744
744
|
onClick: () => {
|
|
745
|
-
|
|
745
|
+
c || d(!m);
|
|
746
746
|
},
|
|
747
747
|
children: [
|
|
748
|
-
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
748
|
+
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be(t.name) } }),
|
|
749
749
|
/* @__PURE__ */ e("span", { className: "tp-toolbar-dropdown-arrow", children: "▾" })
|
|
750
750
|
]
|
|
751
751
|
}
|
|
752
752
|
),
|
|
753
|
-
|
|
753
|
+
m && /* @__PURE__ */ e("div", { className: "tp-toolbar-dropdown-menu", children: (i = t.options) == null ? void 0 : i.map((l) => /* @__PURE__ */ e(
|
|
754
754
|
"button",
|
|
755
755
|
{
|
|
756
756
|
className: "tp-toolbar-dropdown-item",
|
|
757
|
-
onMouseDown: (
|
|
757
|
+
onMouseDown: (y) => y.preventDefault(),
|
|
758
758
|
onClick: () => M(l.value),
|
|
759
759
|
children: l.labelKey ? s(l.labelKey) : l.label
|
|
760
760
|
},
|
|
761
761
|
String(l.value)
|
|
762
762
|
)) }),
|
|
763
763
|
/* @__PURE__ */ e(
|
|
764
|
-
|
|
764
|
+
jt,
|
|
765
765
|
{
|
|
766
766
|
visible: u,
|
|
767
|
-
editor:
|
|
768
|
-
uploadUrl:
|
|
767
|
+
editor: r,
|
|
768
|
+
uploadUrl: p,
|
|
769
769
|
uploadHeaders: T,
|
|
770
|
-
onUpload:
|
|
771
|
-
initialTab:
|
|
770
|
+
onUpload: b,
|
|
771
|
+
initialTab: v,
|
|
772
772
|
onClose: () => f(!1)
|
|
773
773
|
}
|
|
774
774
|
)
|
|
775
775
|
] });
|
|
776
|
-
},
|
|
777
|
-
const { t: s } = fe(), [
|
|
778
|
-
|
|
779
|
-
var
|
|
780
|
-
return (
|
|
776
|
+
}, zt = ({ visible: t, editor: r, onSuccess: a, onCancel: h, onClose: c }) => {
|
|
777
|
+
const { t: s } = fe(), [m, d] = A(""), [u, f] = A(""), v = B(null);
|
|
778
|
+
z(() => (t ? (d(""), f(""), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
779
|
+
var b;
|
|
780
|
+
return (b = v.current) == null ? void 0 : b.focus();
|
|
781
781
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
782
782
|
document.body.style.overflow = "";
|
|
783
783
|
}), [t]);
|
|
784
|
-
const
|
|
785
|
-
const
|
|
786
|
-
if (!
|
|
784
|
+
const L = S(() => {
|
|
785
|
+
const b = m.trim();
|
|
786
|
+
if (!b) {
|
|
787
787
|
f(s("video.urlRequired"));
|
|
788
788
|
return;
|
|
789
789
|
}
|
|
790
790
|
try {
|
|
791
|
-
new URL(
|
|
791
|
+
new URL(b);
|
|
792
792
|
} catch {
|
|
793
793
|
f(s("video.invalidUrl"));
|
|
794
794
|
return;
|
|
795
795
|
}
|
|
796
|
-
|
|
797
|
-
}, [
|
|
798
|
-
|
|
799
|
-
}, [
|
|
800
|
-
|
|
801
|
-
}, [
|
|
802
|
-
|
|
803
|
-
}, [
|
|
796
|
+
r.chain().focus().setVideo({ src: b }).run(), a == null || a(b), c();
|
|
797
|
+
}, [m, r, s, a, c]), H = S(() => {
|
|
798
|
+
h == null || h(), c();
|
|
799
|
+
}, [h, c]), p = S((b) => {
|
|
800
|
+
b.target === b.currentTarget && H();
|
|
801
|
+
}, [H]), T = S((b) => {
|
|
802
|
+
b.key === "Enter" ? (b.preventDefault(), L()) : b.key === "Escape" && (b.preventDefault(), H());
|
|
803
|
+
}, [L, H]);
|
|
804
804
|
return t ? _e(
|
|
805
|
-
/* @__PURE__ */ e("div", { className: "tp-video-dialog-overlay", onMouseDown:
|
|
806
|
-
/* @__PURE__ */
|
|
805
|
+
/* @__PURE__ */ e("div", { className: "tp-video-dialog-overlay", onMouseDown: p, children: /* @__PURE__ */ w("div", { className: "tp-video-dialog", onMouseDown: (b) => b.stopPropagation(), onKeyDown: T, children: [
|
|
806
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-header", children: [
|
|
807
807
|
/* @__PURE__ */ e("span", { className: "tp-dialog-title", children: s("video.title") }),
|
|
808
|
-
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick:
|
|
808
|
+
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick: H, children: "×" })
|
|
809
809
|
] }),
|
|
810
|
-
/* @__PURE__ */
|
|
810
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-body", children: [
|
|
811
811
|
/* @__PURE__ */ e("label", { className: "tp-input-label", children: s("video.url") }),
|
|
812
|
-
/* @__PURE__ */
|
|
812
|
+
/* @__PURE__ */ w("div", { className: "tp-input-row", children: [
|
|
813
813
|
/* @__PURE__ */ e(
|
|
814
814
|
"input",
|
|
815
815
|
{
|
|
816
|
-
ref:
|
|
816
|
+
ref: v,
|
|
817
817
|
type: "url",
|
|
818
818
|
className: "tp-url-input",
|
|
819
819
|
placeholder: s("video.placeholder"),
|
|
820
|
-
value:
|
|
821
|
-
onChange: (
|
|
820
|
+
value: m,
|
|
821
|
+
onChange: (b) => d(b.target.value),
|
|
822
822
|
onKeyDown: T
|
|
823
823
|
}
|
|
824
824
|
),
|
|
825
|
-
/* @__PURE__ */ e("button", { className: "tp-confirm-btn", onClick:
|
|
825
|
+
/* @__PURE__ */ e("button", { className: "tp-confirm-btn", onClick: L, children: s("common.confirm") })
|
|
826
826
|
] }),
|
|
827
827
|
/* @__PURE__ */ e("p", { className: "tp-hint", children: s("video.hint") }),
|
|
828
828
|
u && /* @__PURE__ */ e("div", { className: "tp-error-message", children: u })
|
|
@@ -830,558 +830,571 @@ const bt = ({
|
|
|
830
830
|
] }) }),
|
|
831
831
|
document.body
|
|
832
832
|
) : null;
|
|
833
|
-
},
|
|
834
|
-
const { t:
|
|
835
|
-
|
|
833
|
+
}, Kt = ({ def: t, editor: r, active: a, disabled: h }) => {
|
|
834
|
+
const { t: c } = fe(), [s, m] = A(!1), d = () => {
|
|
835
|
+
h || m(!0);
|
|
836
836
|
};
|
|
837
|
-
return /* @__PURE__ */
|
|
837
|
+
return /* @__PURE__ */ w("div", { className: "tp-toolbar-video-btn", children: [
|
|
838
838
|
/* @__PURE__ */ e(
|
|
839
839
|
"button",
|
|
840
840
|
{
|
|
841
|
-
className: `tp-toolbar-btn${
|
|
842
|
-
title:
|
|
843
|
-
disabled:
|
|
841
|
+
className: `tp-toolbar-btn${a ? " is-active" : ""}${h ? " is-disabled" : ""}`,
|
|
842
|
+
title: c(t.titleKey),
|
|
843
|
+
disabled: h,
|
|
844
844
|
onMouseDown: (u) => u.preventDefault(),
|
|
845
845
|
onClick: d,
|
|
846
|
-
children: /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
846
|
+
children: /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be(t.name) } })
|
|
847
847
|
}
|
|
848
848
|
),
|
|
849
849
|
/* @__PURE__ */ e(
|
|
850
|
-
|
|
850
|
+
zt,
|
|
851
851
|
{
|
|
852
852
|
visible: s,
|
|
853
|
-
editor:
|
|
853
|
+
editor: r,
|
|
854
854
|
onSuccess: () => {
|
|
855
855
|
},
|
|
856
|
-
onClose: () =>
|
|
856
|
+
onClose: () => m(!1)
|
|
857
857
|
}
|
|
858
858
|
)
|
|
859
859
|
] });
|
|
860
|
-
},
|
|
861
|
-
const { t:
|
|
862
|
-
|
|
863
|
-
},
|
|
864
|
-
u({ row:
|
|
865
|
-
},
|
|
866
|
-
|
|
860
|
+
}, Vt = 10, Jt = 10, qt = ({ def: t, editor: r, active: a, disabled: h }) => {
|
|
861
|
+
const { t: c } = fe(), [s, m] = A(!1), [d, u] = A({ row: 0, col: 0 }), f = B(null), v = () => {
|
|
862
|
+
h || (m(!s), u({ row: 0, col: 0 }));
|
|
863
|
+
}, L = (p, T) => {
|
|
864
|
+
u({ row: p, col: T });
|
|
865
|
+
}, H = (p, T) => {
|
|
866
|
+
r.chain().focus().insertTable({ rows: p, cols: T, withHeaderRow: !0 }).run(), m(!1), u({ row: 0, col: 0 });
|
|
867
867
|
};
|
|
868
|
-
return
|
|
869
|
-
const
|
|
870
|
-
f.current && !f.current.contains(T.target) && (
|
|
868
|
+
return z(() => {
|
|
869
|
+
const p = (T) => {
|
|
870
|
+
f.current && !f.current.contains(T.target) && (m(!1), u({ row: 0, col: 0 }));
|
|
871
871
|
};
|
|
872
|
-
return document.addEventListener("pointerdown",
|
|
873
|
-
}, []), /* @__PURE__ */
|
|
874
|
-
/* @__PURE__ */
|
|
872
|
+
return document.addEventListener("pointerdown", p), () => document.removeEventListener("pointerdown", p);
|
|
873
|
+
}, []), /* @__PURE__ */ w("div", { ref: f, className: "tp-toolbar-dropdown", children: [
|
|
874
|
+
/* @__PURE__ */ w(
|
|
875
875
|
"button",
|
|
876
876
|
{
|
|
877
|
-
className: `tp-toolbar-dropdown-trigger${
|
|
878
|
-
title:
|
|
879
|
-
disabled:
|
|
880
|
-
onMouseDown: (
|
|
881
|
-
onClick:
|
|
877
|
+
className: `tp-toolbar-dropdown-trigger${a ? " is-active" : ""}${h ? " is-disabled" : ""}`,
|
|
878
|
+
title: c(t.titleKey),
|
|
879
|
+
disabled: h,
|
|
880
|
+
onMouseDown: (p) => p.preventDefault(),
|
|
881
|
+
onClick: v,
|
|
882
882
|
children: [
|
|
883
|
-
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
883
|
+
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be(t.name) } }),
|
|
884
884
|
/* @__PURE__ */ e("span", { className: "tp-toolbar-dropdown-arrow", children: "▾" })
|
|
885
885
|
]
|
|
886
886
|
}
|
|
887
887
|
),
|
|
888
|
-
s && /* @__PURE__ */
|
|
889
|
-
/* @__PURE__ */ e("div", { className: "tp-table-grid-header", children: d.row > 0 ? `${d.row} × ${d.col}` :
|
|
890
|
-
/* @__PURE__ */ e("div", { className: "tp-table-grid", children: Array.from({ length:
|
|
891
|
-
const
|
|
888
|
+
s && /* @__PURE__ */ w("div", { className: "tp-table-grid-dropdown", children: [
|
|
889
|
+
/* @__PURE__ */ e("div", { className: "tp-table-grid-header", children: d.row > 0 ? `${d.row} × ${d.col}` : c("table.insertHint") }),
|
|
890
|
+
/* @__PURE__ */ e("div", { className: "tp-table-grid", children: Array.from({ length: Vt }, (p, T) => /* @__PURE__ */ e("div", { className: "tp-table-grid-row", children: Array.from({ length: Jt }, (b, M) => {
|
|
891
|
+
const g = T + 1, o = M + 1;
|
|
892
892
|
return /* @__PURE__ */ e(
|
|
893
893
|
"div",
|
|
894
894
|
{
|
|
895
|
-
className: `tp-table-grid-cell${
|
|
896
|
-
onMouseEnter: () =>
|
|
897
|
-
onClick: () =>
|
|
895
|
+
className: `tp-table-grid-cell${g <= d.row && o <= d.col ? " is-hovered" : ""}${g === d.row && o === d.col ? " is-selected" : ""}`,
|
|
896
|
+
onMouseEnter: () => L(g, o),
|
|
897
|
+
onClick: () => H(g, o)
|
|
898
898
|
},
|
|
899
|
-
`${
|
|
899
|
+
`${g}-${o}`
|
|
900
900
|
);
|
|
901
901
|
}) }, T)) })
|
|
902
902
|
] })
|
|
903
903
|
] });
|
|
904
|
-
},
|
|
905
|
-
const { t:
|
|
906
|
-
const { from:
|
|
904
|
+
}, Yt = ({ editor: t, disabled: r = !1 }) => {
|
|
905
|
+
const { t: a } = fe(), h = B("none"), [c, s] = A("none"), m = B([]), d = B(null), u = B(null), f = B(null), v = B(void 0), L = B(null), H = B(0), p = B(!1), T = c !== "none", b = S(() => {
|
|
906
|
+
const { from: D, to: E } = t.state.selection;
|
|
907
907
|
if (t.isActive("orderedList")) return "orderedList";
|
|
908
908
|
if (t.isActive("bulletList")) return "bulletList";
|
|
909
|
-
const P = Math.min(
|
|
910
|
-
if (
|
|
911
|
-
for (let
|
|
912
|
-
const
|
|
913
|
-
if (
|
|
914
|
-
if (
|
|
909
|
+
const P = Math.min(D + 1, E), V = t.state.doc.resolve(P);
|
|
910
|
+
if (V.parent.type.name === "listItem")
|
|
911
|
+
for (let K = V.depth; K > 0; K--) {
|
|
912
|
+
const j = V.node(K);
|
|
913
|
+
if (j.type.name === "orderedList") return "orderedList";
|
|
914
|
+
if (j.type.name === "bulletList") return "bulletList";
|
|
915
915
|
}
|
|
916
916
|
return null;
|
|
917
|
-
}, [t]), M =
|
|
918
|
-
const { from:
|
|
917
|
+
}, [t]), M = S(() => {
|
|
918
|
+
const { from: D, to: E } = t.state.selection;
|
|
919
919
|
if (t.isActive("orderedList") || t.isActive("bulletList")) return;
|
|
920
|
-
for (let
|
|
921
|
-
if (t.isActive("heading", { level:
|
|
922
|
-
const P = Math.min(
|
|
920
|
+
for (let K = 1; K <= 6; K++)
|
|
921
|
+
if (t.isActive("heading", { level: K })) return K;
|
|
922
|
+
const P = Math.min(D + 1, E);
|
|
923
923
|
if (t.state.doc.resolve(P).parent.type.name === "paragraph") return null;
|
|
924
|
-
}, [t]),
|
|
925
|
-
const { from:
|
|
924
|
+
}, [t]), g = S(() => {
|
|
925
|
+
const { from: D, to: E, empty: P } = t.state.selection;
|
|
926
926
|
if (P) return !1;
|
|
927
|
-
const O = t.state.doc.resolve(Math.min(
|
|
928
|
-
|
|
929
|
-
const
|
|
930
|
-
d.current =
|
|
931
|
-
const
|
|
927
|
+
const O = t.state.doc.resolve(Math.min(D + 1, E)).marks();
|
|
928
|
+
m.current = [...O];
|
|
929
|
+
const K = b();
|
|
930
|
+
d.current = K;
|
|
931
|
+
const j = t.getAttributes("textStyle");
|
|
932
932
|
u.current = {
|
|
933
|
-
color:
|
|
934
|
-
fontFamily:
|
|
935
|
-
fontSize:
|
|
933
|
+
color: j.color,
|
|
934
|
+
fontFamily: j.fontFamily,
|
|
935
|
+
fontSize: j.fontSize
|
|
936
936
|
};
|
|
937
|
-
const
|
|
937
|
+
const _ = t.getAttributes("paragraph"), I = t.getAttributes("heading");
|
|
938
938
|
f.current = {
|
|
939
|
-
textAlign:
|
|
940
|
-
lineHeight:
|
|
941
|
-
},
|
|
942
|
-
const
|
|
943
|
-
return
|
|
944
|
-
}, [t,
|
|
939
|
+
textAlign: _.textAlign || I.textAlign,
|
|
940
|
+
lineHeight: _.lineHeight || I.lineHeight
|
|
941
|
+
}, v.current = M();
|
|
942
|
+
const F = O.length > 0, U = !!j.color || !!j.fontFamily || !!j.fontSize, Q = !!f.current.textAlign || !!f.current.lineHeight;
|
|
943
|
+
return F || U || Q || K !== null || v.current !== void 0;
|
|
944
|
+
}, [t, b, M]), o = S(() => {
|
|
945
945
|
if (!d.current) return;
|
|
946
|
-
const
|
|
946
|
+
const D = t.chain().focus();
|
|
947
947
|
switch (d.current) {
|
|
948
948
|
case "orderedList":
|
|
949
|
-
t.isActive("orderedList") || (t.isActive("bulletList") &&
|
|
949
|
+
t.isActive("orderedList") || (t.isActive("bulletList") && D.toggleBulletList(), D.toggleOrderedList().run());
|
|
950
950
|
break;
|
|
951
951
|
case "bulletList":
|
|
952
|
-
t.isActive("bulletList") || (t.isActive("orderedList") &&
|
|
952
|
+
t.isActive("bulletList") || (t.isActive("orderedList") && D.toggleOrderedList(), D.toggleBulletList().run());
|
|
953
953
|
break;
|
|
954
954
|
}
|
|
955
|
-
}, [t]),
|
|
956
|
-
if (
|
|
957
|
-
const
|
|
958
|
-
if (
|
|
959
|
-
|
|
955
|
+
}, [t]), x = S(() => {
|
|
956
|
+
if (v.current === void 0) return;
|
|
957
|
+
const D = t.chain().focus();
|
|
958
|
+
if (v.current === null)
|
|
959
|
+
D.setParagraph().run();
|
|
960
960
|
else {
|
|
961
|
-
const { schema:
|
|
962
|
-
|
|
961
|
+
const { schema: E } = t.state;
|
|
962
|
+
E.nodes.heading && D.setNode("heading", { level: v.current }).run();
|
|
963
963
|
}
|
|
964
|
-
}, [t]),
|
|
965
|
-
let { state:
|
|
966
|
-
if (
|
|
967
|
-
const { schema: O } =
|
|
968
|
-
if (d.current ?
|
|
969
|
-
const
|
|
970
|
-
f.current.textAlign &&
|
|
964
|
+
}, [t]), i = S(() => {
|
|
965
|
+
let { state: D } = t, { from: E, to: P, empty: V } = D.selection;
|
|
966
|
+
if (V) return !1;
|
|
967
|
+
const { schema: O } = D;
|
|
968
|
+
if (d.current ? o() : v.current !== void 0 && x(), f.current) {
|
|
969
|
+
const F = t.chain().focus();
|
|
970
|
+
f.current.textAlign && F.setTextAlign(f.current.textAlign), f.current.lineHeight && F.setLineHeight(f.current.lineHeight), F.run();
|
|
971
971
|
}
|
|
972
|
-
|
|
973
|
-
const
|
|
974
|
-
if (
|
|
975
|
-
return d.current !== null || f.current !== null ||
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
const
|
|
979
|
-
["bold", "italic", "underline", "strike", "superscript", "subscript"].includes(
|
|
972
|
+
D = t.state;
|
|
973
|
+
const K = D.selection;
|
|
974
|
+
if (E = K.from, P = K.to, m.current.length === 0 && !u.current)
|
|
975
|
+
return d.current !== null || f.current !== null || v.current !== void 0;
|
|
976
|
+
const j = D.tr, _ = [];
|
|
977
|
+
if (m.current.forEach((F) => {
|
|
978
|
+
const U = F.type.name;
|
|
979
|
+
["bold", "italic", "underline", "strike", "superscript", "subscript"].includes(U) && _.push(F);
|
|
980
980
|
}), u.current) {
|
|
981
|
-
const { color:
|
|
982
|
-
if (
|
|
983
|
-
const
|
|
984
|
-
|
|
981
|
+
const { color: F, fontFamily: U, fontSize: Q } = u.current, ee = {};
|
|
982
|
+
if (F && (ee.color = F), U && (ee.fontFamily = U), Q && (ee.fontSize = Q), Object.keys(ee).length > 0 && O.marks.textStyle) {
|
|
983
|
+
const we = O.marks.textStyle.create(ee);
|
|
984
|
+
_.push(we);
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
|
-
const
|
|
988
|
-
return
|
|
989
|
-
if (
|
|
990
|
-
const
|
|
987
|
+
const I = m.current.find((F) => F.type.name === "highlight");
|
|
988
|
+
return I && _.push(I), _.length === 0 || (D.doc.nodesBetween(E, P, (F, U) => {
|
|
989
|
+
if (F.isText && U < P && U + F.nodeSize > E) {
|
|
990
|
+
const Q = Math.max(U, E), ee = Math.min(U + F.nodeSize, P);
|
|
991
991
|
["bold", "italic", "underline", "strike", "superscript", "subscript", "textStyle", "highlight"].forEach((ne) => {
|
|
992
992
|
const ue = O.marks[ne];
|
|
993
|
-
ue &&
|
|
994
|
-
}),
|
|
995
|
-
|
|
993
|
+
ue && F.marks.some((ae) => ae.type === ue) && j.removeMark(Q, ee, ue);
|
|
994
|
+
}), _.forEach((ne) => {
|
|
995
|
+
j.addMark(Q, ee, ne);
|
|
996
996
|
});
|
|
997
997
|
}
|
|
998
|
-
}),
|
|
999
|
-
}, [t,
|
|
1000
|
-
|
|
1001
|
-
}, []),
|
|
1002
|
-
if (
|
|
1003
|
-
const { empty:
|
|
1004
|
-
|
|
1005
|
-
}, [t,
|
|
1006
|
-
if (
|
|
998
|
+
}), j.docChanged && t.view.dispatch(j)), !0;
|
|
999
|
+
}, [t, o, x]), l = S(() => {
|
|
1000
|
+
h.current = "none", s("none"), m.current = [], d.current = null, u.current = null, f.current = null, v.current = void 0;
|
|
1001
|
+
}, []), y = S(() => {
|
|
1002
|
+
if (h.current === "none") return;
|
|
1003
|
+
const { empty: D } = t.state.selection;
|
|
1004
|
+
D || (i(), h.current === "single" && l());
|
|
1005
|
+
}, [t, i, l]), $ = S(() => {
|
|
1006
|
+
if (h.current === "single" || h.current === "multiple") {
|
|
1007
1007
|
l();
|
|
1008
1008
|
return;
|
|
1009
1009
|
}
|
|
1010
|
-
|
|
1011
|
-
}, [
|
|
1012
|
-
if (
|
|
1010
|
+
g() && (h.current = "single", s("single"));
|
|
1011
|
+
}, [g, l]), W = S(() => {
|
|
1012
|
+
if (h.current === "multiple") {
|
|
1013
1013
|
l();
|
|
1014
1014
|
return;
|
|
1015
1015
|
}
|
|
1016
|
-
|
|
1017
|
-
}, [
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}, 250) :
|
|
1021
|
-
}, [
|
|
1022
|
-
return
|
|
1023
|
-
|
|
1024
|
-
}, [
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1027
|
-
},
|
|
1028
|
-
!
|
|
1016
|
+
g() && (h.current = "multiple", s("multiple"));
|
|
1017
|
+
}, [g, l]), k = S(() => {
|
|
1018
|
+
r || (H.current++, H.current === 1 ? L.current = window.setTimeout(() => {
|
|
1019
|
+
$(), H.current = 0, L.current = null;
|
|
1020
|
+
}, 250) : H.current === 2 && (L.current && (clearTimeout(L.current), L.current = null), W(), H.current = 0));
|
|
1021
|
+
}, [$, W]);
|
|
1022
|
+
return z(() => {
|
|
1023
|
+
r && (l(), L.current && (clearTimeout(L.current), L.current = null), H.current = 0);
|
|
1024
|
+
}, [r, l]), z(() => {
|
|
1025
|
+
const D = (O) => {
|
|
1026
|
+
h.current === "none" || O.target.closest(".tp-toolbar-btn") || (p.current = !0);
|
|
1027
|
+
}, E = (O) => {
|
|
1028
|
+
!p.current || (p.current = !1, h.current === "none") || O.target.closest(".tp-toolbar-btn") || requestAnimationFrame(() => y());
|
|
1029
1029
|
}, P = (O) => {
|
|
1030
|
-
O.key === "Escape" &&
|
|
1031
|
-
},
|
|
1032
|
-
if (
|
|
1033
|
-
const
|
|
1034
|
-
O.shiftKey &&
|
|
1030
|
+
O.key === "Escape" && h.current !== "none" && l();
|
|
1031
|
+
}, V = (O) => {
|
|
1032
|
+
if (h.current === "none") return;
|
|
1033
|
+
const K = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "PageUp", "PageDown"];
|
|
1034
|
+
O.shiftKey && K.includes(O.key) && y();
|
|
1035
1035
|
};
|
|
1036
|
-
return document.addEventListener("mousedown",
|
|
1037
|
-
document.removeEventListener("mousedown",
|
|
1036
|
+
return document.addEventListener("mousedown", D), document.addEventListener("mouseup", E), document.addEventListener("keydown", P), document.addEventListener("keyup", V), () => {
|
|
1037
|
+
document.removeEventListener("mousedown", D), document.removeEventListener("mouseup", E), document.removeEventListener("keydown", P), document.removeEventListener("keyup", V), L.current && clearTimeout(L.current);
|
|
1038
1038
|
};
|
|
1039
|
-
}, [
|
|
1039
|
+
}, [y, l]), /* @__PURE__ */ w(
|
|
1040
1040
|
"button",
|
|
1041
1041
|
{
|
|
1042
|
-
className: `tp-toolbar-btn${T ? " is-active" : ""}${
|
|
1043
|
-
disabled:
|
|
1044
|
-
title:
|
|
1045
|
-
onClick:
|
|
1042
|
+
className: `tp-toolbar-btn${T ? " is-active" : ""}${c === "multiple" ? " is-locked" : ""}${r ? " is-disabled" : ""}`,
|
|
1043
|
+
disabled: r,
|
|
1044
|
+
title: a("toolbar.formatPainter"),
|
|
1045
|
+
onClick: k,
|
|
1046
1046
|
style: { position: "relative" },
|
|
1047
1047
|
children: [
|
|
1048
|
-
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
1049
|
-
|
|
1048
|
+
/* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be("formatPainter") } }),
|
|
1049
|
+
c === "multiple" && /* @__PURE__ */ e("span", { className: "tp-format-painter-indicator", children: "🔒" })
|
|
1050
1050
|
]
|
|
1051
1051
|
}
|
|
1052
1052
|
);
|
|
1053
|
-
},
|
|
1053
|
+
}, Gt = [
|
|
1054
1054
|
{ type: "decimal", lines: ["1.", "2.", "3."] },
|
|
1055
1055
|
{ type: "decimal-leading-zero", lines: ["01.", "02.", "03."] },
|
|
1056
1056
|
{ type: "lower-roman", lines: ["i.", "ii.", "iii."] },
|
|
1057
1057
|
{ type: "upper-roman", lines: ["I.", "II.", "III."] },
|
|
1058
1058
|
{ type: "lower-alpha", lines: ["a.", "b.", "c."] },
|
|
1059
1059
|
{ type: "upper-alpha", lines: ["A.", "B.", "C."] }
|
|
1060
|
-
],
|
|
1061
|
-
const { t:
|
|
1062
|
-
const { state:
|
|
1063
|
-
let
|
|
1064
|
-
for (let
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1060
|
+
], Xt = ({ def: t, editor: r, active: a, disabled: h }) => {
|
|
1061
|
+
const { t: c } = fe(), [s, m] = A(!1), [d, u] = A(0), f = B(null), v = () => {
|
|
1062
|
+
const { state: i } = r, l = i.selection.$from;
|
|
1063
|
+
let y = null, $ = 0;
|
|
1064
|
+
for (let W = l.depth; W >= 0; W--) {
|
|
1065
|
+
const k = l.node(W);
|
|
1066
|
+
k.type.name === "orderedList" && (y || (y = k), $++);
|
|
1067
1067
|
}
|
|
1068
|
-
return { node:
|
|
1069
|
-
},
|
|
1070
|
-
const { node:
|
|
1071
|
-
return
|
|
1072
|
-
})(),
|
|
1073
|
-
const { node:
|
|
1068
|
+
return { node: y, depth: $ };
|
|
1069
|
+
}, L = (() => {
|
|
1070
|
+
const { node: i, depth: l } = v();
|
|
1071
|
+
return i && i.attrs.listStyleType ? i.attrs.listStyleType : l <= 1 ? "decimal" : l === 2 ? "lower-alpha" : "lower-roman";
|
|
1072
|
+
})(), H = (() => {
|
|
1073
|
+
const { node: i } = v(), l = i == null ? void 0 : i.attrs.start;
|
|
1074
1074
|
return l != null ? Number(l) : 1;
|
|
1075
|
-
})(),
|
|
1076
|
-
const { node:
|
|
1077
|
-
return !!(
|
|
1078
|
-
})(), T =
|
|
1079
|
-
var
|
|
1080
|
-
(
|
|
1081
|
-
}, [t,
|
|
1082
|
-
|
|
1083
|
-
}, [
|
|
1084
|
-
|
|
1085
|
-
}, [
|
|
1086
|
-
const l = parseInt(
|
|
1087
|
-
isNaN(l) ||
|
|
1088
|
-
}, [
|
|
1089
|
-
["Backspace", "Delete", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Tab", "Home", "End"].includes(
|
|
1090
|
-
}, []),
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
}, [
|
|
1094
|
-
return
|
|
1095
|
-
const
|
|
1096
|
-
f.current && !f.current.contains(
|
|
1097
|
-
}, l = () => u((
|
|
1098
|
-
return document.addEventListener("pointerdown",
|
|
1099
|
-
document.removeEventListener("pointerdown",
|
|
1075
|
+
})(), p = (() => {
|
|
1076
|
+
const { node: i } = v();
|
|
1077
|
+
return !!(i != null && i.attrs.reversed);
|
|
1078
|
+
})(), T = S(() => {
|
|
1079
|
+
var i;
|
|
1080
|
+
(i = t.command) == null || i.call(t, r);
|
|
1081
|
+
}, [t, r]), b = S(() => {
|
|
1082
|
+
h || m((i) => !i);
|
|
1083
|
+
}, [h]), M = S((i) => {
|
|
1084
|
+
r.commands.createStyledOrderedList({ listStyleType: i }), r.commands.focus(), m(!1);
|
|
1085
|
+
}, [r]), g = S((i) => {
|
|
1086
|
+
const l = parseInt(i.target.value, 10);
|
|
1087
|
+
isNaN(l) || r.commands.setOrderedListAttrs({ start: l });
|
|
1088
|
+
}, [r]), o = S((i) => {
|
|
1089
|
+
["Backspace", "Delete", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Tab", "Home", "End"].includes(i.key) || i.key === "-" || i.key === "Minus" || i.key >= "0" && i.key <= "9" || i.ctrlKey || i.metaKey || i.preventDefault();
|
|
1090
|
+
}, []), x = S(() => {
|
|
1091
|
+
const i = !p;
|
|
1092
|
+
r.commands.setOrderedListAttrs({ reversed: i || null });
|
|
1093
|
+
}, [r, p]);
|
|
1094
|
+
return z(() => {
|
|
1095
|
+
const i = (y) => {
|
|
1096
|
+
f.current && !f.current.contains(y.target) && m(!1);
|
|
1097
|
+
}, l = () => u((y) => y + 1);
|
|
1098
|
+
return document.addEventListener("pointerdown", i), r.on("transaction", l), () => {
|
|
1099
|
+
document.removeEventListener("pointerdown", i), r.off("transaction", l);
|
|
1100
1100
|
};
|
|
1101
|
-
}, [
|
|
1101
|
+
}, [r]), /* @__PURE__ */ w("div", { ref: f, className: "tp-toolbar-split-btn", children: [
|
|
1102
1102
|
/* @__PURE__ */ e(
|
|
1103
1103
|
"button",
|
|
1104
1104
|
{
|
|
1105
|
-
className: `tp-toolbar-split-main${
|
|
1106
|
-
title:
|
|
1107
|
-
disabled:
|
|
1108
|
-
onMouseDown: (
|
|
1105
|
+
className: `tp-toolbar-split-main${a ? " is-active" : ""}`,
|
|
1106
|
+
title: c(t.titleKey),
|
|
1107
|
+
disabled: h,
|
|
1108
|
+
onMouseDown: (i) => i.preventDefault(),
|
|
1109
1109
|
onClick: T,
|
|
1110
|
-
children: /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
1110
|
+
children: /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be(t.name) } })
|
|
1111
1111
|
}
|
|
1112
1112
|
),
|
|
1113
1113
|
/* @__PURE__ */ e(
|
|
1114
1114
|
"button",
|
|
1115
1115
|
{
|
|
1116
1116
|
className: `tp-toolbar-split-arrow${s ? " is-open" : ""}`,
|
|
1117
|
-
disabled:
|
|
1118
|
-
onMouseDown: (
|
|
1119
|
-
onClick:
|
|
1117
|
+
disabled: h,
|
|
1118
|
+
onMouseDown: (i) => i.preventDefault(),
|
|
1119
|
+
onClick: b,
|
|
1120
1120
|
children: "▾"
|
|
1121
1121
|
}
|
|
1122
1122
|
),
|
|
1123
|
-
s && /* @__PURE__ */
|
|
1124
|
-
/* @__PURE__ */ e("div", { className: "tp-ol-style-grid", children:
|
|
1123
|
+
s && /* @__PURE__ */ w("div", { className: "tp-ol-panel", children: [
|
|
1124
|
+
/* @__PURE__ */ e("div", { className: "tp-ol-style-grid", children: Gt.map((i) => /* @__PURE__ */ e(
|
|
1125
1125
|
"button",
|
|
1126
1126
|
{
|
|
1127
|
-
className: `tp-ol-style-item${
|
|
1127
|
+
className: `tp-ol-style-item${L === i.type ? " is-active" : ""}`,
|
|
1128
1128
|
onMouseDown: (l) => l.preventDefault(),
|
|
1129
|
-
onClick: () => M(
|
|
1130
|
-
children:
|
|
1129
|
+
onClick: () => M(i.type),
|
|
1130
|
+
children: i.lines.map((l, y) => /* @__PURE__ */ w("span", { className: "tp-ol-style-line", children: [
|
|
1131
1131
|
/* @__PURE__ */ e("span", { className: "tp-ol-style-marker", children: l }),
|
|
1132
1132
|
/* @__PURE__ */ e("span", { className: "tp-ol-style-bar" })
|
|
1133
|
-
] },
|
|
1133
|
+
] }, y))
|
|
1134
1134
|
},
|
|
1135
|
-
|
|
1135
|
+
i.type
|
|
1136
1136
|
)) }),
|
|
1137
|
-
/* @__PURE__ */
|
|
1138
|
-
/* @__PURE__ */ e("div", { className: "tp-ol-prop-title", children:
|
|
1139
|
-
/* @__PURE__ */
|
|
1140
|
-
/* @__PURE__ */ e("label", { children:
|
|
1137
|
+
/* @__PURE__ */ w("div", { className: "tp-ol-properties", children: [
|
|
1138
|
+
/* @__PURE__ */ e("div", { className: "tp-ol-prop-title", children: c("orderedList.properties") }),
|
|
1139
|
+
/* @__PURE__ */ w("div", { className: "tp-ol-prop-row", children: [
|
|
1140
|
+
/* @__PURE__ */ e("label", { children: c("orderedList.startAt") }),
|
|
1141
1141
|
/* @__PURE__ */ e(
|
|
1142
1142
|
"input",
|
|
1143
1143
|
{
|
|
1144
1144
|
type: "number",
|
|
1145
1145
|
className: "tp-ol-start-input",
|
|
1146
|
-
defaultValue:
|
|
1147
|
-
onChange:
|
|
1148
|
-
onKeyDown:
|
|
1149
|
-
onMouseDown: (
|
|
1146
|
+
defaultValue: H,
|
|
1147
|
+
onChange: g,
|
|
1148
|
+
onKeyDown: o,
|
|
1149
|
+
onMouseDown: (i) => i.stopPropagation()
|
|
1150
1150
|
}
|
|
1151
1151
|
)
|
|
1152
1152
|
] }),
|
|
1153
|
-
/* @__PURE__ */
|
|
1154
|
-
/* @__PURE__ */ e("label", { children:
|
|
1153
|
+
/* @__PURE__ */ w("div", { className: "tp-ol-prop-row", children: [
|
|
1154
|
+
/* @__PURE__ */ e("label", { children: c("orderedList.reversed") }),
|
|
1155
1155
|
/* @__PURE__ */ e(
|
|
1156
1156
|
"button",
|
|
1157
1157
|
{
|
|
1158
|
-
className: `tp-ol-toggle${
|
|
1159
|
-
onMouseDown: (
|
|
1160
|
-
onClick:
|
|
1158
|
+
className: `tp-ol-toggle${p ? " is-on" : ""}`,
|
|
1159
|
+
onMouseDown: (i) => i.preventDefault(),
|
|
1160
|
+
onClick: x
|
|
1161
1161
|
}
|
|
1162
1162
|
)
|
|
1163
1163
|
] })
|
|
1164
1164
|
] })
|
|
1165
1165
|
] })
|
|
1166
1166
|
] });
|
|
1167
|
-
},
|
|
1167
|
+
}, Zt = [
|
|
1168
1168
|
{ type: "disc", marker: "●" },
|
|
1169
1169
|
{ type: "circle", marker: "○" },
|
|
1170
1170
|
{ type: "square", marker: "■" },
|
|
1171
1171
|
{ type: "none", marker: "—" }
|
|
1172
|
-
],
|
|
1173
|
-
const { t:
|
|
1174
|
-
const { state: T } =
|
|
1175
|
-
let M = null,
|
|
1176
|
-
for (let
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1172
|
+
], Qt = ({ def: t, editor: r, active: a, disabled: h }) => {
|
|
1173
|
+
const { t: c } = fe(), [s, m] = A(!1), [d, u] = A(0), f = B(null), v = (() => {
|
|
1174
|
+
const { state: T } = r, b = T.selection.$from;
|
|
1175
|
+
let M = null, g = 0;
|
|
1176
|
+
for (let o = b.depth; o >= 0; o--) {
|
|
1177
|
+
const x = b.node(o);
|
|
1178
|
+
x.type.name === "bulletList" && (M || (M = x), g++);
|
|
1179
1179
|
}
|
|
1180
|
-
return M && M.attrs.listStyleType ? M.attrs.listStyleType :
|
|
1181
|
-
})(),
|
|
1180
|
+
return M && M.attrs.listStyleType ? M.attrs.listStyleType : g <= 1 ? "disc" : g === 2 ? "circle" : "square";
|
|
1181
|
+
})(), L = S(() => {
|
|
1182
1182
|
var T;
|
|
1183
|
-
(T = t.command) == null || T.call(t,
|
|
1184
|
-
}, [t,
|
|
1185
|
-
|
|
1186
|
-
}, [
|
|
1187
|
-
|
|
1188
|
-
}, [
|
|
1189
|
-
return
|
|
1183
|
+
(T = t.command) == null || T.call(t, r);
|
|
1184
|
+
}, [t, r]), H = S(() => {
|
|
1185
|
+
h || m((T) => !T);
|
|
1186
|
+
}, [h]), p = S((T) => {
|
|
1187
|
+
r.commands.createStyledBulletList({ listStyleType: T }), r.commands.focus(), m(!1);
|
|
1188
|
+
}, [r]);
|
|
1189
|
+
return z(() => {
|
|
1190
1190
|
const T = (M) => {
|
|
1191
|
-
f.current && !f.current.contains(M.target) &&
|
|
1192
|
-
},
|
|
1193
|
-
return document.addEventListener("pointerdown", T),
|
|
1194
|
-
document.removeEventListener("pointerdown", T),
|
|
1191
|
+
f.current && !f.current.contains(M.target) && m(!1);
|
|
1192
|
+
}, b = () => u((M) => M + 1);
|
|
1193
|
+
return document.addEventListener("pointerdown", T), r.on("transaction", b), () => {
|
|
1194
|
+
document.removeEventListener("pointerdown", T), r.off("transaction", b);
|
|
1195
1195
|
};
|
|
1196
|
-
}, [
|
|
1196
|
+
}, [r]), /* @__PURE__ */ w("div", { ref: f, className: "tp-toolbar-split-btn", children: [
|
|
1197
1197
|
/* @__PURE__ */ e(
|
|
1198
1198
|
"button",
|
|
1199
1199
|
{
|
|
1200
|
-
className: `tp-toolbar-split-main${
|
|
1201
|
-
title:
|
|
1202
|
-
disabled:
|
|
1200
|
+
className: `tp-toolbar-split-main${a ? " is-active" : ""}`,
|
|
1201
|
+
title: c(t.titleKey),
|
|
1202
|
+
disabled: h,
|
|
1203
1203
|
onMouseDown: (T) => T.preventDefault(),
|
|
1204
|
-
onClick:
|
|
1205
|
-
children: /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html:
|
|
1204
|
+
onClick: L,
|
|
1205
|
+
children: /* @__PURE__ */ e("span", { className: "tp-toolbar-icon", dangerouslySetInnerHTML: { __html: be(t.name) } })
|
|
1206
1206
|
}
|
|
1207
1207
|
),
|
|
1208
1208
|
/* @__PURE__ */ e(
|
|
1209
1209
|
"button",
|
|
1210
1210
|
{
|
|
1211
1211
|
className: `tp-toolbar-split-arrow${s ? " is-open" : ""}`,
|
|
1212
|
-
disabled:
|
|
1212
|
+
disabled: h,
|
|
1213
1213
|
onMouseDown: (T) => T.preventDefault(),
|
|
1214
|
-
onClick:
|
|
1214
|
+
onClick: H,
|
|
1215
1215
|
children: "▾"
|
|
1216
1216
|
}
|
|
1217
1217
|
),
|
|
1218
|
-
s && /* @__PURE__ */ e("div", { className: "tp-ol-panel", children: /* @__PURE__ */ e("div", { className: "tp-ol-style-grid tp-ul-style-grid", children:
|
|
1218
|
+
s && /* @__PURE__ */ e("div", { className: "tp-ol-panel", children: /* @__PURE__ */ e("div", { className: "tp-ol-style-grid tp-ul-style-grid", children: Zt.map((T) => /* @__PURE__ */ e(
|
|
1219
1219
|
"button",
|
|
1220
1220
|
{
|
|
1221
|
-
className: `tp-ol-style-item${
|
|
1222
|
-
onMouseDown: (
|
|
1223
|
-
onClick: () =>
|
|
1224
|
-
children: [0, 1, 2].map((
|
|
1221
|
+
className: `tp-ol-style-item${v === T.type ? " is-active" : ""}`,
|
|
1222
|
+
onMouseDown: (b) => b.preventDefault(),
|
|
1223
|
+
onClick: () => p(T.type),
|
|
1224
|
+
children: [0, 1, 2].map((b) => /* @__PURE__ */ w("span", { className: "tp-ol-style-line", children: [
|
|
1225
1225
|
/* @__PURE__ */ e("span", { className: "tp-ul-style-marker", children: T.marker }),
|
|
1226
1226
|
/* @__PURE__ */ e("span", { className: "tp-ol-style-bar" })
|
|
1227
|
-
] },
|
|
1227
|
+
] }, b))
|
|
1228
1228
|
},
|
|
1229
1229
|
T.type
|
|
1230
1230
|
)) }) })
|
|
1231
1231
|
] });
|
|
1232
1232
|
};
|
|
1233
|
-
function
|
|
1233
|
+
function ct(t) {
|
|
1234
1234
|
return t === "meta-left" ? "tp-toolbar-capsule tp-toolbar-capsule-left" : t === "meta-io" ? "tp-toolbar-capsule tp-toolbar-capsule-io" : t === "meta-view" ? "tp-toolbar-capsule tp-toolbar-capsule-view" : "";
|
|
1235
1235
|
}
|
|
1236
|
-
const
|
|
1236
|
+
const en = ({
|
|
1237
1237
|
items: t,
|
|
1238
|
-
manager:
|
|
1239
|
-
activeStates:
|
|
1240
|
-
disabledStates:
|
|
1241
|
-
viewMode:
|
|
1238
|
+
manager: r,
|
|
1239
|
+
activeStates: a,
|
|
1240
|
+
disabledStates: h,
|
|
1241
|
+
viewMode: c = "normal",
|
|
1242
1242
|
onToggleViewMode: s,
|
|
1243
|
-
onToolbarClick:
|
|
1243
|
+
onToolbarClick: m,
|
|
1244
1244
|
prepend: d,
|
|
1245
1245
|
append: u
|
|
1246
1246
|
}) => {
|
|
1247
|
-
const f = () =>
|
|
1248
|
-
|
|
1247
|
+
const f = () => r.getEditor(), v = B(null);
|
|
1248
|
+
z(() => wt(v.current, { getEditor: f }), []);
|
|
1249
|
+
const L = S((o) => {
|
|
1250
|
+
if (o === "getHTML") {
|
|
1249
1251
|
s == null || s("html");
|
|
1250
1252
|
return;
|
|
1251
1253
|
}
|
|
1252
|
-
if (
|
|
1254
|
+
if (o === "getJSON") {
|
|
1253
1255
|
s == null || s("json");
|
|
1254
1256
|
return;
|
|
1255
1257
|
}
|
|
1256
|
-
|
|
1257
|
-
}, [s,
|
|
1258
|
-
function
|
|
1259
|
-
const
|
|
1260
|
-
if (!
|
|
1261
|
-
const
|
|
1262
|
-
return
|
|
1258
|
+
m == null || m(o);
|
|
1259
|
+
}, [s, m]), H = (o) => c !== "normal" ? o === "getHTML" ? c === "html" : o === "getJSON" ? c === "json" : !1 : o === "getHTML" || o === "getJSON" ? !1 : a[o] ?? !1, p = (o) => c !== "normal" ? o !== "getHTML" && o !== "getJSON" : h[o] ?? !1, T = Me(() => vt(t), [t]), b = T.filter((o) => o.category === "meta-left" || o.category === "content"), M = T.filter((o) => o.category === "meta-io" || o.category === "meta-view");
|
|
1260
|
+
function g(o) {
|
|
1261
|
+
const x = yt(o);
|
|
1262
|
+
if (!x) return null;
|
|
1263
|
+
const i = f();
|
|
1264
|
+
return o === "imageUpload" ? /* @__PURE__ */ e(Ut, { def: x, editor: i, manager: r, active: H(o), disabled: p(o) }, o) : o === "video" ? /* @__PURE__ */ e(Kt, { def: x, editor: i, active: H(o), disabled: p(o) }, o) : o === "insertTable" ? /* @__PURE__ */ e(qt, { def: x, editor: i, active: H(o), disabled: p(o) }, o) : o === "formatPainter" ? /* @__PURE__ */ e(Yt, { editor: i, disabled: p(o) }, o) : o === "orderedList" ? /* @__PURE__ */ e(Xt, { def: x, editor: i, active: H(o), disabled: p(o) }, o) : o === "bulletList" ? /* @__PURE__ */ e(Qt, { def: x, editor: i, active: H(o), disabled: p(o) }, o) : x.type === "button" ? /* @__PURE__ */ e(Pt, { def: x, editor: i, active: H(o), disabled: p(o), onCustomClick: L }, o) : x.type === "dropdown" ? /* @__PURE__ */ e(It, { def: x, editor: i, active: H(o), disabled: p(o), onCustomClick: L }, o) : x.type === "color-picker" ? /* @__PURE__ */ e(Wt, { def: x, editor: i, disabled: p(o) }, o) : null;
|
|
1263
1265
|
}
|
|
1264
|
-
return /* @__PURE__ */
|
|
1266
|
+
return /* @__PURE__ */ w("div", { className: "tp-toolbar", ref: v, children: [
|
|
1265
1267
|
d,
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
] }, `g-${
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
/* @__PURE__ */ e("div", { className:
|
|
1273
|
-
] }, `r-${
|
|
1268
|
+
b.map((o, x) => /* @__PURE__ */ w(tt.Fragment, { children: [
|
|
1269
|
+
x > 0 && /* @__PURE__ */ e(it, {}),
|
|
1270
|
+
o.category !== "content" ? /* @__PURE__ */ e("div", { className: ct(o.category), children: o.items.map(g) }) : /* @__PURE__ */ e(nt, { children: o.items.map(g) })
|
|
1271
|
+
] }, `g-${x}`)),
|
|
1272
|
+
M.length > 0 && /* @__PURE__ */ e("div", { className: "tp-toolbar-right", children: M.map((o, x) => /* @__PURE__ */ w(tt.Fragment, { children: [
|
|
1273
|
+
x > 0 && /* @__PURE__ */ e(it, {}),
|
|
1274
|
+
/* @__PURE__ */ e("div", { className: ct(o.category), children: o.items.map(g) })
|
|
1275
|
+
] }, `r-${x}`)) }),
|
|
1274
1276
|
u
|
|
1275
1277
|
] });
|
|
1276
|
-
},
|
|
1278
|
+
}, tn = ({
|
|
1277
1279
|
editor: t,
|
|
1278
|
-
visible:
|
|
1279
|
-
position:
|
|
1280
|
-
targetCell:
|
|
1281
|
-
onVisibleChange:
|
|
1280
|
+
visible: r,
|
|
1281
|
+
position: a,
|
|
1282
|
+
targetCell: h,
|
|
1283
|
+
onVisibleChange: c,
|
|
1282
1284
|
onAction: s
|
|
1283
1285
|
}) => {
|
|
1284
|
-
const
|
|
1285
|
-
if (!
|
|
1286
|
-
const
|
|
1287
|
-
return
|
|
1288
|
-
x:
|
|
1289
|
-
y:
|
|
1290
|
-
width:
|
|
1291
|
-
height:
|
|
1286
|
+
const m = B(null), [d, u] = A({ x: 0, y: 0 }), [f, v] = A(0), [L, H] = A(!1), [p, T] = A(!1), b = B({ x: 0, y: 0 }), M = Le.getInstance(), g = (i) => M.t(i), o = S((i) => {
|
|
1287
|
+
if (!m.current) return null;
|
|
1288
|
+
const l = m.current, y = l.getBoundingClientRect(), $ = l.offsetHeight - l.clientHeight, W = Math.max(y.height, l.scrollHeight + $);
|
|
1289
|
+
return y.width === 0 || W === 0 ? null : bt({
|
|
1290
|
+
x: i.x,
|
|
1291
|
+
y: i.y,
|
|
1292
|
+
width: y.width,
|
|
1293
|
+
height: W
|
|
1292
1294
|
});
|
|
1293
1295
|
}, []);
|
|
1294
|
-
|
|
1295
|
-
if (
|
|
1296
|
-
if (u({ x:
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1299
|
-
x:
|
|
1300
|
-
y:
|
|
1296
|
+
z(() => {
|
|
1297
|
+
if (r) {
|
|
1298
|
+
if (u({ x: a.x, y: a.y }), h) {
|
|
1299
|
+
const i = h.getBoundingClientRect();
|
|
1300
|
+
b.current = {
|
|
1301
|
+
x: a.x - i.left,
|
|
1302
|
+
y: a.y - i.top
|
|
1301
1303
|
};
|
|
1302
1304
|
}
|
|
1303
|
-
|
|
1305
|
+
H(t.can().mergeCells()), T(t.can().splitCell());
|
|
1304
1306
|
}
|
|
1305
|
-
}, [
|
|
1306
|
-
if (!
|
|
1307
|
-
const
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
}, [o, d.x, d.y]), K(() => {
|
|
1317
|
-
const r = () => {
|
|
1318
|
-
if (!o || !p) return;
|
|
1319
|
-
const g = p.getBoundingClientRect();
|
|
1320
|
-
if (g.bottom < 0 || g.top > window.innerHeight) {
|
|
1321
|
-
i(!1);
|
|
1307
|
+
}, [r, a, h, t]), pt(() => {
|
|
1308
|
+
if (!r || !m.current) return;
|
|
1309
|
+
const i = o(d);
|
|
1310
|
+
i && ((i.x !== d.x || i.y !== d.y) && u({ x: i.x, y: i.y }), v(i.maxHeight));
|
|
1311
|
+
}, [r, d, o]), z(() => {
|
|
1312
|
+
var W, k;
|
|
1313
|
+
const i = () => {
|
|
1314
|
+
if (!r || !h) return;
|
|
1315
|
+
const D = h.getBoundingClientRect(), E = xt();
|
|
1316
|
+
if (D.bottom < E.top || D.top > E.bottom) {
|
|
1317
|
+
c(!1);
|
|
1322
1318
|
return;
|
|
1323
1319
|
}
|
|
1324
|
-
const
|
|
1325
|
-
x:
|
|
1326
|
-
y:
|
|
1327
|
-
},
|
|
1328
|
-
u({ x:
|
|
1329
|
-
},
|
|
1330
|
-
|
|
1320
|
+
const P = {
|
|
1321
|
+
x: D.left + b.current.x,
|
|
1322
|
+
y: D.top + b.current.y
|
|
1323
|
+
}, V = o(P);
|
|
1324
|
+
V && (u({ x: V.x, y: V.y }), v(V.maxHeight));
|
|
1325
|
+
}, l = (D) => {
|
|
1326
|
+
const E = D.target;
|
|
1327
|
+
return !!E && typeof E.closest == "function" && !!E.closest(".tp-table-context-menu");
|
|
1328
|
+
}, y = (D) => {
|
|
1329
|
+
r && !l(D) && i();
|
|
1330
|
+
}, $ = () => {
|
|
1331
|
+
r && i();
|
|
1331
1332
|
};
|
|
1332
|
-
return window.addEventListener("scroll",
|
|
1333
|
-
|
|
1333
|
+
return window.addEventListener("scroll", y, !0), window.addEventListener("wheel", y, { passive: !0 }), window.addEventListener("resize", $), (W = window.visualViewport) == null || W.addEventListener("resize", $), (k = window.visualViewport) == null || k.addEventListener("scroll", $), () => {
|
|
1334
|
+
var D, E;
|
|
1335
|
+
window.removeEventListener("scroll", y, !0), window.removeEventListener("wheel", y), window.removeEventListener("resize", $), (D = window.visualViewport) == null || D.removeEventListener("resize", $), (E = window.visualViewport) == null || E.removeEventListener("scroll", $);
|
|
1334
1336
|
};
|
|
1335
|
-
}, [
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
},
|
|
1339
|
-
|
|
1337
|
+
}, [r, h, c, o]), z(() => {
|
|
1338
|
+
const i = (y) => {
|
|
1339
|
+
m.current && !m.current.contains(y.target) && c(!1);
|
|
1340
|
+
}, l = (y) => {
|
|
1341
|
+
y.key === "Escape" && c(!1);
|
|
1340
1342
|
};
|
|
1341
|
-
return document.addEventListener("click",
|
|
1342
|
-
document.removeEventListener("click",
|
|
1343
|
+
return document.addEventListener("click", i), document.addEventListener("keydown", l), () => {
|
|
1344
|
+
document.removeEventListener("click", i), document.removeEventListener("keydown", l);
|
|
1343
1345
|
};
|
|
1344
|
-
}, [
|
|
1345
|
-
const
|
|
1346
|
-
s(
|
|
1347
|
-
}, [s,
|
|
1348
|
-
return
|
|
1349
|
-
/* @__PURE__ */
|
|
1346
|
+
}, [c]);
|
|
1347
|
+
const x = S((i) => {
|
|
1348
|
+
s(i), c(!1);
|
|
1349
|
+
}, [s, c]);
|
|
1350
|
+
return r ? _e(
|
|
1351
|
+
/* @__PURE__ */ w(
|
|
1350
1352
|
"div",
|
|
1351
1353
|
{
|
|
1352
|
-
ref:
|
|
1354
|
+
ref: m,
|
|
1353
1355
|
className: "tp-table-context-menu",
|
|
1354
|
-
style: {
|
|
1355
|
-
|
|
1356
|
+
style: {
|
|
1357
|
+
left: d.x,
|
|
1358
|
+
top: d.y,
|
|
1359
|
+
maxHeight: f > 0 ? f : void 0
|
|
1360
|
+
},
|
|
1361
|
+
onClick: (i) => i.stopPropagation(),
|
|
1356
1362
|
children: [
|
|
1357
|
-
/* @__PURE__ */
|
|
1358
|
-
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () =>
|
|
1359
|
-
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () =>
|
|
1360
|
-
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () =>
|
|
1361
|
-
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () =>
|
|
1363
|
+
/* @__PURE__ */ w("div", { className: "tp-table-menu-section", children: [
|
|
1364
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("addRowBefore"), children: g("table.addRowBefore") }),
|
|
1365
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("addRowAfter"), children: g("table.addRowAfter") }),
|
|
1366
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("addColumnBefore"), children: g("table.addColumnBefore") }),
|
|
1367
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("addColumnAfter"), children: g("table.addColumnAfter") })
|
|
1362
1368
|
] }),
|
|
1363
1369
|
/* @__PURE__ */ e("div", { className: "tp-table-menu-divider" }),
|
|
1364
|
-
/* @__PURE__ */
|
|
1365
|
-
/* @__PURE__ */ e("div", { className:
|
|
1366
|
-
/* @__PURE__ */ e("div", { className:
|
|
1370
|
+
/* @__PURE__ */ w("div", { className: "tp-table-menu-section", children: [
|
|
1371
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("selectRow"), children: g("table.selectRow") }),
|
|
1372
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("selectColumn"), children: g("table.selectColumn") }),
|
|
1373
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("selectTable"), children: g("table.selectTable") }),
|
|
1374
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("extendSelection"), children: g("table.extendSelection") })
|
|
1367
1375
|
] }),
|
|
1368
1376
|
/* @__PURE__ */ e("div", { className: "tp-table-menu-divider" }),
|
|
1369
|
-
/* @__PURE__ */
|
|
1370
|
-
/* @__PURE__ */ e("div", { className:
|
|
1371
|
-
/* @__PURE__ */ e("div", { className:
|
|
1372
|
-
/* @__PURE__ */ e("div", { className: "tp-table-menu-item tp-table-menu-item-danger", onClick: () => n("deleteTable"), children: w("table.deleteTable") })
|
|
1377
|
+
/* @__PURE__ */ w("div", { className: "tp-table-menu-section", children: [
|
|
1378
|
+
/* @__PURE__ */ e("div", { className: `tp-table-menu-item${L ? "" : " disabled"}`, onClick: () => L && x("mergeCells"), children: g("table.mergeCells") }),
|
|
1379
|
+
/* @__PURE__ */ e("div", { className: `tp-table-menu-item${p ? "" : " disabled"}`, onClick: () => p && x("splitCell"), children: g("table.splitCell") })
|
|
1373
1380
|
] }),
|
|
1374
1381
|
/* @__PURE__ */ e("div", { className: "tp-table-menu-divider" }),
|
|
1375
|
-
/* @__PURE__ */
|
|
1376
|
-
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () =>
|
|
1377
|
-
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () =>
|
|
1382
|
+
/* @__PURE__ */ w("div", { className: "tp-table-menu-section", children: [
|
|
1383
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("deleteRow"), children: g("table.deleteRow") }),
|
|
1384
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("deleteColumn"), children: g("table.deleteColumn") }),
|
|
1385
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item tp-table-menu-item-danger", onClick: () => x("deleteTable"), children: g("table.deleteTable") })
|
|
1386
|
+
] }),
|
|
1387
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-divider" }),
|
|
1388
|
+
/* @__PURE__ */ w("div", { className: "tp-table-menu-section", children: [
|
|
1389
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("tableSettings"), children: g("table.tableSettings") }),
|
|
1390
|
+
/* @__PURE__ */ e("div", { className: "tp-table-menu-item", onClick: () => x("cellSettings"), children: g("table.cellSettings") })
|
|
1378
1391
|
] })
|
|
1379
1392
|
]
|
|
1380
1393
|
}
|
|
1381
1394
|
),
|
|
1382
1395
|
document.body
|
|
1383
1396
|
) : null;
|
|
1384
|
-
},
|
|
1397
|
+
}, nn = [
|
|
1385
1398
|
"#000000",
|
|
1386
1399
|
"#1a1a1a",
|
|
1387
1400
|
"#333333",
|
|
@@ -1404,7 +1417,7 @@ const Ft = ({
|
|
|
1404
1417
|
"#cc0000",
|
|
1405
1418
|
"#e06666",
|
|
1406
1419
|
"#660000"
|
|
1407
|
-
],
|
|
1420
|
+
], on = [
|
|
1408
1421
|
"#ffffff",
|
|
1409
1422
|
"#f8f9fa",
|
|
1410
1423
|
"#f1f3f4",
|
|
@@ -1428,124 +1441,124 @@ const Ft = ({
|
|
|
1428
1441
|
"#f5aca6",
|
|
1429
1442
|
"#f28b82"
|
|
1430
1443
|
];
|
|
1431
|
-
function
|
|
1432
|
-
const
|
|
1433
|
-
return
|
|
1444
|
+
function rn(t) {
|
|
1445
|
+
const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
|
|
1446
|
+
return r ? { r: parseInt(r[1], 16), g: parseInt(r[2], 16), b: parseInt(r[3], 16) } : null;
|
|
1434
1447
|
}
|
|
1435
|
-
function
|
|
1436
|
-
return "#" + [t,
|
|
1437
|
-
const
|
|
1438
|
-
return
|
|
1448
|
+
function Ze(t, r, a) {
|
|
1449
|
+
return "#" + [t, r, a].map((h) => {
|
|
1450
|
+
const c = Math.round(Math.max(0, Math.min(255, h))).toString(16);
|
|
1451
|
+
return c.length === 1 ? "0" + c : c;
|
|
1439
1452
|
}).join("");
|
|
1440
1453
|
}
|
|
1441
|
-
function
|
|
1442
|
-
t /= 255,
|
|
1443
|
-
const
|
|
1444
|
-
let s = 0,
|
|
1445
|
-
const d = (
|
|
1446
|
-
if (
|
|
1447
|
-
const u =
|
|
1448
|
-
switch (
|
|
1454
|
+
function Qe(t, r, a) {
|
|
1455
|
+
t /= 255, r /= 255, a /= 255;
|
|
1456
|
+
const h = Math.max(t, r, a), c = Math.min(t, r, a);
|
|
1457
|
+
let s = 0, m = 0;
|
|
1458
|
+
const d = (h + c) / 2;
|
|
1459
|
+
if (h !== c) {
|
|
1460
|
+
const u = h - c;
|
|
1461
|
+
switch (m = d > 0.5 ? u / (2 - h - c) : u / (h + c), h) {
|
|
1449
1462
|
case t:
|
|
1450
|
-
s = ((
|
|
1463
|
+
s = ((r - a) / u + (r < a ? 6 : 0)) / 6;
|
|
1451
1464
|
break;
|
|
1452
|
-
case
|
|
1453
|
-
s = ((
|
|
1465
|
+
case r:
|
|
1466
|
+
s = ((a - t) / u + 2) / 6;
|
|
1454
1467
|
break;
|
|
1455
|
-
case
|
|
1456
|
-
s = ((t -
|
|
1468
|
+
case a:
|
|
1469
|
+
s = ((t - r) / u + 4) / 6;
|
|
1457
1470
|
break;
|
|
1458
1471
|
}
|
|
1459
1472
|
}
|
|
1460
|
-
return { h: Math.round(s * 360), s: Math.round(
|
|
1473
|
+
return { h: Math.round(s * 360), s: Math.round(m * 100), l: Math.round(d * 100) };
|
|
1461
1474
|
}
|
|
1462
|
-
function
|
|
1463
|
-
t /= 255,
|
|
1464
|
-
const
|
|
1475
|
+
function et(t, r, a) {
|
|
1476
|
+
t /= 255, r /= 255, a /= 255;
|
|
1477
|
+
const h = Math.max(t, r, a), c = Math.min(t, r, a);
|
|
1465
1478
|
let s = 0;
|
|
1466
|
-
const
|
|
1467
|
-
if (
|
|
1468
|
-
switch (
|
|
1479
|
+
const m = h, d = h - c, u = h === 0 ? 0 : d / h;
|
|
1480
|
+
if (h !== c)
|
|
1481
|
+
switch (h) {
|
|
1469
1482
|
case t:
|
|
1470
|
-
s = ((
|
|
1483
|
+
s = ((r - a) / d + (r < a ? 6 : 0)) / 6;
|
|
1471
1484
|
break;
|
|
1472
|
-
case
|
|
1473
|
-
s = ((
|
|
1485
|
+
case r:
|
|
1486
|
+
s = ((a - t) / d + 2) / 6;
|
|
1474
1487
|
break;
|
|
1475
|
-
case
|
|
1476
|
-
s = ((t -
|
|
1488
|
+
case a:
|
|
1489
|
+
s = ((t - r) / d + 4) / 6;
|
|
1477
1490
|
break;
|
|
1478
1491
|
}
|
|
1479
|
-
return { h: Math.round(s * 360), s: Math.round(u * 100), v: Math.round(
|
|
1492
|
+
return { h: Math.round(s * 360), s: Math.round(u * 100), v: Math.round(m * 100) };
|
|
1480
1493
|
}
|
|
1481
|
-
function
|
|
1482
|
-
|
|
1483
|
-
const
|
|
1484
|
-
let u = 0, f = 0,
|
|
1485
|
-
switch (
|
|
1494
|
+
function ln(t, r, a) {
|
|
1495
|
+
r /= 100, a /= 100;
|
|
1496
|
+
const h = Math.floor(t / 60) % 6, c = t / 60 - Math.floor(t / 60), s = a * (1 - r), m = a * (1 - c * r), d = a * (1 - (1 - c) * r);
|
|
1497
|
+
let u = 0, f = 0, v = 0;
|
|
1498
|
+
switch (h) {
|
|
1486
1499
|
case 0:
|
|
1487
|
-
u =
|
|
1500
|
+
u = a, f = d, v = s;
|
|
1488
1501
|
break;
|
|
1489
1502
|
case 1:
|
|
1490
|
-
u =
|
|
1503
|
+
u = m, f = a, v = s;
|
|
1491
1504
|
break;
|
|
1492
1505
|
case 2:
|
|
1493
|
-
u = s, f =
|
|
1506
|
+
u = s, f = a, v = d;
|
|
1494
1507
|
break;
|
|
1495
1508
|
case 3:
|
|
1496
|
-
u = s, f =
|
|
1509
|
+
u = s, f = m, v = a;
|
|
1497
1510
|
break;
|
|
1498
1511
|
case 4:
|
|
1499
|
-
u = d, f = s,
|
|
1512
|
+
u = d, f = s, v = a;
|
|
1500
1513
|
break;
|
|
1501
1514
|
case 5:
|
|
1502
|
-
u =
|
|
1515
|
+
u = a, f = s, v = m;
|
|
1503
1516
|
break;
|
|
1504
1517
|
}
|
|
1505
|
-
return { r: Math.round(u * 255), g: Math.round(f * 255), b: Math.round(
|
|
1518
|
+
return { r: Math.round(u * 255), g: Math.round(f * 255), b: Math.round(v * 255) };
|
|
1506
1519
|
}
|
|
1507
|
-
function
|
|
1508
|
-
t /= 360,
|
|
1509
|
-
let
|
|
1510
|
-
if (
|
|
1511
|
-
|
|
1520
|
+
function sn(t, r, a) {
|
|
1521
|
+
t /= 360, r /= 100, a /= 100;
|
|
1522
|
+
let h, c, s;
|
|
1523
|
+
if (r === 0)
|
|
1524
|
+
h = c = s = a;
|
|
1512
1525
|
else {
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1526
|
+
const m = (f, v, L) => (L < 0 && (L += 1), L > 1 && (L -= 1), L < 0.16666666666666666 ? f + (v - f) * 6 * L : L < 0.5 ? v : L < 0.6666666666666666 ? f + (v - f) * (0.6666666666666666 - L) * 6 : f), d = a < 0.5 ? a * (1 + r) : a + r - a * r, u = 2 * a - d;
|
|
1527
|
+
h = m(u, d, t + 1 / 3), c = m(u, d, t), s = m(u, d, t - 1 / 3);
|
|
1515
1528
|
}
|
|
1516
|
-
return { r: Math.round(
|
|
1529
|
+
return { r: Math.round(h * 255), g: Math.round(c * 255), b: Math.round(s * 255) };
|
|
1517
1530
|
}
|
|
1518
|
-
const
|
|
1519
|
-
({ value: t, onChange:
|
|
1520
|
-
const [d, u] =
|
|
1521
|
-
let
|
|
1531
|
+
const Ye = ht(
|
|
1532
|
+
({ value: t, onChange: r, placeholder: a, mode: h = "border", beforeOpen: c, onClose: s }, m) => {
|
|
1533
|
+
const [d, u] = A(!1), f = B(null), v = B(null), L = B(null), H = B(null), p = B(null), [T, b] = A(-1e4), [M, g] = A(-1e4), [o, x] = A(t), [i, l] = A(t), y = B(t), [$, W] = A("hex"), [k, D] = A({ h: 0, s: 100, v: 100 }), [E, P] = A({ r: 0, g: 0, b: 0 }), [V, O] = A({ h: 0, s: 0, l: 0 }), [K, j] = A(!1), [_, I] = A(!1), [F, U] = A(!1), Q = S(() => {
|
|
1534
|
+
let n = 0;
|
|
1522
1535
|
const R = 3, Z = () => {
|
|
1523
|
-
if (
|
|
1524
|
-
|
|
1536
|
+
if (n >= R * 2) {
|
|
1537
|
+
U(!1);
|
|
1525
1538
|
return;
|
|
1526
1539
|
}
|
|
1527
|
-
|
|
1540
|
+
U((pe) => !pe), n++, setTimeout(Z, 100);
|
|
1528
1541
|
};
|
|
1529
1542
|
Z();
|
|
1530
1543
|
}, []);
|
|
1531
|
-
|
|
1532
|
-
triggerButtonFlash:
|
|
1544
|
+
at(m, () => ({
|
|
1545
|
+
triggerButtonFlash: Q
|
|
1533
1546
|
}));
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
const R =
|
|
1537
|
-
R && (P(R), O(
|
|
1538
|
-
}, []), ue =
|
|
1539
|
-
const
|
|
1540
|
-
P(
|
|
1541
|
-
}, [
|
|
1542
|
-
|
|
1547
|
+
const ee = Me(() => h === "background" ? on : nn, [h]), we = i || "#d9d9d9", ne = S((n) => {
|
|
1548
|
+
x(n), l(n);
|
|
1549
|
+
const R = rn(n);
|
|
1550
|
+
R && (P(R), O(Qe(R.r, R.g, R.b)), D(et(R.r, R.g, R.b)));
|
|
1551
|
+
}, []), ue = S(() => {
|
|
1552
|
+
const n = ln(k.h, k.s, k.v), R = Ze(n.r, n.g, n.b);
|
|
1553
|
+
P(n), O(Qe(n.r, n.g, n.b)), x(R), l(R);
|
|
1554
|
+
}, [k]);
|
|
1555
|
+
z(() => {
|
|
1543
1556
|
ne(t);
|
|
1544
|
-
}, [t, ne]),
|
|
1557
|
+
}, [t, ne]), z(() => {
|
|
1545
1558
|
ue();
|
|
1546
|
-
}, [
|
|
1547
|
-
const ae =
|
|
1548
|
-
let R =
|
|
1559
|
+
}, [k, ue]);
|
|
1560
|
+
const ae = S((n) => {
|
|
1561
|
+
let R = n.parentElement;
|
|
1549
1562
|
for (; R; ) {
|
|
1550
1563
|
const Z = window.getComputedStyle(R);
|
|
1551
1564
|
if (Z.overflowY === "auto" || Z.overflowY === "scroll")
|
|
@@ -1553,292 +1566,292 @@ const Ue = ct(
|
|
|
1553
1566
|
R = R.parentElement;
|
|
1554
1567
|
}
|
|
1555
1568
|
return null;
|
|
1556
|
-
}, []),
|
|
1557
|
-
if (!d || !
|
|
1558
|
-
const
|
|
1559
|
-
if (
|
|
1560
|
-
requestAnimationFrame(
|
|
1569
|
+
}, []), q = S(() => {
|
|
1570
|
+
if (!d || !v.current || !L.current || !f.current) return;
|
|
1571
|
+
const n = v.current, R = L.current, Z = f.current, pe = n.getBoundingClientRect(), he = R.getBoundingClientRect(), ke = Z.getBoundingClientRect();
|
|
1572
|
+
if (ke.width === 0 && ke.height === 0) {
|
|
1573
|
+
requestAnimationFrame(q);
|
|
1561
1574
|
return;
|
|
1562
1575
|
}
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
let
|
|
1566
|
-
if (
|
|
1567
|
-
|
|
1568
|
-
else if (
|
|
1569
|
-
|
|
1576
|
+
const He = window.innerWidth, Ie = window.innerHeight, ce = 8, Ae = 10, Ee = Ae / 2, Re = pe.width || 260, Fe = pe.height || 348;
|
|
1577
|
+
n.style.maxHeight = "", n.style.overflowY = "";
|
|
1578
|
+
let $e = he.top, ve, Ce = "right";
|
|
1579
|
+
if (he.right + ce + Re <= He - ce)
|
|
1580
|
+
ve = he.right + ce, Ce = "right";
|
|
1581
|
+
else if (he.left - Re - ce >= ce)
|
|
1582
|
+
ve = he.left - Re - ce, Ce = "left";
|
|
1570
1583
|
else {
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1584
|
+
const oe = He - he.right - ce, X = he.left - ce;
|
|
1585
|
+
oe >= X ? (ve = Math.max(ce, He - Re - ce), Ce = "right") : (ve = ce, Ce = "left");
|
|
1573
1586
|
}
|
|
1574
|
-
|
|
1575
|
-
let
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1587
|
+
$e + Fe > Ie - ce && ($e = Math.max(ce, Ie - Fe - ce)), b($e), g(ve), n.dataset.placement = Ce;
|
|
1588
|
+
let C = he.top + he.height / 2 - $e - Ee;
|
|
1589
|
+
const N = ce, Y = Math.max(N, Fe - Ae - ce);
|
|
1590
|
+
C = Math.max(N, Math.min(Y, C)), n.style.setProperty("--triangle-top", `${C}px`);
|
|
1578
1591
|
}, [d]);
|
|
1579
|
-
|
|
1592
|
+
z(() => {
|
|
1580
1593
|
if (!d) return;
|
|
1581
|
-
const
|
|
1582
|
-
return Z && Z.addEventListener("scroll",
|
|
1583
|
-
cancelAnimationFrame(
|
|
1594
|
+
const n = requestAnimationFrame(q), R = v.current, Z = R ? ae(R) : null, pe = () => requestAnimationFrame(q);
|
|
1595
|
+
return Z && Z.addEventListener("scroll", pe, !0), () => {
|
|
1596
|
+
cancelAnimationFrame(n), Z && Z.removeEventListener("scroll", pe, !0);
|
|
1584
1597
|
};
|
|
1585
|
-
}, [d,
|
|
1586
|
-
d && requestAnimationFrame(
|
|
1587
|
-
}, [
|
|
1588
|
-
const
|
|
1598
|
+
}, [d, q, ae]), z(() => {
|
|
1599
|
+
d && requestAnimationFrame(q);
|
|
1600
|
+
}, [$, d, q]);
|
|
1601
|
+
const te = S(() => {
|
|
1589
1602
|
if (d)
|
|
1590
1603
|
s == null || s();
|
|
1591
1604
|
else {
|
|
1592
|
-
if (
|
|
1593
|
-
|
|
1605
|
+
if (c && c() === !1) return;
|
|
1606
|
+
y.current = t, l(t), ne(t);
|
|
1594
1607
|
}
|
|
1595
1608
|
u(!d);
|
|
1596
|
-
}, [d, t, ne,
|
|
1597
|
-
ne(
|
|
1598
|
-
}, [ne]),
|
|
1599
|
-
const R =
|
|
1600
|
-
|
|
1601
|
-
}, [ne]),
|
|
1602
|
-
|
|
1603
|
-
}, [
|
|
1604
|
-
const
|
|
1605
|
-
|
|
1606
|
-
}, [
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
}, [
|
|
1610
|
-
if (!
|
|
1611
|
-
const R =
|
|
1612
|
-
let Z = Math.max(0, Math.min(100, (
|
|
1613
|
-
|
|
1614
|
-
}, []),
|
|
1615
|
-
|
|
1616
|
-
}, [
|
|
1617
|
-
if (!
|
|
1618
|
-
const R =
|
|
1619
|
-
let Z = Math.max(0, Math.min(360, (
|
|
1620
|
-
|
|
1621
|
-
}, []),
|
|
1622
|
-
|
|
1623
|
-
}, [
|
|
1624
|
-
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1609
|
+
}, [d, t, ne, c, s]), J = S((n) => {
|
|
1610
|
+
ne(n);
|
|
1611
|
+
}, [ne]), G = S((n) => {
|
|
1612
|
+
const R = n.target.value;
|
|
1613
|
+
x(R), (/^#[0-9A-Fa-f]{6}$/.test(R) || /^#[0-9A-Fa-f]{3}$/.test(R)) && ne(R);
|
|
1614
|
+
}, [ne]), me = S(() => {
|
|
1615
|
+
o !== i && (/^#[0-9A-Fa-f]{6}$/.test(o) || /^#[0-9A-Fa-f]{3}$/.test(o) ? ne(o) : (x(i), ne(i)));
|
|
1616
|
+
}, [o, i, ne]), Te = S(() => {
|
|
1617
|
+
const n = Ze(E.r, E.g, E.b);
|
|
1618
|
+
x(n), l(n), O(Qe(E.r, E.g, E.b)), D(et(E.r, E.g, E.b));
|
|
1619
|
+
}, [E]), Be = S(() => {
|
|
1620
|
+
const n = sn(V.h, V.s, V.l), R = Ze(n.r, n.g, n.b);
|
|
1621
|
+
x(R), l(R), P(n), D(et(n.r, n.g, n.b));
|
|
1622
|
+
}, [V]), De = S((n) => {
|
|
1623
|
+
if (!H.current) return;
|
|
1624
|
+
const R = H.current.getBoundingClientRect();
|
|
1625
|
+
let Z = Math.max(0, Math.min(100, (n.clientX - R.left) / R.width * 100)), pe = Math.max(0, Math.min(100, (n.clientY - R.top) / R.height * 100));
|
|
1626
|
+
D((he) => ({ ...he, s: Z, v: 100 - pe }));
|
|
1627
|
+
}, []), ye = S((n) => {
|
|
1628
|
+
j(!0), De(n.nativeEvent);
|
|
1629
|
+
}, [De]), xe = S((n) => {
|
|
1630
|
+
if (!p.current) return;
|
|
1631
|
+
const R = p.current.getBoundingClientRect();
|
|
1632
|
+
let Z = Math.max(0, Math.min(360, (n.clientX - R.left) / R.width * 360));
|
|
1633
|
+
D((pe) => ({ ...pe, h: Z }));
|
|
1634
|
+
}, []), Se = S((n) => {
|
|
1635
|
+
I(!0), xe(n.nativeEvent);
|
|
1636
|
+
}, [xe]);
|
|
1637
|
+
z(() => {
|
|
1638
|
+
const n = (Z) => {
|
|
1639
|
+
K && De(Z), _ && xe(Z);
|
|
1627
1640
|
}, R = () => {
|
|
1628
|
-
|
|
1641
|
+
j(!1), I(!1);
|
|
1629
1642
|
};
|
|
1630
|
-
return document.addEventListener("mousemove",
|
|
1631
|
-
document.removeEventListener("mousemove",
|
|
1643
|
+
return document.addEventListener("mousemove", n), document.addEventListener("mouseup", R), () => {
|
|
1644
|
+
document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", R);
|
|
1632
1645
|
};
|
|
1633
|
-
}, [
|
|
1634
|
-
const
|
|
1646
|
+
}, [K, _, De, xe]), z(() => {
|
|
1647
|
+
const n = (Z) => {
|
|
1635
1648
|
if (f.current && !f.current.contains(Z.target) && d) {
|
|
1636
|
-
const
|
|
1637
|
-
if (
|
|
1638
|
-
Z.stopPropagation(), Z.preventDefault(),
|
|
1649
|
+
const pe = Z.target, he = pe.closest ? pe.closest(".tp-color-picker-input") : null;
|
|
1650
|
+
if (he && he !== f.current) return;
|
|
1651
|
+
Z.stopPropagation(), Z.preventDefault(), Q();
|
|
1639
1652
|
}
|
|
1640
1653
|
}, R = () => {
|
|
1641
|
-
d && requestAnimationFrame(
|
|
1654
|
+
d && requestAnimationFrame(q);
|
|
1642
1655
|
};
|
|
1643
|
-
return document.addEventListener("pointerdown",
|
|
1644
|
-
document.removeEventListener("pointerdown",
|
|
1656
|
+
return document.addEventListener("pointerdown", n, !0), window.addEventListener("resize", R), window.addEventListener("scroll", R, !0), () => {
|
|
1657
|
+
document.removeEventListener("pointerdown", n, !0), window.removeEventListener("resize", R), window.removeEventListener("scroll", R, !0);
|
|
1645
1658
|
};
|
|
1646
|
-
}, [d,
|
|
1647
|
-
const
|
|
1648
|
-
|
|
1649
|
-
}, [
|
|
1650
|
-
l(
|
|
1651
|
-
}, [ne, s]),
|
|
1652
|
-
|
|
1659
|
+
}, [d, q]);
|
|
1660
|
+
const Ue = S(() => {
|
|
1661
|
+
r(i), u(!1), s == null || s();
|
|
1662
|
+
}, [i, r, s]), Pe = S(() => {
|
|
1663
|
+
l(y.current), ne(y.current), u(!1), s == null || s();
|
|
1664
|
+
}, [ne, s]), se = S((n) => {
|
|
1665
|
+
n.stopPropagation();
|
|
1653
1666
|
}, []);
|
|
1654
|
-
return /* @__PURE__ */
|
|
1667
|
+
return /* @__PURE__ */ w("div", { ref: f, className: `tp-color-picker-input${d ? " tp-color-picker-input-open" : ""}`, onClick: se, children: [
|
|
1655
1668
|
/* @__PURE__ */ e(
|
|
1656
1669
|
"button",
|
|
1657
1670
|
{
|
|
1658
|
-
ref:
|
|
1671
|
+
ref: L,
|
|
1659
1672
|
type: "button",
|
|
1660
1673
|
className: "tp-color-preview",
|
|
1661
|
-
style: { backgroundColor:
|
|
1662
|
-
onMouseDown: (
|
|
1663
|
-
onClick:
|
|
1674
|
+
style: { backgroundColor: we },
|
|
1675
|
+
onMouseDown: (n) => n.preventDefault(),
|
|
1676
|
+
onClick: te
|
|
1664
1677
|
}
|
|
1665
1678
|
),
|
|
1666
1679
|
/* @__PURE__ */ e(
|
|
1667
1680
|
"input",
|
|
1668
1681
|
{
|
|
1669
|
-
value:
|
|
1682
|
+
value: o,
|
|
1670
1683
|
type: "text",
|
|
1671
1684
|
className: "tp-color-text-input",
|
|
1672
|
-
placeholder:
|
|
1673
|
-
onChange:
|
|
1674
|
-
onBlur:
|
|
1675
|
-
onMouseDown:
|
|
1676
|
-
onClick:
|
|
1685
|
+
placeholder: a || "#d9d9d9",
|
|
1686
|
+
onChange: G,
|
|
1687
|
+
onBlur: me,
|
|
1688
|
+
onMouseDown: se,
|
|
1689
|
+
onClick: se
|
|
1677
1690
|
}
|
|
1678
1691
|
),
|
|
1679
|
-
d && /* @__PURE__ */
|
|
1692
|
+
d && /* @__PURE__ */ w("div", { ref: v, className: "tp-color-panel", style: { position: "fixed", top: `${T}px`, left: `${M}px` }, onClick: se, children: [
|
|
1680
1693
|
/* @__PURE__ */ e(
|
|
1681
1694
|
"div",
|
|
1682
1695
|
{
|
|
1683
|
-
ref:
|
|
1696
|
+
ref: H,
|
|
1684
1697
|
className: "tp-sv-area",
|
|
1685
1698
|
style: {
|
|
1686
|
-
background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${
|
|
1699
|
+
background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(${k.h}, 100%, 50%)`
|
|
1687
1700
|
},
|
|
1688
|
-
onMouseDown:
|
|
1701
|
+
onMouseDown: ye,
|
|
1689
1702
|
children: /* @__PURE__ */ e(
|
|
1690
1703
|
"div",
|
|
1691
1704
|
{
|
|
1692
1705
|
className: "tp-sv-indicator",
|
|
1693
|
-
style: { left: `${
|
|
1706
|
+
style: { left: `${k.s}%`, top: `${100 - k.v}%` }
|
|
1694
1707
|
}
|
|
1695
1708
|
)
|
|
1696
1709
|
}
|
|
1697
1710
|
),
|
|
1698
|
-
/* @__PURE__ */ e("div", { ref:
|
|
1711
|
+
/* @__PURE__ */ e("div", { ref: p, className: "tp-hue-bar", onMouseDown: Se, children: /* @__PURE__ */ e(
|
|
1699
1712
|
"div",
|
|
1700
1713
|
{
|
|
1701
1714
|
className: "tp-hue-indicator",
|
|
1702
|
-
style: { left: `${
|
|
1715
|
+
style: { left: `${k.h / 360 * 100}%` }
|
|
1703
1716
|
}
|
|
1704
1717
|
) }),
|
|
1705
1718
|
/* @__PURE__ */ e("div", { className: "tp-color-section-label", children: "常用颜色" }),
|
|
1706
|
-
/* @__PURE__ */ e("div", { className: "tp-color-grid tp-common-colors", children:
|
|
1719
|
+
/* @__PURE__ */ e("div", { className: "tp-color-grid tp-common-colors", children: ee.map((n) => /* @__PURE__ */ e(
|
|
1707
1720
|
"button",
|
|
1708
1721
|
{
|
|
1709
1722
|
type: "button",
|
|
1710
|
-
className: `tp-color-swatch${t ===
|
|
1711
|
-
style: { backgroundColor:
|
|
1712
|
-
title:
|
|
1723
|
+
className: `tp-color-swatch${t === n ? " tp-color-swatch-selected" : ""}`,
|
|
1724
|
+
style: { backgroundColor: n },
|
|
1725
|
+
title: n,
|
|
1713
1726
|
onMouseDown: (R) => R.preventDefault(),
|
|
1714
|
-
onClick: () => J(
|
|
1727
|
+
onClick: () => J(n)
|
|
1715
1728
|
},
|
|
1716
|
-
|
|
1729
|
+
n
|
|
1717
1730
|
)) }),
|
|
1718
|
-
/* @__PURE__ */ e("div", { className: "tp-input-mode-tabs", children: ["hex", "rgb", "hsl"].map((
|
|
1731
|
+
/* @__PURE__ */ e("div", { className: "tp-input-mode-tabs", children: ["hex", "rgb", "hsl"].map((n) => /* @__PURE__ */ e(
|
|
1719
1732
|
"button",
|
|
1720
1733
|
{
|
|
1721
1734
|
type: "button",
|
|
1722
|
-
className: `tp-mode-tab${
|
|
1723
|
-
onClick: () =>
|
|
1724
|
-
children:
|
|
1735
|
+
className: `tp-mode-tab${$ === n ? " active" : ""}`,
|
|
1736
|
+
onClick: () => W(n),
|
|
1737
|
+
children: n.toUpperCase()
|
|
1725
1738
|
},
|
|
1726
|
-
|
|
1739
|
+
n
|
|
1727
1740
|
)) }),
|
|
1728
|
-
|
|
1741
|
+
$ === "hex" && /* @__PURE__ */ w("div", { className: "tp-color-input-row", children: [
|
|
1729
1742
|
/* @__PURE__ */ e("label", { children: "HEX" }),
|
|
1730
1743
|
/* @__PURE__ */ e(
|
|
1731
1744
|
"input",
|
|
1732
1745
|
{
|
|
1733
|
-
value:
|
|
1746
|
+
value: o,
|
|
1734
1747
|
type: "text",
|
|
1735
1748
|
className: "tp-color-input-field",
|
|
1736
1749
|
placeholder: "#000000",
|
|
1737
|
-
onChange:
|
|
1738
|
-
onBlur:
|
|
1739
|
-
onMouseDown:
|
|
1740
|
-
onClick:
|
|
1750
|
+
onChange: G,
|
|
1751
|
+
onBlur: me,
|
|
1752
|
+
onMouseDown: se,
|
|
1753
|
+
onClick: se
|
|
1741
1754
|
}
|
|
1742
1755
|
)
|
|
1743
1756
|
] }),
|
|
1744
|
-
|
|
1757
|
+
$ === "rgb" && /* @__PURE__ */ w("div", { className: "tp-color-input-row tp-rgb-inline-row", children: [
|
|
1745
1758
|
/* @__PURE__ */ e("label", { children: "R" }),
|
|
1746
|
-
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 255, className: "tp-color-input-field", value:
|
|
1747
|
-
P((R) => ({ ...R, r: Number(
|
|
1748
|
-
}, onMouseDown:
|
|
1759
|
+
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 255, className: "tp-color-input-field", value: E.r, onChange: (n) => {
|
|
1760
|
+
P((R) => ({ ...R, r: Number(n.target.value) })), setTimeout(Te, 0);
|
|
1761
|
+
}, onMouseDown: se, onClick: se }),
|
|
1749
1762
|
/* @__PURE__ */ e("label", { children: "G" }),
|
|
1750
|
-
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 255, className: "tp-color-input-field", value:
|
|
1751
|
-
P((R) => ({ ...R, g: Number(
|
|
1752
|
-
}, onMouseDown:
|
|
1763
|
+
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 255, className: "tp-color-input-field", value: E.g, onChange: (n) => {
|
|
1764
|
+
P((R) => ({ ...R, g: Number(n.target.value) })), setTimeout(Te, 0);
|
|
1765
|
+
}, onMouseDown: se, onClick: se }),
|
|
1753
1766
|
/* @__PURE__ */ e("label", { children: "B" }),
|
|
1754
|
-
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 255, className: "tp-color-input-field", value:
|
|
1755
|
-
P((R) => ({ ...R, b: Number(
|
|
1756
|
-
}, onMouseDown:
|
|
1767
|
+
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 255, className: "tp-color-input-field", value: E.b, onChange: (n) => {
|
|
1768
|
+
P((R) => ({ ...R, b: Number(n.target.value) })), setTimeout(Te, 0);
|
|
1769
|
+
}, onMouseDown: se, onClick: se })
|
|
1757
1770
|
] }),
|
|
1758
|
-
|
|
1771
|
+
$ === "hsl" && /* @__PURE__ */ w("div", { className: "tp-color-input-row tp-hsl-inline-row", children: [
|
|
1759
1772
|
/* @__PURE__ */ e("label", { children: "H" }),
|
|
1760
|
-
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 360, className: "tp-color-input-field", value:
|
|
1761
|
-
O((R) => ({ ...R, h: Number(
|
|
1762
|
-
}, onMouseDown:
|
|
1773
|
+
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 360, className: "tp-color-input-field", value: V.h, onChange: (n) => {
|
|
1774
|
+
O((R) => ({ ...R, h: Number(n.target.value) })), setTimeout(Be, 0);
|
|
1775
|
+
}, onMouseDown: se, onClick: se }),
|
|
1763
1776
|
/* @__PURE__ */ e("span", { className: "tp-input-unit", children: "°" }),
|
|
1764
1777
|
/* @__PURE__ */ e("label", { children: "S" }),
|
|
1765
|
-
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 100, className: "tp-color-input-field", value:
|
|
1766
|
-
O((R) => ({ ...R, s: Number(
|
|
1767
|
-
}, onMouseDown:
|
|
1778
|
+
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 100, className: "tp-color-input-field", value: V.s, onChange: (n) => {
|
|
1779
|
+
O((R) => ({ ...R, s: Number(n.target.value) })), setTimeout(Be, 0);
|
|
1780
|
+
}, onMouseDown: se, onClick: se }),
|
|
1768
1781
|
/* @__PURE__ */ e("span", { className: "tp-input-unit", children: "%" }),
|
|
1769
1782
|
/* @__PURE__ */ e("label", { children: "L" }),
|
|
1770
|
-
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 100, className: "tp-color-input-field", value:
|
|
1771
|
-
O((R) => ({ ...R, l: Number(
|
|
1772
|
-
}, onMouseDown:
|
|
1783
|
+
/* @__PURE__ */ e("input", { type: "number", min: 0, max: 100, className: "tp-color-input-field", value: V.l, onChange: (n) => {
|
|
1784
|
+
O((R) => ({ ...R, l: Number(n.target.value) })), setTimeout(Be, 0);
|
|
1785
|
+
}, onMouseDown: se, onClick: se }),
|
|
1773
1786
|
/* @__PURE__ */ e("span", { className: "tp-input-unit", children: "%" })
|
|
1774
1787
|
] }),
|
|
1775
|
-
/* @__PURE__ */
|
|
1788
|
+
/* @__PURE__ */ w("div", { className: "tp-color-footer-row", children: [
|
|
1776
1789
|
/* @__PURE__ */ e("div", { className: "tp-color-preview-label", children: "当前颜色" }),
|
|
1777
|
-
/* @__PURE__ */ e("div", { className: "tp-color-preview-box", style: { backgroundColor:
|
|
1778
|
-
/* @__PURE__ */
|
|
1779
|
-
/* @__PURE__ */ e("button", { type: "button", className: `tp-color-btn tp-color-btn-cancel${
|
|
1780
|
-
/* @__PURE__ */ e("button", { type: "button", className: `tp-color-btn tp-color-btn-confirm${
|
|
1790
|
+
/* @__PURE__ */ e("div", { className: "tp-color-preview-box", style: { backgroundColor: we } }),
|
|
1791
|
+
/* @__PURE__ */ w("div", { className: "tp-color-actions", children: [
|
|
1792
|
+
/* @__PURE__ */ e("button", { type: "button", className: `tp-color-btn tp-color-btn-cancel${F ? " tp-color-btn-flash" : ""}`, title: "取消", onMouseDown: (n) => n.preventDefault(), onClick: Pe, children: "✕" }),
|
|
1793
|
+
/* @__PURE__ */ e("button", { type: "button", className: `tp-color-btn tp-color-btn-confirm${F ? " tp-color-btn-flash" : ""}`, title: "确认", onMouseDown: (n) => n.preventDefault(), onClick: Ue, children: "✓" })
|
|
1781
1794
|
] })
|
|
1782
1795
|
] })
|
|
1783
1796
|
] })
|
|
1784
1797
|
] });
|
|
1785
1798
|
}
|
|
1786
1799
|
);
|
|
1787
|
-
|
|
1788
|
-
const
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1791
|
-
if (
|
|
1800
|
+
Ye.displayName = "ColorPickerInput";
|
|
1801
|
+
const cn = ({ editor: t, visible: r, onVisibleChange: a }) => {
|
|
1802
|
+
const h = Le.getInstance(), c = (p) => h.t(p), [s, m] = A({ borderColor: "#d9d9d9", borderWidth: 1 }), [d, u] = A("");
|
|
1803
|
+
z(() => {
|
|
1804
|
+
if (r) {
|
|
1792
1805
|
document.body.style.overflow = "hidden";
|
|
1793
|
-
const { state:
|
|
1794
|
-
let
|
|
1795
|
-
|
|
1796
|
-
borderColor:
|
|
1797
|
-
borderWidth:
|
|
1806
|
+
const { state: p } = t, { $from: T } = p.selection;
|
|
1807
|
+
let b = null;
|
|
1808
|
+
p.doc.nodesBetween(T.start(), T.end(), (M) => M.type.name === "table" ? (b = M, !1) : !0), m(b ? {
|
|
1809
|
+
borderColor: b.attrs.borderColor || "#d9d9d9",
|
|
1810
|
+
borderWidth: b.attrs.borderWidth ? parseInt(b.attrs.borderWidth, 10) : 1
|
|
1798
1811
|
} : { borderColor: "#d9d9d9", borderWidth: 1 });
|
|
1799
1812
|
} else
|
|
1800
1813
|
document.body.style.overflow = "";
|
|
1801
1814
|
return () => {
|
|
1802
1815
|
document.body.style.overflow = "";
|
|
1803
1816
|
};
|
|
1804
|
-
}, [
|
|
1805
|
-
const f =
|
|
1817
|
+
}, [r, t]);
|
|
1818
|
+
const f = S(() => {
|
|
1806
1819
|
u("");
|
|
1807
|
-
}, []),
|
|
1808
|
-
d || (t.commands.focus(),
|
|
1809
|
-
}, [d, t,
|
|
1820
|
+
}, []), v = S((p) => (u(p), !0), []), L = S(() => {
|
|
1821
|
+
d || (t.commands.focus(), a(!1));
|
|
1822
|
+
}, [d, t, a]), H = S(() => {
|
|
1810
1823
|
d || (t.chain().focus().setTableBorder({
|
|
1811
1824
|
color: s.borderColor,
|
|
1812
1825
|
width: `${s.borderWidth}px`,
|
|
1813
1826
|
style: "solid"
|
|
1814
|
-
}).run(),
|
|
1815
|
-
}, [d, t, s,
|
|
1816
|
-
return
|
|
1817
|
-
/* @__PURE__ */ e("div", { className: "tp-modal-overlay", onMouseDown: (
|
|
1818
|
-
|
|
1819
|
-
}, children: /* @__PURE__ */
|
|
1820
|
-
/* @__PURE__ */
|
|
1821
|
-
/* @__PURE__ */ e("h3", { className: "tp-modal-title", children:
|
|
1822
|
-
/* @__PURE__ */ e("button", { className: "tp-modal-close", onClick:
|
|
1827
|
+
}).run(), a(!1));
|
|
1828
|
+
}, [d, t, s, a]);
|
|
1829
|
+
return r ? _e(
|
|
1830
|
+
/* @__PURE__ */ e("div", { className: "tp-modal-overlay", onMouseDown: (p) => {
|
|
1831
|
+
p.target === p.currentTarget && L();
|
|
1832
|
+
}, children: /* @__PURE__ */ w("div", { className: "tp-modal", onMouseDown: (p) => p.stopPropagation(), children: [
|
|
1833
|
+
/* @__PURE__ */ w("div", { className: "tp-modal-header", children: [
|
|
1834
|
+
/* @__PURE__ */ e("h3", { className: "tp-modal-title", children: c("table.tableSettings") }),
|
|
1835
|
+
/* @__PURE__ */ e("button", { className: "tp-modal-close", onClick: L, children: "×" })
|
|
1823
1836
|
] }),
|
|
1824
|
-
/* @__PURE__ */
|
|
1825
|
-
/* @__PURE__ */
|
|
1826
|
-
/* @__PURE__ */ e("label", { className: "tp-form-label", children:
|
|
1837
|
+
/* @__PURE__ */ w("div", { className: "tp-modal-body", children: [
|
|
1838
|
+
/* @__PURE__ */ w("div", { className: "tp-form-item", children: [
|
|
1839
|
+
/* @__PURE__ */ e("label", { className: "tp-form-label", children: c("table.borderColor") }),
|
|
1827
1840
|
/* @__PURE__ */ e(
|
|
1828
|
-
|
|
1841
|
+
Ye,
|
|
1829
1842
|
{
|
|
1830
1843
|
value: s.borderColor,
|
|
1831
|
-
onChange: (
|
|
1844
|
+
onChange: (p) => m((T) => ({ ...T, borderColor: p })),
|
|
1832
1845
|
mode: "border",
|
|
1833
1846
|
placeholder: "#d9d9d9",
|
|
1834
|
-
beforeOpen: () =>
|
|
1847
|
+
beforeOpen: () => v("border"),
|
|
1835
1848
|
onClose: f
|
|
1836
1849
|
}
|
|
1837
1850
|
)
|
|
1838
1851
|
] }),
|
|
1839
|
-
/* @__PURE__ */
|
|
1840
|
-
/* @__PURE__ */ e("label", { className: "tp-form-label", children:
|
|
1841
|
-
/* @__PURE__ */
|
|
1852
|
+
/* @__PURE__ */ w("div", { className: "tp-form-item", children: [
|
|
1853
|
+
/* @__PURE__ */ e("label", { className: "tp-form-label", children: c("table.borderWidth") }),
|
|
1854
|
+
/* @__PURE__ */ w("div", { className: "tp-input-with-suffix", children: [
|
|
1842
1855
|
/* @__PURE__ */ e(
|
|
1843
1856
|
"input",
|
|
1844
1857
|
{
|
|
@@ -1847,39 +1860,39 @@ const Vt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
1847
1860
|
min: 0,
|
|
1848
1861
|
max: 10,
|
|
1849
1862
|
value: s.borderWidth,
|
|
1850
|
-
onChange: (
|
|
1863
|
+
onChange: (p) => m((T) => ({ ...T, borderWidth: Number(p.target.value) }))
|
|
1851
1864
|
}
|
|
1852
1865
|
),
|
|
1853
1866
|
/* @__PURE__ */ e("span", { className: "tp-input-suffix", children: "px" })
|
|
1854
1867
|
] })
|
|
1855
1868
|
] })
|
|
1856
1869
|
] }),
|
|
1857
|
-
/* @__PURE__ */
|
|
1858
|
-
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-default", onClick:
|
|
1859
|
-
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-primary", onClick:
|
|
1870
|
+
/* @__PURE__ */ w("div", { className: "tp-modal-footer", children: [
|
|
1871
|
+
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-default", onClick: L, children: c("common.cancel") }),
|
|
1872
|
+
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-primary", onClick: H, children: c("common.confirm") })
|
|
1860
1873
|
] })
|
|
1861
1874
|
] }) }),
|
|
1862
1875
|
document.body
|
|
1863
1876
|
) : null;
|
|
1864
|
-
},
|
|
1877
|
+
}, an = [
|
|
1865
1878
|
{ value: "left", labelKey: "table.alignLeft" },
|
|
1866
1879
|
{ value: "center", labelKey: "table.alignCenter" },
|
|
1867
1880
|
{ value: "right", labelKey: "table.alignRight" },
|
|
1868
1881
|
{ value: "justify", labelKey: "table.alignJustify" }
|
|
1869
|
-
],
|
|
1882
|
+
], dn = [
|
|
1870
1883
|
{ value: "top", labelKey: "table.valignTop" },
|
|
1871
1884
|
{ value: "middle", labelKey: "table.valignMiddle" },
|
|
1872
1885
|
{ value: "bottom", labelKey: "table.valignBottom" }
|
|
1873
1886
|
];
|
|
1874
|
-
function
|
|
1875
|
-
const
|
|
1876
|
-
return `${
|
|
1887
|
+
function un(t) {
|
|
1888
|
+
const r = t.attrs.borderWidth || "1px", a = t.attrs.borderStyle || "solid", h = t.attrs.borderColor || "#d9d9d9";
|
|
1889
|
+
return `${r} ${a} ${h}`;
|
|
1877
1890
|
}
|
|
1878
|
-
function
|
|
1879
|
-
const
|
|
1891
|
+
function ge(t, r, a, h, c, s) {
|
|
1892
|
+
const m = t === 0, d = t + h >= c.height, u = r === 0, f = r + a >= c.width;
|
|
1880
1893
|
switch (s) {
|
|
1881
1894
|
case "top":
|
|
1882
|
-
return
|
|
1895
|
+
return m;
|
|
1883
1896
|
case "bottom":
|
|
1884
1897
|
return d;
|
|
1885
1898
|
case "left":
|
|
@@ -1890,281 +1903,281 @@ function we(t, o, c, p, i, s) {
|
|
|
1890
1903
|
return !1;
|
|
1891
1904
|
}
|
|
1892
1905
|
}
|
|
1893
|
-
function
|
|
1894
|
-
const u = t.attrs.colspan || 1, f = t.attrs.rowspan || 1,
|
|
1895
|
-
switch (
|
|
1906
|
+
function Je(t, r, a, h, c, s, m, d) {
|
|
1907
|
+
const u = t.attrs.colspan || 1, f = t.attrs.rowspan || 1, v = { ...t.attrs };
|
|
1908
|
+
switch (m) {
|
|
1896
1909
|
case "left":
|
|
1897
|
-
|
|
1910
|
+
v.borderLeft = d;
|
|
1898
1911
|
break;
|
|
1899
1912
|
case "right":
|
|
1900
|
-
|
|
1913
|
+
v.borderRight = d;
|
|
1901
1914
|
break;
|
|
1902
1915
|
case "top":
|
|
1903
|
-
|
|
1916
|
+
v.borderTop = d;
|
|
1904
1917
|
break;
|
|
1905
1918
|
case "bottom":
|
|
1906
|
-
|
|
1919
|
+
v.borderBottom = d;
|
|
1907
1920
|
break;
|
|
1908
1921
|
}
|
|
1909
|
-
return
|
|
1922
|
+
return v.borderLeft || (v.borderLeft = ge(r, a, u, f, h, "left") && c ? c : s), v.borderRight || (v.borderRight = ge(r, a, u, f, h, "right") && c ? c : s), v.borderTop || (v.borderTop = ge(r, a, u, f, h, "top") && c ? c : s), v.borderBottom || (v.borderBottom = ge(r, a, u, f, h, "bottom") && c ? c : s), v;
|
|
1910
1923
|
}
|
|
1911
|
-
function
|
|
1912
|
-
const
|
|
1924
|
+
function pn(t, r, a, h, c, s, m, d, u, f) {
|
|
1925
|
+
const v = t.attrs.colspan || 1, L = t.attrs.rowspan || 1;
|
|
1913
1926
|
return f ? {
|
|
1914
1927
|
...t.attrs,
|
|
1915
|
-
borderLeft:
|
|
1916
|
-
borderRight:
|
|
1917
|
-
borderTop:
|
|
1918
|
-
borderBottom:
|
|
1919
|
-
backgroundColor:
|
|
1928
|
+
borderLeft: ge(r, a, v, L, h, "left") && c ? c : s,
|
|
1929
|
+
borderRight: ge(r, a, v, L, h, "right") && c ? c : s,
|
|
1930
|
+
borderTop: ge(r, a, v, L, h, "top") && c ? c : s,
|
|
1931
|
+
borderBottom: ge(r, a, v, L, h, "bottom") && c ? c : s,
|
|
1932
|
+
backgroundColor: m,
|
|
1920
1933
|
textAlign: d,
|
|
1921
1934
|
verticalAlign: u
|
|
1922
|
-
} : { ...t.attrs, backgroundColor:
|
|
1935
|
+
} : { ...t.attrs, backgroundColor: m, textAlign: d, verticalAlign: u };
|
|
1923
1936
|
}
|
|
1924
|
-
const
|
|
1925
|
-
const
|
|
1937
|
+
const hn = ({ editor: t, visible: r, onVisibleChange: a }) => {
|
|
1938
|
+
const h = Le.getInstance(), c = (o) => h.t(o), [s, m] = A({
|
|
1926
1939
|
borderColor: "#d9d9d9",
|
|
1927
1940
|
borderWidth: 1,
|
|
1928
1941
|
backgroundColor: "#ffffff",
|
|
1929
1942
|
textAlign: "left",
|
|
1930
1943
|
verticalAlign: "top"
|
|
1931
|
-
}), [d, u] =
|
|
1932
|
-
const
|
|
1933
|
-
|
|
1934
|
-
}, [f]), T =
|
|
1935
|
-
const { state:
|
|
1936
|
-
if ("$anchorCell" in
|
|
1937
|
-
const
|
|
1938
|
-
let
|
|
1939
|
-
return
|
|
1944
|
+
}), [d, u] = A({ borderColor: "#d9d9d9", borderWidth: 1 }), [f, v] = A(""), L = B(null), H = B(null), p = S(() => {
|
|
1945
|
+
const o = f === "border" ? L.current : H.current;
|
|
1946
|
+
o == null || o.triggerButtonFlash();
|
|
1947
|
+
}, [f]), T = S((o) => f && f !== o ? (p(), !1) : (v(o), !0), [f, p]), b = S(() => {
|
|
1948
|
+
const { state: o } = t, { selection: x } = o;
|
|
1949
|
+
if ("$anchorCell" in x && x.$anchorCell) {
|
|
1950
|
+
const y = x.$anchorCell;
|
|
1951
|
+
let $ = null;
|
|
1952
|
+
return o.doc.nodesBetween(y.pos, y.pos + 1, (W) => W.type.name === "tableCell" || W.type.name === "tableHeader" ? ($ = W, !1) : !0), ($ == null ? void 0 : $.attrs) || null;
|
|
1940
1953
|
}
|
|
1941
|
-
const { $from:
|
|
1954
|
+
const { $from: i } = x;
|
|
1942
1955
|
let l = null;
|
|
1943
|
-
return
|
|
1956
|
+
return o.doc.nodesBetween(i.pos, i.pos + 1, (y) => y.type.name === "tableCell" || y.type.name === "tableHeader" ? (l = y, !1) : !0), (l == null ? void 0 : l.attrs) || null;
|
|
1944
1957
|
}, [t]);
|
|
1945
|
-
|
|
1946
|
-
var
|
|
1947
|
-
if (
|
|
1958
|
+
z(() => {
|
|
1959
|
+
var o, x, i, l;
|
|
1960
|
+
if (r) {
|
|
1948
1961
|
document.body.style.overflow = "hidden";
|
|
1949
|
-
const
|
|
1950
|
-
if (
|
|
1951
|
-
const
|
|
1952
|
-
borderColor: ((
|
|
1953
|
-
borderWidth: (l = (
|
|
1954
|
-
backgroundColor:
|
|
1955
|
-
textAlign:
|
|
1956
|
-
verticalAlign:
|
|
1962
|
+
const y = b();
|
|
1963
|
+
if (y) {
|
|
1964
|
+
const $ = {
|
|
1965
|
+
borderColor: ((x = (o = y.borderLeft) == null ? void 0 : o.match(/#\w+/)) == null ? void 0 : x[0]) || "#d9d9d9",
|
|
1966
|
+
borderWidth: (l = (i = y.borderLeft) == null ? void 0 : i.match(/(\d+)px/)) != null && l[1] ? parseInt(y.borderLeft.match(/(\d+)px/)[1], 10) : 1,
|
|
1967
|
+
backgroundColor: y.backgroundColor || "#ffffff",
|
|
1968
|
+
textAlign: y.textAlign || "left",
|
|
1969
|
+
verticalAlign: y.verticalAlign || "middle"
|
|
1957
1970
|
};
|
|
1958
|
-
|
|
1971
|
+
m($), u({ borderColor: $.borderColor, borderWidth: $.borderWidth });
|
|
1959
1972
|
} else
|
|
1960
|
-
|
|
1973
|
+
m({ borderColor: "#d9d9d9", borderWidth: 1, backgroundColor: "#ffffff", textAlign: "left", verticalAlign: "middle" }), u({ borderColor: "#d9d9d9", borderWidth: 1 });
|
|
1961
1974
|
} else
|
|
1962
1975
|
document.body.style.overflow = "";
|
|
1963
1976
|
return () => {
|
|
1964
1977
|
document.body.style.overflow = "";
|
|
1965
1978
|
};
|
|
1966
|
-
}, [
|
|
1967
|
-
const M =
|
|
1968
|
-
f || (t.commands.focus(),
|
|
1969
|
-
}, [f, t,
|
|
1979
|
+
}, [r, b]);
|
|
1980
|
+
const M = S(() => {
|
|
1981
|
+
f || (t.commands.focus(), a(!1));
|
|
1982
|
+
}, [f, t, a]), g = S(() => {
|
|
1970
1983
|
if (f)
|
|
1971
1984
|
return;
|
|
1972
|
-
const { state:
|
|
1973
|
-
let
|
|
1974
|
-
const
|
|
1975
|
-
const
|
|
1976
|
-
if (
|
|
1977
|
-
const
|
|
1978
|
-
for (let
|
|
1979
|
-
for (let
|
|
1980
|
-
const J =
|
|
1981
|
-
ae.has(J) || ae.set(J, { row:
|
|
1985
|
+
const { state: o, dispatch: x } = t.view, { selection: i } = o, l = i, y = o.tr;
|
|
1986
|
+
let $ = !1;
|
|
1987
|
+
const W = s.borderColor !== d.borderColor || s.borderWidth !== d.borderWidth, k = `${s.borderWidth}px solid ${s.borderColor}`, D = (K, j, _, I, F, U) => {
|
|
1988
|
+
const Q = F + 1, ee = pn(K, _.row, _.col, I, U, k, s.backgroundColor, s.textAlign, s.verticalAlign, W);
|
|
1989
|
+
if (y.setNodeMarkup(j, null, ee), $ = !0, !W) return;
|
|
1990
|
+
const we = K.attrs.colspan || 1, ne = K.attrs.rowspan || 1, ue = "1px solid #d9d9d9", ae = /* @__PURE__ */ new Map();
|
|
1991
|
+
for (let q = 0; q < I.height; q++)
|
|
1992
|
+
for (let te = 0; te < I.width; te++) {
|
|
1993
|
+
const J = I.map[q * I.width + te];
|
|
1994
|
+
ae.has(J) || ae.set(J, { row: q, col: te });
|
|
1982
1995
|
}
|
|
1983
|
-
if (
|
|
1984
|
-
const
|
|
1996
|
+
if (_.col > 0) {
|
|
1997
|
+
const q = I.map[_.row * I.width + _.col - 1], te = Q + q, J = y.doc.nodeAt(te);
|
|
1985
1998
|
if (J && (J.type.name === "tableCell" || J.type.name === "tableHeader")) {
|
|
1986
|
-
const
|
|
1987
|
-
if (
|
|
1988
|
-
const
|
|
1989
|
-
|
|
1999
|
+
const G = ae.get(q);
|
|
2000
|
+
if (G && !ge(G.row, G.col, J.attrs.colspan || 1, J.attrs.rowspan || 1, I, "right")) {
|
|
2001
|
+
const me = Je(J, G.row, G.col, I, U, ue, "right", ee.borderLeft);
|
|
2002
|
+
y.setNodeMarkup(te, null, me);
|
|
1990
2003
|
}
|
|
1991
2004
|
}
|
|
1992
2005
|
}
|
|
1993
|
-
if (
|
|
1994
|
-
const
|
|
2006
|
+
if (_.row > 0) {
|
|
2007
|
+
const q = I.map[(_.row - 1) * I.width + _.col], te = Q + q, J = y.doc.nodeAt(te);
|
|
1995
2008
|
if (J && (J.type.name === "tableCell" || J.type.name === "tableHeader")) {
|
|
1996
|
-
const
|
|
1997
|
-
if (
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2009
|
+
const G = ae.get(q);
|
|
2010
|
+
if (G && !ge(G.row, G.col, J.attrs.colspan || 1, J.attrs.rowspan || 1, I, "bottom")) {
|
|
2011
|
+
const me = Je(J, G.row, G.col, I, U, ue, "bottom", ee.borderTop);
|
|
2012
|
+
y.setNodeMarkup(te, null, me);
|
|
2000
2013
|
}
|
|
2001
2014
|
}
|
|
2002
2015
|
}
|
|
2003
|
-
if (
|
|
2004
|
-
const
|
|
2016
|
+
if (_.col + (K.attrs.colspan || 1) < I.width) {
|
|
2017
|
+
const q = I.map[_.row * I.width + _.col + we], te = Q + q, J = y.doc.nodeAt(te);
|
|
2005
2018
|
if (J && (J.type.name === "tableCell" || J.type.name === "tableHeader")) {
|
|
2006
|
-
const
|
|
2007
|
-
if (
|
|
2008
|
-
const
|
|
2009
|
-
|
|
2019
|
+
const G = ae.get(q);
|
|
2020
|
+
if (G && !ge(G.row, G.col, J.attrs.colspan || 1, J.attrs.rowspan || 1, I, "left")) {
|
|
2021
|
+
const me = Je(J, G.row, G.col, I, U, ue, "left", ee.borderRight);
|
|
2022
|
+
y.setNodeMarkup(te, null, me);
|
|
2010
2023
|
}
|
|
2011
2024
|
}
|
|
2012
2025
|
}
|
|
2013
|
-
if (
|
|
2014
|
-
const
|
|
2026
|
+
if (_.row + (K.attrs.rowspan || 1) < I.height) {
|
|
2027
|
+
const q = I.map[(_.row + ne) * I.width + _.col], te = Q + q, J = y.doc.nodeAt(te);
|
|
2015
2028
|
if (J && (J.type.name === "tableCell" || J.type.name === "tableHeader")) {
|
|
2016
|
-
const
|
|
2017
|
-
if (
|
|
2018
|
-
const
|
|
2019
|
-
|
|
2029
|
+
const G = ae.get(q);
|
|
2030
|
+
if (G && !ge(G.row, G.col, J.attrs.colspan || 1, J.attrs.rowspan || 1, I, "top")) {
|
|
2031
|
+
const me = Je(J, G.row, G.col, I, U, ue, "top", ee.borderBottom);
|
|
2032
|
+
y.setNodeMarkup(te, null, me);
|
|
2020
2033
|
}
|
|
2021
2034
|
}
|
|
2022
2035
|
}
|
|
2023
|
-
}, { $from:
|
|
2024
|
-
let
|
|
2025
|
-
if (
|
|
2026
|
-
const
|
|
2027
|
-
for (let
|
|
2028
|
-
for (let
|
|
2029
|
-
const
|
|
2030
|
-
|
|
2036
|
+
}, { $from: E, $to: P } = i;
|
|
2037
|
+
let V = -1, O = null;
|
|
2038
|
+
if (o.doc.nodesBetween(E.pos, P.pos, (K, j) => K.type.name === "table" ? (V = j, O = K, !1) : !0), O && V >= 0) {
|
|
2039
|
+
const K = un(O), j = dt.get(O), _ = V + 1, I = /* @__PURE__ */ new Map();
|
|
2040
|
+
for (let F = 0; F < j.height; F++)
|
|
2041
|
+
for (let U = 0; U < j.width; U++) {
|
|
2042
|
+
const Q = j.map[F * j.width + U];
|
|
2043
|
+
I.has(Q) || I.set(Q, { row: F, col: U });
|
|
2031
2044
|
}
|
|
2032
|
-
if ("$anchorCell" in
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2035
|
-
const ae =
|
|
2036
|
-
if (
|
|
2037
|
-
const
|
|
2038
|
-
|
|
2045
|
+
if ("$anchorCell" in i && i.$anchorCell) {
|
|
2046
|
+
const F = i.$anchorCell, U = i.$headCell, Q = F.pos - _, ee = U.pos - _, we = j.rectBetween(Q, ee);
|
|
2047
|
+
j.cellsInRect(we).forEach((ue) => {
|
|
2048
|
+
const ae = _ + ue, q = o.doc.nodeAt(ae);
|
|
2049
|
+
if (q && (q.type.name === "tableCell" || q.type.name === "tableHeader")) {
|
|
2050
|
+
const te = I.get(ue);
|
|
2051
|
+
te && D(q, ae, te, j, V, K);
|
|
2039
2052
|
}
|
|
2040
2053
|
});
|
|
2041
2054
|
} else
|
|
2042
|
-
|
|
2043
|
-
if (
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2055
|
+
o.doc.nodesBetween(E.pos, P.pos, (F, U) => {
|
|
2056
|
+
if (F.type.name === "tableCell" || F.type.name === "tableHeader") {
|
|
2057
|
+
const Q = U - _, ee = I.get(Q);
|
|
2058
|
+
ee && D(F, U, ee, j, V, K);
|
|
2046
2059
|
}
|
|
2047
2060
|
return !0;
|
|
2048
2061
|
});
|
|
2049
2062
|
}
|
|
2050
|
-
|
|
2051
|
-
}, [f, t, s, d,
|
|
2052
|
-
return
|
|
2053
|
-
/* @__PURE__ */ e("div", { className: "tp-modal-overlay", onMouseDown: (
|
|
2054
|
-
|
|
2055
|
-
}, children: /* @__PURE__ */
|
|
2056
|
-
/* @__PURE__ */
|
|
2057
|
-
/* @__PURE__ */ e("h3", { className: "tp-modal-title", children:
|
|
2063
|
+
$ && x && (y.setSelection(l.map(y.doc, y.mapping)), x(y), t.commands.focus()), a(!1);
|
|
2064
|
+
}, [f, t, s, d, a]);
|
|
2065
|
+
return r ? _e(
|
|
2066
|
+
/* @__PURE__ */ e("div", { className: "tp-modal-overlay", onMouseDown: (o) => {
|
|
2067
|
+
o.target === o.currentTarget && M();
|
|
2068
|
+
}, children: /* @__PURE__ */ w("div", { className: "tp-modal", onMouseDown: (o) => o.stopPropagation(), children: [
|
|
2069
|
+
/* @__PURE__ */ w("div", { className: "tp-modal-header", children: [
|
|
2070
|
+
/* @__PURE__ */ e("h3", { className: "tp-modal-title", children: c("table.cellSettings") }),
|
|
2058
2071
|
/* @__PURE__ */ e("button", { className: "tp-modal-close", onClick: M, children: "×" })
|
|
2059
2072
|
] }),
|
|
2060
|
-
/* @__PURE__ */
|
|
2061
|
-
/* @__PURE__ */
|
|
2062
|
-
/* @__PURE__ */ e("label", { className: "tp-form-label", children:
|
|
2073
|
+
/* @__PURE__ */ w("div", { className: "tp-modal-body", children: [
|
|
2074
|
+
/* @__PURE__ */ w("div", { className: "tp-form-item", children: [
|
|
2075
|
+
/* @__PURE__ */ e("label", { className: "tp-form-label", children: c("table.borderColor") }),
|
|
2063
2076
|
/* @__PURE__ */ e(
|
|
2064
|
-
|
|
2077
|
+
Ye,
|
|
2065
2078
|
{
|
|
2066
|
-
ref:
|
|
2079
|
+
ref: L,
|
|
2067
2080
|
value: s.borderColor,
|
|
2068
|
-
onChange: (
|
|
2081
|
+
onChange: (o) => m((x) => ({ ...x, borderColor: o })),
|
|
2069
2082
|
mode: "border",
|
|
2070
2083
|
placeholder: "#d9d9d9",
|
|
2071
2084
|
beforeOpen: () => T("border"),
|
|
2072
|
-
onClose: () =>
|
|
2085
|
+
onClose: () => v("")
|
|
2073
2086
|
}
|
|
2074
2087
|
)
|
|
2075
2088
|
] }),
|
|
2076
|
-
/* @__PURE__ */
|
|
2077
|
-
/* @__PURE__ */ e("label", { className: "tp-form-label", children:
|
|
2078
|
-
/* @__PURE__ */
|
|
2079
|
-
/* @__PURE__ */ e("input", { type: "number", className: "tp-text-input", min: 0, max: 10, value: s.borderWidth, onChange: (
|
|
2089
|
+
/* @__PURE__ */ w("div", { className: "tp-form-item", children: [
|
|
2090
|
+
/* @__PURE__ */ e("label", { className: "tp-form-label", children: c("table.borderWidth") }),
|
|
2091
|
+
/* @__PURE__ */ w("div", { className: "tp-input-with-suffix", children: [
|
|
2092
|
+
/* @__PURE__ */ e("input", { type: "number", className: "tp-text-input", min: 0, max: 10, value: s.borderWidth, onChange: (o) => m((x) => ({ ...x, borderWidth: Number(o.target.value) })) }),
|
|
2080
2093
|
/* @__PURE__ */ e("span", { className: "tp-input-suffix", children: "px" })
|
|
2081
2094
|
] })
|
|
2082
2095
|
] }),
|
|
2083
|
-
/* @__PURE__ */
|
|
2084
|
-
/* @__PURE__ */ e("label", { className: "tp-form-label", children:
|
|
2096
|
+
/* @__PURE__ */ w("div", { className: "tp-form-item", children: [
|
|
2097
|
+
/* @__PURE__ */ e("label", { className: "tp-form-label", children: c("table.backgroundColor") }),
|
|
2085
2098
|
/* @__PURE__ */ e(
|
|
2086
|
-
|
|
2099
|
+
Ye,
|
|
2087
2100
|
{
|
|
2088
|
-
ref:
|
|
2101
|
+
ref: H,
|
|
2089
2102
|
value: s.backgroundColor,
|
|
2090
|
-
onChange: (
|
|
2103
|
+
onChange: (o) => m((x) => ({ ...x, backgroundColor: o })),
|
|
2091
2104
|
mode: "background",
|
|
2092
2105
|
placeholder: "transparent",
|
|
2093
2106
|
beforeOpen: () => T("background"),
|
|
2094
|
-
onClose: () =>
|
|
2107
|
+
onClose: () => v("")
|
|
2095
2108
|
}
|
|
2096
2109
|
)
|
|
2097
2110
|
] }),
|
|
2098
|
-
/* @__PURE__ */
|
|
2099
|
-
/* @__PURE__ */ e("label", { className: "tp-form-label", children:
|
|
2100
|
-
/* @__PURE__ */ e("div", { className: "tp-align-options", children:
|
|
2101
|
-
/* @__PURE__ */
|
|
2102
|
-
|
|
2111
|
+
/* @__PURE__ */ w("div", { className: "tp-form-item", children: [
|
|
2112
|
+
/* @__PURE__ */ e("label", { className: "tp-form-label", children: c("table.textAlign") }),
|
|
2113
|
+
/* @__PURE__ */ e("div", { className: "tp-align-options", children: an.map((o) => /* @__PURE__ */ w("button", { className: `tp-align-btn${s.textAlign === o.value ? " active" : ""}`, onClick: () => m((x) => ({ ...x, textAlign: o.value })), children: [
|
|
2114
|
+
/* @__PURE__ */ w("span", { className: "tp-align-icon tp-align-icon-svg", children: [
|
|
2115
|
+
o.value === "left" && /* @__PURE__ */ w("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: [
|
|
2103
2116
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2104
2117
|
/* @__PURE__ */ e("line", { x1: "6", y1: "8", x2: "14", y2: "8" }),
|
|
2105
2118
|
/* @__PURE__ */ e("line", { x1: "6", y1: "12", x2: "11", y2: "12" }),
|
|
2106
2119
|
/* @__PURE__ */ e("line", { x1: "6", y1: "16", x2: "16", y2: "16" })
|
|
2107
2120
|
] }),
|
|
2108
|
-
|
|
2121
|
+
o.value === "center" && /* @__PURE__ */ w("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: [
|
|
2109
2122
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2110
2123
|
/* @__PURE__ */ e("line", { x1: "7", y1: "8", x2: "17", y2: "8" }),
|
|
2111
2124
|
/* @__PURE__ */ e("line", { x1: "9", y1: "12", x2: "15", y2: "12" }),
|
|
2112
2125
|
/* @__PURE__ */ e("line", { x1: "8", y1: "16", x2: "16", y2: "16" })
|
|
2113
2126
|
] }),
|
|
2114
|
-
|
|
2127
|
+
o.value === "right" && /* @__PURE__ */ w("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: [
|
|
2115
2128
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2116
2129
|
/* @__PURE__ */ e("line", { x1: "10", y1: "8", x2: "18", y2: "8" }),
|
|
2117
2130
|
/* @__PURE__ */ e("line", { x1: "13", y1: "12", x2: "18", y2: "12" }),
|
|
2118
2131
|
/* @__PURE__ */ e("line", { x1: "8", y1: "16", x2: "18", y2: "16" })
|
|
2119
2132
|
] }),
|
|
2120
|
-
|
|
2133
|
+
o.value === "justify" && /* @__PURE__ */ w("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: [
|
|
2121
2134
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2122
2135
|
/* @__PURE__ */ e("line", { x1: "6", y1: "8", x2: "18", y2: "8" }),
|
|
2123
2136
|
/* @__PURE__ */ e("line", { x1: "6", y1: "12", x2: "18", y2: "12" }),
|
|
2124
2137
|
/* @__PURE__ */ e("line", { x1: "6", y1: "16", x2: "18", y2: "16" })
|
|
2125
2138
|
] })
|
|
2126
2139
|
] }),
|
|
2127
|
-
/* @__PURE__ */ e("span", { className: "tp-align-label", children:
|
|
2128
|
-
] },
|
|
2140
|
+
/* @__PURE__ */ e("span", { className: "tp-align-label", children: c(o.labelKey) })
|
|
2141
|
+
] }, o.value)) })
|
|
2129
2142
|
] }),
|
|
2130
|
-
/* @__PURE__ */
|
|
2131
|
-
/* @__PURE__ */ e("label", { className: "tp-form-label", children:
|
|
2132
|
-
/* @__PURE__ */ e("div", { className: "tp-align-options", children:
|
|
2133
|
-
/* @__PURE__ */
|
|
2134
|
-
|
|
2143
|
+
/* @__PURE__ */ w("div", { className: "tp-form-item", children: [
|
|
2144
|
+
/* @__PURE__ */ e("label", { className: "tp-form-label", children: c("table.verticalAlign") }),
|
|
2145
|
+
/* @__PURE__ */ e("div", { className: "tp-align-options", children: dn.map((o) => /* @__PURE__ */ w("button", { className: `tp-align-btn${s.verticalAlign === o.value ? " active" : ""}`, onClick: () => m((x) => ({ ...x, verticalAlign: o.value })), children: [
|
|
2146
|
+
/* @__PURE__ */ w("span", { className: "tp-align-icon tp-align-icon-svg", children: [
|
|
2147
|
+
o.value === "top" && /* @__PURE__ */ w("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: [
|
|
2135
2148
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2136
2149
|
/* @__PURE__ */ e("line", { x1: "6", y1: "7", x2: "18", y2: "7" })
|
|
2137
2150
|
] }),
|
|
2138
|
-
|
|
2151
|
+
o.value === "middle" && /* @__PURE__ */ w("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: [
|
|
2139
2152
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2140
2153
|
/* @__PURE__ */ e("line", { x1: "6", y1: "12", x2: "18", y2: "12" })
|
|
2141
2154
|
] }),
|
|
2142
|
-
|
|
2155
|
+
o.value === "bottom" && /* @__PURE__ */ w("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: [
|
|
2143
2156
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
2144
2157
|
/* @__PURE__ */ e("line", { x1: "6", y1: "17", x2: "18", y2: "17" })
|
|
2145
2158
|
] })
|
|
2146
2159
|
] }),
|
|
2147
|
-
/* @__PURE__ */ e("span", { className: "tp-align-label", children:
|
|
2148
|
-
] },
|
|
2160
|
+
/* @__PURE__ */ e("span", { className: "tp-align-label", children: c(o.labelKey) })
|
|
2161
|
+
] }, o.value)) })
|
|
2149
2162
|
] })
|
|
2150
2163
|
] }),
|
|
2151
|
-
/* @__PURE__ */
|
|
2152
|
-
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-default", onClick: M, children:
|
|
2153
|
-
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-primary", onClick:
|
|
2164
|
+
/* @__PURE__ */ w("div", { className: "tp-modal-footer", children: [
|
|
2165
|
+
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-default", onClick: M, children: c("common.cancel") }),
|
|
2166
|
+
/* @__PURE__ */ e("button", { className: "tp-btn tp-btn-primary", onClick: g, children: c("common.confirm") })
|
|
2154
2167
|
] })
|
|
2155
2168
|
] }) }),
|
|
2156
2169
|
document.body
|
|
2157
2170
|
) : null;
|
|
2158
|
-
},
|
|
2159
|
-
const
|
|
2171
|
+
}, fn = ({ manager: t, visible: r, onVisibleChange: a }) => {
|
|
2172
|
+
const h = Le.getInstance(), [c, s] = A([]), [m, d] = A(""), [u, f] = A(null), [v, L] = A(!1), H = B(null), p = B(null), T = B(null), b = S((l, y) => h.t(l, y) || l, [h]), M = S((l) => {
|
|
2160
2173
|
try {
|
|
2161
|
-
const
|
|
2162
|
-
return
|
|
2174
|
+
const y = new Date(l), W = (/* @__PURE__ */ new Date()).getTime() - y.getTime(), k = Math.floor(W / 6e4), D = Math.floor(W / 36e5), E = Math.floor(W / 864e5);
|
|
2175
|
+
return k < 1 ? b("compare.justNow") : k < 60 ? b("compare.minutesAgo", { n: String(k) }) : D < 24 ? b("compare.hoursAgo", { n: String(D) }) : E < 7 ? b("compare.daysAgo", { n: String(E) }) : y.toLocaleDateString() + " " + y.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
2163
2176
|
} catch {
|
|
2164
2177
|
return l;
|
|
2165
2178
|
}
|
|
2166
|
-
}, [
|
|
2167
|
-
const
|
|
2179
|
+
}, [b]), g = S((l) => {
|
|
2180
|
+
const y = {
|
|
2168
2181
|
blur: "compare.sourceBlur",
|
|
2169
2182
|
baseline: "compare.sourceBaseline",
|
|
2170
2183
|
paste: "compare.sourcePaste",
|
|
@@ -2173,132 +2186,132 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2173
2186
|
interval: "compare.sourceInterval",
|
|
2174
2187
|
imported: "compare.sourceImported"
|
|
2175
2188
|
};
|
|
2176
|
-
return
|
|
2177
|
-
}, [
|
|
2178
|
-
|
|
2179
|
-
if (!
|
|
2189
|
+
return y[l] ? b(y[l]) : l;
|
|
2190
|
+
}, [b]), o = S((l, y) => `v${c.length - y}.0 - ${M(l.timestamp)} (${g(l.source)})${l.label ? ` - ${l.label}` : ""}`, [M, g, c]);
|
|
2191
|
+
z(() => {
|
|
2192
|
+
if (!r) {
|
|
2180
2193
|
d(""), f(null);
|
|
2181
2194
|
return;
|
|
2182
2195
|
}
|
|
2183
2196
|
let l = !1;
|
|
2184
|
-
return
|
|
2185
|
-
l || (s(
|
|
2197
|
+
return L(!0), t.listVersions().then((y) => {
|
|
2198
|
+
l || (s(y), !m && y.length > 0 && d(y[0].id), L(!1));
|
|
2186
2199
|
}).catch(() => {
|
|
2187
|
-
l || (s([]),
|
|
2200
|
+
l || (s([]), L(!1));
|
|
2188
2201
|
}), () => {
|
|
2189
2202
|
l = !0;
|
|
2190
2203
|
};
|
|
2191
|
-
}, [
|
|
2192
|
-
if (!
|
|
2204
|
+
}, [r, t]), z(() => {
|
|
2205
|
+
if (!m || !t) {
|
|
2193
2206
|
f(null);
|
|
2194
2207
|
return;
|
|
2195
2208
|
}
|
|
2196
|
-
t.compareWithVersion(
|
|
2197
|
-
}, [
|
|
2198
|
-
var l,
|
|
2199
|
-
if (u &&
|
|
2209
|
+
t.compareWithVersion(m).then(f).catch(() => f(null));
|
|
2210
|
+
}, [m, t]), z(() => {
|
|
2211
|
+
var l, y;
|
|
2212
|
+
if (u && H.current && p.current) {
|
|
2200
2213
|
(l = T.current) == null || l.detach();
|
|
2201
|
-
const
|
|
2202
|
-
|
|
2203
|
-
const
|
|
2204
|
-
return T.current =
|
|
2205
|
-
clearTimeout(
|
|
2214
|
+
const $ = new kt(H.current, p.current);
|
|
2215
|
+
$.attach();
|
|
2216
|
+
const W = setTimeout(() => $.refresh(), 0);
|
|
2217
|
+
return T.current = $, () => {
|
|
2218
|
+
clearTimeout(W), $.detach();
|
|
2206
2219
|
};
|
|
2207
2220
|
} else
|
|
2208
|
-
(
|
|
2209
|
-
}, [u]),
|
|
2210
|
-
const l = (
|
|
2211
|
-
|
|
2221
|
+
(y = T.current) == null || y.detach(), T.current = null;
|
|
2222
|
+
}, [u]), z(() => {
|
|
2223
|
+
const l = (y) => {
|
|
2224
|
+
y.key === "Escape" && r && a(!1);
|
|
2212
2225
|
};
|
|
2213
2226
|
return document.addEventListener("keydown", l), () => document.removeEventListener("keydown", l);
|
|
2214
|
-
}, [
|
|
2215
|
-
const
|
|
2216
|
-
const l = await t.createSnapshot(
|
|
2217
|
-
l ?
|
|
2218
|
-
const
|
|
2219
|
-
s(
|
|
2220
|
-
}, [t,
|
|
2221
|
-
|
|
2222
|
-
}, [
|
|
2223
|
-
return
|
|
2224
|
-
/* @__PURE__ */
|
|
2225
|
-
/* @__PURE__ */
|
|
2226
|
-
/* @__PURE__ */
|
|
2227
|
+
}, [r, a]);
|
|
2228
|
+
const x = S(async () => {
|
|
2229
|
+
const l = await t.createSnapshot(b("compare.createSnapshot"));
|
|
2230
|
+
l ? qe(b("compare.snapshotCreated").replace("{time}", l.label || l.timestamp)) : qe({ message: b("compare.snapshotFailed"), type: "error" });
|
|
2231
|
+
const y = await t.listVersions();
|
|
2232
|
+
s(y);
|
|
2233
|
+
}, [t, b]), i = S(() => {
|
|
2234
|
+
a(!1);
|
|
2235
|
+
}, [a]);
|
|
2236
|
+
return r ? /* @__PURE__ */ w("div", { className: "cyte-compare-overlay", children: [
|
|
2237
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-header", children: [
|
|
2238
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-header__title", children: [
|
|
2239
|
+
/* @__PURE__ */ w("svg", { className: "cyte-compare-header__title-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2227
2240
|
/* @__PURE__ */ e("rect", { x: "3", y: "3", width: "7", height: "18", rx: "1" }),
|
|
2228
2241
|
/* @__PURE__ */ e("rect", { x: "14", y: "3", width: "7", height: "18", rx: "1" }),
|
|
2229
2242
|
/* @__PURE__ */ e("line", { x1: "10", y1: "8", x2: "14", y2: "8" }),
|
|
2230
2243
|
/* @__PURE__ */ e("line", { x1: "10", y1: "12", x2: "14", y2: "12" }),
|
|
2231
2244
|
/* @__PURE__ */ e("line", { x1: "10", y1: "16", x2: "14", y2: "16" })
|
|
2232
2245
|
] }),
|
|
2233
|
-
|
|
2246
|
+
b("compare.title")
|
|
2234
2247
|
] }),
|
|
2235
|
-
/* @__PURE__ */
|
|
2236
|
-
/* @__PURE__ */
|
|
2237
|
-
/* @__PURE__ */
|
|
2238
|
-
|
|
2248
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-header__actions", children: [
|
|
2249
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-version-selector", children: [
|
|
2250
|
+
/* @__PURE__ */ w("span", { className: "cyte-compare-version-selector__label", children: [
|
|
2251
|
+
b("compare.selectVersion"),
|
|
2239
2252
|
":"
|
|
2240
2253
|
] }),
|
|
2241
|
-
/* @__PURE__ */
|
|
2254
|
+
/* @__PURE__ */ w(
|
|
2242
2255
|
"select",
|
|
2243
2256
|
{
|
|
2244
|
-
value:
|
|
2257
|
+
value: m,
|
|
2245
2258
|
onChange: (l) => d(l.target.value),
|
|
2246
2259
|
className: "cyte-compare-version-selector__select",
|
|
2247
2260
|
children: [
|
|
2248
|
-
/* @__PURE__ */ e("option", { value: "", disabled: !0, children:
|
|
2249
|
-
|
|
2261
|
+
/* @__PURE__ */ e("option", { value: "", disabled: !0, children: b("compare.selectVersion") }),
|
|
2262
|
+
c.map((l, y) => /* @__PURE__ */ e("option", { value: l.id, children: o(l, y) }, l.id))
|
|
2250
2263
|
]
|
|
2251
2264
|
}
|
|
2252
2265
|
)
|
|
2253
2266
|
] }),
|
|
2254
|
-
/* @__PURE__ */ e("button", { className: "cyte-compare-btn--close", onClick:
|
|
2267
|
+
/* @__PURE__ */ e("button", { className: "cyte-compare-btn--close", onClick: i, title: b("compare.close"), children: "✕" })
|
|
2255
2268
|
] })
|
|
2256
2269
|
] }),
|
|
2257
|
-
u && /* @__PURE__ */
|
|
2258
|
-
/* @__PURE__ */
|
|
2259
|
-
/* @__PURE__ */
|
|
2270
|
+
u && /* @__PURE__ */ w("div", { className: "cyte-compare-stats", children: [
|
|
2271
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-stats__item", children: [
|
|
2272
|
+
/* @__PURE__ */ w("span", { className: "cyte-compare-stats__badge", children: [
|
|
2260
2273
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--added" }),
|
|
2261
2274
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__count cyte-compare-stats__count--added", children: u.stats.added })
|
|
2262
2275
|
] }),
|
|
2263
|
-
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children:
|
|
2276
|
+
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children: b("compare.statsAdded") })
|
|
2264
2277
|
] }),
|
|
2265
|
-
/* @__PURE__ */
|
|
2266
|
-
/* @__PURE__ */
|
|
2278
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-stats__item", children: [
|
|
2279
|
+
/* @__PURE__ */ w("span", { className: "cyte-compare-stats__badge", children: [
|
|
2267
2280
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--removed" }),
|
|
2268
2281
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__count cyte-compare-stats__count--removed", children: u.stats.removed })
|
|
2269
2282
|
] }),
|
|
2270
|
-
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children:
|
|
2283
|
+
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children: b("compare.statsRemoved") })
|
|
2271
2284
|
] }),
|
|
2272
|
-
/* @__PURE__ */
|
|
2273
|
-
/* @__PURE__ */
|
|
2285
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-stats__item", children: [
|
|
2286
|
+
/* @__PURE__ */ w("span", { className: "cyte-compare-stats__badge", children: [
|
|
2274
2287
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--modified" }),
|
|
2275
2288
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__count cyte-compare-stats__count--modified", children: u.stats.modified })
|
|
2276
2289
|
] }),
|
|
2277
|
-
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children:
|
|
2290
|
+
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children: b("compare.statsModified") })
|
|
2278
2291
|
] }),
|
|
2279
|
-
/* @__PURE__ */
|
|
2280
|
-
/* @__PURE__ */
|
|
2292
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-stats__item cyte-compare-stats__item--unchanged", children: [
|
|
2293
|
+
/* @__PURE__ */ w("span", { className: "cyte-compare-stats__badge", children: [
|
|
2281
2294
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__dot cyte-compare-stats__dot--unchanged" }),
|
|
2282
2295
|
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__count", children: u.stats.unchanged })
|
|
2283
2296
|
] }),
|
|
2284
|
-
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children:
|
|
2297
|
+
/* @__PURE__ */ e("span", { className: "cyte-compare-stats__label", children: b("compare.statsUnchanged") })
|
|
2285
2298
|
] })
|
|
2286
2299
|
] }),
|
|
2287
|
-
/* @__PURE__ */
|
|
2288
|
-
|
|
2289
|
-
/* @__PURE__ */
|
|
2300
|
+
/* @__PURE__ */ w("div", { className: "cyte-compare-content", children: [
|
|
2301
|
+
c.length === 0 && !v && /* @__PURE__ */ w("div", { className: "cyte-compare-empty", children: [
|
|
2302
|
+
/* @__PURE__ */ w("svg", { className: "cyte-compare-empty__icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
2290
2303
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
|
|
2291
2304
|
/* @__PURE__ */ e("path", { d: "M8 12h8M12 8v8" })
|
|
2292
2305
|
] }),
|
|
2293
|
-
/* @__PURE__ */ e("div", { className: "cyte-compare-empty__text", children:
|
|
2294
|
-
/* @__PURE__ */ e("div", { className: "cyte-compare-empty__hint", children:
|
|
2295
|
-
/* @__PURE__ */ e("button", { className: "cyte-compare-btn cyte-compare-btn--primary cyte-compare-snapshot-btn", onClick:
|
|
2306
|
+
/* @__PURE__ */ e("div", { className: "cyte-compare-empty__text", children: b("compare.noVersions") }),
|
|
2307
|
+
/* @__PURE__ */ e("div", { className: "cyte-compare-empty__hint", children: b("compare.noVersionsHint") }),
|
|
2308
|
+
/* @__PURE__ */ e("button", { className: "cyte-compare-btn cyte-compare-btn--primary cyte-compare-snapshot-btn", onClick: x, children: b("compare.createSnapshot") })
|
|
2296
2309
|
] }),
|
|
2297
|
-
u && /* @__PURE__ */
|
|
2298
|
-
/* @__PURE__ */
|
|
2310
|
+
u && /* @__PURE__ */ w(nt, { children: [
|
|
2311
|
+
/* @__PURE__ */ w("div", { ref: H, className: "cyte-compare-pane", children: [
|
|
2299
2312
|
/* @__PURE__ */ e("div", { className: "cyte-compare-pane__header", children: (() => {
|
|
2300
|
-
const l =
|
|
2301
|
-
return l === -1 ?
|
|
2313
|
+
const l = c.findIndex((y) => y.id === m);
|
|
2314
|
+
return l === -1 ? b("compare.leftLabel") : `${b("compare.leftLabel")} - ${o(c[l], l)}`;
|
|
2302
2315
|
})() }),
|
|
2303
2316
|
/* @__PURE__ */ e("div", { className: "cyte-compare-pane__body", children: u.left.map((l) => /* @__PURE__ */ e(
|
|
2304
2317
|
"div",
|
|
@@ -2308,8 +2321,8 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2308
2321
|
l.key
|
|
2309
2322
|
)) })
|
|
2310
2323
|
] }),
|
|
2311
|
-
/* @__PURE__ */
|
|
2312
|
-
/* @__PURE__ */ e("div", { className: "cyte-compare-pane__header", children:
|
|
2324
|
+
/* @__PURE__ */ w("div", { ref: p, className: "cyte-compare-pane", children: [
|
|
2325
|
+
/* @__PURE__ */ e("div", { className: "cyte-compare-pane__header", children: b("compare.rightLabel") }),
|
|
2313
2326
|
/* @__PURE__ */ e("div", { className: "cyte-compare-pane__body", children: u.right.map((l) => /* @__PURE__ */ e(
|
|
2314
2327
|
"div",
|
|
2315
2328
|
{
|
|
@@ -2319,45 +2332,45 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2319
2332
|
)) })
|
|
2320
2333
|
] })
|
|
2321
2334
|
] }),
|
|
2322
|
-
|
|
2335
|
+
c.length > 0 && !m && !u && /* @__PURE__ */ e("div", { className: "cyte-compare-empty", children: /* @__PURE__ */ e("div", { className: "cyte-compare-empty__text", children: b("compare.selectVersion") }) })
|
|
2323
2336
|
] })
|
|
2324
2337
|
] }) : null;
|
|
2325
|
-
},
|
|
2326
|
-
const { t: s } = fe(), [
|
|
2327
|
-
|
|
2328
|
-
var
|
|
2329
|
-
(
|
|
2338
|
+
}, mn = ({ visible: t, defaultFilename: r, onConfirm: a, onCancel: h, onClose: c }) => {
|
|
2339
|
+
const { t: s } = fe(), [m, d] = A(""), u = B(null);
|
|
2340
|
+
z(() => (t ? (d(r || "document"), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
2341
|
+
var p, T;
|
|
2342
|
+
(p = u.current) == null || p.focus(), (T = u.current) == null || T.select();
|
|
2330
2343
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
2331
2344
|
document.body.style.overflow = "";
|
|
2332
|
-
}), [t,
|
|
2333
|
-
const f =
|
|
2334
|
-
const
|
|
2335
|
-
|
|
2336
|
-
}, [
|
|
2337
|
-
|
|
2338
|
-
}, [
|
|
2339
|
-
|
|
2340
|
-
}, [
|
|
2341
|
-
|
|
2342
|
-
}, [f,
|
|
2345
|
+
}), [t, r]);
|
|
2346
|
+
const f = S(() => {
|
|
2347
|
+
const p = m.trim() || "document";
|
|
2348
|
+
a(p), c();
|
|
2349
|
+
}, [m, a, c]), v = S(() => {
|
|
2350
|
+
h == null || h(), c();
|
|
2351
|
+
}, [h, c]), L = S((p) => {
|
|
2352
|
+
p.target === p.currentTarget && v();
|
|
2353
|
+
}, [v]), H = S((p) => {
|
|
2354
|
+
p.key === "Enter" ? (p.preventDefault(), f()) : p.key === "Escape" && (p.preventDefault(), v());
|
|
2355
|
+
}, [f, v]);
|
|
2343
2356
|
return t ? _e(
|
|
2344
|
-
/* @__PURE__ */ e("div", { className: "tp-export-dialog-overlay", onMouseDown:
|
|
2345
|
-
/* @__PURE__ */
|
|
2357
|
+
/* @__PURE__ */ e("div", { className: "tp-export-dialog-overlay", onMouseDown: L, children: /* @__PURE__ */ w("div", { className: "tp-export-dialog", onMouseDown: (p) => p.stopPropagation(), onKeyDown: H, children: [
|
|
2358
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-header", children: [
|
|
2346
2359
|
/* @__PURE__ */ e("span", { className: "tp-dialog-title", children: s("toolbar.exportWord") }),
|
|
2347
|
-
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick:
|
|
2360
|
+
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick: v, children: "×" })
|
|
2348
2361
|
] }),
|
|
2349
|
-
/* @__PURE__ */
|
|
2362
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-body", children: [
|
|
2350
2363
|
/* @__PURE__ */ e("label", { className: "tp-input-label", children: s("toolbar.exportWordFilename") }),
|
|
2351
|
-
/* @__PURE__ */
|
|
2364
|
+
/* @__PURE__ */ w("div", { className: "tp-input-row", children: [
|
|
2352
2365
|
/* @__PURE__ */ e(
|
|
2353
2366
|
"input",
|
|
2354
2367
|
{
|
|
2355
2368
|
ref: u,
|
|
2356
2369
|
type: "text",
|
|
2357
2370
|
className: "tp-filename-input",
|
|
2358
|
-
value:
|
|
2359
|
-
onChange: (
|
|
2360
|
-
onKeyDown:
|
|
2371
|
+
value: m,
|
|
2372
|
+
onChange: (p) => d(p.target.value),
|
|
2373
|
+
onKeyDown: H
|
|
2361
2374
|
}
|
|
2362
2375
|
),
|
|
2363
2376
|
/* @__PURE__ */ e("span", { className: "tp-filename-suffix", children: ".docx" }),
|
|
@@ -2367,42 +2380,42 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2367
2380
|
] }) }),
|
|
2368
2381
|
document.body
|
|
2369
2382
|
) : null;
|
|
2370
|
-
},
|
|
2371
|
-
const { t: s } = fe(), [
|
|
2372
|
-
|
|
2373
|
-
var
|
|
2374
|
-
(
|
|
2383
|
+
}, gn = ({ visible: t, defaultFilename: r, onConfirm: a, onCancel: h, onClose: c }) => {
|
|
2384
|
+
const { t: s } = fe(), [m, d] = A(""), u = B(null);
|
|
2385
|
+
z(() => (t ? (d(r || "document"), document.body.style.overflow = "hidden", setTimeout(() => {
|
|
2386
|
+
var p, T;
|
|
2387
|
+
(p = u.current) == null || p.focus(), (T = u.current) == null || T.select();
|
|
2375
2388
|
}, 100)) : document.body.style.overflow = "", () => {
|
|
2376
2389
|
document.body.style.overflow = "";
|
|
2377
|
-
}), [t,
|
|
2378
|
-
const f =
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2381
|
-
}, [
|
|
2382
|
-
|
|
2383
|
-
}, [
|
|
2384
|
-
|
|
2385
|
-
}, [
|
|
2386
|
-
|
|
2387
|
-
}, [f,
|
|
2390
|
+
}), [t, r]);
|
|
2391
|
+
const f = S(() => {
|
|
2392
|
+
const p = m.trim() || "document";
|
|
2393
|
+
a(p), c();
|
|
2394
|
+
}, [m, a, c]), v = S(() => {
|
|
2395
|
+
h == null || h(), c();
|
|
2396
|
+
}, [h, c]), L = S((p) => {
|
|
2397
|
+
p.target === p.currentTarget && v();
|
|
2398
|
+
}, [v]), H = S((p) => {
|
|
2399
|
+
p.key === "Enter" ? (p.preventDefault(), f()) : p.key === "Escape" && (p.preventDefault(), v());
|
|
2400
|
+
}, [f, v]);
|
|
2388
2401
|
return t ? _e(
|
|
2389
|
-
/* @__PURE__ */ e("div", { className: "tp-export-dialog-overlay", onMouseDown:
|
|
2390
|
-
/* @__PURE__ */
|
|
2402
|
+
/* @__PURE__ */ e("div", { className: "tp-export-dialog-overlay", onMouseDown: L, children: /* @__PURE__ */ w("div", { className: "tp-export-dialog", onMouseDown: (p) => p.stopPropagation(), onKeyDown: H, children: [
|
|
2403
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-header", children: [
|
|
2391
2404
|
/* @__PURE__ */ e("span", { className: "tp-dialog-title", children: s("toolbar.exportMarkdown") }),
|
|
2392
|
-
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick:
|
|
2405
|
+
/* @__PURE__ */ e("button", { className: "tp-dialog-close", onClick: v, children: "×" })
|
|
2393
2406
|
] }),
|
|
2394
|
-
/* @__PURE__ */
|
|
2407
|
+
/* @__PURE__ */ w("div", { className: "tp-dialog-body", children: [
|
|
2395
2408
|
/* @__PURE__ */ e("label", { className: "tp-input-label", children: s("toolbar.exportMarkdownFilename") }),
|
|
2396
|
-
/* @__PURE__ */
|
|
2409
|
+
/* @__PURE__ */ w("div", { className: "tp-input-row", children: [
|
|
2397
2410
|
/* @__PURE__ */ e(
|
|
2398
2411
|
"input",
|
|
2399
2412
|
{
|
|
2400
2413
|
ref: u,
|
|
2401
2414
|
type: "text",
|
|
2402
2415
|
className: "tp-filename-input",
|
|
2403
|
-
value:
|
|
2404
|
-
onChange: (
|
|
2405
|
-
onKeyDown:
|
|
2416
|
+
value: m,
|
|
2417
|
+
onChange: (p) => d(p.target.value),
|
|
2418
|
+
onKeyDown: H
|
|
2406
2419
|
}
|
|
2407
2420
|
),
|
|
2408
2421
|
/* @__PURE__ */ e("span", { className: "tp-filename-suffix", children: ".md" }),
|
|
@@ -2412,35 +2425,40 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2412
2425
|
] }) }),
|
|
2413
2426
|
document.body
|
|
2414
2427
|
) : null;
|
|
2415
|
-
},
|
|
2428
|
+
}, wn = tt.forwardRef((t, r) => {
|
|
2416
2429
|
const {
|
|
2417
|
-
html:
|
|
2418
|
-
json:
|
|
2419
|
-
config:
|
|
2430
|
+
html: a,
|
|
2431
|
+
json: h,
|
|
2432
|
+
config: c,
|
|
2420
2433
|
height: s = "300px",
|
|
2421
|
-
minHeight:
|
|
2434
|
+
minHeight: m,
|
|
2422
2435
|
maxHeight: d,
|
|
2423
2436
|
autoHeight: u = !1,
|
|
2424
2437
|
placeholder: f,
|
|
2425
|
-
toolbar:
|
|
2426
|
-
readonly:
|
|
2427
|
-
disabled:
|
|
2428
|
-
autofocus:
|
|
2438
|
+
toolbar: v,
|
|
2439
|
+
readonly: L = !1,
|
|
2440
|
+
disabled: H = !1,
|
|
2441
|
+
autofocus: p = !1,
|
|
2429
2442
|
locale: T,
|
|
2430
|
-
pasteMode:
|
|
2443
|
+
pasteMode: b,
|
|
2431
2444
|
uploadUrl: M,
|
|
2432
|
-
onChange:
|
|
2433
|
-
onFocus:
|
|
2434
|
-
onBlur:
|
|
2435
|
-
onReady:
|
|
2445
|
+
onChange: g,
|
|
2446
|
+
onFocus: o,
|
|
2447
|
+
onBlur: x,
|
|
2448
|
+
onReady: i,
|
|
2436
2449
|
onViewModeChange: l,
|
|
2437
|
-
onToolbarClick:
|
|
2438
|
-
onFullscreenChange:
|
|
2439
|
-
toolbarRender:
|
|
2440
|
-
} = t, [
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2450
|
+
onToolbarClick: y,
|
|
2451
|
+
onFullscreenChange: $,
|
|
2452
|
+
toolbarRender: W
|
|
2453
|
+
} = t, [k, D] = A("normal"), E = B(""), P = B(null), [V, O] = A(!1), [K, j] = A({ x: 0, y: 0 }), [_, I] = A(null), F = B(null), U = B(null);
|
|
2454
|
+
z(() => () => {
|
|
2455
|
+
var C, N;
|
|
2456
|
+
(C = F.current) == null || C.call(F), F.current = null, (N = U.current) == null || N.call(U), U.current = null;
|
|
2457
|
+
}, []);
|
|
2458
|
+
const [Q, ee] = A(!1), [we, ne] = A(!1), [ue, ae] = A(!1), [q, te] = A(!1), [J, G] = A("document"), [me, Te] = A(!1), [Be, De] = A("document"), [ye, xe] = A(!1), Se = Le.getInstance(), Ue = S((C) => Se.t(C) || C, [Se]), Pe = Me(() => {
|
|
2459
|
+
const N = { ...c || {} };
|
|
2460
|
+
return s !== void 0 && (N.height = s), m !== void 0 && (N.minHeight = m), d !== void 0 && (N.maxHeight = d), u !== void 0 && (N.autoHeight = u), f !== void 0 && (N.placeholder = f), v !== void 0 && (N.toolbar = v), L !== void 0 && (N.readonly = L), H !== void 0 && (N.disabled = H), p !== void 0 && (N.autofocus = p), T !== void 0 && (N.locale = T), b !== void 0 && (N.paste = { ...N.paste, mode: b }), M !== void 0 && (N.upload = { ...N.upload, url: M }), N;
|
|
2461
|
+
}, [c, s, m, d, u, f, v, L, H, p, T, b, M]), se = Me(() => Pe.toolbar || [
|
|
2444
2462
|
// A: 历史操作
|
|
2445
2463
|
"undo",
|
|
2446
2464
|
"redo",
|
|
@@ -2488,207 +2506,240 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2488
2506
|
"getJSON",
|
|
2489
2507
|
"|",
|
|
2490
2508
|
// H: 视图/版本 (meta-view)
|
|
2491
|
-
"fullscreen",
|
|
2492
2509
|
"snapshot",
|
|
2493
2510
|
"compare",
|
|
2494
|
-
"autoFormat"
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2511
|
+
"autoFormat",
|
|
2512
|
+
"fullscreen"
|
|
2513
|
+
], [Pe.toolbar]), { manager: n, isReady: R, isFocused: Z, isEmpty: pe, containerRef: he, setContentFromProp: ke } = Et({
|
|
2514
|
+
config: Pe,
|
|
2515
|
+
onUpdate(C, N) {
|
|
2516
|
+
g == null || g({ html: C, json: N });
|
|
2499
2517
|
},
|
|
2500
2518
|
onFocus(C) {
|
|
2501
|
-
|
|
2519
|
+
o == null || o(C);
|
|
2502
2520
|
},
|
|
2503
2521
|
onBlur(C) {
|
|
2504
|
-
|
|
2522
|
+
x == null || x(C);
|
|
2505
2523
|
},
|
|
2506
2524
|
onReady(C) {
|
|
2507
|
-
|
|
2525
|
+
a ? C.setContent(a) : h && C.setJSON(h), Re(C), i == null || i(C);
|
|
2508
2526
|
}
|
|
2509
|
-
}), { activeStates:
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
}, [
|
|
2513
|
-
|
|
2514
|
-
}, [
|
|
2515
|
-
const
|
|
2516
|
-
let
|
|
2517
|
-
const
|
|
2518
|
-
for (let
|
|
2519
|
-
const
|
|
2520
|
-
if (
|
|
2521
|
-
|
|
2527
|
+
}), { activeStates: He, disabledStates: Ie } = Rt(n);
|
|
2528
|
+
z(() => {
|
|
2529
|
+
a !== void 0 && ke(a);
|
|
2530
|
+
}, [a, ke]), z(() => {
|
|
2531
|
+
h !== void 0 && ke(void 0, h);
|
|
2532
|
+
}, [h, ke]);
|
|
2533
|
+
const ce = S((C) => {
|
|
2534
|
+
let N = "", Y = 0;
|
|
2535
|
+
const oe = " ", re = C.replace(/>\s+</g, "><").trim().split(/(<\/?[^>]+>)/g).filter((de) => de.trim() !== "");
|
|
2536
|
+
for (let de = 0; de < re.length; de++) {
|
|
2537
|
+
const le = re[de];
|
|
2538
|
+
if (le.match(/^<\/\w/))
|
|
2539
|
+
Y = Math.max(0, Y - 1), N += oe.repeat(Y) + le + `
|
|
2522
2540
|
`;
|
|
2523
|
-
else if (
|
|
2524
|
-
|
|
2541
|
+
else if (le.match(/^<\w[^>]*[^\/]>$/)) {
|
|
2542
|
+
N += oe.repeat(Y) + le + `
|
|
2525
2543
|
`;
|
|
2526
|
-
const ie =
|
|
2527
|
-
ie && !ie.match(/^<\/\w/) &&
|
|
2528
|
-
} else if (
|
|
2529
|
-
|
|
2544
|
+
const ie = re[de + 1];
|
|
2545
|
+
ie && !ie.match(/^<\/\w/) && Y++;
|
|
2546
|
+
} else if (le.match(/^<\w[^>]*\/>$/))
|
|
2547
|
+
N += oe.repeat(Y) + le + `
|
|
2530
2548
|
`;
|
|
2531
|
-
else if (
|
|
2532
|
-
|
|
2549
|
+
else if (le.match(/^<\w/))
|
|
2550
|
+
N += oe.repeat(Y) + le + `
|
|
2533
2551
|
`;
|
|
2534
2552
|
else {
|
|
2535
|
-
const ie =
|
|
2536
|
-
ie && (
|
|
2553
|
+
const ie = le.trim();
|
|
2554
|
+
ie && (N += oe.repeat(Y) + ie + `
|
|
2537
2555
|
`);
|
|
2538
2556
|
}
|
|
2539
2557
|
}
|
|
2540
|
-
return
|
|
2541
|
-
}, []),
|
|
2542
|
-
if (!
|
|
2543
|
-
const
|
|
2544
|
-
if (
|
|
2545
|
-
|
|
2558
|
+
return N.trim();
|
|
2559
|
+
}, []), Ae = S((C) => {
|
|
2560
|
+
if (!n) return;
|
|
2561
|
+
const N = n.getEditor();
|
|
2562
|
+
if (k === C) {
|
|
2563
|
+
Ee();
|
|
2546
2564
|
return;
|
|
2547
2565
|
}
|
|
2548
|
-
|
|
2549
|
-
const
|
|
2550
|
-
|
|
2551
|
-
}, [
|
|
2552
|
-
if (!
|
|
2553
|
-
const C =
|
|
2554
|
-
if (
|
|
2555
|
-
const
|
|
2556
|
-
if (
|
|
2566
|
+
k !== "normal" ? Ee() : (E.current = n.getHTML(), P.current = n.getJSON());
|
|
2567
|
+
const Y = C === "html" ? n.getHTML() : JSON.stringify(n.getJSON(), null, 2), oe = C === "html" ? ce(Y) : Y;
|
|
2568
|
+
N.commands.clearContent(), N.commands.insertContent({ type: "codeBlock", attrs: { language: C === "html" ? "html" : "json" }, content: [{ type: "text", text: oe }] }), D(C), l == null || l(C);
|
|
2569
|
+
}, [n, k, ce, l]), Ee = S(() => {
|
|
2570
|
+
if (!n) return;
|
|
2571
|
+
const C = n.getEditor();
|
|
2572
|
+
if (k !== "normal") {
|
|
2573
|
+
const N = C.getText(), Y = k;
|
|
2574
|
+
if (N)
|
|
2557
2575
|
try {
|
|
2558
|
-
if (
|
|
2559
|
-
const
|
|
2560
|
-
|
|
2561
|
-
} else if (
|
|
2562
|
-
const
|
|
2563
|
-
C.commands.setContent(
|
|
2576
|
+
if (Y === "html") {
|
|
2577
|
+
const oe = document.createElement("div");
|
|
2578
|
+
oe.innerHTML = N, C.commands.setContent(N);
|
|
2579
|
+
} else if (Y === "json") {
|
|
2580
|
+
const oe = JSON.parse(N);
|
|
2581
|
+
C.commands.setContent(oe);
|
|
2564
2582
|
}
|
|
2565
2583
|
} catch {
|
|
2566
|
-
alert(
|
|
2584
|
+
alert(Y === "html" ? "HTML 格式错误,请检查输入内容" : "JSON 格式错误,请检查输入内容");
|
|
2567
2585
|
return;
|
|
2568
2586
|
}
|
|
2569
2587
|
else
|
|
2570
|
-
P.current ? C.commands.setContent(P.current) :
|
|
2588
|
+
P.current ? C.commands.setContent(P.current) : E.current && C.commands.setContent(E.current);
|
|
2571
2589
|
} else
|
|
2572
|
-
P.current ? C.commands.setContent(P.current) :
|
|
2573
|
-
|
|
2574
|
-
}, [
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2590
|
+
P.current ? C.commands.setContent(P.current) : E.current && C.commands.setContent(E.current);
|
|
2591
|
+
D("normal"), l == null || l("normal");
|
|
2592
|
+
}, [n, k, l]), Re = S((C) => {
|
|
2593
|
+
var oe, X;
|
|
2594
|
+
const N = C.getEditor(), Y = (re, de) => {
|
|
2595
|
+
Ke() || (rt(N, re), I(re), O(!1), setTimeout(() => {
|
|
2596
|
+
j({ x: de.right, y: de.bottom + 6 }), I(re), O(!0);
|
|
2597
|
+
}, 0));
|
|
2598
|
+
};
|
|
2599
|
+
(oe = F.current) == null || oe.call(F), F.current = Ct(N, {
|
|
2600
|
+
onOpen: Y,
|
|
2601
|
+
shouldShow: () => !Ke(),
|
|
2602
|
+
shouldOpen: () => !Ke()
|
|
2603
|
+
}), (X = U.current) == null || X.call(U), U.current = Nt(N.view.dom), N.view.dom.addEventListener("contextmenu", (re) => {
|
|
2604
|
+
if (Mt()) {
|
|
2605
|
+
O(!1);
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2608
|
+
const le = re.target.closest("td, th");
|
|
2609
|
+
if (!Ke())
|
|
2610
|
+
if (le) {
|
|
2611
|
+
re.preventDefault();
|
|
2612
|
+
const ie = N.state.selection;
|
|
2613
|
+
if ("$anchorCell" in ie) {
|
|
2614
|
+
let ze = !1;
|
|
2584
2615
|
try {
|
|
2585
|
-
|
|
2586
|
-
const
|
|
2587
|
-
|
|
2616
|
+
ie.forEachCell((Ge, ut) => {
|
|
2617
|
+
const We = N.view.nodeDOM(ut);
|
|
2618
|
+
We && We instanceof HTMLElement && (We === le || We.contains(le) || le.contains(We)) && (ze = !0);
|
|
2588
2619
|
});
|
|
2589
2620
|
} catch {
|
|
2590
2621
|
}
|
|
2591
|
-
|
|
2622
|
+
ze || je(N, le), j({ x: re.clientX, y: re.clientY }), I(le), O(!0);
|
|
2592
2623
|
return;
|
|
2593
2624
|
}
|
|
2594
|
-
|
|
2595
|
-
const
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
},
|
|
2625
|
+
rt(N, le);
|
|
2626
|
+
const Ne = V;
|
|
2627
|
+
Ne && O(!1), setTimeout(() => {
|
|
2628
|
+
j({ x: re.clientX, y: re.clientY }), I(le), O(!0);
|
|
2629
|
+
}, Ne ? 0 : 50);
|
|
2599
2630
|
} else
|
|
2600
|
-
O(!1),
|
|
2631
|
+
O(!1), I(null), lt();
|
|
2601
2632
|
});
|
|
2602
|
-
}, [
|
|
2603
|
-
if (
|
|
2604
|
-
|
|
2605
|
-
|
|
2633
|
+
}, [V]), Fe = S((C) => {
|
|
2634
|
+
if (y == null || y(C), C === "snapshot") {
|
|
2635
|
+
n == null || n.createSnapshot().then((N) => {
|
|
2636
|
+
N ? qe(Se.t("compare.snapshotCreated", { time: N.label || N.timestamp })) : qe({ message: Se.t("compare.snapshotFailed"), type: "error" });
|
|
2606
2637
|
});
|
|
2607
2638
|
return;
|
|
2608
2639
|
}
|
|
2609
|
-
if (C === "compare" &&
|
|
2610
|
-
const
|
|
2611
|
-
|
|
2612
|
-
var
|
|
2613
|
-
const
|
|
2614
|
-
|
|
2615
|
-
},
|
|
2640
|
+
if (C === "compare" && ae(!0), C === "fullscreen" && ve(), C === "autoFormat" && (n == null || n.toggleAutoFormatPanel()), C === "importWord") {
|
|
2641
|
+
const N = document.createElement("input");
|
|
2642
|
+
N.type = "file", N.accept = ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", N.onchange = async (Y) => {
|
|
2643
|
+
var X;
|
|
2644
|
+
const oe = (X = Y.target.files) == null ? void 0 : X[0];
|
|
2645
|
+
oe && await (n == null ? void 0 : n.importWordFile(oe));
|
|
2646
|
+
}, N.click();
|
|
2616
2647
|
}
|
|
2617
2648
|
if (C === "importMarkdown") {
|
|
2618
|
-
const
|
|
2619
|
-
|
|
2620
|
-
var
|
|
2621
|
-
const
|
|
2622
|
-
|
|
2623
|
-
},
|
|
2649
|
+
const N = document.createElement("input");
|
|
2650
|
+
N.type = "file", N.accept = ".md,.markdown,text/markdown", N.onchange = async (Y) => {
|
|
2651
|
+
var X;
|
|
2652
|
+
const oe = (X = Y.target.files) == null ? void 0 : X[0];
|
|
2653
|
+
oe && await (n == null ? void 0 : n.importMarkdownFile(oe));
|
|
2654
|
+
}, N.click();
|
|
2624
2655
|
}
|
|
2625
|
-
C === "exportWord" && (
|
|
2626
|
-
}, [
|
|
2627
|
-
if (!
|
|
2628
|
-
const
|
|
2629
|
-
switch ("$anchorCell" in
|
|
2656
|
+
C === "exportWord" && (G((n == null ? void 0 : n.getDocumentTitle()) || "document"), te(!0)), C === "exportMarkdown" && (De((n == null ? void 0 : n.getDocumentTitle()) || "document"), Te(!0));
|
|
2657
|
+
}, [y, n]), $e = S((C) => {
|
|
2658
|
+
if (!n) return;
|
|
2659
|
+
const N = n.getEditor();
|
|
2660
|
+
switch ("$anchorCell" in N.state.selection || (Lt(N), lt()), C) {
|
|
2630
2661
|
case "addRowBefore":
|
|
2631
|
-
|
|
2662
|
+
n.addTableRowBefore();
|
|
2632
2663
|
break;
|
|
2633
2664
|
case "addRowAfter":
|
|
2634
|
-
|
|
2665
|
+
n.addTableRowAfter();
|
|
2635
2666
|
break;
|
|
2636
2667
|
case "addColumnBefore":
|
|
2637
|
-
|
|
2668
|
+
n.addTableColumnBefore();
|
|
2638
2669
|
break;
|
|
2639
2670
|
case "addColumnAfter":
|
|
2640
|
-
|
|
2671
|
+
n.addTableColumnAfter();
|
|
2672
|
+
break;
|
|
2673
|
+
case "selectRow": {
|
|
2674
|
+
const X = _ ?? Ve(N);
|
|
2675
|
+
X && Ht(N, X);
|
|
2676
|
+
break;
|
|
2677
|
+
}
|
|
2678
|
+
case "selectColumn": {
|
|
2679
|
+
const X = _ ?? Ve(N);
|
|
2680
|
+
X && St(N, X);
|
|
2681
|
+
break;
|
|
2682
|
+
}
|
|
2683
|
+
case "selectTable": {
|
|
2684
|
+
const X = _ ?? Ve(N);
|
|
2685
|
+
X && Dt(N, X);
|
|
2686
|
+
break;
|
|
2687
|
+
}
|
|
2688
|
+
case "extendSelection": {
|
|
2689
|
+
const X = _ ?? Ve(N);
|
|
2690
|
+
Tt(N, X ?? void 0);
|
|
2641
2691
|
break;
|
|
2692
|
+
}
|
|
2642
2693
|
case "mergeCells":
|
|
2643
|
-
|
|
2644
|
-
if (
|
|
2645
|
-
if (document.contains(
|
|
2646
|
-
|
|
2694
|
+
N.chain().mergeCells().run(), setTimeout(() => {
|
|
2695
|
+
if (_)
|
|
2696
|
+
if (document.contains(_))
|
|
2697
|
+
je(N, _);
|
|
2647
2698
|
else {
|
|
2648
|
-
const { state:
|
|
2649
|
-
if ("$anchorCell" in
|
|
2650
|
-
const
|
|
2651
|
-
if (
|
|
2652
|
-
const ie =
|
|
2653
|
-
ie &&
|
|
2699
|
+
const { state: X } = N, { selection: re } = X;
|
|
2700
|
+
if ("$anchorCell" in re) {
|
|
2701
|
+
const de = re.$anchorCell.pos;
|
|
2702
|
+
if (X.doc.nodeAt(de)) {
|
|
2703
|
+
const ie = N.view.nodeDOM(de);
|
|
2704
|
+
ie && je(N, ie);
|
|
2654
2705
|
}
|
|
2655
2706
|
}
|
|
2656
2707
|
}
|
|
2657
2708
|
}, 0);
|
|
2658
2709
|
break;
|
|
2659
2710
|
case "splitCell": {
|
|
2660
|
-
const
|
|
2661
|
-
let
|
|
2662
|
-
if (
|
|
2711
|
+
const X = _;
|
|
2712
|
+
let re = null;
|
|
2713
|
+
if (X)
|
|
2663
2714
|
try {
|
|
2664
|
-
|
|
2715
|
+
re = N.view.posAtDOM(X, 0);
|
|
2665
2716
|
} catch {
|
|
2666
2717
|
}
|
|
2667
|
-
|
|
2668
|
-
const { state:
|
|
2669
|
-
if (
|
|
2670
|
-
|
|
2718
|
+
N.chain().splitCell().run(), setTimeout(() => {
|
|
2719
|
+
const { state: de } = N, { selection: le } = de;
|
|
2720
|
+
if (le instanceof ft) {
|
|
2721
|
+
N.commands.focus();
|
|
2671
2722
|
return;
|
|
2672
2723
|
}
|
|
2673
|
-
if (
|
|
2724
|
+
if (re !== null)
|
|
2674
2725
|
try {
|
|
2675
|
-
const ie =
|
|
2726
|
+
const ie = N.view.nodeDOM(re);
|
|
2676
2727
|
if (ie && document.contains(ie)) {
|
|
2677
|
-
|
|
2728
|
+
je(N, ie);
|
|
2678
2729
|
return;
|
|
2679
2730
|
}
|
|
2680
2731
|
} catch {
|
|
2681
2732
|
}
|
|
2682
2733
|
try {
|
|
2683
2734
|
let ie = null;
|
|
2684
|
-
if (
|
|
2685
|
-
const
|
|
2686
|
-
if (
|
|
2687
|
-
const
|
|
2688
|
-
if (
|
|
2689
|
-
const
|
|
2690
|
-
if (
|
|
2691
|
-
|
|
2735
|
+
if (de.doc.descendants((Oe, Ne) => Oe.type.name === "table" ? (ie = Ne, !1) : !0), ie !== null) {
|
|
2736
|
+
const Oe = de.doc.nodeAt(ie);
|
|
2737
|
+
if (Oe) {
|
|
2738
|
+
const Ne = dt.get(Oe);
|
|
2739
|
+
if (Ne.map.length > 0) {
|
|
2740
|
+
const ze = Ne.map[0] + ie + 1, Ge = N.view.nodeDOM(ze);
|
|
2741
|
+
if (Ge) {
|
|
2742
|
+
je(N, Ge);
|
|
2692
2743
|
return;
|
|
2693
2744
|
}
|
|
2694
2745
|
}
|
|
@@ -2696,174 +2747,174 @@ const Xt = ({ editor: t, visible: o, onVisibleChange: c }) => {
|
|
|
2696
2747
|
}
|
|
2697
2748
|
} catch {
|
|
2698
2749
|
}
|
|
2699
|
-
|
|
2750
|
+
N.commands.focus();
|
|
2700
2751
|
}, 0);
|
|
2701
2752
|
break;
|
|
2702
2753
|
}
|
|
2703
2754
|
case "deleteRow":
|
|
2704
|
-
|
|
2755
|
+
n.deleteTableRow();
|
|
2705
2756
|
break;
|
|
2706
2757
|
case "deleteColumn":
|
|
2707
|
-
|
|
2758
|
+
n.deleteTableColumn();
|
|
2708
2759
|
break;
|
|
2709
2760
|
case "deleteTable":
|
|
2710
|
-
|
|
2761
|
+
n.deleteTable();
|
|
2711
2762
|
break;
|
|
2712
2763
|
case "tableSettings":
|
|
2713
|
-
|
|
2764
|
+
ee(!0);
|
|
2714
2765
|
break;
|
|
2715
2766
|
case "cellSettings":
|
|
2716
|
-
|
|
2767
|
+
ne(!0);
|
|
2717
2768
|
break;
|
|
2718
2769
|
}
|
|
2719
|
-
}, [
|
|
2720
|
-
|
|
2721
|
-
const
|
|
2722
|
-
return
|
|
2770
|
+
}, [n, _]), ve = S(() => {
|
|
2771
|
+
xe((C) => {
|
|
2772
|
+
const N = !C;
|
|
2773
|
+
return $ == null || $(N), N;
|
|
2723
2774
|
});
|
|
2724
|
-
}, [
|
|
2725
|
-
C.key === "Escape" && ye && (
|
|
2726
|
-
}, [ye,
|
|
2775
|
+
}, [$]), Ce = S((C) => {
|
|
2776
|
+
C.key === "Escape" && ye && (xe(!1), $ == null || $(!1));
|
|
2777
|
+
}, [ye, $]), ot = Me(() => {
|
|
2727
2778
|
const C = {};
|
|
2728
|
-
return u ? (
|
|
2729
|
-
}, [u, s,
|
|
2730
|
-
return
|
|
2731
|
-
getEditorManager: () =>
|
|
2732
|
-
getHTML: () => (
|
|
2733
|
-
getJSON: () => (
|
|
2734
|
-
getText: () => (
|
|
2735
|
-
setContent: (C) =>
|
|
2736
|
-
setJSON: (C) =>
|
|
2737
|
-
insertHTML: (C) =>
|
|
2738
|
-
insertText: (C) =>
|
|
2739
|
-
focus: () =>
|
|
2740
|
-
blur: () =>
|
|
2741
|
-
isEmpty: () => (
|
|
2742
|
-
clear: () =>
|
|
2743
|
-
undo: () =>
|
|
2744
|
-
redo: () =>
|
|
2745
|
-
setReadonly: (C) =>
|
|
2746
|
-
insertTable: (C,
|
|
2747
|
-
insertImage: (C,
|
|
2748
|
-
insertVideo: (C,
|
|
2749
|
-
exportMarkdown: () => (
|
|
2750
|
-
exportHTMLDocument: (C) => (
|
|
2779
|
+
return u ? (m && (C.minHeight = typeof m == "number" ? `${m}px` : m), d && (C.maxHeight = typeof d == "number" ? `${d}px` : d)) : (s && (C.height = typeof s == "number" ? `${s}px` : s), m && (C.minHeight = typeof m == "number" ? `${m}px` : m)), C;
|
|
2780
|
+
}, [u, s, m, d]);
|
|
2781
|
+
return at(r, () => ({
|
|
2782
|
+
getEditorManager: () => n,
|
|
2783
|
+
getHTML: () => (n == null ? void 0 : n.getHTML()) ?? "",
|
|
2784
|
+
getJSON: () => (n == null ? void 0 : n.getJSON()) ?? { type: "doc", content: [] },
|
|
2785
|
+
getText: () => (n == null ? void 0 : n.getText()) ?? "",
|
|
2786
|
+
setContent: (C) => n == null ? void 0 : n.setContent(C),
|
|
2787
|
+
setJSON: (C) => n == null ? void 0 : n.setJSON(C),
|
|
2788
|
+
insertHTML: (C) => n == null ? void 0 : n.insertHTML(C),
|
|
2789
|
+
insertText: (C) => n == null ? void 0 : n.insertText(C),
|
|
2790
|
+
focus: () => n == null ? void 0 : n.focus(),
|
|
2791
|
+
blur: () => n == null ? void 0 : n.blur(),
|
|
2792
|
+
isEmpty: () => (n == null ? void 0 : n.isEmpty()) ?? !0,
|
|
2793
|
+
clear: () => n == null ? void 0 : n.clear(),
|
|
2794
|
+
undo: () => n == null ? void 0 : n.undo(),
|
|
2795
|
+
redo: () => n == null ? void 0 : n.redo(),
|
|
2796
|
+
setReadonly: (C) => n == null ? void 0 : n.setReadonly(C),
|
|
2797
|
+
insertTable: (C, N, Y) => n == null ? void 0 : n.insertTable(C, N, Y),
|
|
2798
|
+
insertImage: (C, N, Y) => n == null ? void 0 : n.insertImage(C, N, Y),
|
|
2799
|
+
insertVideo: (C, N, Y) => n == null ? void 0 : n.insertVideo(C, N, Y),
|
|
2800
|
+
exportMarkdown: () => (n == null ? void 0 : n.exportMarkdown()) ?? "",
|
|
2801
|
+
exportHTMLDocument: (C) => (n == null ? void 0 : n.exportHTMLDocument(C)) ?? "",
|
|
2751
2802
|
exportWordFile: async (C) => {
|
|
2752
|
-
await (
|
|
2803
|
+
await (n == null ? void 0 : n.exportWordFile(C));
|
|
2753
2804
|
},
|
|
2754
|
-
exportMarkdownFile: (C) => (
|
|
2755
|
-
importMarkdown: (C) =>
|
|
2756
|
-
importHTMLFile: (C) => (
|
|
2757
|
-
importMarkdownFile: (C) => (
|
|
2758
|
-
importWordFile: (C) => (
|
|
2759
|
-
parseHTML: (C) =>
|
|
2760
|
-
addSnapshot: (C,
|
|
2761
|
-
toggleViewMode:
|
|
2762
|
-
restoreOriginalContent:
|
|
2763
|
-
getViewMode: () =>
|
|
2764
|
-
toggleFullscreen:
|
|
2805
|
+
exportMarkdownFile: (C) => (n == null ? void 0 : n.exportMarkdownFile(C)) ?? Promise.resolve(),
|
|
2806
|
+
importMarkdown: (C) => n == null ? void 0 : n.importMarkdown(C),
|
|
2807
|
+
importHTMLFile: (C) => (n == null ? void 0 : n.importHTMLFile(C)) ?? Promise.resolve(),
|
|
2808
|
+
importMarkdownFile: (C) => (n == null ? void 0 : n.importMarkdownFile(C)) ?? Promise.resolve(),
|
|
2809
|
+
importWordFile: (C) => (n == null ? void 0 : n.importWordFile(C)) ?? Promise.resolve({ messages: [] }),
|
|
2810
|
+
parseHTML: (C) => n == null ? void 0 : n.parseHTML(C),
|
|
2811
|
+
addSnapshot: (C, N) => (n == null ? void 0 : n.addSnapshot(C, N)) ?? Promise.resolve(null),
|
|
2812
|
+
toggleViewMode: Ae,
|
|
2813
|
+
restoreOriginalContent: Ee,
|
|
2814
|
+
getViewMode: () => k,
|
|
2815
|
+
toggleFullscreen: ve,
|
|
2765
2816
|
isFullscreen: () => ye
|
|
2766
|
-
}), [
|
|
2817
|
+
}), [n, Ae, Ee, k, ve, ye]), /* @__PURE__ */ w(
|
|
2767
2818
|
"div",
|
|
2768
2819
|
{
|
|
2769
|
-
className: `cyte-editor${
|
|
2770
|
-
style:
|
|
2771
|
-
onKeyDown:
|
|
2820
|
+
className: `cyte-editor${H ? " is-disabled" : ""}${L ? " is-readonly" : ""}${Z ? " is-focused" : ""}${pe ? " is-empty" : ""}${u ? " is-auto-height" : ""}${u && d ? " is-auto-height-limited" : ""}${ye ? " is-fullscreen" : ""}`,
|
|
2821
|
+
style: ot,
|
|
2822
|
+
onKeyDown: Ce,
|
|
2772
2823
|
children: [
|
|
2773
|
-
ye && /* @__PURE__ */
|
|
2774
|
-
/* @__PURE__ */
|
|
2775
|
-
/* @__PURE__ */
|
|
2824
|
+
ye && /* @__PURE__ */ w("div", { className: "cyte-fullscreen-header", children: [
|
|
2825
|
+
/* @__PURE__ */ w("div", { className: "cyte-fullscreen-header__title", children: [
|
|
2826
|
+
/* @__PURE__ */ w("svg", { className: "cyte-fullscreen-header__title-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2776
2827
|
/* @__PURE__ */ e("path", { d: "M8 4H4V8M4 4L10 10" }),
|
|
2777
2828
|
/* @__PURE__ */ e("path", { d: "M16 4H20V8M20 4L14 10" }),
|
|
2778
2829
|
/* @__PURE__ */ e("path", { d: "M4 16V20H8M4 20L10 14" }),
|
|
2779
2830
|
/* @__PURE__ */ e("path", { d: "M20 16V20H16M20 20L14 14" })
|
|
2780
2831
|
] }),
|
|
2781
|
-
|
|
2832
|
+
Ue("toolbar.fullscreenTitle")
|
|
2782
2833
|
] }),
|
|
2783
|
-
/* @__PURE__ */
|
|
2834
|
+
/* @__PURE__ */ w("button", { className: "cyte-fullscreen-header__close", onClick: ve, children: [
|
|
2784
2835
|
"✕ ",
|
|
2785
|
-
|
|
2836
|
+
Ue("toolbar.exitFullscreen")
|
|
2786
2837
|
] })
|
|
2787
2838
|
] }),
|
|
2788
|
-
|
|
2789
|
-
|
|
2839
|
+
W ? W({ manager: n, activeStates: He, disabledStates: Ie, isReady: R }) : R && n && /* @__PURE__ */ e(
|
|
2840
|
+
en,
|
|
2790
2841
|
{
|
|
2791
|
-
items:
|
|
2792
|
-
manager:
|
|
2793
|
-
activeStates:
|
|
2794
|
-
disabledStates:
|
|
2795
|
-
viewMode:
|
|
2796
|
-
onToggleViewMode:
|
|
2797
|
-
onToolbarClick:
|
|
2842
|
+
items: se,
|
|
2843
|
+
manager: n,
|
|
2844
|
+
activeStates: He,
|
|
2845
|
+
disabledStates: Ie,
|
|
2846
|
+
viewMode: k,
|
|
2847
|
+
onToggleViewMode: Ae,
|
|
2848
|
+
onToolbarClick: Fe
|
|
2798
2849
|
}
|
|
2799
2850
|
),
|
|
2800
|
-
/* @__PURE__ */ e("div", { ref:
|
|
2801
|
-
|
|
2802
|
-
|
|
2851
|
+
/* @__PURE__ */ e("div", { ref: he, className: "tp-editor-content" }),
|
|
2852
|
+
R && n && /* @__PURE__ */ e(
|
|
2853
|
+
tn,
|
|
2803
2854
|
{
|
|
2804
|
-
editor:
|
|
2805
|
-
visible:
|
|
2806
|
-
position:
|
|
2807
|
-
targetCell:
|
|
2855
|
+
editor: n.getEditor(),
|
|
2856
|
+
visible: V,
|
|
2857
|
+
position: K,
|
|
2858
|
+
targetCell: _,
|
|
2808
2859
|
onVisibleChange: O,
|
|
2809
|
-
onAction:
|
|
2860
|
+
onAction: $e
|
|
2810
2861
|
}
|
|
2811
2862
|
),
|
|
2812
|
-
|
|
2813
|
-
|
|
2863
|
+
R && n && /* @__PURE__ */ e(
|
|
2864
|
+
cn,
|
|
2814
2865
|
{
|
|
2815
|
-
editor:
|
|
2816
|
-
visible:
|
|
2817
|
-
onVisibleChange:
|
|
2866
|
+
editor: n.getEditor(),
|
|
2867
|
+
visible: Q,
|
|
2868
|
+
onVisibleChange: ee
|
|
2818
2869
|
}
|
|
2819
2870
|
),
|
|
2820
|
-
|
|
2821
|
-
|
|
2871
|
+
R && n && /* @__PURE__ */ e(
|
|
2872
|
+
hn,
|
|
2822
2873
|
{
|
|
2823
|
-
editor:
|
|
2824
|
-
visible:
|
|
2825
|
-
onVisibleChange:
|
|
2874
|
+
editor: n.getEditor(),
|
|
2875
|
+
visible: we,
|
|
2876
|
+
onVisibleChange: ne
|
|
2826
2877
|
}
|
|
2827
2878
|
),
|
|
2828
|
-
|
|
2829
|
-
|
|
2879
|
+
R && n && /* @__PURE__ */ e(
|
|
2880
|
+
fn,
|
|
2830
2881
|
{
|
|
2831
|
-
manager:
|
|
2832
|
-
visible:
|
|
2833
|
-
onVisibleChange:
|
|
2882
|
+
manager: n,
|
|
2883
|
+
visible: ue,
|
|
2884
|
+
onVisibleChange: ae
|
|
2834
2885
|
}
|
|
2835
2886
|
),
|
|
2836
2887
|
/* @__PURE__ */ e(
|
|
2837
|
-
|
|
2888
|
+
mn,
|
|
2838
2889
|
{
|
|
2839
|
-
visible:
|
|
2840
|
-
defaultFilename:
|
|
2841
|
-
onConfirm: (C) =>
|
|
2842
|
-
onClose: () =>
|
|
2890
|
+
visible: q,
|
|
2891
|
+
defaultFilename: J,
|
|
2892
|
+
onConfirm: (C) => n == null ? void 0 : n.exportWordFile(C),
|
|
2893
|
+
onClose: () => te(!1)
|
|
2843
2894
|
}
|
|
2844
2895
|
),
|
|
2845
2896
|
/* @__PURE__ */ e(
|
|
2846
|
-
|
|
2897
|
+
gn,
|
|
2847
2898
|
{
|
|
2848
|
-
visible:
|
|
2849
|
-
defaultFilename:
|
|
2850
|
-
onConfirm: (C) =>
|
|
2851
|
-
onClose: () =>
|
|
2899
|
+
visible: me,
|
|
2900
|
+
defaultFilename: Be,
|
|
2901
|
+
onConfirm: (C) => n == null ? void 0 : n.exportMarkdownFile(C),
|
|
2902
|
+
onClose: () => Te(!1)
|
|
2852
2903
|
}
|
|
2853
2904
|
)
|
|
2854
2905
|
]
|
|
2855
2906
|
}
|
|
2856
2907
|
);
|
|
2857
2908
|
});
|
|
2858
|
-
|
|
2909
|
+
wn.displayName = "CyteEditor";
|
|
2859
2910
|
export {
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2911
|
+
hn as CellSettingsModal,
|
|
2912
|
+
Ye as ColorPickerInput,
|
|
2913
|
+
fn as CompareOverlay,
|
|
2914
|
+
wn as CyteEditor,
|
|
2915
|
+
tn as TableContextMenu,
|
|
2916
|
+
cn as TableSettingsModal,
|
|
2917
|
+
Et as useEditor,
|
|
2867
2918
|
fe as useI18n,
|
|
2868
|
-
|
|
2919
|
+
Rt as useToolbarState
|
|
2869
2920
|
};
|