@baishuyun/ui-base 2.2.0 → 2.2.3

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.
Files changed (97) hide show
  1. package/dist/Card/{Card-CXULQNHa.js → Card-DHOMkrEE.js} +2 -2
  2. package/dist/Card/index.js +1 -1
  3. package/dist/CheckBox/{CheckBox-Bu40TO29.js → CheckBox-VlP6u_-s.js} +2 -2
  4. package/dist/CheckBox/index.js +19 -17
  5. package/dist/ColorPicker/ColorPicker-049kyJn6.js +205 -0
  6. package/dist/ColorPicker/index.js +1 -1
  7. package/dist/DropDown/DropDown-BkTY-3y0.js +166 -0
  8. package/dist/DropDown/index.js +4 -0
  9. package/dist/Editor/ToolbarPlugin/Buttons/index.js +4 -0
  10. package/dist/Editor/constants/index.js +20 -0
  11. package/dist/Editor/index-C0MY9j94.js +832 -0
  12. package/dist/Editor/index.js +581 -0
  13. package/dist/Icon/Icon-CkHAU1fA.js +24 -0
  14. package/dist/Icon/index.js +1 -1
  15. package/dist/InputTag/InputTag-S9hHXsyQ.js +137 -0
  16. package/dist/InputTag/index.js +2 -135
  17. package/dist/Loading/Loading-CEB4PLUE.js +9 -0
  18. package/dist/Loading/index.js +4 -0
  19. package/dist/Modal/{Modal-BZTEGGa0.js → Modal-oRJ-Almn.js} +1 -1
  20. package/dist/Modal/index.js +1 -1
  21. package/dist/Radio/index.js +1 -1
  22. package/dist/Select/Select-BiARGTPz.js +820 -0
  23. package/dist/Select/SelectInputSearch-DigfTvpo.js +34 -0
  24. package/dist/Select/index.js +1 -1
  25. package/dist/Tabs/TabSelect-bKB0Qe9F.js +445 -0
  26. package/dist/Tabs/index.js +7 -0
  27. package/dist/Tree/index.js +1 -1
  28. package/dist/Tree/utils/index.js +1 -1
  29. package/dist/components/CheckBox/Group.d.ts +4 -0
  30. package/dist/components/DropDown/DropDown.d.ts +3 -0
  31. package/dist/components/DropDown/MenuItem/MenuItem.d.ts +8 -0
  32. package/dist/components/DropDown/MenuList/MenuList.d.ts +9 -0
  33. package/dist/components/DropDown/index.d.ts +1 -0
  34. package/dist/components/Editor/Editor.d.ts +4 -0
  35. package/dist/components/Editor/EditorCore.d.ts +4 -0
  36. package/dist/components/Editor/ToolbarPlugin/BaseButton/BaseButton.d.ts +29 -0
  37. package/dist/components/Editor/ToolbarPlugin/Buttons/AlignButton.d.ts +2 -0
  38. package/dist/components/Editor/ToolbarPlugin/Buttons/BoldButton.d.ts +2 -0
  39. package/dist/components/Editor/ToolbarPlugin/Buttons/FillButton.d.ts +2 -0
  40. package/dist/components/Editor/ToolbarPlugin/Buttons/FontColorButton.d.ts +2 -0
  41. package/dist/components/Editor/ToolbarPlugin/Buttons/FontSizeButton.d.ts +2 -0
  42. package/dist/components/Editor/ToolbarPlugin/Buttons/ItalicButton.d.ts +2 -0
  43. package/dist/components/Editor/ToolbarPlugin/Buttons/LinkButton.d.ts +2 -0
  44. package/dist/components/Editor/ToolbarPlugin/Buttons/PictureButton/LinkInput.d.ts +5 -0
  45. package/dist/components/Editor/ToolbarPlugin/Buttons/PictureButton/PictureButton.d.ts +2 -0
  46. package/dist/components/Editor/ToolbarPlugin/Buttons/PictureButton/UploadImage.d.ts +8 -0
  47. package/dist/components/Editor/ToolbarPlugin/Buttons/UnLinkButton.d.ts +2 -0
  48. package/dist/components/Editor/ToolbarPlugin/Buttons/UnderLineButton.d.ts +2 -0
  49. package/dist/components/Editor/ToolbarPlugin/Buttons/index.d.ts +14 -0
  50. package/dist/components/Editor/ToolbarPlugin/ToolbarPlugin.d.ts +3 -0
  51. package/dist/components/Editor/ToolbarPlugin/context/TextFormatProvider.d.ts +3 -0
  52. package/dist/components/Editor/ToolbarPlugin/context/TextFormatsContext.d.ts +17 -0
  53. package/dist/components/Editor/ToolbarPlugin/context/useTextFormatsContext.d.ts +1 -0
  54. package/dist/components/Editor/ToolbarPlugin/interface.d.ts +32 -0
  55. package/dist/components/Editor/commands/ImageCommands.d.ts +8 -0
  56. package/dist/components/Editor/constants/index.d.ts +41 -0
  57. package/dist/components/Editor/hooks/useTextFormatsState.d.ts +2 -0
  58. package/dist/components/Editor/index.d.ts +2 -0
  59. package/dist/components/Editor/interface.d.ts +62 -0
  60. package/dist/components/Editor/nodes/ExtendedTextNode.d.ts +11 -0
  61. package/dist/components/Editor/nodes/ImageComponent.d.ts +11 -0
  62. package/dist/components/Editor/nodes/ImageNode.d.ts +50 -0
  63. package/dist/components/Editor/plugins/EnterKeyPlugin.d.ts +1 -0
  64. package/dist/components/Editor/plugins/ImagePlugin.d.ts +1 -0
  65. package/dist/components/Loading/Loading.d.ts +5 -0
  66. package/dist/components/Loading/index.d.ts +1 -0
  67. package/dist/components/Select/HighlightText/HighlightText.d.ts +1 -0
  68. package/dist/components/Select/context/SelectContext.d.ts +12 -0
  69. package/dist/components/Tabs/Tab/Tab.d.ts +10 -0
  70. package/dist/components/Tabs/TabList/TabList.d.ts +4 -0
  71. package/dist/components/Tabs/TabList/useTabIndicator.d.ts +19 -0
  72. package/dist/components/Tabs/TabList/useTabScroll.d.ts +16 -0
  73. package/dist/components/Tabs/TabPanel/TabPanel.d.ts +9 -0
  74. package/dist/components/Tabs/TabSelect/TabSelect.d.ts +3 -0
  75. package/dist/components/Tabs/TabSelect/interface.d.ts +26 -0
  76. package/dist/components/Tabs/Tabs.d.ts +3 -0
  77. package/dist/components/Tabs/constants.d.ts +9 -0
  78. package/dist/components/Tabs/context/TabContext.d.ts +7 -0
  79. package/dist/components/Tabs/index.d.ts +4 -0
  80. package/dist/components/Tabs/interface.d.ts +61 -0
  81. package/dist/components/index.d.ts +6 -0
  82. package/dist/index.js +41 -30
  83. package/dist/style.css +1 -1
  84. package/dist/vendors/Tree-CjrhMBFX.js +235 -0
  85. package/dist/vendors/color-VzwvCPhF.js +21 -0
  86. package/dist/vendors/index-MTmG1Ezy.js +15 -0
  87. package/dist/vendors/lexical-DdSmj_Kv.js +5891 -0
  88. package/dist/vendors/{lodash-es-CZfJRWhO.js → lodash-es-DFpaJB4Y.js} +2 -2
  89. package/dist/vendors/{simplebar-react-Bf9Zq-21.js → simplebar-react-D68KzE44.js} +1 -1
  90. package/dist/vendors/useFloatingPortal-9VUFOAOG.js +45 -0
  91. package/dist/vendors/{index-ByQkttKA.js → useLocale-DgqW9M3h.js} +35 -47
  92. package/package.json +3 -6
  93. package/dist/ColorPicker/ColorPicker-CwFsihkL.js +0 -207
  94. package/dist/Icon/Icon-BlkVlKDd.js +0 -24
  95. package/dist/Select/Select-C3abXG27.js +0 -855
  96. package/dist/vendors/Tree-CCY2gtpG.js +0 -225
  97. package/dist/vendors/lexical-Bz4mqKs6.js +0 -3
