@baishuyun/ui-base 6.10.1 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/Amap/AmapCircle/index.js +1 -1
  2. package/dist/Amap/AmapMarker/index.js +1 -1
  3. package/dist/Amap/AmapMarkerCluster/index.js +1 -1
  4. package/dist/Amap/AmapProvider/index.js +4 -4
  5. package/dist/Amap/{AmapProvider-DqFp3DZ5.js → AmapProvider-CvRHhN42.js} +1 -1
  6. package/dist/Amap/hooks/index.js +1 -1
  7. package/dist/Amap/index.js +4 -4
  8. package/dist/Calendar/{Calendar-gEtuBW7Y.js → Calendar-BS0nzK4h.js} +2 -2
  9. package/dist/Calendar/context/index.js +1 -1
  10. package/dist/Calendar/index.js +5 -5
  11. package/dist/Calendar/subcomponents/AllDaySection/index.js +1 -1
  12. package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +1 -1
  13. package/dist/Calendar/subcomponents/EventCard/index.js +1 -1
  14. package/dist/Calendar/subcomponents/TimeAxis/index.js +1 -1
  15. package/dist/Calendar/subcomponents/TimeGrid/index.js +1 -1
  16. package/dist/Calendar/utils/index.js +1 -1
  17. package/dist/Calendar/utils/layout/index.js +1 -1
  18. package/dist/Calendar/utils/theme/index.js +1 -1
  19. package/dist/Card/index.js +1 -1
  20. package/dist/CheckBox/index.js +1 -1
  21. package/dist/ColorPicker/{ColorPicker-CYlrnMwM.js → ColorPicker-DVwg07Gs.js} +1 -1
  22. package/dist/ColorPicker/index.js +4 -4
  23. package/dist/ConfigProvider/index.js +3 -3
  24. package/dist/DatePicker/{DatePicker-CagGt_f0.js → DatePicker-DNPnHLT2.js} +2 -2
  25. package/dist/DatePicker/{DatePickerPanel-CaDZzxMD.js → DatePickerPanel-TS6AxAH-.js} +3 -3
  26. package/dist/DatePicker/index.js +4 -4
  27. package/dist/DatePicker/style/index.js +1 -1
  28. package/dist/DropDown/{DropDown-CLuQf970.js → DropDown-DWf5yf4l.js} +2 -2
  29. package/dist/DropDown/index.js +5 -5
  30. package/dist/DropDown/style/index.js +1 -1
  31. package/dist/Editor/Buttons-BBioCubp.js +1148 -0
  32. package/dist/Editor/ToolbarPlugin/Buttons/index.js +7 -7
  33. package/dist/Editor/constants/index.js +3 -3
  34. package/dist/Editor/index.js +774 -371
  35. package/dist/Gantt/GanttChart/index.js +7 -7
  36. package/dist/Gantt/{GanttChart-DvCAp8Dk.js → GanttChart-BaEW7EDO.js} +2 -2
  37. package/dist/Gantt/GanttTable/index.js +5 -5
  38. package/dist/Gantt/{GanttTable-DyVJOVo3.js → GanttTable-CdXhMHF6.js} +1 -1
  39. package/dist/Gantt/GanttToolBar/index.js +6 -6
  40. package/dist/Gantt/{GanttToolBar-CxT68kmT.js → GanttToolBar-COwsYlMG.js} +2 -2
  41. package/dist/Gantt/index.js +9 -9
  42. package/dist/Gantt/utils/index.js +1 -1
  43. package/dist/Gantt/utils/theme/index.js +1 -1
  44. package/dist/Icon/index.js +1 -1
  45. package/dist/InputTag/{InputTag-yRPO90Ku.js → InputTag-Jpm8H32L.js} +1 -1
  46. package/dist/InputTag/index.js +4 -4
  47. package/dist/Loading/{Loading-BF_dtuLc.js → Loading-CiRe7i2R.js} +1 -1
  48. package/dist/Loading/index.js +4 -4
  49. package/dist/Modal/index.js +1 -1
  50. package/dist/NotFoundContent/index.js +1 -1
  51. package/dist/Overlay/index.js +1 -1
  52. package/dist/Radio/index.js +1 -1
  53. package/dist/ScrollBar/index.js +1 -1
  54. package/dist/Segmented/index.js +1 -1
  55. package/dist/Select/{Select-iwzfNy9d.js → Select-BY5Rpo3f.js} +2 -2
  56. package/dist/Select/{SelectInputSearch-Bc_aPNbG.js → SelectInputSearch-i3egm8Wy.js} +1 -1
  57. package/dist/Select/index.js +5 -5
  58. package/dist/Table/{Table-Cm8zFl2G.js → Table-CSPdFGYn.js} +1 -1
  59. package/dist/Table/hooks/index.js +1 -1
  60. package/dist/Table/index.js +4 -4
  61. package/dist/Table/style/index.js +1 -1
  62. package/dist/Table/utils/index.js +1 -1
  63. package/dist/Tabs/{Tabs-BPWRIwtD.js → Tabs-C0m3mt-j.js} +1 -1
  64. package/dist/Tabs/index.js +4 -4
  65. package/dist/Tooltip/index.js +1 -1
  66. package/dist/Tree/index.js +1 -1
  67. package/dist/Tree/utils/index.js +1 -1
  68. package/dist/components/Editor/ToolbarPlugin/Buttons/HeadingButton.d.ts +2 -0
  69. package/dist/components/Editor/ToolbarPlugin/Buttons/SourceButton.d.ts +2 -0
  70. package/dist/components/Editor/ToolbarPlugin/Buttons/TableButton.d.ts +2 -0
  71. package/dist/components/Editor/ToolbarPlugin/Buttons/index.d.ts +3 -0
  72. package/dist/components/Editor/ToolbarPlugin/context/TextFormatsContext.d.ts +2 -0
  73. package/dist/components/Editor/constants/index.d.ts +1 -0
  74. package/dist/components/Editor/context/EditorContainerContext.d.ts +0 -1
  75. package/dist/components/Editor/context/SourceModeContext.d.ts +9 -0
  76. package/dist/components/Editor/htmlConfig.d.ts +2 -0
  77. package/dist/components/Editor/interface.d.ts +1 -1
  78. package/dist/components/Editor/plugins/HeadingPlugin.d.ts +3 -0
  79. package/dist/components/Editor/plugins/LinkColorPlugin.d.ts +2 -0
  80. package/dist/components/Editor/plugins/SourceModePlugin.d.ts +7 -0
  81. package/dist/components/Editor/plugins/TabIndentPlugin.d.ts +1 -0
  82. package/dist/components/Editor/plugins/TablePlugin.d.ts +1 -0
  83. package/dist/components/Editor/utils/fillRootFromHtml.d.ts +2 -0
  84. package/dist/components/Editor/utils/formatEditorHtml.d.ts +1 -0
  85. package/dist/components/Editor/utils/isEmptyEditorHtml.d.ts +1 -0
  86. package/dist/components/Editor/utils/sanitizeEditorHtml.d.ts +1 -0
  87. package/dist/components/Editor/utils/stripInlineStyleProperty.d.ts +2 -0
  88. package/dist/components/Editor/utils/writeHtmlSource.d.ts +1 -0
  89. package/dist/index.js +15 -15
  90. package/dist/locale/lang/en-US.json.d.ts +7 -0
  91. package/dist/locale/lang/zh-CN.json.d.ts +7 -0
  92. package/dist/locale/lang/zh-TW.json.d.ts +7 -0
  93. package/dist/style.css +1 -1
  94. package/dist/vendors/{ConfigProvider-vPuwReNX.js → ConfigProvider-4xHyyeop.js} +15 -1
  95. package/dist/vendors/{LocaleContext-CN9doEXT.js → LocaleContext-I4PW9j4M.js} +7 -0
  96. package/dist/vendors/{useLocale-sawv8CEL.js → useLocale-FGYsRWSe.js} +1 -1
  97. package/dist/vendors/{version-DdQLttdL.js → version-BxI5QM5W.js} +1 -1
  98. package/package.json +4 -1
  99. package/dist/Editor/Buttons-ByO5rS19.js +0 -937
