@baishuyun/ui-base 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Card/Card-BE6v4I-A.js +69 -0
- package/dist/Card/index.js +3 -4
- package/dist/CheckBox/CheckBox--rXaUgMO.js +67 -0
- package/dist/CheckBox/CheckBox-Db8X-pw9.js +33 -0
- package/dist/CheckBox/index.js +4 -39
- package/dist/ColorPicker/ColorPicker-BBP-4-so.js +168 -0
- package/dist/ColorPicker/index.js +6 -5
- package/dist/DropDown/DropDown-CKXi9mXN.js +162 -0
- package/dist/DropDown/index.js +7 -4
- package/dist/Editor/Buttons--dMLPuk2.js +595 -0
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +14 -8
- package/dist/Editor/constants/index.js +53 -20
- package/dist/Editor/index.js +518 -576
- package/dist/Icon/Icon-DppVOyPK.js +19 -0
- package/dist/Icon/index.js +2 -4
- package/dist/InputTag/InputTag-B6N5MZA2.js +139 -0
- package/dist/InputTag/index.js +3 -4
- package/dist/Loading/Loading-Bi5NO-Ky.js +15 -0
- package/dist/Loading/index.js +2 -4
- package/dist/Modal/Modal-FVJpbEgw.js +81 -0
- package/dist/Modal/index.js +3 -4
- package/dist/NotFoundContent/NotFoundContent-CTPpcZOt.js +9 -0
- package/dist/NotFoundContent/index.js +2 -4
- package/dist/Radio/Radio-dyoBNiKF.js +85 -0
- package/dist/Radio/index.js +2 -105
- package/dist/Segmented/Segmented-Dd8glDXI.js +62 -0
- package/dist/Segmented/index.js +2 -4
- package/dist/Select/Select-Bd2ECrB0.js +729 -0
- package/dist/Select/SelectInputSearch-CIXBNLFi.js +46 -0
- package/dist/Select/index.js +11 -6
- package/dist/Tabs/Tabs-C79GTyGd.js +410 -0
- package/dist/Tabs/index.js +6 -7
- package/dist/Tree/index.js +5 -4
- package/dist/Tree/utils/index.js +24 -39
- package/dist/components/Editor/context/EditorContainerContext.d.ts +8 -0
- package/dist/index.js +103 -81
- package/dist/style.css +2 -1
- package/dist/vendors/Tree-CQR9fvpA.js +231 -0
- package/dist/vendors/animations-C5JKFkz4.js +38 -0
- package/dist/vendors/clsx-DNOE4Gl8.js +16 -0
- package/dist/vendors/color-BPWy9DvT.js +12 -0
- package/dist/vendors/fuse.js-BKtvbTjL.js +877 -0
- package/dist/vendors/lexical-hZliMgDv.js +6439 -0
- package/dist/vendors/lodash-es-Bu9xU1fK.js +334 -0
- package/dist/vendors/simplebar-react-CFlS-Nm9.js +370 -0
- package/dist/vendors/tinycolor2-DToeAEPD.js +726 -0
- package/dist/vendors/useFloatingPortal-BA6P5GxV.js +45 -0
- package/dist/vendors/useLocale-BfT0V1j4.js +75 -0
- package/package.json +3 -3
- package/dist/Card/Card-Y1ISqAp9.js +0 -86
- package/dist/CheckBox/CheckBox-C9sXWSA5.js +0 -84
- package/dist/ColorPicker/ColorPicker-D0D5azon.js +0 -216
- package/dist/DropDown/DropDown-DGkSeXQT.js +0 -166
- package/dist/Editor/index-C0Rjz8DK.js +0 -846
- package/dist/Icon/Icon-CBlIwtp2.js +0 -24
- package/dist/InputTag/InputTag-C-rQUJnF.js +0 -155
- package/dist/Loading/Loading-CEB4PLUE.js +0 -9
- package/dist/Modal/Modal-z3TvEXwN.js +0 -80
- package/dist/NotFoundContent/NotFoundContent-h0-oIXlk.js +0 -6
- package/dist/Segmented/Segmented-UgzW78Ey.js +0 -75
- package/dist/Select/Select-hwXXDuLU.js +0 -820
- package/dist/Select/SelectInputSearch-ChUpUgxa.js +0 -34
- package/dist/Tabs/TabSelect-DL8Bhehc.js +0 -445
- package/dist/vendors/Tree-CLEy-xqz.js +0 -235
- package/dist/vendors/clsx-OuTLNxxd.js +0 -16
- package/dist/vendors/color-VzwvCPhF.js +0 -21
- package/dist/vendors/fuse.js-D1DCbUBb.js +0 -1022
- package/dist/vendors/index-MTmG1Ezy.js +0 -15
- package/dist/vendors/lexical-DO7eMeC2.js +0 -5891
- package/dist/vendors/lodash-es-DFpaJB4Y.js +0 -305
- package/dist/vendors/simplebar-react-D68KzE44.js +0 -408
- package/dist/vendors/tinycolor2-Begv3Jc8.js +0 -711
- package/dist/vendors/useFloatingPortal-9VUFOAOG.js +0 -45
- package/dist/vendors/useLocale-DgqW9M3h.js +0 -47
package/dist/Editor/index.js
CHANGED
|
@@ -1,588 +1,530 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import "../Icon/Icon-DppVOyPK.js";
|
|
2
|
+
import "../vendors/useLocale-BfT0V1j4.js";
|
|
3
|
+
import { t as e } from "../vendors/clsx-DNOE4Gl8.js";
|
|
4
|
+
import "../Modal/Modal-FVJpbEgw.js";
|
|
5
|
+
import "../ColorPicker/ColorPicker-BBP-4-so.js";
|
|
6
|
+
import "../vendors/tinycolor2-DToeAEPD.js";
|
|
7
|
+
import "../vendors/color-BPWy9DvT.js";
|
|
8
|
+
import "../Select/SelectInputSearch-CIXBNLFi.js";
|
|
9
|
+
import "../CheckBox/CheckBox--rXaUgMO.js";
|
|
10
|
+
import "../CheckBox/CheckBox-Db8X-pw9.js";
|
|
11
|
+
import "../NotFoundContent/NotFoundContent-CTPpcZOt.js";
|
|
12
|
+
import "../vendors/useFloatingPortal-BA6P5GxV.js";
|
|
13
|
+
import "../DropDown/DropDown-CKXi9mXN.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--dMLPuk2.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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
86
|
-
|
|
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
|
-
|
|
106
|
-
|
|
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
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
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
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
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 };
|