@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
@@ -0,0 +1,1148 @@
1
+ import { t as e } from "../Icon/Icon-BBDcb-yw.js";
2
+ import { a as t, i as n } from "../Overlay/OverlayContext-CVSFoyqN.js";
3
+ import { t as r } from "../Modal/Modal-Cb7Msq26.js";
4
+ import { t as i } from "../ColorPicker/ColorPicker-DVwg07Gs.js";
5
+ import { t as a } from "../vendors/useLocale-FGYsRWSe.js";
6
+ import { n as o } from "../vendors/animations-rwUbyoT0.js";
7
+ import { t as s } from "../CheckBox/CheckBox-nBm0u6zX.js";
8
+ import { t as c } from "../ScrollBar/ScrollBar-N2pOLv-8.js";
9
+ import { t as l } from "../vendors/useFloatingPortal-CmVJbuRm.js";
10
+ import { t as u } from "../DropDown/DropDown-DWf5yf4l.js";
11
+ import { FONT_SIZES as d } from "./constants/index.js";
12
+ import { AlignCenterOutlined as f, AlignLeftOutlined as p, AlignRightOutlined as m } from "@ant-design/icons";
13
+ import { keyBy as h, range as g } from "lodash-es";
14
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
15
+ import b, { createContext as x, forwardRef as S, useCallback as C, useContext as w, useEffect as T, useImperativeHandle as ee, useLayoutEffect as te, useMemo as ne, useRef as E, useState as D } from "react";
16
+ import { Button as O, Form as k, Input as A, message as j } from "antd";
17
+ import re from "clsx";
18
+ import { AnimatePresence as M, motion as ie } from "motion/react";
19
+ import { FloatingPortal as ae } from "@floating-ui/react";
20
+ import { $createParagraphNode as N, $createTextNode as oe, $getRoot as se, $getSelection as P, $isElementNode as ce, $isRangeSelection as F, $isTextNode as le, $setSelection as ue, CAN_REDO_COMMAND as de, CAN_UNDO_COMMAND as fe, COMMAND_PRIORITY_CRITICAL as pe, FORMAT_ELEMENT_COMMAND as me, FORMAT_TEXT_COMMAND as I, INDENT_CONTENT_COMMAND as he, OUTDENT_CONTENT_COMMAND as ge, REDO_COMMAND as _e, UNDO_COMMAND as ve, createCommand as ye, mergeRegister as be } from "lexical";
21
+ import { useLexicalComposerContext as L } from "@lexical/react/LexicalComposerContext";
22
+ import { $patchStyleText as R, $setBlocksType as xe } from "@lexical/selection";
23
+ import { $createLinkNode as Se, $toggleLink as Ce, TOGGLE_LINK_COMMAND as we } from "@lexical/link";
24
+ import { INSERT_ORDERED_LIST_COMMAND as Te, INSERT_UNORDERED_LIST_COMMAND as Ee, REMOVE_LIST_COMMAND as De } from "@lexical/list";
25
+ import { $createCodeNode as Oe } from "@lexical/code-core";
26
+ import { INSERT_TABLE_COMMAND as ke } from "@lexical/table";
27
+ import { $createHeadingNode as Ae } from "@lexical/rich-text";
28
+ //#region src/components/Editor/ToolbarPlugin/toolbarPlugin.module.scss
29
+ var z = {
30
+ "bsy-lexical__toolbar": "_bsy-lexical__toolbar_4va97_1",
31
+ "bsy-lexical__toolbar--floating": "_bsy-lexical__toolbar--floating_4va97_12",
32
+ "bsy-lexical__toolbar-item": "_bsy-lexical__toolbar-item_4va97_18",
33
+ "bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_4va97_24",
34
+ "bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_4va97_30",
35
+ "bsy-lexical__toolbar-select": "_bsy-lexical__toolbar-select_4va97_37",
36
+ "bsy-lexical__toolbar-select-label": "_bsy-lexical__toolbar-select-label_4va97_55",
37
+ "bsy-lexical__toolbar-select-arrow": "_bsy-lexical__toolbar-select-arrow_4va97_66"
38
+ }, B = x(null), V = "plaintext", je = "github-light", H = [
39
+ {
40
+ id: "plaintext",
41
+ label: "Plain text"
42
+ },
43
+ {
44
+ id: "css",
45
+ label: "CSS"
46
+ },
47
+ {
48
+ id: "html",
49
+ label: "HTML"
50
+ },
51
+ {
52
+ id: "xml",
53
+ label: "XML"
54
+ },
55
+ {
56
+ id: "javascript",
57
+ label: "JavaScript"
58
+ },
59
+ {
60
+ id: "typescript",
61
+ label: "TypeScript"
62
+ },
63
+ {
64
+ id: "jsx",
65
+ label: "JSX"
66
+ },
67
+ {
68
+ id: "go",
69
+ label: "Go"
70
+ },
71
+ {
72
+ id: "php",
73
+ label: "PHP"
74
+ },
75
+ {
76
+ id: "c",
77
+ label: "C"
78
+ },
79
+ {
80
+ id: "python",
81
+ label: "Python"
82
+ },
83
+ {
84
+ id: "java",
85
+ label: "Java"
86
+ },
87
+ {
88
+ id: "cpp",
89
+ label: "C++"
90
+ },
91
+ {
92
+ id: "csharp",
93
+ label: "C#"
94
+ },
95
+ {
96
+ id: "vb",
97
+ label: "Visual Basic"
98
+ },
99
+ {
100
+ id: "sql",
101
+ label: "SQL"
102
+ },
103
+ {
104
+ id: "ruby",
105
+ label: "Ruby"
106
+ },
107
+ {
108
+ id: "swift",
109
+ label: "Swift"
110
+ },
111
+ {
112
+ id: "bash",
113
+ label: "Bash"
114
+ },
115
+ {
116
+ id: "lua",
117
+ label: "Lua"
118
+ },
119
+ {
120
+ id: "markdown",
121
+ label: "Markdown"
122
+ }
123
+ ], U = h(H, "id"), Me = (e) => e && U[e] ? e : V, W = x(null), Ne = () => {
124
+ let e = w(W);
125
+ if (!e) throw Error("useHistoryStateContext must be used within HistoryStateProvider");
126
+ return e;
127
+ }, Pe = ({ children: e }) => {
128
+ let [t] = L(), [n, r] = D({
129
+ canUndo: !1,
130
+ canRedo: !1
131
+ });
132
+ return T(() => be(t.registerCommand(fe, (e) => (r((t) => t.canUndo === e ? t : {
133
+ ...t,
134
+ canUndo: e
135
+ }), !1), pe), t.registerCommand(de, (e) => (r((t) => t.canRedo === e ? t : {
136
+ ...t,
137
+ canRedo: e
138
+ }), !1), pe)), [t]), /* @__PURE__ */ v(W.Provider, {
139
+ value: n,
140
+ children: e
141
+ });
142
+ }, Fe = x({ iconSize: 14 }), Ie = Fe.Provider, G = () => w(Fe), Le = {
143
+ "lexical-editor__toolbar-button": "_lexical-editor__toolbar-button_10xg7_1",
144
+ "lexical-editor__toolbar-button-active": "_lexical-editor__toolbar-button-active_10xg7_20"
145
+ }, K = (t) => {
146
+ let { icon: n, tooltip: r, onClick: i, disabled: a = !1, active: o = !1, size: s } = t, { iconSize: c } = G(), l = s ?? c;
147
+ return /* @__PURE__ */ v("button", {
148
+ className: re(Le["lexical-editor__toolbar-button"], { [Le["lexical-editor__toolbar-button-active"]]: o }),
149
+ type: "button",
150
+ onClick: i,
151
+ onMouseDown: (e) => e.preventDefault(),
152
+ disabled: a,
153
+ title: r,
154
+ children: b.isValidElement(n) ? n : /* @__PURE__ */ v(e, {
155
+ name: n,
156
+ size: l
157
+ })
158
+ });
159
+ }, q = () => {
160
+ let e = w(B);
161
+ if (!e) throw Error("useTextFormatsContext must be used within TextFormatsProvider");
162
+ return e;
163
+ }, Re = () => {
164
+ let [e] = L(), t = q(), { t: n } = a(), r = t.bold;
165
+ return /* @__PURE__ */ v(K, {
166
+ icon: "bold",
167
+ tooltip: n("editor.bold"),
168
+ active: r,
169
+ onClick: () => {
170
+ e.dispatchCommand(I, "bold");
171
+ }
172
+ });
173
+ }, ze = () => {
174
+ let [e] = L(), t = q(), { t: n } = a(), r = t.underline;
175
+ return /* @__PURE__ */ v(K, {
176
+ icon: "underline",
177
+ tooltip: n("editor.underline"),
178
+ active: r,
179
+ onClick: () => {
180
+ e.dispatchCommand(I, "underline");
181
+ }
182
+ });
183
+ }, Be = () => {
184
+ let [e] = L(), t = q(), { t: n } = a(), r = t.italic;
185
+ return /* @__PURE__ */ v(K, {
186
+ icon: "italic",
187
+ tooltip: n("editor.italic"),
188
+ active: r,
189
+ onClick: () => {
190
+ e.dispatchCommand(I, "italic");
191
+ }
192
+ });
193
+ }, Ve = () => {
194
+ let [e] = L(), { t } = a(), { fontSize: n, headingTag: r } = q(), i = ne(() => d.map((e) => ({
195
+ key: e.value,
196
+ label: e.label
197
+ })), []), o = C((t) => {
198
+ let n = t.key;
199
+ e.update(() => {
200
+ let e = P();
201
+ F(e) && R(e, { "font-size": n });
202
+ });
203
+ }, [e]);
204
+ return r ? /* @__PURE__ */ v(K, {
205
+ icon: "fontsize",
206
+ tooltip: t("editor.fontSize"),
207
+ disabled: !0
208
+ }) : /* @__PURE__ */ v(u, {
209
+ menus: i,
210
+ onClick: o,
211
+ activeKey: [n],
212
+ showSearch: !1,
213
+ style: {
214
+ width: "60px",
215
+ minWidth: "60px"
216
+ },
217
+ children: /* @__PURE__ */ v("div", {
218
+ className: "dropdown__trigger inline-flex",
219
+ children: /* @__PURE__ */ v(K, {
220
+ icon: "fontsize",
221
+ tooltip: t("editor.fontSize"),
222
+ active: !1
223
+ })
224
+ })
225
+ });
226
+ }, He = () => {
227
+ let [e] = L(), t = q(), { t: n } = a(), r = C((t) => {
228
+ e.update(() => {
229
+ let e = P();
230
+ F(e) && R(e, { color: t });
231
+ });
232
+ }, [e]);
233
+ return /* @__PURE__ */ v(i, {
234
+ value: t.fontColor,
235
+ onChange: r,
236
+ placement: "bottom-start",
237
+ presetColors: "basic",
238
+ children: /* @__PURE__ */ v("div", {
239
+ className: "trigger-picker inline-flex",
240
+ children: /* @__PURE__ */ v(K, {
241
+ icon: "fontcolor",
242
+ tooltip: n("editor.fontColor"),
243
+ onClick: () => {},
244
+ active: !1
245
+ })
246
+ })
247
+ });
248
+ }, Ue = () => {
249
+ let [e] = L(), t = q(), { t: n } = a(), r = C((t) => {
250
+ e.update(() => {
251
+ let e = P();
252
+ F(e) && R(e, { "background-color": t });
253
+ });
254
+ }, [e]);
255
+ return /* @__PURE__ */ v(i, {
256
+ value: t.backgroundColor,
257
+ onChange: r,
258
+ placement: "bottom-start",
259
+ presetColors: "basic",
260
+ children: /* @__PURE__ */ v("div", {
261
+ className: "trigger-picker inline-flex",
262
+ children: /* @__PURE__ */ v(K, {
263
+ icon: "fill",
264
+ tooltip: n("editor.fill"),
265
+ onClick: () => {},
266
+ active: !1
267
+ })
268
+ })
269
+ });
270
+ }, We = () => {
271
+ let [e] = L(), { align: t } = q(), { t: n } = a(), r = [
272
+ {
273
+ key: "left",
274
+ label: n("leftAlign"),
275
+ icon: /* @__PURE__ */ v(p, {})
276
+ },
277
+ {
278
+ key: "center",
279
+ label: n("editor.centerAlign"),
280
+ icon: /* @__PURE__ */ v(f, {})
281
+ },
282
+ {
283
+ key: "right",
284
+ label: n("editor.rightAlign"),
285
+ icon: /* @__PURE__ */ v(m, {})
286
+ }
287
+ ], i = C((t) => {
288
+ e.dispatchCommand(me, t);
289
+ }, [e]), o = r.map((e) => ({
290
+ key: e.key,
291
+ label: /* @__PURE__ */ y("div", {
292
+ className: "flex items-center gap-2",
293
+ children: [e.icon, /* @__PURE__ */ v("span", { children: e.label })]
294
+ })
295
+ })), s = C((e) => {
296
+ i(e.key);
297
+ }, [i]), c = r.find((e) => e.key === t)?.icon || /* @__PURE__ */ v(p, {});
298
+ return /* @__PURE__ */ v(u, {
299
+ menus: o,
300
+ onClick: s,
301
+ showSearch: !1,
302
+ activeKey: [t],
303
+ style: {
304
+ width: "110px",
305
+ minWidth: "110px"
306
+ },
307
+ children: /* @__PURE__ */ v("div", {
308
+ className: "trigger-dropdown inline-flex text-sm",
309
+ children: /* @__PURE__ */ v(K, {
310
+ icon: c,
311
+ tooltip: n("editor.alignment"),
312
+ onClick: () => {},
313
+ active: !1
314
+ })
315
+ })
316
+ });
317
+ };
318
+ //#endregion
319
+ //#region src/components/Editor/ToolbarPlugin/Buttons/LinkButton.tsx
320
+ function Ge(e) {
321
+ return e ? e.startsWith("@") ? "javascript:void(0);" : e.match(/^https?:\/\//) ? e : `http://${e}` : "";
322
+ }
323
+ var Ke = () => {
324
+ let [e] = L(), { link: t } = q(), { t: n } = a(), [i, o] = D(!1), [c, l] = D(""), [u, d] = D(""), [f, p] = D(!0), [m, h] = j.useMessage(), g = E(null), b = C((t) => {
325
+ o(t), t || e.setEditable(!0);
326
+ }, [e]), x = () => {
327
+ if (!c) {
328
+ m.warning(n("editor.linkAddressEmpty"));
329
+ return;
330
+ }
331
+ let t = Ge(c);
332
+ e.setEditable(!0), e.update(() => {
333
+ let e = f ? {
334
+ target: "_blank",
335
+ rel: "noopener noreferrer",
336
+ title: c
337
+ } : { title: c }, n = g.current;
338
+ n !== null && ue(n);
339
+ let r = P();
340
+ if (F(r)) {
341
+ let n = u || c, i = r.getTextContent();
342
+ if (!r.isCollapsed() && n === i) Ce(t, e);
343
+ else {
344
+ let i = r.anchor.getNode(), a = le(i) ? i : null, o = r.style || r.getNodes().find(le)?.getStyle() || a?.getStyle() || "", s = r.format || a?.getFormat() || 0, c = Se(t, e), l = oe(n);
345
+ l.setFormat(s), l.setStyle(o), c.append(l), r.insertNodes([c]);
346
+ }
347
+ } else {
348
+ let n = Se(t, e);
349
+ n.append(oe(u || c));
350
+ let r = se(), i = r.getLastChild();
351
+ if (ce(i) && i.isEmpty()) i.append(n);
352
+ else {
353
+ let e = N();
354
+ e.append(n), r.append(e);
355
+ }
356
+ }
357
+ }), g.current = null, l(""), d(""), b(!1);
358
+ }, S = C(() => {
359
+ let n = "";
360
+ e.getEditorState().read(() => {
361
+ let e = P();
362
+ g.current = e ? e.clone() : null, F(e) && !e.isCollapsed() && (n = e.getTextContent());
363
+ }), e.setEditable(!1), e.update(() => {
364
+ ue(null);
365
+ }), window.getSelection()?.removeAllRanges(), e.getRootElement()?.blur(), t ? (l(t.link === "javascript:void(0);" ? "" : t.link ?? ""), d(t.linkText ?? "")) : (l(""), d(n)), o(!0);
366
+ }, [t, e]);
367
+ return /* @__PURE__ */ y(_, { children: [
368
+ /* @__PURE__ */ v(K, {
369
+ icon: "Insertlink",
370
+ tooltip: n("link"),
371
+ onClick: S,
372
+ active: !!t?.link
373
+ }),
374
+ h,
375
+ /* @__PURE__ */ v(r, {
376
+ title: n("link"),
377
+ open: i,
378
+ onOpenChange: b,
379
+ children: /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ y("div", {
380
+ className: "px-[20px] pb-[60px] pt-[40px]",
381
+ children: [/* @__PURE__ */ y("div", {
382
+ className: "flex items-center relative",
383
+ children: [
384
+ /* @__PURE__ */ v("label", {
385
+ className: "w-[80px] shrink-0",
386
+ children: n("linkAddress")
387
+ }),
388
+ /* @__PURE__ */ v(A, {
389
+ value: c,
390
+ onChange: (e) => l(e.target.value),
391
+ placeholder: n("editor.linkTip")
392
+ }),
393
+ /* @__PURE__ */ v("div", {
394
+ className: "absolute bottom-[-30px] left-[80px]",
395
+ children: /* @__PURE__ */ v("p", {
396
+ className: "text-[#999]",
397
+ children: n("editor.linkAliasTip")
398
+ })
399
+ })
400
+ ]
401
+ }), /* @__PURE__ */ y("div", {
402
+ className: "flex items-center mt-[40px]",
403
+ children: [/* @__PURE__ */ v("label", {
404
+ className: "w-[80px] shrink-0",
405
+ children: n("showContent")
406
+ }), /* @__PURE__ */ v(A, {
407
+ value: u,
408
+ onChange: (e) => d(e.target.value)
409
+ })]
410
+ })]
411
+ }), /* @__PURE__ */ y("div", {
412
+ className: "py-[14px] px-[20px] flex justify-between items-center border-t-[1px] border-solid border-[#e0e0e0]",
413
+ children: [/* @__PURE__ */ v("div", { children: /* @__PURE__ */ v(s, {
414
+ checked: f,
415
+ onChange: (e) => p(e),
416
+ children: n("openInNewTab")
417
+ }) }), /* @__PURE__ */ y("div", {
418
+ className: "flex gap-[15px]",
419
+ children: [/* @__PURE__ */ v(O, {
420
+ onClick: () => b(!1),
421
+ children: n("cancel")
422
+ }), /* @__PURE__ */ v(O, {
423
+ type: "primary",
424
+ onClick: x,
425
+ children: n("confirm")
426
+ })]
427
+ })]
428
+ })] })
429
+ })
430
+ ] });
431
+ }, qe = () => {
432
+ let [e] = L(), { link: t } = q(), { t: n } = a();
433
+ return /* @__PURE__ */ v(K, {
434
+ icon: "cancellink",
435
+ tooltip: n("cancelLink"),
436
+ onClick: () => {
437
+ t && e.dispatchCommand(we, null);
438
+ }
439
+ });
440
+ }, J = {
441
+ "picture-modal__container": "_picture-modal__container_oo6vo_1",
442
+ "picture-modal__sidebar": "_picture-modal__sidebar_oo6vo_4",
443
+ "picture-modal__menu-list": "_picture-modal__menu-list_oo6vo_8",
444
+ "picture-modal__menu-item": "_picture-modal__menu-item_oo6vo_13",
445
+ "picture-modal__menu-item--active": "_picture-modal__menu-item--active_oo6vo_22",
446
+ "picture-modal__content": "_picture-modal__content_oo6vo_25",
447
+ "picture-modal__content-body": "_picture-modal__content-body_oo6vo_31",
448
+ "picture-modal__ops": "_picture-modal__ops_oo6vo_34",
449
+ "picture-modal__content-title": "_picture-modal__content-title_oo6vo_42",
450
+ "picture-modal__upload-area": "_picture-modal__upload-area_oo6vo_53",
451
+ "picture-modal__upload-area--dragging": "_picture-modal__upload-area--dragging_oo6vo_69",
452
+ "picture-modal__preview-list": "_picture-modal__preview-list_oo6vo_75",
453
+ "picture-modal__preview": "_picture-modal__preview_oo6vo_75",
454
+ "picture-modal__preview-image": "_picture-modal__preview-image_oo6vo_89",
455
+ "picture-modal__preview-info": "_picture-modal__preview-info_oo6vo_102",
456
+ "picture-modal__preview-filename": "_picture-modal__preview-filename_oo6vo_106",
457
+ "picture-modal__preview-size": "_picture-modal__preview-size_oo6vo_114",
458
+ "picture-modal__preview-delete": "_picture-modal__preview-delete_oo6vo_118",
459
+ "picture-modal__upload-text": "_picture-modal__upload-text_oo6vo_126",
460
+ "picture-modal__footer": "_picture-modal__footer_oo6vo_130"
461
+ }, Je = S((e, t) => {
462
+ let [n] = k.useForm(), [r, i] = D(""), { t: o } = a(), s = (e) => /^https?:\/\/.+/i.test(e);
463
+ return ee(t, () => ({ getValue: async () => {
464
+ try {
465
+ return await n.validateFields(), r;
466
+ } catch {
467
+ throw Error("URL validation failed");
468
+ }
469
+ } })), /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
470
+ className: J["picture-modal__content-title"],
471
+ "data-title": o("editor.imageUrlNote"),
472
+ children: o("editor.enterImageUrl")
473
+ }), /* @__PURE__ */ v(k, {
474
+ form: n,
475
+ children: /* @__PURE__ */ v(k.Item, {
476
+ name: "url",
477
+ rules: [{
478
+ required: !0,
479
+ message: o("editor.pleaseEnterImageUrl")
480
+ }, { validator: (e, t) => !t || s(t) ? Promise.resolve() : Promise.reject(Error(o("editor.pleaseEnterValidImageUrl"))) }],
481
+ children: /* @__PURE__ */ v(A, {
482
+ placeholder: o("editor.pleaseEnterImageUrl"),
483
+ value: r,
484
+ onChange: (e) => i(e.target.value)
485
+ })
486
+ })
487
+ })] });
488
+ });
489
+ Je.displayName = "LinkInput";
490
+ //#endregion
491
+ //#region src/components/Editor/utils/formatTruncatedFilename.ts
492
+ var Ye = "......", Xe = (e, t, n) => {
493
+ if (t <= 0 || n(e) <= t) return {
494
+ display: e,
495
+ truncated: !1
496
+ };
497
+ 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}${Ye}${s}${o}`, u = (e) => n(e) <= t;
498
+ if (!u(l(""))) {
499
+ let t = `${Ye}${o}`;
500
+ return {
501
+ display: u(t) ? t : e,
502
+ truncated: !0
503
+ };
504
+ }
505
+ let d = 0, f = c.length, p = 0;
506
+ for (; d <= f;) {
507
+ let e = d + f >> 1;
508
+ u(l(c.slice(0, e))) ? (p = e, d = e + 1) : f = e - 1;
509
+ }
510
+ return {
511
+ display: l(c.slice(0, p)),
512
+ truncated: !0
513
+ };
514
+ }, Ze = {
515
+ duration: .2,
516
+ ease: [
517
+ .4,
518
+ 0,
519
+ .2,
520
+ 1
521
+ ]
522
+ }, Qe = ({ name: e }) => {
523
+ let t = E(null), [n, r] = D(e), [i, a] = D(!1);
524
+ return te(() => {
525
+ let n = t.current, i = document.createElement("canvas").getContext("2d");
526
+ if (!n || !i) return;
527
+ let o = () => {
528
+ i.font = getComputedStyle(n).font;
529
+ let t = Xe(e, n.clientWidth, (e) => i.measureText(e).width);
530
+ r(t.display), a(t.truncated);
531
+ };
532
+ o();
533
+ let s = new ResizeObserver(o);
534
+ return s.observe(n), () => s.disconnect();
535
+ }, [e]), /* @__PURE__ */ v("div", {
536
+ ref: t,
537
+ className: J["picture-modal__preview-filename"],
538
+ title: i ? e : void 0,
539
+ children: n
540
+ });
541
+ }, $e = (e) => new Promise((t, n) => {
542
+ let r = new FileReader();
543
+ r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsDataURL(e);
544
+ }), et = S((t, n) => {
545
+ let [r, i] = D(!1), [o, s] = D([]), c = E(o);
546
+ c.current = o;
547
+ let l = E(null), [u, d] = j.useMessage(), { t: f } = a(), p = (e) => (e / 1024).toFixed(1) + "kb", m = (e) => e.type.startsWith("image/") ? e.size > 5242880 ? (u.warning(f("editor.imageSizeNote")), !1) : !0 : (u.warning(f("editor.onlyImageFormatsSupported")), !1), h = (e) => {
548
+ let t = 10 - c.current.length;
549
+ if (t <= 0) {
550
+ u.warning(f("editor.imageCountNote", { count: 10 }));
551
+ return;
552
+ }
553
+ let n = Array.from(e).filter(m), r = n.slice(0, t);
554
+ n.length > t && u.warning(f("editor.imageCountNote", { count: 10 })), r.length && s((e) => [...e, ...r.map((e) => ({
555
+ id: `${e.name}-${e.size}-${e.lastModified}-${Math.random()}`,
556
+ file: e,
557
+ url: URL.createObjectURL(e)
558
+ }))]);
559
+ }, g = (e) => {
560
+ s((t) => {
561
+ let n = t.find((t) => t.id === e);
562
+ return n && URL.revokeObjectURL(n.url), t.filter((t) => t.id !== e);
563
+ });
564
+ }, _ = () => {
565
+ l.current?.click();
566
+ }, b = (e) => {
567
+ e.target.files?.length && h(e.target.files), e.target.value = "";
568
+ };
569
+ return T(() => () => {
570
+ c.current.forEach((e) => URL.revokeObjectURL(e.url));
571
+ }, []), ee(n, () => ({ getValue: async () => {
572
+ if (!o.length) throw u.warning(f("editor.pleaseUploadImageFirst")), Error(f("editor.pleaseUploadImageFirst"));
573
+ try {
574
+ return await Promise.all(o.map(async (e) => ({
575
+ src: await $e(e.file),
576
+ fileName: e.file.name
577
+ })));
578
+ } catch {
579
+ throw Error(f("editor.operationFailed"));
580
+ }
581
+ } }), [
582
+ o,
583
+ u,
584
+ f
585
+ ]), /* @__PURE__ */ y("div", {
586
+ onDragOver: (e) => {
587
+ e.preventDefault(), i(!0);
588
+ },
589
+ onDragLeave: (e) => {
590
+ e.preventDefault(), i(!1);
591
+ },
592
+ onDrop: (e) => {
593
+ e.preventDefault(), i(!1), e.dataTransfer.files.length && h(e.dataTransfer.files);
594
+ },
595
+ children: [
596
+ /* @__PURE__ */ y("div", {
597
+ className: J["picture-modal__ops"],
598
+ children: [/* @__PURE__ */ v("div", {
599
+ className: J["picture-modal__content-title"],
600
+ "data-title": f("editor.imageSizeNote"),
601
+ children: f("editor.uploadImage")
602
+ }), /* @__PURE__ */ y("div", {
603
+ className: `${J["picture-modal__upload-area"]} ${r ? J["picture-modal__upload-area--dragging"] : ""}`,
604
+ onClick: _,
605
+ children: [/* @__PURE__ */ v(e, { name: "upload" }), /* @__PURE__ */ v("span", {
606
+ className: J["picture-modal__upload-text"],
607
+ children: f("editor.clickOrDragToUpload")
608
+ })]
609
+ })]
610
+ }),
611
+ o.length > 0 ? /* @__PURE__ */ v("div", {
612
+ className: J["picture-modal__preview-list"],
613
+ children: /* @__PURE__ */ v(M, {
614
+ mode: "popLayout",
615
+ children: o.map((t) => /* @__PURE__ */ y(ie.div, {
616
+ layout: "position",
617
+ className: J["picture-modal__preview"],
618
+ initial: {
619
+ opacity: 0,
620
+ y: 12
621
+ },
622
+ animate: {
623
+ opacity: 1,
624
+ y: 0
625
+ },
626
+ exit: {
627
+ opacity: 0,
628
+ y: -8
629
+ },
630
+ transition: Ze,
631
+ children: [
632
+ /* @__PURE__ */ v("div", {
633
+ className: J["picture-modal__preview-image"],
634
+ children: /* @__PURE__ */ v("img", {
635
+ src: t.url,
636
+ alt: f("editor.previewImage")
637
+ })
638
+ }),
639
+ /* @__PURE__ */ y("div", {
640
+ className: J["picture-modal__preview-info"],
641
+ children: [/* @__PURE__ */ v(Qe, { name: t.file.name }), /* @__PURE__ */ v("div", {
642
+ className: J["picture-modal__preview-size"],
643
+ children: p(t.file.size)
644
+ })]
645
+ }),
646
+ /* @__PURE__ */ v("div", {
647
+ className: J["picture-modal__preview-delete"],
648
+ role: "button",
649
+ onClick: () => g(t.id),
650
+ children: /* @__PURE__ */ v(e, { name: "delete" })
651
+ })
652
+ ]
653
+ }, t.id))
654
+ })
655
+ }) : null,
656
+ /* @__PURE__ */ v("input", {
657
+ ref: l,
658
+ type: "file",
659
+ accept: "image/*",
660
+ multiple: !0,
661
+ style: { display: "none" },
662
+ onChange: b
663
+ }),
664
+ d
665
+ ]
666
+ });
667
+ });
668
+ et.displayName = "UploadImage";
669
+ //#endregion
670
+ //#region src/components/Editor/commands/ImageCommands.ts
671
+ var Y = ye("INSERT_INLINE_IMAGE_COMMAND"), tt = () => {
672
+ let { t } = a(), [n] = L(), [i, o] = D(!1), s = E(null), l = E(null), u = [{
673
+ key: "upload",
674
+ title: t("editor.uploadImage"),
675
+ icon: /* @__PURE__ */ v(e, { name: "picture" })
676
+ }, {
677
+ key: "url",
678
+ title: t("editor.imageUrl"),
679
+ icon: /* @__PURE__ */ v(e, { name: "Insertlink" })
680
+ }], [d, f] = D(u[0].key), p = async () => {
681
+ try {
682
+ if (d === "upload" && l.current) (await l.current.getValue()).forEach((e) => {
683
+ n.dispatchCommand(Y, {
684
+ src: e.src,
685
+ altText: e.fileName
686
+ });
687
+ });
688
+ else if (s.current) {
689
+ let e = await s.current.getValue();
690
+ n.dispatchCommand(Y, {
691
+ src: e,
692
+ altText: e
693
+ });
694
+ }
695
+ o(!1);
696
+ } catch (e) {
697
+ j.error(e instanceof Error ? e.message : t("editor.operationFailed"));
698
+ }
699
+ }, m = {
700
+ upload: /* @__PURE__ */ v(et, { ref: l }),
701
+ url: /* @__PURE__ */ v(Je, { ref: s })
702
+ };
703
+ return /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v(K, {
704
+ icon: "picture",
705
+ tooltip: t("picture"),
706
+ onClick: () => o(!0)
707
+ }), /* @__PURE__ */ y(r, {
708
+ title: t("addPicture"),
709
+ open: i,
710
+ onOpenChange: o,
711
+ width: "620px",
712
+ children: [/* @__PURE__ */ y("div", {
713
+ className: J["picture-modal__container"],
714
+ children: [/* @__PURE__ */ v("div", {
715
+ className: J["picture-modal__sidebar"],
716
+ children: /* @__PURE__ */ v("ul", {
717
+ className: J["picture-modal__menu-list"],
718
+ children: u.map((e) => /* @__PURE__ */ y("li", {
719
+ className: `${J["picture-modal__menu-item"]} ${d === e.key ? J["picture-modal__menu-item--active"] : ""}`,
720
+ onClick: () => f(e.key),
721
+ children: [/* @__PURE__ */ v("span", {
722
+ className: J["picture-modal__menu-icon"],
723
+ children: e.icon
724
+ }), /* @__PURE__ */ v("span", { children: e.title })]
725
+ }, e.title))
726
+ })
727
+ }), /* @__PURE__ */ v(c, {
728
+ className: J["picture-modal__content"],
729
+ contentClassName: J["picture-modal__content-body"],
730
+ children: m[d]
731
+ })]
732
+ }), /* @__PURE__ */ y("div", {
733
+ className: J["picture-modal__footer"],
734
+ children: [/* @__PURE__ */ v(O, {
735
+ onClick: () => o(!1),
736
+ children: t("cancel")
737
+ }), /* @__PURE__ */ v(O, {
738
+ type: "primary",
739
+ onClick: p,
740
+ children: t("confirm")
741
+ })]
742
+ })]
743
+ })] });
744
+ }, X = {
745
+ xmlns: "http://www.w3.org/2000/svg",
746
+ width: "1em",
747
+ height: "1em",
748
+ viewBox: "0 0 24 24",
749
+ fill: "none",
750
+ stroke: "currentColor",
751
+ strokeWidth: 2,
752
+ strokeLinecap: "round",
753
+ strokeLinejoin: "round"
754
+ }, nt = () => /* @__PURE__ */ y("svg", {
755
+ ...X,
756
+ children: [
757
+ /* @__PURE__ */ v("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
758
+ /* @__PURE__ */ v("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
759
+ /* @__PURE__ */ v("line", {
760
+ x1: "4",
761
+ x2: "20",
762
+ y1: "12",
763
+ y2: "12"
764
+ })
765
+ ]
766
+ }), rt = () => /* @__PURE__ */ y("svg", {
767
+ ...X,
768
+ children: [/* @__PURE__ */ v("path", { d: "M9 14 4 9l5-5" }), /* @__PURE__ */ v("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" })]
769
+ }), it = () => /* @__PURE__ */ y("svg", {
770
+ ...X,
771
+ children: [/* @__PURE__ */ v("path", { d: "m15 14 5-5-5-5" }), /* @__PURE__ */ v("path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" })]
772
+ }), at = () => /* @__PURE__ */ y("svg", {
773
+ ...X,
774
+ children: [
775
+ /* @__PURE__ */ v("path", { d: "m4 19 8-8" }),
776
+ /* @__PURE__ */ v("path", { d: "m12 19-8-8" }),
777
+ /* @__PURE__ */ v("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" })
778
+ ]
779
+ }), ot = () => /* @__PURE__ */ y("svg", {
780
+ ...X,
781
+ children: [
782
+ /* @__PURE__ */ v("path", { d: "m4 5 8 8" }),
783
+ /* @__PURE__ */ v("path", { d: "m12 5-8 8" }),
784
+ /* @__PURE__ */ v("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" })
785
+ ]
786
+ }), st = () => /* @__PURE__ */ y("svg", {
787
+ ...X,
788
+ children: [
789
+ /* @__PURE__ */ v("path", { d: "M21 5H11" }),
790
+ /* @__PURE__ */ v("path", { d: "M21 12H11" }),
791
+ /* @__PURE__ */ v("path", { d: "M21 19H11" }),
792
+ /* @__PURE__ */ v("path", { d: "m3 8 4 4-4 4" })
793
+ ]
794
+ }), ct = () => /* @__PURE__ */ y("svg", {
795
+ ...X,
796
+ children: [
797
+ /* @__PURE__ */ v("path", { d: "M21 5H11" }),
798
+ /* @__PURE__ */ v("path", { d: "M21 12H11" }),
799
+ /* @__PURE__ */ v("path", { d: "M21 19H11" }),
800
+ /* @__PURE__ */ v("path", { d: "m7 8-4 4 4 4" })
801
+ ]
802
+ }), lt = () => /* @__PURE__ */ y("svg", {
803
+ ...X,
804
+ children: [
805
+ /* @__PURE__ */ v("path", { d: "M11 5h10" }),
806
+ /* @__PURE__ */ v("path", { d: "M11 12h10" }),
807
+ /* @__PURE__ */ v("path", { d: "M11 19h10" }),
808
+ /* @__PURE__ */ v("path", { d: "M4 4h1v5" }),
809
+ /* @__PURE__ */ v("path", { d: "M4 9h2" }),
810
+ /* @__PURE__ */ v("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" })
811
+ ]
812
+ }), ut = () => /* @__PURE__ */ y("svg", {
813
+ ...X,
814
+ children: [
815
+ /* @__PURE__ */ v("path", { d: "M3 5h.01" }),
816
+ /* @__PURE__ */ v("path", { d: "M3 12h.01" }),
817
+ /* @__PURE__ */ v("path", { d: "M3 19h.01" }),
818
+ /* @__PURE__ */ v("path", { d: "M8 5h13" }),
819
+ /* @__PURE__ */ v("path", { d: "M8 12h13" }),
820
+ /* @__PURE__ */ v("path", { d: "M8 19h13" })
821
+ ]
822
+ }), dt = () => /* @__PURE__ */ y("svg", {
823
+ ...X,
824
+ className: "lucide lucide-code-xml-icon lucide-code-xml",
825
+ children: [
826
+ /* @__PURE__ */ v("path", { d: "m18 16 4-4-4-4" }),
827
+ /* @__PURE__ */ v("path", { d: "m6 8-4 4 4 4" }),
828
+ /* @__PURE__ */ v("path", { d: "m14.5 4-5 16" })
829
+ ]
830
+ }), ft = () => /* @__PURE__ */ y("svg", {
831
+ ...X,
832
+ className: "lucide lucide-sheet-icon lucide-sheet",
833
+ children: [
834
+ /* @__PURE__ */ v("rect", {
835
+ width: "18",
836
+ height: "18",
837
+ x: "3",
838
+ y: "3",
839
+ rx: "2",
840
+ ry: "2"
841
+ }),
842
+ /* @__PURE__ */ v("line", {
843
+ x1: "3",
844
+ x2: "21",
845
+ y1: "9",
846
+ y2: "9"
847
+ }),
848
+ /* @__PURE__ */ v("line", {
849
+ x1: "3",
850
+ x2: "21",
851
+ y1: "15",
852
+ y2: "15"
853
+ }),
854
+ /* @__PURE__ */ v("line", {
855
+ x1: "9",
856
+ x2: "9",
857
+ y1: "9",
858
+ y2: "21"
859
+ }),
860
+ /* @__PURE__ */ v("line", {
861
+ x1: "15",
862
+ x2: "15",
863
+ y1: "9",
864
+ y2: "21"
865
+ })
866
+ ]
867
+ }), pt = () => /* @__PURE__ */ y("svg", {
868
+ ...X,
869
+ className: "lucide lucide-file-code-corner-icon lucide-file-code-corner",
870
+ children: [
871
+ /* @__PURE__ */ v("path", { d: "M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35" }),
872
+ /* @__PURE__ */ v("path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }),
873
+ /* @__PURE__ */ v("path", { d: "m5 16-3 3 3 3" }),
874
+ /* @__PURE__ */ v("path", { d: "m9 22 3-3-3-3" })
875
+ ]
876
+ }), mt = () => {
877
+ let [e] = L(), { canUndo: t } = Ne(), { t: n } = a();
878
+ return /* @__PURE__ */ v(K, {
879
+ icon: /* @__PURE__ */ v(rt, {}),
880
+ tooltip: n("editor.undo"),
881
+ disabled: !t,
882
+ onClick: () => {
883
+ e.dispatchCommand(ve, void 0);
884
+ }
885
+ });
886
+ }, ht = () => {
887
+ let [e] = L(), { canRedo: t } = Ne(), { t: n } = a();
888
+ return /* @__PURE__ */ v(K, {
889
+ icon: /* @__PURE__ */ v(it, {}),
890
+ tooltip: n("editor.redo"),
891
+ disabled: !t,
892
+ onClick: () => e.dispatchCommand(_e, void 0)
893
+ });
894
+ }, gt = () => {
895
+ let [e] = L(), { strikethrough: t } = q(), { t: n } = a();
896
+ return /* @__PURE__ */ v(K, {
897
+ icon: /* @__PURE__ */ v(nt, {}),
898
+ tooltip: n("editor.strikethrough"),
899
+ active: t,
900
+ onClick: () => e.dispatchCommand(I, "strikethrough")
901
+ });
902
+ }, _t = () => {
903
+ let [e] = L(), { superscript: t } = q(), { t: n } = a();
904
+ return /* @__PURE__ */ v(K, {
905
+ icon: /* @__PURE__ */ v(at, {}),
906
+ tooltip: n("editor.superscript"),
907
+ active: t,
908
+ onClick: () => e.dispatchCommand(I, "superscript")
909
+ });
910
+ }, vt = () => {
911
+ let [e] = L(), { subscript: t } = q(), { t: n } = a();
912
+ return /* @__PURE__ */ v(K, {
913
+ icon: /* @__PURE__ */ v(ot, {}),
914
+ tooltip: n("editor.subscript"),
915
+ active: t,
916
+ onClick: () => e.dispatchCommand(I, "subscript")
917
+ });
918
+ }, yt = () => {
919
+ let [e] = L(), { t } = a();
920
+ return /* @__PURE__ */ v(K, {
921
+ icon: /* @__PURE__ */ v(st, {}),
922
+ tooltip: t("editor.indent"),
923
+ onClick: () => e.dispatchCommand(he, void 0)
924
+ });
925
+ }, bt = () => {
926
+ let [e] = L(), { canOutdent: t } = q(), { t: n } = a();
927
+ return /* @__PURE__ */ v(K, {
928
+ icon: /* @__PURE__ */ v(ct, {}),
929
+ tooltip: n("editor.outdent"),
930
+ disabled: !t,
931
+ onClick: () => e.dispatchCommand(ge, void 0)
932
+ });
933
+ }, xt = () => {
934
+ let [e] = L(), { listType: t } = q(), { t: n } = a(), r = t === "bullet";
935
+ return /* @__PURE__ */ v(K, {
936
+ icon: /* @__PURE__ */ v(ut, {}),
937
+ tooltip: n("editor.bulletList"),
938
+ active: r,
939
+ onClick: () => {
940
+ e.dispatchCommand(r ? De : Ee, void 0);
941
+ }
942
+ });
943
+ }, St = () => {
944
+ let [e] = L(), { listType: t } = q(), { t: n } = a(), r = t === "number";
945
+ return /* @__PURE__ */ v(K, {
946
+ icon: /* @__PURE__ */ v(lt, {}),
947
+ tooltip: n("editor.numberList"),
948
+ active: r,
949
+ onClick: () => {
950
+ e.dispatchCommand(r ? De : Te, void 0);
951
+ }
952
+ });
953
+ }, Ct = () => {
954
+ let [e] = L(), { isCodeBlock: t } = q(), { t: n } = a();
955
+ return /* @__PURE__ */ v(K, {
956
+ icon: /* @__PURE__ */ v(dt, {}),
957
+ tooltip: n("editor.codeBlock"),
958
+ active: t,
959
+ onClick: () => {
960
+ e.update(() => {
961
+ xe(P(), () => t ? N() : Oe(V));
962
+ });
963
+ }
964
+ });
965
+ }, Z = {
966
+ "bsy-lexical__table-picker": "_bsy-lexical__table-picker_mv0nn_1",
967
+ "bsy-lexical__table-picker-grid": "_bsy-lexical__table-picker-grid_mv0nn_9",
968
+ "bsy-lexical__table-picker-cell": "_bsy-lexical__table-picker-cell_mv0nn_15",
969
+ "bsy-lexical__table-picker-cell--active": "_bsy-lexical__table-picker-cell--active_mv0nn_24",
970
+ "bsy-lexical__table-picker-label": "_bsy-lexical__table-picker-label_mv0nn_28"
971
+ }, wt = g(1, 11), Tt = () => {
972
+ let [e] = L(), { isInTable: r } = q(), { t: i } = a(), s = t(), [c, u] = D(!1), [d, f] = D({
973
+ rows: 0,
974
+ cols: 0
975
+ });
976
+ T(() => {
977
+ r && u(!1);
978
+ }, [r]);
979
+ let p = () => {
980
+ u(!1), f({
981
+ rows: 0,
982
+ cols: 0
983
+ });
984
+ }, { refs: m, floatingStyles: h, getReferenceProps: g, getFloatingProps: b } = l({
985
+ isOpen: c,
986
+ close: p,
987
+ showMask: !1,
988
+ zIndex: s,
989
+ popupMinWidth: "220px",
990
+ offset: {
991
+ x: 0,
992
+ y: 4
993
+ }
994
+ });
995
+ return r ? /* @__PURE__ */ v(K, {
996
+ icon: /* @__PURE__ */ v(ft, {}),
997
+ tooltip: i("editor.table"),
998
+ disabled: !0
999
+ }) : /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
1000
+ className: "inline-flex",
1001
+ ref: m.setReference,
1002
+ ...g({ onClick: () => u((e) => !e) }),
1003
+ children: /* @__PURE__ */ v(K, {
1004
+ icon: /* @__PURE__ */ v(ft, {}),
1005
+ tooltip: i("editor.table")
1006
+ })
1007
+ }), /* @__PURE__ */ v(ae, { children: /* @__PURE__ */ v(M, { children: c ? /* @__PURE__ */ v(n, {
1008
+ zIndex: s,
1009
+ children: /* @__PURE__ */ v(ie.div, {
1010
+ ref: m.setFloating,
1011
+ ...b(),
1012
+ style: {
1013
+ ...h,
1014
+ zIndex: s
1015
+ },
1016
+ ...o,
1017
+ children: /* @__PURE__ */ y("div", {
1018
+ className: Z["bsy-lexical__table-picker"],
1019
+ onMouseDown: (e) => e.preventDefault(),
1020
+ onMouseLeave: () => f({
1021
+ rows: 0,
1022
+ cols: 0
1023
+ }),
1024
+ children: [/* @__PURE__ */ v("div", {
1025
+ className: Z["bsy-lexical__table-picker-grid"],
1026
+ children: wt.map((t) => wt.map((n) => /* @__PURE__ */ v("button", {
1027
+ type: "button",
1028
+ className: re(Z["bsy-lexical__table-picker-cell"], d.rows >= t && d.cols >= n && Z["bsy-lexical__table-picker-cell--active"]),
1029
+ onMouseEnter: () => f({
1030
+ rows: t,
1031
+ cols: n
1032
+ }),
1033
+ onClick: () => {
1034
+ e.dispatchCommand(ke, {
1035
+ rows: String(t),
1036
+ columns: String(n),
1037
+ includeHeaders: !1
1038
+ }), p();
1039
+ }
1040
+ }, `${t}-${n}`)))
1041
+ }), /* @__PURE__ */ y("div", {
1042
+ className: Z["bsy-lexical__table-picker-label"],
1043
+ children: [
1044
+ d.rows,
1045
+ " × ",
1046
+ d.cols
1047
+ ]
1048
+ })]
1049
+ })
1050
+ }, "bsy-lexical-table-picker")
1051
+ }) : null }) })] });
1052
+ }, Q = x(null), Et = () => {
1053
+ let e = w(Q);
1054
+ if (!e) throw Error("useSourceMode must be used within SourceModeProvider");
1055
+ return e;
1056
+ }, Dt = () => {
1057
+ let { t: e } = a(), { isSourceMode: t, toggleSourceMode: n } = Et();
1058
+ return /* @__PURE__ */ v(K, {
1059
+ icon: /* @__PURE__ */ v(pt, {}),
1060
+ tooltip: e("editor.sourceMode"),
1061
+ active: t,
1062
+ onClick: n
1063
+ });
1064
+ }, Ot = () => {
1065
+ let [t] = L(), { headingTag: n, isInTable: r } = q(), { t: i } = a(), { iconSize: o } = G(), s = n || "paragraph", c = [
1066
+ {
1067
+ key: "paragraph",
1068
+ label: i("editor.paragraph")
1069
+ },
1070
+ {
1071
+ key: "h1",
1072
+ label: i("editor.heading1")
1073
+ },
1074
+ {
1075
+ key: "h2",
1076
+ label: i("editor.heading2")
1077
+ },
1078
+ {
1079
+ key: "h3",
1080
+ label: i("editor.heading3")
1081
+ }
1082
+ ], l = c.find((e) => e.key === s)?.label, d = C((e) => {
1083
+ let n = e.key;
1084
+ t.update(() => {
1085
+ xe(P(), () => n === "paragraph" ? N() : Ae(n));
1086
+ });
1087
+ }, [t]), f = /* @__PURE__ */ v("div", {
1088
+ className: z["bsy-lexical__toolbar-select"],
1089
+ style: { width: 58 },
1090
+ children: /* @__PURE__ */ v(K, {
1091
+ icon: /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("span", {
1092
+ className: z["bsy-lexical__toolbar-select-label"],
1093
+ children: l
1094
+ }), /* @__PURE__ */ v(e, {
1095
+ name: "arrow-down",
1096
+ size: o,
1097
+ className: z["bsy-lexical__toolbar-select-arrow"]
1098
+ })] }),
1099
+ tooltip: i("editor.heading"),
1100
+ disabled: r
1101
+ })
1102
+ });
1103
+ return r ? f : /* @__PURE__ */ v(u, {
1104
+ menus: c,
1105
+ onClick: d,
1106
+ showSearch: !1,
1107
+ activeKey: [s],
1108
+ style: {
1109
+ width: "110px",
1110
+ minWidth: "110px"
1111
+ },
1112
+ children: f
1113
+ });
1114
+ }, $ = /* @__PURE__ */ new Map(), kt = (e, t) => {
1115
+ if (!e) throw Error("registerToolbarButton: name is required");
1116
+ $.set(e, t);
1117
+ }, At = (e) => {
1118
+ $.delete(e);
1119
+ }, jt = (e) => $.get(e), Mt = () => Array.from($.keys()), Nt = {
1120
+ undo: mt,
1121
+ redo: ht,
1122
+ bold: Re,
1123
+ underline: ze,
1124
+ italic: Be,
1125
+ strikethrough: gt,
1126
+ superscript: _t,
1127
+ subscript: vt,
1128
+ heading: Ot,
1129
+ fontSize: Ve,
1130
+ fontColor: He,
1131
+ fill: Ue,
1132
+ bullet: xt,
1133
+ number: St,
1134
+ outdent: bt,
1135
+ indent: yt,
1136
+ align: We,
1137
+ link: Ke,
1138
+ unLink: qe,
1139
+ picture: tt,
1140
+ code: Ct,
1141
+ table: Tt,
1142
+ source: Dt
1143
+ };
1144
+ Object.entries(Nt).forEach(([e, t]) => {
1145
+ kt(e, t);
1146
+ });
1147
+ //#endregion
1148
+ export { V as _, At as a, z as b, Y as c, Ie as d, G as f, U as g, H as h, kt as i, q as l, je as m, jt as n, Q as o, Pe as p, Mt as r, Et as s, Nt as t, K as u, Me as v, B as y };