@baishuyun/ui-base 6.11.1 → 6.12.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-BAojDII3.js → Calendar-BOLbbip1.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/index.js +1 -1
- package/dist/ConfigProvider/index.js +1 -1
- package/dist/DatePicker/{DatePicker-E9HxZcGE.js → DatePicker-Vi3wfsfz.js} +1 -1
- package/dist/DatePicker/{DatePickerPanel-DM5Bje8r.js → DatePickerPanel-Cwmb-4UR.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/ToolbarPlugin/Buttons/index.js +1 -1
- package/dist/Editor/constants/index.js +1 -1
- package/dist/Editor/index.js +267 -263
- 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/Overlay/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/Editor/interface.d.ts +9 -2
- package/dist/index.js +3 -3
- package/dist/style.css +1 -1
- package/dist/vendors/{version-DU4mlk3q.js → version-CJyzNHuS.js} +1 -1
- package/package.json +1 -1
package/dist/Editor/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-CJyzNHuS.js";
|
|
2
2
|
import "../ScrollBar/style-D26azwz6.js";
|
|
3
3
|
import { t as e } from "../Icon/Icon-oQ_uBooE.js";
|
|
4
4
|
import "../vendors/LocaleContext-I4PW9j4M.js";
|
|
@@ -17,27 +17,27 @@ import "../ScrollBar/ScrollBar-N2pOLv-8.js";
|
|
|
17
17
|
import "../vendors/useFloatingPortal-CmVJbuRm.js";
|
|
18
18
|
import { t as r } from "../DropDown/DropDown-CuL1Qq25.js";
|
|
19
19
|
import "../DropDown/style-LLDVPpPa.js";
|
|
20
|
-
import { _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as
|
|
21
|
-
import { DEFAULT_BACKGROUND_COLOR as
|
|
22
|
-
import { omit as
|
|
23
|
-
import { Fragment as
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import { AnimatePresence as
|
|
27
|
-
import { LexicalComposer as
|
|
28
|
-
import { RichTextPlugin as
|
|
29
|
-
import { ContentEditable as
|
|
30
|
-
import { HistoryPlugin as
|
|
31
|
-
import { OnChangePlugin as
|
|
32
|
-
import { LexicalErrorBoundary as
|
|
33
|
-
import { $generateHtmlFromNodes as
|
|
34
|
-
import { $applyNodeReplacement as
|
|
20
|
+
import { _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as ee, s as v, u as y, v as b, y as te } from "./Buttons-CMkFTv6y.js";
|
|
21
|
+
import { DEFAULT_BACKGROUND_COLOR as x, DEFAULT_FONT_COLOR as ne, DEFAULT_FONT_SIZE as S } from "./constants/index.js";
|
|
22
|
+
import { omit as re } from "lodash-es";
|
|
23
|
+
import { Fragment as ie, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
24
|
+
import ae, { createContext as oe, useCallback as T, useContext as se, useEffect as E, useMemo as D, useRef as O, useState as k } from "react";
|
|
25
|
+
import A from "clsx";
|
|
26
|
+
import { AnimatePresence as ce, motion as le, useReducedMotion as ue } from "motion/react";
|
|
27
|
+
import { LexicalComposer as de } from "@lexical/react/LexicalComposer";
|
|
28
|
+
import { RichTextPlugin as fe } from "@lexical/react/LexicalRichTextPlugin";
|
|
29
|
+
import { ContentEditable as pe } from "@lexical/react/LexicalContentEditable";
|
|
30
|
+
import { HistoryPlugin as me } from "@lexical/react/LexicalHistoryPlugin";
|
|
31
|
+
import { OnChangePlugin as he } from "@lexical/react/LexicalOnChangePlugin";
|
|
32
|
+
import { LexicalErrorBoundary as ge } from "@lexical/react/LexicalErrorBoundary";
|
|
33
|
+
import { $generateHtmlFromNodes as _e, $generateNodesFromDOM as ve } from "@lexical/html";
|
|
34
|
+
import { $applyNodeReplacement as ye, $createLineBreakNode as be, $createParagraphNode as xe, $createTabNode as Se, $createTextNode as Ce, $getNearestNodeFromDOMNode as we, $getNodeByKey as j, $getRoot as Te, $getRoot as M, $getSelection as N, $insertNodes as P, $isElementNode as Ee, $isLineBreakNode as F, $isRangeSelection as I, $isRootOrShadowRoot as De, $isTabNode as Oe, $isTextNode as ke, $onUpdate as Ae, CLEAR_HISTORY_COMMAND as je, COMMAND_PRIORITY_CRITICAL as Me, COMMAND_PRIORITY_EDITOR as Ne, COMMAND_PRIORITY_HIGH as Pe, COMMAND_PRIORITY_LOW as Fe, DROP_COMMAND as Ie, DecoratorNode as Le, HISTORY_MERGE_TAG as Re, INDENT_CONTENT_COMMAND as ze, KEY_ENTER_COMMAND as Be, KEY_TAB_COMMAND as Ve, PASTE_COMMAND as He, PASTE_TAG as Ue, RootNode as We, TextNode as L, isHTMLElement as Ge, mergeRegister as Ke } from "lexical";
|
|
35
35
|
import { useLexicalComposerContext as qe, useLexicalComposerContext as R } from "@lexical/react/LexicalComposerContext";
|
|
36
|
-
import { $getSelectionStyleValueForProperty as
|
|
37
|
-
import { $findMatchingParent as
|
|
38
|
-
import { $isLinkNode as
|
|
39
|
-
import { $isListItemNode as
|
|
40
|
-
import { $createCodeHighlightNode as
|
|
36
|
+
import { $getSelectionStyleValueForProperty as Je, $patchStyleText as Ye, $trimTextContentFromAnchor as Xe } from "@lexical/selection";
|
|
37
|
+
import { $findMatchingParent as z, $restoreEditorState as Ze, mergeRegister as B } from "@lexical/utils";
|
|
38
|
+
import { $isLinkNode as Qe, AutoLinkNode as $e, LinkNode as et } from "@lexical/link";
|
|
39
|
+
import { $isListItemNode as V, $isListNode as tt, ListItemNode as nt, ListNode as rt } from "@lexical/list";
|
|
40
|
+
import { $createCodeHighlightNode as it, $createCodeNode as at, $isCodeHighlightNode as H, $isCodeNode as U, $plainifyCodeContent as ot, CodeHighlightNode as W, CodeNode as G, registerCodeIndentation as st } from "@lexical/code-core";
|
|
41
41
|
import { $findCellNode as ct, $isTableCellNode as K, $isTableNode as lt, $isTableRowNode as ut, $isTableSelection as dt, TableCellNode as q, TableNode as ft, TableRowNode as pt, registerTableCellUnmergeTransform as mt, registerTablePlugin as ht, registerTableSelectionObserver as gt, setScrollableTablesActive as _t } from "@lexical/table";
|
|
42
42
|
import { $isHeadingNode as vt, HeadingNode as yt } from "@lexical/rich-text";
|
|
43
43
|
import { useLexicalEditable as bt } from "@lexical/react/useLexicalEditable";
|
|
@@ -72,16 +72,16 @@ var J = (e) => {
|
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/components/Editor/hooks/useTextFormatsState.ts
|
|
74
74
|
function Dt() {
|
|
75
|
-
let [e] = R(), [t, n] =
|
|
75
|
+
let [e] = R(), [t, n] = k({
|
|
76
76
|
bold: !1,
|
|
77
77
|
italic: !1,
|
|
78
78
|
underline: !1,
|
|
79
79
|
strikethrough: !1,
|
|
80
80
|
superscript: !1,
|
|
81
81
|
subscript: !1,
|
|
82
|
-
fontSize:
|
|
82
|
+
fontSize: S,
|
|
83
83
|
fontColor: ne,
|
|
84
|
-
backgroundColor:
|
|
84
|
+
backgroundColor: x,
|
|
85
85
|
align: "left",
|
|
86
86
|
listType: !1,
|
|
87
87
|
canOutdent: !1,
|
|
@@ -91,9 +91,9 @@ function Dt() {
|
|
|
91
91
|
codeLanguage: i,
|
|
92
92
|
link: void 0
|
|
93
93
|
});
|
|
94
|
-
return
|
|
94
|
+
return E(() => e.registerUpdateListener(({ editorState: e }) => {
|
|
95
95
|
e.read(() => {
|
|
96
|
-
let e =
|
|
96
|
+
let e = N();
|
|
97
97
|
if (dt(e)) {
|
|
98
98
|
n((e) => ({
|
|
99
99
|
...e,
|
|
@@ -103,24 +103,24 @@ function Dt() {
|
|
|
103
103
|
}));
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
if (
|
|
107
|
-
let t =
|
|
106
|
+
if (I(e)) {
|
|
107
|
+
let t = Je(e, "font-size", S), r = Je(e, "color", ne), i = Je(e, "background-color", x), a = e.anchor.getNode(), o = a.getKey() === "root" ? a : z(a, (e) => {
|
|
108
108
|
let t = e.getParent();
|
|
109
|
-
return t !== null &&
|
|
109
|
+
return t !== null && De(t);
|
|
110
110
|
});
|
|
111
111
|
o === null && (o = a.getTopLevelElementOrThrow());
|
|
112
|
-
let s = {}, c =
|
|
112
|
+
let s = {}, c = z(a, Qe);
|
|
113
113
|
c ? (s.link = c.getURL(), s.linkText = c.getTextContent(), s.newBlank = c.getTarget() === "_blank") : s.linkText = e.getTextContent();
|
|
114
|
-
let l =
|
|
115
|
-
if (
|
|
114
|
+
let l = z(a, V), u = !1, d = Ee(o) ? o.getIndent() : 0;
|
|
115
|
+
if (V(l)) {
|
|
116
116
|
d = l.getIndent();
|
|
117
117
|
let e = l.getParent();
|
|
118
|
-
if (
|
|
118
|
+
if (tt(e)) {
|
|
119
119
|
let t = e.getListType();
|
|
120
120
|
u = t === "number" || t === "bullet" ? t : !1;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
let f =
|
|
123
|
+
let f = z(a, U), p = z(a, vt), m = vt(p) ? p.getTag() : void 0;
|
|
124
124
|
n({
|
|
125
125
|
bold: e.hasFormat("bold"),
|
|
126
126
|
italic: e.hasFormat("italic"),
|
|
@@ -131,13 +131,13 @@ function Dt() {
|
|
|
131
131
|
fontSize: t,
|
|
132
132
|
fontColor: r,
|
|
133
133
|
backgroundColor: i,
|
|
134
|
-
align:
|
|
134
|
+
align: Ee(o) ? o.getFormatType() : "left",
|
|
135
135
|
listType: u,
|
|
136
136
|
canOutdent: d > 0 || u !== !1,
|
|
137
137
|
isCodeBlock: !!f,
|
|
138
|
-
isInTable: !!
|
|
138
|
+
isInTable: !!z(a, K),
|
|
139
139
|
headingTag: m === "h1" || m === "h2" || m === "h3" ? m : !1,
|
|
140
|
-
codeLanguage:
|
|
140
|
+
codeLanguage: b(f?.getLanguage()),
|
|
141
141
|
link: s
|
|
142
142
|
});
|
|
143
143
|
}
|
|
@@ -148,26 +148,26 @@ function Dt() {
|
|
|
148
148
|
//#region src/components/Editor/ToolbarPlugin/context/TextFormatProvider.tsx
|
|
149
149
|
var Ot = (e) => {
|
|
150
150
|
let t = Dt();
|
|
151
|
-
return /* @__PURE__ */
|
|
151
|
+
return /* @__PURE__ */ C(te.Provider, {
|
|
152
152
|
value: t,
|
|
153
153
|
children: e.children
|
|
154
154
|
});
|
|
155
|
-
}, kt =
|
|
156
|
-
let e =
|
|
155
|
+
}, kt = oe(null), At = () => {
|
|
156
|
+
let e = se(kt);
|
|
157
157
|
if (!e) throw Error("useEditorContainer must be used within EditorContainerProvider");
|
|
158
158
|
return e;
|
|
159
159
|
}, jt = d.map((e) => ({
|
|
160
160
|
key: e.id,
|
|
161
161
|
label: e.label
|
|
162
162
|
})), Mt = () => {
|
|
163
|
-
let [n] = R(), { codeLanguage: i } = p(), { t: a } = t(), { iconSize: s } = l(), c =
|
|
163
|
+
let [n] = R(), { codeLanguage: i } = p(), { t: a } = t(), { iconSize: s } = l(), c = T((e) => {
|
|
164
164
|
let t = e.key;
|
|
165
165
|
n.update(() => {
|
|
166
|
-
let e =
|
|
167
|
-
|
|
166
|
+
let e = N();
|
|
167
|
+
I(e) && z(e.anchor.getNode(), U)?.setLanguage(t);
|
|
168
168
|
});
|
|
169
169
|
}, [n]), d = u[i].label;
|
|
170
|
-
return /* @__PURE__ */
|
|
170
|
+
return /* @__PURE__ */ C(r, {
|
|
171
171
|
menus: jt,
|
|
172
172
|
onClick: c,
|
|
173
173
|
activeKey: [i],
|
|
@@ -176,14 +176,14 @@ var Ot = (e) => {
|
|
|
176
176
|
width: 120,
|
|
177
177
|
minWidth: 120
|
|
178
178
|
},
|
|
179
|
-
children: /* @__PURE__ */
|
|
179
|
+
children: /* @__PURE__ */ C("div", {
|
|
180
180
|
className: o["bsy-lexical__toolbar-select"],
|
|
181
181
|
style: { width: 120 },
|
|
182
|
-
children: /* @__PURE__ */
|
|
183
|
-
icon: /* @__PURE__ */
|
|
182
|
+
children: /* @__PURE__ */ C(y, {
|
|
183
|
+
icon: /* @__PURE__ */ w(ie, { children: [/* @__PURE__ */ C("span", {
|
|
184
184
|
className: o["bsy-lexical__toolbar-select-label"],
|
|
185
185
|
children: d
|
|
186
|
-
}), /* @__PURE__ */
|
|
186
|
+
}), /* @__PURE__ */ C(e, {
|
|
187
187
|
name: "arrow-down",
|
|
188
188
|
size: s,
|
|
189
189
|
className: o["bsy-lexical__toolbar-select-arrow"]
|
|
@@ -265,18 +265,18 @@ var Ot = (e) => {
|
|
|
265
265
|
}), r;
|
|
266
266
|
}, It = (e, t) => {
|
|
267
267
|
let n = h(e);
|
|
268
|
-
return n ? /* @__PURE__ */
|
|
268
|
+
return n ? /* @__PURE__ */ C(n, { ...t }) : (console.warn(`[ToolbarPlugin] Button "${e}" is not registered.`), null);
|
|
269
269
|
}, Lt = ({ config: e }) => {
|
|
270
|
-
let { isCodeBlock: t } = p(), { isSourceMode: n } =
|
|
270
|
+
let { isCodeBlock: t } = p(), { isSourceMode: n } = v(), r = ue(), i = Ft(e, t, n), a = {
|
|
271
271
|
duration: r ? 0 : .16,
|
|
272
272
|
ease: "easeOut"
|
|
273
273
|
}, s = r ? {} : Nt;
|
|
274
|
-
return /* @__PURE__ */
|
|
274
|
+
return /* @__PURE__ */ C(ce, {
|
|
275
275
|
initial: !1,
|
|
276
276
|
mode: "popLayout",
|
|
277
277
|
children: i.map((e) => {
|
|
278
278
|
let t = null;
|
|
279
|
-
return t = e.kind === "divider" ? /* @__PURE__ */
|
|
279
|
+
return t = e.kind === "divider" ? /* @__PURE__ */ C("div", { className: o["bsy-lexical__toolbar-divider"] }) : e.kind === "language" ? /* @__PURE__ */ C(Mt, {}) : It(e.name, e.props), t === null ? null : /* @__PURE__ */ C(le.div, {
|
|
280
280
|
className: o["bsy-lexical__toolbar-item"],
|
|
281
281
|
layout: "position",
|
|
282
282
|
transition: a,
|
|
@@ -286,10 +286,10 @@ var Ot = (e) => {
|
|
|
286
286
|
})
|
|
287
287
|
});
|
|
288
288
|
}, Rt = (e) => {
|
|
289
|
-
let { config: t = [], style: n, theme: r, mode: i, floating: a } = e, { toolbarRef: s } = At(), l = i === "floating", u =
|
|
289
|
+
let { config: t = [], style: n, theme: r, mode: i, floating: a } = e, { toolbarRef: s } = At(), l = i === "floating", u = ue(), d = {
|
|
290
290
|
duration: u ? 0 : .16,
|
|
291
291
|
ease: "easeOut"
|
|
292
|
-
}, f =
|
|
292
|
+
}, f = D(() => wt(r), [r]), p = D(() => ({ iconSize: Tt(r?.iconSize) }), [r?.iconSize]), m = l ? Et(a) : void 0, h = l ? re(n, [
|
|
293
293
|
"position",
|
|
294
294
|
"left",
|
|
295
295
|
"top",
|
|
@@ -300,28 +300,29 @@ var Ot = (e) => {
|
|
|
300
300
|
"marginTop",
|
|
301
301
|
"marginBottom"
|
|
302
302
|
]) : n;
|
|
303
|
-
return /* @__PURE__ */
|
|
303
|
+
return /* @__PURE__ */ C(c, {
|
|
304
304
|
value: p,
|
|
305
|
-
children: /* @__PURE__ */
|
|
305
|
+
children: /* @__PURE__ */ C(_, { children: /* @__PURE__ */ C(Ot, { children: /* @__PURE__ */ C(le.div, {
|
|
306
306
|
ref: s,
|
|
307
307
|
layout: !u,
|
|
308
308
|
transition: d,
|
|
309
|
-
className:
|
|
309
|
+
className: A(o["bsy-lexical__toolbar"], l && o["bsy-lexical__toolbar--floating"]),
|
|
310
310
|
style: {
|
|
311
311
|
...f,
|
|
312
312
|
...m,
|
|
313
313
|
...h
|
|
314
314
|
},
|
|
315
|
-
children: /* @__PURE__ */
|
|
315
|
+
children: /* @__PURE__ */ C(Lt, { config: t })
|
|
316
316
|
}) }) })
|
|
317
317
|
});
|
|
318
318
|
}, Y = {
|
|
319
|
-
"bsy-lexical-editor": "_bsy-lexical-
|
|
320
|
-
"bsy-lexical-editor--floating": "_bsy-lexical-editor--
|
|
321
|
-
"bsy-lexical-
|
|
322
|
-
"bsy-lexical-
|
|
323
|
-
"bsy-lexical-
|
|
324
|
-
"bsy-lexical-editor__length-badge
|
|
319
|
+
"bsy-lexical-editor": "_bsy-lexical-editor_11st3_1",
|
|
320
|
+
"bsy-lexical-editor--floating": "_bsy-lexical-editor--floating_11st3_7",
|
|
321
|
+
"bsy-lexical-editor__body": "_bsy-lexical-editor__body_11st3_10",
|
|
322
|
+
"bsy-lexical-editor__body--fixed": "_bsy-lexical-editor__body--fixed_11st3_15",
|
|
323
|
+
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_11st3_18",
|
|
324
|
+
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_11st3_30",
|
|
325
|
+
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_11st3_42"
|
|
325
326
|
}, X = class e extends L {
|
|
326
327
|
constructor(e, t) {
|
|
327
328
|
super(e, t);
|
|
@@ -370,7 +371,7 @@ var Ot = (e) => {
|
|
|
370
371
|
}
|
|
371
372
|
};
|
|
372
373
|
function zt(e = "") {
|
|
373
|
-
return
|
|
374
|
+
return ye(new X(e));
|
|
374
375
|
}
|
|
375
376
|
function Z(e) {
|
|
376
377
|
return (t) => {
|
|
@@ -383,7 +384,7 @@ function Z(e) {
|
|
|
383
384
|
...r,
|
|
384
385
|
forChild: (e, t) => {
|
|
385
386
|
let n = (r?.forChild ?? ((e) => e))(e, t);
|
|
386
|
-
if (
|
|
387
|
+
if (ke(n)) {
|
|
387
388
|
let e = [
|
|
388
389
|
i ? `background-color: ${i}` : null,
|
|
389
390
|
a ? `color: ${a}` : null,
|
|
@@ -407,7 +408,7 @@ function Bt(e, t) {
|
|
|
407
408
|
//#endregion
|
|
408
409
|
//#region src/components/Editor/plugins/LinkColorPlugin.tsx
|
|
409
410
|
function Vt(e) {
|
|
410
|
-
if (!
|
|
411
|
+
if (!z(e, Qe)) return;
|
|
411
412
|
let t = e.getStyle();
|
|
412
413
|
if (!t) return;
|
|
413
414
|
let n = Bt(t, "color");
|
|
@@ -415,7 +416,7 @@ function Vt(e) {
|
|
|
415
416
|
}
|
|
416
417
|
function Ht() {
|
|
417
418
|
let [e] = R();
|
|
418
|
-
return
|
|
419
|
+
return E(() => e.registerNodeTransform(X, Vt), [e]), null;
|
|
419
420
|
}
|
|
420
421
|
var Q = {
|
|
421
422
|
imageWrapper: "_imageWrapper_y06h3_1",
|
|
@@ -428,15 +429,15 @@ var Q = {
|
|
|
428
429
|
bottomLeft: "_bottomLeft_y06h3_54",
|
|
429
430
|
bottomRight: "_bottomRight_y06h3_59"
|
|
430
431
|
}, Ut = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
|
|
431
|
-
let [a] = R(), [o, s] =
|
|
432
|
+
let [a] = R(), [o, s] = k(!1), [c, l] = k(null), u = O(null), [d, f] = k({
|
|
432
433
|
width: n || void 0,
|
|
433
434
|
height: r || void 0
|
|
434
|
-
}), p =
|
|
435
|
+
}), p = T(() => {
|
|
435
436
|
n && r && f({
|
|
436
437
|
width: n,
|
|
437
438
|
height: r
|
|
438
439
|
});
|
|
439
|
-
}, [n, r]), m =
|
|
440
|
+
}, [n, r]), m = T((e, t) => {
|
|
440
441
|
if (e.preventDefault(), e.stopPropagation(), !u.current) return;
|
|
441
442
|
let n = d.width || u.current.offsetWidth, r = d.height || u.current.offsetHeight, i = n / r;
|
|
442
443
|
(!d.width || !d.height) && f({
|
|
@@ -451,7 +452,7 @@ var Q = {
|
|
|
451
452
|
aspectRatio: i,
|
|
452
453
|
direction: t
|
|
453
454
|
});
|
|
454
|
-
}, [d]), h =
|
|
455
|
+
}, [d]), h = T((e) => {
|
|
455
456
|
if (!c?.isResizing) return;
|
|
456
457
|
let t = e.clientX - c.startX, n;
|
|
457
458
|
switch (c.direction) {
|
|
@@ -474,9 +475,9 @@ var Q = {
|
|
|
474
475
|
width: n,
|
|
475
476
|
height: r
|
|
476
477
|
});
|
|
477
|
-
}, [c]), g =
|
|
478
|
+
}, [c]), g = T(() => {
|
|
478
479
|
c?.isResizing && (a.update(() => {
|
|
479
|
-
let e =
|
|
480
|
+
let e = j(i);
|
|
480
481
|
Kt(e) && e.setWidthAndHeight(d.width, d.height);
|
|
481
482
|
}), l(null));
|
|
482
483
|
}, [
|
|
@@ -485,7 +486,7 @@ var Q = {
|
|
|
485
486
|
d,
|
|
486
487
|
c
|
|
487
488
|
]);
|
|
488
|
-
|
|
489
|
+
ae.useEffect(() => {
|
|
489
490
|
if (c?.isResizing) return document.addEventListener("mousemove", h), document.addEventListener("mouseup", g), () => {
|
|
490
491
|
document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", g);
|
|
491
492
|
};
|
|
@@ -494,31 +495,31 @@ var Q = {
|
|
|
494
495
|
h,
|
|
495
496
|
g
|
|
496
497
|
]);
|
|
497
|
-
let _ =
|
|
498
|
+
let _ = T(() => {
|
|
498
499
|
s(!0);
|
|
499
500
|
}, []);
|
|
500
|
-
return
|
|
501
|
+
return E(() => a.registerUpdateListener(({ editorState: e }) => {
|
|
501
502
|
e.read(() => {
|
|
502
|
-
let e =
|
|
503
|
-
|
|
503
|
+
let e = N();
|
|
504
|
+
I(e) && !e.getNodes().some((e) => e.getKey() === i || e.getParent() && e.getParent()?.getKey() === i) && o && s(!1);
|
|
504
505
|
});
|
|
505
506
|
}), [
|
|
506
507
|
a,
|
|
507
508
|
i,
|
|
508
509
|
o
|
|
509
|
-
]),
|
|
510
|
+
]), E(() => {
|
|
510
511
|
let e = (e) => {
|
|
511
512
|
o && u.current && !u.current.contains(e.target) && s(!1);
|
|
512
513
|
};
|
|
513
514
|
if (o) return document.addEventListener("mousedown", e), () => {
|
|
514
515
|
document.removeEventListener("mousedown", e);
|
|
515
516
|
};
|
|
516
|
-
}, [o]), /* @__PURE__ */
|
|
517
|
-
className:
|
|
517
|
+
}, [o]), /* @__PURE__ */ w("div", {
|
|
518
|
+
className: A(Q.imageWrapper, {
|
|
518
519
|
[Q.selected]: o,
|
|
519
520
|
[Q.resizing]: c?.isResizing
|
|
520
521
|
}),
|
|
521
|
-
children: [/* @__PURE__ */
|
|
522
|
+
children: [/* @__PURE__ */ C("img", {
|
|
522
523
|
ref: u,
|
|
523
524
|
src: e,
|
|
524
525
|
alt: t,
|
|
@@ -530,21 +531,21 @@ var Q = {
|
|
|
530
531
|
onLoad: p,
|
|
531
532
|
onClick: _,
|
|
532
533
|
draggable: !1
|
|
533
|
-
}), o && /* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
535
|
-
className:
|
|
534
|
+
}), o && /* @__PURE__ */ w(ie, { children: [
|
|
535
|
+
/* @__PURE__ */ C("div", {
|
|
536
|
+
className: A(Q.resizeHandle, Q.bottomRight),
|
|
536
537
|
onMouseDown: (e) => m(e, "bottom-right")
|
|
537
538
|
}),
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
className:
|
|
539
|
+
/* @__PURE__ */ C("div", {
|
|
540
|
+
className: A(Q.resizeHandle, Q.bottomLeft),
|
|
540
541
|
onMouseDown: (e) => m(e, "bottom-left")
|
|
541
542
|
}),
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
className:
|
|
543
|
+
/* @__PURE__ */ C("div", {
|
|
544
|
+
className: A(Q.resizeHandle, Q.topRight),
|
|
544
545
|
onMouseDown: (e) => m(e, "top-right")
|
|
545
546
|
}),
|
|
546
|
-
/* @__PURE__ */
|
|
547
|
-
className:
|
|
547
|
+
/* @__PURE__ */ C("div", {
|
|
548
|
+
className: A(Q.resizeHandle, Q.topLeft),
|
|
548
549
|
onMouseDown: (e) => m(e, "top-left")
|
|
549
550
|
})
|
|
550
551
|
] })]
|
|
@@ -595,7 +596,7 @@ var Q = {
|
|
|
595
596
|
n.__width = e, n.__height = t;
|
|
596
597
|
}
|
|
597
598
|
decorate() {
|
|
598
|
-
return /* @__PURE__ */
|
|
599
|
+
return /* @__PURE__ */ C(Ut, {
|
|
599
600
|
src: this.__src,
|
|
600
601
|
altText: this.__altText,
|
|
601
602
|
width: this.__width,
|
|
@@ -662,7 +663,7 @@ function qt(e) {
|
|
|
662
663
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
663
664
|
function Jt() {
|
|
664
665
|
let [e] = R();
|
|
665
|
-
return
|
|
666
|
+
return E(() => e.registerCommand(s, (e) => (P([Gt(e)]), !0), Ne), [e]), null;
|
|
666
667
|
}
|
|
667
668
|
//#endregion
|
|
668
669
|
//#region src/components/Editor/utils/stripImagesFromHtml.ts
|
|
@@ -674,8 +675,8 @@ function Yt(e) {
|
|
|
674
675
|
//#region src/components/Editor/plugins/PasteStripImagePlugin.tsx
|
|
675
676
|
var Xt = /<img\b|<picture\b/i;
|
|
676
677
|
function Zt() {
|
|
677
|
-
let [e] = R(), { isSourceModeRef: t } =
|
|
678
|
-
return
|
|
678
|
+
let [e] = R(), { isSourceModeRef: t } = v();
|
|
679
|
+
return E(() => {
|
|
679
680
|
let n = (n) => {
|
|
680
681
|
if (t.current) return !1;
|
|
681
682
|
let r = "clipboardData" in n ? n.clipboardData : "dataTransfer" in n ? n.dataTransfer : null;
|
|
@@ -685,38 +686,38 @@ function Zt() {
|
|
|
685
686
|
n.preventDefault();
|
|
686
687
|
let a = r.getData("text/plain");
|
|
687
688
|
return !Xt.test(i) && !a || e.update(() => {
|
|
688
|
-
let t =
|
|
689
|
+
let t = N();
|
|
689
690
|
if (t === null) return;
|
|
690
691
|
let n = i ? Yt(i) : "", r = document.createElement("div");
|
|
691
692
|
if (r.innerHTML = n, n && r.textContent?.trim()) {
|
|
692
|
-
let t =
|
|
693
|
+
let t = ve(e, new DOMParser().parseFromString(n, "text/html"));
|
|
693
694
|
if (t.length) {
|
|
694
|
-
|
|
695
|
+
P(t);
|
|
695
696
|
return;
|
|
696
697
|
}
|
|
697
698
|
}
|
|
698
699
|
a && t.insertRawText(a);
|
|
699
700
|
}, { tag: Ue }), !0;
|
|
700
701
|
};
|
|
701
|
-
return
|
|
702
|
+
return B(e.registerCommand(He, (e) => n(e), Pe), e.registerCommand(Ie, (e) => n(e), Pe));
|
|
702
703
|
}, [e, t]), null;
|
|
703
704
|
}
|
|
704
705
|
//#endregion
|
|
705
706
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
706
707
|
function Qt() {
|
|
707
|
-
let [e] = R(), t =
|
|
708
|
-
return
|
|
708
|
+
let [e] = R(), t = O(0);
|
|
709
|
+
return E(() => e.registerCommand(Be, (n) => {
|
|
709
710
|
let r = Date.now(), i = r - t.current;
|
|
710
711
|
return t.current = r, i < 250 && i > 0 ? e.getEditorState().read(() => {
|
|
711
|
-
let e =
|
|
712
|
-
return
|
|
712
|
+
let e = N();
|
|
713
|
+
return I(e) ? !!z(e.anchor.getNode(), (e) => V(e) || U(e) || K(e)) : !1;
|
|
713
714
|
}, { editor: e }) ? !1 : (e.update(() => {
|
|
714
|
-
let e =
|
|
715
|
-
if (
|
|
715
|
+
let e = N();
|
|
716
|
+
if (I(e)) {
|
|
716
717
|
let t = e.anchor.getNode().getTopLevelElement();
|
|
717
718
|
if (t && t.getTextContent().trim() === "") {
|
|
718
|
-
let n =
|
|
719
|
-
|
|
719
|
+
let n = xe();
|
|
720
|
+
Ye(e, {
|
|
720
721
|
"background-color": "",
|
|
721
722
|
color: "",
|
|
722
723
|
"font-size": "",
|
|
@@ -788,31 +789,31 @@ var $t = {
|
|
|
788
789
|
theme: m
|
|
789
790
|
}), o = [];
|
|
790
791
|
return a.tokens.forEach((e, t) => {
|
|
791
|
-
t && o.push(
|
|
792
|
+
t && o.push(be()), e.forEach((e) => {
|
|
792
793
|
e.content.split(" ").forEach((t, n) => {
|
|
793
|
-
if (n && o.push(
|
|
794
|
-
let r =
|
|
794
|
+
if (n && o.push(Se()), t === "") return;
|
|
795
|
+
let r = it(t), i = typeof e.htmlStyle == "string" ? e.htmlStyle : e.htmlStyle ? Object.entries(e.htmlStyle).map(([e, t]) => `${e}:${t}`).join(";") : e.color ? `color: ${e.color}` : "";
|
|
795
796
|
i && r.setStyle(i), o.push(r);
|
|
796
797
|
});
|
|
797
798
|
});
|
|
798
799
|
}), o;
|
|
799
800
|
}, dn = (e, t) => {
|
|
800
|
-
let n =
|
|
801
|
+
let n = j(e);
|
|
801
802
|
if (!U(n) || !n.isAttached()) return;
|
|
802
|
-
let r =
|
|
803
|
-
if (!
|
|
803
|
+
let r = N();
|
|
804
|
+
if (!I(r)) {
|
|
804
805
|
t();
|
|
805
806
|
return;
|
|
806
807
|
}
|
|
807
|
-
let { anchor: i } = r, a = i.offset, o = i.type === "element" &&
|
|
808
|
+
let { anchor: i } = r, a = i.offset, o = i.type === "element" && F(n.getChildAtIndex(i.offset - 1)), s = 0;
|
|
808
809
|
if (o || (s = a + i.getNode().getPreviousSiblings().reduce((e, t) => e + t.getTextContentSize(), 0)), t()) {
|
|
809
810
|
if (o) {
|
|
810
811
|
i.getNode().select(a, a);
|
|
811
812
|
return;
|
|
812
813
|
}
|
|
813
814
|
n.getChildren().some((e) => {
|
|
814
|
-
let t =
|
|
815
|
-
if (t ||
|
|
815
|
+
let t = ke(e);
|
|
816
|
+
if (t || F(e)) {
|
|
816
817
|
let n = e.getTextContentSize();
|
|
817
818
|
if (t && n >= s) return e.select(s, s), !0;
|
|
818
819
|
s -= n;
|
|
@@ -820,7 +821,7 @@ var $t = {
|
|
|
820
821
|
return !1;
|
|
821
822
|
});
|
|
822
823
|
}
|
|
823
|
-
}, fn = (e, t) =>
|
|
824
|
+
}, fn = (e, t) => H(e) && H(t) && e.__text === t.__text && e.__highlightType === t.__highlightType && e.__style === t.__style || Oe(e) && Oe(t) || F(e) && F(t), pn = (e, t) => {
|
|
824
825
|
let n = 0;
|
|
825
826
|
for (; n < e.length && fn(e[n], t[n]);) n++;
|
|
826
827
|
let r = e.length, i = t.length, a = Math.min(r, i) - n, o = 0;
|
|
@@ -834,7 +835,7 @@ var $t = {
|
|
|
834
835
|
nodesForReplacement: t.slice(n, i - o)
|
|
835
836
|
};
|
|
836
837
|
}, mn = (e, t, n, r, i) => {
|
|
837
|
-
let a = i.getKey(), o =
|
|
838
|
+
let a = i.getKey(), o = b(i.getLanguage());
|
|
838
839
|
if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
|
|
839
840
|
else {
|
|
840
841
|
i.getTheme() !== "github-light" && i.setTheme(m);
|
|
@@ -845,7 +846,7 @@ var $t = {
|
|
|
845
846
|
let i = [...n.pendingKeys];
|
|
846
847
|
n.pendingKeys.clear(), n.loading = null, e.update(() => {
|
|
847
848
|
i.forEach((e) => {
|
|
848
|
-
|
|
849
|
+
j(e)?.markDirty();
|
|
849
850
|
});
|
|
850
851
|
}, { tag: Re });
|
|
851
852
|
}, () => {
|
|
@@ -855,21 +856,21 @@ var $t = {
|
|
|
855
856
|
}
|
|
856
857
|
i.getIsSyntaxHighlightSupported() || i.setIsSyntaxHighlightSupported(!0);
|
|
857
858
|
}
|
|
858
|
-
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0,
|
|
859
|
+
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, Ae(() => {
|
|
859
860
|
n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
|
|
860
861
|
})), dn(a, () => {
|
|
861
|
-
let e =
|
|
862
|
+
let e = j(a);
|
|
862
863
|
if (!U(e) || !e.isAttached()) return !1;
|
|
863
|
-
let n = un(e,
|
|
864
|
+
let n = un(e, b(e.getLanguage()), t), { from: r, to: i, nodesForReplacement: o } = pn(e.getChildren(), n);
|
|
864
865
|
return r !== i || o.length ? (e.splice(r, i - r, o), !0) : !1;
|
|
865
866
|
}));
|
|
866
867
|
}, hn = (e, t, n, r, i) => {
|
|
867
868
|
let a = i.getParent();
|
|
868
|
-
U(a) ? mn(e, t, n, r, a) :
|
|
869
|
+
U(a) ? mn(e, t, n, r, a) : H(i) && i.replace(Ce(i.__text));
|
|
869
870
|
};
|
|
870
871
|
function gn() {
|
|
871
872
|
let [e] = R();
|
|
872
|
-
return
|
|
873
|
+
return E(() => {
|
|
873
874
|
if (!e.hasNodes([G, W])) throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");
|
|
874
875
|
let t = null, n = {
|
|
875
876
|
didTransform: !1,
|
|
@@ -879,7 +880,7 @@ function gn() {
|
|
|
879
880
|
}, r = (e) => {
|
|
880
881
|
t = e;
|
|
881
882
|
}, i = (e) => {
|
|
882
|
-
let t =
|
|
883
|
+
let t = j(e);
|
|
883
884
|
if (!U(t)) return;
|
|
884
885
|
let n = t.getChildrenSize();
|
|
885
886
|
n === 0 ? t.selectStart() : t.select(0, n);
|
|
@@ -887,7 +888,7 @@ function gn() {
|
|
|
887
888
|
if (!(t instanceof Node) || !e.getRootElement()?.contains(t)) return null;
|
|
888
889
|
let n = null;
|
|
889
890
|
return e.getEditorState().read(() => {
|
|
890
|
-
let e =
|
|
891
|
+
let e = we(t), r = e ? z(e, U) : null;
|
|
891
892
|
U(r) && (n = r.getKey());
|
|
892
893
|
}, { editor: e }), n;
|
|
893
894
|
}, o = null, s = (t, n, r) => {
|
|
@@ -925,17 +926,17 @@ function gn() {
|
|
|
925
926
|
//#region src/components/Editor/plugins/TablePlugin.tsx
|
|
926
927
|
function _n() {
|
|
927
928
|
let [e] = R();
|
|
928
|
-
return
|
|
929
|
+
return E(() => (_t(e, !0), B(ht(e), gt(e, !1), mt(e), e.registerNodeTransform(q, (e) => {
|
|
929
930
|
e.getBackgroundColor() !== null && e.setBackgroundColor(null);
|
|
930
931
|
}), e.registerCommand(Ve, (e) => {
|
|
931
|
-
let t =
|
|
932
|
-
if (!
|
|
932
|
+
let t = N();
|
|
933
|
+
if (!I(t) || !t.isCollapsed()) return !1;
|
|
933
934
|
let n = ct(t.anchor.getNode());
|
|
934
935
|
if (n === null) return !1;
|
|
935
936
|
let r = e.shiftKey ? "previous" : "next", i = r === "next" ? "getNextSibling" : "getPreviousSibling", a = r === "next" ? "getFirstChild" : "getLastChild", o = n[i](), s = null;
|
|
936
937
|
if (K(o)) s = o;
|
|
937
938
|
else {
|
|
938
|
-
let e =
|
|
939
|
+
let e = z(n, ut);
|
|
939
940
|
if (e !== null) for (let t = e[i](); t !== null; t = t[i]()) {
|
|
940
941
|
if (!ut(t)) continue;
|
|
941
942
|
let e = t[a]();
|
|
@@ -949,60 +950,60 @@ function _n() {
|
|
|
949
950
|
let e = s.getFirstDescendant();
|
|
950
951
|
e ? e.selectStart() : s.selectStart();
|
|
951
952
|
} else {
|
|
952
|
-
let e =
|
|
953
|
+
let e = z(n, lt);
|
|
953
954
|
e && (r === "next" ? e.selectNext() : e.selectPrevious());
|
|
954
955
|
}
|
|
955
956
|
return !0;
|
|
956
|
-
},
|
|
957
|
+
}, Pe))), [e]), null;
|
|
957
958
|
}
|
|
958
959
|
//#endregion
|
|
959
960
|
//#region src/components/Editor/plugins/TabIndentPlugin.tsx
|
|
960
961
|
var vn = "\xA0".repeat(4);
|
|
961
962
|
function yn() {
|
|
962
963
|
let [e] = R();
|
|
963
|
-
return
|
|
964
|
+
return E(() => e.registerCommand(Ve, (t) => {
|
|
964
965
|
if (t.shiftKey) return !1;
|
|
965
|
-
let n =
|
|
966
|
-
if (!
|
|
966
|
+
let n = N();
|
|
967
|
+
if (!I(n)) return !1;
|
|
967
968
|
let r = n.anchor.getNode();
|
|
968
|
-
if (ct(r) !== null ||
|
|
969
|
+
if (ct(r) !== null || z(r, U)) return !1;
|
|
969
970
|
t.preventDefault();
|
|
970
|
-
let i =
|
|
971
|
-
if (
|
|
971
|
+
let i = z(r, V);
|
|
972
|
+
if (V(i)) {
|
|
972
973
|
let e = new Set([i]);
|
|
973
974
|
for (let t of n.getNodes()) {
|
|
974
|
-
let n =
|
|
975
|
-
|
|
975
|
+
let n = z(t, V);
|
|
976
|
+
V(n) && e.add(n);
|
|
976
977
|
}
|
|
977
978
|
for (let t of e) t.setIndent(t.getIndent() + 1);
|
|
978
979
|
return !0;
|
|
979
980
|
}
|
|
980
981
|
let a = r.getTopLevelElement(), o = n.focus.getNode().getTopLevelElement();
|
|
981
982
|
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(ze, void 0) : (n.insertText(vn), !0);
|
|
982
|
-
},
|
|
983
|
+
}, Ne), [e]), null;
|
|
983
984
|
}
|
|
984
985
|
//#endregion
|
|
985
986
|
//#region src/components/Editor/plugins/MaxLengthPlugin.tsx
|
|
986
987
|
function bn({ maxLength: e, onMaxLengthExceed: t }) {
|
|
987
|
-
let [n] = R(), { isSourceModeRef: r } =
|
|
988
|
-
return i.current = t,
|
|
988
|
+
let [n] = R(), { isSourceModeRef: r } = v(), i = O(t);
|
|
989
|
+
return i.current = t, E(() => {
|
|
989
990
|
let t = null;
|
|
990
991
|
return n.registerNodeTransform(We, (a) => {
|
|
991
992
|
if (r.current) return;
|
|
992
993
|
let o = a.getTextContentSize();
|
|
993
994
|
if (o <= e) return;
|
|
994
|
-
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u =
|
|
995
|
+
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u = N();
|
|
995
996
|
if (c === e && t !== s) {
|
|
996
|
-
t = s,
|
|
997
|
+
t = s, Ze(n, s), i.current?.();
|
|
997
998
|
return;
|
|
998
999
|
}
|
|
999
|
-
if (
|
|
1000
|
-
|
|
1000
|
+
if (I(u) && u.isCollapsed()) {
|
|
1001
|
+
Xe(n, u.anchor, l), i.current?.();
|
|
1001
1002
|
return;
|
|
1002
1003
|
}
|
|
1003
1004
|
a.selectEnd();
|
|
1004
|
-
let d =
|
|
1005
|
-
|
|
1005
|
+
let d = N();
|
|
1006
|
+
I(d) && (Xe(n, d.anchor, l), i.current?.());
|
|
1006
1007
|
});
|
|
1007
1008
|
}, [
|
|
1008
1009
|
n,
|
|
@@ -1043,12 +1044,12 @@ var xn = [
|
|
|
1043
1044
|
}
|
|
1044
1045
|
};
|
|
1045
1046
|
function Cn(e, t) {
|
|
1046
|
-
let n =
|
|
1047
|
+
let n = M();
|
|
1047
1048
|
if (n.clear(), !t.trim()) return;
|
|
1048
1049
|
let r = new DOMParser().parseFromString(t, "text/html");
|
|
1049
1050
|
Sn(r);
|
|
1050
|
-
let i =
|
|
1051
|
-
i.length && (n.select(),
|
|
1051
|
+
let i = ve(e, r);
|
|
1052
|
+
i.length && (n.select(), P(i));
|
|
1052
1053
|
}
|
|
1053
1054
|
//#endregion
|
|
1054
1055
|
//#region src/components/Editor/utils/isEmptyEditorHtml.ts
|
|
@@ -1117,15 +1118,15 @@ function Mn(e) {
|
|
|
1117
1118
|
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
1118
1119
|
}
|
|
1119
1120
|
function Nn(e, t) {
|
|
1120
|
-
let n =
|
|
1121
|
+
let n = M(), r = n.getTextContentSize();
|
|
1121
1122
|
if (r <= t) return !1;
|
|
1122
1123
|
let i = r - t;
|
|
1123
1124
|
n.selectEnd();
|
|
1124
|
-
let a =
|
|
1125
|
-
return
|
|
1125
|
+
let a = N();
|
|
1126
|
+
return I(a) ? Xe(e, a.anchor, i) : Pn(i), !0;
|
|
1126
1127
|
}
|
|
1127
1128
|
function Pn(e) {
|
|
1128
|
-
let t = e, n =
|
|
1129
|
+
let t = e, n = M().getAllTextNodes();
|
|
1129
1130
|
for (let e = n.length - 1; e >= 0 && t > 0; e--) {
|
|
1130
1131
|
let r = n[e], i = r.getTextContent();
|
|
1131
1132
|
i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
|
|
@@ -1178,42 +1179,42 @@ async function Ln(e) {
|
|
|
1178
1179
|
//#endregion
|
|
1179
1180
|
//#region src/components/Editor/utils/writeHtmlSource.ts
|
|
1180
1181
|
function Rn(e) {
|
|
1181
|
-
|
|
1182
|
-
let t =
|
|
1183
|
-
if (
|
|
1182
|
+
M().clear();
|
|
1183
|
+
let t = at("html");
|
|
1184
|
+
if (M().append(t), !e) return;
|
|
1184
1185
|
t.select();
|
|
1185
|
-
let n =
|
|
1186
|
-
|
|
1186
|
+
let n = N();
|
|
1187
|
+
I(n) && n.insertRawText(e);
|
|
1187
1188
|
}
|
|
1188
1189
|
//#endregion
|
|
1189
1190
|
//#region src/components/Editor/plugins/SourceModePlugin.tsx
|
|
1190
1191
|
function zn({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
1191
|
-
let [r] = R(), [i, a] =
|
|
1192
|
+
let [r] = R(), [i, a] = k(!1), o = O(!1), s = O(n);
|
|
1192
1193
|
s.current = n;
|
|
1193
|
-
let c = Mn(t) ? t : void 0, l =
|
|
1194
|
+
let c = Mn(t) ? t : void 0, l = T(() => {
|
|
1194
1195
|
if (o.current) return;
|
|
1195
1196
|
let e = "", t = "";
|
|
1196
1197
|
r.getEditorState().read(() => {
|
|
1197
|
-
t =
|
|
1198
|
+
t = M().getTextContent(), e = _e(r, null);
|
|
1198
1199
|
}, { editor: r }), Ln(wn(e, t) ? "" : $(e)).then((e) => {
|
|
1199
1200
|
o.current || (o.current = !0, a(!0), r.update(() => {
|
|
1200
1201
|
Rn(e);
|
|
1201
|
-
}), r.dispatchCommand(
|
|
1202
|
+
}), r.dispatchCommand(je, void 0));
|
|
1202
1203
|
});
|
|
1203
|
-
}, [r]), u =
|
|
1204
|
+
}, [r]), u = T(() => {
|
|
1204
1205
|
if (!o.current) return;
|
|
1205
1206
|
let e = !1;
|
|
1206
1207
|
o.current = !1, r.update(() => {
|
|
1207
|
-
Cn(r, $(
|
|
1208
|
-
}), a(!1), r.dispatchCommand(
|
|
1209
|
-
}, [r, c]), d =
|
|
1208
|
+
Cn(r, $(M().getTextContent())), c !== void 0 && (e = Nn(r, c));
|
|
1209
|
+
}), a(!1), r.dispatchCommand(je, void 0), e && s.current?.();
|
|
1210
|
+
}, [r, c]), d = T(() => {
|
|
1210
1211
|
if (o.current) {
|
|
1211
1212
|
u();
|
|
1212
1213
|
return;
|
|
1213
1214
|
}
|
|
1214
1215
|
l();
|
|
1215
1216
|
}, [l, u]);
|
|
1216
|
-
|
|
1217
|
+
E(() => {
|
|
1217
1218
|
let e = (e) => {
|
|
1218
1219
|
if (!o.current) return !1;
|
|
1219
1220
|
let t = "clipboardData" in e ? e.clipboardData : "dataTransfer" in e ? e.dataTransfer : null;
|
|
@@ -1223,22 +1224,22 @@ function zn({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
|
1223
1224
|
if (!n) return !0;
|
|
1224
1225
|
let i = $(n);
|
|
1225
1226
|
return r.update(() => {
|
|
1226
|
-
let e =
|
|
1227
|
-
|
|
1227
|
+
let e = N();
|
|
1228
|
+
I(e) && i && e.insertRawText(i);
|
|
1228
1229
|
}, { tag: Ue }), !0;
|
|
1229
1230
|
};
|
|
1230
|
-
return
|
|
1231
|
+
return B(r.registerNodeTransform(We, () => {
|
|
1231
1232
|
if (!o.current) return;
|
|
1232
|
-
let e =
|
|
1233
|
+
let e = M(), t = e.getChildrenSize() === 1 ? e.getFirstChild() : null;
|
|
1233
1234
|
U(t) && t.getLanguage() === "html" || Rn(e.getTextContent());
|
|
1234
|
-
}), r.registerCommand(He, e,
|
|
1235
|
+
}), r.registerCommand(He, e, Me), r.registerCommand(Ie, e, Me));
|
|
1235
1236
|
}, [r]);
|
|
1236
|
-
let f =
|
|
1237
|
+
let f = D(() => ({
|
|
1237
1238
|
isSourceMode: i,
|
|
1238
1239
|
isSourceModeRef: o,
|
|
1239
1240
|
toggleSourceMode: d
|
|
1240
1241
|
}), [i, d]);
|
|
1241
|
-
return /* @__PURE__ */
|
|
1242
|
+
return /* @__PURE__ */ C(g.Provider, {
|
|
1242
1243
|
value: f,
|
|
1243
1244
|
children: e
|
|
1244
1245
|
});
|
|
@@ -1248,7 +1249,7 @@ function zn({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
|
1248
1249
|
function Bn(e) {
|
|
1249
1250
|
let t = e.getTag();
|
|
1250
1251
|
if (t === "h4" || t === "h5" || t === "h6") {
|
|
1251
|
-
e.replace(
|
|
1252
|
+
e.replace(xe(), !0);
|
|
1252
1253
|
return;
|
|
1253
1254
|
}
|
|
1254
1255
|
for (let t of e.getAllTextNodes()) {
|
|
@@ -1260,14 +1261,14 @@ function Bn(e) {
|
|
|
1260
1261
|
}
|
|
1261
1262
|
function Vn() {
|
|
1262
1263
|
let [e] = R();
|
|
1263
|
-
return
|
|
1264
|
+
return E(() => e.registerNodeTransform(yt, Bn), [e]), null;
|
|
1264
1265
|
}
|
|
1265
1266
|
//#endregion
|
|
1266
1267
|
//#region src/components/Editor/LengthBadge.tsx
|
|
1267
1268
|
var Hn = ({ current: e, maxLength: t }) => {
|
|
1268
1269
|
let n = e > t;
|
|
1269
|
-
return /* @__PURE__ */
|
|
1270
|
-
className:
|
|
1270
|
+
return /* @__PURE__ */ w("div", {
|
|
1271
|
+
className: A(Y["bsy-lexical-editor__length-badge"], n && Y["bsy-lexical-editor__length-badge--exceeded"]),
|
|
1271
1272
|
"aria-live": "polite",
|
|
1272
1273
|
children: [
|
|
1273
1274
|
e,
|
|
@@ -1280,109 +1281,112 @@ Hn.displayName = "BsyLexicalEditorLengthBadge";
|
|
|
1280
1281
|
//#endregion
|
|
1281
1282
|
//#region src/components/Editor/EditorCore.tsx
|
|
1282
1283
|
var Un = (e) => {
|
|
1283
|
-
let { height: t =
|
|
1284
|
-
|
|
1285
|
-
let
|
|
1286
|
-
containerRef:
|
|
1287
|
-
toolbarRef:
|
|
1288
|
-
}), []),
|
|
1289
|
-
|
|
1290
|
-
let t =
|
|
1291
|
-
|
|
1284
|
+
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s } = e, [c] = R(), { isSourceMode: l, isSourceModeRef: u } = v(), d = O(null), f = O(null), p = O(null), m = O(s);
|
|
1285
|
+
m.current = s;
|
|
1286
|
+
let h = Mn(o) ? o : void 0, [g, _] = k(0), ee = i?.mode === "floating", y = h !== void 0 && !l, b = D(() => ({
|
|
1287
|
+
containerRef: d,
|
|
1288
|
+
toolbarRef: f
|
|
1289
|
+
}), []), te = T((e) => {
|
|
1290
|
+
u.current || e.read(() => {
|
|
1291
|
+
let t = M().getTextContent(), n = $(_e(c, null)), i = wn(n, t) ? null : n;
|
|
1292
|
+
p.current = i, h !== void 0 && _(t.length), r({
|
|
1292
1293
|
text: t,
|
|
1293
1294
|
html: i
|
|
1294
1295
|
}, e);
|
|
1295
|
-
}, { editor:
|
|
1296
|
+
}, { editor: c });
|
|
1296
1297
|
}, [
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1298
|
+
r,
|
|
1299
|
+
c,
|
|
1300
|
+
h,
|
|
1301
|
+
u
|
|
1301
1302
|
]);
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}, { editor:
|
|
1303
|
+
E(() => {
|
|
1304
|
+
h === void 0 || l || c.getEditorState().read(() => {
|
|
1305
|
+
_(M().getTextContentSize());
|
|
1306
|
+
}, { editor: c });
|
|
1306
1307
|
}, [
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
]),
|
|
1311
|
-
if (e.value === void 0 || e.value ===
|
|
1312
|
-
if (
|
|
1308
|
+
c,
|
|
1309
|
+
h,
|
|
1310
|
+
l
|
|
1311
|
+
]), E(() => {
|
|
1312
|
+
if (e.value === void 0 || e.value === p.current) return;
|
|
1313
|
+
if (u.current) {
|
|
1313
1314
|
let t = e.value?.trim() ? $(e.value) : "", n = e.value;
|
|
1314
1315
|
Ln(t).then((e) => {
|
|
1315
|
-
!
|
|
1316
|
+
!u.current || p.current !== n || c.update(() => {
|
|
1316
1317
|
Rn(e);
|
|
1317
1318
|
});
|
|
1318
|
-
}),
|
|
1319
|
+
}), p.current = e.value;
|
|
1319
1320
|
return;
|
|
1320
1321
|
}
|
|
1321
1322
|
let t = !1;
|
|
1322
|
-
|
|
1323
|
-
Cn(
|
|
1324
|
-
}), t &&
|
|
1323
|
+
c.update(() => {
|
|
1324
|
+
Cn(c, e.value?.trim() ? $(e.value) : ""), h !== void 0 && (t = Nn(c, h));
|
|
1325
|
+
}), t && m.current?.();
|
|
1325
1326
|
}, [
|
|
1326
1327
|
e.value,
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1328
|
+
c,
|
|
1329
|
+
h,
|
|
1330
|
+
u
|
|
1330
1331
|
]);
|
|
1331
|
-
let
|
|
1332
|
-
return /* @__PURE__ */
|
|
1332
|
+
let x = i?.config?.length ? i?.config : [], ne = bt(), S = typeof t == "number" ? t : void 0;
|
|
1333
|
+
return /* @__PURE__ */ C(kt.Provider, {
|
|
1333
1334
|
value: b,
|
|
1334
|
-
children: /* @__PURE__ */
|
|
1335
|
-
ref:
|
|
1336
|
-
className:
|
|
1335
|
+
children: /* @__PURE__ */ w("div", {
|
|
1336
|
+
ref: d,
|
|
1337
|
+
className: A(Y["bsy-lexical-editor"], ee && Y["bsy-lexical-editor--floating"]),
|
|
1337
1338
|
onClick: (e) => {
|
|
1338
|
-
let t =
|
|
1339
|
-
!t || !n || !t.contains(n) ||
|
|
1339
|
+
let t = c.getRootElement(), n = e.target;
|
|
1340
|
+
!t || !n || !t.contains(n) || c.isEditable() || c.setEditable(!0);
|
|
1340
1341
|
},
|
|
1341
1342
|
children: [
|
|
1342
|
-
|
|
1343
|
-
config:
|
|
1344
|
-
theme:
|
|
1345
|
-
style:
|
|
1346
|
-
mode:
|
|
1347
|
-
floating:
|
|
1343
|
+
x.length > 0 && /* @__PURE__ */ C(Rt, {
|
|
1344
|
+
config: x,
|
|
1345
|
+
theme: a?.toolbar,
|
|
1346
|
+
style: i?.style,
|
|
1347
|
+
mode: i?.mode,
|
|
1348
|
+
floating: i?.floating
|
|
1348
1349
|
}),
|
|
1349
|
-
/* @__PURE__ */
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1350
|
+
/* @__PURE__ */ w("div", {
|
|
1351
|
+
className: A(Y["bsy-lexical-editor__body"], S !== void 0 && Y["bsy-lexical-editor__body--fixed"]),
|
|
1352
|
+
style: { height: S },
|
|
1353
|
+
children: [/* @__PURE__ */ C(fe, {
|
|
1354
|
+
contentEditable: /* @__PURE__ */ C(pe, {
|
|
1355
|
+
className: Y["bsy-lexical-editor__content-editable"],
|
|
1356
|
+
style: {
|
|
1357
|
+
minHeight: S === void 0 ? n : void 0,
|
|
1358
|
+
cursor: ne ? "auto" : "text"
|
|
1359
|
+
}
|
|
1360
|
+
}),
|
|
1361
|
+
ErrorBoundary: ge
|
|
1362
|
+
}), y ? /* @__PURE__ */ C(Hn, {
|
|
1363
|
+
current: g,
|
|
1364
|
+
maxLength: h
|
|
1365
|
+
}) : null]
|
|
1358
1366
|
}),
|
|
1359
|
-
/* @__PURE__ */
|
|
1360
|
-
/* @__PURE__ */
|
|
1361
|
-
/* @__PURE__ */
|
|
1362
|
-
/* @__PURE__ */
|
|
1363
|
-
/* @__PURE__ */
|
|
1364
|
-
/* @__PURE__ */
|
|
1365
|
-
/* @__PURE__ */
|
|
1366
|
-
/* @__PURE__ */
|
|
1367
|
-
/* @__PURE__ */
|
|
1368
|
-
/* @__PURE__ */
|
|
1369
|
-
|
|
1370
|
-
maxLength:
|
|
1371
|
-
onMaxLengthExceed:
|
|
1367
|
+
/* @__PURE__ */ C(xt, {}),
|
|
1368
|
+
/* @__PURE__ */ C(St, {}),
|
|
1369
|
+
/* @__PURE__ */ C(Ht, {}),
|
|
1370
|
+
/* @__PURE__ */ C(Vn, {}),
|
|
1371
|
+
/* @__PURE__ */ C(Jt, {}),
|
|
1372
|
+
/* @__PURE__ */ C(Zt, {}),
|
|
1373
|
+
/* @__PURE__ */ C(Qt, {}),
|
|
1374
|
+
/* @__PURE__ */ C(gn, {}),
|
|
1375
|
+
/* @__PURE__ */ C(_n, {}),
|
|
1376
|
+
/* @__PURE__ */ C(yn, {}),
|
|
1377
|
+
y ? /* @__PURE__ */ C(bn, {
|
|
1378
|
+
maxLength: h,
|
|
1379
|
+
onMaxLengthExceed: s
|
|
1372
1380
|
}) : null,
|
|
1373
|
-
/* @__PURE__ */
|
|
1374
|
-
/* @__PURE__ */
|
|
1375
|
-
v ? /* @__PURE__ */ S(Hn, {
|
|
1376
|
-
current: h,
|
|
1377
|
-
maxLength: m
|
|
1378
|
-
}) : null
|
|
1381
|
+
/* @__PURE__ */ C(me, {}),
|
|
1382
|
+
/* @__PURE__ */ C(he, { onChange: te })
|
|
1379
1383
|
]
|
|
1380
1384
|
})
|
|
1381
1385
|
});
|
|
1382
|
-
}, Wn = (e) => /* @__PURE__ */
|
|
1386
|
+
}, Wn = (e) => /* @__PURE__ */ C(zn, {
|
|
1383
1387
|
maxLength: e.maxLength,
|
|
1384
1388
|
onMaxLengthExceed: e.onMaxLengthExceed,
|
|
1385
|
-
children: /* @__PURE__ */
|
|
1389
|
+
children: /* @__PURE__ */ C(Un, { ...e })
|
|
1386
1390
|
});
|
|
1387
1391
|
Wn.displayName = "BsyLexicalEditorCore";
|
|
1388
1392
|
//#endregion
|
|
@@ -1392,8 +1396,8 @@ var Gn = "1px solid #d9d9d9", Kn = { export: new Map([[q, (e, t) => {
|
|
|
1392
1396
|
return Ge(n.element) && (n.element.style.border = Gn), n;
|
|
1393
1397
|
}]]) }, qn = (e) => {
|
|
1394
1398
|
let { autoFocus: t = !1 } = e;
|
|
1395
|
-
return /* @__PURE__ */
|
|
1396
|
-
initialConfig:
|
|
1399
|
+
return /* @__PURE__ */ C(de, {
|
|
1400
|
+
initialConfig: D(() => ({
|
|
1397
1401
|
namespace: "bsyLexicalEditor",
|
|
1398
1402
|
onError: (e) => {
|
|
1399
1403
|
console.error("Lexical error", e);
|
|
@@ -1431,10 +1435,10 @@ var Gn = "1px solid #d9d9d9", Kn = { export: new Map([[q, (e, t) => {
|
|
|
1431
1435
|
},
|
|
1432
1436
|
html: Kn,
|
|
1433
1437
|
nodes: [
|
|
1438
|
+
et,
|
|
1434
1439
|
$e,
|
|
1435
|
-
|
|
1440
|
+
rt,
|
|
1436
1441
|
nt,
|
|
1437
|
-
tt,
|
|
1438
1442
|
yt,
|
|
1439
1443
|
G,
|
|
1440
1444
|
W,
|
|
@@ -1450,9 +1454,9 @@ var Gn = "1px solid #d9d9d9", Kn = { export: new Map([[q, (e, t) => {
|
|
|
1450
1454
|
}
|
|
1451
1455
|
]
|
|
1452
1456
|
}), [t]),
|
|
1453
|
-
children: /* @__PURE__ */
|
|
1457
|
+
children: /* @__PURE__ */ C(Wn, { ...e })
|
|
1454
1458
|
});
|
|
1455
1459
|
};
|
|
1456
1460
|
qn.displayName = "BsyLexicalEditor";
|
|
1457
1461
|
//#endregion
|
|
1458
|
-
export {
|
|
1462
|
+
export { Te as $getRoot, y as BaseButton, qn as default, ee as listRegisteredToolbarButtons, f as registerToolbarButton, a as unregisterToolbarButton, qe as useLexicalComposerContext };
|