@baishuyun/ui-base 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/Card/Card-F2t4Rv_v.js +69 -0
  2. package/dist/Card/index.js +3 -4
  3. package/dist/CheckBox/CheckBox-DFoMXJZz.js +67 -0
  4. package/dist/CheckBox/CheckBox-q2vu7qf7.js +33 -0
  5. package/dist/CheckBox/index.js +4 -39
  6. package/dist/ColorPicker/ColorPicker-Bh4KTHxh.js +168 -0
  7. package/dist/ColorPicker/index.js +6 -5
  8. package/dist/DropDown/DropDown-BEzloRRM.js +162 -0
  9. package/dist/DropDown/index.js +7 -4
  10. package/dist/Editor/Buttons-ClWtl3G-.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-DXmPqVzg.js +19 -0
  15. package/dist/Icon/index.js +2 -4
  16. package/dist/InputTag/InputTag-DbiyuWo9.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-BO1s8pJe.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-DoQO-Xi5.js +729 -0
  29. package/dist/Select/SelectInputSearch-gp6gcY3x.js +46 -0
  30. package/dist/Select/index.js +11 -6
  31. package/dist/Tabs/Tabs-Dsxn_7gF.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-DgwG7Unx.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 +4 -4
  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,588 +1,530 @@
1
- import { jsx as u, jsxs as W, Fragment as et } from "react/jsx-runtime";
2
- import { o as N, P as F, _ as $, Y as M, w as U, f as nt, x as G, j as it, C as ot, L as rt, $ as B, S as st, a as at, W as V, J as lt, F as ct, B as ut, M as dt, b as J, g as ht, m as gt, h as mt, c as ft, d as _t, e as bt, n as pt, q as z, s as xt, i as yt, k as vt } from "../vendors/lexical-DO7eMeC2.js";
3
- import wt, { useState as S, useEffect as y, useRef as O, useCallback as E, useMemo as Tt } from "react";
4
- import { p as Ct, T as Et, g as Lt, a as Z, k as X, v as H, I as Nt, m as kt } from "./index-D7tFsaxU.js";
5
- import { B as ie, l as oe, r as re, u as se } from "./index-D7tFsaxU.js";
6
- import { DEFAULT_BACKGROUND_COLOR as j, DEFAULT_FONT_COLOR as K, DEFAULT_FONT_SIZE as Y } from "./constants/index.js";
7
- import { c as R } from "../vendors/clsx-OuTLNxxd.js";
8
- const I = {
9
- "bsy-lexical__toolbar": "_bsy-lexical__toolbar_n60av_1",
10
- "bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_n60av_9",
11
- "bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_n60av_15"
1
+ import "../Icon/Icon-DXmPqVzg.js";
2
+ import "../vendors/useLocale-BfT0V1j4.js";
3
+ import { t as e } from "../vendors/clsx-DNOE4Gl8.js";
4
+ import "../Modal/Modal-BO1s8pJe.js";
5
+ import "../ColorPicker/ColorPicker-Bh4KTHxh.js";
6
+ import "../vendors/tinycolor2-DToeAEPD.js";
7
+ import "../vendors/color-BPWy9DvT.js";
8
+ import "../Select/SelectInputSearch-gp6gcY3x.js";
9
+ import "../CheckBox/CheckBox-DFoMXJZz.js";
10
+ import "../CheckBox/CheckBox-q2vu7qf7.js";
11
+ import "../NotFoundContent/NotFoundContent-CTPpcZOt.js";
12
+ import "../vendors/useFloatingPortal-BA6P5GxV.js";
13
+ import "../DropDown/DropDown-BEzloRRM.js";
14
+ import { C as t, D as n, F as r, I as i, M as a, N as o, O as s, P as c, S as l, T as u, _ as d, a as f, b as p, c as m, d as h, f as g, g as _, h as v, l as y, m as b, o as x, p as ee, r as te, t as ne, u as re, v as ie, w as S, x as C, y as w } from "../vendors/lexical-hZliMgDv.js";
15
+ import { a as T, c as E, i as D, l as O, n as k, o as ae, r as oe, s as se } from "./Buttons-ClWtl3G-.js";
16
+ import { DEFAULT_BACKGROUND_COLOR as A, DEFAULT_FONT_COLOR as j, DEFAULT_FONT_SIZE as M } from "./constants/index.js";
17
+ import { Fragment as ce, jsx as N, jsxs as P } from "react/jsx-runtime";
18
+ import F, { useCallback as I, useEffect as L, useMemo as R, useRef as z, useState as B } from "react";
19
+ //#region src/components/Editor/ToolbarPlugin/ToolbarPlugin.module.scss
20
+ var V = {
21
+ "bsy-lexical__toolbar": "_bsy-lexical__toolbar_n60av_1",
22
+ "bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_n60av_9",
23
+ "bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_n60av_15"
12
24
  };
13
- function Rt() {
14
- const [i] = N(), [t, o] = S({
15
- bold: !1,
16
- italic: !1,
17
- underline: !1,
18
- fontSize: Y,
19
- fontColor: K,
20
- backgroundColor: j,
21
- align: "left",
22
- link: void 0
23
- });
24
- return y(() => i.registerUpdateListener(({ editorState: e }) => {
25
- e.read(() => {
26
- const n = F();
27
- if ($(n)) {
28
- const s = M(
29
- n,
30
- "font-size",
31
- Y
32
- ), a = M(
33
- n,
34
- "color",
35
- K
36
- ), l = M(
37
- n,
38
- "background-color",
39
- j
40
- ), r = n.anchor.getNode();
41
- let m = r.getKey() === "root" ? r : U(r, (_) => {
42
- const h = _.getParent();
43
- return h !== null && nt(h);
44
- });
45
- m === null && (m = r.getTopLevelElementOrThrow());
46
- const d = {}, f = U(r, Ct);
47
- f ? (d.link = f.getURL(), d.linkText = f.getTextContent(), d.newBlank = f.getTarget() === "_blank") : d.linkText = n.getTextContent(), o({
48
- bold: n.hasFormat("bold"),
49
- italic: n.hasFormat("italic"),
50
- underline: n.hasFormat("underline"),
51
- fontSize: s,
52
- fontColor: a,
53
- backgroundColor: l,
54
- align: G(m) ? m.getFormatType() : "left",
55
- link: d
56
- });
57
- }
58
- });
59
- }), [i]), t;
25
+ //#endregion
26
+ //#region src/components/Editor/hooks/useTextFormatsState.ts
27
+ function H() {
28
+ let [e] = i(), [t, a] = B({
29
+ bold: !1,
30
+ italic: !1,
31
+ underline: !1,
32
+ fontSize: M,
33
+ fontColor: j,
34
+ backgroundColor: A,
35
+ align: "left",
36
+ link: void 0
37
+ });
38
+ return L(() => e.registerUpdateListener(({ editorState: e }) => {
39
+ e.read(() => {
40
+ let e = C();
41
+ if (u(e)) {
42
+ let t = d(e, "font-size", M), i = d(e, "color", j), o = d(e, "background-color", A), s = e.anchor.getNode(), c = s.getKey() === "root" ? s : v(s, (e) => {
43
+ let t = e.getParent();
44
+ return t !== null && n(t);
45
+ });
46
+ c === null && (c = s.getTopLevelElementOrThrow());
47
+ let l = {}, u = v(s, x);
48
+ u ? (l.link = u.getURL(), l.linkText = u.getTextContent(), l.newBlank = u.getTarget() === "_blank") : l.linkText = e.getTextContent(), a({
49
+ bold: e.hasFormat("bold"),
50
+ italic: e.hasFormat("italic"),
51
+ underline: e.hasFormat("underline"),
52
+ fontSize: t,
53
+ fontColor: i,
54
+ backgroundColor: o,
55
+ align: r(c) ? c.getFormatType() : "left",
56
+ link: l
57
+ });
58
+ }
59
+ });
60
+ }), [e]), t;
60
61
  }
61
- const Dt = (i) => {
62
- const t = Rt();
63
- return /* @__PURE__ */ u(Et.Provider, { value: t, children: i.children });
64
- }, St = (i) => {
65
- const { config: t = [], style: o } = i, e = (n, s) => {
66
- const a = typeof n == "string" ? n : n.name, l = Lt(a);
67
- return l ? typeof n == "string" ? /* @__PURE__ */ u(l, {}, `${a}-${s}`) : /* @__PURE__ */ u(l, { ...n.props }, `${a}-${s}`) : (console.warn(`[ToolbarPlugin] Button "${a}" is not registered.`), null);
68
- };
69
- return /* @__PURE__ */ u(Dt, { children: /* @__PURE__ */ u("div", { className: I["bsy-lexical__toolbar"], style: o, children: t.map((n, s) => /* @__PURE__ */ W(
70
- "div",
71
- {
72
- className: I["bsy-lexical__toolbar-group"],
73
- "data-group": n.key,
74
- children: [
75
- n.buttons.map((a, l) => e(a, l)),
76
- s < t.length - 1 && /* @__PURE__ */ u("div", { className: I["bsy-lexical__toolbar-divider"] })
77
- ]
78
- },
79
- n.key + s
80
- )) }) });
81
- }, q = {
82
- "bsy-lexical-editor": "_bsy-lexical-editor_19ssw_1",
83
- "bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_19ssw_6"
62
+ //#endregion
63
+ //#region src/components/Editor/ToolbarPlugin/context/TextFormatProvider.tsx
64
+ var U = (e) => {
65
+ let t = H();
66
+ return /* @__PURE__ */ N(O.Provider, {
67
+ value: t,
68
+ children: e.children
69
+ });
70
+ }, W = (e) => {
71
+ let { config: t = [], style: n } = e, r = (e, t) => {
72
+ let n = typeof e == "string" ? e : e.name, r = k(n);
73
+ return r ? typeof e == "string" ? /* @__PURE__ */ N(r, {}, `${n}-${t}`) : /* @__PURE__ */ N(r, { ...e.props }, `${n}-${t}`) : (console.warn(`[ToolbarPlugin] Button "${n}" is not registered.`), null);
74
+ };
75
+ return /* @__PURE__ */ N(U, { children: /* @__PURE__ */ N("div", {
76
+ className: V["bsy-lexical__toolbar"],
77
+ style: n,
78
+ children: t.map((e, n) => /* @__PURE__ */ P("div", {
79
+ className: V["bsy-lexical__toolbar-group"],
80
+ "data-group": e.key,
81
+ children: [e.buttons.map((e, t) => r(e, t)), n < t.length - 1 && /* @__PURE__ */ N("div", { className: V["bsy-lexical__toolbar-divider"] })]
82
+ }, e.key + n))
83
+ }) });
84
+ }, G = {
85
+ "bsy-lexical-editor": "_bsy-lexical-editor_19ssw_1",
86
+ "bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_19ssw_6"
87
+ }, K = {
88
+ imageWrapper: "_imageWrapper_y06h3_1",
89
+ selected: "_selected_y06h3_8",
90
+ resizing: "_resizing_y06h3_12",
91
+ image: "_image_y06h3_1",
92
+ resizeHandle: "_resizeHandle_y06h3_30",
93
+ topLeft: "_topLeft_y06h3_44",
94
+ topRight: "_topRight_y06h3_49",
95
+ bottomLeft: "_bottomLeft_y06h3_54",
96
+ bottomRight: "_bottomRight_y06h3_59"
97
+ }, le = ({ src: n, altText: r, width: a, height: o, nodeKey: s }) => {
98
+ let [c] = i(), [l, d] = B(!1), [f, p] = B(null), m = z(null), [h, g] = B({
99
+ width: a || void 0,
100
+ height: o || void 0
101
+ }), _ = I(() => {
102
+ a && o && g({
103
+ width: a,
104
+ height: o
105
+ });
106
+ }, [a, o]), v = I((e, t) => {
107
+ if (e.preventDefault(), e.stopPropagation(), !m.current) return;
108
+ let n = h.width || m.current.offsetWidth, r = h.height || m.current.offsetHeight, i = n / r;
109
+ (!h.width || !h.height) && g({
110
+ width: n,
111
+ height: r
112
+ }), p({
113
+ isResizing: !0,
114
+ startX: e.clientX,
115
+ startY: e.clientY,
116
+ startWidth: n,
117
+ startHeight: r,
118
+ aspectRatio: i,
119
+ direction: t
120
+ });
121
+ }, [h]), y = I((e) => {
122
+ if (!f?.isResizing) return;
123
+ let t = e.clientX - f.startX, n;
124
+ switch (f.direction) {
125
+ case "bottom-right":
126
+ n = Math.max(50, f.startWidth + t);
127
+ break;
128
+ case "bottom-left":
129
+ n = Math.max(50, f.startWidth - t);
130
+ break;
131
+ case "top-right":
132
+ n = Math.max(50, f.startWidth + t);
133
+ break;
134
+ case "top-left":
135
+ n = Math.max(50, f.startWidth - t);
136
+ break;
137
+ default: n = Math.max(50, f.startWidth + t);
138
+ }
139
+ let r = n / f.aspectRatio;
140
+ g({
141
+ width: n,
142
+ height: r
143
+ });
144
+ }, [f]), b = I(() => {
145
+ f?.isResizing && (c.update(() => {
146
+ let e = t(s);
147
+ ue(e) && e.setWidthAndHeight(h.width, h.height);
148
+ }), p(null));
149
+ }, [
150
+ c,
151
+ s,
152
+ h,
153
+ f
154
+ ]);
155
+ F.useEffect(() => {
156
+ if (f?.isResizing) return document.addEventListener("mousemove", y), document.addEventListener("mouseup", b), () => {
157
+ document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", b);
158
+ };
159
+ }, [
160
+ f,
161
+ y,
162
+ b
163
+ ]);
164
+ let x = I(() => {
165
+ d(!0);
166
+ }, []);
167
+ return L(() => c.registerUpdateListener(({ editorState: e }) => {
168
+ e.read(() => {
169
+ let e = C();
170
+ u(e) && !e.getNodes().some((e) => e.getKey() === s || e.getParent() && e.getParent()?.getKey() === s) && l && d(!1);
171
+ });
172
+ }), [
173
+ c,
174
+ s,
175
+ l
176
+ ]), L(() => {
177
+ let e = (e) => {
178
+ l && m.current && !m.current.contains(e.target) && d(!1);
179
+ };
180
+ if (l) return document.addEventListener("mousedown", e), () => {
181
+ document.removeEventListener("mousedown", e);
182
+ };
183
+ }, [l]), /* @__PURE__ */ P("div", {
184
+ className: e(K.imageWrapper, {
185
+ [K.selected]: l,
186
+ [K.resizing]: f?.isResizing
187
+ }),
188
+ children: [/* @__PURE__ */ N("img", {
189
+ ref: m,
190
+ src: n,
191
+ alt: r,
192
+ className: K.image,
193
+ style: {
194
+ width: h.width,
195
+ height: h.height
196
+ },
197
+ onLoad: _,
198
+ onClick: x,
199
+ draggable: !1
200
+ }), l && /* @__PURE__ */ P(ce, { children: [
201
+ /* @__PURE__ */ N("div", {
202
+ className: e(K.resizeHandle, K.bottomRight),
203
+ onMouseDown: (e) => v(e, "bottom-right")
204
+ }),
205
+ /* @__PURE__ */ N("div", {
206
+ className: e(K.resizeHandle, K.bottomLeft),
207
+ onMouseDown: (e) => v(e, "bottom-left")
208
+ }),
209
+ /* @__PURE__ */ N("div", {
210
+ className: e(K.resizeHandle, K.topRight),
211
+ onMouseDown: (e) => v(e, "top-right")
212
+ }),
213
+ /* @__PURE__ */ N("div", {
214
+ className: e(K.resizeHandle, K.topLeft),
215
+ onMouseDown: (e) => v(e, "top-left")
216
+ })
217
+ ] })]
218
+ });
219
+ }, q = class e extends l {
220
+ static getType() {
221
+ return "image";
222
+ }
223
+ static clone(t) {
224
+ return new e(t.__src, t.__altText, t.__width, t.__height, t.__key);
225
+ }
226
+ constructor(e, t, n, r, i) {
227
+ super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r;
228
+ }
229
+ createDOM() {
230
+ let e = document.createElement("div");
231
+ return e.style.display = "inline-block", e;
232
+ }
233
+ updateDOM() {
234
+ return !1;
235
+ }
236
+ exportDOM() {
237
+ let e = document.createElement("img");
238
+ return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.style.maxWidth = "100%", e.style.display = "inline", e.style.verticalAlign = "baseline", this.__width && e.setAttribute("width", this.__width.toString()), this.__height && e.setAttribute("height", this.__height.toString()), { element: e };
239
+ }
240
+ getSrc() {
241
+ return this.__src;
242
+ }
243
+ getAltText() {
244
+ return this.__altText;
245
+ }
246
+ getWidth() {
247
+ return this.__width;
248
+ }
249
+ getHeight() {
250
+ return this.__height;
251
+ }
252
+ setSrc(e) {
253
+ let t = this.getWritable();
254
+ t.__src = e;
255
+ }
256
+ setAltText(e) {
257
+ let t = this.getWritable();
258
+ t.__altText = e;
259
+ }
260
+ setWidthAndHeight(e, t) {
261
+ let n = this.getWritable();
262
+ n.__width = e, n.__height = t;
263
+ }
264
+ decorate() {
265
+ return /* @__PURE__ */ N(le, {
266
+ src: this.__src,
267
+ altText: this.__altText,
268
+ width: this.__width,
269
+ height: this.__height,
270
+ nodeKey: this.getKey()
271
+ });
272
+ }
273
+ static importDOM() {
274
+ return { img: () => ({
275
+ conversion: Y,
276
+ priority: 0
277
+ }) };
278
+ }
279
+ static importJSON(e) {
280
+ let { src: t, altText: n, width: r, height: i } = e;
281
+ return J({
282
+ src: t,
283
+ altText: n,
284
+ width: r,
285
+ height: i
286
+ });
287
+ }
288
+ exportJSON() {
289
+ return {
290
+ src: this.getSrc(),
291
+ altText: this.getAltText(),
292
+ width: this.getWidth(),
293
+ height: this.getHeight(),
294
+ type: "image",
295
+ version: 1
296
+ };
297
+ }
298
+ isInline() {
299
+ return !0;
300
+ }
84
301
  };
85
- function Wt({ validateUrl: i, attributes: t }) {
86
- const [o] = N();
87
- return y((() => {
88
- if (!o.hasNodes([Z])) throw new Error("LinkPlugin: LinkNode not registered on editor");
89
- return it(o.registerCommand(X, ((e) => {
90
- if (e === null) return H(e), !0;
91
- if (typeof e == "string") return !(i !== void 0 && !i(e)) && (H(e, t), !0);
92
- {
93
- const { url: n, target: s, rel: a, title: l } = e;
94
- return H(n, { ...t, rel: a, target: s, title: l }), !0;
95
- }
96
- }), B), i !== void 0 ? o.registerCommand(ot, ((e) => {
97
- const n = F();
98
- if (!$(n) || n.isCollapsed() || !rt(e, ClipboardEvent) || e.clipboardData === null) return !1;
99
- const s = e.clipboardData.getData("text");
100
- return !!i(s) && !n.getNodes().some(((a) => G(a))) && (o.dispatchCommand(X, { ...t, url: s }), e.preventDefault(), !0);
101
- }), B) : () => {
102
- });
103
- }), [o, i, t]), null;
302
+ function J({ src: e, altText: t, width: n, height: r, key: i }) {
303
+ return new q(e, t, n, r, i);
104
304
  }
105
- const Ft = "_imageWrapper_y06h3_1", $t = "_selected_y06h3_8", Mt = "_resizing_y06h3_12", Ht = "_image_y06h3_1", It = "_resizeHandle_y06h3_30", Bt = "_topLeft_y06h3_44", zt = "_topRight_y06h3_49", Ot = "_bottomLeft_y06h3_54", At = "_bottomRight_y06h3_59", x = {
106
- imageWrapper: Ft,
107
- selected: $t,
108
- resizing: Mt,
109
- image: Ht,
110
- resizeHandle: It,
111
- topLeft: Bt,
112
- topRight: zt,
113
- bottomLeft: Ot,
114
- bottomRight: At
115
- }, Pt = ({
116
- src: i,
117
- altText: t,
118
- width: o,
119
- height: e,
120
- nodeKey: n
121
- }) => {
122
- const [s] = N(), [a, l] = S(!1), [r, m] = S(null), d = O(null), [g, f] = S({
123
- width: o || void 0,
124
- height: e || void 0
125
- }), _ = E(() => {
126
- o && e && f({ width: o, height: e });
127
- }, [o, e]), h = E(
128
- (c, b) => {
129
- if (c.preventDefault(), c.stopPropagation(), !d.current) return;
130
- const p = g.width || d.current.offsetWidth, T = g.height || d.current.offsetHeight, k = p / T;
131
- (!g.width || !g.height) && f({ width: p, height: T }), m({
132
- isResizing: !0,
133
- startX: c.clientX,
134
- startY: c.clientY,
135
- startWidth: p,
136
- startHeight: T,
137
- aspectRatio: k,
138
- direction: b
139
- });
140
- },
141
- [g]
142
- ), v = E(
143
- (c) => {
144
- if (!(r != null && r.isResizing)) return;
145
- const b = c.clientX - r.startX;
146
- let p;
147
- switch (r.direction) {
148
- case "bottom-right":
149
- p = Math.max(50, r.startWidth + b);
150
- break;
151
- case "bottom-left":
152
- p = Math.max(50, r.startWidth - b);
153
- break;
154
- case "top-right":
155
- p = Math.max(50, r.startWidth + b);
156
- break;
157
- case "top-left":
158
- p = Math.max(50, r.startWidth - b);
159
- break;
160
- default:
161
- p = Math.max(50, r.startWidth + b);
162
- }
163
- const T = p / r.aspectRatio;
164
- f({ width: p, height: T });
165
- },
166
- [r]
167
- ), w = E(() => {
168
- r != null && r.isResizing && (s.update(() => {
169
- const c = st(n);
170
- Ut(c) && c.setWidthAndHeight(g.width, g.height);
171
- }), m(null));
172
- }, [s, n, g, r]);
173
- wt.useEffect(() => {
174
- if (r != null && r.isResizing)
175
- return document.addEventListener("mousemove", v), document.addEventListener("mouseup", w), () => {
176
- document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", w);
177
- };
178
- }, [r, v, w]);
179
- const tt = E(() => {
180
- l(!0);
181
- }, []);
182
- return y(() => s.registerUpdateListener(({ editorState: c }) => {
183
- c.read(() => {
184
- const b = F();
185
- $(b) && !b.getNodes().some((k) => {
186
- var P;
187
- return k.getKey() === n || k.getParent() && ((P = k.getParent()) == null ? void 0 : P.getKey()) === n;
188
- }) && a && l(!1);
189
- });
190
- }), [s, n, a]), y(() => {
191
- const c = (b) => {
192
- a && d.current && !d.current.contains(b.target) && l(!1);
193
- };
194
- if (a)
195
- return document.addEventListener("mousedown", c), () => {
196
- document.removeEventListener("mousedown", c);
197
- };
198
- }, [a]), /* @__PURE__ */ W(
199
- "div",
200
- {
201
- className: R(x.imageWrapper, {
202
- [x.selected]: a,
203
- [x.resizing]: r == null ? void 0 : r.isResizing
204
- }),
205
- children: [
206
- /* @__PURE__ */ u(
207
- "img",
208
- {
209
- ref: d,
210
- src: i,
211
- alt: t,
212
- className: x.image,
213
- style: {
214
- width: g.width,
215
- height: g.height
216
- },
217
- onLoad: _,
218
- onClick: tt,
219
- draggable: !1
220
- }
221
- ),
222
- a && /* @__PURE__ */ W(et, { children: [
223
- /* @__PURE__ */ u(
224
- "div",
225
- {
226
- className: R(x.resizeHandle, x.bottomRight),
227
- onMouseDown: (c) => h(c, "bottom-right")
228
- }
229
- ),
230
- /* @__PURE__ */ u(
231
- "div",
232
- {
233
- className: R(x.resizeHandle, x.bottomLeft),
234
- onMouseDown: (c) => h(c, "bottom-left")
235
- }
236
- ),
237
- /* @__PURE__ */ u(
238
- "div",
239
- {
240
- className: R(x.resizeHandle, x.topRight),
241
- onMouseDown: (c) => h(c, "top-right")
242
- }
243
- ),
244
- /* @__PURE__ */ u(
245
- "div",
246
- {
247
- className: R(x.resizeHandle, x.topLeft),
248
- onMouseDown: (c) => h(c, "top-left")
249
- }
250
- )
251
- ] })
252
- ]
253
- }
254
- );
255
- };
256
- class D extends at {
257
- static getType() {
258
- return "image";
259
- }
260
- static clone(t) {
261
- return new D(t.__src, t.__altText, t.__width, t.__height, t.__key);
262
- }
263
- constructor(t, o, e, n, s) {
264
- super(s), this.__src = t, this.__altText = o || "", this.__width = e, this.__height = n;
265
- }
266
- createDOM() {
267
- const t = document.createElement("div");
268
- return t.style.display = "inline-block", t;
269
- }
270
- updateDOM() {
271
- return !1;
272
- }
273
- exportDOM() {
274
- const t = document.createElement("img");
275
- return t.setAttribute("src", this.__src), t.setAttribute("alt", this.__altText), t.style.maxWidth = "100%", t.style.display = "inline", t.style.verticalAlign = "baseline", this.__width && t.setAttribute("width", this.__width.toString()), this.__height && t.setAttribute("height", this.__height.toString()), { element: t };
276
- }
277
- getSrc() {
278
- return this.__src;
279
- }
280
- getAltText() {
281
- return this.__altText;
282
- }
283
- getWidth() {
284
- return this.__width;
285
- }
286
- getHeight() {
287
- return this.__height;
288
- }
289
- setSrc(t) {
290
- const o = this.getWritable();
291
- o.__src = t;
292
- }
293
- setAltText(t) {
294
- const o = this.getWritable();
295
- o.__altText = t;
296
- }
297
- setWidthAndHeight(t, o) {
298
- const e = this.getWritable();
299
- e.__width = t, e.__height = o;
300
- }
301
- decorate() {
302
- return /* @__PURE__ */ u(
303
- Pt,
304
- {
305
- src: this.__src,
306
- altText: this.__altText,
307
- width: this.__width,
308
- height: this.__height,
309
- nodeKey: this.getKey()
310
- }
311
- );
312
- }
313
- static importDOM() {
314
- return {
315
- img: () => ({
316
- conversion: Jt,
317
- priority: 0
318
- })
319
- };
320
- }
321
- static importJSON(t) {
322
- const { src: o, altText: e, width: n, height: s } = t;
323
- return A({ src: o, altText: e, width: n, height: s });
324
- }
325
- exportJSON() {
326
- return {
327
- src: this.getSrc(),
328
- altText: this.getAltText(),
329
- width: this.getWidth(),
330
- height: this.getHeight(),
331
- type: "image",
332
- version: 1
333
- };
334
- }
335
- isInline() {
336
- return !0;
337
- }
338
- }
339
- function A({ src: i, altText: t, width: o, height: e, key: n }) {
340
- return new D(i, t, o, e, n);
341
- }
342
- function Ut(i) {
343
- return i instanceof D;
305
+ function ue(e) {
306
+ return e instanceof q;
344
307
  }
345
- function Jt(i) {
346
- if (i instanceof HTMLImageElement) {
347
- const { src: t, alt: o, style: e } = i;
348
- let n, s;
349
- if (e.width) {
350
- const l = parseInt(e.width, 10);
351
- isNaN(l) || (n = l);
352
- }
353
- if (e.height) {
354
- const l = parseInt(e.height, 10);
355
- isNaN(l) || (s = l);
356
- }
357
- return n === void 0 && i.width && (n = i.width), s === void 0 && i.height && (s = i.height), { node: A({
358
- src: t,
359
- altText: o,
360
- width: n,
361
- height: s
362
- }) };
363
- }
364
- return null;
308
+ function Y(e) {
309
+ if (e instanceof HTMLImageElement) {
310
+ let { src: t, alt: n, style: r } = e, i, a;
311
+ if (r.width) {
312
+ let e = parseInt(r.width, 10);
313
+ isNaN(e) || (i = e);
314
+ }
315
+ if (r.height) {
316
+ let e = parseInt(r.height, 10);
317
+ isNaN(e) || (a = e);
318
+ }
319
+ return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: J({
320
+ src: t,
321
+ altText: n,
322
+ width: i,
323
+ height: a
324
+ }) };
325
+ }
326
+ return null;
365
327
  }
366
- function Xt() {
367
- const [i] = N();
368
- return y(() => i.registerCommand(
369
- Nt,
370
- (t) => {
371
- const o = A(t);
372
- return V([o]), !0;
373
- },
374
- lt
375
- ), [i]), null;
328
+ //#endregion
329
+ //#region src/components/Editor/plugins/ImagePlugin.tsx
330
+ function de() {
331
+ let [e] = i();
332
+ return L(() => e.registerCommand(ae, (e) => (S([J(e)]), !0), 0), [e]), null;
376
333
  }
377
- function jt() {
378
- const [i] = N(), t = O(0), o = 250;
379
- return y(() => i.registerCommand(
380
- ct,
381
- (e) => {
382
- const n = Date.now(), s = n - t.current;
383
- return t.current = n, s < o && s > 0 ? (i.update(() => {
384
- const a = F();
385
- if ($(a)) {
386
- const r = a.anchor.getNode().getTopLevelElement();
387
- if (r && r.getTextContent().trim() === "") {
388
- const m = ut();
389
- dt(a, {
390
- "background-color": "",
391
- color: "",
392
- "font-size": "",
393
- "font-weight": "",
394
- "font-style": "",
395
- "text-decoration": ""
396
- }), r.replace(m), m.select();
397
- const d = m.getPreviousSibling();
398
- d && d.getTextContent().trim() === "" && d.remove();
399
- }
400
- }
401
- }), e == null || e.preventDefault(), !0) : !1;
402
- },
403
- B
404
- ), [i]), null;
334
+ //#endregion
335
+ //#region src/components/Editor/plugins/EnterKeyPlugin.tsx
336
+ function fe() {
337
+ let [e] = i(), t = z(0);
338
+ return L(() => e.registerCommand(p, (n) => {
339
+ let r = Date.now(), i = r - t.current;
340
+ return t.current = r, i < 250 && i > 0 ? (e.update(() => {
341
+ let e = C();
342
+ if (u(e)) {
343
+ let t = e.anchor.getNode().getTopLevelElement();
344
+ if (t && t.getTextContent().trim() === "") {
345
+ let n = w();
346
+ _(e, {
347
+ "background-color": "",
348
+ color: "",
349
+ "font-size": "",
350
+ "font-weight": "",
351
+ "font-style": "",
352
+ "text-decoration": ""
353
+ }), t.replace(n), n.select();
354
+ let r = n.getPreviousSibling();
355
+ r && r.getTextContent().trim() === "" && r.remove();
356
+ }
357
+ }
358
+ }), n?.preventDefault(), !0) : !1;
359
+ }, 1), [e]), null;
405
360
  }
406
- const Q = (i) => {
407
- var d;
408
- const { height: t = 126, onChange: o, toolbar: e } = i, [n] = N(), s = O(null), a = E(
409
- (g) => {
410
- g.read(() => {
411
- const _ = J().getTextContent(), h = ht(n, null), w = !_.trim() && (h === "<p><br></p>" || h === "<p></p>" || h === "" || /^<p>\s*<br>\s*<\/p>$/.test(h)) ? null : h;
412
- s.current = w, o(
413
- {
414
- text: _,
415
- html: w
416
- },
417
- g
418
- );
419
- });
420
- },
421
- [o, n]
422
- );
423
- y(() => {
424
- i.value !== void 0 && i.value !== s.current && n.update(() => {
425
- if (J().clear(), i.value && i.value.trim()) {
426
- const f = new DOMParser().parseFromString(i.value, "text/html"), _ = gt(n, f);
427
- V(_);
428
- }
429
- });
430
- }, [i.value, n]);
431
- const l = (d = e == null ? void 0 : e.config) != null && d.length ? e == null ? void 0 : e.config : [], r = n.isEditable(), m = () => {
432
- r || (n.setEditable(!0), n.focus(() => {
433
- }, { defaultSelection: "rootEnd" }));
434
- };
435
- return /* @__PURE__ */ W("div", { className: q["bsy-lexical-editor"], onClick: m, children: [
436
- l.length > 0 && /* @__PURE__ */ u(
437
- St,
438
- {
439
- config: l,
440
- style: {
441
- ...e == null ? void 0 : e.style
442
- }
443
- }
444
- ),
445
- /* @__PURE__ */ u(
446
- mt,
447
- {
448
- contentEditable: /* @__PURE__ */ u(
449
- _t,
450
- {
451
- className: q["bsy-lexical-editor__content-editable"],
452
- style: {
453
- height: t,
454
- cursor: r ? "auto" : "text"
455
- }
456
- }
457
- ),
458
- ErrorBoundary: ft
459
- }
460
- ),
461
- /* @__PURE__ */ u(Wt, {}),
462
- /* @__PURE__ */ u(Xt, {}),
463
- /* @__PURE__ */ u(jt, {}),
464
- /* @__PURE__ */ u(bt, {}),
465
- /* @__PURE__ */ u(pt, { onChange: a })
466
- ] });
361
+ //#endregion
362
+ //#region src/components/Editor/EditorCore.tsx
363
+ var X = (e) => {
364
+ let { height: t = 126, onChange: n, toolbar: r } = e, [a] = i(), o = z(null), s = z(null), l = R(() => ({
365
+ containerRef: o,
366
+ getPopupContainer: () => o.current || document.body
367
+ }), []), u = I((e) => {
368
+ e.read(() => {
369
+ let t = c().getTextContent(), r = ee(a, null), i = !t.trim() && (r === "<p><br></p>" || r === "<p></p>" || r === "" || /^<p>\s*<br>\s*<\/p>$/.test(r)) ? null : r;
370
+ s.current = i, n({
371
+ text: t,
372
+ html: i
373
+ }, e);
374
+ });
375
+ }, [n, a]);
376
+ L(() => {
377
+ e.value !== void 0 && e.value !== s.current && a.update(() => {
378
+ c().clear(), e.value && e.value.trim() && S(b(a, new DOMParser().parseFromString(e.value, "text/html")));
379
+ });
380
+ }, [e.value, a]);
381
+ let d = r?.config?.length ? r?.config : [], f = a.isEditable();
382
+ return /* @__PURE__ */ N(se.Provider, {
383
+ value: l,
384
+ children: /* @__PURE__ */ P("div", {
385
+ ref: o,
386
+ className: G["bsy-lexical-editor"],
387
+ onClick: () => {
388
+ f || (a.setEditable(!0), a.focus(() => {}, { defaultSelection: "rootEnd" }));
389
+ },
390
+ children: [
391
+ d.length > 0 && /* @__PURE__ */ N(W, {
392
+ config: d,
393
+ style: { ...r?.style }
394
+ }),
395
+ /* @__PURE__ */ N(g, {
396
+ contentEditable: /* @__PURE__ */ N(h, {
397
+ className: G["bsy-lexical-editor__content-editable"],
398
+ style: {
399
+ height: t,
400
+ cursor: f ? "auto" : "text"
401
+ }
402
+ }),
403
+ ErrorBoundary: m
404
+ }),
405
+ /* @__PURE__ */ N(ne, {}),
406
+ /* @__PURE__ */ N(de, {}),
407
+ /* @__PURE__ */ N(fe, {}),
408
+ /* @__PURE__ */ N(re, {}),
409
+ /* @__PURE__ */ N(y, { onChange: u })
410
+ ]
411
+ })
412
+ });
467
413
  };
468
- Q.displayName = "BsyLexicalEditorCore";
469
- class L extends z {
470
- constructor(t, o) {
471
- super(t, o);
472
- }
473
- static getType() {
474
- return "extended-text";
475
- }
476
- static clone(t) {
477
- return new L(t.__text, t.__key);
478
- }
479
- static importDOM() {
480
- const t = z.importDOM();
481
- return {
482
- ...t,
483
- code: () => ({
484
- conversion: C(t == null ? void 0 : t.code),
485
- priority: 1
486
- }),
487
- em: () => ({
488
- conversion: C(t == null ? void 0 : t.em),
489
- priority: 1
490
- }),
491
- span: () => ({
492
- conversion: C(t == null ? void 0 : t.span),
493
- priority: 1
494
- }),
495
- strong: () => ({
496
- conversion: C(t == null ? void 0 : t.strong),
497
- priority: 1
498
- }),
499
- sub: () => ({
500
- conversion: C(t == null ? void 0 : t.sub),
501
- priority: 1
502
- }),
503
- sup: () => ({
504
- conversion: C(t == null ? void 0 : t.sup),
505
- priority: 1
506
- })
507
- };
508
- }
509
- static importJSON(t) {
510
- return Kt().updateFromJSON(t);
511
- }
512
- isSimpleText() {
513
- return this.__type === "extended-text" && this.__mode === 0;
514
- }
515
- // no need to add exportJSON here, since we are not adding any new properties
516
- }
517
- function Kt(i = "") {
518
- return yt(new L(i));
414
+ X.displayName = "BsyLexicalEditorCore";
415
+ //#endregion
416
+ //#region src/components/Editor/nodes/ExtendedTextNode.tsx
417
+ var Z = class e extends a {
418
+ constructor(e, t) {
419
+ super(e, t);
420
+ }
421
+ static getType() {
422
+ return "extended-text";
423
+ }
424
+ static clone(t) {
425
+ return new e(t.__text, t.__key);
426
+ }
427
+ static importDOM() {
428
+ let e = a.importDOM();
429
+ return {
430
+ ...e,
431
+ code: () => ({
432
+ conversion: Q(e?.code),
433
+ priority: 1
434
+ }),
435
+ em: () => ({
436
+ conversion: Q(e?.em),
437
+ priority: 1
438
+ }),
439
+ span: () => ({
440
+ conversion: Q(e?.span),
441
+ priority: 1
442
+ }),
443
+ strong: () => ({
444
+ conversion: Q(e?.strong),
445
+ priority: 1
446
+ }),
447
+ sub: () => ({
448
+ conversion: Q(e?.sub),
449
+ priority: 1
450
+ }),
451
+ sup: () => ({
452
+ conversion: Q(e?.sup),
453
+ priority: 1
454
+ })
455
+ };
456
+ }
457
+ static importJSON(e) {
458
+ return pe().updateFromJSON(e);
459
+ }
460
+ isSimpleText() {
461
+ return this.__type === "extended-text" && this.__mode === 0;
462
+ }
463
+ };
464
+ function pe(e = "") {
465
+ return s(new Z(e));
519
466
  }
520
- function C(i) {
521
- return (t) => {
522
- const o = i == null ? void 0 : i(t);
523
- if (!o)
524
- return null;
525
- const e = o.conversion(t);
526
- if (!e)
527
- return e;
528
- const n = t.style.backgroundColor, s = t.style.color, a = t.style.fontFamily, l = t.style.fontWeight, r = t.style.fontSize, m = t.style.textDecoration;
529
- return {
530
- ...e,
531
- forChild: (d, g) => {
532
- const _ = ((e == null ? void 0 : e.forChild) ?? ((h) => h))(d, g);
533
- if (xt(_)) {
534
- const h = [
535
- n ? `background-color: ${n}` : null,
536
- s ? `color: ${s}` : null,
537
- a ? `font-family: ${a}` : null,
538
- l ? `font-weight: ${l}` : null,
539
- r ? `font-size: ${r}` : null,
540
- m ? `text-decoration: ${m}` : null
541
- ].filter((v) => v !== null).join("; ");
542
- if (h.length)
543
- return _.setStyle(h);
544
- }
545
- return _;
546
- }
547
- };
548
- };
467
+ function Q(e) {
468
+ return (t) => {
469
+ let n = e?.(t);
470
+ if (!n) return null;
471
+ let r = n.conversion(t);
472
+ if (!r) return r;
473
+ let i = t.style.backgroundColor, a = t.style.color, s = t.style.fontFamily, c = t.style.fontWeight, l = t.style.fontSize, u = t.style.textDecoration;
474
+ return {
475
+ ...r,
476
+ forChild: (e, t) => {
477
+ let n = (r?.forChild ?? ((e) => e))(e, t);
478
+ if (o(n)) {
479
+ let e = [
480
+ i ? `background-color: ${i}` : null,
481
+ a ? `color: ${a}` : null,
482
+ s ? `font-family: ${s}` : null,
483
+ c ? `font-weight: ${c}` : null,
484
+ l ? `font-size: ${l}` : null,
485
+ u ? `text-decoration: ${u}` : null
486
+ ].filter((e) => e !== null).join("; ");
487
+ if (e.length) return n.setStyle(e);
488
+ }
489
+ return n;
490
+ }
491
+ };
492
+ };
549
493
  }
550
- const Yt = (i) => {
551
- const { autoFocus: t = !1 } = i, o = Tt(() => ({
552
- namespace: "bsyLexicalEditor",
553
- onError: (e) => {
554
- console.error("Lexical error", e);
555
- },
556
- editable: t,
557
- theme: {
558
- text: {
559
- bold: "editor-text-bold",
560
- italic: "editor-text-italic",
561
- underline: "editor-text-underline"
562
- },
563
- link: "editor-link"
564
- },
565
- nodes: [
566
- Z,
567
- kt,
568
- D,
569
- L,
570
- {
571
- replace: z,
572
- with: (e) => new L(e.__text),
573
- withKlass: L
574
- }
575
- ]
576
- }), [t]);
577
- return /* @__PURE__ */ u(vt, { initialConfig: o, children: /* @__PURE__ */ u(Q, { ...i }) });
578
- };
579
- Yt.displayName = "BsyLexicalEditor";
580
- export {
581
- J as $getRoot,
582
- ie as BaseButton,
583
- Yt as default,
584
- oe as listRegisteredToolbarButtons,
585
- re as registerToolbarButton,
586
- se as unregisterToolbarButton,
587
- N as useLexicalComposerContext
494
+ //#endregion
495
+ //#region src/components/Editor/Editor.tsx
496
+ var $ = (e) => {
497
+ let { autoFocus: t = !1 } = e;
498
+ return /* @__PURE__ */ N(ie, {
499
+ initialConfig: R(() => ({
500
+ namespace: "bsyLexicalEditor",
501
+ onError: (e) => {
502
+ console.error("Lexical error", e);
503
+ },
504
+ editable: t,
505
+ theme: {
506
+ text: {
507
+ bold: "editor-text-bold",
508
+ italic: "editor-text-italic",
509
+ underline: "editor-text-underline"
510
+ },
511
+ link: "editor-link"
512
+ },
513
+ nodes: [
514
+ te,
515
+ f,
516
+ q,
517
+ Z,
518
+ {
519
+ replace: a,
520
+ with: (e) => new Z(e.__text),
521
+ withKlass: Z
522
+ }
523
+ ]
524
+ }), [t]),
525
+ children: /* @__PURE__ */ N(X, { ...e })
526
+ });
588
527
  };
528
+ $.displayName = "BsyLexicalEditor";
529
+ //#endregion
530
+ export { c as $getRoot, E as BaseButton, $ as default, oe as listRegisteredToolbarButtons, D as registerToolbarButton, T as unregisterToolbarButton, i as useLexicalComposerContext };