@@ -0,0 +1,832 @@
1
+ import { jsx as i, jsxs as g, Fragment as V } from "react/jsx-runtime";
2
+ import { I as D } from "../Icon/Icon-CkHAU1fA.js";
3
+ import fe, { createContext as ge, useContext as ve, useMemo as ke, useCallback as T, useState as w, forwardRef as oe, useImperativeHandle as ae, useRef as J } from "react";
4
+ import { c as xe } from "../vendors/clsx-OuTLNxxd.js";
5
+ import { o as C, l as G, P as A, _ as O, M as H, p as ye, r as Ne, t as we, v as se, x as z, u as ce, i as de, y as Q, w as W, E as X, z as Ce, A as be, b as Ie, B as Ue } from "../vendors/lexical-DdSmj_Kv.js";
6
+ import { u as N } from "../vendors/useLocale-DgqW9M3h.js";
7
+ import { D as ue } from "../DropDown/DropDown-BkTY-3y0.js";
8
+ import { FONT_SIZES as Oe } from "./constants/index.js";
9
+ import { C as pe } from "../ColorPicker/ColorPicker-049kyJn6.js";
10
+ import { AlignLeftOutlined as ee, AlignCenterOutlined as Se, AlignRightOutlined as Le } from "@ant-design/icons";
11
+ import { M as _e } from "../Modal/Modal-oRJ-Almn.js";
12
+ import { message as Y, Input as K, Button as j, Form as $ } from "antd";
13
+ import Ae from "../CheckBox/index.js";
14
+ import { AnimatePresence as Te, motion as E } from "motion/react";
15
+ const te = {
16
+ "lexical-editor__toolbar-button": "_lexical-editor__toolbar-button_1y192_1",
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 {
208
+ static getType() {
209
+ return "link";
210
+ }
211
+ static clone(e) {
212
+ return new B(e.__url, { rel: e.__rel, target: e.__target, title: e.__title }, e.__key);
213
+ }
214
+ constructor(e = "", t = {}, r) {
215
+ super(r);
216
+ const { target: l = null, rel: o = null, title: c = null } = t;
217
+ this.__url = e, this.__target = l, this.__rel = o, this.__title = c;
218
+ }
219
+ createDOM(e) {
220
+ const t = document.createElement("a");
221
+ return this.updateLinkDOM(null, t, e), we(t, e.theme.link), t;
222
+ }
223
+ updateLinkDOM(e, t, r) {
224
+ if (se(t)) {
225
+ e && e.__url === this.__url || (t.href = this.sanitizeUrl(this.__url));
226
+ for (const l of ["target", "rel", "title"]) {
227
+ const o = `__${l}`, c = this[o];
228
+ e && e[o] === c || (c ? t[l] = c : t.removeAttribute(l));
229
+ }
230
+ }
231
+ }
232
+ updateDOM(e, t, r) {
233
+ return this.updateLinkDOM(e, t, r), !1;
234
+ }
235
+ static importDOM() {
236
+ return { a: (e) => ({ conversion: qe, priority: 1 }) };
237
+ }
238
+ static importJSON(e) {
239
+ return R().updateFromJSON(e);
240
+ }
241
+ updateFromJSON(e) {
242
+ return super.updateFromJSON(e).setURL(e.url).setRel(e.rel || null).setTarget(e.target || null).setTitle(e.title || null);
243
+ }
244
+ sanitizeUrl(e) {
245
+ e = le(e);
246
+ try {
247
+ const t = new URL(le(e));
248
+ if (!ze.has(t.protocol)) return "about:blank";
249
+ } catch {
250
+ return e;
251
+ }
252
+ return e;
253
+ }
254
+ exportJSON() {
255
+ return { ...super.exportJSON(), rel: this.getRel(), target: this.getTarget(), title: this.getTitle(), url: this.getURL() };
256
+ }
257
+ getURL() {
258
+ return this.getLatest().__url;
259
+ }
260
+ setURL(e) {
261
+ const t = this.getWritable();
262
+ return t.__url = e, t;
263
+ }
264
+ getTarget() {
265
+ return this.getLatest().__target;
266
+ }
267
+ setTarget(e) {
268
+ const t = this.getWritable();
269
+ return t.__target = e, t;
270
+ }
271
+ getRel() {
272
+ return this.getLatest().__rel;
273
+ }
274
+ setRel(e) {
275
+ const t = this.getWritable();
276
+ return t.__rel = e, t;
277
+ }
278
+ getTitle() {
279
+ return this.getLatest().__title;
280
+ }
281
+ setTitle(e) {
282
+ const t = this.getWritable();
283
+ return t.__title = e, t;
284
+ }
285
+ insertNewAfter(e, t = !0) {
286
+ const r = R(this.__url, { rel: this.__rel, target: this.__target, title: this.__title });
287
+ return this.insertAfter(r, t), r;
288
+ }
289
+ canInsertTextBefore() {
290
+ return !1;
291
+ }
292
+ canInsertTextAfter() {
293
+ return !1;
294
+ }
295
+ canBeEmpty() {
296
+ return !1;
297
+ }
298
+ isInline() {
299
+ return !0;
300
+ }
301
+ extractWithChild(e, t, r) {
302
+ if (!O(t)) return !1;
303
+ const l = t.anchor.getNode(), o = t.focus.getNode();
304
+ return this.isParentOf(l) && this.isParentOf(o) && t.getTextContent().length > 0;
305
+ }
306
+ isEmailURI() {
307
+ return this.__url.startsWith("mailto:");
308
+ }
309
+ isWebSiteURI() {
310
+ return this.__url.startsWith("https://") || this.__url.startsWith("http://");
311
+ }
312
+ }
313
+ function qe(n) {
314
+ let e = null;
315
+ if (se(n)) {
316
+ const t = n.textContent;
317
+ (t !== null && t !== "" || n.children.length > 0) && (e = R(n.getAttribute("href") || "", { rel: n.getAttribute("rel"), target: n.getAttribute("target"), title: n.getAttribute("title") }));
318
+ }
319
+ return { node: e };
320
+ }
321
+ function R(n = "", e) {
322
+ return de(new B(n, e));
323
+ }
324
+ function L(n) {
325
+ return n instanceof B;
326
+ }
327
+ class q extends B {
328
+ constructor(e = "", t = {}, r) {
329
+ super(e, t, r), this.__isUnlinked = t.isUnlinked !== void 0 && t.isUnlinked !== null && t.isUnlinked;
330
+ }
331
+ static getType() {
332
+ return "autolink";
333
+ }
334
+ static clone(e) {
335
+ return new q(e.__url, { isUnlinked: e.__isUnlinked, rel: e.__rel, target: e.__target, title: e.__title }, e.__key);
336
+ }
337
+ getIsUnlinked() {
338
+ return this.__isUnlinked;
339
+ }
340
+ setIsUnlinked(e) {
341
+ const t = this.getWritable();
342
+ return t.__isUnlinked = e, t;
343
+ }
344
+ createDOM(e) {
345
+ return this.__isUnlinked ? document.createElement("span") : super.createDOM(e);
346
+ }
347
+ updateDOM(e, t, r) {
348
+ return super.updateDOM(e, t, r) || e.__isUnlinked !== this.__isUnlinked;
349
+ }
350
+ static importJSON(e) {
351
+ return ne().updateFromJSON(e);
352
+ }
353
+ updateFromJSON(e) {
354
+ return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked || !1);
355
+ }
356
+ static importDOM() {
357
+ return null;
358
+ }
359
+ exportJSON() {
360
+ return { ...super.exportJSON(), isUnlinked: this.__isUnlinked };
361
+ }
362
+ insertNewAfter(e, t = !0) {
363
+ const r = this.getParentOrThrow().insertNewAfter(e, t);
364
+ if (z(r)) {
365
+ const l = ne(this.__url, { isUnlinked: this.__isUnlinked, rel: this.__rel, target: this.__target, title: this.__title });
366
+ return r.append(l), l;
367
+ }
368
+ return null;
369
+ }
370
+ }
371
+ function ne(n = "", e) {
372
+ return de(new q(n, e));
373
+ }
374
+ function P(n) {
375
+ return n instanceof q;
376
+ }
377
+ const We = ce("TOGGLE_LINK_COMMAND");
378
+ function ie(n, e) {
379
+ if (n.type === "element") {
380
+ const t = n.getNode();
381
+ return z(t) || (function(r, ...l) {
382
+ const o = new URL("https://lexical.dev/docs/error"), c = new URLSearchParams();
383
+ c.append("code", r);
384
+ for (const _ of l) c.append("v", _);
385
+ throw o.search = c.toString(), Error(`Minified Lexical error #${r}; visit ${o.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
386
+ })(252), t.getChildren()[n.offset + e] || null;
387
+ }
388
+ return null;
389
+ }
390
+ function $e(n, e = {}) {
391
+ const { target: t, title: r } = e, l = e.rel === void 0 ? "noreferrer" : e.rel, o = A();
392
+ if (o === null || !O(o) && !Q(o)) return;
393
+ if (Q(o)) {
394
+ const a = o.getNodes();
395
+ return a.length === 0 ? void 0 : void a.forEach(((d) => {
396
+ if (n === null) {
397
+ const u = W(d, ((s) => !P(s) && L(s)));
398
+ u && (u.insertBefore(d), u.getChildren().length === 0 && u.remove());
399
+ } else {
400
+ const u = W(d, ((s) => !P(s) && L(s)));
401
+ if (u) u.setURL(n), t !== void 0 && u.setTarget(t), l !== void 0 && u.setRel(l);
402
+ else {
403
+ const s = R(n, { rel: l, target: t });
404
+ d.insertBefore(s), s.append(d);
405
+ }
406
+ }
407
+ }));
408
+ }
409
+ const c = o.extract();
410
+ if (n === null) return void c.forEach(((a) => {
411
+ const d = W(a, ((u) => !P(u) && L(u)));
412
+ if (d) {
413
+ const u = d.getChildren();
414
+ for (let s = 0; s < u.length; s++) d.insertBefore(u[s]);
415
+ d.remove();
416
+ }
417
+ }));
418
+ const _ = /* @__PURE__ */ new Set(), m = (a) => {
419
+ _.has(a.getKey()) || (_.add(a.getKey()), a.setURL(n), t !== void 0 && a.setTarget(t), l !== void 0 && a.setRel(l), r !== void 0 && a.setTitle(r));
420
+ };
421
+ if (c.length === 1) {
422
+ const a = re(c[0], L);
423
+ if (a !== null) return m(a);
424
+ }
425
+ (function(a) {
426
+ const d = A();
427
+ if (!O(d)) return a();
428
+ const u = X(d), s = u.isBackward(), v = ie(u.anchor, s ? -1 : 0), x = ie(u.focus, s ? 0 : -1);
429
+ if (a(), v || x) {
430
+ const M = A();
431
+ if (O(M)) {
432
+ const h = M.clone();
433
+ if (v) {
434
+ const I = v.getParent();
435
+ I && h.anchor.set(I.getKey(), v.getIndexWithinParent() + (s ? 1 : 0), "element");
436
+ }
437
+ if (x) {
438
+ const I = x.getParent();
439
+ I && h.focus.set(I.getKey(), x.getIndexWithinParent() + (s ? 0 : 1), "element");
440
+ }
441
+ Ce(X(h));
442
+ }
443
+ }
444
+ })((() => {
445
+ let a = null;
446
+ for (const d of c) {
447
+ if (!d.isAttached()) continue;
448
+ const u = re(d, L);
449
+ if (u) {
450
+ m(u);
451
+ continue;
452
+ }
453
+ if (z(d)) {
454
+ if (!d.isInline()) continue;
455
+ if (L(d)) {
456
+ if (!(P(d) || a !== null && a.getParentOrThrow().isParentOf(d))) {
457
+ m(d), a = d;
458
+ continue;
459
+ }
460
+ for (const v of d.getChildren()) d.insertBefore(v);
461
+ d.remove();
462
+ continue;
463
+ }
464
+ }
465
+ const s = d.getPreviousSibling();
466
+ L(s) && s.is(a) ? s.append(d) : (a = R(n, { rel: l, target: t, title: r }), d.insertAfter(a), a.append(d));
467
+ }
468
+ }));
469
+ }
470
+ function re(n, e) {
471
+ let t = n;
472
+ for (; t !== null && t.getParent() !== null && !e(t); ) t = t.getParentOrThrow();
473
+ return e(t) ? t : null;
474
+ }
475
+ const Je = /^\+?[0-9\s()-]{5,}$/;
476
+ function le(n) {
477
+ return n.match(/^[a-z][a-z0-9+.-]*:/i) || n.match(/^[/#.]/) ? n : n.includes("@") ? `mailto:${n}` : Je.test(n) ? `tel:${n}` : `https://${n}`;
478
+ }
479
+ const Ke = () => {
480
+ const [n] = C(), { link: e } = U(), { t } = N(), [r, l] = w(!1), [o, c] = w(""), [_, m] = w(""), [a, d] = w(!0), [u, s] = Y.useMessage(), v = T((h) => h ? h.startsWith("@") ? "javascript:void(0);" : h.match(/^https?:\/\//) ? h : `http://${h}` : "", []), x = () => {
481
+ if (!o) {
482
+ u.warning(t("editor.linkAddressEmpty"));
483
+ return;
484
+ }
485
+ const h = v(o);
486
+ n.update(() => {
487
+ const I = a ? { target: "_blank", rel: "noopener noreferrer", title: o } : { title: o }, F = A(), S = R(h, I), p = be(_ || o);
488
+ if (O(F))
489
+ F.isCollapsed() ? (S.append(p), F.insertNodes([S])) : $e(h);
490
+ else {
491
+ S.append(p);
492
+ const k = Ie(), y = k.getLastChild();
493
+ if (z(y) && y.isEmpty())
494
+ y.append(S);
495
+ else {
496
+ const Z = Ue();
497
+ Z.append(S), k.append(Z);
498
+ }
499
+ }
500
+ }), c(""), m(""), l(!1);
501
+ }, M = T(() => {
502
+ e ? (c(e.link === "javascript:void(0);" ? "" : e.link), m(e.linkText)) : (c(""), m("")), l(!0);
503
+ }, [e]);
504
+ return /* @__PURE__ */ g(V, { children: [
505
+ /* @__PURE__ */ i(
506
+ b,
507
+ {
508
+ icon: "Insertlink",
509
+ tooltip: t("link"),
510
+ onClick: M,
511
+ active: !!(e != null && e.link)
512
+ }
513
+ ),
514
+ s,
515
+ /* @__PURE__ */ i(_e, { title: t("link"), open: r, onOpenChange: l, children: /* @__PURE__ */ g("div", { children: [
516
+ /* @__PURE__ */ g("div", { className: "px-[20px] pb-[60px] pt-[40px]", children: [
517
+ /* @__PURE__ */ g("div", { className: "flex items-center relative", children: [
518
+ /* @__PURE__ */ i("label", { className: "w-[80px] shrink-0", children: t("linkAddress") }),
519
+ /* @__PURE__ */ i(
520
+ K,
521
+ {
522
+ value: o,
523
+ onChange: (h) => c(h.target.value),
524
+ placeholder: t("editor.linkTip")
525
+ }
526
+ ),
527
+ /* @__PURE__ */ i("div", { className: "absolute bottom-[-30px] left-[80px]", children: /* @__PURE__ */ i("p", { className: "text-[#999]", children: "链接可用 @表单别名,用于应用内表单跳转" }) })
528
+ ] }),
529
+ /* @__PURE__ */ g("div", { className: "flex items-center mt-[40px]", children: [
530
+ /* @__PURE__ */ i("label", { className: "w-[80px] shrink-0", children: t("showContent") }),
531
+ /* @__PURE__ */ i(K, { value: _, onChange: (h) => m(h.target.value) })
532
+ ] })
533
+ ] }),
534
+ /* @__PURE__ */ g("div", { className: "py-[14px] px-[20px] flex justify-between items-center border-t-[1px] border-solid border-[#e0e0e0]", children: [
535
+ /* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(Ae, { checked: a, onChange: (h) => d(h), children: t("openInNewTab") }) }),
536
+ /* @__PURE__ */ g("div", { className: "flex gap-[15px]", children: [
537
+ /* @__PURE__ */ i(j, { onClick: () => l(!1), children: t("cancel") }),
538
+ /* @__PURE__ */ i(j, { type: "primary", onClick: x, children: t("confirm") })
539
+ ] })
540
+ ] })
541
+ ] }) })
542
+ ] });
543
+ }, Ve = () => {
544
+ const [n] = C(), { link: e } = U(), { t } = N(), r = () => {
545
+ e && n.dispatchCommand(We, null);
546
+ };
547
+ return /* @__PURE__ */ i(b, { icon: "cancellink", tooltip: t("cancelLink"), onClick: r });
548
+ }, f = {
549
+ "picture-modal__container": "_picture-modal__container_qyj1h_1",
550
+ "picture-modal__sidebar": "_picture-modal__sidebar_qyj1h_4",
551
+ "picture-modal__menu-list": "_picture-modal__menu-list_qyj1h_9",
552
+ "picture-modal__menu-item": "_picture-modal__menu-item_qyj1h_14",
553
+ "picture-modal__slider": "_picture-modal__slider_qyj1h_24",
554
+ "picture-modal__content": "_picture-modal__content_qyj1h_35",
555
+ "picture-modal__content-title": "_picture-modal__content-title_qyj1h_51",
556
+ "picture-modal__upload-area": "_picture-modal__upload-area_qyj1h_62",
557
+ "picture-modal__upload-area--dragging": "_picture-modal__upload-area--dragging_qyj1h_77",
558
+ "picture-modal__preview": "_picture-modal__preview_qyj1h_83",
559
+ "picture-modal__preview-image": "_picture-modal__preview-image_qyj1h_92",
560
+ "picture-modal__preview-info": "_picture-modal__preview-info_qyj1h_99",
561
+ "picture-modal__preview-filename": "_picture-modal__preview-filename_qyj1h_103",
562
+ "picture-modal__preview-size": "_picture-modal__preview-size_qyj1h_109",
563
+ "picture-modal__preview-delete": "_picture-modal__preview-delete_qyj1h_113",
564
+ "picture-modal__upload-text": "_picture-modal__upload-text_qyj1h_121",
565
+ "picture-modal__footer": "_picture-modal__footer_qyj1h_125"
566
+ }, me = oe((n, e) => {
567
+ const [t] = $.useForm(), [r, l] = w(""), { t: o } = N(), c = (_) => /^https?:\/\/.+/i.test(_);
568
+ return ae(e, () => ({
569
+ getValue: async () => {
570
+ try {
571
+ return await t.validateFields(), r;
572
+ } catch {
573
+ throw new Error("URL validation failed");
574
+ }
575
+ }
576
+ })), /* @__PURE__ */ g(V, { children: [
577
+ /* @__PURE__ */ i("div", { className: f["picture-modal__content-title"], "data-title": o("editor.imageUrlNote"), children: o("editor.enterImageUrl") }),
578
+ /* @__PURE__ */ i($, { form: t, children: /* @__PURE__ */ i(
579
+ $.Item,
580
+ {
581
+ name: "url",
582
+ rules: [
583
+ { required: !0, message: o("editor.pleaseEnterImageUrl") },
584
+ {
585
+ validator: (_, m) => !m || c(m) ? Promise.resolve() : Promise.reject(new Error(o("editor.pleaseEnterValidImageUrl")))
586
+ }
587
+ ],
588
+ children: /* @__PURE__ */ i(
589
+ K,
590
+ {
591
+ placeholder: o("editor.pleaseEnterImageUrl"),
592
+ value: r,
593
+ onChange: (_) => l(_.target.value)
594
+ }
595
+ )
596
+ }
597
+ ) })
598
+ ] });
599
+ });
600
+ me.displayName = "LinkInput";
601
+ const he = oe((n, e) => {
602
+ const [t, r] = w(null), [l, o] = w(!1), [c, _] = w(null), m = J(null), [a, d] = Y.useMessage(), { t: u } = N(), 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), x = (p) => {
603
+ if (v(p)) {
604
+ const k = URL.createObjectURL(p);
605
+ r(k), _(p);
606
+ }
607
+ }, M = () => {
608
+ var p;
609
+ (p = m.current) == null || p.click();
610
+ }, h = (p) => {
611
+ var y;
612
+ const k = (y = p.target.files) == null ? void 0 : y[0];
613
+ k && x(k);
614
+ }, I = (p) => {
615
+ p.preventDefault(), o(!0);
616
+ }, F = (p) => {
617
+ p.preventDefault(), o(!1);
618
+ }, S = (p) => {
619
+ p.preventDefault(), o(!1);
620
+ const k = p.dataTransfer.files[0];
621
+ k && x(k);
622
+ };
623
+ return ae(e, () => ({
624
+ getValue: async () => {
625
+ if (!c)
626
+ throw a.warning(u("editor.pleaseUploadImageFirst")), new Error(u("editor.pleaseUploadImageFirst"));
627
+ return new Promise((p, k) => {
628
+ const y = new FileReader();
629
+ y.onload = () => {
630
+ p({
631
+ src: y.result,
632
+ fileName: c.name
633
+ });
634
+ }, y.onerror = () => {
635
+ k(new Error(u("editor.operationFailed")));
636
+ }, y.readAsDataURL(c);
637
+ });
638
+ }
639
+ })), /* @__PURE__ */ g(
640
+ "div",
641
+ {
642
+ className: "h-full",
643
+ onDragOver: I,
644
+ onDragLeave: F,
645
+ onDrop: S,
646
+ children: [
647
+ /* @__PURE__ */ i(
648
+ "div",
649
+ {
650
+ className: f["picture-modal__content-title"],
651
+ "data-title": u("editor.imageSizeNote"),
652
+ children: u("editor.uploadImage")
653
+ }
654
+ ),
655
+ /* @__PURE__ */ g(
656
+ "div",
657
+ {
658
+ className: `${f["picture-modal__upload-area"]} ${l ? f["picture-modal__upload-area--dragging"] : ""}`,
659
+ onClick: M,
660
+ children: [
661
+ /* @__PURE__ */ i(D, { name: "upload" }),
662
+ /* @__PURE__ */ i("span", { className: f["picture-modal__upload-text"], children: u("editor.clickOrDragToUpload") })
663
+ ]
664
+ }
665
+ ),
666
+ /* @__PURE__ */ i(Te, { mode: "wait", children: t && c && /* @__PURE__ */ g(
667
+ E.div,
668
+ {
669
+ className: f["picture-modal__preview"],
670
+ initial: { opacity: 0, y: 20, scale: 0.95 },
671
+ animate: { opacity: 1, y: 0, scale: 1 },
672
+ exit: { opacity: 0, y: -10, scale: 0.95 },
673
+ transition: {
674
+ duration: 0.3,
675
+ ease: [0.4, 0, 0.2, 1]
676
+ },
677
+ children: [
678
+ /* @__PURE__ */ i(
679
+ E.div,
680
+ {
681
+ className: f["picture-modal__preview-image"],
682
+ initial: { opacity: 0, scale: 0.8 },
683
+ animate: { opacity: 1, scale: 1 },
684
+ transition: { delay: 0.1, duration: 0.2 },
685
+ children: /* @__PURE__ */ i(
686
+ "img",
687
+ {
688
+ src: t,
689
+ style: { maxWidth: "120px", height: "80px" },
690
+ alt: u("editor.previewImage")
691
+ }
692
+ )
693
+ }
694
+ ),
695
+ /* @__PURE__ */ g(
696
+ E.div,
697
+ {
698
+ className: f["picture-modal__preview-info"],
699
+ initial: { opacity: 0, x: 20 },
700
+ animate: { opacity: 1, x: 0 },
701
+ transition: { delay: 0.15, duration: 0.2 },
702
+ children: [
703
+ /* @__PURE__ */ i("div", { className: f["picture-modal__preview-filename"], children: c.name }),
704
+ /* @__PURE__ */ i("div", { className: f["picture-modal__preview-size"], children: s(c.size) })
705
+ ]
706
+ }
707
+ ),
708
+ /* @__PURE__ */ i(
709
+ E.div,
710
+ {
711
+ className: f["picture-modal__preview-delete"],
712
+ role: "button",
713
+ onClick: () => {
714
+ r(null), _(null);
715
+ },
716
+ initial: { opacity: 0, scale: 0.8 },
717
+ animate: { opacity: 1, scale: 1 },
718
+ transition: { delay: 0.2, duration: 0.2 },
719
+ whileHover: { scale: 1.1 },
720
+ whileTap: { scale: 0.95 },
721
+ children: /* @__PURE__ */ i(D, { name: "delete" })
722
+ }
723
+ )
724
+ ]
725
+ },
726
+ "preview"
727
+ ) }),
728
+ /* @__PURE__ */ i(
729
+ "input",
730
+ {
731
+ ref: m,
732
+ type: "file",
733
+ accept: "image/*",
734
+ style: { display: "none" },
735
+ onChange: h
736
+ }
737
+ ),
738
+ d
739
+ ]
740
+ }
741
+ );
742
+ });
743
+ he.displayName = "UploadImage";
744
+ const Ge = ce(
745
+ "INSERT_INLINE_IMAGE_COMMAND"
746
+ ), He = () => {
747
+ const { t: n } = N(), [e] = C(), [t, r] = w(!1), l = J(null), o = J(null), c = [
748
+ {
749
+ key: "upload",
750
+ title: n("editor.uploadImage"),
751
+ icon: /* @__PURE__ */ i(D, { name: "picture" })
752
+ },
753
+ {
754
+ key: "url",
755
+ title: n("editor.imageUrl"),
756
+ icon: /* @__PURE__ */ i(D, { name: "Insertlink" })
757
+ }
758
+ ], [_, m] = w(c[0].key), a = () => c.findIndex((v) => v.key === _) * 40, d = async () => {
759
+ try {
760
+ let s = "", v = "";
761
+ if (_ === "upload" && o.current) {
762
+ const x = await o.current.getValue();
763
+ s = x.src, v = x.fileName;
764
+ } else l.current && (s = await l.current.getValue(), v = s);
765
+ e.dispatchCommand(Ge, {
766
+ src: s,
767
+ altText: v
768
+ }), r(!1);
769
+ } catch (s) {
770
+ Y.error(s instanceof Error ? s.message : n("editor.operationFailed"));
771
+ }
772
+ }, u = {
773
+ upload: /* @__PURE__ */ i(he, { ref: o }),
774
+ url: /* @__PURE__ */ i(me, { ref: l })
775
+ };
776
+ return /* @__PURE__ */ g(V, { children: [
777
+ /* @__PURE__ */ i(b, { icon: "picture", tooltip: n("picture"), onClick: () => r(!0) }),
778
+ /* @__PURE__ */ g(_e, { title: n("addPicture"), open: t, onOpenChange: r, width: "620px", children: [
779
+ /* @__PURE__ */ g("div", { className: f["picture-modal__container"], children: [
780
+ /* @__PURE__ */ g("div", { className: f["picture-modal__sidebar"], children: [
781
+ /* @__PURE__ */ i(
782
+ "div",
783
+ {
784
+ className: f["picture-modal__slider"],
785
+ style: {
786
+ transform: `translateY(${a()}px)`
787
+ }
788
+ }
789
+ ),
790
+ /* @__PURE__ */ i("ul", { className: f["picture-modal__menu-list"], children: c.map((s) => /* @__PURE__ */ g(
791
+ "li",
792
+ {
793
+ className: `${f["picture-modal__menu-item"]} ${_ === s.key ? f["picture-modal__menu-item--active"] : ""}`,
794
+ onClick: () => m(s.key),
795
+ children: [
796
+ /* @__PURE__ */ i("span", { className: f["picture-modal__menu-icon"], children: s.icon }),
797
+ /* @__PURE__ */ i("span", { children: s.title })
798
+ ]
799
+ },
800
+ s.title
801
+ )) })
802
+ ] }),
803
+ /* @__PURE__ */ i("div", { className: f["picture-modal__content"], children: u[_] })
804
+ ] }),
805
+ /* @__PURE__ */ g("div", { className: f["picture-modal__footer"], children: [
806
+ /* @__PURE__ */ i(j, { onClick: () => r(!1), children: n("cancel") }),
807
+ /* @__PURE__ */ i(j, { type: "primary", onClick: d, children: n("confirm") })
808
+ ] })
809
+ ] })
810
+ ] });
811
+ }, dt = {
812
+ bold: Re,
813
+ underline: Fe,
814
+ italic: De,
815
+ fontSize: Be,
816
+ fontColor: Ee,
817
+ fill: Pe,
818
+ align: je,
819
+ link: Ke,
820
+ unLink: Ve,
821
+ picture: He
822
+ };
823
+ export {
824
+ dt as B,
825
+ Ge as I,
826
+ Me as T,
827
+ B as g,
828
+ We as k,
829
+ q as m,
830
+ L as p,
831
+ $e as v
832
+ };