@@ -1,937 +0,0 @@
1
- import { t as e } from "../Icon/Icon-BBDcb-yw.js";
2
- import { t } from "../Modal/Modal-Cb7Msq26.js";
3
- import { t as n } from "../ColorPicker/ColorPicker-CYlrnMwM.js";
4
- import { t as r } from "../vendors/useLocale-sawv8CEL.js";
5
- import { t as i } from "../CheckBox/CheckBox-nBm0u6zX.js";
6
- import { t as a } from "../ScrollBar/ScrollBar-N2pOLv-8.js";
7
- import { t as o } from "../DropDown/DropDown-CLuQf970.js";
8
- import { FONT_SIZES as s } from "./constants/index.js";
9
- import { AlignCenterOutlined as c, AlignLeftOutlined as l, AlignRightOutlined as u } from "@ant-design/icons";
10
- import { keyBy as d } from "lodash-es";
11
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
12
- import h, { createContext as g, forwardRef as _, useCallback as v, useContext as y, useEffect as b, useImperativeHandle as x, useLayoutEffect as S, useMemo as C, useRef as w, useState as T } from "react";
13
- import { Button as E, Form as D, Input as O, message as k } from "antd";
14
- import ee from "clsx";
15
- import { AnimatePresence as te, motion as ne } from "motion/react";
16
- import { $createParagraphNode as re, $createTextNode as A, $getRoot as ie, $getSelection as j, $isElementNode as ae, $isRangeSelection as M, $isTextNode as N, $setSelection as P, CAN_REDO_COMMAND as oe, CAN_UNDO_COMMAND as se, COMMAND_PRIORITY_CRITICAL as ce, FORMAT_ELEMENT_COMMAND as le, FORMAT_TEXT_COMMAND as F, INDENT_CONTENT_COMMAND as ue, OUTDENT_CONTENT_COMMAND as de, REDO_COMMAND as fe, UNDO_COMMAND as pe, createCommand as me, mergeRegister as he } from "lexical";
17
- import { useLexicalComposerContext as I } from "@lexical/react/LexicalComposerContext";
18
- import { $patchStyleText as L, $setBlocksType as ge } from "@lexical/selection";
19
- import { $createLinkNode as _e, $toggleLink as ve, TOGGLE_LINK_COMMAND as ye } from "@lexical/link";
20
- import { INSERT_ORDERED_LIST_COMMAND as be, INSERT_UNORDERED_LIST_COMMAND as xe, REMOVE_LIST_COMMAND as Se } from "@lexical/list";
21
- import { $createCodeNode as Ce } from "@lexical/code-core";
22
- //#region src/components/Editor/ToolbarPlugin/context/TextFormatsContext.tsx
23
- var we = g(null), R = "plaintext", Te = "github-light", z = [
24
- {
25
- id: "plaintext",
26
- label: "Plain text"
27
- },
28
- {
29
- id: "css",
30
- label: "CSS"
31
- },
32
- {
33
- id: "html",
34
- label: "HTML"
35
- },
36
- {
37
- id: "xml",
38
- label: "XML"
39
- },
40
- {
41
- id: "javascript",
42
- label: "JavaScript"
43
- },
44
- {
45
- id: "typescript",
46
- label: "TypeScript"
47
- },
48
- {
49
- id: "jsx",
50
- label: "JSX"
51
- },
52
- {
53
- id: "go",
54
- label: "Go"
55
- },
56
- {
57
- id: "php",
58
- label: "PHP"
59
- },
60
- {
61
- id: "c",
62
- label: "C"
63
- },
64
- {
65
- id: "python",
66
- label: "Python"
67
- },
68
- {
69
- id: "java",
70
- label: "Java"
71
- },
72
- {
73
- id: "cpp",
74
- label: "C++"
75
- },
76
- {
77
- id: "csharp",
78
- label: "C#"
79
- },
80
- {
81
- id: "vb",
82
- label: "Visual Basic"
83
- },
84
- {
85
- id: "sql",
86
- label: "SQL"
87
- },
88
- {
89
- id: "ruby",
90
- label: "Ruby"
91
- },
92
- {
93
- id: "swift",
94
- label: "Swift"
95
- },
96
- {
97
- id: "bash",
98
- label: "Bash"
99
- },
100
- {
101
- id: "lua",
102
- label: "Lua"
103
- },
104
- {
105
- id: "markdown",
106
- label: "Markdown"
107
- }
108
- ], B = d(z, "id"), Ee = (e) => e && B[e] ? e : R, V = g(null), H = () => {
109
- let e = y(V);
110
- if (!e) throw Error("useHistoryStateContext must be used within HistoryStateProvider");
111
- return e;
112
- }, De = ({ children: e }) => {
113
- let [t] = I(), [n, r] = T({
114
- canUndo: !1,
115
- canRedo: !1
116
- });
117
- return b(() => he(t.registerCommand(se, (e) => (r((t) => t.canUndo === e ? t : {
118
- ...t,
119
- canUndo: e
120
- }), !1), ce), t.registerCommand(oe, (e) => (r((t) => t.canRedo === e ? t : {
121
- ...t,
122
- canRedo: e
123
- }), !1), ce)), [t]), /* @__PURE__ */ p(V.Provider, {
124
- value: n,
125
- children: e
126
- });
127
- }, U = g({ iconSize: 14 }), Oe = U.Provider, W = () => y(U), G = {
128
- "lexical-editor__toolbar-button": "_lexical-editor__toolbar-button_10xg7_1",
129
- "lexical-editor__toolbar-button-active": "_lexical-editor__toolbar-button-active_10xg7_20"
130
- }, K = (t) => {
131
- let { icon: n, tooltip: r, onClick: i, disabled: a = !1, active: o = !1, size: s } = t, { iconSize: c } = W(), l = s ?? c;
132
- return /* @__PURE__ */ p("button", {
133
- className: ee(G["lexical-editor__toolbar-button"], { [G["lexical-editor__toolbar-button-active"]]: o }),
134
- type: "button",
135
- onClick: i,
136
- onMouseDown: (e) => e.preventDefault(),
137
- disabled: a,
138
- title: r,
139
- children: h.isValidElement(n) ? n : /* @__PURE__ */ p(e, {
140
- name: n,
141
- size: l
142
- })
143
- });
144
- }, q = () => {
145
- let e = y(we);
146
- if (!e) throw Error("useTextFormatsContext must be used within TextFormatsProvider");
147
- return e;
148
- }, ke = () => {
149
- let [e] = I(), t = q(), { t: n } = r(), i = t.bold;
150
- return /* @__PURE__ */ p(K, {
151
- icon: "bold",
152
- tooltip: n("editor.bold"),
153
- active: i,
154
- onClick: () => {
155
- e.dispatchCommand(F, "bold");
156
- }
157
- });
158
- }, Ae = () => {
159
- let [e] = I(), t = q(), { t: n } = r(), i = t.underline;
160
- return /* @__PURE__ */ p(K, {
161
- icon: "underline",
162
- tooltip: n("editor.underline"),
163
- active: i,
164
- onClick: () => {
165
- e.dispatchCommand(F, "underline");
166
- }
167
- });
168
- }, je = () => {
169
- let [e] = I(), t = q(), { t: n } = r(), i = t.italic;
170
- return /* @__PURE__ */ p(K, {
171
- icon: "italic",
172
- tooltip: n("editor.italic"),
173
- active: i,
174
- onClick: () => {
175
- e.dispatchCommand(F, "italic");
176
- }
177
- });
178
- }, J = g(null), Y = () => {
179
- let e = y(J);
180
- if (!e) throw Error("useEditorContainer must be used within EditorContainerProvider");
181
- return e;
182
- }, Me = () => {
183
- let [e] = I(), { t } = r(), n = q(), { getPopupContainer: i } = Y();
184
- return /* @__PURE__ */ p(o, {
185
- menus: C(() => s.map((e) => ({
186
- key: e.value,
187
- label: e.label
188
- })), []),
189
- onClick: v((t) => {
190
- let n = t.key;
191
- e.update(() => {
192
- let e = j();
193
- M(e) && L(e, { "font-size": n });
194
- });
195
- }, [e]),
196
- activeKey: [n.fontSize],
197
- showSearch: !1,
198
- getPopupContainer: i,
199
- style: {
200
- width: "60px",
201
- minWidth: "60px"
202
- },
203
- children: /* @__PURE__ */ p("div", {
204
- className: "dropdown__trigger inline-flex",
205
- children: /* @__PURE__ */ p(K, {
206
- icon: "fontsize",
207
- tooltip: t("editor.fontSize"),
208
- active: !1
209
- })
210
- })
211
- });
212
- }, Ne = () => {
213
- let [e] = I(), t = q(), { t: i } = r(), { getPopupContainer: a } = Y(), o = v((t) => {
214
- e.update(() => {
215
- let e = j();
216
- M(e) && L(e, { color: t });
217
- });
218
- }, [e]);
219
- return /* @__PURE__ */ p(n, {
220
- value: t.fontColor,
221
- onChange: o,
222
- placement: "bottom-start",
223
- presetColors: "basic",
224
- getPopupContainer: a,
225
- children: /* @__PURE__ */ p("div", {
226
- className: "trigger-picker inline-flex",
227
- children: /* @__PURE__ */ p(K, {
228
- icon: "fontcolor",
229
- tooltip: i("editor.fontColor"),
230
- onClick: () => {},
231
- active: !1
232
- })
233
- })
234
- });
235
- }, Pe = () => {
236
- let [e] = I(), t = q(), { t: i } = r(), { getPopupContainer: a } = Y(), o = v((t) => {
237
- e.update(() => {
238
- let e = j();
239
- M(e) && L(e, { "background-color": t });
240
- });
241
- }, [e]);
242
- return /* @__PURE__ */ p(n, {
243
- value: t.backgroundColor,
244
- onChange: o,
245
- placement: "bottom-start",
246
- presetColors: "basic",
247
- getPopupContainer: a,
248
- children: /* @__PURE__ */ p("div", {
249
- className: "trigger-picker inline-flex",
250
- children: /* @__PURE__ */ p(K, {
251
- icon: "fill",
252
- tooltip: i("editor.fill"),
253
- onClick: () => {},
254
- active: !1
255
- })
256
- })
257
- });
258
- }, Fe = () => {
259
- let [e] = I(), { align: t } = q(), { t: n } = r(), { getPopupContainer: i } = Y(), a = [
260
- {
261
- key: "left",
262
- label: n("leftAlign"),
263
- icon: /* @__PURE__ */ p(l, {})
264
- },
265
- {
266
- key: "center",
267
- label: n("editor.centerAlign"),
268
- icon: /* @__PURE__ */ p(c, {})
269
- },
270
- {
271
- key: "right",
272
- label: n("editor.rightAlign"),
273
- icon: /* @__PURE__ */ p(u, {})
274
- }
275
- ], s = v((t) => {
276
- e.dispatchCommand(le, t);
277
- }, [e]), d = a.map((e) => ({
278
- key: e.key,
279
- label: /* @__PURE__ */ m("div", {
280
- className: "flex items-center gap-2",
281
- children: [e.icon, /* @__PURE__ */ p("span", { children: e.label })]
282
- })
283
- })), f = v((e) => {
284
- s(e.key);
285
- }, [s]), h = a.find((e) => e.key === t)?.icon || /* @__PURE__ */ p(l, {});
286
- return /* @__PURE__ */ p(o, {
287
- menus: d,
288
- onClick: f,
289
- showSearch: !1,
290
- activeKey: [t],
291
- getPopupContainer: i,
292
- style: {
293
- width: "110px",
294
- minWidth: "110px"
295
- },
296
- children: /* @__PURE__ */ p("div", {
297
- className: "trigger-dropdown inline-flex text-sm",
298
- children: /* @__PURE__ */ p(K, {
299
- icon: h,
300
- tooltip: n("editor.alignment"),
301
- onClick: () => {},
302
- active: !1
303
- })
304
- })
305
- });
306
- };
307
- //#endregion
308
- //#region src/components/Editor/ToolbarPlugin/Buttons/LinkButton.tsx
309
- function Ie(e) {
310
- return e ? e.startsWith("@") ? "javascript:void(0);" : e.match(/^https?:\/\//) ? e : `http://${e}` : "";
311
- }
312
- var Le = () => {
313
- let [e] = I(), { link: n } = q(), { t: a } = r(), [o, s] = T(!1), [c, l] = T(""), [u, d] = T(""), [h, g] = T(!0), [_, y] = k.useMessage(), b = w(null), x = v((t) => {
314
- s(t), t || e.setEditable(!0);
315
- }, [e]), S = () => {
316
- if (!c) {
317
- _.warning(a("editor.linkAddressEmpty"));
318
- return;
319
- }
320
- let t = Ie(c);
321
- e.setEditable(!0), e.update(() => {
322
- let e = h ? {
323
- target: "_blank",
324
- rel: "noopener noreferrer",
325
- title: c
326
- } : { title: c }, n = b.current;
327
- n !== null && P(n);
328
- let r = j();
329
- if (M(r)) {
330
- let n = u || c, i = r.getTextContent();
331
- if (!r.isCollapsed() && n === i) ve(t, e);
332
- else {
333
- let i = r.anchor.getNode(), a = N(i) ? i : null, o = r.style || r.getNodes().find(N)?.getStyle() || a?.getStyle() || "", s = r.format || a?.getFormat() || 0, c = _e(t, e), l = A(n);
334
- l.setFormat(s), l.setStyle(o), c.append(l), r.insertNodes([c]);
335
- }
336
- } else {
337
- let n = _e(t, e);
338
- n.append(A(u || c));
339
- let r = ie(), i = r.getLastChild();
340
- if (ae(i) && i.isEmpty()) i.append(n);
341
- else {
342
- let e = re();
343
- e.append(n), r.append(e);
344
- }
345
- }
346
- }), b.current = null, l(""), d(""), x(!1);
347
- }, C = v(() => {
348
- let t = "";
349
- e.getEditorState().read(() => {
350
- let e = j();
351
- b.current = e ? e.clone() : null, M(e) && !e.isCollapsed() && (t = e.getTextContent());
352
- }), e.setEditable(!1), e.update(() => {
353
- P(null);
354
- }), window.getSelection()?.removeAllRanges(), e.getRootElement()?.blur(), n ? (l(n.link === "javascript:void(0);" ? "" : n.link ?? ""), d(n.linkText ?? "")) : (l(""), d(t)), s(!0);
355
- }, [n, e]);
356
- return /* @__PURE__ */ m(f, { children: [
357
- /* @__PURE__ */ p(K, {
358
- icon: "Insertlink",
359
- tooltip: a("link"),
360
- onClick: C,
361
- active: !!n?.link
362
- }),
363
- y,
364
- /* @__PURE__ */ p(t, {
365
- title: a("link"),
366
- open: o,
367
- onOpenChange: x,
368
- children: /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ m("div", {
369
- className: "px-[20px] pb-[60px] pt-[40px]",
370
- children: [/* @__PURE__ */ m("div", {
371
- className: "flex items-center relative",
372
- children: [
373
- /* @__PURE__ */ p("label", {
374
- className: "w-[80px] shrink-0",
375
- children: a("linkAddress")
376
- }),
377
- /* @__PURE__ */ p(O, {
378
- value: c,
379
- onChange: (e) => l(e.target.value),
380
- placeholder: a("editor.linkTip")
381
- }),
382
- /* @__PURE__ */ p("div", {
383
- className: "absolute bottom-[-30px] left-[80px]",
384
- children: /* @__PURE__ */ p("p", {
385
- className: "text-[#999]",
386
- children: a("editor.linkAliasTip")
387
- })
388
- })
389
- ]
390
- }), /* @__PURE__ */ m("div", {
391
- className: "flex items-center mt-[40px]",
392
- children: [/* @__PURE__ */ p("label", {
393
- className: "w-[80px] shrink-0",
394
- children: a("showContent")
395
- }), /* @__PURE__ */ p(O, {
396
- value: u,
397
- onChange: (e) => d(e.target.value)
398
- })]
399
- })]
400
- }), /* @__PURE__ */ m("div", {
401
- className: "py-[14px] px-[20px] flex justify-between items-center border-t-[1px] border-solid border-[#e0e0e0]",
402
- children: [/* @__PURE__ */ p("div", { children: /* @__PURE__ */ p(i, {
403
- checked: h,
404
- onChange: (e) => g(e),
405
- children: a("openInNewTab")
406
- }) }), /* @__PURE__ */ m("div", {
407
- className: "flex gap-[15px]",
408
- children: [/* @__PURE__ */ p(E, {
409
- onClick: () => x(!1),
410
- children: a("cancel")
411
- }), /* @__PURE__ */ p(E, {
412
- type: "primary",
413
- onClick: S,
414
- children: a("confirm")
415
- })]
416
- })]
417
- })] })
418
- })
419
- ] });
420
- }, Re = () => {
421
- let [e] = I(), { link: t } = q(), { t: n } = r();
422
- return /* @__PURE__ */ p(K, {
423
- icon: "cancellink",
424
- tooltip: n("cancelLink"),
425
- onClick: () => {
426
- t && e.dispatchCommand(ye, null);
427
- }
428
- });
429
- }, X = {
430
- "picture-modal__container": "_picture-modal__container_oo6vo_1",
431
- "picture-modal__sidebar": "_picture-modal__sidebar_oo6vo_4",
432
- "picture-modal__menu-list": "_picture-modal__menu-list_oo6vo_8",
433
- "picture-modal__menu-item": "_picture-modal__menu-item_oo6vo_13",
434
- "picture-modal__menu-item--active": "_picture-modal__menu-item--active_oo6vo_22",
435
- "picture-modal__content": "_picture-modal__content_oo6vo_25",
436
- "picture-modal__content-body": "_picture-modal__content-body_oo6vo_31",
437
- "picture-modal__ops": "_picture-modal__ops_oo6vo_34",
438
- "picture-modal__content-title": "_picture-modal__content-title_oo6vo_42",
439
- "picture-modal__upload-area": "_picture-modal__upload-area_oo6vo_53",
440
- "picture-modal__upload-area--dragging": "_picture-modal__upload-area--dragging_oo6vo_69",
441
- "picture-modal__preview-list": "_picture-modal__preview-list_oo6vo_75",
442
- "picture-modal__preview": "_picture-modal__preview_oo6vo_75",
443
- "picture-modal__preview-image": "_picture-modal__preview-image_oo6vo_89",
444
- "picture-modal__preview-info": "_picture-modal__preview-info_oo6vo_102",
445
- "picture-modal__preview-filename": "_picture-modal__preview-filename_oo6vo_106",
446
- "picture-modal__preview-size": "_picture-modal__preview-size_oo6vo_114",
447
- "picture-modal__preview-delete": "_picture-modal__preview-delete_oo6vo_118",
448
- "picture-modal__upload-text": "_picture-modal__upload-text_oo6vo_126",
449
- "picture-modal__footer": "_picture-modal__footer_oo6vo_130"
450
- }, ze = _((e, t) => {
451
- let [n] = D.useForm(), [i, a] = T(""), { t: o } = r(), s = (e) => /^https?:\/\/.+/i.test(e);
452
- return x(t, () => ({ getValue: async () => {
453
- try {
454
- return await n.validateFields(), i;
455
- } catch {
456
- throw Error("URL validation failed");
457
- }
458
- } })), /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", {
459
- className: X["picture-modal__content-title"],
460
- "data-title": o("editor.imageUrlNote"),
461
- children: o("editor.enterImageUrl")
462
- }), /* @__PURE__ */ p(D, {
463
- form: n,
464
- children: /* @__PURE__ */ p(D.Item, {
465
- name: "url",
466
- rules: [{
467
- required: !0,
468
- message: o("editor.pleaseEnterImageUrl")
469
- }, { validator: (e, t) => !t || s(t) ? Promise.resolve() : Promise.reject(Error(o("editor.pleaseEnterValidImageUrl"))) }],
470
- children: /* @__PURE__ */ p(O, {
471
- placeholder: o("editor.pleaseEnterImageUrl"),
472
- value: i,
473
- onChange: (e) => a(e.target.value)
474
- })
475
- })
476
- })] });
477
- });
478
- ze.displayName = "LinkInput";
479
- //#endregion
480
- //#region src/components/Editor/utils/formatTruncatedFilename.ts
481
- var Be = "......", Ve = (e, t, n) => {
482
- if (t <= 0 || n(e) <= t) return {
483
- display: e,
484
- truncated: !1
485
- };
486
- let r = e.lastIndexOf("."), i = r > 0 && r < e.length - 1, a = i ? e.slice(0, r) : e, o = i ? e.slice(r) : "", s = a.slice(-2), c = a.slice(0, -2), l = (e) => `${e}${Be}${s}${o}`, u = (e) => n(e) <= t;
487
- if (!u(l(""))) {
488
- let t = `${Be}${o}`;
489
- return {
490
- display: u(t) ? t : e,
491
- truncated: !0
492
- };
493
- }
494
- let d = 0, f = c.length, p = 0;
495
- for (; d <= f;) {
496
- let e = d + f >> 1;
497
- u(l(c.slice(0, e))) ? (p = e, d = e + 1) : f = e - 1;
498
- }
499
- return {
500
- display: l(c.slice(0, p)),
501
- truncated: !0
502
- };
503
- }, He = {
504
- duration: .2,
505
- ease: [
506
- .4,
507
- 0,
508
- .2,
509
- 1
510
- ]
511
- }, Ue = ({ name: e }) => {
512
- let t = w(null), [n, r] = T(e), [i, a] = T(!1);
513
- return S(() => {
514
- let n = t.current, i = document.createElement("canvas").getContext("2d");
515
- if (!n || !i) return;
516
- let o = () => {
517
- i.font = getComputedStyle(n).font;
518
- let t = Ve(e, n.clientWidth, (e) => i.measureText(e).width);
519
- r(t.display), a(t.truncated);
520
- };
521
- o();
522
- let s = new ResizeObserver(o);
523
- return s.observe(n), () => s.disconnect();
524
- }, [e]), /* @__PURE__ */ p("div", {
525
- ref: t,
526
- className: X["picture-modal__preview-filename"],
527
- title: i ? e : void 0,
528
- children: n
529
- });
530
- }, We = (e) => new Promise((t, n) => {
531
- let r = new FileReader();
532
- r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsDataURL(e);
533
- }), Ge = _((t, n) => {
534
- let [i, a] = T(!1), [o, s] = T([]), c = w(o);
535
- c.current = o;
536
- let l = w(null), [u, d] = k.useMessage(), { t: f } = r(), h = (e) => (e / 1024).toFixed(1) + "kb", g = (e) => e.type.startsWith("image/") ? e.size > 5242880 ? (u.warning(f("editor.imageSizeNote")), !1) : !0 : (u.warning(f("editor.onlyImageFormatsSupported")), !1), _ = (e) => {
537
- let t = 10 - c.current.length;
538
- if (t <= 0) {
539
- u.warning(f("editor.imageCountNote", { count: 10 }));
540
- return;
541
- }
542
- let n = Array.from(e).filter(g), r = n.slice(0, t);
543
- n.length > t && u.warning(f("editor.imageCountNote", { count: 10 })), r.length && s((e) => [...e, ...r.map((e) => ({
544
- id: `${e.name}-${e.size}-${e.lastModified}-${Math.random()}`,
545
- file: e,
546
- url: URL.createObjectURL(e)
547
- }))]);
548
- }, v = (e) => {
549
- s((t) => {
550
- let n = t.find((t) => t.id === e);
551
- return n && URL.revokeObjectURL(n.url), t.filter((t) => t.id !== e);
552
- });
553
- }, y = () => {
554
- l.current?.click();
555
- }, S = (e) => {
556
- e.target.files?.length && _(e.target.files), e.target.value = "";
557
- };
558
- return b(() => () => {
559
- c.current.forEach((e) => URL.revokeObjectURL(e.url));
560
- }, []), x(n, () => ({ getValue: async () => {
561
- if (!o.length) throw u.warning(f("editor.pleaseUploadImageFirst")), Error(f("editor.pleaseUploadImageFirst"));
562
- try {
563
- return await Promise.all(o.map(async (e) => ({
564
- src: await We(e.file),
565
- fileName: e.file.name
566
- })));
567
- } catch {
568
- throw Error(f("editor.operationFailed"));
569
- }
570
- } }), [
571
- o,
572
- u,
573
- f
574
- ]), /* @__PURE__ */ m("div", {
575
- onDragOver: (e) => {
576
- e.preventDefault(), a(!0);
577
- },
578
- onDragLeave: (e) => {
579
- e.preventDefault(), a(!1);
580
- },
581
- onDrop: (e) => {
582
- e.preventDefault(), a(!1), e.dataTransfer.files.length && _(e.dataTransfer.files);
583
- },
584
- children: [
585
- /* @__PURE__ */ m("div", {
586
- className: X["picture-modal__ops"],
587
- children: [/* @__PURE__ */ p("div", {
588
- className: X["picture-modal__content-title"],
589
- "data-title": f("editor.imageSizeNote"),
590
- children: f("editor.uploadImage")
591
- }), /* @__PURE__ */ m("div", {
592
- className: `${X["picture-modal__upload-area"]} ${i ? X["picture-modal__upload-area--dragging"] : ""}`,
593
- onClick: y,
594
- children: [/* @__PURE__ */ p(e, { name: "upload" }), /* @__PURE__ */ p("span", {
595
- className: X["picture-modal__upload-text"],
596
- children: f("editor.clickOrDragToUpload")
597
- })]
598
- })]
599
- }),
600
- o.length > 0 ? /* @__PURE__ */ p("div", {
601
- className: X["picture-modal__preview-list"],
602
- children: /* @__PURE__ */ p(te, {
603
- mode: "popLayout",
604
- children: o.map((t) => /* @__PURE__ */ m(ne.div, {
605
- layout: "position",
606
- className: X["picture-modal__preview"],
607
- initial: {
608
- opacity: 0,
609
- y: 12
610
- },
611
- animate: {
612
- opacity: 1,
613
- y: 0
614
- },
615
- exit: {
616
- opacity: 0,
617
- y: -8
618
- },
619
- transition: He,
620
- children: [
621
- /* @__PURE__ */ p("div", {
622
- className: X["picture-modal__preview-image"],
623
- children: /* @__PURE__ */ p("img", {
624
- src: t.url,
625
- alt: f("editor.previewImage")
626
- })
627
- }),
628
- /* @__PURE__ */ m("div", {
629
- className: X["picture-modal__preview-info"],
630
- children: [/* @__PURE__ */ p(Ue, { name: t.file.name }), /* @__PURE__ */ p("div", {
631
- className: X["picture-modal__preview-size"],
632
- children: h(t.file.size)
633
- })]
634
- }),
635
- /* @__PURE__ */ p("div", {
636
- className: X["picture-modal__preview-delete"],
637
- role: "button",
638
- onClick: () => v(t.id),
639
- children: /* @__PURE__ */ p(e, { name: "delete" })
640
- })
641
- ]
642
- }, t.id))
643
- })
644
- }) : null,
645
- /* @__PURE__ */ p("input", {
646
- ref: l,
647
- type: "file",
648
- accept: "image/*",
649
- multiple: !0,
650
- style: { display: "none" },
651
- onChange: S
652
- }),
653
- d
654
- ]
655
- });
656
- });
657
- Ge.displayName = "UploadImage";
658
- //#endregion
659
- //#region src/components/Editor/commands/ImageCommands.ts
660
- var Z = me("INSERT_INLINE_IMAGE_COMMAND"), Ke = () => {
661
- let { t: n } = r(), [i] = I(), [o, s] = T(!1), c = w(null), l = w(null), u = [{
662
- key: "upload",
663
- title: n("editor.uploadImage"),
664
- icon: /* @__PURE__ */ p(e, { name: "picture" })
665
- }, {
666
- key: "url",
667
- title: n("editor.imageUrl"),
668
- icon: /* @__PURE__ */ p(e, { name: "Insertlink" })
669
- }], [d, h] = T(u[0].key), g = async () => {
670
- try {
671
- if (d === "upload" && l.current) (await l.current.getValue()).forEach((e) => {
672
- i.dispatchCommand(Z, {
673
- src: e.src,
674
- altText: e.fileName
675
- });
676
- });
677
- else if (c.current) {
678
- let e = await c.current.getValue();
679
- i.dispatchCommand(Z, {
680
- src: e,
681
- altText: e
682
- });
683
- }
684
- s(!1);
685
- } catch (e) {
686
- k.error(e instanceof Error ? e.message : n("editor.operationFailed"));
687
- }
688
- }, _ = {
689
- upload: /* @__PURE__ */ p(Ge, { ref: l }),
690
- url: /* @__PURE__ */ p(ze, { ref: c })
691
- };
692
- return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(K, {
693
- icon: "picture",
694
- tooltip: n("picture"),
695
- onClick: () => s(!0)
696
- }), /* @__PURE__ */ m(t, {
697
- title: n("addPicture"),
698
- open: o,
699
- onOpenChange: s,
700
- width: "620px",
701
- children: [/* @__PURE__ */ m("div", {
702
- className: X["picture-modal__container"],
703
- children: [/* @__PURE__ */ p("div", {
704
- className: X["picture-modal__sidebar"],
705
- children: /* @__PURE__ */ p("ul", {
706
- className: X["picture-modal__menu-list"],
707
- children: u.map((e) => /* @__PURE__ */ m("li", {
708
- className: `${X["picture-modal__menu-item"]} ${d === e.key ? X["picture-modal__menu-item--active"] : ""}`,
709
- onClick: () => h(e.key),
710
- children: [/* @__PURE__ */ p("span", {
711
- className: X["picture-modal__menu-icon"],
712
- children: e.icon
713
- }), /* @__PURE__ */ p("span", { children: e.title })]
714
- }, e.title))
715
- })
716
- }), /* @__PURE__ */ p(a, {
717
- className: X["picture-modal__content"],
718
- contentClassName: X["picture-modal__content-body"],
719
- children: _[d]
720
- })]
721
- }), /* @__PURE__ */ m("div", {
722
- className: X["picture-modal__footer"],
723
- children: [/* @__PURE__ */ p(E, {
724
- onClick: () => s(!1),
725
- children: n("cancel")
726
- }), /* @__PURE__ */ p(E, {
727
- type: "primary",
728
- onClick: g,
729
- children: n("confirm")
730
- })]
731
- })]
732
- })] });
733
- }, Q = {
734
- xmlns: "http://www.w3.org/2000/svg",
735
- width: "1em",
736
- height: "1em",
737
- viewBox: "0 0 24 24",
738
- fill: "none",
739
- stroke: "currentColor",
740
- strokeWidth: 2,
741
- strokeLinecap: "round",
742
- strokeLinejoin: "round"
743
- }, qe = () => /* @__PURE__ */ m("svg", {
744
- ...Q,
745
- children: [
746
- /* @__PURE__ */ p("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
747
- /* @__PURE__ */ p("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
748
- /* @__PURE__ */ p("line", {
749
- x1: "4",
750
- x2: "20",
751
- y1: "12",
752
- y2: "12"
753
- })
754
- ]
755
- }), Je = () => /* @__PURE__ */ m("svg", {
756
- ...Q,
757
- children: [/* @__PURE__ */ p("path", { d: "M9 14 4 9l5-5" }), /* @__PURE__ */ p("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" })]
758
- }), Ye = () => /* @__PURE__ */ m("svg", {
759
- ...Q,
760
- children: [/* @__PURE__ */ p("path", { d: "m15 14 5-5-5-5" }), /* @__PURE__ */ p("path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" })]
761
- }), Xe = () => /* @__PURE__ */ m("svg", {
762
- ...Q,
763
- children: [
764
- /* @__PURE__ */ p("path", { d: "m4 19 8-8" }),
765
- /* @__PURE__ */ p("path", { d: "m12 19-8-8" }),
766
- /* @__PURE__ */ p("path", { d: "M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" })
767
- ]
768
- }), Ze = () => /* @__PURE__ */ m("svg", {
769
- ...Q,
770
- children: [
771
- /* @__PURE__ */ p("path", { d: "m4 5 8 8" }),
772
- /* @__PURE__ */ p("path", { d: "m12 5-8 8" }),
773
- /* @__PURE__ */ p("path", { d: "M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07" })
774
- ]
775
- }), Qe = () => /* @__PURE__ */ m("svg", {
776
- ...Q,
777
- children: [
778
- /* @__PURE__ */ p("path", { d: "M21 5H11" }),
779
- /* @__PURE__ */ p("path", { d: "M21 12H11" }),
780
- /* @__PURE__ */ p("path", { d: "M21 19H11" }),
781
- /* @__PURE__ */ p("path", { d: "m3 8 4 4-4 4" })
782
- ]
783
- }), $e = () => /* @__PURE__ */ m("svg", {
784
- ...Q,
785
- children: [
786
- /* @__PURE__ */ p("path", { d: "M21 5H11" }),
787
- /* @__PURE__ */ p("path", { d: "M21 12H11" }),
788
- /* @__PURE__ */ p("path", { d: "M21 19H11" }),
789
- /* @__PURE__ */ p("path", { d: "m7 8-4 4 4 4" })
790
- ]
791
- }), et = () => /* @__PURE__ */ m("svg", {
792
- ...Q,
793
- children: [
794
- /* @__PURE__ */ p("path", { d: "M11 5h10" }),
795
- /* @__PURE__ */ p("path", { d: "M11 12h10" }),
796
- /* @__PURE__ */ p("path", { d: "M11 19h10" }),
797
- /* @__PURE__ */ p("path", { d: "M4 4h1v5" }),
798
- /* @__PURE__ */ p("path", { d: "M4 9h2" }),
799
- /* @__PURE__ */ p("path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" })
800
- ]
801
- }), tt = () => /* @__PURE__ */ m("svg", {
802
- ...Q,
803
- children: [
804
- /* @__PURE__ */ p("path", { d: "M3 5h.01" }),
805
- /* @__PURE__ */ p("path", { d: "M3 12h.01" }),
806
- /* @__PURE__ */ p("path", { d: "M3 19h.01" }),
807
- /* @__PURE__ */ p("path", { d: "M8 5h13" }),
808
- /* @__PURE__ */ p("path", { d: "M8 12h13" }),
809
- /* @__PURE__ */ p("path", { d: "M8 19h13" })
810
- ]
811
- }), nt = () => /* @__PURE__ */ m("svg", {
812
- ...Q,
813
- className: "lucide lucide-code-xml-icon lucide-code-xml",
814
- children: [
815
- /* @__PURE__ */ p("path", { d: "m18 16 4-4-4-4" }),
816
- /* @__PURE__ */ p("path", { d: "m6 8-4 4 4 4" }),
817
- /* @__PURE__ */ p("path", { d: "m14.5 4-5 16" })
818
- ]
819
- }), rt = () => {
820
- let [e] = I(), { canUndo: t } = H(), { t: n } = r();
821
- return /* @__PURE__ */ p(K, {
822
- icon: /* @__PURE__ */ p(Je, {}),
823
- tooltip: n("editor.undo"),
824
- disabled: !t,
825
- onClick: () => e.dispatchCommand(pe, void 0)
826
- });
827
- }, it = () => {
828
- let [e] = I(), { canRedo: t } = H(), { t: n } = r();
829
- return /* @__PURE__ */ p(K, {
830
- icon: /* @__PURE__ */ p(Ye, {}),
831
- tooltip: n("editor.redo"),
832
- disabled: !t,
833
- onClick: () => e.dispatchCommand(fe, void 0)
834
- });
835
- }, at = () => {
836
- let [e] = I(), { strikethrough: t } = q(), { t: n } = r();
837
- return /* @__PURE__ */ p(K, {
838
- icon: /* @__PURE__ */ p(qe, {}),
839
- tooltip: n("editor.strikethrough"),
840
- active: t,
841
- onClick: () => e.dispatchCommand(F, "strikethrough")
842
- });
843
- }, ot = () => {
844
- let [e] = I(), { superscript: t } = q(), { t: n } = r();
845
- return /* @__PURE__ */ p(K, {
846
- icon: /* @__PURE__ */ p(Xe, {}),
847
- tooltip: n("editor.superscript"),
848
- active: t,
849
- onClick: () => e.dispatchCommand(F, "superscript")
850
- });
851
- }, st = () => {
852
- let [e] = I(), { subscript: t } = q(), { t: n } = r();
853
- return /* @__PURE__ */ p(K, {
854
- icon: /* @__PURE__ */ p(Ze, {}),
855
- tooltip: n("editor.subscript"),
856
- active: t,
857
- onClick: () => e.dispatchCommand(F, "subscript")
858
- });
859
- }, ct = () => {
860
- let [e] = I(), { t } = r();
861
- return /* @__PURE__ */ p(K, {
862
- icon: /* @__PURE__ */ p(Qe, {}),
863
- tooltip: t("editor.indent"),
864
- onClick: () => e.dispatchCommand(ue, void 0)
865
- });
866
- }, lt = () => {
867
- let [e] = I(), { canOutdent: t } = q(), { t: n } = r();
868
- return /* @__PURE__ */ p(K, {
869
- icon: /* @__PURE__ */ p($e, {}),
870
- tooltip: n("editor.outdent"),
871
- disabled: !t,
872
- onClick: () => e.dispatchCommand(de, void 0)
873
- });
874
- }, ut = () => {
875
- let [e] = I(), { listType: t } = q(), { t: n } = r(), i = t === "bullet";
876
- return /* @__PURE__ */ p(K, {
877
- icon: /* @__PURE__ */ p(tt, {}),
878
- tooltip: n("editor.bulletList"),
879
- active: i,
880
- onClick: () => {
881
- e.dispatchCommand(i ? Se : xe, void 0);
882
- }
883
- });
884
- }, dt = () => {
885
- let [e] = I(), { listType: t } = q(), { t: n } = r(), i = t === "number";
886
- return /* @__PURE__ */ p(K, {
887
- icon: /* @__PURE__ */ p(et, {}),
888
- tooltip: n("editor.numberList"),
889
- active: i,
890
- onClick: () => {
891
- e.dispatchCommand(i ? Se : be, void 0);
892
- }
893
- });
894
- }, ft = () => {
895
- let [e] = I(), { isCodeBlock: t } = q(), { t: n } = r();
896
- return /* @__PURE__ */ p(K, {
897
- icon: /* @__PURE__ */ p(nt, {}),
898
- tooltip: n("editor.codeBlock"),
899
- active: t,
900
- onClick: () => {
901
- e.update(() => {
902
- ge(j(), () => t ? re() : Ce(R));
903
- });
904
- }
905
- });
906
- }, $ = /* @__PURE__ */ new Map(), pt = (e, t) => {
907
- if (!e) throw Error("registerToolbarButton: name is required");
908
- $.set(e, t);
909
- }, mt = (e) => {
910
- $.delete(e);
911
- }, ht = (e) => $.get(e), gt = () => Array.from($.keys()), _t = {
912
- undo: rt,
913
- redo: it,
914
- bold: ke,
915
- underline: Ae,
916
- italic: je,
917
- strikethrough: at,
918
- superscript: ot,
919
- subscript: st,
920
- fontSize: Me,
921
- fontColor: Ne,
922
- fill: Pe,
923
- bullet: ut,
924
- number: dt,
925
- outdent: lt,
926
- indent: ct,
927
- align: Fe,
928
- link: Le,
929
- unLink: Re,
930
- picture: Ke,
931
- code: ft
932
- };
933
- Object.entries(_t).forEach(([e, t]) => {
934
- pt(e, t);
935
- });
936
- //#endregion
937
- export { R as _, mt as a, Y as c, Oe as d, W as f, B as g, z as h, pt as i, q as l, Te as m, ht as n, Z as o, De as p, gt as r, J as s, _t as t, K as u, Ee as v, we as y };