@baishuyun/ui-base 6.7.3 → 6.8.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/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 +4 -4
- package/dist/Amap/{AmapProvider-DSjQj2oA.js → AmapProvider-Cwi6WOe0.js} +1 -1
- package/dist/Amap/hooks/index.js +1 -1
- package/dist/Amap/index.js +4 -4
- package/dist/Calendar/{Calendar-C2iO_3cX.js → Calendar-DnQrN8KB.js} +2 -2
- package/dist/Calendar/context/index.js +1 -1
- package/dist/Calendar/index.js +5 -5
- 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-BtTIb9tX.js → ColorPicker-CL57cSDG.js} +2 -1
- package/dist/ColorPicker/index.js +4 -4
- package/dist/ConfigProvider/index.js +3 -3
- package/dist/DatePicker/{DatePicker-BMTK0Phw.js → DatePicker-C0XbZmrZ.js} +2 -2
- package/dist/DatePicker/{DatePickerPanel-BH_Z4e88.js → DatePickerPanel-BEn16cat.js} +3 -3
- package/dist/DatePicker/index.js +4 -4
- package/dist/DatePicker/style/index.js +1 -1
- package/dist/DropDown/{DropDown-CdTjlySd.js → DropDown-yDH9V_9Y.js} +2 -2
- package/dist/DropDown/index.js +5 -5
- package/dist/DropDown/style/index.js +1 -1
- package/dist/Editor/{Buttons-BcP66z6E.js → Buttons-BivKInBV.js} +144 -124
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +7 -7
- package/dist/Editor/constants/index.js +1 -1
- package/dist/Editor/index.js +274 -164
- package/dist/Gantt/GanttChart/index.js +7 -7
- package/dist/Gantt/{GanttChart-BYzMKcZ2.js → GanttChart-CDw1IQ4F.js} +2 -2
- package/dist/Gantt/GanttTable/index.js +5 -5
- package/dist/Gantt/{GanttTable-DqJziqML.js → GanttTable-xbXD_PWI.js} +1 -1
- package/dist/Gantt/GanttToolBar/index.js +6 -6
- package/dist/Gantt/{GanttToolBar-C50n7PD9.js → GanttToolBar-BTeTsR6Z.js} +2 -2
- package/dist/Gantt/index.js +9 -9
- 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/InputTag-hzCCJQ1z.js +144 -0
- package/dist/InputTag/index.js +4 -2
- package/dist/Loading/Loading-DiywS7ex.js +19 -0
- package/dist/Loading/index.js +4 -2
- package/dist/Modal/index.js +1 -1
- package/dist/NotFoundContent/index.js +1 -1
- package/dist/Radio/{Radio-DSoZotcs.js → Radio-CX9cUqb7.js} +12 -12
- package/dist/Radio/index.js +2 -2
- package/dist/ScrollBar/index.js +1 -1
- package/dist/Segmented/index.js +1 -1
- package/dist/Select/{Select-DujgkkUp.js → Select-D6EK7whJ.js} +195 -194
- package/dist/Select/{SelectInputSearch-Bikrj3FI.js → SelectInputSearch-COUzreau.js} +1 -1
- package/dist/Select/index.js +7 -7
- package/dist/Table/{Table-k9wdWm6V.js → Table-yQXQEk6d.js} +1 -1
- package/dist/Table/hooks/index.js +1 -1
- package/dist/Table/index.js +4 -4
- package/dist/Table/style/index.js +1 -1
- package/dist/Table/utils/index.js +1 -1
- package/dist/Tabs/Tabs-BiKW70CL.js +398 -0
- package/dist/Tabs/index.js +4 -2
- package/dist/Tooltip/index.js +1 -1
- package/dist/Tree/index.js +3 -3
- package/dist/Tree/utils/index.js +1 -1
- package/dist/components/DropDown/interface.d.ts +167 -169
- package/dist/components/Editor/LengthBadge.d.ts +6 -0
- package/dist/components/Editor/ToolbarPlugin/BaseButton/BaseButton.d.ts +1 -1
- package/dist/components/Editor/ToolbarPlugin/ToolbarPlugin.d.ts +5 -1
- package/dist/components/Editor/ToolbarPlugin/context/EditorToolbarThemeContext.d.ts +6 -0
- package/dist/components/Editor/ToolbarPlugin/interface.d.ts +30 -32
- package/dist/components/Editor/index.d.ts +1 -1
- package/dist/components/Editor/interface.d.ts +118 -60
- package/dist/components/Editor/plugins/MaxLengthPlugin.d.ts +7 -0
- package/dist/components/Editor/utils/resolveEditorToolbarThemeVars.d.ts +5 -0
- package/dist/components/Editor/utils/textLength.d.ts +4 -0
- package/dist/components/InputTag/interface.d.ts +32 -32
- package/dist/components/Radio/interface.d.ts +95 -97
- package/dist/components/Tabs/TabSelect/interface.d.ts +23 -25
- package/dist/components/Tabs/interface.d.ts +58 -60
- package/dist/components/Tree/types/node.d.ts +19 -19
- package/dist/components/Tree/types/tree.d.ts +81 -83
- package/dist/components/index.d.ts +2 -0
- package/dist/index.js +18 -18
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/lang/en-US.json.d.ts +177 -166
- package/dist/locale/lang/zh-CN.json.d.ts +177 -166
- package/dist/locale/lang/zh-TW.json.d.ts +177 -166
- package/dist/style.css +1 -1
- package/dist/vendors/{ConfigProvider-C3Uwzinj.js → ConfigProvider-DxrZpdIb.js} +23 -1
- package/dist/vendors/{LocaleContext-B1HuhJc-.js → LocaleContext-Dcw6C1LX.js} +11 -0
- package/dist/vendors/{Tree-DQkpLl6f.js → Tree-DXmVRDn0.js} +8 -7
- package/dist/vendors/{useLocale-BYtF5pxt.js → useLocale-BKZX2_zw.js} +1 -1
- package/dist/vendors/{version-Dkos5Cha.js → version-4HBYLKDL.js} +1 -1
- package/dist/vite-env.d.ts +13 -13
- package/dist/vitest-matchers.d.ts +0 -1
- package/package.json +8 -8
- package/dist/InputTag/InputTag-LnUqz0Hz.js +0 -143
- package/dist/Loading/Loading-CcTZogVx.js +0 -15
- package/dist/Tabs/Tabs-Ctgg45Ox.js +0 -410
package/dist/Editor/index.js
CHANGED
|
@@ -1,76 +1,91 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-4HBYLKDL.js";
|
|
2
2
|
import "../ScrollBar/style-D26azwz6.js";
|
|
3
3
|
import "../Icon/Icon-BBDcb-yw.js";
|
|
4
|
-
import "../vendors/LocaleContext-
|
|
4
|
+
import "../vendors/LocaleContext-Dcw6C1LX.js";
|
|
5
5
|
import "../Modal/Modal-LiztSF7x.js";
|
|
6
|
-
import "../ColorPicker/ColorPicker-
|
|
6
|
+
import "../ColorPicker/ColorPicker-CL57cSDG.js";
|
|
7
7
|
import "../vendors/useFloatingOverlay-BApqkHSu.js";
|
|
8
|
-
import "../vendors/useLocale-
|
|
8
|
+
import "../vendors/useLocale-BKZX2_zw.js";
|
|
9
9
|
import "../vendors/color-D6XBXROa.js";
|
|
10
10
|
import "../vendors/useLatchedPopupPortalRoot-4fVhqVT4.js";
|
|
11
|
-
import "../
|
|
11
|
+
import { t as e } from "../vendors/cssVars-BYg1matG.js";
|
|
12
|
+
import "../Select/SelectInputSearch-COUzreau.js";
|
|
12
13
|
import "../CheckBox/CheckBox-ByWSy9Yr.js";
|
|
13
14
|
import "../CheckBox/CheckBox-nBm0u6zX.js";
|
|
14
15
|
import "../NotFoundContent/NotFoundContent-BLmzWNBi.js";
|
|
15
16
|
import "../ScrollBar/ScrollBar-QhXVe8zd.js";
|
|
16
17
|
import "../vendors/useFloatingPortal-CmVJbuRm.js";
|
|
17
|
-
import "../DropDown/DropDown-
|
|
18
|
+
import "../DropDown/DropDown-yDH9V_9Y.js";
|
|
18
19
|
import "../DropDown/style-Fdp-U4md.js";
|
|
19
|
-
import { a as
|
|
20
|
-
import { DEFAULT_BACKGROUND_COLOR as
|
|
21
|
-
import { Fragment as
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import { LexicalComposer as
|
|
25
|
-
import { RichTextPlugin as
|
|
26
|
-
import { ContentEditable as
|
|
27
|
-
import { HistoryPlugin as
|
|
28
|
-
import { OnChangePlugin as
|
|
29
|
-
import { LexicalErrorBoundary as
|
|
30
|
-
import { $generateHtmlFromNodes as
|
|
31
|
-
import { $applyNodeReplacement as
|
|
32
|
-
import { useLexicalComposerContext as
|
|
33
|
-
import { $getSelectionStyleValueForProperty as R, $patchStyleText as z } from "@lexical/selection";
|
|
34
|
-
import { $findMatchingParent as B } from "@lexical/utils";
|
|
35
|
-
import { $isLinkNode as
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
20
|
+
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, u as l } from "./Buttons-BivKInBV.js";
|
|
21
|
+
import { DEFAULT_BACKGROUND_COLOR as u, DEFAULT_FONT_COLOR as d, DEFAULT_FONT_SIZE as f } from "./constants/index.js";
|
|
22
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
23
|
+
import g, { useCallback as _, useEffect as v, useMemo as y, useRef as b, useState as x } from "react";
|
|
24
|
+
import S from "clsx";
|
|
25
|
+
import { LexicalComposer as C } from "@lexical/react/LexicalComposer";
|
|
26
|
+
import { RichTextPlugin as w } from "@lexical/react/LexicalRichTextPlugin";
|
|
27
|
+
import { ContentEditable as T } from "@lexical/react/LexicalContentEditable";
|
|
28
|
+
import { HistoryPlugin as E } from "@lexical/react/LexicalHistoryPlugin";
|
|
29
|
+
import { OnChangePlugin as ee } from "@lexical/react/LexicalOnChangePlugin";
|
|
30
|
+
import { LexicalErrorBoundary as te } from "@lexical/react/LexicalErrorBoundary";
|
|
31
|
+
import { $generateHtmlFromNodes as ne, $generateNodesFromDOM as re } from "@lexical/html";
|
|
32
|
+
import { $applyNodeReplacement as D, $createParagraphNode as O, $getNodeByKey as k, $getRoot as ie, $getRoot as A, $getSelection as j, $insertNodes as M, $isElementNode as ae, $isRangeSelection as N, $isRootOrShadowRoot as oe, $isTextNode as se, COMMAND_PRIORITY_EDITOR as ce, COMMAND_PRIORITY_LOW as le, DecoratorNode as ue, KEY_ENTER_COMMAND as P, RootNode as F, TextNode as I } from "lexical";
|
|
33
|
+
import { useLexicalComposerContext as de, useLexicalComposerContext as L } from "@lexical/react/LexicalComposerContext";
|
|
34
|
+
import { $getSelectionStyleValueForProperty as R, $patchStyleText as fe, $trimTextContentFromAnchor as z } from "@lexical/selection";
|
|
35
|
+
import { $findMatchingParent as B, $restoreEditorState as V } from "@lexical/utils";
|
|
36
|
+
import { $isLinkNode as pe, AutoLinkNode as me, LinkNode as he } from "@lexical/link";
|
|
37
|
+
import { useLexicalEditable as ge } from "@lexical/react/useLexicalEditable";
|
|
38
|
+
import { LinkPlugin as _e } from "@lexical/react/LexicalLinkPlugin";
|
|
39
|
+
//#region src/components/Editor/utils/resolveEditorToolbarThemeVars.ts
|
|
40
|
+
var H = (e) => {
|
|
41
|
+
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
42
|
+
}, ve = (t) => {
|
|
43
|
+
if (!t) return {};
|
|
44
|
+
let n = {};
|
|
45
|
+
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
|
+
}, U = (e) => {
|
|
47
|
+
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
48
|
+
if (typeof e == "string") {
|
|
49
|
+
let t = Number.parseFloat(e);
|
|
50
|
+
if (Number.isFinite(t)) return t;
|
|
51
|
+
}
|
|
52
|
+
return 14;
|
|
53
|
+
}, W = {
|
|
54
|
+
"bsy-lexical__toolbar": "_bsy-lexical__toolbar_1tygc_1",
|
|
55
|
+
"bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_1tygc_10",
|
|
56
|
+
"bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_1tygc_16"
|
|
42
57
|
};
|
|
43
58
|
//#endregion
|
|
44
59
|
//#region src/components/Editor/hooks/useTextFormatsState.ts
|
|
45
|
-
function
|
|
46
|
-
let [e] = L(), [t, n] =
|
|
60
|
+
function ye() {
|
|
61
|
+
let [e] = L(), [t, n] = x({
|
|
47
62
|
bold: !1,
|
|
48
63
|
italic: !1,
|
|
49
64
|
underline: !1,
|
|
50
|
-
fontSize:
|
|
51
|
-
fontColor:
|
|
52
|
-
backgroundColor:
|
|
65
|
+
fontSize: f,
|
|
66
|
+
fontColor: d,
|
|
67
|
+
backgroundColor: u,
|
|
53
68
|
align: "left",
|
|
54
69
|
link: void 0
|
|
55
70
|
});
|
|
56
|
-
return
|
|
71
|
+
return v(() => e.registerUpdateListener(({ editorState: e }) => {
|
|
57
72
|
e.read(() => {
|
|
58
|
-
let e =
|
|
73
|
+
let e = j();
|
|
59
74
|
if (N(e)) {
|
|
60
|
-
let t = R(e, "font-size",
|
|
75
|
+
let t = R(e, "font-size", f), r = R(e, "color", d), i = R(e, "background-color", u), a = e.anchor.getNode(), o = a.getKey() === "root" ? a : B(a, (e) => {
|
|
61
76
|
let t = e.getParent();
|
|
62
|
-
return t !== null &&
|
|
77
|
+
return t !== null && oe(t);
|
|
63
78
|
});
|
|
64
79
|
o === null && (o = a.getTopLevelElementOrThrow());
|
|
65
|
-
let s = {},
|
|
66
|
-
|
|
80
|
+
let s = {}, c = B(a, pe);
|
|
81
|
+
c ? (s.link = c.getURL(), s.linkText = c.getTextContent(), s.newBlank = c.getTarget() === "_blank") : s.linkText = e.getTextContent(), n({
|
|
67
82
|
bold: e.hasFormat("bold"),
|
|
68
83
|
italic: e.hasFormat("italic"),
|
|
69
84
|
underline: e.hasFormat("underline"),
|
|
70
85
|
fontSize: t,
|
|
71
86
|
fontColor: r,
|
|
72
87
|
backgroundColor: i,
|
|
73
|
-
align:
|
|
88
|
+
align: ae(o) ? o.getFormatType() : "left",
|
|
74
89
|
link: s
|
|
75
90
|
});
|
|
76
91
|
}
|
|
@@ -79,30 +94,39 @@ function le() {
|
|
|
79
94
|
}
|
|
80
95
|
//#endregion
|
|
81
96
|
//#region src/components/Editor/ToolbarPlugin/context/TextFormatProvider.tsx
|
|
82
|
-
var
|
|
83
|
-
let t =
|
|
84
|
-
return /* @__PURE__ */
|
|
97
|
+
var be = (e) => {
|
|
98
|
+
let t = ye();
|
|
99
|
+
return /* @__PURE__ */ m(l.Provider, {
|
|
85
100
|
value: t,
|
|
86
101
|
children: e.children
|
|
87
102
|
});
|
|
88
|
-
},
|
|
89
|
-
let { config: t = [], style: n } = e, r = (e, t) => {
|
|
90
|
-
let n = typeof e == "string" ? e : e.name, r =
|
|
91
|
-
return r ? typeof e == "string" ? /* @__PURE__ */
|
|
103
|
+
}, xe = (e) => {
|
|
104
|
+
let { config: t = [], style: n, theme: r } = e, o = y(() => ve(r), [r]), s = y(() => ({ iconSize: U(r?.iconSize) }), [r?.iconSize]), c = (e, t) => {
|
|
105
|
+
let n = typeof e == "string" ? e : e.name, r = a(n);
|
|
106
|
+
return r ? typeof e == "string" ? /* @__PURE__ */ m(r, {}, `${n}-${t}`) : /* @__PURE__ */ m(r, { ...e.props }, `${n}-${t}`) : (console.warn(`[ToolbarPlugin] Button "${n}" is not registered.`), null);
|
|
92
107
|
};
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
return /* @__PURE__ */ m(i, {
|
|
109
|
+
value: s,
|
|
110
|
+
children: /* @__PURE__ */ m(be, { children: /* @__PURE__ */ m("div", {
|
|
111
|
+
className: W["bsy-lexical__toolbar"],
|
|
112
|
+
style: {
|
|
113
|
+
...o,
|
|
114
|
+
...n
|
|
115
|
+
},
|
|
116
|
+
children: t.map((e, n) => /* @__PURE__ */ h("div", {
|
|
117
|
+
className: W["bsy-lexical__toolbar-group"],
|
|
118
|
+
"data-group": e.key,
|
|
119
|
+
children: [e.buttons.map((e, t) => c(e, t)), n < t.length - 1 && /* @__PURE__ */ m("div", { className: W["bsy-lexical__toolbar-divider"] })]
|
|
120
|
+
}, e.key + n))
|
|
121
|
+
}) })
|
|
122
|
+
});
|
|
123
|
+
}, 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"
|
|
102
129
|
}, K = {
|
|
103
|
-
"bsy-lexical-editor": "_bsy-lexical-editor_19ssw_1",
|
|
104
|
-
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_19ssw_6"
|
|
105
|
-
}, q = {
|
|
106
130
|
imageWrapper: "_imageWrapper_y06h3_1",
|
|
107
131
|
selected: "_selected_y06h3_8",
|
|
108
132
|
resizing: "_resizing_y06h3_12",
|
|
@@ -112,19 +136,19 @@ var ue = (e) => {
|
|
|
112
136
|
topRight: "_topRight_y06h3_49",
|
|
113
137
|
bottomLeft: "_bottomLeft_y06h3_54",
|
|
114
138
|
bottomRight: "_bottomRight_y06h3_59"
|
|
115
|
-
},
|
|
116
|
-
let [a] = L(), [o, s] =
|
|
139
|
+
}, Se = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
|
|
140
|
+
let [a] = L(), [o, s] = x(!1), [c, l] = x(null), u = b(null), [d, f] = x({
|
|
117
141
|
width: n || void 0,
|
|
118
142
|
height: r || void 0
|
|
119
|
-
}),
|
|
120
|
-
n && r &&
|
|
143
|
+
}), y = _(() => {
|
|
144
|
+
n && r && f({
|
|
121
145
|
width: n,
|
|
122
146
|
height: r
|
|
123
147
|
});
|
|
124
|
-
}, [n, r]), C =
|
|
148
|
+
}, [n, r]), C = _((e, t) => {
|
|
125
149
|
if (e.preventDefault(), e.stopPropagation(), !u.current) return;
|
|
126
|
-
let n =
|
|
127
|
-
(!
|
|
150
|
+
let n = d.width || u.current.offsetWidth, r = d.height || u.current.offsetHeight, i = n / r;
|
|
151
|
+
(!d.width || !d.height) && f({
|
|
128
152
|
width: n,
|
|
129
153
|
height: r
|
|
130
154
|
}), l({
|
|
@@ -136,7 +160,7 @@ var ue = (e) => {
|
|
|
136
160
|
aspectRatio: i,
|
|
137
161
|
direction: t
|
|
138
162
|
});
|
|
139
|
-
}, [
|
|
163
|
+
}, [d]), w = _((e) => {
|
|
140
164
|
if (!c?.isResizing) return;
|
|
141
165
|
let t = e.clientX - c.startX, n;
|
|
142
166
|
switch (c.direction) {
|
|
@@ -155,22 +179,22 @@ var ue = (e) => {
|
|
|
155
179
|
default: n = Math.max(50, c.startWidth + t);
|
|
156
180
|
}
|
|
157
181
|
let r = n / c.aspectRatio;
|
|
158
|
-
|
|
182
|
+
f({
|
|
159
183
|
width: n,
|
|
160
184
|
height: r
|
|
161
185
|
});
|
|
162
|
-
}, [c]), T =
|
|
186
|
+
}, [c]), T = _(() => {
|
|
163
187
|
c?.isResizing && (a.update(() => {
|
|
164
|
-
let e =
|
|
165
|
-
|
|
188
|
+
let e = k(i);
|
|
189
|
+
Ce(e) && e.setWidthAndHeight(d.width, d.height);
|
|
166
190
|
}), l(null));
|
|
167
191
|
}, [
|
|
168
192
|
a,
|
|
169
193
|
i,
|
|
170
|
-
|
|
194
|
+
d,
|
|
171
195
|
c
|
|
172
196
|
]);
|
|
173
|
-
|
|
197
|
+
g.useEffect(() => {
|
|
174
198
|
if (c?.isResizing) return document.addEventListener("mousemove", w), document.addEventListener("mouseup", T), () => {
|
|
175
199
|
document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", T);
|
|
176
200
|
};
|
|
@@ -179,62 +203,62 @@ var ue = (e) => {
|
|
|
179
203
|
w,
|
|
180
204
|
T
|
|
181
205
|
]);
|
|
182
|
-
let E =
|
|
206
|
+
let E = _(() => {
|
|
183
207
|
s(!0);
|
|
184
208
|
}, []);
|
|
185
|
-
return
|
|
209
|
+
return v(() => a.registerUpdateListener(({ editorState: e }) => {
|
|
186
210
|
e.read(() => {
|
|
187
|
-
let e =
|
|
211
|
+
let e = j();
|
|
188
212
|
N(e) && !e.getNodes().some((e) => e.getKey() === i || e.getParent() && e.getParent()?.getKey() === i) && o && s(!1);
|
|
189
213
|
});
|
|
190
214
|
}), [
|
|
191
215
|
a,
|
|
192
216
|
i,
|
|
193
217
|
o
|
|
194
|
-
]),
|
|
218
|
+
]), v(() => {
|
|
195
219
|
let e = (e) => {
|
|
196
220
|
o && u.current && !u.current.contains(e.target) && s(!1);
|
|
197
221
|
};
|
|
198
222
|
if (o) return document.addEventListener("mousedown", e), () => {
|
|
199
223
|
document.removeEventListener("mousedown", e);
|
|
200
224
|
};
|
|
201
|
-
}, [o]), /* @__PURE__ */
|
|
202
|
-
className:
|
|
203
|
-
[
|
|
204
|
-
[
|
|
225
|
+
}, [o]), /* @__PURE__ */ h("div", {
|
|
226
|
+
className: S(K.imageWrapper, {
|
|
227
|
+
[K.selected]: o,
|
|
228
|
+
[K.resizing]: c?.isResizing
|
|
205
229
|
}),
|
|
206
|
-
children: [/* @__PURE__ */
|
|
230
|
+
children: [/* @__PURE__ */ m("img", {
|
|
207
231
|
ref: u,
|
|
208
232
|
src: e,
|
|
209
233
|
alt: t,
|
|
210
|
-
className:
|
|
234
|
+
className: K.image,
|
|
211
235
|
style: {
|
|
212
|
-
width:
|
|
213
|
-
height:
|
|
236
|
+
width: d.width,
|
|
237
|
+
height: d.height
|
|
214
238
|
},
|
|
215
|
-
onLoad:
|
|
239
|
+
onLoad: y,
|
|
216
240
|
onClick: E,
|
|
217
241
|
draggable: !1
|
|
218
|
-
}), o && /* @__PURE__ */ p
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
className:
|
|
242
|
+
}), o && /* @__PURE__ */ h(p, { children: [
|
|
243
|
+
/* @__PURE__ */ m("div", {
|
|
244
|
+
className: S(K.resizeHandle, K.bottomRight),
|
|
221
245
|
onMouseDown: (e) => C(e, "bottom-right")
|
|
222
246
|
}),
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
-
className:
|
|
247
|
+
/* @__PURE__ */ m("div", {
|
|
248
|
+
className: S(K.resizeHandle, K.bottomLeft),
|
|
225
249
|
onMouseDown: (e) => C(e, "bottom-left")
|
|
226
250
|
}),
|
|
227
|
-
/* @__PURE__ */
|
|
228
|
-
className:
|
|
251
|
+
/* @__PURE__ */ m("div", {
|
|
252
|
+
className: S(K.resizeHandle, K.topRight),
|
|
229
253
|
onMouseDown: (e) => C(e, "top-right")
|
|
230
254
|
}),
|
|
231
|
-
/* @__PURE__ */
|
|
232
|
-
className:
|
|
255
|
+
/* @__PURE__ */ m("div", {
|
|
256
|
+
className: S(K.resizeHandle, K.topLeft),
|
|
233
257
|
onMouseDown: (e) => C(e, "top-left")
|
|
234
258
|
})
|
|
235
259
|
] })]
|
|
236
260
|
});
|
|
237
|
-
},
|
|
261
|
+
}, q = class e extends ue {
|
|
238
262
|
static getType() {
|
|
239
263
|
return "image";
|
|
240
264
|
}
|
|
@@ -280,7 +304,7 @@ var ue = (e) => {
|
|
|
280
304
|
n.__width = e, n.__height = t;
|
|
281
305
|
}
|
|
282
306
|
decorate() {
|
|
283
|
-
return /* @__PURE__ */
|
|
307
|
+
return /* @__PURE__ */ m(Se, {
|
|
284
308
|
src: this.__src,
|
|
285
309
|
altText: this.__altText,
|
|
286
310
|
width: this.__width,
|
|
@@ -290,13 +314,13 @@ var ue = (e) => {
|
|
|
290
314
|
}
|
|
291
315
|
static importDOM() {
|
|
292
316
|
return { img: () => ({
|
|
293
|
-
conversion:
|
|
317
|
+
conversion: we,
|
|
294
318
|
priority: 0
|
|
295
319
|
}) };
|
|
296
320
|
}
|
|
297
321
|
static importJSON(e) {
|
|
298
322
|
let { src: t, altText: n, width: r, height: i } = e;
|
|
299
|
-
return
|
|
323
|
+
return J({
|
|
300
324
|
src: t,
|
|
301
325
|
altText: n,
|
|
302
326
|
width: r,
|
|
@@ -317,13 +341,13 @@ var ue = (e) => {
|
|
|
317
341
|
return !0;
|
|
318
342
|
}
|
|
319
343
|
};
|
|
320
|
-
function
|
|
321
|
-
return new
|
|
344
|
+
function J({ src: e, altText: t, width: n, height: r, key: i }) {
|
|
345
|
+
return new q(e, t, n, r, i);
|
|
322
346
|
}
|
|
323
|
-
function
|
|
324
|
-
return e instanceof
|
|
347
|
+
function Ce(e) {
|
|
348
|
+
return e instanceof q;
|
|
325
349
|
}
|
|
326
|
-
function
|
|
350
|
+
function we(e) {
|
|
327
351
|
if (e instanceof HTMLImageElement) {
|
|
328
352
|
let { src: t, alt: n, style: r } = e, i, a;
|
|
329
353
|
if (r.width) {
|
|
@@ -334,7 +358,7 @@ function me(e) {
|
|
|
334
358
|
let e = parseInt(r.height, 10);
|
|
335
359
|
isNaN(e) || (a = e);
|
|
336
360
|
}
|
|
337
|
-
return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node:
|
|
361
|
+
return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: J({
|
|
338
362
|
src: t,
|
|
339
363
|
altText: n,
|
|
340
364
|
width: i,
|
|
@@ -345,23 +369,23 @@ function me(e) {
|
|
|
345
369
|
}
|
|
346
370
|
//#endregion
|
|
347
371
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
348
|
-
function
|
|
372
|
+
function Te() {
|
|
349
373
|
let [e] = L();
|
|
350
|
-
return
|
|
374
|
+
return v(() => e.registerCommand(o, (e) => (M([J(e)]), !0), ce), [e]), null;
|
|
351
375
|
}
|
|
352
376
|
//#endregion
|
|
353
377
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
354
|
-
function
|
|
355
|
-
let [e] = L(), t =
|
|
356
|
-
return
|
|
378
|
+
function Ee() {
|
|
379
|
+
let [e] = L(), t = b(0);
|
|
380
|
+
return v(() => e.registerCommand(P, (n) => {
|
|
357
381
|
let r = Date.now(), i = r - t.current;
|
|
358
382
|
return t.current = r, i < 250 && i > 0 ? (e.update(() => {
|
|
359
|
-
let e =
|
|
383
|
+
let e = j();
|
|
360
384
|
if (N(e)) {
|
|
361
385
|
let t = e.anchor.getNode().getTopLevelElement();
|
|
362
386
|
if (t && t.getTextContent().trim() === "") {
|
|
363
|
-
let n =
|
|
364
|
-
|
|
387
|
+
let n = O();
|
|
388
|
+
fe(e, {
|
|
365
389
|
"background-color": "",
|
|
366
390
|
color: "",
|
|
367
391
|
"font-size": "",
|
|
@@ -374,57 +398,143 @@ function ge() {
|
|
|
374
398
|
}
|
|
375
399
|
}
|
|
376
400
|
}), n?.preventDefault(), !0) : !1;
|
|
377
|
-
},
|
|
401
|
+
}, le), [e]), null;
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/components/Editor/plugins/MaxLengthPlugin.tsx
|
|
405
|
+
function De({ maxLength: e, onMaxLengthExceed: t }) {
|
|
406
|
+
let [n] = L(), r = b(t);
|
|
407
|
+
return r.current = t, v(() => {
|
|
408
|
+
let t = null;
|
|
409
|
+
return n.registerNodeTransform(F, (i) => {
|
|
410
|
+
let a = i.getTextContentSize();
|
|
411
|
+
if (a <= e) return;
|
|
412
|
+
let o = n.getEditorState(), s = o.read(() => i.getTextContentSize()), c = a - e, l = j();
|
|
413
|
+
if (s === e && t !== o) {
|
|
414
|
+
t = o, V(n, o), r.current?.();
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (N(l) && l.isCollapsed()) {
|
|
418
|
+
z(n, l.anchor, c), r.current?.();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
i.selectEnd();
|
|
422
|
+
let u = j();
|
|
423
|
+
N(u) && (z(n, u.anchor, c), r.current?.());
|
|
424
|
+
});
|
|
425
|
+
}, [n, e]), null;
|
|
426
|
+
}
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region src/components/Editor/LengthBadge.tsx
|
|
429
|
+
var Y = ({ current: e, maxLength: t }) => {
|
|
430
|
+
let n = e > t;
|
|
431
|
+
return /* @__PURE__ */ h("div", {
|
|
432
|
+
className: S(G["bsy-lexical-editor__length-badge"], n && G["bsy-lexical-editor__length-badge--exceeded"]),
|
|
433
|
+
"aria-live": "polite",
|
|
434
|
+
children: [
|
|
435
|
+
e,
|
|
436
|
+
"/",
|
|
437
|
+
t
|
|
438
|
+
]
|
|
439
|
+
});
|
|
440
|
+
};
|
|
441
|
+
Y.displayName = "BsyLexicalEditorLengthBadge";
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/components/Editor/utils/textLength.ts
|
|
444
|
+
function Oe(e) {
|
|
445
|
+
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
446
|
+
}
|
|
447
|
+
function ke(e, t) {
|
|
448
|
+
let n = A(), r = n.getTextContentSize();
|
|
449
|
+
if (r <= t) return !1;
|
|
450
|
+
let i = r - t;
|
|
451
|
+
n.selectEnd();
|
|
452
|
+
let a = j();
|
|
453
|
+
return N(a) ? z(e, a.anchor, i) : Ae(i), !0;
|
|
454
|
+
}
|
|
455
|
+
function Ae(e) {
|
|
456
|
+
let t = e, n = A().getAllTextNodes();
|
|
457
|
+
for (let e = n.length - 1; e >= 0 && t > 0; e--) {
|
|
458
|
+
let r = n[e], i = r.getTextContent();
|
|
459
|
+
i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
|
|
460
|
+
}
|
|
378
461
|
}
|
|
379
462
|
//#endregion
|
|
380
463
|
//#region src/components/Editor/EditorCore.tsx
|
|
381
464
|
var X = (e) => {
|
|
382
|
-
let { height: t = 126, onChange: n, toolbar: r } = e, [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
465
|
+
let { height: t = 126, onChange: n, toolbar: r, theme: i, maxLength: a, onMaxLengthExceed: o } = e, [s] = L(), l = b(null), u = b(null), d = b(o);
|
|
466
|
+
d.current = o;
|
|
467
|
+
let f = Oe(a) ? a : void 0, [p, g] = x(0), C = y(() => ({
|
|
468
|
+
containerRef: l,
|
|
469
|
+
getPopupContainer: () => l.current || document.body
|
|
470
|
+
}), []), D = _((e) => {
|
|
386
471
|
e.read(() => {
|
|
387
|
-
let t =
|
|
388
|
-
|
|
472
|
+
let t = A().getTextContent(), r = ne(s, null), i = !t.trim() && (r === "<p><br></p>" || r === "<p></p>" || r === "" || /^<p>\s*<br>\s*<\/p>$/.test(r)) ? null : r;
|
|
473
|
+
u.current = i, f !== void 0 && g(t.length), n({
|
|
389
474
|
text: t,
|
|
390
|
-
html:
|
|
475
|
+
html: i
|
|
391
476
|
}, e);
|
|
392
|
-
});
|
|
393
|
-
}, [
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
477
|
+
}, { editor: s });
|
|
478
|
+
}, [
|
|
479
|
+
n,
|
|
480
|
+
s,
|
|
481
|
+
f
|
|
482
|
+
]);
|
|
483
|
+
v(() => {
|
|
484
|
+
f !== void 0 && s.getEditorState().read(() => {
|
|
485
|
+
g(A().getTextContentSize());
|
|
486
|
+
}, { editor: s });
|
|
487
|
+
}, [s, f]), v(() => {
|
|
488
|
+
if (e.value !== void 0 && e.value !== u.current) {
|
|
489
|
+
let t = !1;
|
|
490
|
+
s.update(() => {
|
|
491
|
+
A().clear(), e.value && e.value.trim() && (M(re(s, new DOMParser().parseFromString(e.value, "text/html"))), f !== void 0 && (t = ke(s, f)));
|
|
492
|
+
}), t && d.current?.();
|
|
493
|
+
}
|
|
494
|
+
}, [
|
|
495
|
+
e.value,
|
|
496
|
+
s,
|
|
497
|
+
f
|
|
498
|
+
]);
|
|
499
|
+
let O = r?.config?.length ? r?.config : [], k = ge();
|
|
500
|
+
return /* @__PURE__ */ m(c.Provider, {
|
|
501
|
+
value: C,
|
|
502
|
+
children: /* @__PURE__ */ h("div", {
|
|
503
|
+
ref: l,
|
|
504
|
+
className: G["bsy-lexical-editor"],
|
|
505
|
+
onClick: (e) => {
|
|
506
|
+
let t = s.getRootElement(), n = e.target;
|
|
507
|
+
!t || !n || !t.contains(n) || s.isEditable() || s.setEditable(!0);
|
|
407
508
|
},
|
|
408
509
|
children: [
|
|
409
|
-
|
|
410
|
-
config:
|
|
411
|
-
|
|
510
|
+
O.length > 0 && /* @__PURE__ */ m(xe, {
|
|
511
|
+
config: O,
|
|
512
|
+
theme: i?.toolbar,
|
|
513
|
+
style: r?.style
|
|
412
514
|
}),
|
|
413
|
-
/* @__PURE__ */
|
|
414
|
-
contentEditable: /* @__PURE__ */
|
|
415
|
-
className:
|
|
515
|
+
/* @__PURE__ */ m(w, {
|
|
516
|
+
contentEditable: /* @__PURE__ */ m(T, {
|
|
517
|
+
className: S(G["bsy-lexical-editor__content-editable"], f !== void 0 && G["bsy-lexical-editor__content-editable--with-length-badge"]),
|
|
416
518
|
style: {
|
|
417
519
|
height: t,
|
|
418
|
-
cursor:
|
|
520
|
+
cursor: k ? "auto" : "text"
|
|
419
521
|
}
|
|
420
522
|
}),
|
|
421
|
-
ErrorBoundary:
|
|
523
|
+
ErrorBoundary: te
|
|
524
|
+
}),
|
|
525
|
+
/* @__PURE__ */ m(_e, {}),
|
|
526
|
+
/* @__PURE__ */ m(Te, {}),
|
|
527
|
+
/* @__PURE__ */ m(Ee, {}),
|
|
528
|
+
f !== void 0 && /* @__PURE__ */ m(De, {
|
|
529
|
+
maxLength: f,
|
|
530
|
+
onMaxLengthExceed: o
|
|
422
531
|
}),
|
|
423
|
-
/* @__PURE__ */
|
|
424
|
-
/* @__PURE__ */
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
|
|
427
|
-
|
|
532
|
+
/* @__PURE__ */ m(E, {}),
|
|
533
|
+
/* @__PURE__ */ m(ee, { onChange: D }),
|
|
534
|
+
f !== void 0 && /* @__PURE__ */ m(Y, {
|
|
535
|
+
current: p,
|
|
536
|
+
maxLength: f
|
|
537
|
+
})
|
|
428
538
|
]
|
|
429
539
|
})
|
|
430
540
|
});
|
|
@@ -432,7 +542,7 @@ var X = (e) => {
|
|
|
432
542
|
X.displayName = "BsyLexicalEditorCore";
|
|
433
543
|
//#endregion
|
|
434
544
|
//#region src/components/Editor/nodes/ExtendedTextNode.tsx
|
|
435
|
-
var Z = class e extends
|
|
545
|
+
var Z = class e extends I {
|
|
436
546
|
constructor(e, t) {
|
|
437
547
|
super(e, t);
|
|
438
548
|
}
|
|
@@ -443,7 +553,7 @@ var Z = class e extends F {
|
|
|
443
553
|
return new e(t.__text, t.__key);
|
|
444
554
|
}
|
|
445
555
|
static importDOM() {
|
|
446
|
-
let e =
|
|
556
|
+
let e = I.importDOM();
|
|
447
557
|
return {
|
|
448
558
|
...e,
|
|
449
559
|
code: () => ({
|
|
@@ -473,14 +583,14 @@ var Z = class e extends F {
|
|
|
473
583
|
};
|
|
474
584
|
}
|
|
475
585
|
static importJSON(e) {
|
|
476
|
-
return
|
|
586
|
+
return je().updateFromJSON(e);
|
|
477
587
|
}
|
|
478
588
|
isSimpleText() {
|
|
479
589
|
return this.__type === "extended-text" && this.__mode === 0;
|
|
480
590
|
}
|
|
481
591
|
};
|
|
482
|
-
function
|
|
483
|
-
return
|
|
592
|
+
function je(e = "") {
|
|
593
|
+
return D(new Z(e));
|
|
484
594
|
}
|
|
485
595
|
function Q(e) {
|
|
486
596
|
return (t) => {
|
|
@@ -493,7 +603,7 @@ function Q(e) {
|
|
|
493
603
|
...r,
|
|
494
604
|
forChild: (e, t) => {
|
|
495
605
|
let n = (r?.forChild ?? ((e) => e))(e, t);
|
|
496
|
-
if (
|
|
606
|
+
if (se(n)) {
|
|
497
607
|
let e = [
|
|
498
608
|
i ? `background-color: ${i}` : null,
|
|
499
609
|
a ? `color: ${a}` : null,
|
|
@@ -513,8 +623,8 @@ function Q(e) {
|
|
|
513
623
|
//#region src/components/Editor/Editor.tsx
|
|
514
624
|
var $ = (e) => {
|
|
515
625
|
let { autoFocus: t = !1 } = e;
|
|
516
|
-
return /* @__PURE__ */
|
|
517
|
-
initialConfig:
|
|
626
|
+
return /* @__PURE__ */ m(C, {
|
|
627
|
+
initialConfig: y(() => ({
|
|
518
628
|
namespace: "bsyLexicalEditor",
|
|
519
629
|
onError: (e) => {
|
|
520
630
|
console.error("Lexical error", e);
|
|
@@ -529,20 +639,20 @@ var $ = (e) => {
|
|
|
529
639
|
link: "editor-link"
|
|
530
640
|
},
|
|
531
641
|
nodes: [
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
642
|
+
he,
|
|
643
|
+
me,
|
|
644
|
+
q,
|
|
535
645
|
Z,
|
|
536
646
|
{
|
|
537
|
-
replace:
|
|
647
|
+
replace: I,
|
|
538
648
|
with: (e) => new Z(e.__text),
|
|
539
649
|
withKlass: Z
|
|
540
650
|
}
|
|
541
651
|
]
|
|
542
652
|
}), [t]),
|
|
543
|
-
children: /* @__PURE__ */
|
|
653
|
+
children: /* @__PURE__ */ m(X, { ...e })
|
|
544
654
|
});
|
|
545
655
|
};
|
|
546
656
|
$.displayName = "BsyLexicalEditor";
|
|
547
657
|
//#endregion
|
|
548
|
-
export {
|
|
658
|
+
export { ie as $getRoot, n as BaseButton, $ as default, s as listRegisteredToolbarButtons, r as registerToolbarButton, t as unregisterToolbarButton, de as useLexicalComposerContext };
|