@baishuyun/ui-base 2.3.1 → 2.3.2

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 (74) hide show
  1. package/dist/Card/Card-BE6v4I-A.js +69 -0
  2. package/dist/Card/index.js +3 -4
  3. package/dist/CheckBox/CheckBox--rXaUgMO.js +67 -0
  4. package/dist/CheckBox/CheckBox-Db8X-pw9.js +33 -0
  5. package/dist/CheckBox/index.js +4 -39
  6. package/dist/ColorPicker/ColorPicker-BBP-4-so.js +168 -0
  7. package/dist/ColorPicker/index.js +6 -5
  8. package/dist/DropDown/DropDown-CKXi9mXN.js +162 -0
  9. package/dist/DropDown/index.js +7 -4
  10. package/dist/Editor/Buttons--dMLPuk2.js +595 -0
  11. package/dist/Editor/ToolbarPlugin/Buttons/index.js +14 -8
  12. package/dist/Editor/constants/index.js +53 -20
  13. package/dist/Editor/index.js +518 -576
  14. package/dist/Icon/Icon-DppVOyPK.js +19 -0
  15. package/dist/Icon/index.js +2 -4
  16. package/dist/InputTag/InputTag-B6N5MZA2.js +139 -0
  17. package/dist/InputTag/index.js +3 -4
  18. package/dist/Loading/Loading-Bi5NO-Ky.js +15 -0
  19. package/dist/Loading/index.js +2 -4
  20. package/dist/Modal/Modal-FVJpbEgw.js +81 -0
  21. package/dist/Modal/index.js +3 -4
  22. package/dist/NotFoundContent/NotFoundContent-CTPpcZOt.js +9 -0
  23. package/dist/NotFoundContent/index.js +2 -4
  24. package/dist/Radio/Radio-dyoBNiKF.js +85 -0
  25. package/dist/Radio/index.js +2 -105
  26. package/dist/Segmented/Segmented-Dd8glDXI.js +62 -0
  27. package/dist/Segmented/index.js +2 -4
  28. package/dist/Select/Select-Bd2ECrB0.js +729 -0
  29. package/dist/Select/SelectInputSearch-CIXBNLFi.js +46 -0
  30. package/dist/Select/index.js +11 -6
  31. package/dist/Tabs/Tabs-C79GTyGd.js +410 -0
  32. package/dist/Tabs/index.js +6 -7
  33. package/dist/Tree/index.js +5 -4
  34. package/dist/Tree/utils/index.js +24 -39
  35. package/dist/components/Editor/context/EditorContainerContext.d.ts +8 -0
  36. package/dist/index.js +103 -81
  37. package/dist/style.css +2 -1
  38. package/dist/vendors/Tree-CQR9fvpA.js +231 -0
  39. package/dist/vendors/animations-C5JKFkz4.js +38 -0
  40. package/dist/vendors/clsx-DNOE4Gl8.js +16 -0
  41. package/dist/vendors/color-BPWy9DvT.js +12 -0
  42. package/dist/vendors/fuse.js-BKtvbTjL.js +877 -0
  43. package/dist/vendors/lexical-hZliMgDv.js +6439 -0
  44. package/dist/vendors/lodash-es-Bu9xU1fK.js +334 -0
  45. package/dist/vendors/simplebar-react-CFlS-Nm9.js +370 -0
  46. package/dist/vendors/tinycolor2-DToeAEPD.js +726 -0
  47. package/dist/vendors/useFloatingPortal-BA6P5GxV.js +45 -0
  48. package/dist/vendors/useLocale-BfT0V1j4.js +75 -0
  49. package/package.json +3 -3
  50. package/dist/Card/Card-Y1ISqAp9.js +0 -86
  51. package/dist/CheckBox/CheckBox-C9sXWSA5.js +0 -84
  52. package/dist/ColorPicker/ColorPicker-uPJOs52x.js +0 -215
  53. package/dist/DropDown/DropDown-DGkSeXQT.js +0 -166
  54. package/dist/Editor/index-D7tFsaxU.js +0 -846
  55. package/dist/Icon/Icon-CBlIwtp2.js +0 -24
  56. package/dist/InputTag/InputTag-C-rQUJnF.js +0 -155
  57. package/dist/Loading/Loading-CEB4PLUE.js +0 -9
  58. package/dist/Modal/Modal-z3TvEXwN.js +0 -80
  59. package/dist/NotFoundContent/NotFoundContent-h0-oIXlk.js +0 -6
  60. package/dist/Segmented/Segmented-UgzW78Ey.js +0 -75
  61. package/dist/Select/Select-hwXXDuLU.js +0 -820
  62. package/dist/Select/SelectInputSearch-ChUpUgxa.js +0 -34
  63. package/dist/Tabs/TabSelect-DL8Bhehc.js +0 -445
  64. package/dist/vendors/Tree-CLEy-xqz.js +0 -235
  65. package/dist/vendors/clsx-OuTLNxxd.js +0 -16
  66. package/dist/vendors/color-VzwvCPhF.js +0 -21
  67. package/dist/vendors/fuse.js-D1DCbUBb.js +0 -1022
  68. package/dist/vendors/index-MTmG1Ezy.js +0 -15
  69. package/dist/vendors/lexical-DO7eMeC2.js +0 -5891
  70. package/dist/vendors/lodash-es-DFpaJB4Y.js +0 -305
  71. package/dist/vendors/simplebar-react-D68KzE44.js +0 -408
  72. package/dist/vendors/tinycolor2-Begv3Jc8.js +0 -711
  73. package/dist/vendors/useFloatingPortal-9VUFOAOG.js +0 -45
  74. package/dist/vendors/useLocale-DgqW9M3h.js +0 -47
