@baishuyun/ui-base 2.3.2 → 2.3.4
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 → Card-CaKTq_1y.js} +17 -17
- package/dist/Card/index.js +2 -2
- package/dist/CheckBox/CheckBox-Cz6KW9Lw.js +33 -0
- package/dist/CheckBox/{CheckBox--rXaUgMO.js → CheckBox-l__wOnmH.js} +25 -25
- package/dist/CheckBox/index.js +3 -3
- package/dist/ColorPicker/ColorPicker-C1kG_eI-.js +168 -0
- package/dist/ColorPicker/index.js +4 -5
- package/dist/DropDown/DropDown-BAPBTglm.js +162 -0
- package/dist/DropDown/index.js +6 -6
- package/dist/Editor/{Buttons--dMLPuk2.js → Buttons-CsKKYGbV.js} +207 -204
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +12 -13
- package/dist/Editor/index.js +207 -196
- package/dist/Icon/Icon-CTZCSuVg.js +19 -0
- package/dist/Icon/index.js +1 -1
- package/dist/InputTag/{InputTag-B6N5MZA2.js → InputTag-V4UnUnGJ.js} +33 -33
- package/dist/InputTag/index.js +2 -2
- package/dist/Loading/index.js +1 -1
- package/dist/Modal/{Modal-FVJpbEgw.js → Modal-DQ5bptu_.js} +1 -1
- package/dist/Modal/index.js +2 -2
- package/dist/NotFoundContent/index.js +1 -1
- package/dist/Radio/{Radio-dyoBNiKF.js → Radio-CZOrtNyn.js} +25 -25
- package/dist/Radio/index.js +1 -1
- package/dist/Segmented/{Segmented-Dd8glDXI.js → Segmented-DEGgLO-b.js} +15 -15
- package/dist/Segmented/index.js +1 -1
- package/dist/Select/Select-BoNqxIRo.js +729 -0
- package/dist/Select/{SelectInputSearch-CIXBNLFi.js → SelectInputSearch-DMY6Y9B6.js} +2 -2
- package/dist/Select/index.js +10 -10
- package/dist/Tabs/{Tabs-C79GTyGd.js → Tabs-BqT-_eVo.js} +138 -138
- package/dist/Tabs/index.js +4 -5
- package/dist/Tree/index.js +4 -4
- package/dist/Tree/utils/index.js +1 -1
- package/dist/index.js +19 -20
- package/dist/vendors/Tree-nIRgDY2s.js +231 -0
- package/dist/vendors/{color-BPWy9DvT.js → color-CyuNdAfc.js} +2 -2
- package/package.json +4 -2
- package/dist/CheckBox/CheckBox-Db8X-pw9.js +0 -33
- package/dist/ColorPicker/ColorPicker-BBP-4-so.js +0 -168
- package/dist/DropDown/DropDown-CKXi9mXN.js +0 -162
- package/dist/Icon/Icon-DppVOyPK.js +0 -19
- package/dist/Select/Select-Bd2ECrB0.js +0 -729
- package/dist/vendors/Tree-CQR9fvpA.js +0 -231
- package/dist/vendors/clsx-DNOE4Gl8.js +0 -16
- package/dist/vendors/fuse.js-BKtvbTjL.js +0 -877
- package/dist/vendors/lexical-hZliMgDv.js +0 -6439
- package/dist/vendors/lodash-es-Bu9xU1fK.js +0 -334
- package/dist/vendors/simplebar-react-CFlS-Nm9.js +0 -370
- package/dist/vendors/tinycolor2-DToeAEPD.js +0 -726
- /package/dist/Loading/{Loading-Bi5NO-Ky.js → Loading-Dy5A--HK.js} +0 -0
- /package/dist/NotFoundContent/{NotFoundContent-CTPpcZOt.js → NotFoundContent-1-41e1rN.js} +0 -0
- /package/dist/vendors/{animations-C5JKFkz4.js → animations-DvjIfVz9.js} +0 -0
- /package/dist/vendors/{useFloatingPortal-BA6P5GxV.js → useFloatingPortal-W4pliYWU.js} +0 -0
- /package/dist/vendors/{useLocale-BfT0V1j4.js → useLocale-BXnqO-Ju.js} +0 -0
package/dist/Editor/index.js
CHANGED
|
@@ -1,59 +1,70 @@
|
|
|
1
|
-
import "../Icon/Icon-
|
|
2
|
-
import "../vendors/useLocale-
|
|
3
|
-
import
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
import "../
|
|
9
|
-
import "../
|
|
10
|
-
import "../
|
|
11
|
-
import "../
|
|
12
|
-
import "
|
|
13
|
-
import "
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
1
|
+
import "../Icon/Icon-CTZCSuVg.js";
|
|
2
|
+
import "../vendors/useLocale-BXnqO-Ju.js";
|
|
3
|
+
import "../Modal/Modal-DQ5bptu_.js";
|
|
4
|
+
import "../ColorPicker/ColorPicker-C1kG_eI-.js";
|
|
5
|
+
import "../vendors/color-CyuNdAfc.js";
|
|
6
|
+
import "../Select/SelectInputSearch-DMY6Y9B6.js";
|
|
7
|
+
import "../CheckBox/CheckBox-l__wOnmH.js";
|
|
8
|
+
import "../CheckBox/CheckBox-Cz6KW9Lw.js";
|
|
9
|
+
import "../NotFoundContent/NotFoundContent-1-41e1rN.js";
|
|
10
|
+
import "../vendors/useFloatingPortal-W4pliYWU.js";
|
|
11
|
+
import "../DropDown/DropDown-BAPBTglm.js";
|
|
12
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s } from "./Buttons-CsKKYGbV.js";
|
|
13
|
+
import { DEFAULT_BACKGROUND_COLOR as c, DEFAULT_FONT_COLOR as l, DEFAULT_FONT_SIZE as u } from "./constants/index.js";
|
|
14
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
15
|
+
import m, { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
16
|
+
import b from "clsx";
|
|
17
|
+
import { LexicalComposer as x } from "@lexical/react/LexicalComposer";
|
|
18
|
+
import { RichTextPlugin as S } from "@lexical/react/LexicalRichTextPlugin";
|
|
19
|
+
import { ContentEditable as C } from "@lexical/react/LexicalContentEditable";
|
|
20
|
+
import { HistoryPlugin as w } from "@lexical/react/LexicalHistoryPlugin";
|
|
21
|
+
import { OnChangePlugin as T } from "@lexical/react/LexicalOnChangePlugin";
|
|
22
|
+
import { LexicalErrorBoundary as E } from "@lexical/react/LexicalErrorBoundary";
|
|
23
|
+
import { $generateHtmlFromNodes as D, $generateNodesFromDOM as O } from "@lexical/html";
|
|
24
|
+
import { $applyNodeReplacement as ee, $createParagraphNode as te, $getNodeByKey as ne, $getRoot as re, $getRoot as k, $getSelection as A, $insertNodes as j, $isElementNode as M, $isRangeSelection as N, $isRootOrShadowRoot as ie, $isTextNode as P, COMMAND_PRIORITY_EDITOR as ae, COMMAND_PRIORITY_LOW as oe, DecoratorNode as se, KEY_ENTER_COMMAND as ce, TextNode as F } from "lexical";
|
|
25
|
+
import { useLexicalComposerContext as I, useLexicalComposerContext as L } from "@lexical/react/LexicalComposerContext";
|
|
26
|
+
import { $getSelectionStyleValueForProperty as R, $patchStyleText as z } from "@lexical/selection";
|
|
27
|
+
import { $findMatchingParent as B } from "@lexical/utils";
|
|
28
|
+
import { $isLinkNode as V, AutoLinkNode as H, LinkNode as U } from "@lexical/link";
|
|
29
|
+
import { LinkPlugin as W } from "@lexical/react/LexicalLinkPlugin";
|
|
19
30
|
//#region src/components/Editor/ToolbarPlugin/ToolbarPlugin.module.scss
|
|
20
|
-
var
|
|
31
|
+
var G = {
|
|
21
32
|
"bsy-lexical__toolbar": "_bsy-lexical__toolbar_n60av_1",
|
|
22
33
|
"bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_n60av_9",
|
|
23
34
|
"bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_n60av_15"
|
|
24
35
|
};
|
|
25
36
|
//#endregion
|
|
26
37
|
//#region src/components/Editor/hooks/useTextFormatsState.ts
|
|
27
|
-
function
|
|
28
|
-
let [e] =
|
|
38
|
+
function le() {
|
|
39
|
+
let [e] = L(), [t, n] = y({
|
|
29
40
|
bold: !1,
|
|
30
41
|
italic: !1,
|
|
31
42
|
underline: !1,
|
|
32
|
-
fontSize:
|
|
33
|
-
fontColor:
|
|
34
|
-
backgroundColor:
|
|
43
|
+
fontSize: u,
|
|
44
|
+
fontColor: l,
|
|
45
|
+
backgroundColor: c,
|
|
35
46
|
align: "left",
|
|
36
47
|
link: void 0
|
|
37
48
|
});
|
|
38
|
-
return
|
|
49
|
+
return g(() => e.registerUpdateListener(({ editorState: e }) => {
|
|
39
50
|
e.read(() => {
|
|
40
|
-
let e =
|
|
41
|
-
if (
|
|
42
|
-
let t =
|
|
51
|
+
let e = A();
|
|
52
|
+
if (N(e)) {
|
|
53
|
+
let t = R(e, "font-size", u), r = R(e, "color", l), i = R(e, "background-color", c), a = e.anchor.getNode(), o = a.getKey() === "root" ? a : B(a, (e) => {
|
|
43
54
|
let t = e.getParent();
|
|
44
|
-
return t !== null &&
|
|
55
|
+
return t !== null && ie(t);
|
|
45
56
|
});
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
|
|
57
|
+
o === null && (o = a.getTopLevelElementOrThrow());
|
|
58
|
+
let s = {}, d = B(a, V);
|
|
59
|
+
d ? (s.link = d.getURL(), s.linkText = d.getTextContent(), s.newBlank = d.getTarget() === "_blank") : s.linkText = e.getTextContent(), n({
|
|
49
60
|
bold: e.hasFormat("bold"),
|
|
50
61
|
italic: e.hasFormat("italic"),
|
|
51
62
|
underline: e.hasFormat("underline"),
|
|
52
63
|
fontSize: t,
|
|
53
|
-
fontColor:
|
|
54
|
-
backgroundColor:
|
|
55
|
-
align:
|
|
56
|
-
link:
|
|
64
|
+
fontColor: r,
|
|
65
|
+
backgroundColor: i,
|
|
66
|
+
align: M(o) ? o.getFormatType() : "left",
|
|
67
|
+
link: s
|
|
57
68
|
});
|
|
58
69
|
}
|
|
59
70
|
});
|
|
@@ -61,30 +72,30 @@ function H() {
|
|
|
61
72
|
}
|
|
62
73
|
//#endregion
|
|
63
74
|
//#region src/components/Editor/ToolbarPlugin/context/TextFormatProvider.tsx
|
|
64
|
-
var
|
|
65
|
-
let t =
|
|
66
|
-
return /* @__PURE__ */
|
|
75
|
+
var ue = (e) => {
|
|
76
|
+
let t = le();
|
|
77
|
+
return /* @__PURE__ */ f(r.Provider, {
|
|
67
78
|
value: t,
|
|
68
79
|
children: e.children
|
|
69
80
|
});
|
|
70
|
-
},
|
|
81
|
+
}, de = (e) => {
|
|
71
82
|
let { config: t = [], style: n } = e, r = (e, t) => {
|
|
72
|
-
let n = typeof e == "string" ? e : e.name, r =
|
|
73
|
-
return r ? typeof e == "string" ? /* @__PURE__ */
|
|
83
|
+
let n = typeof e == "string" ? e : e.name, r = i(n);
|
|
84
|
+
return r ? typeof e == "string" ? /* @__PURE__ */ f(r, {}, `${n}-${t}`) : /* @__PURE__ */ f(r, { ...e.props }, `${n}-${t}`) : (console.warn(`[ToolbarPlugin] Button "${n}" is not registered.`), null);
|
|
74
85
|
};
|
|
75
|
-
return /* @__PURE__ */
|
|
76
|
-
className:
|
|
86
|
+
return /* @__PURE__ */ f(ue, { children: /* @__PURE__ */ f("div", {
|
|
87
|
+
className: G["bsy-lexical__toolbar"],
|
|
77
88
|
style: n,
|
|
78
|
-
children: t.map((e, n) => /* @__PURE__ */
|
|
79
|
-
className:
|
|
89
|
+
children: t.map((e, n) => /* @__PURE__ */ p("div", {
|
|
90
|
+
className: G["bsy-lexical__toolbar-group"],
|
|
80
91
|
"data-group": e.key,
|
|
81
|
-
children: [e.buttons.map((e, t) => r(e, t)), n < t.length - 1 && /* @__PURE__ */
|
|
92
|
+
children: [e.buttons.map((e, t) => r(e, t)), n < t.length - 1 && /* @__PURE__ */ f("div", { className: G["bsy-lexical__toolbar-divider"] })]
|
|
82
93
|
}, e.key + n))
|
|
83
94
|
}) });
|
|
84
|
-
},
|
|
95
|
+
}, K = {
|
|
85
96
|
"bsy-lexical-editor": "_bsy-lexical-editor_19ssw_1",
|
|
86
97
|
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_19ssw_6"
|
|
87
|
-
},
|
|
98
|
+
}, q = {
|
|
88
99
|
imageWrapper: "_imageWrapper_y06h3_1",
|
|
89
100
|
selected: "_selected_y06h3_8",
|
|
90
101
|
resizing: "_resizing_y06h3_12",
|
|
@@ -94,22 +105,22 @@ var U = (e) => {
|
|
|
94
105
|
topRight: "_topRight_y06h3_49",
|
|
95
106
|
bottomLeft: "_bottomLeft_y06h3_54",
|
|
96
107
|
bottomRight: "_bottomRight_y06h3_59"
|
|
97
|
-
},
|
|
98
|
-
let [
|
|
99
|
-
width:
|
|
100
|
-
height:
|
|
101
|
-
}),
|
|
102
|
-
|
|
103
|
-
width:
|
|
104
|
-
height:
|
|
108
|
+
}, fe = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
|
|
109
|
+
let [a] = L(), [o, s] = y(!1), [c, l] = y(null), u = v(null), [_, x] = y({
|
|
110
|
+
width: n || void 0,
|
|
111
|
+
height: r || void 0
|
|
112
|
+
}), S = h(() => {
|
|
113
|
+
n && r && x({
|
|
114
|
+
width: n,
|
|
115
|
+
height: r
|
|
105
116
|
});
|
|
106
|
-
}, [
|
|
107
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
108
|
-
let n =
|
|
109
|
-
(!
|
|
117
|
+
}, [n, r]), C = h((e, t) => {
|
|
118
|
+
if (e.preventDefault(), e.stopPropagation(), !u.current) return;
|
|
119
|
+
let n = _.width || u.current.offsetWidth, r = _.height || u.current.offsetHeight, i = n / r;
|
|
120
|
+
(!_.width || !_.height) && x({
|
|
110
121
|
width: n,
|
|
111
122
|
height: r
|
|
112
|
-
}),
|
|
123
|
+
}), l({
|
|
113
124
|
isResizing: !0,
|
|
114
125
|
startX: e.clientX,
|
|
115
126
|
startY: e.clientY,
|
|
@@ -118,105 +129,105 @@ var U = (e) => {
|
|
|
118
129
|
aspectRatio: i,
|
|
119
130
|
direction: t
|
|
120
131
|
});
|
|
121
|
-
}, [
|
|
122
|
-
if (!
|
|
123
|
-
let t = e.clientX -
|
|
124
|
-
switch (
|
|
132
|
+
}, [_]), w = h((e) => {
|
|
133
|
+
if (!c?.isResizing) return;
|
|
134
|
+
let t = e.clientX - c.startX, n;
|
|
135
|
+
switch (c.direction) {
|
|
125
136
|
case "bottom-right":
|
|
126
|
-
n = Math.max(50,
|
|
137
|
+
n = Math.max(50, c.startWidth + t);
|
|
127
138
|
break;
|
|
128
139
|
case "bottom-left":
|
|
129
|
-
n = Math.max(50,
|
|
140
|
+
n = Math.max(50, c.startWidth - t);
|
|
130
141
|
break;
|
|
131
142
|
case "top-right":
|
|
132
|
-
n = Math.max(50,
|
|
143
|
+
n = Math.max(50, c.startWidth + t);
|
|
133
144
|
break;
|
|
134
145
|
case "top-left":
|
|
135
|
-
n = Math.max(50,
|
|
146
|
+
n = Math.max(50, c.startWidth - t);
|
|
136
147
|
break;
|
|
137
|
-
default: n = Math.max(50,
|
|
148
|
+
default: n = Math.max(50, c.startWidth + t);
|
|
138
149
|
}
|
|
139
|
-
let r = n /
|
|
140
|
-
|
|
150
|
+
let r = n / c.aspectRatio;
|
|
151
|
+
x({
|
|
141
152
|
width: n,
|
|
142
153
|
height: r
|
|
143
154
|
});
|
|
144
|
-
}, [
|
|
145
|
-
|
|
146
|
-
let e =
|
|
147
|
-
|
|
148
|
-
}),
|
|
155
|
+
}, [c]), T = h(() => {
|
|
156
|
+
c?.isResizing && (a.update(() => {
|
|
157
|
+
let e = ne(i);
|
|
158
|
+
pe(e) && e.setWidthAndHeight(_.width, _.height);
|
|
159
|
+
}), l(null));
|
|
149
160
|
}, [
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
a,
|
|
162
|
+
i,
|
|
163
|
+
_,
|
|
164
|
+
c
|
|
154
165
|
]);
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
document.removeEventListener("mousemove",
|
|
166
|
+
m.useEffect(() => {
|
|
167
|
+
if (c?.isResizing) return document.addEventListener("mousemove", w), document.addEventListener("mouseup", T), () => {
|
|
168
|
+
document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", T);
|
|
158
169
|
};
|
|
159
170
|
}, [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
c,
|
|
172
|
+
w,
|
|
173
|
+
T
|
|
163
174
|
]);
|
|
164
|
-
let
|
|
165
|
-
|
|
175
|
+
let E = h(() => {
|
|
176
|
+
s(!0);
|
|
166
177
|
}, []);
|
|
167
|
-
return
|
|
178
|
+
return g(() => a.registerUpdateListener(({ editorState: e }) => {
|
|
168
179
|
e.read(() => {
|
|
169
|
-
let e =
|
|
170
|
-
|
|
180
|
+
let e = A();
|
|
181
|
+
N(e) && !e.getNodes().some((e) => e.getKey() === i || e.getParent() && e.getParent()?.getKey() === i) && o && s(!1);
|
|
171
182
|
});
|
|
172
183
|
}), [
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
]),
|
|
184
|
+
a,
|
|
185
|
+
i,
|
|
186
|
+
o
|
|
187
|
+
]), g(() => {
|
|
177
188
|
let e = (e) => {
|
|
178
|
-
|
|
189
|
+
o && u.current && !u.current.contains(e.target) && s(!1);
|
|
179
190
|
};
|
|
180
|
-
if (
|
|
191
|
+
if (o) return document.addEventListener("mousedown", e), () => {
|
|
181
192
|
document.removeEventListener("mousedown", e);
|
|
182
193
|
};
|
|
183
|
-
}, [
|
|
184
|
-
className:
|
|
185
|
-
[
|
|
186
|
-
[
|
|
194
|
+
}, [o]), /* @__PURE__ */ p("div", {
|
|
195
|
+
className: b(q.imageWrapper, {
|
|
196
|
+
[q.selected]: o,
|
|
197
|
+
[q.resizing]: c?.isResizing
|
|
187
198
|
}),
|
|
188
|
-
children: [/* @__PURE__ */
|
|
189
|
-
ref:
|
|
190
|
-
src:
|
|
191
|
-
alt:
|
|
192
|
-
className:
|
|
199
|
+
children: [/* @__PURE__ */ f("img", {
|
|
200
|
+
ref: u,
|
|
201
|
+
src: e,
|
|
202
|
+
alt: t,
|
|
203
|
+
className: q.image,
|
|
193
204
|
style: {
|
|
194
|
-
width:
|
|
195
|
-
height:
|
|
205
|
+
width: _.width,
|
|
206
|
+
height: _.height
|
|
196
207
|
},
|
|
197
|
-
onLoad:
|
|
198
|
-
onClick:
|
|
208
|
+
onLoad: S,
|
|
209
|
+
onClick: E,
|
|
199
210
|
draggable: !1
|
|
200
|
-
}),
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
className:
|
|
203
|
-
onMouseDown: (e) =>
|
|
211
|
+
}), o && /* @__PURE__ */ p(d, { children: [
|
|
212
|
+
/* @__PURE__ */ f("div", {
|
|
213
|
+
className: b(q.resizeHandle, q.bottomRight),
|
|
214
|
+
onMouseDown: (e) => C(e, "bottom-right")
|
|
204
215
|
}),
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
className:
|
|
207
|
-
onMouseDown: (e) =>
|
|
216
|
+
/* @__PURE__ */ f("div", {
|
|
217
|
+
className: b(q.resizeHandle, q.bottomLeft),
|
|
218
|
+
onMouseDown: (e) => C(e, "bottom-left")
|
|
208
219
|
}),
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
-
className:
|
|
211
|
-
onMouseDown: (e) =>
|
|
220
|
+
/* @__PURE__ */ f("div", {
|
|
221
|
+
className: b(q.resizeHandle, q.topRight),
|
|
222
|
+
onMouseDown: (e) => C(e, "top-right")
|
|
212
223
|
}),
|
|
213
|
-
/* @__PURE__ */
|
|
214
|
-
className:
|
|
215
|
-
onMouseDown: (e) =>
|
|
224
|
+
/* @__PURE__ */ f("div", {
|
|
225
|
+
className: b(q.resizeHandle, q.topLeft),
|
|
226
|
+
onMouseDown: (e) => C(e, "top-left")
|
|
216
227
|
})
|
|
217
228
|
] })]
|
|
218
229
|
});
|
|
219
|
-
},
|
|
230
|
+
}, J = class e extends se {
|
|
220
231
|
static getType() {
|
|
221
232
|
return "image";
|
|
222
233
|
}
|
|
@@ -262,7 +273,7 @@ var U = (e) => {
|
|
|
262
273
|
n.__width = e, n.__height = t;
|
|
263
274
|
}
|
|
264
275
|
decorate() {
|
|
265
|
-
return /* @__PURE__ */
|
|
276
|
+
return /* @__PURE__ */ f(fe, {
|
|
266
277
|
src: this.__src,
|
|
267
278
|
altText: this.__altText,
|
|
268
279
|
width: this.__width,
|
|
@@ -272,13 +283,13 @@ var U = (e) => {
|
|
|
272
283
|
}
|
|
273
284
|
static importDOM() {
|
|
274
285
|
return { img: () => ({
|
|
275
|
-
conversion:
|
|
286
|
+
conversion: me,
|
|
276
287
|
priority: 0
|
|
277
288
|
}) };
|
|
278
289
|
}
|
|
279
290
|
static importJSON(e) {
|
|
280
291
|
let { src: t, altText: n, width: r, height: i } = e;
|
|
281
|
-
return
|
|
292
|
+
return Y({
|
|
282
293
|
src: t,
|
|
283
294
|
altText: n,
|
|
284
295
|
width: r,
|
|
@@ -299,13 +310,13 @@ var U = (e) => {
|
|
|
299
310
|
return !0;
|
|
300
311
|
}
|
|
301
312
|
};
|
|
302
|
-
function
|
|
303
|
-
return new
|
|
313
|
+
function Y({ src: e, altText: t, width: n, height: r, key: i }) {
|
|
314
|
+
return new J(e, t, n, r, i);
|
|
304
315
|
}
|
|
305
|
-
function
|
|
306
|
-
return e instanceof
|
|
316
|
+
function pe(e) {
|
|
317
|
+
return e instanceof J;
|
|
307
318
|
}
|
|
308
|
-
function
|
|
319
|
+
function me(e) {
|
|
309
320
|
if (e instanceof HTMLImageElement) {
|
|
310
321
|
let { src: t, alt: n, style: r } = e, i, a;
|
|
311
322
|
if (r.width) {
|
|
@@ -316,7 +327,7 @@ function Y(e) {
|
|
|
316
327
|
let e = parseInt(r.height, 10);
|
|
317
328
|
isNaN(e) || (a = e);
|
|
318
329
|
}
|
|
319
|
-
return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node:
|
|
330
|
+
return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: Y({
|
|
320
331
|
src: t,
|
|
321
332
|
altText: n,
|
|
322
333
|
width: i,
|
|
@@ -327,23 +338,23 @@ function Y(e) {
|
|
|
327
338
|
}
|
|
328
339
|
//#endregion
|
|
329
340
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
330
|
-
function
|
|
331
|
-
let [e] =
|
|
332
|
-
return
|
|
341
|
+
function he() {
|
|
342
|
+
let [e] = L();
|
|
343
|
+
return g(() => e.registerCommand(a, (e) => (j([Y(e)]), !0), ae), [e]), null;
|
|
333
344
|
}
|
|
334
345
|
//#endregion
|
|
335
346
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
336
|
-
function
|
|
337
|
-
let [e] =
|
|
338
|
-
return
|
|
347
|
+
function ge() {
|
|
348
|
+
let [e] = L(), t = v(0);
|
|
349
|
+
return g(() => e.registerCommand(ce, (n) => {
|
|
339
350
|
let r = Date.now(), i = r - t.current;
|
|
340
351
|
return t.current = r, i < 250 && i > 0 ? (e.update(() => {
|
|
341
|
-
let e =
|
|
342
|
-
if (
|
|
352
|
+
let e = A();
|
|
353
|
+
if (N(e)) {
|
|
343
354
|
let t = e.anchor.getNode().getTopLevelElement();
|
|
344
355
|
if (t && t.getTextContent().trim() === "") {
|
|
345
|
-
let n =
|
|
346
|
-
|
|
356
|
+
let n = te();
|
|
357
|
+
z(e, {
|
|
347
358
|
"background-color": "",
|
|
348
359
|
color: "",
|
|
349
360
|
"font-size": "",
|
|
@@ -356,57 +367,57 @@ function fe() {
|
|
|
356
367
|
}
|
|
357
368
|
}
|
|
358
369
|
}), n?.preventDefault(), !0) : !1;
|
|
359
|
-
},
|
|
370
|
+
}, oe), [e]), null;
|
|
360
371
|
}
|
|
361
372
|
//#endregion
|
|
362
373
|
//#region src/components/Editor/EditorCore.tsx
|
|
363
374
|
var X = (e) => {
|
|
364
|
-
let { height: t = 126, onChange: n, toolbar: r } = e, [
|
|
365
|
-
containerRef:
|
|
366
|
-
getPopupContainer: () =>
|
|
367
|
-
}), []),
|
|
375
|
+
let { height: t = 126, onChange: n, toolbar: r } = e, [i] = L(), a = v(null), o = v(null), c = _(() => ({
|
|
376
|
+
containerRef: a,
|
|
377
|
+
getPopupContainer: () => a.current || document.body
|
|
378
|
+
}), []), l = h((e) => {
|
|
368
379
|
e.read(() => {
|
|
369
|
-
let t =
|
|
370
|
-
|
|
380
|
+
let t = k().getTextContent(), r = D(i, null), a = !t.trim() && (r === "<p><br></p>" || r === "<p></p>" || r === "" || /^<p>\s*<br>\s*<\/p>$/.test(r)) ? null : r;
|
|
381
|
+
o.current = a, n({
|
|
371
382
|
text: t,
|
|
372
|
-
html:
|
|
383
|
+
html: a
|
|
373
384
|
}, e);
|
|
374
385
|
});
|
|
375
|
-
}, [n,
|
|
376
|
-
|
|
377
|
-
e.value !== void 0 && e.value !==
|
|
378
|
-
|
|
386
|
+
}, [n, i]);
|
|
387
|
+
g(() => {
|
|
388
|
+
e.value !== void 0 && e.value !== o.current && i.update(() => {
|
|
389
|
+
k().clear(), e.value && e.value.trim() && j(O(i, new DOMParser().parseFromString(e.value, "text/html")));
|
|
379
390
|
});
|
|
380
|
-
}, [e.value,
|
|
381
|
-
let
|
|
382
|
-
return /* @__PURE__ */
|
|
383
|
-
value:
|
|
384
|
-
children: /* @__PURE__ */
|
|
385
|
-
ref:
|
|
386
|
-
className:
|
|
391
|
+
}, [e.value, i]);
|
|
392
|
+
let u = r?.config?.length ? r?.config : [], d = i.isEditable();
|
|
393
|
+
return /* @__PURE__ */ f(s.Provider, {
|
|
394
|
+
value: c,
|
|
395
|
+
children: /* @__PURE__ */ p("div", {
|
|
396
|
+
ref: a,
|
|
397
|
+
className: K["bsy-lexical-editor"],
|
|
387
398
|
onClick: () => {
|
|
388
|
-
|
|
399
|
+
d || (i.setEditable(!0), i.focus(() => {}, { defaultSelection: "rootEnd" }));
|
|
389
400
|
},
|
|
390
401
|
children: [
|
|
391
|
-
|
|
392
|
-
config:
|
|
402
|
+
u.length > 0 && /* @__PURE__ */ f(de, {
|
|
403
|
+
config: u,
|
|
393
404
|
style: { ...r?.style }
|
|
394
405
|
}),
|
|
395
|
-
/* @__PURE__ */
|
|
396
|
-
contentEditable: /* @__PURE__ */
|
|
397
|
-
className:
|
|
406
|
+
/* @__PURE__ */ f(S, {
|
|
407
|
+
contentEditable: /* @__PURE__ */ f(C, {
|
|
408
|
+
className: K["bsy-lexical-editor__content-editable"],
|
|
398
409
|
style: {
|
|
399
410
|
height: t,
|
|
400
|
-
cursor:
|
|
411
|
+
cursor: d ? "auto" : "text"
|
|
401
412
|
}
|
|
402
413
|
}),
|
|
403
|
-
ErrorBoundary:
|
|
414
|
+
ErrorBoundary: E
|
|
404
415
|
}),
|
|
405
|
-
/* @__PURE__ */
|
|
406
|
-
/* @__PURE__ */
|
|
407
|
-
/* @__PURE__ */
|
|
408
|
-
/* @__PURE__ */
|
|
409
|
-
/* @__PURE__ */
|
|
416
|
+
/* @__PURE__ */ f(W, {}),
|
|
417
|
+
/* @__PURE__ */ f(he, {}),
|
|
418
|
+
/* @__PURE__ */ f(ge, {}),
|
|
419
|
+
/* @__PURE__ */ f(w, {}),
|
|
420
|
+
/* @__PURE__ */ f(T, { onChange: l })
|
|
410
421
|
]
|
|
411
422
|
})
|
|
412
423
|
});
|
|
@@ -414,7 +425,7 @@ var X = (e) => {
|
|
|
414
425
|
X.displayName = "BsyLexicalEditorCore";
|
|
415
426
|
//#endregion
|
|
416
427
|
//#region src/components/Editor/nodes/ExtendedTextNode.tsx
|
|
417
|
-
var Z = class e extends
|
|
428
|
+
var Z = class e extends F {
|
|
418
429
|
constructor(e, t) {
|
|
419
430
|
super(e, t);
|
|
420
431
|
}
|
|
@@ -425,7 +436,7 @@ var Z = class e extends a {
|
|
|
425
436
|
return new e(t.__text, t.__key);
|
|
426
437
|
}
|
|
427
438
|
static importDOM() {
|
|
428
|
-
let e =
|
|
439
|
+
let e = F.importDOM();
|
|
429
440
|
return {
|
|
430
441
|
...e,
|
|
431
442
|
code: () => ({
|
|
@@ -455,14 +466,14 @@ var Z = class e extends a {
|
|
|
455
466
|
};
|
|
456
467
|
}
|
|
457
468
|
static importJSON(e) {
|
|
458
|
-
return
|
|
469
|
+
return _e().updateFromJSON(e);
|
|
459
470
|
}
|
|
460
471
|
isSimpleText() {
|
|
461
472
|
return this.__type === "extended-text" && this.__mode === 0;
|
|
462
473
|
}
|
|
463
474
|
};
|
|
464
|
-
function
|
|
465
|
-
return
|
|
475
|
+
function _e(e = "") {
|
|
476
|
+
return ee(new Z(e));
|
|
466
477
|
}
|
|
467
478
|
function Q(e) {
|
|
468
479
|
return (t) => {
|
|
@@ -470,19 +481,19 @@ function Q(e) {
|
|
|
470
481
|
if (!n) return null;
|
|
471
482
|
let r = n.conversion(t);
|
|
472
483
|
if (!r) return r;
|
|
473
|
-
let i = t.style.backgroundColor, a = t.style.color,
|
|
484
|
+
let i = t.style.backgroundColor, a = t.style.color, o = t.style.fontFamily, s = t.style.fontWeight, c = t.style.fontSize, l = t.style.textDecoration;
|
|
474
485
|
return {
|
|
475
486
|
...r,
|
|
476
487
|
forChild: (e, t) => {
|
|
477
488
|
let n = (r?.forChild ?? ((e) => e))(e, t);
|
|
478
|
-
if (
|
|
489
|
+
if (P(n)) {
|
|
479
490
|
let e = [
|
|
480
491
|
i ? `background-color: ${i}` : null,
|
|
481
492
|
a ? `color: ${a}` : null,
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
493
|
+
o ? `font-family: ${o}` : null,
|
|
494
|
+
s ? `font-weight: ${s}` : null,
|
|
495
|
+
c ? `font-size: ${c}` : null,
|
|
496
|
+
l ? `text-decoration: ${l}` : null
|
|
486
497
|
].filter((e) => e !== null).join("; ");
|
|
487
498
|
if (e.length) return n.setStyle(e);
|
|
488
499
|
}
|
|
@@ -495,8 +506,8 @@ function Q(e) {
|
|
|
495
506
|
//#region src/components/Editor/Editor.tsx
|
|
496
507
|
var $ = (e) => {
|
|
497
508
|
let { autoFocus: t = !1 } = e;
|
|
498
|
-
return /* @__PURE__ */
|
|
499
|
-
initialConfig:
|
|
509
|
+
return /* @__PURE__ */ f(x, {
|
|
510
|
+
initialConfig: _(() => ({
|
|
500
511
|
namespace: "bsyLexicalEditor",
|
|
501
512
|
onError: (e) => {
|
|
502
513
|
console.error("Lexical error", e);
|
|
@@ -511,20 +522,20 @@ var $ = (e) => {
|
|
|
511
522
|
link: "editor-link"
|
|
512
523
|
},
|
|
513
524
|
nodes: [
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
525
|
+
U,
|
|
526
|
+
H,
|
|
527
|
+
J,
|
|
517
528
|
Z,
|
|
518
529
|
{
|
|
519
|
-
replace:
|
|
530
|
+
replace: F,
|
|
520
531
|
with: (e) => new Z(e.__text),
|
|
521
532
|
withKlass: Z
|
|
522
533
|
}
|
|
523
534
|
]
|
|
524
535
|
}), [t]),
|
|
525
|
-
children: /* @__PURE__ */
|
|
536
|
+
children: /* @__PURE__ */ f(X, { ...e })
|
|
526
537
|
});
|
|
527
538
|
};
|
|
528
539
|
$.displayName = "BsyLexicalEditor";
|
|
529
540
|
//#endregion
|
|
530
|
-
export {
|
|
541
|
+
export { re as $getRoot, t as BaseButton, $ as default, o as listRegisteredToolbarButtons, n as registerToolbarButton, e as unregisterToolbarButton, I as useLexicalComposerContext };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createFromIconfontCN as e } from "@ant-design/icons";
|
|
2
|
+
import { isNumber as t } from "lodash-es";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Icon/Icon.tsx
|
|
5
|
+
var r = e({ scriptUrl: "https://at.alicdn.com/t/c/font_4786625_ofg0ibxfhle.js" }), i = ({ name: e, style: i, className: a, onClick: o, color: s, size: c = 16 }) => {
|
|
6
|
+
let l = {
|
|
7
|
+
color: s,
|
|
8
|
+
fontSize: t(c) ? `${c}px` : c,
|
|
9
|
+
...i
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ n(r, {
|
|
12
|
+
onClick: o,
|
|
13
|
+
type: `icon-${e}`,
|
|
14
|
+
style: l,
|
|
15
|
+
className: `${a || ""}`
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { i as t };
|
package/dist/Icon/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./Icon-
|
|
1
|
+
import { t as e } from "./Icon-CTZCSuVg.js";
|
|
2
2
|
export { e as default };
|