@baishuyun/ui-base 2.2.3 → 2.2.5
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/Card/Card-Y1ISqAp9.js +86 -0
- package/dist/Card/index.js +1 -1
- package/dist/CheckBox/{CheckBox-VlP6u_-s.js → CheckBox-C9sXWSA5.js} +1 -1
- package/dist/CheckBox/index.js +1 -1
- package/dist/ColorPicker/{ColorPicker-049kyJn6.js → ColorPicker-DNIXPakN.js} +70 -64
- package/dist/ColorPicker/index.js +1 -1
- package/dist/DropDown/{DropDown-BkTY-3y0.js → DropDown-DGkSeXQT.js} +1 -1
- package/dist/DropDown/index.js +1 -1
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +6 -2
- package/dist/Editor/{index-C0MY9j94.js → index-CCq3AgcW.js} +426 -412
- package/dist/Editor/index.js +115 -108
- package/dist/Icon/Icon-CBlIwtp2.js +24 -0
- package/dist/Icon/index.js +1 -1
- package/dist/InputTag/{InputTag-S9hHXsyQ.js → InputTag-C6MbuO-e.js} +1 -1
- package/dist/InputTag/index.js +1 -1
- package/dist/Modal/{Modal-oRJ-Almn.js → Modal-z3TvEXwN.js} +1 -1
- package/dist/Modal/index.js +1 -1
- package/dist/Select/{Select-BiARGTPz.js → Select-hwXXDuLU.js} +3 -3
- package/dist/Select/{SelectInputSearch-DigfTvpo.js → SelectInputSearch-ChUpUgxa.js} +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/Tabs/{TabSelect-bKB0Qe9F.js → TabSelect-DL8Bhehc.js} +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/Tree/index.js +1 -1
- package/dist/components/Card/Card.type.d.ts +9 -1
- package/dist/components/ColorPicker/ColorPicker.type.d.ts +11 -0
- package/dist/components/Editor/ToolbarPlugin/Buttons/index.d.ts +6 -3
- package/dist/components/Editor/ToolbarPlugin/Buttons/registry.d.ts +6 -0
- package/dist/components/Editor/ToolbarPlugin/interface.d.ts +4 -3
- package/dist/components/Editor/index.d.ts +5 -0
- package/dist/index.js +9 -9
- package/dist/vendors/{Tree-CjrhMBFX.js → Tree-CLEy-xqz.js} +2 -2
- package/dist/vendors/{lexical-DdSmj_Kv.js → lexical-DO7eMeC2.js} +7 -7
- package/package.json +2 -2
- package/dist/Card/Card-DHOMkrEE.js +0 -74
- package/dist/Icon/Icon-CkHAU1fA.js +0 -24
|
@@ -1,251 +1,60 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { I as
|
|
3
|
-
import
|
|
1
|
+
import { jsx as r, jsxs as g, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import { I as E } from "../Icon/Icon-CBlIwtp2.js";
|
|
3
|
+
import ge, { createContext as ve, useContext as ke, useMemo as ye, useCallback as A, useState as N, forwardRef as ae, useImperativeHandle as se, useRef as K } from "react";
|
|
4
4
|
import { c as xe } from "../vendors/clsx-OuTLNxxd.js";
|
|
5
|
-
import {
|
|
6
|
-
import { u as
|
|
7
|
-
import { D as
|
|
8
|
-
import { FONT_SIZES as
|
|
9
|
-
import { C as
|
|
10
|
-
import { AlignLeftOutlined as
|
|
11
|
-
import { M as _e } from "../Modal/Modal-
|
|
12
|
-
import { message as
|
|
5
|
+
import { l as ce, i as de, P as T, _ as O, y as X, w as $, E as ee, p as we, x as z, r as Ne, t as be, v as ue, o as b, u as H, M as Y, z as Ce, A as Ie, b as Ue, B as Oe } from "../vendors/lexical-DO7eMeC2.js";
|
|
6
|
+
import { u as w } from "../vendors/useLocale-DgqW9M3h.js";
|
|
7
|
+
import { D as pe } from "../DropDown/DropDown-DGkSeXQT.js";
|
|
8
|
+
import { FONT_SIZES as Se } from "./constants/index.js";
|
|
9
|
+
import { C as me } from "../ColorPicker/ColorPicker-DNIXPakN.js";
|
|
10
|
+
import { AlignLeftOutlined as te, AlignCenterOutlined as Le, AlignRightOutlined as Te } from "@ant-design/icons";
|
|
11
|
+
import { M as _e } from "../Modal/Modal-z3TvEXwN.js";
|
|
12
|
+
import { message as Z, Input as V, Button as j, Form as J } from "antd";
|
|
13
13
|
import Ae from "../CheckBox/index.js";
|
|
14
|
-
import { AnimatePresence as
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
"lexical-editor__toolbar-button-active": "_lexical-editor__toolbar-button-active_1y192_7"
|
|
18
|
-
}, b = (n) => {
|
|
19
|
-
const { icon: e, tooltip: t, onClick: r, disabled: l = !1, active: o = !1, size: c = 14 } = n;
|
|
20
|
-
return /* @__PURE__ */ i(
|
|
21
|
-
"button",
|
|
22
|
-
{
|
|
23
|
-
className: xe(te["lexical-editor__toolbar-button"], {
|
|
24
|
-
[te["lexical-editor__toolbar-button-active"]]: o
|
|
25
|
-
}),
|
|
26
|
-
type: "button",
|
|
27
|
-
onClick: r,
|
|
28
|
-
disabled: l,
|
|
29
|
-
title: t,
|
|
30
|
-
children: fe.isValidElement(e) ? e : /* @__PURE__ */ i(D, { name: e, size: c })
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
}, Me = ge(null), U = () => {
|
|
34
|
-
const n = ve(Me);
|
|
35
|
-
if (!n)
|
|
36
|
-
throw new Error("useTextFormatsContext must be used within TextFormatsProvider");
|
|
37
|
-
return n;
|
|
38
|
-
}, Re = () => {
|
|
39
|
-
const [n] = C(), e = U(), { t } = N(), r = e.bold, l = () => {
|
|
40
|
-
n.dispatchCommand(G, "bold");
|
|
41
|
-
};
|
|
42
|
-
return /* @__PURE__ */ i(b, { icon: "bold", tooltip: t("editor.bold"), active: r, onClick: l });
|
|
43
|
-
}, Fe = () => {
|
|
44
|
-
const [n] = C(), e = U(), { t } = N(), r = e.underline, l = () => {
|
|
45
|
-
n.dispatchCommand(G, "underline");
|
|
46
|
-
};
|
|
47
|
-
return /* @__PURE__ */ i(
|
|
48
|
-
b,
|
|
49
|
-
{
|
|
50
|
-
icon: "underline",
|
|
51
|
-
tooltip: t("editor.underline"),
|
|
52
|
-
active: r,
|
|
53
|
-
onClick: l
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
}, De = () => {
|
|
57
|
-
const [n] = C(), e = U(), { t } = N(), r = e.italic, l = () => {
|
|
58
|
-
n.dispatchCommand(G, "italic");
|
|
59
|
-
};
|
|
60
|
-
return /* @__PURE__ */ i(
|
|
61
|
-
b,
|
|
62
|
-
{
|
|
63
|
-
icon: "italic",
|
|
64
|
-
tooltip: t("editor.italic"),
|
|
65
|
-
active: r,
|
|
66
|
-
onClick: l
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
}, Be = () => {
|
|
70
|
-
const [n] = C(), e = U(), t = ke(() => Oe.map((l) => ({
|
|
71
|
-
key: l.value,
|
|
72
|
-
label: l.label
|
|
73
|
-
})), []), r = T(
|
|
74
|
-
(l) => {
|
|
75
|
-
const o = l.key;
|
|
76
|
-
n.update(() => {
|
|
77
|
-
const c = A();
|
|
78
|
-
O(c) && H(c, {
|
|
79
|
-
"font-size": o
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
[n]
|
|
84
|
-
);
|
|
85
|
-
return /* @__PURE__ */ i(
|
|
86
|
-
ue,
|
|
87
|
-
{
|
|
88
|
-
menus: t,
|
|
89
|
-
onClick: r,
|
|
90
|
-
activeKey: [e.fontSize],
|
|
91
|
-
showSearch: !1,
|
|
92
|
-
style: {
|
|
93
|
-
width: "60px",
|
|
94
|
-
minWidth: "60px"
|
|
95
|
-
},
|
|
96
|
-
children: /* @__PURE__ */ i("div", { className: "dropdown__trigger inline-flex", children: /* @__PURE__ */ i(b, { icon: "fontsize", tooltip: "字号", active: !1 }) })
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
}, Ee = () => {
|
|
100
|
-
const [n] = C(), e = U(), { t } = N(), r = T(
|
|
101
|
-
(l) => {
|
|
102
|
-
n.update(() => {
|
|
103
|
-
const o = A();
|
|
104
|
-
O(o) && H(o, {
|
|
105
|
-
color: l
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
[n]
|
|
110
|
-
);
|
|
111
|
-
return /* @__PURE__ */ i(
|
|
112
|
-
pe,
|
|
113
|
-
{
|
|
114
|
-
value: e.fontColor,
|
|
115
|
-
onChange: r,
|
|
116
|
-
placement: "bottom-start",
|
|
117
|
-
children: /* @__PURE__ */ i("div", { className: "trigger-picker inline-flex", children: /* @__PURE__ */ i(
|
|
118
|
-
b,
|
|
119
|
-
{
|
|
120
|
-
icon: "fontcolor",
|
|
121
|
-
tooltip: t("editor.fontColor"),
|
|
122
|
-
onClick: () => {
|
|
123
|
-
},
|
|
124
|
-
active: !1
|
|
125
|
-
}
|
|
126
|
-
) })
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
}, Pe = () => {
|
|
130
|
-
const [n] = C(), e = U(), { t } = N(), r = T(
|
|
131
|
-
(l) => {
|
|
132
|
-
n.update(() => {
|
|
133
|
-
const o = A();
|
|
134
|
-
O(o) && H(o, {
|
|
135
|
-
"background-color": l
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
},
|
|
139
|
-
[n]
|
|
140
|
-
);
|
|
141
|
-
return /* @__PURE__ */ i(
|
|
142
|
-
pe,
|
|
143
|
-
{
|
|
144
|
-
value: e.backgroundColor,
|
|
145
|
-
onChange: r,
|
|
146
|
-
placement: "bottom-start",
|
|
147
|
-
children: /* @__PURE__ */ i("div", { className: "trigger-picker inline-flex", children: /* @__PURE__ */ i(b, { icon: "fill", tooltip: t("editor.fill"), onClick: () => {
|
|
148
|
-
}, active: !1 }) })
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
}, je = () => {
|
|
152
|
-
var m;
|
|
153
|
-
const [n] = C(), { align: e } = U(), { t } = N(), r = [
|
|
154
|
-
{
|
|
155
|
-
key: "left",
|
|
156
|
-
label: t("leftAlign"),
|
|
157
|
-
icon: /* @__PURE__ */ i(ee, {})
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
key: "center",
|
|
161
|
-
label: t("editor.centerAlign"),
|
|
162
|
-
icon: /* @__PURE__ */ i(Se, {})
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
key: "right",
|
|
166
|
-
label: t("editor.rightAlign"),
|
|
167
|
-
icon: /* @__PURE__ */ i(Le, {})
|
|
168
|
-
}
|
|
169
|
-
], l = T(
|
|
170
|
-
(a) => {
|
|
171
|
-
n.dispatchCommand(ye, a);
|
|
172
|
-
},
|
|
173
|
-
[n]
|
|
174
|
-
), o = r.map((a) => ({
|
|
175
|
-
key: a.key,
|
|
176
|
-
label: /* @__PURE__ */ g("div", { className: "flex items-center gap-2", children: [
|
|
177
|
-
a.icon,
|
|
178
|
-
/* @__PURE__ */ i("span", { children: a.label })
|
|
179
|
-
] })
|
|
180
|
-
})), c = T(
|
|
181
|
-
(a) => {
|
|
182
|
-
l(a.key);
|
|
183
|
-
},
|
|
184
|
-
[l]
|
|
185
|
-
), _ = ((m = r.find((a) => a.key === e)) == null ? void 0 : m.icon) || /* @__PURE__ */ i(ee, {});
|
|
186
|
-
return /* @__PURE__ */ i(
|
|
187
|
-
ue,
|
|
188
|
-
{
|
|
189
|
-
menus: o,
|
|
190
|
-
onClick: c,
|
|
191
|
-
showSearch: !1,
|
|
192
|
-
activeKey: [e],
|
|
193
|
-
style: { width: "110px", minWidth: "110px" },
|
|
194
|
-
children: /* @__PURE__ */ i("div", { className: "trigger-dropdown inline-flex text-sm", children: /* @__PURE__ */ i(
|
|
195
|
-
b,
|
|
196
|
-
{
|
|
197
|
-
icon: _,
|
|
198
|
-
tooltip: t("editor.alignment"),
|
|
199
|
-
onClick: () => {
|
|
200
|
-
},
|
|
201
|
-
active: !1
|
|
202
|
-
}
|
|
203
|
-
) })
|
|
204
|
-
}
|
|
205
|
-
);
|
|
206
|
-
}, ze = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "sms:", "tel:"]);
|
|
207
|
-
class B extends Ne {
|
|
14
|
+
import { AnimatePresence as Me, motion as D } from "motion/react";
|
|
15
|
+
const Be = ve(null), Re = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "sms:", "tel:"]);
|
|
16
|
+
class F extends Ne {
|
|
208
17
|
static getType() {
|
|
209
18
|
return "link";
|
|
210
19
|
}
|
|
211
20
|
static clone(e) {
|
|
212
|
-
return new
|
|
21
|
+
return new F(e.__url, { rel: e.__rel, target: e.__target, title: e.__title }, e.__key);
|
|
213
22
|
}
|
|
214
|
-
constructor(e = "", t = {},
|
|
215
|
-
super(
|
|
216
|
-
const { target:
|
|
217
|
-
this.__url = e, this.__target =
|
|
23
|
+
constructor(e = "", t = {}, i) {
|
|
24
|
+
super(i);
|
|
25
|
+
const { target: o = null, rel: l = null, title: c = null } = t;
|
|
26
|
+
this.__url = e, this.__target = o, this.__rel = l, this.__title = c;
|
|
218
27
|
}
|
|
219
28
|
createDOM(e) {
|
|
220
29
|
const t = document.createElement("a");
|
|
221
|
-
return this.updateLinkDOM(null, t, e),
|
|
30
|
+
return this.updateLinkDOM(null, t, e), be(t, e.theme.link), t;
|
|
222
31
|
}
|
|
223
|
-
updateLinkDOM(e, t,
|
|
224
|
-
if (
|
|
32
|
+
updateLinkDOM(e, t, i) {
|
|
33
|
+
if (ue(t)) {
|
|
225
34
|
e && e.__url === this.__url || (t.href = this.sanitizeUrl(this.__url));
|
|
226
|
-
for (const
|
|
227
|
-
const
|
|
228
|
-
e && e[
|
|
35
|
+
for (const o of ["target", "rel", "title"]) {
|
|
36
|
+
const l = `__${o}`, c = this[l];
|
|
37
|
+
e && e[l] === c || (c ? t[o] = c : t.removeAttribute(o));
|
|
229
38
|
}
|
|
230
39
|
}
|
|
231
40
|
}
|
|
232
|
-
updateDOM(e, t,
|
|
233
|
-
return this.updateLinkDOM(e, t,
|
|
41
|
+
updateDOM(e, t, i) {
|
|
42
|
+
return this.updateLinkDOM(e, t, i), !1;
|
|
234
43
|
}
|
|
235
44
|
static importDOM() {
|
|
236
|
-
return { a: (e) => ({ conversion:
|
|
45
|
+
return { a: (e) => ({ conversion: Ee, priority: 1 }) };
|
|
237
46
|
}
|
|
238
47
|
static importJSON(e) {
|
|
239
|
-
return
|
|
48
|
+
return B().updateFromJSON(e);
|
|
240
49
|
}
|
|
241
50
|
updateFromJSON(e) {
|
|
242
51
|
return super.updateFromJSON(e).setURL(e.url).setRel(e.rel || null).setTarget(e.target || null).setTitle(e.title || null);
|
|
243
52
|
}
|
|
244
53
|
sanitizeUrl(e) {
|
|
245
|
-
e =
|
|
54
|
+
e = oe(e);
|
|
246
55
|
try {
|
|
247
|
-
const t = new URL(
|
|
248
|
-
if (!
|
|
56
|
+
const t = new URL(oe(e));
|
|
57
|
+
if (!Re.has(t.protocol)) return "about:blank";
|
|
249
58
|
} catch {
|
|
250
59
|
return e;
|
|
251
60
|
}
|
|
@@ -283,8 +92,8 @@ class B extends Ne {
|
|
|
283
92
|
return t.__title = e, t;
|
|
284
93
|
}
|
|
285
94
|
insertNewAfter(e, t = !0) {
|
|
286
|
-
const
|
|
287
|
-
return this.insertAfter(
|
|
95
|
+
const i = B(this.__url, { rel: this.__rel, target: this.__target, title: this.__title });
|
|
96
|
+
return this.insertAfter(i, t), i;
|
|
288
97
|
}
|
|
289
98
|
canInsertTextBefore() {
|
|
290
99
|
return !1;
|
|
@@ -298,10 +107,10 @@ class B extends Ne {
|
|
|
298
107
|
isInline() {
|
|
299
108
|
return !0;
|
|
300
109
|
}
|
|
301
|
-
extractWithChild(e, t,
|
|
110
|
+
extractWithChild(e, t, i) {
|
|
302
111
|
if (!O(t)) return !1;
|
|
303
|
-
const
|
|
304
|
-
return this.isParentOf(
|
|
112
|
+
const o = t.anchor.getNode(), l = t.focus.getNode();
|
|
113
|
+
return this.isParentOf(o) && this.isParentOf(l) && t.getTextContent().length > 0;
|
|
305
114
|
}
|
|
306
115
|
isEmailURI() {
|
|
307
116
|
return this.__url.startsWith("mailto:");
|
|
@@ -310,23 +119,23 @@ class B extends Ne {
|
|
|
310
119
|
return this.__url.startsWith("https://") || this.__url.startsWith("http://");
|
|
311
120
|
}
|
|
312
121
|
}
|
|
313
|
-
function
|
|
122
|
+
function Ee(n) {
|
|
314
123
|
let e = null;
|
|
315
|
-
if (
|
|
124
|
+
if (ue(n)) {
|
|
316
125
|
const t = n.textContent;
|
|
317
|
-
(t !== null && t !== "" || n.children.length > 0) && (e =
|
|
126
|
+
(t !== null && t !== "" || n.children.length > 0) && (e = B(n.getAttribute("href") || "", { rel: n.getAttribute("rel"), target: n.getAttribute("target"), title: n.getAttribute("title") }));
|
|
318
127
|
}
|
|
319
128
|
return { node: e };
|
|
320
129
|
}
|
|
321
|
-
function
|
|
322
|
-
return de(new
|
|
130
|
+
function B(n = "", e) {
|
|
131
|
+
return de(new F(n, e));
|
|
323
132
|
}
|
|
324
133
|
function L(n) {
|
|
325
|
-
return n instanceof
|
|
134
|
+
return n instanceof F;
|
|
326
135
|
}
|
|
327
|
-
class q extends
|
|
328
|
-
constructor(e = "", t = {},
|
|
329
|
-
super(e, t,
|
|
136
|
+
class q extends F {
|
|
137
|
+
constructor(e = "", t = {}, i) {
|
|
138
|
+
super(e, t, i), this.__isUnlinked = t.isUnlinked !== void 0 && t.isUnlinked !== null && t.isUnlinked;
|
|
330
139
|
}
|
|
331
140
|
static getType() {
|
|
332
141
|
return "autolink";
|
|
@@ -344,8 +153,8 @@ class q extends B {
|
|
|
344
153
|
createDOM(e) {
|
|
345
154
|
return this.__isUnlinked ? document.createElement("span") : super.createDOM(e);
|
|
346
155
|
}
|
|
347
|
-
updateDOM(e, t,
|
|
348
|
-
return super.updateDOM(e, t,
|
|
156
|
+
updateDOM(e, t, i) {
|
|
157
|
+
return super.updateDOM(e, t, i) || e.__isUnlinked !== this.__isUnlinked;
|
|
349
158
|
}
|
|
350
159
|
static importJSON(e) {
|
|
351
160
|
return ne().updateFromJSON(e);
|
|
@@ -360,10 +169,10 @@ class q extends B {
|
|
|
360
169
|
return { ...super.exportJSON(), isUnlinked: this.__isUnlinked };
|
|
361
170
|
}
|
|
362
171
|
insertNewAfter(e, t = !0) {
|
|
363
|
-
const
|
|
364
|
-
if (z(
|
|
365
|
-
const
|
|
366
|
-
return
|
|
172
|
+
const i = this.getParentOrThrow().insertNewAfter(e, t);
|
|
173
|
+
if (z(i)) {
|
|
174
|
+
const o = ne(this.__url, { isUnlinked: this.__isUnlinked, rel: this.__rel, target: this.__target, title: this.__title });
|
|
175
|
+
return i.append(o), o;
|
|
367
176
|
}
|
|
368
177
|
return null;
|
|
369
178
|
}
|
|
@@ -374,87 +183,87 @@ function ne(n = "", e) {
|
|
|
374
183
|
function P(n) {
|
|
375
184
|
return n instanceof q;
|
|
376
185
|
}
|
|
377
|
-
const
|
|
378
|
-
function
|
|
186
|
+
const Fe = ce("TOGGLE_LINK_COMMAND");
|
|
187
|
+
function re(n, e) {
|
|
379
188
|
if (n.type === "element") {
|
|
380
189
|
const t = n.getNode();
|
|
381
|
-
return z(t) || (function(
|
|
382
|
-
const
|
|
383
|
-
c.append("code",
|
|
384
|
-
for (const
|
|
385
|
-
throw
|
|
190
|
+
return z(t) || (function(i, ...o) {
|
|
191
|
+
const l = new URL("https://lexical.dev/docs/error"), c = new URLSearchParams();
|
|
192
|
+
c.append("code", i);
|
|
193
|
+
for (const m of o) c.append("v", m);
|
|
194
|
+
throw l.search = c.toString(), Error(`Minified Lexical error #${i}; visit ${l.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
|
|
386
195
|
})(252), t.getChildren()[n.offset + e] || null;
|
|
387
196
|
}
|
|
388
197
|
return null;
|
|
389
198
|
}
|
|
390
|
-
function
|
|
391
|
-
const { target: t, title:
|
|
392
|
-
if (
|
|
393
|
-
if (
|
|
394
|
-
const a =
|
|
199
|
+
function De(n, e = {}) {
|
|
200
|
+
const { target: t, title: i } = e, o = e.rel === void 0 ? "noreferrer" : e.rel, l = T();
|
|
201
|
+
if (l === null || !O(l) && !X(l)) return;
|
|
202
|
+
if (X(l)) {
|
|
203
|
+
const a = l.getNodes();
|
|
395
204
|
return a.length === 0 ? void 0 : void a.forEach(((d) => {
|
|
396
205
|
if (n === null) {
|
|
397
|
-
const u =
|
|
206
|
+
const u = $(d, ((s) => !P(s) && L(s)));
|
|
398
207
|
u && (u.insertBefore(d), u.getChildren().length === 0 && u.remove());
|
|
399
208
|
} else {
|
|
400
|
-
const u =
|
|
401
|
-
if (u) u.setURL(n), t !== void 0 && u.setTarget(t),
|
|
209
|
+
const u = $(d, ((s) => !P(s) && L(s)));
|
|
210
|
+
if (u) u.setURL(n), t !== void 0 && u.setTarget(t), o !== void 0 && u.setRel(o);
|
|
402
211
|
else {
|
|
403
|
-
const s =
|
|
212
|
+
const s = B(n, { rel: o, target: t });
|
|
404
213
|
d.insertBefore(s), s.append(d);
|
|
405
214
|
}
|
|
406
215
|
}
|
|
407
216
|
}));
|
|
408
217
|
}
|
|
409
|
-
const c =
|
|
218
|
+
const c = l.extract();
|
|
410
219
|
if (n === null) return void c.forEach(((a) => {
|
|
411
|
-
const d =
|
|
220
|
+
const d = $(a, ((u) => !P(u) && L(u)));
|
|
412
221
|
if (d) {
|
|
413
222
|
const u = d.getChildren();
|
|
414
223
|
for (let s = 0; s < u.length; s++) d.insertBefore(u[s]);
|
|
415
224
|
d.remove();
|
|
416
225
|
}
|
|
417
226
|
}));
|
|
418
|
-
const
|
|
419
|
-
|
|
227
|
+
const m = /* @__PURE__ */ new Set(), _ = (a) => {
|
|
228
|
+
m.has(a.getKey()) || (m.add(a.getKey()), a.setURL(n), t !== void 0 && a.setTarget(t), o !== void 0 && a.setRel(o), i !== void 0 && a.setTitle(i));
|
|
420
229
|
};
|
|
421
230
|
if (c.length === 1) {
|
|
422
|
-
const a =
|
|
423
|
-
if (a !== null) return
|
|
231
|
+
const a = ie(c[0], L);
|
|
232
|
+
if (a !== null) return _(a);
|
|
424
233
|
}
|
|
425
234
|
(function(a) {
|
|
426
|
-
const d =
|
|
235
|
+
const d = T();
|
|
427
236
|
if (!O(d)) return a();
|
|
428
|
-
const u =
|
|
429
|
-
if (a(), v ||
|
|
430
|
-
const M =
|
|
237
|
+
const u = ee(d), s = u.isBackward(), v = re(u.anchor, s ? -1 : 0), y = re(u.focus, s ? 0 : -1);
|
|
238
|
+
if (a(), v || y) {
|
|
239
|
+
const M = T();
|
|
431
240
|
if (O(M)) {
|
|
432
241
|
const h = M.clone();
|
|
433
242
|
if (v) {
|
|
434
243
|
const I = v.getParent();
|
|
435
244
|
I && h.anchor.set(I.getKey(), v.getIndexWithinParent() + (s ? 1 : 0), "element");
|
|
436
245
|
}
|
|
437
|
-
if (
|
|
438
|
-
const I =
|
|
439
|
-
I && h.focus.set(I.getKey(),
|
|
246
|
+
if (y) {
|
|
247
|
+
const I = y.getParent();
|
|
248
|
+
I && h.focus.set(I.getKey(), y.getIndexWithinParent() + (s ? 0 : 1), "element");
|
|
440
249
|
}
|
|
441
|
-
|
|
250
|
+
we(ee(h));
|
|
442
251
|
}
|
|
443
252
|
}
|
|
444
253
|
})((() => {
|
|
445
254
|
let a = null;
|
|
446
255
|
for (const d of c) {
|
|
447
256
|
if (!d.isAttached()) continue;
|
|
448
|
-
const u =
|
|
257
|
+
const u = ie(d, L);
|
|
449
258
|
if (u) {
|
|
450
|
-
|
|
259
|
+
_(u);
|
|
451
260
|
continue;
|
|
452
261
|
}
|
|
453
262
|
if (z(d)) {
|
|
454
263
|
if (!d.isInline()) continue;
|
|
455
264
|
if (L(d)) {
|
|
456
265
|
if (!(P(d) || a !== null && a.getParentOrThrow().isParentOf(d))) {
|
|
457
|
-
|
|
266
|
+
_(d), a = d;
|
|
458
267
|
continue;
|
|
459
268
|
}
|
|
460
269
|
for (const v of d.getChildren()) d.insertBefore(v);
|
|
@@ -463,47 +272,238 @@ function $e(n, e = {}) {
|
|
|
463
272
|
}
|
|
464
273
|
}
|
|
465
274
|
const s = d.getPreviousSibling();
|
|
466
|
-
L(s) && s.is(a) ? s.append(d) : (a =
|
|
275
|
+
L(s) && s.is(a) ? s.append(d) : (a = B(n, { rel: o, target: t, title: i }), d.insertAfter(a), a.append(d));
|
|
467
276
|
}
|
|
468
277
|
}));
|
|
469
278
|
}
|
|
470
|
-
function
|
|
279
|
+
function ie(n, e) {
|
|
471
280
|
let t = n;
|
|
472
281
|
for (; t !== null && t.getParent() !== null && !e(t); ) t = t.getParentOrThrow();
|
|
473
282
|
return e(t) ? t : null;
|
|
474
283
|
}
|
|
475
|
-
const
|
|
476
|
-
function
|
|
477
|
-
return n.match(/^[a-z][a-z0-9+.-]*:/i) || n.match(/^[/#.]/) ? n : n.includes("@") ? `mailto:${n}` :
|
|
284
|
+
const Pe = /^\+?[0-9\s()-]{5,}$/;
|
|
285
|
+
function oe(n) {
|
|
286
|
+
return n.match(/^[a-z][a-z0-9+.-]*:/i) || n.match(/^[/#.]/) ? n : n.includes("@") ? `mailto:${n}` : Pe.test(n) ? `tel:${n}` : `https://${n}`;
|
|
478
287
|
}
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
288
|
+
const le = {
|
|
289
|
+
"lexical-editor__toolbar-button": "_lexical-editor__toolbar-button_1y192_1",
|
|
290
|
+
"lexical-editor__toolbar-button-active": "_lexical-editor__toolbar-button-active_1y192_7"
|
|
291
|
+
}, C = (n) => {
|
|
292
|
+
const { icon: e, tooltip: t, onClick: i, disabled: o = !1, active: l = !1, size: c = 14 } = n;
|
|
293
|
+
return /* @__PURE__ */ r(
|
|
294
|
+
"button",
|
|
295
|
+
{
|
|
296
|
+
className: xe(le["lexical-editor__toolbar-button"], {
|
|
297
|
+
[le["lexical-editor__toolbar-button-active"]]: l
|
|
298
|
+
}),
|
|
299
|
+
type: "button",
|
|
300
|
+
onClick: i,
|
|
301
|
+
disabled: o,
|
|
302
|
+
title: t,
|
|
303
|
+
children: ge.isValidElement(e) ? e : /* @__PURE__ */ r(E, { name: e, size: c })
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}, U = () => {
|
|
307
|
+
const n = ke(Be);
|
|
308
|
+
if (!n)
|
|
309
|
+
throw new Error("useTextFormatsContext must be used within TextFormatsProvider");
|
|
310
|
+
return n;
|
|
311
|
+
}, je = () => {
|
|
312
|
+
const [n] = b(), e = U(), { t } = w(), i = e.bold, o = () => {
|
|
313
|
+
n.dispatchCommand(H, "bold");
|
|
314
|
+
};
|
|
315
|
+
return /* @__PURE__ */ r(C, { icon: "bold", tooltip: t("editor.bold"), active: i, onClick: o });
|
|
316
|
+
}, ze = () => {
|
|
317
|
+
const [n] = b(), e = U(), { t } = w(), i = e.underline, o = () => {
|
|
318
|
+
n.dispatchCommand(H, "underline");
|
|
319
|
+
};
|
|
320
|
+
return /* @__PURE__ */ r(
|
|
321
|
+
C,
|
|
322
|
+
{
|
|
323
|
+
icon: "underline",
|
|
324
|
+
tooltip: t("editor.underline"),
|
|
325
|
+
active: i,
|
|
326
|
+
onClick: o
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
}, qe = () => {
|
|
330
|
+
const [n] = b(), e = U(), { t } = w(), i = e.italic, o = () => {
|
|
331
|
+
n.dispatchCommand(H, "italic");
|
|
332
|
+
};
|
|
333
|
+
return /* @__PURE__ */ r(
|
|
334
|
+
C,
|
|
335
|
+
{
|
|
336
|
+
icon: "italic",
|
|
337
|
+
tooltip: t("editor.italic"),
|
|
338
|
+
active: i,
|
|
339
|
+
onClick: o
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
}, We = () => {
|
|
343
|
+
const [n] = b(), e = U(), t = ye(() => Se.map((o) => ({
|
|
344
|
+
key: o.value,
|
|
345
|
+
label: o.label
|
|
346
|
+
})), []), i = A(
|
|
347
|
+
(o) => {
|
|
348
|
+
const l = o.key;
|
|
349
|
+
n.update(() => {
|
|
350
|
+
const c = T();
|
|
351
|
+
O(c) && Y(c, {
|
|
352
|
+
"font-size": l
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
},
|
|
356
|
+
[n]
|
|
357
|
+
);
|
|
358
|
+
return /* @__PURE__ */ r(
|
|
359
|
+
pe,
|
|
360
|
+
{
|
|
361
|
+
menus: t,
|
|
362
|
+
onClick: i,
|
|
363
|
+
activeKey: [e.fontSize],
|
|
364
|
+
showSearch: !1,
|
|
365
|
+
style: {
|
|
366
|
+
width: "60px",
|
|
367
|
+
minWidth: "60px"
|
|
368
|
+
},
|
|
369
|
+
children: /* @__PURE__ */ r("div", { className: "dropdown__trigger inline-flex", children: /* @__PURE__ */ r(C, { icon: "fontsize", tooltip: "字号", active: !1 }) })
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
}, $e = () => {
|
|
373
|
+
const [n] = b(), e = U(), { t } = w(), i = A(
|
|
374
|
+
(o) => {
|
|
375
|
+
n.update(() => {
|
|
376
|
+
const l = T();
|
|
377
|
+
O(l) && Y(l, {
|
|
378
|
+
color: o
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
},
|
|
382
|
+
[n]
|
|
383
|
+
);
|
|
384
|
+
return /* @__PURE__ */ r(
|
|
385
|
+
me,
|
|
386
|
+
{
|
|
387
|
+
value: e.fontColor,
|
|
388
|
+
onChange: i,
|
|
389
|
+
placement: "bottom-start",
|
|
390
|
+
children: /* @__PURE__ */ r("div", { className: "trigger-picker inline-flex", children: /* @__PURE__ */ r(
|
|
391
|
+
C,
|
|
392
|
+
{
|
|
393
|
+
icon: "fontcolor",
|
|
394
|
+
tooltip: t("editor.fontColor"),
|
|
395
|
+
onClick: () => {
|
|
396
|
+
},
|
|
397
|
+
active: !1
|
|
398
|
+
}
|
|
399
|
+
) })
|
|
400
|
+
}
|
|
401
|
+
);
|
|
402
|
+
}, Je = () => {
|
|
403
|
+
const [n] = b(), e = U(), { t } = w(), i = A(
|
|
404
|
+
(o) => {
|
|
405
|
+
n.update(() => {
|
|
406
|
+
const l = T();
|
|
407
|
+
O(l) && Y(l, {
|
|
408
|
+
"background-color": o
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
[n]
|
|
413
|
+
);
|
|
414
|
+
return /* @__PURE__ */ r(
|
|
415
|
+
me,
|
|
416
|
+
{
|
|
417
|
+
value: e.backgroundColor,
|
|
418
|
+
onChange: i,
|
|
419
|
+
placement: "bottom-start",
|
|
420
|
+
children: /* @__PURE__ */ r("div", { className: "trigger-picker inline-flex", children: /* @__PURE__ */ r(C, { icon: "fill", tooltip: t("editor.fill"), onClick: () => {
|
|
421
|
+
}, active: !1 }) })
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
}, Ke = () => {
|
|
425
|
+
var _;
|
|
426
|
+
const [n] = b(), { align: e } = U(), { t } = w(), i = [
|
|
427
|
+
{
|
|
428
|
+
key: "left",
|
|
429
|
+
label: t("leftAlign"),
|
|
430
|
+
icon: /* @__PURE__ */ r(te, {})
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
key: "center",
|
|
434
|
+
label: t("editor.centerAlign"),
|
|
435
|
+
icon: /* @__PURE__ */ r(Le, {})
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
key: "right",
|
|
439
|
+
label: t("editor.rightAlign"),
|
|
440
|
+
icon: /* @__PURE__ */ r(Te, {})
|
|
441
|
+
}
|
|
442
|
+
], o = A(
|
|
443
|
+
(a) => {
|
|
444
|
+
n.dispatchCommand(Ce, a);
|
|
445
|
+
},
|
|
446
|
+
[n]
|
|
447
|
+
), l = i.map((a) => ({
|
|
448
|
+
key: a.key,
|
|
449
|
+
label: /* @__PURE__ */ g("div", { className: "flex items-center gap-2", children: [
|
|
450
|
+
a.icon,
|
|
451
|
+
/* @__PURE__ */ r("span", { children: a.label })
|
|
452
|
+
] })
|
|
453
|
+
})), c = A(
|
|
454
|
+
(a) => {
|
|
455
|
+
o(a.key);
|
|
456
|
+
},
|
|
457
|
+
[o]
|
|
458
|
+
), m = ((_ = i.find((a) => a.key === e)) == null ? void 0 : _.icon) || /* @__PURE__ */ r(te, {});
|
|
459
|
+
return /* @__PURE__ */ r(
|
|
460
|
+
pe,
|
|
461
|
+
{
|
|
462
|
+
menus: l,
|
|
463
|
+
onClick: c,
|
|
464
|
+
showSearch: !1,
|
|
465
|
+
activeKey: [e],
|
|
466
|
+
style: { width: "110px", minWidth: "110px" },
|
|
467
|
+
children: /* @__PURE__ */ r("div", { className: "trigger-dropdown inline-flex text-sm", children: /* @__PURE__ */ r(
|
|
468
|
+
C,
|
|
469
|
+
{
|
|
470
|
+
icon: m,
|
|
471
|
+
tooltip: t("editor.alignment"),
|
|
472
|
+
onClick: () => {
|
|
473
|
+
},
|
|
474
|
+
active: !1
|
|
475
|
+
}
|
|
476
|
+
) })
|
|
477
|
+
}
|
|
478
|
+
);
|
|
479
|
+
}, Ve = () => {
|
|
480
|
+
const [n] = b(), { link: e } = U(), { t } = w(), [i, o] = N(!1), [l, c] = N(""), [m, _] = N(""), [a, d] = N(!0), [u, s] = Z.useMessage(), v = A((h) => h ? h.startsWith("@") ? "javascript:void(0);" : h.match(/^https?:\/\//) ? h : `http://${h}` : "", []), y = () => {
|
|
481
|
+
if (!l) {
|
|
482
482
|
u.warning(t("editor.linkAddressEmpty"));
|
|
483
483
|
return;
|
|
484
484
|
}
|
|
485
|
-
const h = v(
|
|
485
|
+
const h = v(l);
|
|
486
486
|
n.update(() => {
|
|
487
|
-
const I = a ? { target: "_blank", rel: "noopener noreferrer", title:
|
|
488
|
-
if (O(
|
|
489
|
-
|
|
487
|
+
const I = a ? { target: "_blank", rel: "noopener noreferrer", title: l } : { title: l }, R = T(), S = B(h, I), p = Ie(m || l);
|
|
488
|
+
if (O(R))
|
|
489
|
+
R.isCollapsed() ? (S.append(p), R.insertNodes([S])) : De(h);
|
|
490
490
|
else {
|
|
491
491
|
S.append(p);
|
|
492
|
-
const k =
|
|
493
|
-
if (z(
|
|
494
|
-
|
|
492
|
+
const k = Ue(), x = k.getLastChild();
|
|
493
|
+
if (z(x) && x.isEmpty())
|
|
494
|
+
x.append(S);
|
|
495
495
|
else {
|
|
496
|
-
const
|
|
497
|
-
|
|
496
|
+
const Q = Oe();
|
|
497
|
+
Q.append(S), k.append(Q);
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
}), c(""),
|
|
501
|
-
}, M =
|
|
502
|
-
e ? (c(e.link === "javascript:void(0);" ? "" : e.link),
|
|
500
|
+
}), c(""), _(""), o(!1);
|
|
501
|
+
}, M = A(() => {
|
|
502
|
+
e ? (c(e.link === "javascript:void(0);" ? "" : e.link), _(e.linkText)) : (c(""), _("")), o(!0);
|
|
503
503
|
}, [e]);
|
|
504
|
-
return /* @__PURE__ */ g(
|
|
505
|
-
/* @__PURE__ */
|
|
506
|
-
|
|
504
|
+
return /* @__PURE__ */ g(G, { children: [
|
|
505
|
+
/* @__PURE__ */ r(
|
|
506
|
+
C,
|
|
507
507
|
{
|
|
508
508
|
icon: "Insertlink",
|
|
509
509
|
tooltip: t("link"),
|
|
@@ -512,39 +512,39 @@ const Ke = () => {
|
|
|
512
512
|
}
|
|
513
513
|
),
|
|
514
514
|
s,
|
|
515
|
-
/* @__PURE__ */
|
|
515
|
+
/* @__PURE__ */ r(_e, { title: t("link"), open: i, onOpenChange: o, children: /* @__PURE__ */ g("div", { children: [
|
|
516
516
|
/* @__PURE__ */ g("div", { className: "px-[20px] pb-[60px] pt-[40px]", children: [
|
|
517
517
|
/* @__PURE__ */ g("div", { className: "flex items-center relative", children: [
|
|
518
|
-
/* @__PURE__ */
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
|
|
518
|
+
/* @__PURE__ */ r("label", { className: "w-[80px] shrink-0", children: t("linkAddress") }),
|
|
519
|
+
/* @__PURE__ */ r(
|
|
520
|
+
V,
|
|
521
521
|
{
|
|
522
|
-
value:
|
|
522
|
+
value: l,
|
|
523
523
|
onChange: (h) => c(h.target.value),
|
|
524
524
|
placeholder: t("editor.linkTip")
|
|
525
525
|
}
|
|
526
526
|
),
|
|
527
|
-
/* @__PURE__ */
|
|
527
|
+
/* @__PURE__ */ r("div", { className: "absolute bottom-[-30px] left-[80px]", children: /* @__PURE__ */ r("p", { className: "text-[#999]", children: "链接可用 @表单别名,用于应用内表单跳转" }) })
|
|
528
528
|
] }),
|
|
529
529
|
/* @__PURE__ */ g("div", { className: "flex items-center mt-[40px]", children: [
|
|
530
|
-
/* @__PURE__ */
|
|
531
|
-
/* @__PURE__ */
|
|
530
|
+
/* @__PURE__ */ r("label", { className: "w-[80px] shrink-0", children: t("showContent") }),
|
|
531
|
+
/* @__PURE__ */ r(V, { value: m, onChange: (h) => _(h.target.value) })
|
|
532
532
|
] })
|
|
533
533
|
] }),
|
|
534
534
|
/* @__PURE__ */ g("div", { className: "py-[14px] px-[20px] flex justify-between items-center border-t-[1px] border-solid border-[#e0e0e0]", children: [
|
|
535
|
-
/* @__PURE__ */
|
|
535
|
+
/* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(Ae, { checked: a, onChange: (h) => d(h), children: t("openInNewTab") }) }),
|
|
536
536
|
/* @__PURE__ */ g("div", { className: "flex gap-[15px]", children: [
|
|
537
|
-
/* @__PURE__ */
|
|
538
|
-
/* @__PURE__ */
|
|
537
|
+
/* @__PURE__ */ r(j, { onClick: () => o(!1), children: t("cancel") }),
|
|
538
|
+
/* @__PURE__ */ r(j, { type: "primary", onClick: y, children: t("confirm") })
|
|
539
539
|
] })
|
|
540
540
|
] })
|
|
541
541
|
] }) })
|
|
542
542
|
] });
|
|
543
|
-
},
|
|
544
|
-
const [n] =
|
|
545
|
-
e && n.dispatchCommand(
|
|
543
|
+
}, Ge = () => {
|
|
544
|
+
const [n] = b(), { link: e } = U(), { t } = w(), i = () => {
|
|
545
|
+
e && n.dispatchCommand(Fe, null);
|
|
546
546
|
};
|
|
547
|
-
return /* @__PURE__ */
|
|
547
|
+
return /* @__PURE__ */ r(C, { icon: "cancellink", tooltip: t("cancelLink"), onClick: i });
|
|
548
548
|
}, f = {
|
|
549
549
|
"picture-modal__container": "_picture-modal__container_qyj1h_1",
|
|
550
550
|
"picture-modal__sidebar": "_picture-modal__sidebar_qyj1h_4",
|
|
@@ -563,77 +563,77 @@ const Ke = () => {
|
|
|
563
563
|
"picture-modal__preview-delete": "_picture-modal__preview-delete_qyj1h_113",
|
|
564
564
|
"picture-modal__upload-text": "_picture-modal__upload-text_qyj1h_121",
|
|
565
565
|
"picture-modal__footer": "_picture-modal__footer_qyj1h_125"
|
|
566
|
-
},
|
|
567
|
-
const [t] =
|
|
568
|
-
return
|
|
566
|
+
}, he = ae((n, e) => {
|
|
567
|
+
const [t] = J.useForm(), [i, o] = N(""), { t: l } = w(), c = (m) => /^https?:\/\/.+/i.test(m);
|
|
568
|
+
return se(e, () => ({
|
|
569
569
|
getValue: async () => {
|
|
570
570
|
try {
|
|
571
|
-
return await t.validateFields(),
|
|
571
|
+
return await t.validateFields(), i;
|
|
572
572
|
} catch {
|
|
573
573
|
throw new Error("URL validation failed");
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
})), /* @__PURE__ */ g(
|
|
577
|
-
/* @__PURE__ */
|
|
578
|
-
/* @__PURE__ */
|
|
579
|
-
|
|
576
|
+
})), /* @__PURE__ */ g(G, { children: [
|
|
577
|
+
/* @__PURE__ */ r("div", { className: f["picture-modal__content-title"], "data-title": l("editor.imageUrlNote"), children: l("editor.enterImageUrl") }),
|
|
578
|
+
/* @__PURE__ */ r(J, { form: t, children: /* @__PURE__ */ r(
|
|
579
|
+
J.Item,
|
|
580
580
|
{
|
|
581
581
|
name: "url",
|
|
582
582
|
rules: [
|
|
583
|
-
{ required: !0, message:
|
|
583
|
+
{ required: !0, message: l("editor.pleaseEnterImageUrl") },
|
|
584
584
|
{
|
|
585
|
-
validator: (
|
|
585
|
+
validator: (m, _) => !_ || c(_) ? Promise.resolve() : Promise.reject(new Error(l("editor.pleaseEnterValidImageUrl")))
|
|
586
586
|
}
|
|
587
587
|
],
|
|
588
|
-
children: /* @__PURE__ */
|
|
589
|
-
|
|
588
|
+
children: /* @__PURE__ */ r(
|
|
589
|
+
V,
|
|
590
590
|
{
|
|
591
|
-
placeholder:
|
|
592
|
-
value:
|
|
593
|
-
onChange: (
|
|
591
|
+
placeholder: l("editor.pleaseEnterImageUrl"),
|
|
592
|
+
value: i,
|
|
593
|
+
onChange: (m) => o(m.target.value)
|
|
594
594
|
}
|
|
595
595
|
)
|
|
596
596
|
}
|
|
597
597
|
) })
|
|
598
598
|
] });
|
|
599
599
|
});
|
|
600
|
-
|
|
601
|
-
const
|
|
602
|
-
const [t,
|
|
600
|
+
he.displayName = "LinkInput";
|
|
601
|
+
const fe = ae((n, e) => {
|
|
602
|
+
const [t, i] = N(null), [o, l] = N(!1), [c, m] = N(null), _ = K(null), [a, d] = Z.useMessage(), { t: u } = w(), s = (p) => (p / 1024).toFixed(1) + "kb", v = (p) => p.type.startsWith("image/") ? p.size > 1048576 ? (a.warning(u("editor.imageSizeNote")), !1) : !0 : (a.warning(u("editor.onlyImageFormatsSupported")), !1), y = (p) => {
|
|
603
603
|
if (v(p)) {
|
|
604
604
|
const k = URL.createObjectURL(p);
|
|
605
|
-
|
|
605
|
+
i(k), m(p);
|
|
606
606
|
}
|
|
607
607
|
}, M = () => {
|
|
608
608
|
var p;
|
|
609
|
-
(p =
|
|
609
|
+
(p = _.current) == null || p.click();
|
|
610
610
|
}, h = (p) => {
|
|
611
|
-
var
|
|
612
|
-
const k = (
|
|
613
|
-
k &&
|
|
611
|
+
var x;
|
|
612
|
+
const k = (x = p.target.files) == null ? void 0 : x[0];
|
|
613
|
+
k && y(k);
|
|
614
614
|
}, I = (p) => {
|
|
615
|
-
p.preventDefault(),
|
|
616
|
-
},
|
|
617
|
-
p.preventDefault(),
|
|
615
|
+
p.preventDefault(), l(!0);
|
|
616
|
+
}, R = (p) => {
|
|
617
|
+
p.preventDefault(), l(!1);
|
|
618
618
|
}, S = (p) => {
|
|
619
|
-
p.preventDefault(),
|
|
619
|
+
p.preventDefault(), l(!1);
|
|
620
620
|
const k = p.dataTransfer.files[0];
|
|
621
|
-
k &&
|
|
621
|
+
k && y(k);
|
|
622
622
|
};
|
|
623
|
-
return
|
|
623
|
+
return se(e, () => ({
|
|
624
624
|
getValue: async () => {
|
|
625
625
|
if (!c)
|
|
626
626
|
throw a.warning(u("editor.pleaseUploadImageFirst")), new Error(u("editor.pleaseUploadImageFirst"));
|
|
627
627
|
return new Promise((p, k) => {
|
|
628
|
-
const
|
|
629
|
-
|
|
628
|
+
const x = new FileReader();
|
|
629
|
+
x.onload = () => {
|
|
630
630
|
p({
|
|
631
|
-
src:
|
|
631
|
+
src: x.result,
|
|
632
632
|
fileName: c.name
|
|
633
633
|
});
|
|
634
|
-
},
|
|
634
|
+
}, x.onerror = () => {
|
|
635
635
|
k(new Error(u("editor.operationFailed")));
|
|
636
|
-
},
|
|
636
|
+
}, x.readAsDataURL(c);
|
|
637
637
|
});
|
|
638
638
|
}
|
|
639
639
|
})), /* @__PURE__ */ g(
|
|
@@ -641,10 +641,10 @@ const he = oe((n, e) => {
|
|
|
641
641
|
{
|
|
642
642
|
className: "h-full",
|
|
643
643
|
onDragOver: I,
|
|
644
|
-
onDragLeave:
|
|
644
|
+
onDragLeave: R,
|
|
645
645
|
onDrop: S,
|
|
646
646
|
children: [
|
|
647
|
-
/* @__PURE__ */
|
|
647
|
+
/* @__PURE__ */ r(
|
|
648
648
|
"div",
|
|
649
649
|
{
|
|
650
650
|
className: f["picture-modal__content-title"],
|
|
@@ -655,16 +655,16 @@ const he = oe((n, e) => {
|
|
|
655
655
|
/* @__PURE__ */ g(
|
|
656
656
|
"div",
|
|
657
657
|
{
|
|
658
|
-
className: `${f["picture-modal__upload-area"]} ${
|
|
658
|
+
className: `${f["picture-modal__upload-area"]} ${o ? f["picture-modal__upload-area--dragging"] : ""}`,
|
|
659
659
|
onClick: M,
|
|
660
660
|
children: [
|
|
661
|
-
/* @__PURE__ */
|
|
662
|
-
/* @__PURE__ */
|
|
661
|
+
/* @__PURE__ */ r(E, { name: "upload" }),
|
|
662
|
+
/* @__PURE__ */ r("span", { className: f["picture-modal__upload-text"], children: u("editor.clickOrDragToUpload") })
|
|
663
663
|
]
|
|
664
664
|
}
|
|
665
665
|
),
|
|
666
|
-
/* @__PURE__ */
|
|
667
|
-
|
|
666
|
+
/* @__PURE__ */ r(Me, { mode: "wait", children: t && c && /* @__PURE__ */ g(
|
|
667
|
+
D.div,
|
|
668
668
|
{
|
|
669
669
|
className: f["picture-modal__preview"],
|
|
670
670
|
initial: { opacity: 0, y: 20, scale: 0.95 },
|
|
@@ -675,14 +675,14 @@ const he = oe((n, e) => {
|
|
|
675
675
|
ease: [0.4, 0, 0.2, 1]
|
|
676
676
|
},
|
|
677
677
|
children: [
|
|
678
|
-
/* @__PURE__ */
|
|
679
|
-
|
|
678
|
+
/* @__PURE__ */ r(
|
|
679
|
+
D.div,
|
|
680
680
|
{
|
|
681
681
|
className: f["picture-modal__preview-image"],
|
|
682
682
|
initial: { opacity: 0, scale: 0.8 },
|
|
683
683
|
animate: { opacity: 1, scale: 1 },
|
|
684
684
|
transition: { delay: 0.1, duration: 0.2 },
|
|
685
|
-
children: /* @__PURE__ */
|
|
685
|
+
children: /* @__PURE__ */ r(
|
|
686
686
|
"img",
|
|
687
687
|
{
|
|
688
688
|
src: t,
|
|
@@ -693,42 +693,42 @@ const he = oe((n, e) => {
|
|
|
693
693
|
}
|
|
694
694
|
),
|
|
695
695
|
/* @__PURE__ */ g(
|
|
696
|
-
|
|
696
|
+
D.div,
|
|
697
697
|
{
|
|
698
698
|
className: f["picture-modal__preview-info"],
|
|
699
699
|
initial: { opacity: 0, x: 20 },
|
|
700
700
|
animate: { opacity: 1, x: 0 },
|
|
701
701
|
transition: { delay: 0.15, duration: 0.2 },
|
|
702
702
|
children: [
|
|
703
|
-
/* @__PURE__ */
|
|
704
|
-
/* @__PURE__ */
|
|
703
|
+
/* @__PURE__ */ r("div", { className: f["picture-modal__preview-filename"], children: c.name }),
|
|
704
|
+
/* @__PURE__ */ r("div", { className: f["picture-modal__preview-size"], children: s(c.size) })
|
|
705
705
|
]
|
|
706
706
|
}
|
|
707
707
|
),
|
|
708
|
-
/* @__PURE__ */
|
|
709
|
-
|
|
708
|
+
/* @__PURE__ */ r(
|
|
709
|
+
D.div,
|
|
710
710
|
{
|
|
711
711
|
className: f["picture-modal__preview-delete"],
|
|
712
712
|
role: "button",
|
|
713
713
|
onClick: () => {
|
|
714
|
-
|
|
714
|
+
i(null), m(null);
|
|
715
715
|
},
|
|
716
716
|
initial: { opacity: 0, scale: 0.8 },
|
|
717
717
|
animate: { opacity: 1, scale: 1 },
|
|
718
718
|
transition: { delay: 0.2, duration: 0.2 },
|
|
719
719
|
whileHover: { scale: 1.1 },
|
|
720
720
|
whileTap: { scale: 0.95 },
|
|
721
|
-
children: /* @__PURE__ */
|
|
721
|
+
children: /* @__PURE__ */ r(E, { name: "delete" })
|
|
722
722
|
}
|
|
723
723
|
)
|
|
724
724
|
]
|
|
725
725
|
},
|
|
726
726
|
"preview"
|
|
727
727
|
) }),
|
|
728
|
-
/* @__PURE__ */
|
|
728
|
+
/* @__PURE__ */ r(
|
|
729
729
|
"input",
|
|
730
730
|
{
|
|
731
|
-
ref:
|
|
731
|
+
ref: _,
|
|
732
732
|
type: "file",
|
|
733
733
|
accept: "image/*",
|
|
734
734
|
style: { display: "none" },
|
|
@@ -740,45 +740,45 @@ const he = oe((n, e) => {
|
|
|
740
740
|
}
|
|
741
741
|
);
|
|
742
742
|
});
|
|
743
|
-
|
|
744
|
-
const
|
|
743
|
+
fe.displayName = "UploadImage";
|
|
744
|
+
const He = ce(
|
|
745
745
|
"INSERT_INLINE_IMAGE_COMMAND"
|
|
746
|
-
),
|
|
747
|
-
const { t: n } =
|
|
746
|
+
), Ye = () => {
|
|
747
|
+
const { t: n } = w(), [e] = b(), [t, i] = N(!1), o = K(null), l = K(null), c = [
|
|
748
748
|
{
|
|
749
749
|
key: "upload",
|
|
750
750
|
title: n("editor.uploadImage"),
|
|
751
|
-
icon: /* @__PURE__ */
|
|
751
|
+
icon: /* @__PURE__ */ r(E, { name: "picture" })
|
|
752
752
|
},
|
|
753
753
|
{
|
|
754
754
|
key: "url",
|
|
755
755
|
title: n("editor.imageUrl"),
|
|
756
|
-
icon: /* @__PURE__ */
|
|
756
|
+
icon: /* @__PURE__ */ r(E, { name: "Insertlink" })
|
|
757
757
|
}
|
|
758
|
-
], [
|
|
758
|
+
], [m, _] = N(c[0].key), a = () => c.findIndex((v) => v.key === m) * 40, d = async () => {
|
|
759
759
|
try {
|
|
760
760
|
let s = "", v = "";
|
|
761
|
-
if (
|
|
762
|
-
const
|
|
763
|
-
s =
|
|
764
|
-
} else
|
|
765
|
-
e.dispatchCommand(
|
|
761
|
+
if (m === "upload" && l.current) {
|
|
762
|
+
const y = await l.current.getValue();
|
|
763
|
+
s = y.src, v = y.fileName;
|
|
764
|
+
} else o.current && (s = await o.current.getValue(), v = s);
|
|
765
|
+
e.dispatchCommand(He, {
|
|
766
766
|
src: s,
|
|
767
767
|
altText: v
|
|
768
|
-
}),
|
|
768
|
+
}), i(!1);
|
|
769
769
|
} catch (s) {
|
|
770
|
-
|
|
770
|
+
Z.error(s instanceof Error ? s.message : n("editor.operationFailed"));
|
|
771
771
|
}
|
|
772
772
|
}, u = {
|
|
773
|
-
upload: /* @__PURE__ */
|
|
774
|
-
url: /* @__PURE__ */
|
|
773
|
+
upload: /* @__PURE__ */ r(fe, { ref: l }),
|
|
774
|
+
url: /* @__PURE__ */ r(he, { ref: o })
|
|
775
775
|
};
|
|
776
|
-
return /* @__PURE__ */ g(
|
|
777
|
-
/* @__PURE__ */
|
|
778
|
-
/* @__PURE__ */ g(_e, { title: n("addPicture"), open: t, onOpenChange:
|
|
776
|
+
return /* @__PURE__ */ g(G, { children: [
|
|
777
|
+
/* @__PURE__ */ r(C, { icon: "picture", tooltip: n("picture"), onClick: () => i(!0) }),
|
|
778
|
+
/* @__PURE__ */ g(_e, { title: n("addPicture"), open: t, onOpenChange: i, width: "620px", children: [
|
|
779
779
|
/* @__PURE__ */ g("div", { className: f["picture-modal__container"], children: [
|
|
780
780
|
/* @__PURE__ */ g("div", { className: f["picture-modal__sidebar"], children: [
|
|
781
|
-
/* @__PURE__ */
|
|
781
|
+
/* @__PURE__ */ r(
|
|
782
782
|
"div",
|
|
783
783
|
{
|
|
784
784
|
className: f["picture-modal__slider"],
|
|
@@ -787,46 +787,60 @@ const Ge = ce(
|
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
789
|
),
|
|
790
|
-
/* @__PURE__ */
|
|
790
|
+
/* @__PURE__ */ r("ul", { className: f["picture-modal__menu-list"], children: c.map((s) => /* @__PURE__ */ g(
|
|
791
791
|
"li",
|
|
792
792
|
{
|
|
793
|
-
className: `${f["picture-modal__menu-item"]} ${
|
|
794
|
-
onClick: () =>
|
|
793
|
+
className: `${f["picture-modal__menu-item"]} ${m === s.key ? f["picture-modal__menu-item--active"] : ""}`,
|
|
794
|
+
onClick: () => _(s.key),
|
|
795
795
|
children: [
|
|
796
|
-
/* @__PURE__ */
|
|
797
|
-
/* @__PURE__ */
|
|
796
|
+
/* @__PURE__ */ r("span", { className: f["picture-modal__menu-icon"], children: s.icon }),
|
|
797
|
+
/* @__PURE__ */ r("span", { children: s.title })
|
|
798
798
|
]
|
|
799
799
|
},
|
|
800
800
|
s.title
|
|
801
801
|
)) })
|
|
802
802
|
] }),
|
|
803
|
-
/* @__PURE__ */
|
|
803
|
+
/* @__PURE__ */ r("div", { className: f["picture-modal__content"], children: u[m] })
|
|
804
804
|
] }),
|
|
805
805
|
/* @__PURE__ */ g("div", { className: f["picture-modal__footer"], children: [
|
|
806
|
-
/* @__PURE__ */
|
|
807
|
-
/* @__PURE__ */
|
|
806
|
+
/* @__PURE__ */ r(j, { onClick: () => i(!1), children: n("cancel") }),
|
|
807
|
+
/* @__PURE__ */ r(j, { type: "primary", onClick: d, children: n("confirm") })
|
|
808
808
|
] })
|
|
809
809
|
] })
|
|
810
810
|
] });
|
|
811
|
-
},
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
811
|
+
}, W = /* @__PURE__ */ new Map(), Ze = (n, e) => {
|
|
812
|
+
if (!n)
|
|
813
|
+
throw new Error("registerToolbarButton: name is required");
|
|
814
|
+
W.set(n, e);
|
|
815
|
+
}, mt = (n) => {
|
|
816
|
+
W.delete(n);
|
|
817
|
+
}, _t = (n) => W.get(n), ht = () => Array.from(W.keys()), Qe = {
|
|
818
|
+
bold: je,
|
|
819
|
+
underline: ze,
|
|
820
|
+
italic: qe,
|
|
821
|
+
fontSize: We,
|
|
822
|
+
fontColor: $e,
|
|
823
|
+
fill: Je,
|
|
824
|
+
align: Ke,
|
|
825
|
+
link: Ve,
|
|
826
|
+
unLink: Ge,
|
|
827
|
+
picture: Ye
|
|
822
828
|
};
|
|
829
|
+
Object.entries(Qe).forEach(([n, e]) => {
|
|
830
|
+
Ze(n, e);
|
|
831
|
+
});
|
|
823
832
|
export {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
833
|
+
C as B,
|
|
834
|
+
He as I,
|
|
835
|
+
Be as T,
|
|
836
|
+
F as a,
|
|
837
|
+
Qe as b,
|
|
838
|
+
_t as g,
|
|
839
|
+
Fe as k,
|
|
840
|
+
ht as l,
|
|
829
841
|
q as m,
|
|
830
842
|
L as p,
|
|
831
|
-
|
|
843
|
+
Ze as r,
|
|
844
|
+
mt as u,
|
|
845
|
+
De as v
|
|
832
846
|
};
|