@baishuyun/ui-base 6.8.2 → 6.9.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.
- package/dist/Amap/AmapCircle/index.js +1 -1
- package/dist/Amap/AmapMarker/index.js +1 -1
- package/dist/Amap/AmapMarkerCluster/index.js +1 -1
- package/dist/Amap/AmapProvider/index.js +1 -1
- package/dist/Amap/hooks/index.js +1 -1
- package/dist/Amap/index.js +1 -1
- package/dist/Calendar/{Calendar-DnQrN8KB.js → Calendar-MghsGFZ0.js} +1 -1
- package/dist/Calendar/context/index.js +1 -1
- package/dist/Calendar/index.js +3 -3
- package/dist/Calendar/subcomponents/AllDaySection/index.js +1 -1
- package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +1 -1
- package/dist/Calendar/subcomponents/EventCard/index.js +1 -1
- package/dist/Calendar/subcomponents/TimeAxis/index.js +1 -1
- package/dist/Calendar/subcomponents/TimeGrid/index.js +1 -1
- package/dist/Calendar/utils/index.js +1 -1
- package/dist/Calendar/utils/layout/index.js +1 -1
- package/dist/Calendar/utils/theme/index.js +1 -1
- package/dist/Card/index.js +1 -1
- package/dist/CheckBox/index.js +1 -1
- package/dist/ColorPicker/{ColorPicker-CL57cSDG.js → ColorPicker-t1uBeATW.js} +14 -12
- package/dist/ColorPicker/index.js +2 -2
- package/dist/ConfigProvider/index.js +1 -1
- package/dist/DatePicker/{DatePicker-C0XbZmrZ.js → DatePicker-uizefM92.js} +1 -1
- package/dist/DatePicker/{DatePickerPanel-BEn16cat.js → DatePickerPanel-bbGVwlo7.js} +1 -1
- package/dist/DatePicker/index.js +2 -2
- package/dist/DatePicker/style/index.js +1 -1
- package/dist/DropDown/index.js +1 -1
- package/dist/DropDown/style/index.js +1 -1
- package/dist/Editor/{Buttons-BivKInBV.js → Buttons-BhStZyIa.js} +2 -2
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +3 -3
- package/dist/Editor/constants/index.js +1 -1
- package/dist/Editor/index.js +215 -187
- package/dist/Gantt/GanttChart/index.js +1 -1
- package/dist/Gantt/GanttTable/index.js +1 -1
- package/dist/Gantt/GanttToolBar/index.js +1 -1
- package/dist/Gantt/index.js +1 -1
- package/dist/Gantt/utils/index.js +1 -1
- package/dist/Gantt/utils/theme/index.js +1 -1
- package/dist/Icon/index.js +1 -1
- package/dist/InputTag/index.js +1 -1
- package/dist/Loading/index.js +1 -1
- package/dist/Modal/index.js +1 -1
- package/dist/NotFoundContent/index.js +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/ScrollBar/index.js +1 -1
- package/dist/Segmented/index.js +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/Table/hooks/index.js +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/Table/style/index.js +1 -1
- package/dist/Table/utils/index.js +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/Tooltip/index.js +1 -1
- package/dist/Tree/index.js +1 -1
- package/dist/Tree/utils/index.js +1 -1
- package/dist/components/ColorPicker/ColorPicker.type.d.ts +1 -1
- package/dist/components/Editor/ToolbarPlugin/ToolbarPlugin.d.ts +2 -3
- package/dist/components/Editor/context/EditorContainerContext.d.ts +1 -0
- package/dist/components/Editor/index.d.ts +1 -1
- package/dist/components/Editor/interface.d.ts +26 -8
- package/dist/components/Editor/utils/resolveFloatingToolbarStyle.d.ts +3 -0
- package/dist/index.js +4 -4
- package/dist/style.css +1 -1
- package/dist/vendors/{version-4HBYLKDL.js → version-D76DufO-.js} +1 -1
- package/package.json +1 -1
package/dist/Editor/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-D76DufO-.js";
|
|
2
2
|
import "../ScrollBar/style-D26azwz6.js";
|
|
3
3
|
import "../Icon/Icon-BBDcb-yw.js";
|
|
4
4
|
import "../vendors/LocaleContext-Dcw6C1LX.js";
|
|
5
5
|
import "../Modal/Modal-LiztSF7x.js";
|
|
6
|
-
import "../ColorPicker/ColorPicker-
|
|
6
|
+
import "../ColorPicker/ColorPicker-t1uBeATW.js";
|
|
7
7
|
import "../vendors/useFloatingOverlay-BApqkHSu.js";
|
|
8
8
|
import "../vendors/useLocale-BKZX2_zw.js";
|
|
9
9
|
import "../vendors/color-D6XBXROa.js";
|
|
@@ -17,67 +17,79 @@ import "../ScrollBar/ScrollBar-QhXVe8zd.js";
|
|
|
17
17
|
import "../vendors/useFloatingPortal-CmVJbuRm.js";
|
|
18
18
|
import "../DropDown/DropDown-yDH9V_9Y.js";
|
|
19
19
|
import "../DropDown/style-Fdp-U4md.js";
|
|
20
|
-
import { a as t, c as n,
|
|
21
|
-
import { DEFAULT_BACKGROUND_COLOR as
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import S from "
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import { $
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { $
|
|
36
|
-
import { $
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
20
|
+
import { a as t, c as n, d as r, i, l as a, n as o, o as s, r as c, s as l, u } from "./Buttons-BhStZyIa.js";
|
|
21
|
+
import { DEFAULT_BACKGROUND_COLOR as d, DEFAULT_FONT_COLOR as f, DEFAULT_FONT_SIZE as p } from "./constants/index.js";
|
|
22
|
+
import { omit as m } from "lodash-es";
|
|
23
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
24
|
+
import v, { useCallback as y, useEffect as b, useMemo as x, useRef as S, useState as C } from "react";
|
|
25
|
+
import w from "clsx";
|
|
26
|
+
import { LexicalComposer as T } from "@lexical/react/LexicalComposer";
|
|
27
|
+
import { RichTextPlugin as E } from "@lexical/react/LexicalRichTextPlugin";
|
|
28
|
+
import { ContentEditable as ee } from "@lexical/react/LexicalContentEditable";
|
|
29
|
+
import { HistoryPlugin as te } from "@lexical/react/LexicalHistoryPlugin";
|
|
30
|
+
import { OnChangePlugin as ne } from "@lexical/react/LexicalOnChangePlugin";
|
|
31
|
+
import { LexicalErrorBoundary as D } from "@lexical/react/LexicalErrorBoundary";
|
|
32
|
+
import { $generateHtmlFromNodes as re, $generateNodesFromDOM as ie } from "@lexical/html";
|
|
33
|
+
import { $applyNodeReplacement as O, $createParagraphNode as k, $getNodeByKey as A, $getRoot as j, $getRoot as M, $getSelection as N, $insertNodes as P, $isElementNode as ae, $isRangeSelection as F, $isRootOrShadowRoot as oe, $isTextNode as se, COMMAND_PRIORITY_EDITOR as ce, COMMAND_PRIORITY_LOW as le, DecoratorNode as ue, KEY_ENTER_COMMAND as de, RootNode as fe, TextNode as I } from "lexical";
|
|
34
|
+
import { useLexicalComposerContext as pe, useLexicalComposerContext as L } from "@lexical/react/LexicalComposerContext";
|
|
35
|
+
import { $getSelectionStyleValueForProperty as R, $patchStyleText as z, $trimTextContentFromAnchor as B } from "@lexical/selection";
|
|
36
|
+
import { $findMatchingParent as V, $restoreEditorState as me } from "@lexical/utils";
|
|
37
|
+
import { $isLinkNode as he, AutoLinkNode as ge, LinkNode as _e } from "@lexical/link";
|
|
38
|
+
import { useLexicalEditable as ve } from "@lexical/react/useLexicalEditable";
|
|
39
|
+
import { LinkPlugin as ye } from "@lexical/react/LexicalLinkPlugin";
|
|
39
40
|
//#region src/components/Editor/utils/resolveEditorToolbarThemeVars.ts
|
|
40
41
|
var H = (e) => {
|
|
41
42
|
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
42
|
-
},
|
|
43
|
+
}, be = (t) => {
|
|
43
44
|
if (!t) return {};
|
|
44
45
|
let n = {};
|
|
45
46
|
return e(n, "--bsy-editor-toolbar-bg", t.bg), e(n, "--bsy-editor-toolbar-border-color", t.borderColor), e(n, "--bsy-editor-toolbar-padding", t.padding), e(n, "--bsy-editor-toolbar-gap", H(t.gap)), e(n, "--bsy-editor-toolbar-group-gap", H(t.groupGap)), e(n, "--bsy-editor-toolbar-divider-color", t.dividerColor), e(n, "--bsy-editor-toolbar-divider-size", H(t.dividerSize)), e(n, "--bsy-editor-toolbar-divider-margin", H(t.dividerMargin)), e(n, "--bsy-editor-toolbar-color-icon", t.colorIcon), e(n, "--bsy-editor-toolbar-item-hover-bg", t.itemHoverBg), e(n, "--bsy-editor-toolbar-item-hover-color", t.itemHoverColor), e(n, "--bsy-editor-toolbar-item-active-bg", t.itemActiveBg), e(n, "--bsy-editor-toolbar-item-active-color", t.itemActiveColor), e(n, "--bsy-editor-toolbar-item-padding", H(t.itemPadding)), e(n, "--bsy-editor-toolbar-item-border-radius", H(t.itemBorderRadius)), e(n, "--bsy-editor-toolbar-icon-size", H(t.iconSize)), n;
|
|
46
|
-
},
|
|
47
|
+
}, xe = (e) => {
|
|
47
48
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
48
49
|
if (typeof e == "string") {
|
|
49
50
|
let t = Number.parseFloat(e);
|
|
50
51
|
if (Number.isFinite(t)) return t;
|
|
51
52
|
}
|
|
52
53
|
return 14;
|
|
53
|
-
},
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
}, Se = (e) => {
|
|
55
|
+
let t = e?.placement ?? "top", n = e?.offset, r = typeof n == "number" ? 0 : n?.x ?? 0, i = typeof n == "number" ? n : n?.y ?? 0, a = t === "top", o = {
|
|
56
|
+
position: "absolute",
|
|
57
|
+
[a ? "bottom" : "top"]: "100%",
|
|
58
|
+
[a ? "marginBottom" : "marginTop"]: i,
|
|
59
|
+
left: 0,
|
|
60
|
+
right: 0,
|
|
61
|
+
width: "100%"
|
|
62
|
+
};
|
|
63
|
+
return r && (o.transform = `translateX(${r}px)`), o;
|
|
64
|
+
}, U = {
|
|
65
|
+
"bsy-lexical__toolbar": "_bsy-lexical__toolbar_3xekt_1",
|
|
66
|
+
"bsy-lexical__toolbar--floating": "_bsy-lexical__toolbar--floating_3xekt_10",
|
|
67
|
+
"bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_3xekt_16",
|
|
68
|
+
"bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_3xekt_22"
|
|
57
69
|
};
|
|
58
70
|
//#endregion
|
|
59
71
|
//#region src/components/Editor/hooks/useTextFormatsState.ts
|
|
60
|
-
function
|
|
61
|
-
let [e] = L(), [t, n] =
|
|
72
|
+
function Ce() {
|
|
73
|
+
let [e] = L(), [t, n] = C({
|
|
62
74
|
bold: !1,
|
|
63
75
|
italic: !1,
|
|
64
76
|
underline: !1,
|
|
65
|
-
fontSize:
|
|
66
|
-
fontColor:
|
|
67
|
-
backgroundColor:
|
|
77
|
+
fontSize: p,
|
|
78
|
+
fontColor: f,
|
|
79
|
+
backgroundColor: d,
|
|
68
80
|
align: "left",
|
|
69
81
|
link: void 0
|
|
70
82
|
});
|
|
71
|
-
return
|
|
83
|
+
return b(() => e.registerUpdateListener(({ editorState: e }) => {
|
|
72
84
|
e.read(() => {
|
|
73
|
-
let e =
|
|
74
|
-
if (
|
|
75
|
-
let t = R(e, "font-size",
|
|
85
|
+
let e = N();
|
|
86
|
+
if (F(e)) {
|
|
87
|
+
let t = R(e, "font-size", p), r = R(e, "color", f), i = R(e, "background-color", d), a = e.anchor.getNode(), o = a.getKey() === "root" ? a : V(a, (e) => {
|
|
76
88
|
let t = e.getParent();
|
|
77
89
|
return t !== null && oe(t);
|
|
78
90
|
});
|
|
79
91
|
o === null && (o = a.getTopLevelElementOrThrow());
|
|
80
|
-
let s = {}, c =
|
|
92
|
+
let s = {}, c = V(a, he);
|
|
81
93
|
c ? (s.link = c.getURL(), s.linkText = c.getTextContent(), s.newBlank = c.getTarget() === "_blank") : s.linkText = e.getTextContent(), n({
|
|
82
94
|
bold: e.hasFormat("bold"),
|
|
83
95
|
italic: e.hasFormat("italic"),
|
|
@@ -94,39 +106,52 @@ function ye() {
|
|
|
94
106
|
}
|
|
95
107
|
//#endregion
|
|
96
108
|
//#region src/components/Editor/ToolbarPlugin/context/TextFormatProvider.tsx
|
|
97
|
-
var
|
|
98
|
-
let t =
|
|
99
|
-
return /* @__PURE__ */
|
|
109
|
+
var we = (e) => {
|
|
110
|
+
let t = Ce();
|
|
111
|
+
return /* @__PURE__ */ g(r.Provider, {
|
|
100
112
|
value: t,
|
|
101
113
|
children: e.children
|
|
102
114
|
});
|
|
103
|
-
},
|
|
104
|
-
let { config: t = [], style:
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
}, Te = (e) => {
|
|
116
|
+
let { config: t = [], style: r, theme: i, mode: a, floating: s } = e, { toolbarRef: c } = n(), l = a === "floating", d = x(() => be(i), [i]), f = x(() => ({ iconSize: xe(i?.iconSize) }), [i?.iconSize]), p = l ? Se(s) : void 0, h = l ? m(r, [
|
|
117
|
+
"position",
|
|
118
|
+
"left",
|
|
119
|
+
"top",
|
|
120
|
+
"right",
|
|
121
|
+
"bottom",
|
|
122
|
+
"inset",
|
|
123
|
+
"transform",
|
|
124
|
+
"marginTop",
|
|
125
|
+
"marginBottom"
|
|
126
|
+
]) : r, v = (e, t) => {
|
|
127
|
+
let n = typeof e == "string" ? e : e.name, r = o(n);
|
|
128
|
+
return r ? typeof e == "string" ? /* @__PURE__ */ g(r, {}, `${n}-${t}`) : /* @__PURE__ */ g(r, { ...e.props }, `${n}-${t}`) : (console.warn(`[ToolbarPlugin] Button "${n}" is not registered.`), null);
|
|
107
129
|
};
|
|
108
|
-
return /* @__PURE__ */
|
|
109
|
-
value:
|
|
110
|
-
children: /* @__PURE__ */
|
|
111
|
-
|
|
130
|
+
return /* @__PURE__ */ g(u, {
|
|
131
|
+
value: f,
|
|
132
|
+
children: /* @__PURE__ */ g(we, { children: /* @__PURE__ */ g("div", {
|
|
133
|
+
ref: c,
|
|
134
|
+
className: w(U["bsy-lexical__toolbar"], l && U["bsy-lexical__toolbar--floating"]),
|
|
112
135
|
style: {
|
|
113
|
-
...
|
|
114
|
-
...
|
|
136
|
+
...d,
|
|
137
|
+
...p,
|
|
138
|
+
...h
|
|
115
139
|
},
|
|
116
|
-
children: t.map((e, n) => /* @__PURE__ */
|
|
117
|
-
className:
|
|
140
|
+
children: t.map((e, n) => /* @__PURE__ */ _("div", {
|
|
141
|
+
className: U["bsy-lexical__toolbar-group"],
|
|
118
142
|
"data-group": e.key,
|
|
119
|
-
children: [e.buttons.map((e, t) =>
|
|
143
|
+
children: [e.buttons.map((e, t) => v(e, t)), n < t.length - 1 && /* @__PURE__ */ g("div", { className: U["bsy-lexical__toolbar-divider"] })]
|
|
120
144
|
}, e.key + n))
|
|
121
145
|
}) })
|
|
122
146
|
});
|
|
147
|
+
}, W = {
|
|
148
|
+
"bsy-lexical-editor": "_bsy-lexical-editor_jbc8k_1",
|
|
149
|
+
"bsy-lexical-editor--floating": "_bsy-lexical-editor--floating_jbc8k_7",
|
|
150
|
+
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_jbc8k_10",
|
|
151
|
+
"bsy-lexical-editor__content-editable--with-length-badge": "_bsy-lexical-editor__content-editable--with-length-badge_jbc8k_17",
|
|
152
|
+
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_jbc8k_20",
|
|
153
|
+
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_jbc8k_36"
|
|
123
154
|
}, G = {
|
|
124
|
-
"bsy-lexical-editor": "_bsy-lexical-editor_tsu2x_1",
|
|
125
|
-
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_tsu2x_7",
|
|
126
|
-
"bsy-lexical-editor__content-editable--with-length-badge": "_bsy-lexical-editor__content-editable--with-length-badge_tsu2x_14",
|
|
127
|
-
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_tsu2x_17",
|
|
128
|
-
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_tsu2x_33"
|
|
129
|
-
}, K = {
|
|
130
155
|
imageWrapper: "_imageWrapper_y06h3_1",
|
|
131
156
|
selected: "_selected_y06h3_8",
|
|
132
157
|
resizing: "_resizing_y06h3_12",
|
|
@@ -136,16 +161,16 @@ var be = (e) => {
|
|
|
136
161
|
topRight: "_topRight_y06h3_49",
|
|
137
162
|
bottomLeft: "_bottomLeft_y06h3_54",
|
|
138
163
|
bottomRight: "_bottomRight_y06h3_59"
|
|
139
|
-
},
|
|
140
|
-
let [a] = L(), [o, s] =
|
|
164
|
+
}, Ee = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
|
|
165
|
+
let [a] = L(), [o, s] = C(!1), [c, l] = C(null), u = S(null), [d, f] = C({
|
|
141
166
|
width: n || void 0,
|
|
142
167
|
height: r || void 0
|
|
143
|
-
}),
|
|
168
|
+
}), p = y(() => {
|
|
144
169
|
n && r && f({
|
|
145
170
|
width: n,
|
|
146
171
|
height: r
|
|
147
172
|
});
|
|
148
|
-
}, [n, r]),
|
|
173
|
+
}, [n, r]), m = y((e, t) => {
|
|
149
174
|
if (e.preventDefault(), e.stopPropagation(), !u.current) return;
|
|
150
175
|
let n = d.width || u.current.offsetWidth, r = d.height || u.current.offsetHeight, i = n / r;
|
|
151
176
|
(!d.width || !d.height) && f({
|
|
@@ -160,7 +185,7 @@ var be = (e) => {
|
|
|
160
185
|
aspectRatio: i,
|
|
161
186
|
direction: t
|
|
162
187
|
});
|
|
163
|
-
}, [d]),
|
|
188
|
+
}, [d]), x = y((e) => {
|
|
164
189
|
if (!c?.isResizing) return;
|
|
165
190
|
let t = e.clientX - c.startX, n;
|
|
166
191
|
switch (c.direction) {
|
|
@@ -183,10 +208,10 @@ var be = (e) => {
|
|
|
183
208
|
width: n,
|
|
184
209
|
height: r
|
|
185
210
|
});
|
|
186
|
-
}, [c]), T =
|
|
211
|
+
}, [c]), T = y(() => {
|
|
187
212
|
c?.isResizing && (a.update(() => {
|
|
188
|
-
let e =
|
|
189
|
-
|
|
213
|
+
let e = A(i);
|
|
214
|
+
De(e) && e.setWidthAndHeight(d.width, d.height);
|
|
190
215
|
}), l(null));
|
|
191
216
|
}, [
|
|
192
217
|
a,
|
|
@@ -194,71 +219,71 @@ var be = (e) => {
|
|
|
194
219
|
d,
|
|
195
220
|
c
|
|
196
221
|
]);
|
|
197
|
-
|
|
198
|
-
if (c?.isResizing) return document.addEventListener("mousemove",
|
|
199
|
-
document.removeEventListener("mousemove",
|
|
222
|
+
v.useEffect(() => {
|
|
223
|
+
if (c?.isResizing) return document.addEventListener("mousemove", x), document.addEventListener("mouseup", T), () => {
|
|
224
|
+
document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", T);
|
|
200
225
|
};
|
|
201
226
|
}, [
|
|
202
227
|
c,
|
|
203
|
-
|
|
228
|
+
x,
|
|
204
229
|
T
|
|
205
230
|
]);
|
|
206
|
-
let E =
|
|
231
|
+
let E = y(() => {
|
|
207
232
|
s(!0);
|
|
208
233
|
}, []);
|
|
209
|
-
return
|
|
234
|
+
return b(() => a.registerUpdateListener(({ editorState: e }) => {
|
|
210
235
|
e.read(() => {
|
|
211
|
-
let e =
|
|
212
|
-
|
|
236
|
+
let e = N();
|
|
237
|
+
F(e) && !e.getNodes().some((e) => e.getKey() === i || e.getParent() && e.getParent()?.getKey() === i) && o && s(!1);
|
|
213
238
|
});
|
|
214
239
|
}), [
|
|
215
240
|
a,
|
|
216
241
|
i,
|
|
217
242
|
o
|
|
218
|
-
]),
|
|
243
|
+
]), b(() => {
|
|
219
244
|
let e = (e) => {
|
|
220
245
|
o && u.current && !u.current.contains(e.target) && s(!1);
|
|
221
246
|
};
|
|
222
247
|
if (o) return document.addEventListener("mousedown", e), () => {
|
|
223
248
|
document.removeEventListener("mousedown", e);
|
|
224
249
|
};
|
|
225
|
-
}, [o]), /* @__PURE__ */
|
|
226
|
-
className:
|
|
227
|
-
[
|
|
228
|
-
[
|
|
250
|
+
}, [o]), /* @__PURE__ */ _("div", {
|
|
251
|
+
className: w(G.imageWrapper, {
|
|
252
|
+
[G.selected]: o,
|
|
253
|
+
[G.resizing]: c?.isResizing
|
|
229
254
|
}),
|
|
230
|
-
children: [/* @__PURE__ */
|
|
255
|
+
children: [/* @__PURE__ */ g("img", {
|
|
231
256
|
ref: u,
|
|
232
257
|
src: e,
|
|
233
258
|
alt: t,
|
|
234
|
-
className:
|
|
259
|
+
className: G.image,
|
|
235
260
|
style: {
|
|
236
261
|
width: d.width,
|
|
237
262
|
height: d.height
|
|
238
263
|
},
|
|
239
|
-
onLoad:
|
|
264
|
+
onLoad: p,
|
|
240
265
|
onClick: E,
|
|
241
266
|
draggable: !1
|
|
242
|
-
}), o && /* @__PURE__ */ h
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
className:
|
|
245
|
-
onMouseDown: (e) =>
|
|
267
|
+
}), o && /* @__PURE__ */ _(h, { children: [
|
|
268
|
+
/* @__PURE__ */ g("div", {
|
|
269
|
+
className: w(G.resizeHandle, G.bottomRight),
|
|
270
|
+
onMouseDown: (e) => m(e, "bottom-right")
|
|
246
271
|
}),
|
|
247
|
-
/* @__PURE__ */
|
|
248
|
-
className:
|
|
249
|
-
onMouseDown: (e) =>
|
|
272
|
+
/* @__PURE__ */ g("div", {
|
|
273
|
+
className: w(G.resizeHandle, G.bottomLeft),
|
|
274
|
+
onMouseDown: (e) => m(e, "bottom-left")
|
|
250
275
|
}),
|
|
251
|
-
/* @__PURE__ */
|
|
252
|
-
className:
|
|
253
|
-
onMouseDown: (e) =>
|
|
276
|
+
/* @__PURE__ */ g("div", {
|
|
277
|
+
className: w(G.resizeHandle, G.topRight),
|
|
278
|
+
onMouseDown: (e) => m(e, "top-right")
|
|
254
279
|
}),
|
|
255
|
-
/* @__PURE__ */
|
|
256
|
-
className:
|
|
257
|
-
onMouseDown: (e) =>
|
|
280
|
+
/* @__PURE__ */ g("div", {
|
|
281
|
+
className: w(G.resizeHandle, G.topLeft),
|
|
282
|
+
onMouseDown: (e) => m(e, "top-left")
|
|
258
283
|
})
|
|
259
284
|
] })]
|
|
260
285
|
});
|
|
261
|
-
},
|
|
286
|
+
}, K = class e extends ue {
|
|
262
287
|
static getType() {
|
|
263
288
|
return "image";
|
|
264
289
|
}
|
|
@@ -304,7 +329,7 @@ var be = (e) => {
|
|
|
304
329
|
n.__width = e, n.__height = t;
|
|
305
330
|
}
|
|
306
331
|
decorate() {
|
|
307
|
-
return /* @__PURE__ */
|
|
332
|
+
return /* @__PURE__ */ g(Ee, {
|
|
308
333
|
src: this.__src,
|
|
309
334
|
altText: this.__altText,
|
|
310
335
|
width: this.__width,
|
|
@@ -314,13 +339,13 @@ var be = (e) => {
|
|
|
314
339
|
}
|
|
315
340
|
static importDOM() {
|
|
316
341
|
return { img: () => ({
|
|
317
|
-
conversion:
|
|
342
|
+
conversion: Oe,
|
|
318
343
|
priority: 0
|
|
319
344
|
}) };
|
|
320
345
|
}
|
|
321
346
|
static importJSON(e) {
|
|
322
347
|
let { src: t, altText: n, width: r, height: i } = e;
|
|
323
|
-
return
|
|
348
|
+
return q({
|
|
324
349
|
src: t,
|
|
325
350
|
altText: n,
|
|
326
351
|
width: r,
|
|
@@ -341,13 +366,13 @@ var be = (e) => {
|
|
|
341
366
|
return !0;
|
|
342
367
|
}
|
|
343
368
|
};
|
|
344
|
-
function
|
|
345
|
-
return new
|
|
369
|
+
function q({ src: e, altText: t, width: n, height: r, key: i }) {
|
|
370
|
+
return new K(e, t, n, r, i);
|
|
346
371
|
}
|
|
347
|
-
function
|
|
348
|
-
return e instanceof
|
|
372
|
+
function De(e) {
|
|
373
|
+
return e instanceof K;
|
|
349
374
|
}
|
|
350
|
-
function
|
|
375
|
+
function Oe(e) {
|
|
351
376
|
if (e instanceof HTMLImageElement) {
|
|
352
377
|
let { src: t, alt: n, style: r } = e, i, a;
|
|
353
378
|
if (r.width) {
|
|
@@ -358,7 +383,7 @@ function we(e) {
|
|
|
358
383
|
let e = parseInt(r.height, 10);
|
|
359
384
|
isNaN(e) || (a = e);
|
|
360
385
|
}
|
|
361
|
-
return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node:
|
|
386
|
+
return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: q({
|
|
362
387
|
src: t,
|
|
363
388
|
altText: n,
|
|
364
389
|
width: i,
|
|
@@ -369,23 +394,23 @@ function we(e) {
|
|
|
369
394
|
}
|
|
370
395
|
//#endregion
|
|
371
396
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
372
|
-
function
|
|
397
|
+
function ke() {
|
|
373
398
|
let [e] = L();
|
|
374
|
-
return
|
|
399
|
+
return b(() => e.registerCommand(s, (e) => (P([q(e)]), !0), ce), [e]), null;
|
|
375
400
|
}
|
|
376
401
|
//#endregion
|
|
377
402
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
378
|
-
function
|
|
379
|
-
let [e] = L(), t =
|
|
380
|
-
return
|
|
403
|
+
function Ae() {
|
|
404
|
+
let [e] = L(), t = S(0);
|
|
405
|
+
return b(() => e.registerCommand(de, (n) => {
|
|
381
406
|
let r = Date.now(), i = r - t.current;
|
|
382
407
|
return t.current = r, i < 250 && i > 0 ? (e.update(() => {
|
|
383
|
-
let e =
|
|
384
|
-
if (
|
|
408
|
+
let e = N();
|
|
409
|
+
if (F(e)) {
|
|
385
410
|
let t = e.anchor.getNode().getTopLevelElement();
|
|
386
411
|
if (t && t.getTextContent().trim() === "") {
|
|
387
|
-
let n =
|
|
388
|
-
|
|
412
|
+
let n = k();
|
|
413
|
+
z(e, {
|
|
389
414
|
"background-color": "",
|
|
390
415
|
color: "",
|
|
391
416
|
"font-size": "",
|
|
@@ -402,34 +427,34 @@ function Ee() {
|
|
|
402
427
|
}
|
|
403
428
|
//#endregion
|
|
404
429
|
//#region src/components/Editor/plugins/MaxLengthPlugin.tsx
|
|
405
|
-
function
|
|
406
|
-
let [n] = L(), r =
|
|
407
|
-
return r.current = t,
|
|
430
|
+
function je({ maxLength: e, onMaxLengthExceed: t }) {
|
|
431
|
+
let [n] = L(), r = S(t);
|
|
432
|
+
return r.current = t, b(() => {
|
|
408
433
|
let t = null;
|
|
409
|
-
return n.registerNodeTransform(
|
|
434
|
+
return n.registerNodeTransform(fe, (i) => {
|
|
410
435
|
let a = i.getTextContentSize();
|
|
411
436
|
if (a <= e) return;
|
|
412
|
-
let o = n.getEditorState(), s = o.read(() => i.getTextContentSize()), c = a - e, l =
|
|
437
|
+
let o = n.getEditorState(), s = o.read(() => i.getTextContentSize()), c = a - e, l = N();
|
|
413
438
|
if (s === e && t !== o) {
|
|
414
|
-
t = o,
|
|
439
|
+
t = o, me(n, o), r.current?.();
|
|
415
440
|
return;
|
|
416
441
|
}
|
|
417
|
-
if (
|
|
418
|
-
|
|
442
|
+
if (F(l) && l.isCollapsed()) {
|
|
443
|
+
B(n, l.anchor, c), r.current?.();
|
|
419
444
|
return;
|
|
420
445
|
}
|
|
421
446
|
i.selectEnd();
|
|
422
|
-
let u =
|
|
423
|
-
|
|
447
|
+
let u = N();
|
|
448
|
+
F(u) && (B(n, u.anchor, c), r.current?.());
|
|
424
449
|
});
|
|
425
450
|
}, [n, e]), null;
|
|
426
451
|
}
|
|
427
452
|
//#endregion
|
|
428
453
|
//#region src/components/Editor/LengthBadge.tsx
|
|
429
|
-
var
|
|
454
|
+
var J = ({ current: e, maxLength: t }) => {
|
|
430
455
|
let n = e > t;
|
|
431
|
-
return /* @__PURE__ */
|
|
432
|
-
className:
|
|
456
|
+
return /* @__PURE__ */ _("div", {
|
|
457
|
+
className: w(W["bsy-lexical-editor__length-badge"], n && W["bsy-lexical-editor__length-badge--exceeded"]),
|
|
433
458
|
"aria-live": "polite",
|
|
434
459
|
children: [
|
|
435
460
|
e,
|
|
@@ -438,22 +463,22 @@ var Y = ({ current: e, maxLength: t }) => {
|
|
|
438
463
|
]
|
|
439
464
|
});
|
|
440
465
|
};
|
|
441
|
-
|
|
466
|
+
J.displayName = "BsyLexicalEditorLengthBadge";
|
|
442
467
|
//#endregion
|
|
443
468
|
//#region src/components/Editor/utils/textLength.ts
|
|
444
|
-
function
|
|
469
|
+
function Y(e) {
|
|
445
470
|
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
446
471
|
}
|
|
447
|
-
function
|
|
448
|
-
let n =
|
|
472
|
+
function Me(e, t) {
|
|
473
|
+
let n = M(), r = n.getTextContentSize();
|
|
449
474
|
if (r <= t) return !1;
|
|
450
475
|
let i = r - t;
|
|
451
476
|
n.selectEnd();
|
|
452
|
-
let a =
|
|
453
|
-
return
|
|
477
|
+
let a = N();
|
|
478
|
+
return F(a) ? B(e, a.anchor, i) : Ne(i), !0;
|
|
454
479
|
}
|
|
455
|
-
function
|
|
456
|
-
let t = e, n =
|
|
480
|
+
function Ne(e) {
|
|
481
|
+
let t = e, n = M().getAllTextNodes();
|
|
457
482
|
for (let e = n.length - 1; e >= 0 && t > 0; e--) {
|
|
458
483
|
let r = n[e], i = r.getTextContent();
|
|
459
484
|
i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
|
|
@@ -462,15 +487,16 @@ function Ae(e) {
|
|
|
462
487
|
//#endregion
|
|
463
488
|
//#region src/components/Editor/EditorCore.tsx
|
|
464
489
|
var X = (e) => {
|
|
465
|
-
let { height: t = 126, onChange: n, toolbar: r, theme: i, maxLength: a, onMaxLengthExceed: o } = e, [s] = L(),
|
|
466
|
-
|
|
467
|
-
let
|
|
468
|
-
containerRef:
|
|
469
|
-
|
|
470
|
-
|
|
490
|
+
let { height: t = 126, onChange: n, toolbar: r, theme: i, maxLength: a, onMaxLengthExceed: o } = e, [s] = L(), c = S(null), u = S(null), d = S(null), f = S(o);
|
|
491
|
+
f.current = o;
|
|
492
|
+
let p = Y(a) ? a : void 0, [m, h] = C(0), v = r?.mode === "floating", T = x(() => ({
|
|
493
|
+
containerRef: c,
|
|
494
|
+
toolbarRef: u,
|
|
495
|
+
getPopupContainer: () => v && u.current ? u.current : c.current || document.body
|
|
496
|
+
}), [v]), O = y((e) => {
|
|
471
497
|
e.read(() => {
|
|
472
|
-
let t =
|
|
473
|
-
|
|
498
|
+
let t = M().getTextContent(), r = re(s, null), i = !t.trim() && (r === "<p><br></p>" || r === "<p></p>" || r === "" || /^<p>\s*<br>\s*<\/p>$/.test(r)) ? null : r;
|
|
499
|
+
d.current = i, p !== void 0 && h(t.length), n({
|
|
474
500
|
text: t,
|
|
475
501
|
html: i
|
|
476
502
|
}, e);
|
|
@@ -478,62 +504,64 @@ var X = (e) => {
|
|
|
478
504
|
}, [
|
|
479
505
|
n,
|
|
480
506
|
s,
|
|
481
|
-
|
|
507
|
+
p
|
|
482
508
|
]);
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
509
|
+
b(() => {
|
|
510
|
+
p !== void 0 && s.getEditorState().read(() => {
|
|
511
|
+
h(M().getTextContentSize());
|
|
486
512
|
}, { editor: s });
|
|
487
|
-
}, [s,
|
|
488
|
-
if (e.value !== void 0 && e.value !==
|
|
513
|
+
}, [s, p]), b(() => {
|
|
514
|
+
if (e.value !== void 0 && e.value !== d.current) {
|
|
489
515
|
let t = !1;
|
|
490
516
|
s.update(() => {
|
|
491
|
-
|
|
492
|
-
}), t &&
|
|
517
|
+
M().clear(), e.value && e.value.trim() && (P(ie(s, new DOMParser().parseFromString(e.value, "text/html"))), p !== void 0 && (t = Me(s, p)));
|
|
518
|
+
}), t && f.current?.();
|
|
493
519
|
}
|
|
494
520
|
}, [
|
|
495
521
|
e.value,
|
|
496
522
|
s,
|
|
497
|
-
|
|
523
|
+
p
|
|
498
524
|
]);
|
|
499
|
-
let
|
|
500
|
-
return /* @__PURE__ */
|
|
501
|
-
value:
|
|
502
|
-
children: /* @__PURE__ */
|
|
503
|
-
ref:
|
|
504
|
-
className:
|
|
525
|
+
let k = r?.config?.length ? r?.config : [], A = ve();
|
|
526
|
+
return /* @__PURE__ */ g(l.Provider, {
|
|
527
|
+
value: T,
|
|
528
|
+
children: /* @__PURE__ */ _("div", {
|
|
529
|
+
ref: c,
|
|
530
|
+
className: w(W["bsy-lexical-editor"], v && W["bsy-lexical-editor--floating"]),
|
|
505
531
|
onClick: (e) => {
|
|
506
532
|
let t = s.getRootElement(), n = e.target;
|
|
507
533
|
!t || !n || !t.contains(n) || s.isEditable() || s.setEditable(!0);
|
|
508
534
|
},
|
|
509
535
|
children: [
|
|
510
|
-
|
|
511
|
-
config:
|
|
536
|
+
k.length > 0 && /* @__PURE__ */ g(Te, {
|
|
537
|
+
config: k,
|
|
512
538
|
theme: i?.toolbar,
|
|
513
|
-
style: r?.style
|
|
539
|
+
style: r?.style,
|
|
540
|
+
mode: r?.mode,
|
|
541
|
+
floating: r?.floating
|
|
514
542
|
}),
|
|
515
|
-
/* @__PURE__ */
|
|
516
|
-
contentEditable: /* @__PURE__ */
|
|
517
|
-
className:
|
|
543
|
+
/* @__PURE__ */ g(E, {
|
|
544
|
+
contentEditable: /* @__PURE__ */ g(ee, {
|
|
545
|
+
className: w(W["bsy-lexical-editor__content-editable"], p !== void 0 && W["bsy-lexical-editor__content-editable--with-length-badge"]),
|
|
518
546
|
style: {
|
|
519
547
|
height: t,
|
|
520
|
-
cursor:
|
|
548
|
+
cursor: A ? "auto" : "text"
|
|
521
549
|
}
|
|
522
550
|
}),
|
|
523
|
-
ErrorBoundary:
|
|
551
|
+
ErrorBoundary: D
|
|
524
552
|
}),
|
|
525
|
-
/* @__PURE__ */
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
/* @__PURE__ */
|
|
528
|
-
|
|
529
|
-
maxLength:
|
|
553
|
+
/* @__PURE__ */ g(ye, {}),
|
|
554
|
+
/* @__PURE__ */ g(ke, {}),
|
|
555
|
+
/* @__PURE__ */ g(Ae, {}),
|
|
556
|
+
p !== void 0 && /* @__PURE__ */ g(je, {
|
|
557
|
+
maxLength: p,
|
|
530
558
|
onMaxLengthExceed: o
|
|
531
559
|
}),
|
|
532
|
-
/* @__PURE__ */
|
|
533
|
-
/* @__PURE__ */
|
|
534
|
-
|
|
535
|
-
current:
|
|
536
|
-
maxLength:
|
|
560
|
+
/* @__PURE__ */ g(te, {}),
|
|
561
|
+
/* @__PURE__ */ g(ne, { onChange: O }),
|
|
562
|
+
p !== void 0 && /* @__PURE__ */ g(J, {
|
|
563
|
+
current: m,
|
|
564
|
+
maxLength: p
|
|
537
565
|
})
|
|
538
566
|
]
|
|
539
567
|
})
|
|
@@ -583,14 +611,14 @@ var Z = class e extends I {
|
|
|
583
611
|
};
|
|
584
612
|
}
|
|
585
613
|
static importJSON(e) {
|
|
586
|
-
return
|
|
614
|
+
return Pe().updateFromJSON(e);
|
|
587
615
|
}
|
|
588
616
|
isSimpleText() {
|
|
589
617
|
return this.__type === "extended-text" && this.__mode === 0;
|
|
590
618
|
}
|
|
591
619
|
};
|
|
592
|
-
function
|
|
593
|
-
return
|
|
620
|
+
function Pe(e = "") {
|
|
621
|
+
return O(new Z(e));
|
|
594
622
|
}
|
|
595
623
|
function Q(e) {
|
|
596
624
|
return (t) => {
|
|
@@ -623,8 +651,8 @@ function Q(e) {
|
|
|
623
651
|
//#region src/components/Editor/Editor.tsx
|
|
624
652
|
var $ = (e) => {
|
|
625
653
|
let { autoFocus: t = !1 } = e;
|
|
626
|
-
return /* @__PURE__ */
|
|
627
|
-
initialConfig:
|
|
654
|
+
return /* @__PURE__ */ g(T, {
|
|
655
|
+
initialConfig: x(() => ({
|
|
628
656
|
namespace: "bsyLexicalEditor",
|
|
629
657
|
onError: (e) => {
|
|
630
658
|
console.error("Lexical error", e);
|
|
@@ -639,9 +667,9 @@ var $ = (e) => {
|
|
|
639
667
|
link: "editor-link"
|
|
640
668
|
},
|
|
641
669
|
nodes: [
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
670
|
+
_e,
|
|
671
|
+
ge,
|
|
672
|
+
K,
|
|
645
673
|
Z,
|
|
646
674
|
{
|
|
647
675
|
replace: I,
|
|
@@ -650,9 +678,9 @@ var $ = (e) => {
|
|
|
650
678
|
}
|
|
651
679
|
]
|
|
652
680
|
}), [t]),
|
|
653
|
-
children: /* @__PURE__ */
|
|
681
|
+
children: /* @__PURE__ */ g(X, { ...e })
|
|
654
682
|
});
|
|
655
683
|
};
|
|
656
684
|
$.displayName = "BsyLexicalEditor";
|
|
657
685
|
//#endregion
|
|
658
|
-
export {
|
|
686
|
+
export { j as $getRoot, a as BaseButton, $ as default, c as listRegisteredToolbarButtons, i as registerToolbarButton, t as unregisterToolbarButton, pe as useLexicalComposerContext };
|