@@ -1,846 +0,0 @@
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
- import { c as xe } from "../vendors/clsx-OuTLNxxd.js";
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-uPJOs52x.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
- import Ae from "../CheckBox/index.js";
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 {
17
- static getType() {
18
- return "link";
19
- }
20
- static clone(e) {
21
- return new F(e.__url, { rel: e.__rel, target: e.__target, title: e.__title }, e.__key);
22
- }
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;
27
- }
28
- createDOM(e) {
29
- const t = document.createElement("a");
30
- return this.updateLinkDOM(null, t, e), be(t, e.theme.link), t;
31
- }
32
- updateLinkDOM(e, t, i) {
33
- if (ue(t)) {
34
- e && e.__url === this.__url || (t.href = this.sanitizeUrl(this.__url));
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));
38
- }
39
- }
40
- }
41
- updateDOM(e, t, i) {
42
- return this.updateLinkDOM(e, t, i), !1;
43
- }
44
- static importDOM() {
45
- return { a: (e) => ({ conversion: Ee, priority: 1 }) };
46
- }
47
- static importJSON(e) {
48
- return B().updateFromJSON(e);
49
- }
50
- updateFromJSON(e) {
51
- return super.updateFromJSON(e).setURL(e.url).setRel(e.rel || null).setTarget(e.target || null).setTitle(e.title || null);
52
- }
53
- sanitizeUrl(e) {
54
- e = oe(e);
55
- try {
56
- const t = new URL(oe(e));
57
- if (!Re.has(t.protocol)) return "about:blank";
58
- } catch {
59
- return e;
60
- }
61
- return e;
62
- }
63
- exportJSON() {
64
- return { ...super.exportJSON(), rel: this.getRel(), target: this.getTarget(), title: this.getTitle(), url: this.getURL() };
65
- }
66
- getURL() {
67
- return this.getLatest().__url;
68
- }
69
- setURL(e) {
70
- const t = this.getWritable();
71
- return t.__url = e, t;
72
- }
73
- getTarget() {
74
- return this.getLatest().__target;
75
- }
76
- setTarget(e) {
77
- const t = this.getWritable();
78
- return t.__target = e, t;
79
- }
80
- getRel() {
81
- return this.getLatest().__rel;
82
- }
83
- setRel(e) {
84
- const t = this.getWritable();
85
- return t.__rel = e, t;
86
- }
87
- getTitle() {
88
- return this.getLatest().__title;
89
- }
90
- setTitle(e) {
91
- const t = this.getWritable();
92
- return t.__title = e, t;
93
- }
94
- insertNewAfter(e, t = !0) {
95
- const i = B(this.__url, { rel: this.__rel, target: this.__target, title: this.__title });
96
- return this.insertAfter(i, t), i;
97
- }
98
- canInsertTextBefore() {
99
- return !1;
100
- }
101
- canInsertTextAfter() {
102
- return !1;
103
- }
104
- canBeEmpty() {
105
- return !1;
106
- }
107
- isInline() {
108
- return !0;
109
- }
110
- extractWithChild(e, t, i) {
111
- if (!O(t)) return !1;
112
- const o = t.anchor.getNode(), l = t.focus.getNode();
113
- return this.isParentOf(o) && this.isParentOf(l) && t.getTextContent().length > 0;
114
- }
115
- isEmailURI() {
116
- return this.__url.startsWith("mailto:");
117
- }
118
- isWebSiteURI() {
119
- return this.__url.startsWith("https://") || this.__url.startsWith("http://");
120
- }
121
- }
122
- function Ee(n) {
123
- let e = null;
124
- if (ue(n)) {
125
- const t = n.textContent;
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") }));
127
- }
128
- return { node: e };
129
- }
130
- function B(n = "", e) {
131
- return de(new F(n, e));
132
- }
133
- function L(n) {
134
- return n instanceof F;
135
- }
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;
139
- }
140
- static getType() {
141
- return "autolink";
142
- }
143
- static clone(e) {
144
- return new q(e.__url, { isUnlinked: e.__isUnlinked, rel: e.__rel, target: e.__target, title: e.__title }, e.__key);
145
- }
146
- getIsUnlinked() {
147
- return this.__isUnlinked;
148
- }
149
- setIsUnlinked(e) {
150
- const t = this.getWritable();
151
- return t.__isUnlinked = e, t;
152
- }
153
- createDOM(e) {
154
- return this.__isUnlinked ? document.createElement("span") : super.createDOM(e);
155
- }
156
- updateDOM(e, t, i) {
157
- return super.updateDOM(e, t, i) || e.__isUnlinked !== this.__isUnlinked;
158
- }
159
- static importJSON(e) {
160
- return ne().updateFromJSON(e);
161
- }
162
- updateFromJSON(e) {
163
- return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked || !1);
164
- }
165
- static importDOM() {
166
- return null;
167
- }
168
- exportJSON() {
169
- return { ...super.exportJSON(), isUnlinked: this.__isUnlinked };
170
- }
171
- insertNewAfter(e, t = !0) {
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;
176
- }
177
- return null;
178
- }
179
- }
180
- function ne(n = "", e) {
181
- return de(new q(n, e));
182
- }
183
- function P(n) {
184
- return n instanceof q;
185
- }
186
- const Fe = ce("TOGGLE_LINK_COMMAND");
187
- function re(n, e) {
188
- if (n.type === "element") {
189
- const t = n.getNode();
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.`);
195
- })(252), t.getChildren()[n.offset + e] || null;
196
- }
197
- return null;
198
- }
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();
204
- return a.length === 0 ? void 0 : void a.forEach(((d) => {
205
- if (n === null) {
206
- const u = $(d, ((s) => !P(s) && L(s)));
207
- u && (u.insertBefore(d), u.getChildren().length === 0 && u.remove());
208
- } else {
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);
211
- else {
212
- const s = B(n, { rel: o, target: t });
213
- d.insertBefore(s), s.append(d);
214
- }
215
- }
216
- }));
217
- }
218
- const c = l.extract();
219
- if (n === null) return void c.forEach(((a) => {
220
- const d = $(a, ((u) => !P(u) && L(u)));
221
- if (d) {
222
- const u = d.getChildren();
223
- for (let s = 0; s < u.length; s++) d.insertBefore(u[s]);
224
- d.remove();
225
- }
226
- }));
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));
229
- };
230
- if (c.length === 1) {
231
- const a = ie(c[0], L);
232
- if (a !== null) return _(a);
233
- }
234
- (function(a) {
235
- const d = T();
236
- if (!O(d)) return a();
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();
240
- if (O(M)) {
241
- const h = M.clone();
242
- if (v) {
243
- const I = v.getParent();
244
- I && h.anchor.set(I.getKey(), v.getIndexWithinParent() + (s ? 1 : 0), "element");
245
- }
246
- if (y) {
247
- const I = y.getParent();
248
- I && h.focus.set(I.getKey(), y.getIndexWithinParent() + (s ? 0 : 1), "element");
249
- }
250
- we(ee(h));
251
- }
252
- }
253
- })((() => {
254
- let a = null;
255
- for (const d of c) {
256
- if (!d.isAttached()) continue;
257
- const u = ie(d, L);
258
- if (u) {
259
- _(u);
260
- continue;
261
- }
262
- if (z(d)) {
263
- if (!d.isInline()) continue;
264
- if (L(d)) {
265
- if (!(P(d) || a !== null && a.getParentOrThrow().isParentOf(d))) {
266
- _(d), a = d;
267
- continue;
268
- }
269
- for (const v of d.getChildren()) d.insertBefore(v);
270
- d.remove();
271
- continue;
272
- }
273
- }
274
- const s = d.getPreviousSibling();
275
- L(s) && s.is(a) ? s.append(d) : (a = B(n, { rel: o, target: t, title: i }), d.insertAfter(a), a.append(d));
276
- }
277
- }));
278
- }
279
- function ie(n, e) {
280
- let t = n;
281
- for (; t !== null && t.getParent() !== null && !e(t); ) t = t.getParentOrThrow();
282
- return e(t) ? t : null;
283
- }
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}`;
287
- }
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
- u.warning(t("editor.linkAddressEmpty"));
483
- return;
484
- }
485
- const h = v(l);
486
- n.update(() => {
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
- else {
491
- S.append(p);
492
- const k = Ue(), x = k.getLastChild();
493
- if (z(x) && x.isEmpty())
494
- x.append(S);
495
- else {
496
- const Q = Oe();
497
- Q.append(S), k.append(Q);
498
- }
499
- }
500
- }), c(""), _(""), o(!1);
501
- }, M = A(() => {
502
- e ? (c(e.link === "javascript:void(0);" ? "" : e.link), _(e.linkText)) : (c(""), _("")), o(!0);
503
- }, [e]);
504
- return /* @__PURE__ */ g(G, { children: [
505
- /* @__PURE__ */ r(
506
- C,
507
- {
508
- icon: "Insertlink",
509
- tooltip: t("link"),
510
- onClick: M,
511
- active: !!(e != null && e.link)
512
- }
513
- ),
514
- s,
515
- /* @__PURE__ */ r(_e, { title: t("link"), open: i, onOpenChange: o, 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__ */ r("label", { className: "w-[80px] shrink-0", children: t("linkAddress") }),
519
- /* @__PURE__ */ r(
520
- V,
521
- {
522
- value: l,
523
- onChange: (h) => c(h.target.value),
524
- placeholder: t("editor.linkTip")
525
- }
526
- ),
527
- /* @__PURE__ */ r("div", { className: "absolute bottom-[-30px] left-[80px]", children: /* @__PURE__ */ r("p", { className: "text-[#999]", children: "链接可用 @表单别名,用于应用内表单跳转" }) })
528
- ] }),
529
- /* @__PURE__ */ g("div", { className: "flex items-center mt-[40px]", children: [
530
- /* @__PURE__ */ r("label", { className: "w-[80px] shrink-0", children: t("showContent") }),
531
- /* @__PURE__ */ r(V, { value: m, onChange: (h) => _(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__ */ r("div", { children: /* @__PURE__ */ r(Ae, { checked: a, onChange: (h) => d(h), children: t("openInNewTab") }) }),
536
- /* @__PURE__ */ g("div", { className: "flex gap-[15px]", children: [
537
- /* @__PURE__ */ r(j, { onClick: () => o(!1), children: t("cancel") }),
538
- /* @__PURE__ */ r(j, { type: "primary", onClick: y, children: t("confirm") })
539
- ] })
540
- ] })
541
- ] }) })
542
- ] });
543
- }, Ge = () => {
544
- const [n] = b(), { link: e } = U(), { t } = w(), i = () => {
545
- e && n.dispatchCommand(Fe, null);
546
- };
547
- return /* @__PURE__ */ r(C, { icon: "cancellink", tooltip: t("cancelLink"), onClick: i });
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
- }, 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
- getValue: async () => {
570
- try {
571
- return await t.validateFields(), i;
572
- } catch {
573
- throw new Error("URL validation failed");
574
- }
575
- }
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
- {
581
- name: "url",
582
- rules: [
583
- { required: !0, message: l("editor.pleaseEnterImageUrl") },
584
- {
585
- validator: (m, _) => !_ || c(_) ? Promise.resolve() : Promise.reject(new Error(l("editor.pleaseEnterValidImageUrl")))
586
- }
587
- ],
588
- children: /* @__PURE__ */ r(
589
- V,
590
- {
591
- placeholder: l("editor.pleaseEnterImageUrl"),
592
- value: i,
593
- onChange: (m) => o(m.target.value)
594
- }
595
- )
596
- }
597
- ) })
598
- ] });
599
- });
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
- if (v(p)) {
604
- const k = URL.createObjectURL(p);
605
- i(k), m(p);
606
- }
607
- }, M = () => {
608
- var p;
609
- (p = _.current) == null || p.click();
610
- }, h = (p) => {
611
- var x;
612
- const k = (x = p.target.files) == null ? void 0 : x[0];
613
- k && y(k);
614
- }, I = (p) => {
615
- p.preventDefault(), l(!0);
616
- }, R = (p) => {
617
- p.preventDefault(), l(!1);
618
- }, S = (p) => {
619
- p.preventDefault(), l(!1);
620
- const k = p.dataTransfer.files[0];
621
- k && y(k);
622
- };
623
- return se(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 x = new FileReader();
629
- x.onload = () => {
630
- p({
631
- src: x.result,
632
- fileName: c.name
633
- });
634
- }, x.onerror = () => {
635
- k(new Error(u("editor.operationFailed")));
636
- }, x.readAsDataURL(c);
637
- });
638
- }
639
- })), /* @__PURE__ */ g(
640
- "div",
641
- {
642
- className: "h-full",
643
- onDragOver: I,
644
- onDragLeave: R,
645
- onDrop: S,
646
- children: [
647
- /* @__PURE__ */ r(
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"]} ${o ? f["picture-modal__upload-area--dragging"] : ""}`,
659
- onClick: M,
660
- children: [
661
- /* @__PURE__ */ r(E, { name: "upload" }),
662
- /* @__PURE__ */ r("span", { className: f["picture-modal__upload-text"], children: u("editor.clickOrDragToUpload") })
663
- ]
664
- }
665
- ),
666
- /* @__PURE__ */ r(Me, { mode: "wait", children: t && c && /* @__PURE__ */ g(
667
- D.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__ */ r(
679
- D.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__ */ r(
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
- D.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__ */ 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
- ]
706
- }
707
- ),
708
- /* @__PURE__ */ r(
709
- D.div,
710
- {
711
- className: f["picture-modal__preview-delete"],
712
- role: "button",
713
- onClick: () => {
714
- i(null), m(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__ */ r(E, { name: "delete" })
722
- }
723
- )
724
- ]
725
- },
726
- "preview"
727
- ) }),
728
- /* @__PURE__ */ r(
729
- "input",
730
- {
731
- ref: _,
732
- type: "file",
733
- accept: "image/*",
734
- style: { display: "none" },
735
- onChange: h
736
- }
737
- ),
738
- d
739
- ]
740
- }
741
- );
742
- });
743
- fe.displayName = "UploadImage";
744
- const He = ce(
745
- "INSERT_INLINE_IMAGE_COMMAND"
746
- ), Ye = () => {
747
- const { t: n } = w(), [e] = b(), [t, i] = N(!1), o = K(null), l = K(null), c = [
748
- {
749
- key: "upload",
750
- title: n("editor.uploadImage"),
751
- icon: /* @__PURE__ */ r(E, { name: "picture" })
752
- },
753
- {
754
- key: "url",
755
- title: n("editor.imageUrl"),
756
- icon: /* @__PURE__ */ r(E, { name: "Insertlink" })
757
- }
758
- ], [m, _] = N(c[0].key), a = () => c.findIndex((v) => v.key === m) * 40, d = async () => {
759
- try {
760
- let s = "", v = "";
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
- src: s,
767
- altText: v
768
- }), i(!1);
769
- } catch (s) {
770
- Z.error(s instanceof Error ? s.message : n("editor.operationFailed"));
771
- }
772
- }, u = {
773
- upload: /* @__PURE__ */ r(fe, { ref: l }),
774
- url: /* @__PURE__ */ r(he, { ref: o })
775
- };
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
- /* @__PURE__ */ g("div", { className: f["picture-modal__container"], children: [
780
- /* @__PURE__ */ g("div", { className: f["picture-modal__sidebar"], children: [
781
- /* @__PURE__ */ r(
782
- "div",
783
- {
784
- className: f["picture-modal__slider"],
785
- style: {
786
- transform: `translateY(${a()}px)`
787
- }
788
- }
789
- ),
790
- /* @__PURE__ */ r("ul", { className: f["picture-modal__menu-list"], children: c.map((s) => /* @__PURE__ */ g(
791
- "li",
792
- {
793
- className: `${f["picture-modal__menu-item"]} ${m === s.key ? f["picture-modal__menu-item--active"] : ""}`,
794
- onClick: () => _(s.key),
795
- children: [
796
- /* @__PURE__ */ r("span", { className: f["picture-modal__menu-icon"], children: s.icon }),
797
- /* @__PURE__ */ r("span", { children: s.title })
798
- ]
799
- },
800
- s.title
801
- )) })
802
- ] }),
803
- /* @__PURE__ */ r("div", { className: f["picture-modal__content"], children: u[m] })
804
- ] }),
805
- /* @__PURE__ */ g("div", { className: f["picture-modal__footer"], children: [
806
- /* @__PURE__ */ r(j, { onClick: () => i(!1), children: n("cancel") }),
807
- /* @__PURE__ */ r(j, { type: "primary", onClick: d, children: n("confirm") })
808
- ] })
809
- ] })
810
- ] });
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
828
- };
829
- Object.entries(Qe).forEach(([n, e]) => {
830
- Ze(n, e);
831
- });
832
- export {
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,
841
- q as m,
842
- L as p,
843
- Ze as r,
844
- mt as u,
845
- De as v
846
- };