@baishuyun/ui-base 6.19.0 → 6.20.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/index.js +1 -1
- package/dist/Calendar/{Calendar-DEr4d6DN.js → Calendar-BcnZPHnb.js} +1 -1
- package/dist/Calendar/index.js +3 -3
- 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-Bzvz3bI6.js → DatePicker-CbSagdHy.js} +1 -1
- package/dist/DatePicker/{DatePickerPanel-CaAOuWM_.js → DatePickerPanel-BK9Id043.js} +1 -1
- package/dist/DatePicker/index.js +2 -2
- package/dist/DropDown/index.js +1 -1
- package/dist/Editor/index.js +1118 -893
- package/dist/Gantt/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/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/components/Editor/ToolbarPlugin/context/TextFormatsContext.d.ts +1 -0
- package/dist/components/Editor/constants/index.d.ts +2 -0
- package/dist/components/Editor/constants/portableEditorStyles.d.ts +0 -1
- package/dist/components/Editor/plugins/IndentLimitPlugin.d.ts +1 -0
- package/dist/components/Editor/utils/clampElementIndent.d.ts +3 -0
- package/dist/index.js +3 -3
- package/dist/style.css +1 -1
- package/dist/vendors/{version-Dt7Pnhic.js → version-C4BJ0f2S.js} +1 -1
- package/package.json +2 -2
package/dist/Editor/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-C4BJ0f2S.js";
|
|
2
2
|
import "../ScrollBar/style-D26azwz6.js";
|
|
3
3
|
import { t as e } from "../Icon/Icon-DrdQOEJE.js";
|
|
4
4
|
import "../vendors/LocaleContext-DXQoOKM2.js";
|
|
@@ -21,33 +21,33 @@ import { t as d } from "../vendors/useFloatingPortal-DJ1iKmW-.js";
|
|
|
21
21
|
import { t as f } from "../DropDown/DropDown-B_szM67V.js";
|
|
22
22
|
import { dropRightWhile as p, dropWhile as m, keyBy as h, omit as g, range as _ } from "lodash-es";
|
|
23
23
|
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
24
|
-
import x, { createContext as S, forwardRef as C, memo as w, useCallback as T, useContext as E, useDeferredValue as D, useEffect as O, useId as ee, useImperativeHandle as
|
|
25
|
-
import { Button as N, Form as ne, Input as re, message as
|
|
26
|
-
import
|
|
27
|
-
import { useEventListener as
|
|
28
|
-
import { AnimatePresence as
|
|
29
|
-
import { FloatingPortal as
|
|
30
|
-
import { LexicalComposer as
|
|
31
|
-
import { RichTextPlugin as
|
|
32
|
-
import { ContentEditable as
|
|
33
|
-
import { HistoryPlugin as
|
|
34
|
-
import { OnChangePlugin as
|
|
35
|
-
import { LexicalErrorBoundary as
|
|
36
|
-
import { $generateHtmlFromNodes as
|
|
37
|
-
import { $applyNodeReplacement as
|
|
38
|
-
import { useLexicalComposerContext as ct, useLexicalComposerContext as
|
|
24
|
+
import x, { createContext as S, forwardRef as C, memo as w, useCallback as T, useContext as E, useDeferredValue as D, useEffect as O, useId as ee, useImperativeHandle as te, useLayoutEffect as k, useMemo as A, useRef as j, useState as M } from "react";
|
|
25
|
+
import { Button as N, Form as ne, Input as re, message as P } from "antd";
|
|
26
|
+
import F from "clsx";
|
|
27
|
+
import { useEventListener as ie } from "ahooks";
|
|
28
|
+
import { AnimatePresence as ae, motion as oe, useReducedMotion as se } from "motion/react";
|
|
29
|
+
import { FloatingPortal as ce } from "@floating-ui/react";
|
|
30
|
+
import { LexicalComposer as le } from "@lexical/react/LexicalComposer";
|
|
31
|
+
import { RichTextPlugin as ue } from "@lexical/react/LexicalRichTextPlugin";
|
|
32
|
+
import { ContentEditable as de } from "@lexical/react/LexicalContentEditable";
|
|
33
|
+
import { HistoryPlugin as fe } from "@lexical/react/LexicalHistoryPlugin";
|
|
34
|
+
import { OnChangePlugin as pe } from "@lexical/react/LexicalOnChangePlugin";
|
|
35
|
+
import { LexicalErrorBoundary as me } from "@lexical/react/LexicalErrorBoundary";
|
|
36
|
+
import { $generateHtmlFromNodes as he, $generateNodesFromDOM as ge } from "@lexical/html";
|
|
37
|
+
import { $applyNodeReplacement as _e, $createLineBreakNode as ve, $createParagraphNode as ye, $createTabNode as be, $createTextNode as xe, $getNearestNodeFromDOMNode as Se, $getNodeByKey as Ce, $getRoot as we, $getRoot as I, $getSelection as L, $insertNodes as Te, $isElementNode as Ee, $isLineBreakNode as De, $isRangeSelection as R, $isRootOrShadowRoot as Oe, $isTabNode as ke, $isTextNode as Ae, $nodesOfType as je, $onUpdate as Me, $setSelection as Ne, BLUR_COMMAND as Pe, CAN_REDO_COMMAND as Fe, CAN_UNDO_COMMAND as Ie, CLEAR_HISTORY_COMMAND as Le, COMMAND_PRIORITY_CRITICAL as Re, COMMAND_PRIORITY_EDITOR as ze, COMMAND_PRIORITY_HIGH as Be, COMMAND_PRIORITY_LOW as Ve, DROP_COMMAND as He, DecoratorNode as Ue, FOCUS_COMMAND as We, FORMAT_ELEMENT_COMMAND as Ge, FORMAT_TEXT_COMMAND as Ke, HISTORY_MERGE_TAG as qe, INDENT_CONTENT_COMMAND as Je, KEY_ENTER_COMMAND as Ye, KEY_TAB_COMMAND as Xe, OUTDENT_CONTENT_COMMAND as Ze, PASTE_COMMAND as Qe, PASTE_TAG as $e, ParagraphNode as et, REDO_COMMAND as tt, RootNode as nt, TextNode as rt, UNDO_COMMAND as it, createCommand as at, isHTMLElement as ot, mergeRegister as st } from "lexical";
|
|
38
|
+
import { useLexicalComposerContext as ct, useLexicalComposerContext as z } from "@lexical/react/LexicalComposerContext";
|
|
39
39
|
import { $createLinkNode as lt, $isLinkNode as ut, $toggleLink as dt, AutoLinkNode as ft, LinkNode as pt, TOGGLE_LINK_COMMAND as mt } from "@lexical/link";
|
|
40
|
-
import { $isListItemNode as
|
|
41
|
-
import { $createCodeHighlightNode as
|
|
42
|
-
import { $getSelectionStyleValueForProperty as
|
|
43
|
-
import { $findCellNode as
|
|
44
|
-
import { $createHeadingNode as
|
|
45
|
-
import { $findMatchingParent as
|
|
40
|
+
import { $isListItemNode as B, $isListNode as ht, INSERT_ORDERED_LIST_COMMAND as gt, INSERT_UNORDERED_LIST_COMMAND as _t, ListItemNode as vt, ListNode as yt, REMOVE_LIST_COMMAND as bt } from "@lexical/list";
|
|
41
|
+
import { $createCodeHighlightNode as xt, $createCodeNode as St, $isCodeHighlightNode as Ct, $isCodeNode as V, $plainifyCodeContent as wt, CodeHighlightNode as Tt, CodeNode as Et, registerCodeIndentation as Dt } from "@lexical/code-core";
|
|
42
|
+
import { $getSelectionStyleValueForProperty as Ot, $patchStyleText as kt, $setBlocksType as At, $trimTextContentFromAnchor as jt } from "@lexical/selection";
|
|
43
|
+
import { $findCellNode as Mt, $isTableCellNode as Nt, $isTableNode as Pt, $isTableRowNode as Ft, $isTableSelection as It, INSERT_TABLE_COMMAND as Lt, TableCellNode as Rt, TableNode as zt, TableRowNode as Bt, registerTableCellUnmergeTransform as Vt, registerTablePlugin as Ht, registerTableSelectionObserver as Ut, setScrollableTablesActive as Wt } from "@lexical/table";
|
|
44
|
+
import { $createHeadingNode as Gt, $isHeadingNode as Kt, HeadingNode as qt } from "@lexical/rich-text";
|
|
45
|
+
import { $findMatchingParent as H, $handleIndentAndOutdent as Jt, $restoreEditorState as Yt, mergeRegister as Xt } from "@lexical/utils";
|
|
46
46
|
import Zt from "dompurify";
|
|
47
47
|
import { useLexicalEditable as Qt } from "@lexical/react/useLexicalEditable";
|
|
48
48
|
import { LinkPlugin as $t } from "@lexical/react/LexicalLinkPlugin";
|
|
49
49
|
import { ListPlugin as en } from "@lexical/react/LexicalListPlugin";
|
|
50
|
-
var
|
|
50
|
+
var U = {
|
|
51
51
|
imageWrapper: "_imageWrapper_y06h3_1",
|
|
52
52
|
selected: "_selected_y06h3_8",
|
|
53
53
|
resizing: "_resizing_y06h3_12",
|
|
@@ -58,7 +58,7 @@ var V = {
|
|
|
58
58
|
bottomLeft: "_bottomLeft_y06h3_54",
|
|
59
59
|
bottomRight: "_bottomRight_y06h3_59"
|
|
60
60
|
}, tn = ({ src: e, altText: t, width: n, height: r, dataId: i, dataSrc: a, nodeKey: o }) => {
|
|
61
|
-
let [s] =
|
|
61
|
+
let [s] = z(), [c, l] = M(!1), [u, d] = M(null), f = j(null), [p, m] = M({
|
|
62
62
|
width: n || void 0,
|
|
63
63
|
height: r || void 0
|
|
64
64
|
}), h = T(() => {
|
|
@@ -106,7 +106,7 @@ var V = {
|
|
|
106
106
|
});
|
|
107
107
|
}, [u]), S = T(() => {
|
|
108
108
|
u?.isResizing && (s.update(() => {
|
|
109
|
-
let e =
|
|
109
|
+
let e = Ce(o);
|
|
110
110
|
an(e) && e.setWidthAndHeight(p.width, p.height);
|
|
111
111
|
}), d(null));
|
|
112
112
|
}, [
|
|
@@ -129,8 +129,8 @@ var V = {
|
|
|
129
129
|
}, []);
|
|
130
130
|
return O(() => s.registerUpdateListener(({ editorState: e }) => {
|
|
131
131
|
e.read(() => {
|
|
132
|
-
let e =
|
|
133
|
-
|
|
132
|
+
let e = L();
|
|
133
|
+
R(e) && !e.getNodes().some((e) => e.getKey() === o || e.getParent() && e.getParent()?.getKey() === o) && c && l(!1);
|
|
134
134
|
});
|
|
135
135
|
}), [
|
|
136
136
|
s,
|
|
@@ -144,9 +144,9 @@ var V = {
|
|
|
144
144
|
document.removeEventListener("mousedown", e);
|
|
145
145
|
};
|
|
146
146
|
}, [c]), /* @__PURE__ */ b("div", {
|
|
147
|
-
className:
|
|
148
|
-
[
|
|
149
|
-
[
|
|
147
|
+
className: F(U.imageWrapper, {
|
|
148
|
+
[U.selected]: c,
|
|
149
|
+
[U.resizing]: u?.isResizing
|
|
150
150
|
}),
|
|
151
151
|
children: [/* @__PURE__ */ y("img", {
|
|
152
152
|
ref: f,
|
|
@@ -154,7 +154,7 @@ var V = {
|
|
|
154
154
|
alt: t,
|
|
155
155
|
"data-id": i,
|
|
156
156
|
"data-src": a,
|
|
157
|
-
className:
|
|
157
|
+
className: U.image,
|
|
158
158
|
style: {
|
|
159
159
|
width: p.width,
|
|
160
160
|
height: p.height
|
|
@@ -164,24 +164,24 @@ var V = {
|
|
|
164
164
|
draggable: !1
|
|
165
165
|
}), c && /* @__PURE__ */ b(v, { children: [
|
|
166
166
|
/* @__PURE__ */ y("div", {
|
|
167
|
-
className:
|
|
167
|
+
className: F(U.resizeHandle, U.bottomRight),
|
|
168
168
|
onMouseDown: (e) => g(e, "bottom-right")
|
|
169
169
|
}),
|
|
170
170
|
/* @__PURE__ */ y("div", {
|
|
171
|
-
className:
|
|
171
|
+
className: F(U.resizeHandle, U.bottomLeft),
|
|
172
172
|
onMouseDown: (e) => g(e, "bottom-left")
|
|
173
173
|
}),
|
|
174
174
|
/* @__PURE__ */ y("div", {
|
|
175
|
-
className:
|
|
175
|
+
className: F(U.resizeHandle, U.topRight),
|
|
176
176
|
onMouseDown: (e) => g(e, "top-right")
|
|
177
177
|
}),
|
|
178
178
|
/* @__PURE__ */ y("div", {
|
|
179
|
-
className:
|
|
179
|
+
className: F(U.resizeHandle, U.topLeft),
|
|
180
180
|
onMouseDown: (e) => g(e, "top-left")
|
|
181
181
|
})
|
|
182
182
|
] })]
|
|
183
183
|
});
|
|
184
|
-
}, nn = class e extends
|
|
184
|
+
}, nn = class e extends Ue {
|
|
185
185
|
__src;
|
|
186
186
|
__altText;
|
|
187
187
|
__width;
|
|
@@ -311,7 +311,7 @@ function on(e) {
|
|
|
311
311
|
}
|
|
312
312
|
//#endregion
|
|
313
313
|
//#region src/components/Editor/constants/toolbarSize.ts
|
|
314
|
-
var sn = "default",
|
|
314
|
+
var sn = "default", W = {
|
|
315
315
|
x: 0,
|
|
316
316
|
y: 5
|
|
317
317
|
}, cn = {
|
|
@@ -323,24 +323,24 @@ var sn = "default", H = {
|
|
|
323
323
|
itemHeight: 30,
|
|
324
324
|
iconSize: 16
|
|
325
325
|
}
|
|
326
|
-
},
|
|
326
|
+
}, ln = (e) => {
|
|
327
327
|
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
328
|
-
},
|
|
329
|
-
let n = cn[t], r =
|
|
328
|
+
}, un = (e, t = sn) => {
|
|
329
|
+
let n = cn[t], r = ln(e?.itemHeight) ?? `${n.itemHeight}px`, i = ln(e?.iconSize) ?? `${n.iconSize}px`, a = {
|
|
330
330
|
"--bsy-editor-toolbar-item-height": r,
|
|
331
331
|
"--bsy-editor-toolbar-icon-size": i,
|
|
332
332
|
"--bsy-editor-toolbar-divider-color": "#e0e0e0",
|
|
333
333
|
"--bsy-editor-toolbar-item-highlight-color": "#0265ff"
|
|
334
334
|
};
|
|
335
|
-
return e ? (s(a, "--bsy-editor-toolbar-bg", e.bg), s(a, "--bsy-editor-toolbar-border-color", e.borderColor), s(a, "--bsy-editor-toolbar-padding", e.padding), s(a, "--bsy-editor-toolbar-gap",
|
|
336
|
-
},
|
|
335
|
+
return e ? (s(a, "--bsy-editor-toolbar-bg", e.bg), s(a, "--bsy-editor-toolbar-border-color", e.borderColor), s(a, "--bsy-editor-toolbar-padding", e.padding), s(a, "--bsy-editor-toolbar-gap", ln(e.gap)), s(a, "--bsy-editor-toolbar-group-gap", ln(e.groupGap)), s(a, "--bsy-editor-toolbar-divider-color", e.dividerColor), s(a, "--bsy-editor-toolbar-divider-margin", ln(e.dividerMargin)), s(a, "--bsy-editor-toolbar-color-icon", e.colorIcon), s(a, "--bsy-editor-toolbar-item-hover-bg", e.itemHoverBg), s(a, "--bsy-editor-toolbar-item-hover-color", e.itemHoverColor), s(a, "--bsy-editor-toolbar-item-active-bg", e.itemActiveBg), s(a, "--bsy-editor-toolbar-item-active-color", e.itemActiveColor), s(a, "--bsy-editor-toolbar-item-highlight-color", e.itemHighlightColor), s(a, "--bsy-editor-toolbar-item-padding", ln(e.itemPadding)), s(a, "--bsy-editor-toolbar-item-border-radius", ln(e.itemBorderRadius)), a) : a;
|
|
336
|
+
}, dn = (e, t = sn) => {
|
|
337
337
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
338
338
|
if (typeof e == "string") {
|
|
339
339
|
let t = Number.parseFloat(e);
|
|
340
340
|
if (Number.isFinite(t)) return t;
|
|
341
341
|
}
|
|
342
342
|
return cn[t].iconSize;
|
|
343
|
-
},
|
|
343
|
+
}, fn = (e) => {
|
|
344
344
|
let t = e?.placement ?? "top", n = e?.offset, r = typeof n == "number" ? 0 : n?.x ?? 0, i = typeof n == "number" ? n : n?.y ?? 0, a = t === "top", o = {
|
|
345
345
|
position: "absolute",
|
|
346
346
|
[a ? "bottom" : "top"]: "100%",
|
|
@@ -350,7 +350,7 @@ var sn = "default", H = {
|
|
|
350
350
|
width: "100%"
|
|
351
351
|
};
|
|
352
352
|
return r && (o.transform = `translateX(${r}px)`), o;
|
|
353
|
-
},
|
|
353
|
+
}, pn = (e, t, n, r) => {
|
|
354
354
|
if (e.length === 0 || t <= 0 || e.reduce((e, t, n) => e + t.width + (n > 0 ? r : 0), 0) <= t) return e.length;
|
|
355
355
|
let i = 0, a = 0;
|
|
356
356
|
for (let o = 0; o < e.length; o++) {
|
|
@@ -360,13 +360,13 @@ var sn = "default", H = {
|
|
|
360
360
|
}
|
|
361
361
|
for (; a > 0 && e[a - 1]?.isDivider;) --a;
|
|
362
362
|
return a;
|
|
363
|
-
},
|
|
363
|
+
}, mn = (e, t) => {
|
|
364
364
|
let n = (e) => e.kind === "divider";
|
|
365
365
|
return {
|
|
366
366
|
visible: e.slice(0, t),
|
|
367
367
|
overflow: p(m(e.slice(t), n), n)
|
|
368
368
|
};
|
|
369
|
-
},
|
|
369
|
+
}, G = {
|
|
370
370
|
"bsy-lexical__toolbar": "_bsy-lexical__toolbar_1wqto_1",
|
|
371
371
|
"bsy-lexical__toolbar--floating": "_bsy-lexical__toolbar--floating_1wqto_14",
|
|
372
372
|
"bsy-lexical__toolbar--sticky": "_bsy-lexical__toolbar--sticky_1wqto_19",
|
|
@@ -387,7 +387,7 @@ var sn = "default", H = {
|
|
|
387
387
|
"bsy-lexical__toolbar-overflow-row--instant": "_bsy-lexical__toolbar-overflow-row--instant_1wqto_128",
|
|
388
388
|
"bsy-lexical__toolbar-overflow-inner": "_bsy-lexical__toolbar-overflow-inner_1wqto_132",
|
|
389
389
|
"bsy-lexical__toolbar-with-divider": "_bsy-lexical__toolbar-with-divider_1wqto_140"
|
|
390
|
-
},
|
|
390
|
+
}, hn = S(null), gn = [
|
|
391
391
|
{
|
|
392
392
|
label: "12",
|
|
393
393
|
value: "12px"
|
|
@@ -436,14 +436,14 @@ var sn = "default", H = {
|
|
|
436
436
|
label: "128",
|
|
437
437
|
value: "128px"
|
|
438
438
|
}
|
|
439
|
-
],
|
|
439
|
+
], _n = "16px", vn = "#000", yn = "transparent", bn = [
|
|
440
440
|
"jpg",
|
|
441
441
|
"jpeg",
|
|
442
442
|
"png",
|
|
443
443
|
"gif",
|
|
444
444
|
"bmp",
|
|
445
445
|
"tif"
|
|
446
|
-
],
|
|
446
|
+
], xn = bn.map((e) => `.${e}`).join(","), Sn = "plaintext", Cn = "github-light", wn = [
|
|
447
447
|
{
|
|
448
448
|
id: "plaintext",
|
|
449
449
|
label: "Plain text"
|
|
@@ -528,69 +528,70 @@ var sn = "default", H = {
|
|
|
528
528
|
id: "markdown",
|
|
529
529
|
label: "Markdown"
|
|
530
530
|
}
|
|
531
|
-
],
|
|
531
|
+
], Tn = h(wn, "id"), En = (e) => e && Tn[e] ? e : Sn, Dn = (e) => e === "center" || e === "right" || e === "left" ? e : e === "end" ? "right" : "left", On = (e) => {
|
|
532
532
|
if (e) {
|
|
533
|
-
|
|
533
|
+
I().selectStart();
|
|
534
534
|
return;
|
|
535
535
|
}
|
|
536
|
-
|
|
537
|
-
},
|
|
536
|
+
Ne(null);
|
|
537
|
+
}, kn = (e) => {
|
|
538
538
|
let t = e.getRootElement();
|
|
539
|
-
|
|
540
|
-
},
|
|
541
|
-
|
|
542
|
-
},
|
|
539
|
+
On(!!(t && document.activeElement && t.contains(document.activeElement)));
|
|
540
|
+
}, An = () => {
|
|
541
|
+
L() === null && I().selectStart();
|
|
542
|
+
}, K = (e) => {
|
|
543
543
|
e.isEditable() || e.setEditable(!0), e.update(() => {
|
|
544
|
-
|
|
544
|
+
An();
|
|
545
545
|
}), e.focus(void 0, { defaultSelection: "rootStart" });
|
|
546
|
-
},
|
|
546
|
+
}, jn = {
|
|
547
547
|
bold: !1,
|
|
548
548
|
italic: !1,
|
|
549
549
|
underline: !1,
|
|
550
550
|
strikethrough: !1,
|
|
551
551
|
superscript: !1,
|
|
552
552
|
subscript: !1,
|
|
553
|
-
fontSize:
|
|
554
|
-
fontColor:
|
|
555
|
-
backgroundColor:
|
|
553
|
+
fontSize: _n,
|
|
554
|
+
fontColor: vn,
|
|
555
|
+
backgroundColor: yn,
|
|
556
556
|
align: "left",
|
|
557
557
|
listType: !1,
|
|
558
|
+
canIndent: !0,
|
|
558
559
|
canOutdent: !1,
|
|
559
560
|
isCodeBlock: !1,
|
|
560
561
|
isInTable: !1,
|
|
561
562
|
headingTag: !1,
|
|
562
|
-
codeLanguage:
|
|
563
|
+
codeLanguage: Sn,
|
|
563
564
|
hasEditorText: !1,
|
|
564
565
|
link: void 0
|
|
565
|
-
},
|
|
566
|
-
let t = !!
|
|
567
|
-
...
|
|
566
|
+
}, Mn = (e) => {
|
|
567
|
+
let t = !!I().getTextContent().trim(), n = {
|
|
568
|
+
...jn,
|
|
568
569
|
hasEditorText: t
|
|
569
570
|
};
|
|
570
571
|
if (!e) return n;
|
|
571
|
-
let r =
|
|
572
|
-
if (
|
|
572
|
+
let r = L();
|
|
573
|
+
if (It(r)) return {
|
|
573
574
|
...n,
|
|
574
575
|
isInTable: !0
|
|
575
576
|
};
|
|
576
|
-
if (!
|
|
577
|
-
let i =
|
|
577
|
+
if (!R(r)) return n;
|
|
578
|
+
let i = Ot(r, "font-size", _n), a = Ot(r, "color", vn), o = Ot(r, "background-color", yn), s = r.anchor.getNode(), c = s.getKey() === "root" ? s : H(s, (e) => {
|
|
578
579
|
let t = e.getParent();
|
|
579
|
-
return t !== null &&
|
|
580
|
+
return t !== null && Oe(t);
|
|
580
581
|
});
|
|
581
582
|
c === null && (c = s.getTopLevelElementOrThrow());
|
|
582
|
-
let l = {}, u =
|
|
583
|
+
let l = {}, u = H(s, ut);
|
|
583
584
|
u ? (l.link = u.getURL(), l.linkText = u.getTextContent(), l.newBlank = u.getTarget() === "_blank") : l.linkText = r.getTextContent();
|
|
584
|
-
let d =
|
|
585
|
-
if (
|
|
585
|
+
let d = H(s, B), f = !1, p = Ee(c) ? c.getIndent() : 0;
|
|
586
|
+
if (B(d)) {
|
|
586
587
|
p = d.getIndent();
|
|
587
588
|
let e = d.getParent();
|
|
588
|
-
if (
|
|
589
|
+
if (ht(e)) {
|
|
589
590
|
let t = e.getListType();
|
|
590
591
|
f = t === "number" || t === "bullet" ? t : !1;
|
|
591
592
|
}
|
|
592
593
|
}
|
|
593
|
-
let m =
|
|
594
|
+
let m = H(s, V), h = H(s, Kt), g = Kt(h) ? h.getTag() : void 0;
|
|
594
595
|
return {
|
|
595
596
|
bold: r.hasFormat("bold"),
|
|
596
597
|
italic: r.hasFormat("italic"),
|
|
@@ -601,72 +602,73 @@ var sn = "default", H = {
|
|
|
601
602
|
fontSize: i,
|
|
602
603
|
fontColor: a,
|
|
603
604
|
backgroundColor: o,
|
|
604
|
-
align:
|
|
605
|
+
align: Dn(Ee(c) ? c.getFormatType() : ""),
|
|
605
606
|
listType: f,
|
|
607
|
+
canIndent: p < 8,
|
|
606
608
|
canOutdent: p > 0 || f !== !1,
|
|
607
609
|
isCodeBlock: !!m,
|
|
608
|
-
isInTable: !!
|
|
610
|
+
isInTable: !!H(s, Nt),
|
|
609
611
|
headingTag: g === "h1" || g === "h2" || g === "h3" ? g : !1,
|
|
610
|
-
codeLanguage:
|
|
612
|
+
codeLanguage: En(m?.getLanguage()),
|
|
611
613
|
hasEditorText: t,
|
|
612
614
|
link: l
|
|
613
615
|
};
|
|
614
|
-
},
|
|
616
|
+
}, Nn = (e, t) => {
|
|
615
617
|
e.isEditable() || e.setEditable(!0), e.update(() => {
|
|
616
|
-
|
|
618
|
+
An(), t(Mn(!0));
|
|
617
619
|
}), e.focus(void 0, { defaultSelection: "rootStart" });
|
|
618
|
-
},
|
|
619
|
-
let t =
|
|
620
|
-
return
|
|
620
|
+
}, Pn = (e) => {
|
|
621
|
+
let t = jn;
|
|
622
|
+
return Nn(e, (e) => {
|
|
621
623
|
t = e;
|
|
622
624
|
}), t;
|
|
623
|
-
}, Pn = () => {
|
|
624
|
-
let [e] = R(), [t, n] = M(!1);
|
|
625
|
-
return O(() => Xt(e.registerCommand(Ge, () => (n(!0), !1), He), e.registerCommand(Fe, () => (n(!1), !1), He)), [e]), t;
|
|
626
625
|
}, Fn = () => {
|
|
627
|
-
let [e] =
|
|
626
|
+
let [e] = z(), [t, n] = M(!1);
|
|
627
|
+
return O(() => Xt(e.registerCommand(We, () => (n(!0), !1), Ve), e.registerCommand(Pe, () => (n(!1), !1), Ve)), [e]), t;
|
|
628
|
+
}, In = () => {
|
|
629
|
+
let [e] = z(), t = Fn(), [n, r] = M(jn);
|
|
628
630
|
return O(() => (e.getEditorState().read(() => {
|
|
629
|
-
r(
|
|
631
|
+
r(Mn(t));
|
|
630
632
|
}, { editor: e }), e.registerUpdateListener(({ editorState: n }) => {
|
|
631
633
|
n.read(() => {
|
|
632
|
-
r(
|
|
634
|
+
r(Mn(t));
|
|
633
635
|
}, { editor: e });
|
|
634
636
|
})), [e, t]), n;
|
|
635
|
-
},
|
|
636
|
-
let t =
|
|
637
|
-
return /* @__PURE__ */ y(
|
|
637
|
+
}, Ln = (e) => {
|
|
638
|
+
let t = In();
|
|
639
|
+
return /* @__PURE__ */ y(hn.Provider, {
|
|
638
640
|
value: t,
|
|
639
641
|
children: e.children
|
|
640
642
|
});
|
|
641
|
-
},
|
|
642
|
-
let e = E(
|
|
643
|
+
}, Rn = S(null), zn = () => {
|
|
644
|
+
let e = E(Rn);
|
|
643
645
|
if (!e) throw Error("useHistoryStateContext must be used within HistoryStateProvider");
|
|
644
646
|
return e;
|
|
645
|
-
},
|
|
646
|
-
let [t] =
|
|
647
|
+
}, Bn = ({ children: e }) => {
|
|
648
|
+
let [t] = z(), [n, r] = M({
|
|
647
649
|
canUndo: !1,
|
|
648
650
|
canRedo: !1
|
|
649
651
|
});
|
|
650
|
-
return O(() => st(t.registerCommand(
|
|
652
|
+
return O(() => st(t.registerCommand(Ie, (e) => (r((t) => t.canUndo === e ? t : {
|
|
651
653
|
...t,
|
|
652
654
|
canUndo: e
|
|
653
|
-
}), !1),
|
|
655
|
+
}), !1), Re), t.registerCommand(Fe, (e) => (r((t) => t.canRedo === e ? t : {
|
|
654
656
|
...t,
|
|
655
657
|
canRedo: e
|
|
656
|
-
}), !1),
|
|
658
|
+
}), !1), Re)), [t]), /* @__PURE__ */ y(Rn.Provider, {
|
|
657
659
|
value: n,
|
|
658
660
|
children: e
|
|
659
661
|
});
|
|
660
|
-
},
|
|
662
|
+
}, Vn = S({ iconSize: cn.default.iconSize }), Hn = Vn.Provider, Un = () => E(Vn), Wn = {
|
|
661
663
|
"lexical-editor__toolbar-button": "_lexical-editor__toolbar-button_dp4a1_1",
|
|
662
664
|
"lexical-editor__toolbar-button-active": "_lexical-editor__toolbar-button-active_dp4a1_26",
|
|
663
665
|
"lexical-editor__toolbar-button-highlight": "_lexical-editor__toolbar-button-highlight_dp4a1_30",
|
|
664
666
|
"lexical-editor__toolbar-button-tooltip-trigger": "_lexical-editor__toolbar-button-tooltip-trigger_dp4a1_36"
|
|
665
667
|
}, q = ({ icon: t, tooltip: n, onClick: r, disabled: i, showDisabledTooltip: a, active: o, highlight: s, size: l }) => {
|
|
666
|
-
let { iconSize: u } =
|
|
667
|
-
className:
|
|
668
|
-
[
|
|
669
|
-
[
|
|
668
|
+
let { iconSize: u } = Un(), d = /* @__PURE__ */ y("button", {
|
|
669
|
+
className: F(Wn["lexical-editor__toolbar-button"], {
|
|
670
|
+
[Wn["lexical-editor__toolbar-button-active"]]: o,
|
|
671
|
+
[Wn["lexical-editor__toolbar-button-highlight"]]: s
|
|
670
672
|
}),
|
|
671
673
|
type: "button",
|
|
672
674
|
onClick: r,
|
|
@@ -681,16 +683,16 @@ var sn = "default", H = {
|
|
|
681
683
|
content: n,
|
|
682
684
|
minWidth: "auto",
|
|
683
685
|
children: i ? /* @__PURE__ */ y("span", {
|
|
684
|
-
className:
|
|
686
|
+
className: Wn["lexical-editor__toolbar-button-tooltip-trigger"],
|
|
685
687
|
children: d
|
|
686
688
|
}) : d
|
|
687
689
|
});
|
|
688
690
|
}, J = () => {
|
|
689
|
-
let e = E(
|
|
691
|
+
let e = E(hn);
|
|
690
692
|
if (!e) throw Error("useTextFormatsContext must be used within TextFormatsProvider");
|
|
691
693
|
return e;
|
|
692
|
-
},
|
|
693
|
-
let [r] =
|
|
694
|
+
}, Gn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
695
|
+
let [r] = z(), i = J(), { t: o } = a(), s = i.bold;
|
|
694
696
|
return /* @__PURE__ */ y(q, {
|
|
695
697
|
icon: "bold",
|
|
696
698
|
tooltip: t ?? o("editor.bold"),
|
|
@@ -698,11 +700,11 @@ var sn = "default", H = {
|
|
|
698
700
|
active: s,
|
|
699
701
|
disabled: e,
|
|
700
702
|
onClick: () => {
|
|
701
|
-
|
|
703
|
+
K(r), r.dispatchCommand(Ke, "bold");
|
|
702
704
|
}
|
|
703
705
|
});
|
|
704
|
-
},
|
|
705
|
-
let [r] =
|
|
706
|
+
}, Kn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
707
|
+
let [r] = z(), i = J(), { t: o } = a(), s = i.underline;
|
|
706
708
|
return /* @__PURE__ */ y(q, {
|
|
707
709
|
icon: "underline",
|
|
708
710
|
tooltip: t ?? o("editor.underline"),
|
|
@@ -710,11 +712,11 @@ var sn = "default", H = {
|
|
|
710
712
|
active: s,
|
|
711
713
|
disabled: e,
|
|
712
714
|
onClick: () => {
|
|
713
|
-
|
|
715
|
+
K(r), r.dispatchCommand(Ke, "underline");
|
|
714
716
|
}
|
|
715
717
|
});
|
|
716
|
-
},
|
|
717
|
-
let [r] =
|
|
718
|
+
}, qn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
719
|
+
let [r] = z(), i = J(), { t: o } = a(), s = i.italic;
|
|
718
720
|
return /* @__PURE__ */ y(q, {
|
|
719
721
|
icon: "italic",
|
|
720
722
|
tooltip: t ?? o("editor.italic"),
|
|
@@ -722,18 +724,18 @@ var sn = "default", H = {
|
|
|
722
724
|
active: s,
|
|
723
725
|
disabled: e,
|
|
724
726
|
onClick: () => {
|
|
725
|
-
|
|
727
|
+
K(r), r.dispatchCommand(Ke, "italic");
|
|
726
728
|
}
|
|
727
729
|
});
|
|
728
|
-
},
|
|
729
|
-
let [r] =
|
|
730
|
+
}, Jn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
731
|
+
let [r] = z(), { t: i } = a(), { fontSize: o, headingTag: s } = J(), c = A(() => gn.map((e) => ({
|
|
730
732
|
key: e.value,
|
|
731
733
|
label: e.label
|
|
732
734
|
})), []), l = T((e) => {
|
|
733
735
|
let t = e.key;
|
|
734
|
-
|
|
735
|
-
let e =
|
|
736
|
-
|
|
736
|
+
K(r), r.update(() => {
|
|
737
|
+
let e = L();
|
|
738
|
+
R(e) && kt(e, { "font-size": t });
|
|
737
739
|
});
|
|
738
740
|
}, [r]);
|
|
739
741
|
return s || e ? /* @__PURE__ */ y(q, {
|
|
@@ -746,7 +748,7 @@ var sn = "default", H = {
|
|
|
746
748
|
onClick: l,
|
|
747
749
|
activeKey: [o],
|
|
748
750
|
showSearch: !1,
|
|
749
|
-
offset:
|
|
751
|
+
offset: W,
|
|
750
752
|
style: {
|
|
751
753
|
width: "60px",
|
|
752
754
|
minWidth: "60px"
|
|
@@ -761,28 +763,28 @@ var sn = "default", H = {
|
|
|
761
763
|
})
|
|
762
764
|
})
|
|
763
765
|
});
|
|
764
|
-
},
|
|
766
|
+
}, Yn = "M896 860.48V960H128v-99.52h768zM578.944 128l251.648 655.936h-115.2l-59.904-164.48H379.904L320 784H204.8L456.384 128h122.56z m-58.944 115.776h-3.712L412.16 531.2h211.072L520 243.84z", Xn = "M766.4 744.32c43.712 0 79.36-36.224 79.36-80.512 0-53.504-79.36-140.8-79.36-140.8s-79.36 87.296-79.36 140.8c0 44.288 35.648 80.512 79.36 80.512z m-377.088-44.16c7.04 7.168 18.56 7.168 25.6 0l256.064-256c7.104-7.04 7.104-18.56 0-25.6l-256-256a16.32 16.32 0 0 0-1.92-1.664L334.72 82.688a9.088 9.088 0 0 0-12.8 0l-48 48a9.088 9.088 0 0 0 0 12.8l67.2 67.2-207.808 207.936c-7.04 7.04-7.04 18.56 0 25.6l255.936 256z m12.864-448.576L581.12 430.528H223.36L402.24 251.52z m501.824 564.416H120a8 8 0 0 0-8 8v80c0 4.416 3.584 8 8 8h784a8 8 0 0 0 8-8v-80a8 8 0 0 0-8-8z", Zn = 860.48, Qn = 99.52, $n = /rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0(?:\.0+)?\s*\)/, er = {
|
|
765
767
|
fontColor: {
|
|
766
|
-
path:
|
|
767
|
-
clipHeight:
|
|
768
|
+
path: Yn,
|
|
769
|
+
clipHeight: Zn,
|
|
768
770
|
x: 128,
|
|
769
771
|
width: 768,
|
|
770
772
|
rx: 0
|
|
771
773
|
},
|
|
772
774
|
fill: {
|
|
773
|
-
path:
|
|
775
|
+
path: Xn,
|
|
774
776
|
clipHeight: 816,
|
|
775
777
|
x: 112,
|
|
776
778
|
width: 800,
|
|
777
779
|
rx: 8
|
|
778
780
|
}
|
|
779
|
-
},
|
|
781
|
+
}, tr = (e, t) => {
|
|
780
782
|
let n = t.trim().toLowerCase();
|
|
781
|
-
if (e === "fill") return !n || n === "transparent" ||
|
|
783
|
+
if (e === "fill") return !n || n === "transparent" || $n.test(n);
|
|
782
784
|
let r = n.replace(/\s+/g, "");
|
|
783
785
|
return r === "#000" || r === "#000000" || r === "black" || r === "rgb(0,0,0)" || r === "rgba(0,0,0,1)" || r === "rgba(0,0,0,1.0)";
|
|
784
|
-
},
|
|
785
|
-
let r = `${ee().replace(/:/g, "")}clip`, i =
|
|
786
|
+
}, nr = ({ variant: e, barColor: t, size: n }) => {
|
|
787
|
+
let r = `${ee().replace(/:/g, "")}clip`, i = er[e];
|
|
786
788
|
return /* @__PURE__ */ b("svg", {
|
|
787
789
|
width: n,
|
|
788
790
|
height: n,
|
|
@@ -805,32 +807,32 @@ var sn = "default", H = {
|
|
|
805
807
|
}),
|
|
806
808
|
/* @__PURE__ */ y("rect", {
|
|
807
809
|
x: i.x,
|
|
808
|
-
y:
|
|
810
|
+
y: Zn,
|
|
809
811
|
width: i.width,
|
|
810
|
-
height:
|
|
812
|
+
height: Qn,
|
|
811
813
|
rx: i.rx,
|
|
812
|
-
fill:
|
|
814
|
+
fill: tr(e, t) ? "currentColor" : t
|
|
813
815
|
})
|
|
814
816
|
]
|
|
815
817
|
});
|
|
816
|
-
},
|
|
817
|
-
let [r] =
|
|
818
|
-
|
|
819
|
-
let t =
|
|
820
|
-
|
|
818
|
+
}, rr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
819
|
+
let [r] = z(), o = J(), { iconSize: s } = Un(), { t: c } = a(), l = T((e) => {
|
|
820
|
+
K(r), r.update(() => {
|
|
821
|
+
let t = L();
|
|
822
|
+
R(t) && kt(t, { color: e });
|
|
821
823
|
});
|
|
822
824
|
}, [r]);
|
|
823
825
|
return /* @__PURE__ */ y(i, {
|
|
824
826
|
value: o.fontColor,
|
|
825
827
|
onChange: l,
|
|
826
828
|
placement: "bottom-start",
|
|
827
|
-
offset:
|
|
829
|
+
offset: W.y,
|
|
828
830
|
presetColors: "basic",
|
|
829
831
|
disabled: e,
|
|
830
832
|
children: /* @__PURE__ */ y("div", {
|
|
831
833
|
className: "trigger-picker inline-flex",
|
|
832
834
|
children: /* @__PURE__ */ y(q, {
|
|
833
|
-
icon: /* @__PURE__ */ y(
|
|
835
|
+
icon: /* @__PURE__ */ y(nr, {
|
|
834
836
|
variant: "fontColor",
|
|
835
837
|
barColor: o.fontColor,
|
|
836
838
|
size: s
|
|
@@ -841,24 +843,24 @@ var sn = "default", H = {
|
|
|
841
843
|
})
|
|
842
844
|
})
|
|
843
845
|
});
|
|
844
|
-
},
|
|
845
|
-
let [r] =
|
|
846
|
-
|
|
847
|
-
let t =
|
|
848
|
-
|
|
846
|
+
}, ir = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
847
|
+
let [r] = z(), o = J(), { iconSize: s } = Un(), { t: c } = a(), l = T((e) => {
|
|
848
|
+
K(r), r.update(() => {
|
|
849
|
+
let t = L();
|
|
850
|
+
R(t) && kt(t, { "background-color": e });
|
|
849
851
|
});
|
|
850
852
|
}, [r]);
|
|
851
853
|
return /* @__PURE__ */ y(i, {
|
|
852
854
|
value: o.backgroundColor,
|
|
853
855
|
onChange: l,
|
|
854
856
|
placement: "bottom-start",
|
|
855
|
-
offset:
|
|
857
|
+
offset: W.y,
|
|
856
858
|
presetColors: "basic",
|
|
857
859
|
disabled: e,
|
|
858
860
|
children: /* @__PURE__ */ y("div", {
|
|
859
861
|
className: "trigger-picker inline-flex",
|
|
860
862
|
children: /* @__PURE__ */ y(q, {
|
|
861
|
-
icon: /* @__PURE__ */ y(
|
|
863
|
+
icon: /* @__PURE__ */ y(nr, {
|
|
862
864
|
variant: "fill",
|
|
863
865
|
barColor: o.backgroundColor,
|
|
864
866
|
size: s
|
|
@@ -869,17 +871,17 @@ var sn = "default", H = {
|
|
|
869
871
|
})
|
|
870
872
|
})
|
|
871
873
|
});
|
|
872
|
-
},
|
|
874
|
+
}, ar = {
|
|
873
875
|
left: "paragraph",
|
|
874
876
|
center: "paragraphmiddle",
|
|
875
877
|
right: "paragraphright"
|
|
876
|
-
},
|
|
877
|
-
let [i] =
|
|
878
|
+
}, or = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
879
|
+
let [i] = z(), { align: o } = J(), { iconSize: s } = Un(), { t: c } = a(), l = A(() => [
|
|
878
880
|
{
|
|
879
881
|
key: "left",
|
|
880
882
|
label: c("leftAlign"),
|
|
881
883
|
icon: /* @__PURE__ */ y(e, {
|
|
882
|
-
name:
|
|
884
|
+
name: ar.left,
|
|
883
885
|
size: s
|
|
884
886
|
})
|
|
885
887
|
},
|
|
@@ -887,7 +889,7 @@ var sn = "default", H = {
|
|
|
887
889
|
key: "center",
|
|
888
890
|
label: c("editor.centerAlign"),
|
|
889
891
|
icon: /* @__PURE__ */ y(e, {
|
|
890
|
-
name:
|
|
892
|
+
name: ar.center,
|
|
891
893
|
size: s
|
|
892
894
|
})
|
|
893
895
|
},
|
|
@@ -895,23 +897,23 @@ var sn = "default", H = {
|
|
|
895
897
|
key: "right",
|
|
896
898
|
label: c("editor.rightAlign"),
|
|
897
899
|
icon: /* @__PURE__ */ y(e, {
|
|
898
|
-
name:
|
|
900
|
+
name: ar.right,
|
|
899
901
|
size: s
|
|
900
902
|
})
|
|
901
903
|
}
|
|
902
904
|
], [s, c]), u = T((e) => {
|
|
903
|
-
|
|
905
|
+
K(i), i.dispatchCommand(Ge, e.key);
|
|
904
906
|
}, [i]), d = /* @__PURE__ */ y("div", {
|
|
905
|
-
className:
|
|
907
|
+
className: G["bsy-lexical__toolbar-select"],
|
|
906
908
|
style: { width: 50 },
|
|
907
909
|
children: /* @__PURE__ */ y(q, {
|
|
908
910
|
icon: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(e, {
|
|
909
|
-
name:
|
|
911
|
+
name: ar[Dn(o)],
|
|
910
912
|
size: s
|
|
911
913
|
}), /* @__PURE__ */ y(e, {
|
|
912
914
|
name: "arrow-down",
|
|
913
915
|
size: s,
|
|
914
|
-
className:
|
|
916
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
915
917
|
})] }),
|
|
916
918
|
tooltip: n ?? c("editor.alignment"),
|
|
917
919
|
showDisabledTooltip: r,
|
|
@@ -923,44 +925,44 @@ var sn = "default", H = {
|
|
|
923
925
|
onClick: u,
|
|
924
926
|
showSearch: !1,
|
|
925
927
|
activeKey: [o],
|
|
926
|
-
offset:
|
|
928
|
+
offset: W,
|
|
927
929
|
style: {
|
|
928
930
|
width: "110px",
|
|
929
931
|
minWidth: "110px"
|
|
930
932
|
},
|
|
931
933
|
children: d
|
|
932
934
|
});
|
|
933
|
-
},
|
|
934
|
-
let [i] =
|
|
935
|
+
}, sr = (e) => e ? e.startsWith("@") || e.match(/^https?:\/\//) ? e : `http://${e}` : "", cr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
936
|
+
let [i] = z(), { link: o } = J(), { t: s } = a(), [c, u] = M(!1), [d, f] = M(""), [p, m] = M(""), [h, g] = M(!0), [_, x] = P.useMessage(), S = j(null), C = T((e) => {
|
|
935
937
|
u(e), e || i.setEditable(!0);
|
|
936
938
|
}, [i]), w = () => {
|
|
937
939
|
if (!d) {
|
|
938
940
|
_.warning(s("editor.linkAddressEmpty"));
|
|
939
941
|
return;
|
|
940
942
|
}
|
|
941
|
-
let e =
|
|
943
|
+
let e = sr(d);
|
|
942
944
|
i.setEditable(!0), i.update(() => {
|
|
943
945
|
let t = h ? {
|
|
944
946
|
target: "_blank",
|
|
945
947
|
rel: "noopener noreferrer",
|
|
946
948
|
title: d
|
|
947
949
|
} : { title: d }, n = S.current;
|
|
948
|
-
n !== null &&
|
|
949
|
-
let r =
|
|
950
|
-
if (
|
|
950
|
+
n !== null && Ne(n);
|
|
951
|
+
let r = L();
|
|
952
|
+
if (R(r)) {
|
|
951
953
|
let n = p || d, i = r.getTextContent();
|
|
952
954
|
if (!r.isCollapsed() && n === i) dt(e, t);
|
|
953
955
|
else {
|
|
954
|
-
let i = r.anchor.getNode(), a =
|
|
956
|
+
let i = r.anchor.getNode(), a = Ae(i) ? i : null, o = r.style || r.getNodes().find(Ae)?.getStyle() || a?.getStyle() || "", s = r.format || a?.getFormat() || 0, c = lt(e, t), l = xe(n);
|
|
955
957
|
l.setFormat(s), l.setStyle(o), c.append(l), r.insertNodes([c]);
|
|
956
958
|
}
|
|
957
959
|
} else {
|
|
958
960
|
let n = lt(e, t);
|
|
959
|
-
n.append(
|
|
960
|
-
let r =
|
|
961
|
-
if (
|
|
961
|
+
n.append(xe(p || d));
|
|
962
|
+
let r = I(), i = r.getLastChild();
|
|
963
|
+
if (Ee(i) && i.isEmpty()) i.append(n);
|
|
962
964
|
else {
|
|
963
|
-
let e =
|
|
965
|
+
let e = ye();
|
|
964
966
|
e.append(n), r.append(e);
|
|
965
967
|
}
|
|
966
968
|
}
|
|
@@ -968,10 +970,10 @@ var sn = "default", H = {
|
|
|
968
970
|
}, E = T(() => {
|
|
969
971
|
let e = "";
|
|
970
972
|
i.getEditorState().read(() => {
|
|
971
|
-
let t =
|
|
972
|
-
S.current = t ? t.clone() : null,
|
|
973
|
+
let t = L();
|
|
974
|
+
S.current = t ? t.clone() : null, R(t) && !t.isCollapsed() && (e = t.getTextContent());
|
|
973
975
|
}), i.setEditable(!1), i.update(() => {
|
|
974
|
-
|
|
976
|
+
Ne(null);
|
|
975
977
|
}), window.getSelection()?.removeAllRanges(), i.getRootElement()?.blur(), o ? (f(o.link ?? ""), m(o.linkText ?? "")) : (f(""), m(e)), u(!0);
|
|
976
978
|
}, [o, i]);
|
|
977
979
|
return /* @__PURE__ */ b(v, { children: [
|
|
@@ -1040,15 +1042,15 @@ var sn = "default", H = {
|
|
|
1040
1042
|
})] })
|
|
1041
1043
|
})
|
|
1042
1044
|
] });
|
|
1043
|
-
},
|
|
1044
|
-
let [r] =
|
|
1045
|
+
}, lr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1046
|
+
let [r] = z(), { link: i } = J(), { t: o } = a();
|
|
1045
1047
|
return /* @__PURE__ */ y(q, {
|
|
1046
1048
|
icon: "cancellink",
|
|
1047
1049
|
tooltip: t ?? o("cancelLink"),
|
|
1048
1050
|
showDisabledTooltip: n,
|
|
1049
1051
|
disabled: e,
|
|
1050
1052
|
onClick: () => {
|
|
1051
|
-
i && (
|
|
1053
|
+
i && (K(r), r.dispatchCommand(mt, null));
|
|
1052
1054
|
}
|
|
1053
1055
|
});
|
|
1054
1056
|
}, Y = {
|
|
@@ -1077,9 +1079,9 @@ var sn = "default", H = {
|
|
|
1077
1079
|
"picture-modal__preview-delete": "_picture-modal__preview-delete_1067t_143",
|
|
1078
1080
|
"picture-modal__upload-text": "_picture-modal__upload-text_1067t_151",
|
|
1079
1081
|
"picture-modal__footer": "_picture-modal__footer_1067t_155"
|
|
1080
|
-
},
|
|
1082
|
+
}, ur = C((e, t) => {
|
|
1081
1083
|
let [n] = ne.useForm(), [r, i] = M(""), { t: o } = a(), s = (e) => /^https?:\/\/.+/i.test(e);
|
|
1082
|
-
return
|
|
1084
|
+
return te(t, () => ({ getValue: async () => {
|
|
1083
1085
|
try {
|
|
1084
1086
|
return await n.validateFields(), r;
|
|
1085
1087
|
} catch {
|
|
@@ -1105,17 +1107,17 @@ var sn = "default", H = {
|
|
|
1105
1107
|
})
|
|
1106
1108
|
})] });
|
|
1107
1109
|
});
|
|
1108
|
-
|
|
1110
|
+
ur.displayName = "LinkInput";
|
|
1109
1111
|
//#endregion
|
|
1110
1112
|
//#region src/components/Editor/utils/formatTruncatedFilename.ts
|
|
1111
|
-
var
|
|
1113
|
+
var dr = "......", fr = (e, t, n) => {
|
|
1112
1114
|
if (t <= 0 || n(e) <= t) return {
|
|
1113
1115
|
display: e,
|
|
1114
1116
|
truncated: !1
|
|
1115
1117
|
};
|
|
1116
|
-
let r = e.lastIndexOf("."), i = r > 0 && r < e.length - 1, a = i ? e.slice(0, r) : e, o = i ? e.slice(r) : "", s = a.slice(-2), c = a.slice(0, -2), l = (e) => `${e}${
|
|
1118
|
+
let r = e.lastIndexOf("."), i = r > 0 && r < e.length - 1, a = i ? e.slice(0, r) : e, o = i ? e.slice(r) : "", s = a.slice(-2), c = a.slice(0, -2), l = (e) => `${e}${dr}${s}${o}`, u = (e) => n(e) <= t;
|
|
1117
1119
|
if (!u(l(""))) {
|
|
1118
|
-
let t = `${
|
|
1120
|
+
let t = `${dr}${o}`;
|
|
1119
1121
|
return {
|
|
1120
1122
|
display: u(t) ? t : e,
|
|
1121
1123
|
truncated: !0
|
|
@@ -1130,28 +1132,28 @@ var lr = "......", ur = (e, t, n) => {
|
|
|
1130
1132
|
display: l(c.slice(0, p)),
|
|
1131
1133
|
truncated: !0
|
|
1132
1134
|
};
|
|
1133
|
-
},
|
|
1134
|
-
let e = E(
|
|
1135
|
+
}, pr = S(null), mr = S({ text: "" }), hr = S(void 0), gr = () => {
|
|
1136
|
+
let e = E(pr);
|
|
1135
1137
|
if (!e) throw Error("useEditorContainer must be used within EditorContainerProvider");
|
|
1136
1138
|
return e;
|
|
1137
|
-
},
|
|
1138
|
-
function
|
|
1139
|
+
}, _r = () => E(mr), vr = () => E(hr), yr = "EditorImageUploadingError";
|
|
1140
|
+
function br(e) {
|
|
1139
1141
|
if (!e || typeof e != "object" || !("name" in e)) return !1;
|
|
1140
1142
|
let t = String(e.name);
|
|
1141
1143
|
return t === "AbortError" || t === "CanceledError";
|
|
1142
1144
|
}
|
|
1143
|
-
function
|
|
1144
|
-
return
|
|
1145
|
+
function xr(e) {
|
|
1146
|
+
return bn.includes(e.name.split(".").pop()?.toLowerCase() ?? "");
|
|
1145
1147
|
}
|
|
1146
|
-
function
|
|
1148
|
+
function Sr(e) {
|
|
1147
1149
|
if (Number.isFinite(e)) return Math.min(100, Math.max(0, e));
|
|
1148
1150
|
}
|
|
1149
|
-
function
|
|
1151
|
+
function Cr(e) {
|
|
1150
1152
|
return e === void 0 ? .55 : .55 * (1 - e / 100);
|
|
1151
1153
|
}
|
|
1152
1154
|
//#endregion
|
|
1153
1155
|
//#region src/components/Editor/ToolbarPlugin/Buttons/PictureButton/UploadImage.tsx
|
|
1154
|
-
var
|
|
1156
|
+
var wr = {
|
|
1155
1157
|
duration: .2,
|
|
1156
1158
|
ease: [
|
|
1157
1159
|
.4,
|
|
@@ -1159,14 +1161,14 @@ var Sr = {
|
|
|
1159
1161
|
.2,
|
|
1160
1162
|
1
|
|
1161
1163
|
]
|
|
1162
|
-
},
|
|
1164
|
+
}, Tr = ({ name: e, error: t }) => {
|
|
1163
1165
|
let n = j(null), [r, i] = M(e), [a, o] = M(!1);
|
|
1164
|
-
return
|
|
1166
|
+
return k(() => {
|
|
1165
1167
|
let t = n.current, r = document.createElement("canvas").getContext("2d");
|
|
1166
1168
|
if (!t || !r) return;
|
|
1167
1169
|
let a = () => {
|
|
1168
1170
|
r.font = getComputedStyle(t).font;
|
|
1169
|
-
let n =
|
|
1171
|
+
let n = fr(e, t.clientWidth, (e) => r.measureText(e).width);
|
|
1170
1172
|
i(n.display), o(n.truncated);
|
|
1171
1173
|
};
|
|
1172
1174
|
a();
|
|
@@ -1174,17 +1176,17 @@ var Sr = {
|
|
|
1174
1176
|
return s.observe(t), () => s.disconnect();
|
|
1175
1177
|
}, [e]), /* @__PURE__ */ y("div", {
|
|
1176
1178
|
ref: n,
|
|
1177
|
-
className:
|
|
1179
|
+
className: F(Y["picture-modal__preview-filename"], t && Y["picture-modal__preview-filename--error"]),
|
|
1178
1180
|
title: a ? e : void 0,
|
|
1179
1181
|
children: r
|
|
1180
1182
|
});
|
|
1181
|
-
},
|
|
1183
|
+
}, Er = (e) => new Promise((t, n) => {
|
|
1182
1184
|
let r = new FileReader();
|
|
1183
1185
|
r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsDataURL(e);
|
|
1184
|
-
}),
|
|
1185
|
-
let { upload: r } =
|
|
1186
|
+
}), Dr = C((t, n) => {
|
|
1187
|
+
let { upload: r } = gr(), [i, o] = M(!1), [s, c] = M([]), l = j(s);
|
|
1186
1188
|
l.current = s;
|
|
1187
|
-
let u = j(null), d = j(/* @__PURE__ */ new Map()), f = r?.customRequest, [p, m] =
|
|
1189
|
+
let u = j(null), d = j(/* @__PURE__ */ new Map()), f = r?.customRequest, [p, m] = P.useMessage(), { t: h } = a(), g = (e) => (e / 1024).toFixed(1) + "kb", _ = (e, t) => {
|
|
1188
1190
|
c((n) => n.map((n) => n.id === e ? {
|
|
1189
1191
|
...n,
|
|
1190
1192
|
...t
|
|
@@ -1198,7 +1200,7 @@ var Sr = {
|
|
|
1198
1200
|
d.current.set(e, n), f(t, {
|
|
1199
1201
|
signal: n.signal,
|
|
1200
1202
|
onProgress: (t) => {
|
|
1201
|
-
let n =
|
|
1203
|
+
let n = Sr(t);
|
|
1202
1204
|
n !== void 0 && _(e, { percent: n });
|
|
1203
1205
|
}
|
|
1204
1206
|
}).then((t) => {
|
|
@@ -1209,11 +1211,11 @@ var Sr = {
|
|
|
1209
1211
|
attachment: typeof t == "string" ? void 0 : t.attachment
|
|
1210
1212
|
});
|
|
1211
1213
|
}).catch((t) => {
|
|
1212
|
-
n.signal.aborted ||
|
|
1214
|
+
n.signal.aborted || br(t) || _(e, { status: "error" });
|
|
1213
1215
|
}).finally(() => {
|
|
1214
1216
|
d.current.delete(e);
|
|
1215
1217
|
});
|
|
1216
|
-
}, x = (e) =>
|
|
1218
|
+
}, x = (e) => xr(e) ? e.size > 5242880 ? (p.warning(h("editor.imageSizeNote")), !1) : !0 : (p.warning(h("editor.onlyImageFormatsSupported")), !1), S = (e) => {
|
|
1217
1219
|
let t = 10 - l.current.length;
|
|
1218
1220
|
if (t <= 0) {
|
|
1219
1221
|
p.warning(h("editor.imageCountNote", { count: 10 }));
|
|
@@ -1242,16 +1244,16 @@ var Sr = {
|
|
|
1242
1244
|
};
|
|
1243
1245
|
return O(() => () => {
|
|
1244
1246
|
d.current.forEach((e) => e.abort()), d.current.clear(), l.current.forEach((e) => URL.revokeObjectURL(e.url));
|
|
1245
|
-
}, []),
|
|
1247
|
+
}, []), te(n, () => ({ getValue: async () => {
|
|
1246
1248
|
if (s.some((e) => e.status === "uploading")) {
|
|
1247
1249
|
let e = Error(h("editor.imageUploading"));
|
|
1248
|
-
throw e.name =
|
|
1250
|
+
throw e.name = yr, e;
|
|
1249
1251
|
}
|
|
1250
1252
|
let e = s.filter((e) => e.status === "success");
|
|
1251
1253
|
if (!e.length) throw p.warning(h("editor.pleaseUploadImageFirst")), Error(h("editor.pleaseUploadImageFirst"));
|
|
1252
1254
|
try {
|
|
1253
1255
|
return await Promise.all(e.map(async (e) => ({
|
|
1254
|
-
src: e.src ?? await
|
|
1256
|
+
src: e.src ?? await Er(e.file),
|
|
1255
1257
|
fileName: e.file.name,
|
|
1256
1258
|
attachment: e.attachment
|
|
1257
1259
|
})));
|
|
@@ -1290,11 +1292,11 @@ var Sr = {
|
|
|
1290
1292
|
}),
|
|
1291
1293
|
s.length > 0 ? /* @__PURE__ */ y("div", {
|
|
1292
1294
|
className: Y["picture-modal__preview-list"],
|
|
1293
|
-
children: /* @__PURE__ */ y(
|
|
1295
|
+
children: /* @__PURE__ */ y(ae, {
|
|
1294
1296
|
mode: "popLayout",
|
|
1295
|
-
children: s.map((t) => /* @__PURE__ */ b(
|
|
1297
|
+
children: s.map((t) => /* @__PURE__ */ b(oe.div, {
|
|
1296
1298
|
layout: "position",
|
|
1297
|
-
className:
|
|
1299
|
+
className: F(Y["picture-modal__preview"], t.status === "error" && Y["picture-modal__preview--error"]),
|
|
1298
1300
|
initial: {
|
|
1299
1301
|
opacity: 0,
|
|
1300
1302
|
y: 12
|
|
@@ -1307,7 +1309,7 @@ var Sr = {
|
|
|
1307
1309
|
opacity: 0,
|
|
1308
1310
|
y: -8
|
|
1309
1311
|
},
|
|
1310
|
-
transition:
|
|
1312
|
+
transition: wr,
|
|
1311
1313
|
children: [
|
|
1312
1314
|
/* @__PURE__ */ b("div", {
|
|
1313
1315
|
className: Y["picture-modal__preview-image"],
|
|
@@ -1316,13 +1318,13 @@ var Sr = {
|
|
|
1316
1318
|
alt: h("editor.previewImage")
|
|
1317
1319
|
}), t.status === "uploading" ? /* @__PURE__ */ y("div", {
|
|
1318
1320
|
className: Y["picture-modal__preview-mask"],
|
|
1319
|
-
style: { opacity:
|
|
1321
|
+
style: { opacity: Cr(t.percent) },
|
|
1320
1322
|
children: t.percent === void 0 ? /* @__PURE__ */ y("span", { className: Y["picture-modal__preview-spinner"] }) : null
|
|
1321
1323
|
}) : null]
|
|
1322
1324
|
}),
|
|
1323
1325
|
/* @__PURE__ */ b("div", {
|
|
1324
1326
|
className: Y["picture-modal__preview-info"],
|
|
1325
|
-
children: [/* @__PURE__ */ y(
|
|
1327
|
+
children: [/* @__PURE__ */ y(Tr, {
|
|
1326
1328
|
name: t.file.name,
|
|
1327
1329
|
error: t.status === "error"
|
|
1328
1330
|
}), /* @__PURE__ */ y("div", {
|
|
@@ -1343,7 +1345,7 @@ var Sr = {
|
|
|
1343
1345
|
/* @__PURE__ */ y("input", {
|
|
1344
1346
|
ref: u,
|
|
1345
1347
|
type: "file",
|
|
1346
|
-
accept:
|
|
1348
|
+
accept: xn,
|
|
1347
1349
|
multiple: !0,
|
|
1348
1350
|
style: { display: "none" },
|
|
1349
1351
|
onChange: T
|
|
@@ -1352,11 +1354,11 @@ var Sr = {
|
|
|
1352
1354
|
]
|
|
1353
1355
|
});
|
|
1354
1356
|
});
|
|
1355
|
-
|
|
1357
|
+
Dr.displayName = "UploadImage";
|
|
1356
1358
|
//#endregion
|
|
1357
1359
|
//#region src/components/Editor/commands/ImageCommands.ts
|
|
1358
|
-
var
|
|
1359
|
-
let { t: o } = a(), [s] =
|
|
1360
|
+
var Or = at("INSERT_INLINE_IMAGE_COMMAND"), kr = ({ disabled: t, tooltip: n, showDisabledTooltip: i }) => {
|
|
1361
|
+
let { t: o } = a(), [s] = z(), { attachmentsBySrcRef: c } = gr(), [l, d] = M(!1), f = j(null), p = j(null), m = [{
|
|
1360
1362
|
key: "upload",
|
|
1361
1363
|
title: o("editor.uploadImage"),
|
|
1362
1364
|
icon: /* @__PURE__ */ y(e, { name: "picture" })
|
|
@@ -1367,7 +1369,7 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1367
1369
|
}], [h, g] = M(m[0].key), _ = async () => {
|
|
1368
1370
|
try {
|
|
1369
1371
|
if (h === "upload" && p.current) (await p.current.getValue()).forEach((e) => {
|
|
1370
|
-
e.attachment !== void 0 && c.current.set(e.src, e.attachment), s.dispatchCommand(
|
|
1372
|
+
e.attachment !== void 0 && c.current.set(e.src, e.attachment), s.dispatchCommand(Or, {
|
|
1371
1373
|
src: e.src,
|
|
1372
1374
|
altText: e.fileName,
|
|
1373
1375
|
dataId: e.attachment?._id
|
|
@@ -1375,7 +1377,7 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1375
1377
|
});
|
|
1376
1378
|
else if (f.current) {
|
|
1377
1379
|
let e = await f.current.getValue();
|
|
1378
|
-
s.dispatchCommand(
|
|
1380
|
+
s.dispatchCommand(Or, {
|
|
1379
1381
|
src: e,
|
|
1380
1382
|
dataSrc: e
|
|
1381
1383
|
});
|
|
@@ -1384,14 +1386,14 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1384
1386
|
} catch (e) {
|
|
1385
1387
|
let t = e instanceof Error ? e.message : o("editor.operationFailed");
|
|
1386
1388
|
if (e instanceof Error && e.name === "EditorImageUploadingError") {
|
|
1387
|
-
|
|
1389
|
+
P.warning(t);
|
|
1388
1390
|
return;
|
|
1389
1391
|
}
|
|
1390
|
-
|
|
1392
|
+
P.error(t);
|
|
1391
1393
|
}
|
|
1392
1394
|
}, x = {
|
|
1393
|
-
upload: /* @__PURE__ */ y(
|
|
1394
|
-
url: /* @__PURE__ */ y(
|
|
1395
|
+
upload: /* @__PURE__ */ y(Dr, { ref: p }),
|
|
1396
|
+
url: /* @__PURE__ */ y(ur, { ref: f })
|
|
1395
1397
|
};
|
|
1396
1398
|
return /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(q, {
|
|
1397
1399
|
icon: "picture",
|
|
@@ -1436,8 +1438,8 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1436
1438
|
})]
|
|
1437
1439
|
})]
|
|
1438
1440
|
})] });
|
|
1439
|
-
},
|
|
1440
|
-
let [r] =
|
|
1441
|
+
}, Ar = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1442
|
+
let [r] = z(), { canUndo: i } = zn(), { t: o } = a();
|
|
1441
1443
|
return /* @__PURE__ */ y(q, {
|
|
1442
1444
|
icon: "chexiao",
|
|
1443
1445
|
tooltip: t ?? o("editor.undo"),
|
|
@@ -1447,8 +1449,8 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1447
1449
|
r.dispatchCommand(it, void 0);
|
|
1448
1450
|
}
|
|
1449
1451
|
});
|
|
1450
|
-
},
|
|
1451
|
-
let [r] =
|
|
1452
|
+
}, jr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1453
|
+
let [r] = z(), { canRedo: i } = zn(), { t: o } = a();
|
|
1452
1454
|
return /* @__PURE__ */ y(q, {
|
|
1453
1455
|
icon: "fanhui",
|
|
1454
1456
|
tooltip: t ?? o("editor.redo"),
|
|
@@ -1456,8 +1458,8 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1456
1458
|
disabled: e || !i,
|
|
1457
1459
|
onClick: () => r.dispatchCommand(tt, void 0)
|
|
1458
1460
|
});
|
|
1459
|
-
},
|
|
1460
|
-
let [r] =
|
|
1461
|
+
}, Mr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1462
|
+
let [r] = z(), { strikethrough: i } = J(), { t: o } = a();
|
|
1461
1463
|
return /* @__PURE__ */ y(q, {
|
|
1462
1464
|
icon: "shanchuxian",
|
|
1463
1465
|
tooltip: t ?? o("editor.strikethrough"),
|
|
@@ -1465,11 +1467,11 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1465
1467
|
active: i,
|
|
1466
1468
|
disabled: e,
|
|
1467
1469
|
onClick: () => {
|
|
1468
|
-
|
|
1470
|
+
K(r), r.dispatchCommand(Ke, "strikethrough");
|
|
1469
1471
|
}
|
|
1470
1472
|
});
|
|
1471
|
-
},
|
|
1472
|
-
let [r] =
|
|
1473
|
+
}, Nr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1474
|
+
let [r] = z(), { superscript: i } = J(), { t: o } = a();
|
|
1473
1475
|
return /* @__PURE__ */ y(q, {
|
|
1474
1476
|
icon: "shangbiao",
|
|
1475
1477
|
tooltip: t ?? o("editor.superscript"),
|
|
@@ -1477,11 +1479,11 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1477
1479
|
active: i,
|
|
1478
1480
|
disabled: e,
|
|
1479
1481
|
onClick: () => {
|
|
1480
|
-
|
|
1482
|
+
K(r), r.dispatchCommand(Ke, "superscript");
|
|
1481
1483
|
}
|
|
1482
1484
|
});
|
|
1483
|
-
},
|
|
1484
|
-
let [r] =
|
|
1485
|
+
}, Pr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1486
|
+
let [r] = z(), { subscript: i } = J(), { t: o } = a();
|
|
1485
1487
|
return /* @__PURE__ */ y(q, {
|
|
1486
1488
|
icon: "xiabiao",
|
|
1487
1489
|
tooltip: t ?? o("editor.subscript"),
|
|
@@ -1489,36 +1491,36 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1489
1491
|
active: i,
|
|
1490
1492
|
disabled: e,
|
|
1491
1493
|
onClick: () => {
|
|
1492
|
-
|
|
1494
|
+
K(r), r.dispatchCommand(Ke, "subscript");
|
|
1493
1495
|
}
|
|
1494
1496
|
});
|
|
1495
|
-
},
|
|
1496
|
-
let [r] =
|
|
1497
|
+
}, Fr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1498
|
+
let [r] = z(), { canIndent: i } = J(), o = Fn(), { t: s } = a();
|
|
1497
1499
|
return /* @__PURE__ */ y(q, {
|
|
1498
1500
|
icon: "zengjiasuojin",
|
|
1499
|
-
tooltip: t ??
|
|
1501
|
+
tooltip: t ?? s("editor.indent"),
|
|
1500
1502
|
showDisabledTooltip: n,
|
|
1501
|
-
disabled: e,
|
|
1503
|
+
disabled: e || o && !i,
|
|
1502
1504
|
onClick: () => {
|
|
1503
|
-
|
|
1505
|
+
K(r), r.dispatchCommand(Je, void 0);
|
|
1504
1506
|
}
|
|
1505
1507
|
});
|
|
1506
|
-
},
|
|
1507
|
-
let [r] =
|
|
1508
|
+
}, Ir = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1509
|
+
let [r] = z(), { canOutdent: i } = J(), o = Fn(), { t: s } = a();
|
|
1508
1510
|
return /* @__PURE__ */ b("div", {
|
|
1509
|
-
className:
|
|
1510
|
-
children: [/* @__PURE__ */ y("div", { className:
|
|
1511
|
+
className: G["bsy-lexical__toolbar-with-divider"],
|
|
1512
|
+
children: [/* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ y(q, {
|
|
1511
1513
|
icon: "jianshaosuojin",
|
|
1512
1514
|
tooltip: t ?? s("editor.outdent"),
|
|
1513
1515
|
showDisabledTooltip: n,
|
|
1514
1516
|
disabled: e || o && !i,
|
|
1515
1517
|
onClick: () => {
|
|
1516
|
-
|
|
1518
|
+
K(r), r.dispatchCommand(Ze, void 0);
|
|
1517
1519
|
}
|
|
1518
1520
|
})]
|
|
1519
1521
|
});
|
|
1520
|
-
},
|
|
1521
|
-
let [r] =
|
|
1522
|
+
}, Lr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1523
|
+
let [r] = z(), { listType: i } = J(), { t: o } = a(), s = i === "bullet";
|
|
1522
1524
|
return /* @__PURE__ */ y(q, {
|
|
1523
1525
|
icon: "xuhaoliebiao",
|
|
1524
1526
|
tooltip: t ?? o("editor.bulletList"),
|
|
@@ -1526,12 +1528,12 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1526
1528
|
active: s,
|
|
1527
1529
|
disabled: e,
|
|
1528
1530
|
onClick: () => {
|
|
1529
|
-
let e =
|
|
1530
|
-
r.dispatchCommand(e.listType === "bullet" ?
|
|
1531
|
+
let e = Pn(r);
|
|
1532
|
+
r.dispatchCommand(e.listType === "bullet" ? bt : _t, void 0);
|
|
1531
1533
|
}
|
|
1532
1534
|
});
|
|
1533
|
-
},
|
|
1534
|
-
let [r] =
|
|
1535
|
+
}, Rr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1536
|
+
let [r] = z(), { listType: i } = J(), { t: o } = a(), s = i === "number";
|
|
1535
1537
|
return /* @__PURE__ */ y(q, {
|
|
1536
1538
|
icon: "bianhaoliebiao",
|
|
1537
1539
|
tooltip: t ?? o("editor.numberList"),
|
|
@@ -1539,12 +1541,12 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1539
1541
|
active: s,
|
|
1540
1542
|
disabled: e,
|
|
1541
1543
|
onClick: () => {
|
|
1542
|
-
let e =
|
|
1543
|
-
r.dispatchCommand(e.listType === "number" ?
|
|
1544
|
+
let e = Pn(r);
|
|
1545
|
+
r.dispatchCommand(e.listType === "number" ? bt : gt, void 0);
|
|
1544
1546
|
}
|
|
1545
1547
|
});
|
|
1546
|
-
},
|
|
1547
|
-
let [r] =
|
|
1548
|
+
}, zr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1549
|
+
let [r] = z(), { isCodeBlock: i } = J(), { t: o } = a();
|
|
1548
1550
|
return /* @__PURE__ */ y(q, {
|
|
1549
1551
|
icon: "daima",
|
|
1550
1552
|
tooltip: t ?? o("editor.codeBlock"),
|
|
@@ -1552,19 +1554,19 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1552
1554
|
active: i,
|
|
1553
1555
|
disabled: e,
|
|
1554
1556
|
onClick: () => {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
+
Nn(r, (e) => {
|
|
1558
|
+
At(L(), () => e.isCodeBlock ? ye() : St(Sn));
|
|
1557
1559
|
});
|
|
1558
1560
|
}
|
|
1559
1561
|
});
|
|
1560
|
-
},
|
|
1562
|
+
}, Br = {
|
|
1561
1563
|
"bsy-lexical__table-picker": "_bsy-lexical__table-picker_mv0nn_1",
|
|
1562
1564
|
"bsy-lexical__table-picker-grid": "_bsy-lexical__table-picker-grid_mv0nn_9",
|
|
1563
1565
|
"bsy-lexical__table-picker-cell": "_bsy-lexical__table-picker-cell_mv0nn_15",
|
|
1564
1566
|
"bsy-lexical__table-picker-cell--active": "_bsy-lexical__table-picker-cell--active_mv0nn_24",
|
|
1565
1567
|
"bsy-lexical__table-picker-label": "_bsy-lexical__table-picker-label_mv0nn_28"
|
|
1566
|
-
},
|
|
1567
|
-
let [s] =
|
|
1568
|
+
}, Vr = _(1, 11), Hr = ({ disabled: e, tooltip: r, showDisabledTooltip: i }) => {
|
|
1569
|
+
let [s] = z(), { isInTable: c } = J(), { t: l } = a(), u = t(), [f, p] = M(!1), [m, h] = M({
|
|
1568
1570
|
rows: 0,
|
|
1569
1571
|
cols: 0
|
|
1570
1572
|
});
|
|
@@ -1582,7 +1584,7 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1582
1584
|
showMask: !1,
|
|
1583
1585
|
zIndex: u,
|
|
1584
1586
|
popupMinWidth: "220px",
|
|
1585
|
-
offset:
|
|
1587
|
+
offset: W
|
|
1586
1588
|
});
|
|
1587
1589
|
return c ? /* @__PURE__ */ y(q, {
|
|
1588
1590
|
icon: "charubiaoge",
|
|
@@ -1599,9 +1601,9 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1599
1601
|
showDisabledTooltip: i,
|
|
1600
1602
|
disabled: e
|
|
1601
1603
|
})
|
|
1602
|
-
}), /* @__PURE__ */ y(
|
|
1604
|
+
}), /* @__PURE__ */ y(ce, { children: /* @__PURE__ */ y(n, {
|
|
1603
1605
|
zIndex: u,
|
|
1604
|
-
children: /* @__PURE__ */ y(
|
|
1606
|
+
children: /* @__PURE__ */ y(ae, { children: f ? /* @__PURE__ */ y(oe.div, {
|
|
1605
1607
|
ref: _.setFloating,
|
|
1606
1608
|
...C(),
|
|
1607
1609
|
style: {
|
|
@@ -1610,23 +1612,23 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1610
1612
|
},
|
|
1611
1613
|
...o,
|
|
1612
1614
|
children: /* @__PURE__ */ b("div", {
|
|
1613
|
-
className:
|
|
1615
|
+
className: Br["bsy-lexical__table-picker"],
|
|
1614
1616
|
onMouseDown: (e) => e.preventDefault(),
|
|
1615
1617
|
onMouseLeave: () => h({
|
|
1616
1618
|
rows: 0,
|
|
1617
1619
|
cols: 0
|
|
1618
1620
|
}),
|
|
1619
1621
|
children: [/* @__PURE__ */ y("div", {
|
|
1620
|
-
className:
|
|
1621
|
-
children:
|
|
1622
|
+
className: Br["bsy-lexical__table-picker-grid"],
|
|
1623
|
+
children: Vr.map((e) => Vr.map((t) => /* @__PURE__ */ y("button", {
|
|
1622
1624
|
type: "button",
|
|
1623
|
-
className:
|
|
1625
|
+
className: F(Br["bsy-lexical__table-picker-cell"], m.rows >= e && m.cols >= t && Br["bsy-lexical__table-picker-cell--active"]),
|
|
1624
1626
|
onMouseEnter: () => h({
|
|
1625
1627
|
rows: e,
|
|
1626
1628
|
cols: t
|
|
1627
1629
|
}),
|
|
1628
1630
|
onClick: () => {
|
|
1629
|
-
s.dispatchCommand(
|
|
1631
|
+
s.dispatchCommand(Lt, {
|
|
1630
1632
|
rows: String(e),
|
|
1631
1633
|
columns: String(t),
|
|
1632
1634
|
includeHeaders: !1
|
|
@@ -1634,7 +1636,7 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1634
1636
|
}
|
|
1635
1637
|
}, `${e}-${t}`)))
|
|
1636
1638
|
}), /* @__PURE__ */ b("div", {
|
|
1637
|
-
className:
|
|
1639
|
+
className: Br["bsy-lexical__table-picker-label"],
|
|
1638
1640
|
children: [
|
|
1639
1641
|
m.rows,
|
|
1640
1642
|
" × ",
|
|
@@ -1644,12 +1646,12 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1644
1646
|
})
|
|
1645
1647
|
}, "bsy-lexical-table-picker") : null })
|
|
1646
1648
|
}) })] });
|
|
1647
|
-
},
|
|
1648
|
-
let e = E(
|
|
1649
|
+
}, Ur = S(null), Wr = () => {
|
|
1650
|
+
let e = E(Ur);
|
|
1649
1651
|
if (!e) throw Error("useSourceMode must be used within SourceModeProvider");
|
|
1650
1652
|
return e;
|
|
1651
|
-
},
|
|
1652
|
-
let { t: r } = a(), { isSourceMode: i, toggleSourceMode: o } =
|
|
1653
|
+
}, Gr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1654
|
+
let { t: r } = a(), { isSourceMode: i, toggleSourceMode: o } = Wr();
|
|
1653
1655
|
return /* @__PURE__ */ y(q, {
|
|
1654
1656
|
icon: "yuanmamoshi",
|
|
1655
1657
|
tooltip: t ?? r("editor.sourceMode"),
|
|
@@ -1658,8 +1660,8 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1658
1660
|
disabled: e,
|
|
1659
1661
|
onClick: o
|
|
1660
1662
|
});
|
|
1661
|
-
},
|
|
1662
|
-
let [i] =
|
|
1663
|
+
}, Kr = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
1664
|
+
let [i] = z(), { headingTag: o, isInTable: s } = J(), { t: c } = a(), { iconSize: l } = Un(), u = o || "paragraph", d = [
|
|
1663
1665
|
{
|
|
1664
1666
|
key: "paragraph",
|
|
1665
1667
|
label: c("editor.paragraph")
|
|
@@ -1678,20 +1680,20 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1678
1680
|
}
|
|
1679
1681
|
], p = d.find((e) => e.key === u)?.label, m = T((e) => {
|
|
1680
1682
|
let t = e.key;
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
+
K(i), i.update(() => {
|
|
1684
|
+
At(L(), () => t === "paragraph" ? ye() : Gt(t));
|
|
1683
1685
|
});
|
|
1684
1686
|
}, [i]), h = /* @__PURE__ */ y("div", {
|
|
1685
|
-
className:
|
|
1687
|
+
className: G["bsy-lexical__toolbar-select"],
|
|
1686
1688
|
style: { width: 62 },
|
|
1687
1689
|
children: /* @__PURE__ */ y(q, {
|
|
1688
1690
|
icon: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("span", {
|
|
1689
|
-
className:
|
|
1691
|
+
className: G["bsy-lexical__toolbar-select-label"],
|
|
1690
1692
|
children: p
|
|
1691
1693
|
}), /* @__PURE__ */ y(e, {
|
|
1692
1694
|
name: "arrow-down",
|
|
1693
1695
|
size: l,
|
|
1694
|
-
className:
|
|
1696
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
1695
1697
|
})] }),
|
|
1696
1698
|
tooltip: n,
|
|
1697
1699
|
showDisabledTooltip: r,
|
|
@@ -1703,7 +1705,7 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1703
1705
|
onClick: m,
|
|
1704
1706
|
showSearch: !1,
|
|
1705
1707
|
activeKey: [u],
|
|
1706
|
-
offset:
|
|
1708
|
+
offset: W,
|
|
1707
1709
|
style: {
|
|
1708
1710
|
width: "62px",
|
|
1709
1711
|
minWidth: "62px"
|
|
@@ -1713,48 +1715,48 @@ var Er = at("INSERT_INLINE_IMAGE_COMMAND"), Dr = ({ disabled: t, tooltip: n, sho
|
|
|
1713
1715
|
};
|
|
1714
1716
|
//#endregion
|
|
1715
1717
|
//#region src/components/Editor/utils/clearInlineTextFormat.ts
|
|
1716
|
-
function
|
|
1717
|
-
let e =
|
|
1718
|
-
if (
|
|
1719
|
-
|
|
1718
|
+
function qr() {
|
|
1719
|
+
let e = L();
|
|
1720
|
+
if (R(e)) {
|
|
1721
|
+
kt(e, {
|
|
1720
1722
|
"font-size": null,
|
|
1721
1723
|
color: null,
|
|
1722
1724
|
"background-color": null
|
|
1723
1725
|
});
|
|
1724
|
-
for (let t of e.getNodes())
|
|
1726
|
+
for (let t of e.getNodes()) Ae(t) && t.setFormat(0);
|
|
1725
1727
|
e.setFormat(0);
|
|
1726
1728
|
}
|
|
1727
1729
|
}
|
|
1728
1730
|
//#endregion
|
|
1729
1731
|
//#region src/components/Editor/ToolbarPlugin/Buttons/ClearFormatButton.tsx
|
|
1730
|
-
var
|
|
1731
|
-
let [r] =
|
|
1732
|
+
var Jr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1733
|
+
let [r] = z(), { t: i } = a();
|
|
1732
1734
|
return /* @__PURE__ */ y(q, {
|
|
1733
1735
|
icon: "clearTree",
|
|
1734
1736
|
tooltip: t ?? i("editor.clearFormat"),
|
|
1735
1737
|
showDisabledTooltip: n,
|
|
1736
1738
|
disabled: e,
|
|
1737
1739
|
onClick: () => {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
+
K(r), r.update(() => {
|
|
1741
|
+
qr();
|
|
1740
1742
|
});
|
|
1741
1743
|
}
|
|
1742
1744
|
});
|
|
1743
|
-
},
|
|
1745
|
+
}, Yr = [
|
|
1744
1746
|
"quick",
|
|
1745
1747
|
"formal",
|
|
1746
1748
|
"colloquial",
|
|
1747
1749
|
"lively",
|
|
1748
1750
|
"literary",
|
|
1749
1751
|
"retro"
|
|
1750
|
-
],
|
|
1752
|
+
], Xr = {
|
|
1751
1753
|
quick: "editor.aiPresetQuick",
|
|
1752
1754
|
formal: "editor.aiPresetFormal",
|
|
1753
1755
|
colloquial: "editor.aiPresetColloquial",
|
|
1754
1756
|
lively: "editor.aiPresetLively",
|
|
1755
1757
|
literary: "editor.aiPresetLiterary",
|
|
1756
1758
|
retro: "editor.aiPresetRetro"
|
|
1757
|
-
},
|
|
1759
|
+
}, Zr = {
|
|
1758
1760
|
typeset: [
|
|
1759
1761
|
"你是一名专业的 HTML 文档排版引擎。输入已是 HTML 片段。",
|
|
1760
1762
|
"任务:在不改内容层(措辞、语序、修辞、情感色彩)的前提下,做形式层 + 视觉层优化,充分利用富文本能力(标题、列表、加粗、字色、背景色、缩进、对齐)。",
|
|
@@ -1791,7 +1793,7 @@ var Kr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
|
1791
1793
|
" - 需要扫读的关键词:给 span 加 background-color 浅底。对:<span style=\"background-color:#fff4cd\">关键词</span>。错:<p style=\"background-color:#f0f6ff\">整段</p>。",
|
|
1792
1794
|
" - 背景色只能写在 span 上(短语级),禁止写在 p / h1-h3 / ul / ol / li。",
|
|
1793
1795
|
" - 段落/标题缩进只用 padding-inline-start,且必须是 40px 的倍数(与编辑器「增加缩进」一致)。",
|
|
1794
|
-
" -
|
|
1796
|
+
" - 列表不要写 ul/ol/li 的 padding;标记槽由编辑器按字号处理。",
|
|
1795
1797
|
" - 颜色用任意合法 CSS 色值即可(#RGB、#RRGGBB、rgb())。同一篇里主色不超过 2 种强调色,正文保持深色可读。",
|
|
1796
1798
|
" - span 仅可用于 color / font-size / background-color。",
|
|
1797
1799
|
" - p / h1-h3 仅可用于 text-align / padding-inline-start。",
|
|
@@ -1818,7 +1820,7 @@ var Kr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
|
1818
1820
|
literary: "语气:更书面、文学感(适配小说、散文、高级文案)。\n规则:若主语言为中文,允许四字格;若为英文,允许复杂从句和排比;不改变原风格基调。",
|
|
1819
1821
|
retro: "语气:带一点复古书面色彩,仍保持现代可读。\n规则:仅当主语言为中文时生效:仿民国白话风(之/其/乃);其他语言自动降级为 literary。"
|
|
1820
1822
|
}
|
|
1821
|
-
},
|
|
1823
|
+
}, Qr = Zr.typeset.join("\n"), $r = Zr.polishSystem.join("\n"), ei = (e) => `${$r}\n\n【本轮风格】\n${Zr.polish[e] ?? Zr.polish.quick}`, ti = (e) => {
|
|
1822
1824
|
if (!e.trim()) return {
|
|
1823
1825
|
html: e,
|
|
1824
1826
|
blocks: []
|
|
@@ -1833,16 +1835,16 @@ var Kr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
|
1833
1835
|
html: t.body.innerHTML,
|
|
1834
1836
|
blocks: n
|
|
1835
1837
|
};
|
|
1836
|
-
},
|
|
1838
|
+
}, ni = "<!--bsy-block-->", ri = /<!--bsy-code-(\d+)-->/g, ii = "bsy-html-root", ai = (e) => new DOMParser().parseFromString(`<${ii}>${e}</${ii}>`, "text/html").body.querySelector(ii), oi = (e, t) => {
|
|
1837
1839
|
if (!t.length) return e;
|
|
1838
|
-
let n = /* @__PURE__ */ new Set(), r = e.replace(
|
|
1840
|
+
let n = /* @__PURE__ */ new Set(), r = e.replace(ri, (e, r) => {
|
|
1839
1841
|
let i = Number(r), a = t[i];
|
|
1840
1842
|
return a === void 0 ? "" : (n.add(i), a);
|
|
1841
1843
|
}), i = t.filter((e, t) => !n.has(t)).join("");
|
|
1842
1844
|
return i ? `${r}${i}` : r;
|
|
1843
|
-
},
|
|
1845
|
+
}, si = (e) => {
|
|
1844
1846
|
if (!/<pre[\s>/]/i.test(e)) return e;
|
|
1845
|
-
let t =
|
|
1847
|
+
let t = ai(e);
|
|
1846
1848
|
if (!t) return e;
|
|
1847
1849
|
let n = t.ownerDocument;
|
|
1848
1850
|
for (let e of Array.from(t.querySelectorAll("pre"))) {
|
|
@@ -1850,38 +1852,68 @@ var Kr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
|
1850
1852
|
e.replaceWith(t);
|
|
1851
1853
|
}
|
|
1852
1854
|
return t.innerHTML.replace(/<!--bsy-code-dropped-->/g, "");
|
|
1853
|
-
},
|
|
1854
|
-
if (!e.trim() || !
|
|
1855
|
-
let t =
|
|
1855
|
+
}, ci = (e, t) => oi(si(e), t), li = "p, h1, h2, h3, li", ui = /background(-color)?\s*:/i, di = (e) => {
|
|
1856
|
+
if (!e.trim() || !ui.test(e)) return e;
|
|
1857
|
+
let t = ai(e);
|
|
1856
1858
|
if (!t) return e;
|
|
1857
|
-
for (let e of Array.from(t.querySelectorAll(
|
|
1859
|
+
for (let e of Array.from(t.querySelectorAll(li))) {
|
|
1858
1860
|
let t = e;
|
|
1859
1861
|
t.style.removeProperty("background-color"), t.style.removeProperty("background"), t.getAttribute("style")?.trim() || t.removeAttribute("style");
|
|
1860
1862
|
}
|
|
1861
1863
|
return t.innerHTML;
|
|
1864
|
+
}, fi = "--listitem-marker-font-size", pi = `max(24px, calc(var(${fi}, 1em) * 1.25))`, mi = new Set([
|
|
1865
|
+
"U",
|
|
1866
|
+
"I",
|
|
1867
|
+
"EM",
|
|
1868
|
+
"B",
|
|
1869
|
+
"STRONG"
|
|
1870
|
+
]), hi = (e) => e.startsWith("--listitem-marker-"), gi = [
|
|
1871
|
+
["fontSize", fi],
|
|
1872
|
+
["color", "--listitem-marker-color"],
|
|
1873
|
+
["backgroundColor", "--listitem-marker-background-color"],
|
|
1874
|
+
["fontFamily", "--listitem-marker-font-family"]
|
|
1875
|
+
], _i = (e) => {
|
|
1876
|
+
let t = e.style.fontSize;
|
|
1877
|
+
if (gi.some(([t]) => e.style[t])) {
|
|
1878
|
+
for (let n = e.parentElement; n; n = n.parentElement) if (t && mi.has(n.tagName) && !n.style.fontSize && (n.style.fontSize = t), !(n.tagName !== "LI" || n.classList.contains("editor-nested-listitem"))) for (let [t, r] of gi) {
|
|
1879
|
+
let i = e.style[t];
|
|
1880
|
+
i && !n.style.getPropertyValue(r) && n.style.setProperty(r, i);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}, vi = (e, t, n, r) => {
|
|
1884
|
+
if (!e) return;
|
|
1885
|
+
let i = e.shadowRoot ?? e.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
1886
|
+
a.className = "bsy-editor-html-preview__body", a.innerHTML = n(t);
|
|
1887
|
+
for (let e of Array.from(a.querySelectorAll("table"))) {
|
|
1888
|
+
if (e.parentElement?.classList.contains("editor-table-scrollable-wrapper")) continue;
|
|
1889
|
+
let t = document.createElement("div");
|
|
1890
|
+
t.className = "editor-table-scrollable-wrapper", e.replaceWith(t), t.append(e);
|
|
1891
|
+
}
|
|
1892
|
+
let o = document.createElement("style");
|
|
1893
|
+
o.textContent = r, i.replaceChildren(o, a);
|
|
1862
1894
|
};
|
|
1863
1895
|
//#endregion
|
|
1864
1896
|
//#region src/components/Editor/utils/htmlText.ts
|
|
1865
|
-
function
|
|
1897
|
+
function yi(e) {
|
|
1866
1898
|
return /<[^>]*$/.test(e.trim());
|
|
1867
1899
|
}
|
|
1868
|
-
function
|
|
1900
|
+
function bi(e) {
|
|
1869
1901
|
return e ? new DOMParser().parseFromString(e, "text/html").body.textContent ?? "" : "";
|
|
1870
1902
|
}
|
|
1871
1903
|
//#endregion
|
|
1872
1904
|
//#region src/components/Editor/utils/fillRootFromHtml.ts
|
|
1873
|
-
var
|
|
1905
|
+
var xi = [
|
|
1874
1906
|
"color",
|
|
1875
1907
|
"background-color",
|
|
1876
1908
|
"font-size",
|
|
1877
1909
|
"font-family",
|
|
1878
1910
|
"font-weight",
|
|
1879
1911
|
"text-decoration"
|
|
1880
|
-
],
|
|
1912
|
+
], Si = (e) => {
|
|
1881
1913
|
let t = e.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, td, th");
|
|
1882
1914
|
for (let n of Array.from(t)) {
|
|
1883
1915
|
let t = n, r = [];
|
|
1884
|
-
for (let e of
|
|
1916
|
+
for (let e of xi) {
|
|
1885
1917
|
let n = t.style.getPropertyValue(e);
|
|
1886
1918
|
n && (r.push(`${e}: ${n}`), t.style.removeProperty(e));
|
|
1887
1919
|
}
|
|
@@ -1899,28 +1931,28 @@ var fi = [
|
|
|
1899
1931
|
}
|
|
1900
1932
|
}
|
|
1901
1933
|
}
|
|
1902
|
-
},
|
|
1903
|
-
let n =
|
|
1934
|
+
}, Ci = (e, t) => {
|
|
1935
|
+
let n = I();
|
|
1904
1936
|
if (n.clear(), t.trim()) {
|
|
1905
1937
|
let r = new DOMParser().parseFromString(t, "text/html");
|
|
1906
|
-
|
|
1907
|
-
let i =
|
|
1938
|
+
Si(r);
|
|
1939
|
+
let i = ge(e, r);
|
|
1908
1940
|
if (i.length) {
|
|
1909
|
-
n.select(),
|
|
1941
|
+
n.select(), Te(i), Ne(null);
|
|
1910
1942
|
return;
|
|
1911
1943
|
}
|
|
1912
1944
|
}
|
|
1913
|
-
let r =
|
|
1914
|
-
n.append(r),
|
|
1945
|
+
let r = ye();
|
|
1946
|
+
n.append(r), Ne(null);
|
|
1915
1947
|
};
|
|
1916
1948
|
//#endregion
|
|
1917
1949
|
//#region src/components/Editor/utils/isEmptyEditorHtml.ts
|
|
1918
|
-
function
|
|
1950
|
+
function wi(e, t) {
|
|
1919
1951
|
return !t.trim() && (e === "<p><br></p>" || e === "<p></p>" || e === "" || /^<p>\s*<br>\s*<\/p>$/.test(e));
|
|
1920
1952
|
}
|
|
1921
1953
|
//#endregion
|
|
1922
1954
|
//#region src/components/Editor/utils/sanitizeEditorHtml.ts
|
|
1923
|
-
var
|
|
1955
|
+
var Ti = /* @__PURE__ */ "p.br.strong.em.b.i.u.s.span.sub.sup.ul.ol.li.a.img.pre.code.table.thead.tbody.tr.td.th.h1.h2.h3.h4.h5.h6".split("."), Ei = [
|
|
1924
1956
|
"href",
|
|
1925
1957
|
"src",
|
|
1926
1958
|
"alt",
|
|
@@ -1936,12 +1968,12 @@ var gi = /* @__PURE__ */ "p.br.strong.em.b.i.u.s.span.sub.sup.ul.ol.li.a.img.pre
|
|
|
1936
1968
|
"style",
|
|
1937
1969
|
"width",
|
|
1938
1970
|
"height"
|
|
1939
|
-
],
|
|
1971
|
+
], Di = new Set(/* @__PURE__ */ "color.background-color.font-size.font-family.font-weight.font-style.text-decoration.text-align.max-width.display.vertical-align.width.height.border.margin.margin-inline-start.padding.padding-inline-start.line-height.list-style-type.list-style-position.list-style.border-collapse.table-layout.overflow-x.white-space.position.top.bottom.tab-size.border-radius.box-sizing.min-width.min-height.cursor".split(".")), Oi = /^(?:(?:(?:f|ht)tps?|mailto|blob):|data:image\/[a-z0-9.+-]+[;,].*|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i, ki = new Set([
|
|
1940
1972
|
"pre",
|
|
1941
1973
|
"code",
|
|
1942
1974
|
"td",
|
|
1943
1975
|
"th"
|
|
1944
|
-
]),
|
|
1976
|
+
]), Ai = new Set(["pre", "code"]), ji = new Set(["sup", "sub"]), Mi = (e, t) => hi(e) ? t === "li" : Di.has(e) ? e === "padding-inline-start" ? !0 : e === "padding" || e.startsWith("padding-") ? ki.has(t) : e === "border-radius" ? Ai.has(t) : e === "position" || e === "top" || e === "bottom" ? ji.has(t) : !0 : !1, Ni = (e, t) => e.split(";").map((e) => e.trim()).filter(Boolean).map((e) => {
|
|
1945
1977
|
let n = e.indexOf(":");
|
|
1946
1978
|
if (n === -1) return null;
|
|
1947
1979
|
let r = e.slice(0, n).trim().toLowerCase(), i = e.slice(n + 1).trim();
|
|
@@ -1949,78 +1981,80 @@ var gi = /* @__PURE__ */ "p.br.strong.em.b.i.u.s.span.sub.sup.ul.ol.li.a.img.pre
|
|
|
1949
1981
|
if (/url\s*\(/i.test(i)) return null;
|
|
1950
1982
|
r = "background-color";
|
|
1951
1983
|
}
|
|
1952
|
-
return !
|
|
1953
|
-
}).filter((e) => e !== null).join("; "),
|
|
1954
|
-
|
|
1984
|
+
return !Mi(r, t) || /expression|javascript:|url\s*\(\s*['"]?\s*javascript/i.test(i) ? null : `${r}: ${i}`;
|
|
1985
|
+
}).filter((e) => e !== null).join("; "), Pi = !1, Fi = () => {
|
|
1986
|
+
Pi ||= (Zt.addHook("uponSanitizeAttribute", (e, t) => {
|
|
1955
1987
|
if (t.attrName === "href" && /^data:/i.test(t.attrValue)) {
|
|
1956
1988
|
t.keepAttr = !1;
|
|
1957
1989
|
return;
|
|
1958
1990
|
}
|
|
1959
|
-
t.attrName === "style" && (t.attrValue =
|
|
1991
|
+
t.attrName === "style" && (t.attrValue = Ni(t.attrValue, e.nodeName.toLowerCase()), t.attrValue || (t.keepAttr = !1));
|
|
1960
1992
|
}), !0);
|
|
1961
1993
|
};
|
|
1962
1994
|
function X(e) {
|
|
1963
|
-
return e ? (
|
|
1964
|
-
ALLOWED_TAGS:
|
|
1965
|
-
ALLOWED_ATTR:
|
|
1995
|
+
return e ? (Fi(), Zt.sanitize(e, {
|
|
1996
|
+
ALLOWED_TAGS: Ti,
|
|
1997
|
+
ALLOWED_ATTR: Ei,
|
|
1966
1998
|
ALLOW_DATA_ATTR: !1,
|
|
1967
1999
|
ADD_ATTR: [
|
|
1968
2000
|
"data-language",
|
|
1969
2001
|
"data-id",
|
|
1970
2002
|
"data-src"
|
|
1971
2003
|
],
|
|
1972
|
-
ALLOWED_URI_REGEXP:
|
|
2004
|
+
ALLOWED_URI_REGEXP: Oi
|
|
1973
2005
|
})) : "";
|
|
1974
2006
|
}
|
|
1975
2007
|
//#endregion
|
|
1976
2008
|
//#region src/components/Editor/constants/portableEditorStyles.ts
|
|
1977
|
-
var
|
|
2009
|
+
var Ii = {
|
|
1978
2010
|
margin: "0.6em 0 0.4em",
|
|
1979
2011
|
"font-weight": "600",
|
|
1980
2012
|
"line-height": "1.35"
|
|
1981
|
-
},
|
|
2013
|
+
}, Li = {
|
|
1982
2014
|
h1: {
|
|
1983
|
-
...
|
|
2015
|
+
...Ii,
|
|
1984
2016
|
"font-size": "2em"
|
|
1985
2017
|
},
|
|
1986
2018
|
h2: {
|
|
1987
|
-
...
|
|
2019
|
+
...Ii,
|
|
1988
2020
|
"font-size": "1.5em"
|
|
1989
2021
|
},
|
|
1990
2022
|
h3: {
|
|
1991
|
-
...
|
|
2023
|
+
...Ii,
|
|
1992
2024
|
"font-size": "1.25em"
|
|
1993
2025
|
},
|
|
1994
2026
|
h4: {
|
|
1995
|
-
...
|
|
2027
|
+
...Ii,
|
|
1996
2028
|
"font-size": "1.125em"
|
|
1997
2029
|
},
|
|
1998
2030
|
h5: {
|
|
1999
|
-
...
|
|
2031
|
+
...Ii,
|
|
2000
2032
|
"font-size": "1em"
|
|
2001
2033
|
},
|
|
2002
2034
|
h6: {
|
|
2003
|
-
...
|
|
2035
|
+
...Ii,
|
|
2004
2036
|
"font-size": "0.875em"
|
|
2005
2037
|
}
|
|
2006
|
-
},
|
|
2038
|
+
}, Ri = {
|
|
2007
2039
|
color: "#0269ff",
|
|
2008
2040
|
cursor: "pointer"
|
|
2009
|
-
},
|
|
2041
|
+
}, zi = {
|
|
2010
2042
|
margin: "0",
|
|
2011
|
-
"padding-inline-start": "
|
|
2043
|
+
"padding-inline-start": "0",
|
|
2012
2044
|
"list-style-position": "outside"
|
|
2013
|
-
},
|
|
2045
|
+
}, Bi = [
|
|
2014
2046
|
"disc",
|
|
2015
2047
|
"circle",
|
|
2016
2048
|
"square"
|
|
2017
|
-
],
|
|
2049
|
+
], Vi = {
|
|
2018
2050
|
margin: "0",
|
|
2051
|
+
"margin-inline-start": pi,
|
|
2019
2052
|
"list-style": "inherit"
|
|
2020
|
-
},
|
|
2053
|
+
}, Hi = {
|
|
2021
2054
|
margin: "0",
|
|
2055
|
+
"margin-inline-start": "0",
|
|
2022
2056
|
"list-style-type": "none"
|
|
2023
|
-
},
|
|
2057
|
+
}, Ui = {
|
|
2024
2058
|
display: "block",
|
|
2025
2059
|
"box-sizing": "border-box",
|
|
2026
2060
|
"max-width": "100%",
|
|
@@ -2035,23 +2069,23 @@ var Di = {
|
|
|
2035
2069
|
"border-radius": "4px",
|
|
2036
2070
|
"background-color": "rgb(240, 242, 245)",
|
|
2037
2071
|
color: "#1f2328"
|
|
2038
|
-
},
|
|
2072
|
+
}, Wi = {
|
|
2039
2073
|
"border-collapse": "collapse",
|
|
2040
2074
|
"table-layout": "fixed",
|
|
2041
2075
|
width: "100%",
|
|
2042
2076
|
"overflow-x": "auto",
|
|
2043
2077
|
margin: "8px 0"
|
|
2044
|
-
},
|
|
2078
|
+
}, Gi = {
|
|
2045
2079
|
"box-sizing": "border-box",
|
|
2046
2080
|
"min-width": "75px",
|
|
2047
2081
|
"min-height": "32px",
|
|
2048
2082
|
padding: "4px 8px",
|
|
2049
2083
|
border: "1px solid #d9d9d9",
|
|
2050
2084
|
"vertical-align": "top"
|
|
2051
|
-
},
|
|
2085
|
+
}, Ki = {
|
|
2052
2086
|
"font-weight": "600",
|
|
2053
2087
|
"background-color": "#f2f3f5"
|
|
2054
|
-
},
|
|
2088
|
+
}, qi = {
|
|
2055
2089
|
display: "inline-block",
|
|
2056
2090
|
position: "static",
|
|
2057
2091
|
top: "auto",
|
|
@@ -2060,38 +2094,39 @@ var Di = {
|
|
|
2060
2094
|
"line-height": "1"
|
|
2061
2095
|
}, Z = (e, t) => {
|
|
2062
2096
|
for (let [n, r] of Object.entries(t)) e.style.getPropertyValue(n) || e.style.setProperty(n, r);
|
|
2063
|
-
},
|
|
2097
|
+
}, Ji = (e) => {
|
|
2064
2098
|
let t = 0, n = e;
|
|
2065
2099
|
for (; n;) n.tagName === "UL" && (t += 1), n = n.parentElement;
|
|
2066
2100
|
return t;
|
|
2067
|
-
},
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2101
|
+
}, Yi = (e) => {
|
|
2102
|
+
let t = [...e.querySelectorAll("*")].filter((e) => e instanceof HTMLElement);
|
|
2103
|
+
for (let e of t) _i(e);
|
|
2104
|
+
for (let e of t) {
|
|
2105
|
+
let t = e.tagName.toLowerCase(), n = Li[t];
|
|
2106
|
+
if (n && Z(e, n), t === "a" && Z(e, Ri), t === "ul") {
|
|
2107
|
+
let t = Math.min(Math.max(Ji(e), 1), Bi.length);
|
|
2108
|
+
Z(e, {
|
|
2109
|
+
...zi,
|
|
2110
|
+
"list-style-type": Bi[t - 1]
|
|
2076
2111
|
});
|
|
2077
2112
|
}
|
|
2078
|
-
|
|
2079
|
-
...
|
|
2113
|
+
t === "ol" && Z(e, {
|
|
2114
|
+
...zi,
|
|
2080
2115
|
"list-style-type": "decimal"
|
|
2081
|
-
}),
|
|
2082
|
-
...
|
|
2083
|
-
"vertical-align":
|
|
2084
|
-
}),
|
|
2085
|
-
for (let
|
|
2086
|
-
|
|
2116
|
+
}), t === "li" && Z(e, e.classList.contains("editor-nested-listitem") ? Hi : Vi), t === "pre" && Z(e, Ui), (t === "sup" || t === "sub") && Z(e, {
|
|
2117
|
+
...qi,
|
|
2118
|
+
"vertical-align": t === "sup" ? "super" : "sub"
|
|
2119
|
+
}), t === "table" && Z(e, Wi), (t === "td" || t === "th") && (Z(e, Gi), (t === "th" || e.classList.contains("editor-table-cell-header")) && Z(e, Ki)), e.classList.contains("editor-text-underline-strikethrough") ? Z(e, { "text-decoration": "underline line-through" }) : e.classList.contains("editor-text-underline") ? Z(e, { "text-decoration": "underline" }) : e.classList.contains("editor-text-strikethrough") && Z(e, { "text-decoration": "line-through" });
|
|
2120
|
+
for (let t of Array.from(e.classList)) t.startsWith("editor-") && e.classList.remove(t);
|
|
2121
|
+
e.classList.length === 0 && e.removeAttribute("class");
|
|
2087
2122
|
}
|
|
2088
|
-
},
|
|
2123
|
+
}, Xi = (e) => {
|
|
2089
2124
|
let t = e.parentNode;
|
|
2090
2125
|
if (t) {
|
|
2091
2126
|
for (; e.firstChild;) t.insertBefore(e.firstChild, e);
|
|
2092
2127
|
t.removeChild(e);
|
|
2093
2128
|
}
|
|
2094
|
-
},
|
|
2129
|
+
}, Zi = (e) => {
|
|
2095
2130
|
let t = !0;
|
|
2096
2131
|
for (; t;) {
|
|
2097
2132
|
t = !1;
|
|
@@ -2099,34 +2134,34 @@ var Di = {
|
|
|
2099
2134
|
if (n.attributes.length > 0) continue;
|
|
2100
2135
|
let e = n.tagName.toLowerCase();
|
|
2101
2136
|
if (e === "span") {
|
|
2102
|
-
|
|
2137
|
+
Xi(n), t = !0;
|
|
2103
2138
|
continue;
|
|
2104
2139
|
}
|
|
2105
2140
|
if (n.childElementCount !== 1 || n.childNodes.length !== 1) continue;
|
|
2106
2141
|
let r = n.firstElementChild;
|
|
2107
|
-
(e === "b" && r?.tagName === "STRONG" || e === "i" && r?.tagName === "EM") && (
|
|
2142
|
+
(e === "b" && r?.tagName === "STRONG" || e === "i" && r?.tagName === "EM") && (Xi(n), t = !0);
|
|
2108
2143
|
}
|
|
2109
2144
|
}
|
|
2110
2145
|
};
|
|
2111
|
-
function
|
|
2146
|
+
function Qi(e) {
|
|
2112
2147
|
if (!e.trim()) return e;
|
|
2113
2148
|
let t = new DOMParser().parseFromString(e, "text/html");
|
|
2114
|
-
|
|
2149
|
+
Yi(t.body), Zi(t.body);
|
|
2115
2150
|
for (let e of Array.from(t.body.querySelectorAll("pre"))) e.textContent?.trim() || e.remove();
|
|
2116
2151
|
return t.body.innerHTML;
|
|
2117
2152
|
}
|
|
2118
2153
|
//#endregion
|
|
2119
2154
|
//#region src/components/Editor/utils/applyAiPolish.ts
|
|
2120
|
-
function
|
|
2121
|
-
return e.join(`\n\n${
|
|
2155
|
+
function $i(e) {
|
|
2156
|
+
return e.join(`\n\n${ni}\n\n`);
|
|
2122
2157
|
}
|
|
2123
|
-
function
|
|
2124
|
-
return e.includes("<!--bsy-block-->") ? e.split(
|
|
2158
|
+
function ea(e) {
|
|
2159
|
+
return e.includes("<!--bsy-block-->") ? e.split(ni).map((e) => e.trim()) : [e];
|
|
2125
2160
|
}
|
|
2126
|
-
function
|
|
2127
|
-
return e.split(
|
|
2161
|
+
function ta(e) {
|
|
2162
|
+
return e.split(ni).join("").trim().length > 0;
|
|
2128
2163
|
}
|
|
2129
|
-
function
|
|
2164
|
+
function na(e, t) {
|
|
2130
2165
|
let n = e.map(() => "");
|
|
2131
2166
|
if (e.length === 0) return n;
|
|
2132
2167
|
let r = [], i = [];
|
|
@@ -2140,7 +2175,7 @@ function qi(e, t) {
|
|
|
2140
2175
|
for (; d < c;) n[n.length - 1] += o[d], d += 1;
|
|
2141
2176
|
return n;
|
|
2142
2177
|
}
|
|
2143
|
-
var
|
|
2178
|
+
var ra = new Set(["PRE"]), ia = new Set([
|
|
2144
2179
|
"PRE",
|
|
2145
2180
|
"TABLE",
|
|
2146
2181
|
"THEAD",
|
|
@@ -2151,11 +2186,11 @@ var Ji = new Set(["PRE"]), Yi = new Set([
|
|
|
2151
2186
|
"IMG",
|
|
2152
2187
|
"BR"
|
|
2153
2188
|
]);
|
|
2154
|
-
function
|
|
2189
|
+
function aa(e) {
|
|
2155
2190
|
let t = [], n = (e) => {
|
|
2156
2191
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
2157
2192
|
let t = e.tagName;
|
|
2158
|
-
if (
|
|
2193
|
+
if (ra.has(t)) return;
|
|
2159
2194
|
for (let t of Array.from(e.childNodes)) n(t);
|
|
2160
2195
|
return;
|
|
2161
2196
|
}
|
|
@@ -2163,31 +2198,31 @@ function Xi(e) {
|
|
|
2163
2198
|
};
|
|
2164
2199
|
return n(e), t;
|
|
2165
2200
|
}
|
|
2166
|
-
function
|
|
2201
|
+
function oa(e, t) {
|
|
2167
2202
|
let n = e;
|
|
2168
|
-
for (; n && n !== t && !
|
|
2203
|
+
for (; n && n !== t && !ia.has(n.tagName) && !(n.textContent ?? "").trim() && !n.querySelector("img, pre, table, br");) {
|
|
2169
2204
|
let e = n.parentElement;
|
|
2170
2205
|
n.remove(), n = e;
|
|
2171
2206
|
}
|
|
2172
2207
|
}
|
|
2173
|
-
function
|
|
2208
|
+
function sa(e) {
|
|
2174
2209
|
let t = e.tagName;
|
|
2175
2210
|
return t === "PRE" || t === "IMG" || t === "TABLE";
|
|
2176
2211
|
}
|
|
2177
|
-
function
|
|
2178
|
-
let t =
|
|
2179
|
-
return t ? Array.from(t.children).filter((e) => !
|
|
2212
|
+
function ca(e) {
|
|
2213
|
+
let t = ai(e);
|
|
2214
|
+
return t ? Array.from(t.children).filter((e) => !sa(e)).map((e) => e.textContent ?? "") : [];
|
|
2180
2215
|
}
|
|
2181
|
-
function
|
|
2182
|
-
return e.includes("<!--bsy-block-->") ? e :
|
|
2216
|
+
function la(e) {
|
|
2217
|
+
return e.includes("<!--bsy-block-->") ? e : bi(e) || e;
|
|
2183
2218
|
}
|
|
2184
|
-
function
|
|
2185
|
-
let n =
|
|
2219
|
+
function ua(e, t) {
|
|
2220
|
+
let n = aa(e);
|
|
2186
2221
|
if (n.length === 0) {
|
|
2187
2222
|
t && (e.querySelector("br")?.remove(), e.append(e.ownerDocument.createTextNode(t)));
|
|
2188
2223
|
return;
|
|
2189
2224
|
}
|
|
2190
|
-
let r =
|
|
2225
|
+
let r = na(n.map((e) => e.textContent ?? ""), t);
|
|
2191
2226
|
for (let t = 0; t < n.length; t++) {
|
|
2192
2227
|
let i = r[t], a = n[t];
|
|
2193
2228
|
if (i) {
|
|
@@ -2195,38 +2230,38 @@ function ta(e, t) {
|
|
|
2195
2230
|
continue;
|
|
2196
2231
|
}
|
|
2197
2232
|
let o = a.parentElement;
|
|
2198
|
-
a.remove(),
|
|
2233
|
+
a.remove(), oa(o, e);
|
|
2199
2234
|
}
|
|
2200
2235
|
}
|
|
2201
|
-
function
|
|
2202
|
-
let n =
|
|
2203
|
-
if (!
|
|
2204
|
-
let r =
|
|
2236
|
+
function da(e, t) {
|
|
2237
|
+
let n = la(t);
|
|
2238
|
+
if (!ta(n) || !e.trim()) return "";
|
|
2239
|
+
let r = ai(e);
|
|
2205
2240
|
if (!r) return "";
|
|
2206
|
-
let i = Array.from(r.children).filter((e) => !
|
|
2241
|
+
let i = Array.from(r.children).filter((e) => !sa(e));
|
|
2207
2242
|
if (i.length === 0) return "";
|
|
2208
|
-
let a =
|
|
2209
|
-
for (let e = 0; e < i.length; e++)
|
|
2243
|
+
let a = ea(n), o = a.length === i.length ? a : na(i.map((e) => e.textContent ?? ""), a.join(""));
|
|
2244
|
+
for (let e = 0; e < i.length; e++) ua(i[e], o[e] ?? "");
|
|
2210
2245
|
return r.innerHTML;
|
|
2211
2246
|
}
|
|
2212
|
-
function
|
|
2247
|
+
function fa(e, t) {
|
|
2213
2248
|
let n = "";
|
|
2214
2249
|
e.getEditorState().read(() => {
|
|
2215
|
-
n =
|
|
2250
|
+
n = Qi(X(he(e, null)));
|
|
2216
2251
|
}, { editor: e });
|
|
2217
|
-
let r = X(
|
|
2218
|
-
return !r.trim() ||
|
|
2219
|
-
|
|
2252
|
+
let r = X(da(n, t));
|
|
2253
|
+
return !r.trim() || wi(r, bi(r)) ? !1 : (e.update(() => {
|
|
2254
|
+
Ci(e, r), On(!0);
|
|
2220
2255
|
}, { discrete: !0 }), !0);
|
|
2221
2256
|
}
|
|
2222
2257
|
//#endregion
|
|
2223
2258
|
//#region src/components/Editor/utils/readEditorAiSnapshot.ts
|
|
2224
|
-
function
|
|
2259
|
+
function pa(e) {
|
|
2225
2260
|
let t = "", n = "", r = "";
|
|
2226
2261
|
e.getEditorState().read(() => {
|
|
2227
|
-
n =
|
|
2262
|
+
n = I().getTextContent(), t = Qi(X(he(e, null))), r = $i(ca(t));
|
|
2228
2263
|
}, { editor: e });
|
|
2229
|
-
let i =
|
|
2264
|
+
let i = ti(t);
|
|
2230
2265
|
return {
|
|
2231
2266
|
html: t,
|
|
2232
2267
|
text: n,
|
|
@@ -2265,17 +2300,17 @@ var Q = {
|
|
|
2265
2300
|
"bsy-lexical-ai__footer": "_bsy-lexical-ai__footer_p7v4i_165",
|
|
2266
2301
|
"bsy-lexical-ai__error": "_bsy-lexical-ai__error_p7v4i_173",
|
|
2267
2302
|
"bsy-lexical-ai__preset": "_bsy-lexical-ai__preset_p7v4i_178"
|
|
2268
|
-
},
|
|
2269
|
-
let [i] =
|
|
2303
|
+
}, ma = "data:image/png;base64,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", ha = "data:image/png;base64,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", ga = 16, _a = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
2304
|
+
let [i] = z(), { typeset: o, polish: s, canTypeset: c, canPolish: l, aiOpen: u, setAiOpen: d, aiSessionRef: p } = gr(), { hasEditorText: m } = J(), { t: h } = a(), { iconSize: g } = Un(), _ = t || !c || !m, x = t || !l || !m, S = t || !!u, C = T(() => {
|
|
2270
2305
|
if (t || !c || !o) return;
|
|
2271
|
-
let e =
|
|
2306
|
+
let e = pa(i);
|
|
2272
2307
|
e.text.trim() && (p.current = {
|
|
2273
2308
|
originalHtml: e.html,
|
|
2274
2309
|
codeBlocks: e.codeBlocks
|
|
2275
2310
|
}, d("typeset"), o({
|
|
2276
2311
|
text: e.text,
|
|
2277
2312
|
html: e.htmlWithoutCode,
|
|
2278
|
-
prompt:
|
|
2313
|
+
prompt: Qr
|
|
2279
2314
|
}));
|
|
2280
2315
|
}, [
|
|
2281
2316
|
p,
|
|
@@ -2286,15 +2321,15 @@ var Q = {
|
|
|
2286
2321
|
o
|
|
2287
2322
|
]), w = T((e) => {
|
|
2288
2323
|
if (t || !l || !s) return;
|
|
2289
|
-
let n =
|
|
2290
|
-
|
|
2324
|
+
let n = pa(i);
|
|
2325
|
+
ta(n.polishText) && (p.current = {
|
|
2291
2326
|
originalHtml: n.html,
|
|
2292
2327
|
originalText: n.polishText,
|
|
2293
2328
|
preset: e
|
|
2294
2329
|
}, d("polish"), s({
|
|
2295
2330
|
text: n.polishText,
|
|
2296
2331
|
preset: e,
|
|
2297
|
-
prompt:
|
|
2332
|
+
prompt: ei(e)
|
|
2298
2333
|
}));
|
|
2299
2334
|
}, [
|
|
2300
2335
|
p,
|
|
@@ -2308,16 +2343,16 @@ var Q = {
|
|
|
2308
2343
|
C();
|
|
2309
2344
|
return;
|
|
2310
2345
|
}
|
|
2311
|
-
|
|
2346
|
+
Yr.includes(e.key) && w(e.key);
|
|
2312
2347
|
}, [w, C]), D = [{
|
|
2313
2348
|
key: "typeset",
|
|
2314
2349
|
label: h("editor.aiTypeset"),
|
|
2315
2350
|
disabled: _,
|
|
2316
2351
|
icon: /* @__PURE__ */ y("img", {
|
|
2317
|
-
src:
|
|
2352
|
+
src: ma,
|
|
2318
2353
|
alt: "",
|
|
2319
|
-
width:
|
|
2320
|
-
height:
|
|
2354
|
+
width: ga,
|
|
2355
|
+
height: ga,
|
|
2321
2356
|
className: Q["bsy-lexical-ai__icon"],
|
|
2322
2357
|
draggable: !1
|
|
2323
2358
|
})
|
|
@@ -2326,40 +2361,40 @@ var Q = {
|
|
|
2326
2361
|
label: h("editor.aiPolish"),
|
|
2327
2362
|
disabled: x,
|
|
2328
2363
|
icon: /* @__PURE__ */ y("img", {
|
|
2329
|
-
src:
|
|
2364
|
+
src: ha,
|
|
2330
2365
|
alt: "",
|
|
2331
|
-
width:
|
|
2332
|
-
height:
|
|
2366
|
+
width: ga,
|
|
2367
|
+
height: ga,
|
|
2333
2368
|
className: Q["bsy-lexical-ai__icon"],
|
|
2334
2369
|
draggable: !1
|
|
2335
2370
|
}),
|
|
2336
|
-
children:
|
|
2371
|
+
children: Yr.map((e) => ({
|
|
2337
2372
|
key: e,
|
|
2338
|
-
label: h(
|
|
2373
|
+
label: h(Xr[e])
|
|
2339
2374
|
}))
|
|
2340
2375
|
}], O = /* @__PURE__ */ y("div", {
|
|
2341
|
-
className:
|
|
2376
|
+
className: F(G["bsy-lexical__toolbar-select"], G["bsy-lexical__toolbar-select--ai"], Q["bsy-lexical-ai__trigger"]),
|
|
2342
2377
|
children: /* @__PURE__ */ y(q, {
|
|
2343
2378
|
tooltip: n,
|
|
2344
2379
|
showDisabledTooltip: r,
|
|
2345
2380
|
disabled: S,
|
|
2346
2381
|
icon: /* @__PURE__ */ b(v, { children: [
|
|
2347
2382
|
/* @__PURE__ */ y("img", {
|
|
2348
|
-
src:
|
|
2383
|
+
src: ma,
|
|
2349
2384
|
alt: "",
|
|
2350
|
-
width:
|
|
2351
|
-
height:
|
|
2385
|
+
width: ga,
|
|
2386
|
+
height: ga,
|
|
2352
2387
|
className: Q["bsy-lexical-ai__icon"],
|
|
2353
2388
|
draggable: !1
|
|
2354
2389
|
}),
|
|
2355
2390
|
/* @__PURE__ */ y("span", {
|
|
2356
|
-
className:
|
|
2391
|
+
className: G["bsy-lexical__toolbar-select-label"],
|
|
2357
2392
|
children: h("editor.aiTypeset")
|
|
2358
2393
|
}),
|
|
2359
2394
|
/* @__PURE__ */ y(e, {
|
|
2360
2395
|
name: "arrow-down",
|
|
2361
2396
|
size: g,
|
|
2362
|
-
className:
|
|
2397
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
2363
2398
|
})
|
|
2364
2399
|
] })
|
|
2365
2400
|
})
|
|
@@ -2368,51 +2403,51 @@ var Q = {
|
|
|
2368
2403
|
menus: D,
|
|
2369
2404
|
onClick: E,
|
|
2370
2405
|
showSearch: !1,
|
|
2371
|
-
offset:
|
|
2406
|
+
offset: W,
|
|
2372
2407
|
style: {
|
|
2373
2408
|
width: 147,
|
|
2374
2409
|
minWidth: 147
|
|
2375
2410
|
},
|
|
2376
2411
|
children: O
|
|
2377
2412
|
});
|
|
2378
|
-
},
|
|
2413
|
+
}, va = /* @__PURE__ */ new Map(), ya = (e, t) => {
|
|
2379
2414
|
if (!e) throw Error("registerToolbarButton: name is required");
|
|
2380
|
-
|
|
2381
|
-
},
|
|
2382
|
-
|
|
2383
|
-
},
|
|
2415
|
+
va.set(e, t);
|
|
2416
|
+
}, ba = (e) => {
|
|
2417
|
+
va.delete(e);
|
|
2418
|
+
}, xa = (e) => va.get(e), Sa = () => Array.from(va.keys());
|
|
2384
2419
|
Object.entries({
|
|
2385
|
-
undo:
|
|
2386
|
-
redo:
|
|
2387
|
-
bold:
|
|
2388
|
-
underline:
|
|
2389
|
-
italic:
|
|
2390
|
-
strikethrough:
|
|
2391
|
-
superscript:
|
|
2392
|
-
subscript:
|
|
2393
|
-
heading:
|
|
2394
|
-
fontSize:
|
|
2395
|
-
fontColor:
|
|
2396
|
-
fill:
|
|
2397
|
-
clearFormat:
|
|
2398
|
-
bullet:
|
|
2399
|
-
number:
|
|
2400
|
-
outdent:
|
|
2401
|
-
indent:
|
|
2402
|
-
align:
|
|
2403
|
-
link:
|
|
2404
|
-
unLink:
|
|
2405
|
-
picture:
|
|
2406
|
-
code:
|
|
2407
|
-
table:
|
|
2408
|
-
source:
|
|
2409
|
-
ai:
|
|
2420
|
+
undo: Ar,
|
|
2421
|
+
redo: jr,
|
|
2422
|
+
bold: Gn,
|
|
2423
|
+
underline: Kn,
|
|
2424
|
+
italic: qn,
|
|
2425
|
+
strikethrough: Mr,
|
|
2426
|
+
superscript: Nr,
|
|
2427
|
+
subscript: Pr,
|
|
2428
|
+
heading: Kr,
|
|
2429
|
+
fontSize: Jn,
|
|
2430
|
+
fontColor: rr,
|
|
2431
|
+
fill: ir,
|
|
2432
|
+
clearFormat: Jr,
|
|
2433
|
+
bullet: Lr,
|
|
2434
|
+
number: Rr,
|
|
2435
|
+
outdent: Ir,
|
|
2436
|
+
indent: Fr,
|
|
2437
|
+
align: or,
|
|
2438
|
+
link: cr,
|
|
2439
|
+
unLink: lr,
|
|
2440
|
+
picture: kr,
|
|
2441
|
+
code: zr,
|
|
2442
|
+
table: Hr,
|
|
2443
|
+
source: Gr,
|
|
2444
|
+
ai: _a
|
|
2410
2445
|
}).forEach(([e, t]) => {
|
|
2411
|
-
|
|
2446
|
+
ya(e, t);
|
|
2412
2447
|
});
|
|
2413
2448
|
//#endregion
|
|
2414
2449
|
//#region src/components/Editor/utils/getToolbarItems.ts
|
|
2415
|
-
var
|
|
2450
|
+
var Ca = (e, t, n) => {
|
|
2416
2451
|
if (n) return [
|
|
2417
2452
|
{
|
|
2418
2453
|
kind: "button",
|
|
@@ -2470,44 +2505,44 @@ var ma = (e, t, n) => {
|
|
|
2470
2505
|
key: `divider-${t.key}`
|
|
2471
2506
|
});
|
|
2472
2507
|
}), r;
|
|
2473
|
-
},
|
|
2508
|
+
}, wa = wn.map((e) => ({
|
|
2474
2509
|
key: e.id,
|
|
2475
2510
|
label: e.label
|
|
2476
|
-
})),
|
|
2477
|
-
let [t] =
|
|
2511
|
+
})), Ta = () => {
|
|
2512
|
+
let [t] = z(), { codeLanguage: n } = J(), { t: r } = a(), { iconSize: i } = Un(), o = T((e) => {
|
|
2478
2513
|
let n = e.key;
|
|
2479
|
-
|
|
2480
|
-
let e =
|
|
2481
|
-
|
|
2514
|
+
K(t), t.update(() => {
|
|
2515
|
+
let e = L();
|
|
2516
|
+
R(e) && H(e.anchor.getNode(), V)?.setLanguage(n);
|
|
2482
2517
|
});
|
|
2483
|
-
}, [t]), s =
|
|
2518
|
+
}, [t]), s = Tn[n].label;
|
|
2484
2519
|
return /* @__PURE__ */ y(f, {
|
|
2485
|
-
menus:
|
|
2520
|
+
menus: wa,
|
|
2486
2521
|
onClick: o,
|
|
2487
2522
|
activeKey: [n],
|
|
2488
2523
|
showSearch: !1,
|
|
2489
|
-
offset:
|
|
2524
|
+
offset: W,
|
|
2490
2525
|
style: {
|
|
2491
2526
|
width: 120,
|
|
2492
2527
|
minWidth: 120
|
|
2493
2528
|
},
|
|
2494
2529
|
children: /* @__PURE__ */ y("div", {
|
|
2495
|
-
className:
|
|
2530
|
+
className: G["bsy-lexical__toolbar-select"],
|
|
2496
2531
|
style: { width: 120 },
|
|
2497
2532
|
children: /* @__PURE__ */ y(q, {
|
|
2498
2533
|
icon: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("span", {
|
|
2499
|
-
className:
|
|
2534
|
+
className: G["bsy-lexical__toolbar-select-label"],
|
|
2500
2535
|
children: s
|
|
2501
2536
|
}), /* @__PURE__ */ y(e, {
|
|
2502
2537
|
name: "arrow-down",
|
|
2503
2538
|
size: i,
|
|
2504
|
-
className:
|
|
2539
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
2505
2540
|
})] }),
|
|
2506
2541
|
tooltip: r("editor.codeLanguage")
|
|
2507
2542
|
})
|
|
2508
2543
|
})
|
|
2509
2544
|
});
|
|
2510
|
-
},
|
|
2545
|
+
}, Ea = {
|
|
2511
2546
|
initial: {
|
|
2512
2547
|
opacity: 0,
|
|
2513
2548
|
x: 6
|
|
@@ -2520,24 +2555,24 @@ var ma = (e, t, n) => {
|
|
|
2520
2555
|
opacity: 0,
|
|
2521
2556
|
x: -6
|
|
2522
2557
|
}
|
|
2523
|
-
},
|
|
2524
|
-
if (e.kind === "divider") return /* @__PURE__ */ y("div", { className:
|
|
2525
|
-
if (e.kind === "language") return /* @__PURE__ */ y(
|
|
2526
|
-
let t =
|
|
2558
|
+
}, Da = (e) => {
|
|
2559
|
+
if (e.kind === "divider") return /* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] });
|
|
2560
|
+
if (e.kind === "language") return /* @__PURE__ */ y(Ta, {});
|
|
2561
|
+
let t = xa(e.name);
|
|
2527
2562
|
return t ? /* @__PURE__ */ y(t, { ...e.props }) : (console.warn(`[ToolbarPlugin] Button "${e.name}" is not registered.`), null);
|
|
2528
|
-
},
|
|
2529
|
-
let i =
|
|
2530
|
-
return i === null ? null : /* @__PURE__ */ y(
|
|
2563
|
+
}, Oa = C(function({ item: e, motionProps: t, transition: n }, r) {
|
|
2564
|
+
let i = Da(e);
|
|
2565
|
+
return i === null ? null : /* @__PURE__ */ y(oe.div, {
|
|
2531
2566
|
ref: r,
|
|
2532
2567
|
"data-toolbar-item-key": e.key,
|
|
2533
|
-
className:
|
|
2568
|
+
className: F(G["bsy-lexical__toolbar-item"], e.kind === "button" && e.props?.disabled && G["bsy-lexical__toolbar-item--disabled"]),
|
|
2534
2569
|
layout: "position",
|
|
2535
2570
|
transition: n,
|
|
2536
2571
|
...t,
|
|
2537
2572
|
children: i
|
|
2538
2573
|
}, e.key);
|
|
2539
|
-
}),
|
|
2540
|
-
let { isCodeBlock: n } = J(), { isSourceMode: r } =
|
|
2574
|
+
}), ka = ({ config: e, sizeToken: t }) => {
|
|
2575
|
+
let { isCodeBlock: n } = J(), { isSourceMode: r } = Wr(), i = se(), o = A(() => Ca(e, n, r), [
|
|
2541
2576
|
e,
|
|
2542
2577
|
n,
|
|
2543
2578
|
r
|
|
@@ -2554,7 +2589,7 @@ var ma = (e, t, n) => {
|
|
|
2554
2589
|
let [_, v] = M(!1), x = {
|
|
2555
2590
|
duration: i ? 0 : .16,
|
|
2556
2591
|
ease: "easeOut"
|
|
2557
|
-
}, S = i ? {} :
|
|
2592
|
+
}, S = i ? {} : Ea, C = T(() => {
|
|
2558
2593
|
let e = l.current;
|
|
2559
2594
|
if (!e || f.current && g.current !== o.length) return;
|
|
2560
2595
|
let t = getComputedStyle(e), n = Number.parseFloat(t.columnGap || t.gap) || 0, r = e.clientWidth, i = new Set(o.map((e) => e.key));
|
|
@@ -2570,16 +2605,16 @@ var ma = (e, t, n) => {
|
|
|
2570
2605
|
}));
|
|
2571
2606
|
f.current && o.length > 0 && c.every((e) => e.width <= 0) || (f.current = !1, m({
|
|
2572
2607
|
keys: s,
|
|
2573
|
-
count:
|
|
2608
|
+
count: pn(c, r, a, n)
|
|
2574
2609
|
}));
|
|
2575
2610
|
}, [s, o]);
|
|
2576
|
-
|
|
2611
|
+
k(() => {
|
|
2577
2612
|
f.current = !0, u.current = {};
|
|
2578
2613
|
}, [
|
|
2579
2614
|
s,
|
|
2580
2615
|
o.length,
|
|
2581
2616
|
t
|
|
2582
|
-
]),
|
|
2617
|
+
]), k(() => {
|
|
2583
2618
|
C();
|
|
2584
2619
|
let e = l.current;
|
|
2585
2620
|
if (!e || typeof ResizeObserver > "u") return;
|
|
@@ -2590,27 +2625,27 @@ var ma = (e, t, n) => {
|
|
|
2590
2625
|
s,
|
|
2591
2626
|
t
|
|
2592
2627
|
]);
|
|
2593
|
-
let { visible: w, overflow: E } =
|
|
2628
|
+
let { visible: w, overflow: E } = mn(o, h), D = E.length > 0, O = j(E);
|
|
2594
2629
|
E.length > 0 && (O.current = E);
|
|
2595
|
-
let ee = _ && D,
|
|
2630
|
+
let ee = _ && D, te = D || _ && O.current.length > 0, N = D ? E : O.current;
|
|
2596
2631
|
return /* @__PURE__ */ b("div", {
|
|
2597
|
-
className:
|
|
2632
|
+
className: F(G["bsy-lexical__toolbar-stack"], i && G["bsy-lexical__toolbar-stack--instant"]),
|
|
2598
2633
|
children: [/* @__PURE__ */ b("div", {
|
|
2599
2634
|
ref: l,
|
|
2600
|
-
className:
|
|
2635
|
+
className: G["bsy-lexical__toolbar-items"],
|
|
2601
2636
|
children: [
|
|
2602
|
-
/* @__PURE__ */ y(
|
|
2637
|
+
/* @__PURE__ */ y(ae, {
|
|
2603
2638
|
initial: !1,
|
|
2604
2639
|
mode: "popLayout",
|
|
2605
|
-
children: w.map((e) => /* @__PURE__ */ y(
|
|
2640
|
+
children: w.map((e) => /* @__PURE__ */ y(Oa, {
|
|
2606
2641
|
item: e,
|
|
2607
2642
|
motionProps: S,
|
|
2608
2643
|
transition: x
|
|
2609
2644
|
}, e.key))
|
|
2610
2645
|
}),
|
|
2611
2646
|
D ? /* @__PURE__ */ b("div", {
|
|
2612
|
-
className:
|
|
2613
|
-
children: [/* @__PURE__ */ y("div", { className:
|
|
2647
|
+
className: F(G["bsy-lexical__toolbar-overflow"], G["bsy-lexical__toolbar-with-divider"]),
|
|
2648
|
+
children: [/* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ y(q, {
|
|
2614
2649
|
icon: ee ? "packupeverything" : "expandall",
|
|
2615
2650
|
tooltip: c(ee ? "editor.collapse" : "editor.expand"),
|
|
2616
2651
|
highlight: ee,
|
|
@@ -2619,19 +2654,19 @@ var ma = (e, t, n) => {
|
|
|
2619
2654
|
}) : null,
|
|
2620
2655
|
/* @__PURE__ */ b("div", {
|
|
2621
2656
|
ref: d,
|
|
2622
|
-
className:
|
|
2657
|
+
className: F(G["bsy-lexical__toolbar-more-sizer"], G["bsy-lexical__toolbar-with-divider"]),
|
|
2623
2658
|
"aria-hidden": !0,
|
|
2624
|
-
children: [/* @__PURE__ */ y("div", { className:
|
|
2659
|
+
children: [/* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ y(q, {
|
|
2625
2660
|
icon: "expandall",
|
|
2626
2661
|
tooltip: ""
|
|
2627
2662
|
})]
|
|
2628
2663
|
})
|
|
2629
2664
|
]
|
|
2630
|
-
}),
|
|
2631
|
-
className:
|
|
2665
|
+
}), te ? /* @__PURE__ */ y("div", {
|
|
2666
|
+
className: F(G["bsy-lexical__toolbar-overflow-row"], ee && G["bsy-lexical__toolbar-overflow-row--open"], i && G["bsy-lexical__toolbar-overflow-row--instant"]),
|
|
2632
2667
|
children: /* @__PURE__ */ y("div", {
|
|
2633
|
-
className:
|
|
2634
|
-
children: N.map((e) => /* @__PURE__ */ y(
|
|
2668
|
+
className: G["bsy-lexical__toolbar-overflow-inner"],
|
|
2669
|
+
children: N.map((e) => /* @__PURE__ */ y(Oa, {
|
|
2635
2670
|
item: e,
|
|
2636
2671
|
motionProps: {},
|
|
2637
2672
|
transition: x
|
|
@@ -2639,11 +2674,11 @@ var ma = (e, t, n) => {
|
|
|
2639
2674
|
})
|
|
2640
2675
|
}) : null]
|
|
2641
2676
|
});
|
|
2642
|
-
},
|
|
2643
|
-
let { config: t = [], style: n, theme: r, mode: i, floating: a, stickyOffset: o, size: s = sn } = e, { toolbarRef: c } =
|
|
2677
|
+
}, Aa = (e) => {
|
|
2678
|
+
let { config: t = [], style: n, theme: r, mode: i, floating: a, stickyOffset: o, size: s = sn } = e, { toolbarRef: c } = gr(), l = i === "floating", u = o !== void 0, d = se(), f = {
|
|
2644
2679
|
duration: d ? 0 : .16,
|
|
2645
2680
|
ease: "easeOut"
|
|
2646
|
-
}, p = A(() =>
|
|
2681
|
+
}, p = A(() => un(r, s), [r, s]), m = A(() => ({ iconSize: dn(r?.iconSize, s) }), [r?.iconSize, s]), h = l ? fn(a) : void 0, _ = l ? g(n, [
|
|
2647
2682
|
"position",
|
|
2648
2683
|
"left",
|
|
2649
2684
|
"top",
|
|
@@ -2654,41 +2689,41 @@ var ma = (e, t, n) => {
|
|
|
2654
2689
|
"marginTop",
|
|
2655
2690
|
"marginBottom"
|
|
2656
2691
|
]) : n;
|
|
2657
|
-
return /* @__PURE__ */ y(
|
|
2692
|
+
return /* @__PURE__ */ y(Hn, {
|
|
2658
2693
|
value: m,
|
|
2659
|
-
children: /* @__PURE__ */ y(
|
|
2694
|
+
children: /* @__PURE__ */ y(Bn, { children: /* @__PURE__ */ y(Ln, { children: /* @__PURE__ */ y(oe.div, {
|
|
2660
2695
|
ref: c,
|
|
2661
2696
|
layout: d || u ? !1 : "position",
|
|
2662
2697
|
transition: f,
|
|
2663
|
-
className:
|
|
2698
|
+
className: F(G["bsy-lexical__toolbar"], l && G["bsy-lexical__toolbar--floating"], u && G["bsy-lexical__toolbar--sticky"]),
|
|
2664
2699
|
style: {
|
|
2665
2700
|
...p,
|
|
2666
2701
|
...u ? { top: o } : null,
|
|
2667
2702
|
...h,
|
|
2668
2703
|
..._
|
|
2669
2704
|
},
|
|
2670
|
-
children: /* @__PURE__ */ y(
|
|
2705
|
+
children: /* @__PURE__ */ y(ka, {
|
|
2671
2706
|
config: t,
|
|
2672
2707
|
sizeToken: `${s}|${r?.itemHeight ?? ""}|${r?.iconSize ?? ""}`
|
|
2673
2708
|
})
|
|
2674
2709
|
}) }) })
|
|
2675
2710
|
});
|
|
2676
2711
|
}, $ = {
|
|
2677
|
-
"bsy-lexical-editor": "_bsy-lexical-
|
|
2678
|
-
"bsy-lexical-editor--floating": "_bsy-lexical-editor--
|
|
2679
|
-
"bsy-lexical-editor--sticky-toolbar": "_bsy-lexical-editor--sticky-
|
|
2680
|
-
"bsy-lexical-editor__body": "_bsy-lexical-
|
|
2681
|
-
"bsy-lexical-editor__body--fixed": "_bsy-lexical-editor__body--
|
|
2682
|
-
"bsy-lexical-editor__editable-wrap": "_bsy-lexical-editor__editable-
|
|
2683
|
-
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-
|
|
2684
|
-
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-
|
|
2685
|
-
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--
|
|
2686
|
-
},
|
|
2712
|
+
"bsy-lexical-editor": "_bsy-lexical-editor_135r0_2",
|
|
2713
|
+
"bsy-lexical-editor--floating": "_bsy-lexical-editor--floating_135r0_9",
|
|
2714
|
+
"bsy-lexical-editor--sticky-toolbar": "_bsy-lexical-editor--sticky-toolbar_135r0_9",
|
|
2715
|
+
"bsy-lexical-editor__body": "_bsy-lexical-editor__body_135r0_12",
|
|
2716
|
+
"bsy-lexical-editor__body--fixed": "_bsy-lexical-editor__body--fixed_135r0_17",
|
|
2717
|
+
"bsy-lexical-editor__editable-wrap": "_bsy-lexical-editor__editable-wrap_135r0_20",
|
|
2718
|
+
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_135r0_30",
|
|
2719
|
+
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_135r0_50",
|
|
2720
|
+
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_135r0_62"
|
|
2721
|
+
}, ja = (e) => {
|
|
2687
2722
|
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
2688
|
-
},
|
|
2723
|
+
}, Ma = (e) => {
|
|
2689
2724
|
let t = {};
|
|
2690
|
-
return e ? (s(t, "--bsy-editor-container-border-color", e.borderColor), s(t, "--bsy-editor-container-border-width",
|
|
2691
|
-
},
|
|
2725
|
+
return e ? (s(t, "--bsy-editor-container-border-color", e.borderColor), s(t, "--bsy-editor-container-border-width", ja(e.borderWidth)), s(t, "--bsy-editor-container-border-radius", ja(e.borderRadius)), t) : t;
|
|
2726
|
+
}, Na = class e extends rt {
|
|
2692
2727
|
constructor(e, t) {
|
|
2693
2728
|
super(e, t);
|
|
2694
2729
|
}
|
|
@@ -2703,42 +2738,42 @@ var ma = (e, t, n) => {
|
|
|
2703
2738
|
return {
|
|
2704
2739
|
...e,
|
|
2705
2740
|
code: () => ({
|
|
2706
|
-
conversion:
|
|
2741
|
+
conversion: Fa(e?.code),
|
|
2707
2742
|
priority: 1
|
|
2708
2743
|
}),
|
|
2709
2744
|
em: () => ({
|
|
2710
|
-
conversion:
|
|
2745
|
+
conversion: Fa(e?.em),
|
|
2711
2746
|
priority: 1
|
|
2712
2747
|
}),
|
|
2713
2748
|
span: () => ({
|
|
2714
|
-
conversion:
|
|
2749
|
+
conversion: Fa(e?.span),
|
|
2715
2750
|
priority: 1
|
|
2716
2751
|
}),
|
|
2717
2752
|
strong: () => ({
|
|
2718
|
-
conversion:
|
|
2753
|
+
conversion: Fa(e?.strong),
|
|
2719
2754
|
priority: 1
|
|
2720
2755
|
}),
|
|
2721
2756
|
sub: () => ({
|
|
2722
|
-
conversion:
|
|
2757
|
+
conversion: Fa(e?.sub),
|
|
2723
2758
|
priority: 1
|
|
2724
2759
|
}),
|
|
2725
2760
|
sup: () => ({
|
|
2726
|
-
conversion:
|
|
2761
|
+
conversion: Fa(e?.sup),
|
|
2727
2762
|
priority: 1
|
|
2728
2763
|
})
|
|
2729
2764
|
};
|
|
2730
2765
|
}
|
|
2731
2766
|
static importJSON(e) {
|
|
2732
|
-
return
|
|
2767
|
+
return Pa().updateFromJSON(e);
|
|
2733
2768
|
}
|
|
2734
2769
|
isSimpleText() {
|
|
2735
2770
|
return this.__type === "extended-text" && this.__mode === 0;
|
|
2736
2771
|
}
|
|
2737
2772
|
};
|
|
2738
|
-
function
|
|
2739
|
-
return
|
|
2773
|
+
function Pa(e = "") {
|
|
2774
|
+
return _e(new Na(e));
|
|
2740
2775
|
}
|
|
2741
|
-
function
|
|
2776
|
+
function Fa(e) {
|
|
2742
2777
|
return (t) => {
|
|
2743
2778
|
let n = e?.(t);
|
|
2744
2779
|
if (!n) return null;
|
|
@@ -2749,7 +2784,7 @@ function Ea(e) {
|
|
|
2749
2784
|
...r,
|
|
2750
2785
|
forChild: (e, t) => {
|
|
2751
2786
|
let n = (r?.forChild ?? ((e) => e))(e, t);
|
|
2752
|
-
if (
|
|
2787
|
+
if (Ae(n)) {
|
|
2753
2788
|
let e = [
|
|
2754
2789
|
i ? `background-color: ${i}` : null,
|
|
2755
2790
|
a ? `color: ${a}` : null,
|
|
@@ -2767,81 +2802,81 @@ function Ea(e) {
|
|
|
2767
2802
|
}
|
|
2768
2803
|
//#endregion
|
|
2769
2804
|
//#region src/components/Editor/utils/stripInlineStyleProperty.ts
|
|
2770
|
-
function
|
|
2805
|
+
function Ia(e, t) {
|
|
2771
2806
|
return e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; ");
|
|
2772
2807
|
}
|
|
2773
2808
|
//#endregion
|
|
2774
2809
|
//#region src/components/Editor/plugins/LinkColorPlugin.tsx
|
|
2775
|
-
function
|
|
2776
|
-
if (!
|
|
2810
|
+
function La(e) {
|
|
2811
|
+
if (!H(e, ut)) return;
|
|
2777
2812
|
let t = e.getStyle();
|
|
2778
2813
|
if (!t) return;
|
|
2779
|
-
let n =
|
|
2814
|
+
let n = Ia(t, "color");
|
|
2780
2815
|
n !== t && e.setStyle(n);
|
|
2781
2816
|
}
|
|
2782
|
-
function
|
|
2783
|
-
let [e] =
|
|
2784
|
-
return O(() => e.registerNodeTransform(
|
|
2817
|
+
function Ra() {
|
|
2818
|
+
let [e] = z();
|
|
2819
|
+
return O(() => e.registerNodeTransform(Na, La), [e]), null;
|
|
2785
2820
|
}
|
|
2786
2821
|
//#endregion
|
|
2787
2822
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
2788
|
-
function
|
|
2789
|
-
let [e] =
|
|
2790
|
-
return O(() => e.registerCommand(
|
|
2823
|
+
function za() {
|
|
2824
|
+
let [e] = z();
|
|
2825
|
+
return O(() => e.registerCommand(Or, (e) => (Te([rn(e)]), !0), ze), [e]), null;
|
|
2791
2826
|
}
|
|
2792
2827
|
//#endregion
|
|
2793
2828
|
//#region src/components/Editor/utils/stripImagesFromHtml.ts
|
|
2794
|
-
function
|
|
2829
|
+
function Ba(e) {
|
|
2795
2830
|
let t = new DOMParser().parseFromString(e, "text/html");
|
|
2796
2831
|
return t.querySelectorAll("img, picture").forEach((e) => e.remove()), t.body.innerHTML;
|
|
2797
2832
|
}
|
|
2798
2833
|
//#endregion
|
|
2799
2834
|
//#region src/components/Editor/plugins/PasteStripImagePlugin.tsx
|
|
2800
|
-
var
|
|
2801
|
-
function
|
|
2802
|
-
let [e] =
|
|
2835
|
+
var Va = /<img\b|<picture\b/i;
|
|
2836
|
+
function Ha() {
|
|
2837
|
+
let [e] = z(), { isSourceModeRef: t } = Wr();
|
|
2803
2838
|
return O(() => {
|
|
2804
2839
|
let n = (n) => {
|
|
2805
2840
|
if (t.current) return !1;
|
|
2806
2841
|
let r = "clipboardData" in n ? n.clipboardData : "dataTransfer" in n ? n.dataTransfer : null;
|
|
2807
2842
|
if (!r || r.getData("application/x-lexical-editor") || r.getData("application/x-lexical-drag")) return !1;
|
|
2808
2843
|
let i = r.getData("text/html");
|
|
2809
|
-
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) ||
|
|
2844
|
+
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) || Va.test(i))) return !1;
|
|
2810
2845
|
n.preventDefault();
|
|
2811
2846
|
let a = r.getData("text/plain");
|
|
2812
|
-
return !
|
|
2813
|
-
let t =
|
|
2847
|
+
return !Va.test(i) && !a || e.update(() => {
|
|
2848
|
+
let t = L();
|
|
2814
2849
|
if (t === null) return;
|
|
2815
|
-
let n = i ?
|
|
2850
|
+
let n = i ? Ba(i) : "", r = document.createElement("div");
|
|
2816
2851
|
if (r.innerHTML = n, n && r.textContent?.trim()) {
|
|
2817
|
-
let t =
|
|
2852
|
+
let t = ge(e, new DOMParser().parseFromString(n, "text/html"));
|
|
2818
2853
|
if (t.length) {
|
|
2819
|
-
|
|
2854
|
+
Te(t);
|
|
2820
2855
|
return;
|
|
2821
2856
|
}
|
|
2822
2857
|
}
|
|
2823
2858
|
a && t.insertRawText(a);
|
|
2824
|
-
}, { tag:
|
|
2859
|
+
}, { tag: $e }), !0;
|
|
2825
2860
|
};
|
|
2826
|
-
return Xt(e.registerCommand(
|
|
2861
|
+
return Xt(e.registerCommand(Qe, (e) => n(e), Be), e.registerCommand(He, (e) => n(e), Be));
|
|
2827
2862
|
}, [e, t]), null;
|
|
2828
2863
|
}
|
|
2829
2864
|
//#endregion
|
|
2830
2865
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
2831
|
-
function
|
|
2832
|
-
let [e] =
|
|
2833
|
-
return O(() => e.registerCommand(
|
|
2866
|
+
function Ua() {
|
|
2867
|
+
let [e] = z(), t = j(0);
|
|
2868
|
+
return O(() => e.registerCommand(Ye, (n) => {
|
|
2834
2869
|
let r = Date.now(), i = r - t.current;
|
|
2835
2870
|
return t.current = r, i < 250 && i > 0 ? e.getEditorState().read(() => {
|
|
2836
|
-
let e =
|
|
2837
|
-
return
|
|
2871
|
+
let e = L();
|
|
2872
|
+
return R(e) ? !!H(e.anchor.getNode(), (e) => B(e) || V(e) || Nt(e)) : !1;
|
|
2838
2873
|
}, { editor: e }) ? !1 : (e.update(() => {
|
|
2839
|
-
let e =
|
|
2840
|
-
if (
|
|
2874
|
+
let e = L();
|
|
2875
|
+
if (R(e)) {
|
|
2841
2876
|
let t = e.anchor.getNode().getTopLevelElement();
|
|
2842
2877
|
if (t && t.getTextContent().trim() === "") {
|
|
2843
|
-
let n =
|
|
2844
|
-
|
|
2878
|
+
let n = ye();
|
|
2879
|
+
kt(e, {
|
|
2845
2880
|
"background-color": "",
|
|
2846
2881
|
color: "",
|
|
2847
2882
|
"font-size": "",
|
|
@@ -2854,11 +2889,11 @@ function Pa() {
|
|
|
2854
2889
|
}
|
|
2855
2890
|
}
|
|
2856
2891
|
}), n?.preventDefault(), !0) : !1;
|
|
2857
|
-
},
|
|
2892
|
+
}, Ve), [e]), null;
|
|
2858
2893
|
}
|
|
2859
2894
|
//#endregion
|
|
2860
2895
|
//#region src/components/Editor/utils/codeHighlighter.ts
|
|
2861
|
-
var
|
|
2896
|
+
var Wa = {
|
|
2862
2897
|
css: () => import("@shikijs/langs/css"),
|
|
2863
2898
|
html: () => import("@shikijs/langs/html"),
|
|
2864
2899
|
xml: () => import("@shikijs/langs/xml"),
|
|
@@ -2879,70 +2914,70 @@ var Fa = {
|
|
|
2879
2914
|
bash: () => import("@shikijs/langs/shellscript"),
|
|
2880
2915
|
lua: () => import("@shikijs/langs/lua"),
|
|
2881
2916
|
markdown: () => import("@shikijs/langs/markdown")
|
|
2882
|
-
},
|
|
2917
|
+
}, Ga = (e) => e === "bash" ? "shellscript" : e, Ka = (e) => e in Wa, qa = null, Ja = null, Ya = /* @__PURE__ */ new Map(), Xa = () => (qa ||= Promise.all([import("@shikijs/core"), import("@shikijs/engine-javascript")]).then(([{ createHighlighterCoreSync: e }, { createJavaScriptRegexEngine: t }]) => e({
|
|
2883
2918
|
engine: t(),
|
|
2884
2919
|
langs: [],
|
|
2885
2920
|
themes: []
|
|
2886
2921
|
})).catch((e) => {
|
|
2887
|
-
throw
|
|
2888
|
-
}),
|
|
2889
|
-
let t =
|
|
2890
|
-
return t || (t =
|
|
2891
|
-
let n =
|
|
2922
|
+
throw qa = null, e;
|
|
2923
|
+
}), qa), Za = (e, t) => Ka(t) && e.getLoadedLanguages().includes(Ga(t)), Qa = (e) => {
|
|
2924
|
+
let t = Ya.get(e);
|
|
2925
|
+
return t || (t = Xa().then(async (t) => {
|
|
2926
|
+
let n = Ga(e);
|
|
2892
2927
|
if (!t.getLoadedLanguages().includes(n)) {
|
|
2893
|
-
let n = await
|
|
2928
|
+
let n = await Wa[e]();
|
|
2894
2929
|
await t.loadLanguage(n.default);
|
|
2895
2930
|
}
|
|
2896
2931
|
return t;
|
|
2897
2932
|
}).catch((t) => {
|
|
2898
|
-
throw
|
|
2899
|
-
}),
|
|
2900
|
-
},
|
|
2933
|
+
throw Ya.delete(e), t;
|
|
2934
|
+
}), Ya.set(e, t)), t;
|
|
2935
|
+
}, $a = () => (Ja ||= Xa().then(async (e) => {
|
|
2901
2936
|
if (!e.getLoadedThemes().includes("github-light")) {
|
|
2902
2937
|
let t = await import("@shikijs/themes/github-light");
|
|
2903
2938
|
await e.loadTheme(t.default);
|
|
2904
2939
|
}
|
|
2905
2940
|
return e;
|
|
2906
2941
|
}).catch((e) => {
|
|
2907
|
-
throw
|
|
2908
|
-
}),
|
|
2942
|
+
throw Ja = null, e;
|
|
2943
|
+
}), Ja), eo = (e, t, n) => {
|
|
2909
2944
|
let r = e.getTextContent();
|
|
2910
|
-
if (e.getStyle() && e.setStyle(""), !n || !
|
|
2911
|
-
let i =
|
|
2945
|
+
if (e.getStyle() && e.setStyle(""), !n || !Za(n, t)) return wt(r);
|
|
2946
|
+
let i = Ga(t), a = n.codeToTokens(r, {
|
|
2912
2947
|
lang: i,
|
|
2913
|
-
theme:
|
|
2948
|
+
theme: Cn
|
|
2914
2949
|
}), o = [];
|
|
2915
2950
|
return a.tokens.forEach((e, t) => {
|
|
2916
|
-
t && o.push(
|
|
2951
|
+
t && o.push(ve()), e.forEach((e) => {
|
|
2917
2952
|
e.content.split(" ").forEach((t, n) => {
|
|
2918
|
-
if (n && o.push(
|
|
2919
|
-
let r =
|
|
2953
|
+
if (n && o.push(be()), t === "") return;
|
|
2954
|
+
let r = xt(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}` : "";
|
|
2920
2955
|
i && r.setStyle(i), o.push(r);
|
|
2921
2956
|
});
|
|
2922
2957
|
});
|
|
2923
2958
|
}), o;
|
|
2924
|
-
},
|
|
2925
|
-
let n =
|
|
2926
|
-
if (!
|
|
2927
|
-
let r =
|
|
2928
|
-
if (!
|
|
2959
|
+
}, to = (e, t) => {
|
|
2960
|
+
let n = Ce(e);
|
|
2961
|
+
if (!V(n) || !n.isAttached()) return;
|
|
2962
|
+
let r = L();
|
|
2963
|
+
if (!R(r)) {
|
|
2929
2964
|
t();
|
|
2930
2965
|
return;
|
|
2931
2966
|
}
|
|
2932
2967
|
let { anchor: i } = r;
|
|
2933
|
-
if (
|
|
2968
|
+
if (H(i.getNode(), V) !== n) {
|
|
2934
2969
|
t();
|
|
2935
2970
|
return;
|
|
2936
2971
|
}
|
|
2937
|
-
let a = i.offset, o = i.type === "element" &&
|
|
2972
|
+
let a = i.offset, o = i.type === "element" && De(n.getChildAtIndex(i.offset - 1)), s = 0;
|
|
2938
2973
|
if (o || (s = a + i.getNode().getPreviousSiblings().reduce((e, t) => e + t.getTextContentSize(), 0)), t()) {
|
|
2939
2974
|
if (o) {
|
|
2940
2975
|
i.getNode().select(a, a);
|
|
2941
2976
|
return;
|
|
2942
2977
|
}
|
|
2943
2978
|
n.getChildren().some((e) => {
|
|
2944
|
-
let t =
|
|
2945
|
-
if (t ||
|
|
2979
|
+
let t = Ae(e);
|
|
2980
|
+
if (t || De(e)) {
|
|
2946
2981
|
let n = e.getTextContentSize();
|
|
2947
2982
|
if (t && n >= s) return e.select(s, s), !0;
|
|
2948
2983
|
s -= n;
|
|
@@ -2950,11 +2985,11 @@ var Fa = {
|
|
|
2950
2985
|
return !1;
|
|
2951
2986
|
});
|
|
2952
2987
|
}
|
|
2953
|
-
},
|
|
2988
|
+
}, no = (e, t) => Ct(e) && Ct(t) && e.__text === t.__text && e.__highlightType === t.__highlightType && e.__style === t.__style || ke(e) && ke(t) || De(e) && De(t), ro = (e, t) => {
|
|
2954
2989
|
let n = 0;
|
|
2955
|
-
for (; n < e.length &&
|
|
2990
|
+
for (; n < e.length && no(e[n], t[n]);) n++;
|
|
2956
2991
|
let r = e.length, i = t.length, a = Math.min(r, i) - n, o = 0;
|
|
2957
|
-
for (; o < a;) if (o++, !
|
|
2992
|
+
for (; o < a;) if (o++, !no(e[r - o], t[i - o])) {
|
|
2958
2993
|
o--;
|
|
2959
2994
|
break;
|
|
2960
2995
|
}
|
|
@@ -2963,21 +2998,21 @@ var Fa = {
|
|
|
2963
2998
|
to: r - o,
|
|
2964
2999
|
nodesForReplacement: t.slice(n, i - o)
|
|
2965
3000
|
};
|
|
2966
|
-
},
|
|
2967
|
-
let a = i.getKey(), o =
|
|
3001
|
+
}, io = (e, t, n, r, i) => {
|
|
3002
|
+
let a = i.getKey(), o = En(i.getLanguage());
|
|
2968
3003
|
if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
|
|
2969
3004
|
else {
|
|
2970
|
-
i.getTheme() !== "github-light" && i.setTheme(
|
|
2971
|
-
let s = t ? t.getLoadedThemes().includes("github-light") ?
|
|
3005
|
+
i.getTheme() !== "github-light" && i.setTheme(Cn);
|
|
3006
|
+
let s = t ? t.getLoadedThemes().includes("github-light") ? Ka(o) && !Za(t, o) ? Qa(o) : null : $a() : Xa();
|
|
2972
3007
|
if (s) {
|
|
2973
3008
|
i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1), n.pendingKeys.add(a), n.loading !== s && (n.loading = s, s.then((t) => {
|
|
2974
3009
|
r(t);
|
|
2975
3010
|
let i = [...n.pendingKeys];
|
|
2976
3011
|
n.pendingKeys.clear(), n.loading = null, e.update(() => {
|
|
2977
3012
|
i.forEach((e) => {
|
|
2978
|
-
|
|
3013
|
+
Ce(e)?.markDirty();
|
|
2979
3014
|
});
|
|
2980
|
-
}, { tag:
|
|
3015
|
+
}, { tag: qe });
|
|
2981
3016
|
}, () => {
|
|
2982
3017
|
n.pendingKeys.clear(), n.loading = null;
|
|
2983
3018
|
}));
|
|
@@ -2985,22 +3020,22 @@ var Fa = {
|
|
|
2985
3020
|
}
|
|
2986
3021
|
i.getIsSyntaxHighlightSupported() || i.setIsSyntaxHighlightSupported(!0);
|
|
2987
3022
|
}
|
|
2988
|
-
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0,
|
|
3023
|
+
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, Me(() => {
|
|
2989
3024
|
n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
|
|
2990
|
-
})),
|
|
2991
|
-
let e =
|
|
2992
|
-
if (!
|
|
2993
|
-
let n =
|
|
3025
|
+
})), to(a, () => {
|
|
3026
|
+
let e = Ce(a);
|
|
3027
|
+
if (!V(e) || !e.isAttached()) return !1;
|
|
3028
|
+
let n = eo(e, En(e.getLanguage()), t), { from: r, to: i, nodesForReplacement: o } = ro(e.getChildren(), n);
|
|
2994
3029
|
return r !== i || o.length ? (e.splice(r, i - r, o), !0) : !1;
|
|
2995
3030
|
}));
|
|
2996
|
-
},
|
|
3031
|
+
}, ao = (e, t, n, r, i) => {
|
|
2997
3032
|
let a = i.getParent();
|
|
2998
|
-
|
|
3033
|
+
V(a) ? io(e, t, n, r, a) : Ct(i) && i.replace(xe(i.__text));
|
|
2999
3034
|
};
|
|
3000
|
-
function
|
|
3001
|
-
let [e] =
|
|
3035
|
+
function oo() {
|
|
3036
|
+
let [e] = z();
|
|
3002
3037
|
return O(() => {
|
|
3003
|
-
if (!e.hasNodes([
|
|
3038
|
+
if (!e.hasNodes([Et, Tt])) throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");
|
|
3004
3039
|
let t = null, n = {
|
|
3005
3040
|
didTransform: !1,
|
|
3006
3041
|
nodesCurrentlyHighlighting: /* @__PURE__ */ new Set(),
|
|
@@ -3009,16 +3044,16 @@ function Za() {
|
|
|
3009
3044
|
}, r = (e) => {
|
|
3010
3045
|
t = e;
|
|
3011
3046
|
}, i = (e) => {
|
|
3012
|
-
let t =
|
|
3013
|
-
if (!
|
|
3047
|
+
let t = Ce(e);
|
|
3048
|
+
if (!V(t)) return;
|
|
3014
3049
|
let n = t.getChildrenSize();
|
|
3015
3050
|
n === 0 ? t.selectStart() : t.select(0, n);
|
|
3016
3051
|
}, a = (t) => {
|
|
3017
3052
|
if (!(t instanceof Node) || !e.getRootElement()?.contains(t)) return null;
|
|
3018
3053
|
let n = null;
|
|
3019
3054
|
return e.getEditorState().read(() => {
|
|
3020
|
-
let e =
|
|
3021
|
-
|
|
3055
|
+
let e = Se(t), r = e ? H(e, V) : null;
|
|
3056
|
+
V(r) && (n = r.getKey());
|
|
3022
3057
|
}, { editor: e }), n;
|
|
3023
3058
|
}, o = null, s = (t, n, r) => {
|
|
3024
3059
|
t.preventDefault(), r && (o = n), e.update(() => {
|
|
@@ -3040,12 +3075,12 @@ function Za() {
|
|
|
3040
3075
|
}, d = (e, t) => {
|
|
3041
3076
|
t?.removeEventListener("mousedown", c, !0), t?.removeEventListener("mouseup", u, !0), t?.removeEventListener("dblclick", l, !0), e?.addEventListener("mousedown", c, !0), e?.addEventListener("mouseup", u, !0), e?.addEventListener("dblclick", l, !0);
|
|
3042
3077
|
};
|
|
3043
|
-
return st(
|
|
3044
|
-
|
|
3078
|
+
return st(Dt(e), e.registerNodeTransform(Et, (i) => {
|
|
3079
|
+
io(e, t, n, r, i);
|
|
3045
3080
|
}), e.registerNodeTransform(rt, (i) => {
|
|
3046
|
-
|
|
3047
|
-
}), e.registerNodeTransform(
|
|
3048
|
-
|
|
3081
|
+
ao(e, t, n, r, i);
|
|
3082
|
+
}), e.registerNodeTransform(Tt, (i) => {
|
|
3083
|
+
ao(e, t, n, r, i);
|
|
3049
3084
|
}), e.registerRootListener(d), () => {
|
|
3050
3085
|
d(null, e.getRootElement());
|
|
3051
3086
|
});
|
|
@@ -3053,23 +3088,23 @@ function Za() {
|
|
|
3053
3088
|
}
|
|
3054
3089
|
//#endregion
|
|
3055
3090
|
//#region src/components/Editor/plugins/TablePlugin.tsx
|
|
3056
|
-
function
|
|
3057
|
-
let [e] =
|
|
3058
|
-
return O(() => (
|
|
3091
|
+
function so() {
|
|
3092
|
+
let [e] = z();
|
|
3093
|
+
return O(() => (Wt(e, !0), Xt(Ht(e), Ut(e, !1), Vt(e), e.registerNodeTransform(Rt, (e) => {
|
|
3059
3094
|
e.getBackgroundColor() !== null && e.setBackgroundColor(null);
|
|
3060
|
-
}), e.registerCommand(
|
|
3061
|
-
let t =
|
|
3062
|
-
if (!
|
|
3063
|
-
let n =
|
|
3095
|
+
}), e.registerCommand(Xe, (e) => {
|
|
3096
|
+
let t = L();
|
|
3097
|
+
if (!R(t) || !t.isCollapsed()) return !1;
|
|
3098
|
+
let n = Mt(t.anchor.getNode());
|
|
3064
3099
|
if (n === null) return !1;
|
|
3065
3100
|
let r = e.shiftKey ? "previous" : "next", i = r === "next" ? "getNextSibling" : "getPreviousSibling", a = r === "next" ? "getFirstChild" : "getLastChild", o = n[i](), s = null;
|
|
3066
|
-
if (
|
|
3101
|
+
if (Nt(o)) s = o;
|
|
3067
3102
|
else {
|
|
3068
|
-
let e =
|
|
3103
|
+
let e = H(n, Ft);
|
|
3069
3104
|
if (e !== null) for (let t = e[i](); t !== null; t = t[i]()) {
|
|
3070
|
-
if (!
|
|
3105
|
+
if (!Ft(t)) continue;
|
|
3071
3106
|
let e = t[a]();
|
|
3072
|
-
if (
|
|
3107
|
+
if (Nt(e)) {
|
|
3073
3108
|
s = e;
|
|
3074
3109
|
break;
|
|
3075
3110
|
}
|
|
@@ -3079,60 +3114,76 @@ function Qa() {
|
|
|
3079
3114
|
let e = s.getFirstDescendant();
|
|
3080
3115
|
e ? e.selectStart() : s.selectStart();
|
|
3081
3116
|
} else {
|
|
3082
|
-
let e =
|
|
3117
|
+
let e = H(n, Pt);
|
|
3083
3118
|
e && (r === "next" ? e.selectNext() : e.selectPrevious());
|
|
3084
3119
|
}
|
|
3085
3120
|
return !0;
|
|
3086
|
-
},
|
|
3121
|
+
}, Be))), [e]), null;
|
|
3087
3122
|
}
|
|
3088
3123
|
//#endregion
|
|
3089
|
-
//#region src/components/Editor/
|
|
3090
|
-
var
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3124
|
+
//#region src/components/Editor/utils/clampElementIndent.ts
|
|
3125
|
+
var co = (e) => {
|
|
3126
|
+
let t = e.getIndent();
|
|
3127
|
+
t < 8 && e.setIndent(t + 1);
|
|
3128
|
+
}, lo = (e) => {
|
|
3129
|
+
let t = e.getIndent();
|
|
3130
|
+
if (t > 8) {
|
|
3131
|
+
e.setIndent(8);
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
t < 0 && e.setIndent(0);
|
|
3135
|
+
}, uo = "\xA0".repeat(4);
|
|
3136
|
+
function fo() {
|
|
3137
|
+
let [e] = z();
|
|
3138
|
+
return O(() => e.registerCommand(Xe, (t) => {
|
|
3094
3139
|
if (t.shiftKey) return !1;
|
|
3095
|
-
let n =
|
|
3096
|
-
if (!
|
|
3140
|
+
let n = L();
|
|
3141
|
+
if (!R(n)) return !1;
|
|
3097
3142
|
let r = n.anchor.getNode();
|
|
3098
|
-
if (
|
|
3143
|
+
if (Mt(r) !== null || H(r, V)) return !1;
|
|
3099
3144
|
t.preventDefault();
|
|
3100
|
-
let i =
|
|
3101
|
-
if (
|
|
3145
|
+
let i = H(r, B);
|
|
3146
|
+
if (B(i)) {
|
|
3102
3147
|
let e = new Set([i]);
|
|
3103
3148
|
for (let t of n.getNodes()) {
|
|
3104
|
-
let n =
|
|
3105
|
-
|
|
3149
|
+
let n = H(t, B);
|
|
3150
|
+
B(n) && e.add(n);
|
|
3106
3151
|
}
|
|
3107
|
-
for (let t of e)
|
|
3152
|
+
for (let t of e) co(t);
|
|
3108
3153
|
return !0;
|
|
3109
3154
|
}
|
|
3110
3155
|
let a = r.getTopLevelElement(), o = n.focus.getNode().getTopLevelElement();
|
|
3111
|
-
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(
|
|
3112
|
-
},
|
|
3156
|
+
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(Je, void 0) : (n.insertText(uo), !0);
|
|
3157
|
+
}, ze), [e]), null;
|
|
3158
|
+
}
|
|
3159
|
+
//#endregion
|
|
3160
|
+
//#region src/components/Editor/plugins/IndentLimitPlugin.tsx
|
|
3161
|
+
function po() {
|
|
3162
|
+
let [e] = z();
|
|
3163
|
+
return O(() => Xt(e.registerCommand(Je, () => Jt(co), Be), e.registerNodeTransform(et, lo), e.registerNodeTransform(qt, lo), e.registerNodeTransform(vt, lo)), [e]), null;
|
|
3113
3164
|
}
|
|
3114
3165
|
//#endregion
|
|
3115
3166
|
//#region src/components/Editor/plugins/MaxLengthPlugin.tsx
|
|
3116
|
-
function
|
|
3117
|
-
let [n] =
|
|
3167
|
+
function mo({ maxLength: e, onMaxLengthExceed: t }) {
|
|
3168
|
+
let [n] = z(), { isSourceModeRef: r } = Wr(), i = j(t);
|
|
3118
3169
|
return i.current = t, O(() => {
|
|
3119
3170
|
let t = null;
|
|
3120
3171
|
return n.registerNodeTransform(nt, (a) => {
|
|
3121
3172
|
if (r.current) return;
|
|
3122
3173
|
let o = a.getTextContentSize();
|
|
3123
3174
|
if (o <= e) return;
|
|
3124
|
-
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u =
|
|
3175
|
+
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u = L();
|
|
3125
3176
|
if (c === e && t !== s) {
|
|
3126
3177
|
t = s, Yt(n, s), i.current?.();
|
|
3127
3178
|
return;
|
|
3128
3179
|
}
|
|
3129
|
-
if (
|
|
3130
|
-
|
|
3180
|
+
if (R(u) && u.isCollapsed()) {
|
|
3181
|
+
jt(n, u.anchor, l), i.current?.();
|
|
3131
3182
|
return;
|
|
3132
3183
|
}
|
|
3133
3184
|
a.selectEnd();
|
|
3134
|
-
let d =
|
|
3135
|
-
|
|
3185
|
+
let d = L();
|
|
3186
|
+
R(d) && (jt(n, d.anchor, l), i.current?.());
|
|
3136
3187
|
});
|
|
3137
3188
|
}, [
|
|
3138
3189
|
n,
|
|
@@ -3142,19 +3193,19 @@ function to({ maxLength: e, onMaxLengthExceed: t }) {
|
|
|
3142
3193
|
}
|
|
3143
3194
|
//#endregion
|
|
3144
3195
|
//#region src/components/Editor/utils/textLength.ts
|
|
3145
|
-
function
|
|
3196
|
+
function ho(e) {
|
|
3146
3197
|
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
3147
3198
|
}
|
|
3148
|
-
function
|
|
3149
|
-
let n =
|
|
3199
|
+
function go(e, t) {
|
|
3200
|
+
let n = I(), r = n.getTextContentSize();
|
|
3150
3201
|
if (r <= t) return !1;
|
|
3151
3202
|
let i = r - t;
|
|
3152
3203
|
n.selectEnd();
|
|
3153
|
-
let a =
|
|
3154
|
-
return
|
|
3204
|
+
let a = L();
|
|
3205
|
+
return R(a) ? jt(e, a.anchor, i) : _o(i), !0;
|
|
3155
3206
|
}
|
|
3156
|
-
function
|
|
3157
|
-
let t = e, n =
|
|
3207
|
+
function _o(e) {
|
|
3208
|
+
let t = e, n = I().getAllTextNodes();
|
|
3158
3209
|
for (let e = n.length - 1; e >= 0 && t > 0; e--) {
|
|
3159
3210
|
let r = n[e], i = r.getTextContent();
|
|
3160
3211
|
i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
|
|
@@ -3162,7 +3213,7 @@ function io(e) {
|
|
|
3162
3213
|
}
|
|
3163
3214
|
//#endregion
|
|
3164
3215
|
//#region src/components/Editor/utils/formatEditorHtml.ts
|
|
3165
|
-
var
|
|
3216
|
+
var vo = new Set([
|
|
3166
3217
|
"area",
|
|
3167
3218
|
"base",
|
|
3168
3219
|
"br",
|
|
@@ -3177,65 +3228,65 @@ var ao = new Set([
|
|
|
3177
3228
|
"source",
|
|
3178
3229
|
"track",
|
|
3179
3230
|
"wbr"
|
|
3180
|
-
]),
|
|
3181
|
-
let r = e.tagName.toLowerCase(), i = `<${r}${
|
|
3182
|
-
if (
|
|
3183
|
-
let a = n || r === "pre", o =
|
|
3184
|
-
return a || !
|
|
3185
|
-
},
|
|
3231
|
+
]), yo = new Set(/* @__PURE__ */ "address.article.aside.blockquote.div.dl.dt.dd.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.table.tbody.td.tfoot.th.thead.tr.ul".split(".")), bo = 80, xo = (e) => e.replace(/&/g, "&").replace(/"/g, """), So = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), Co = (e) => Array.from(e.attributes).map((e) => ` ${e.name}="${xo(e.value)}"`).join(""), wo = (e) => " ".repeat(e), To = (e, t, n) => {
|
|
3232
|
+
let r = e.tagName.toLowerCase(), i = `<${r}${Co(e)}>`;
|
|
3233
|
+
if (vo.has(r)) return i;
|
|
3234
|
+
let a = n || r === "pre", o = Eo(e, t + 1, a), s = `</${r}>`;
|
|
3235
|
+
return a || !yo.has(r) ? `${i}${o}${s}` : Array.from(e.children).some((e) => yo.has(e.tagName.toLowerCase())) ? `${i}\n${Eo(e, t + 1, !1, !0)}\n${wo(t)}${s}` : i.length + o.length + s.length > bo ? `${i}\n${wo(t + 1)}${o}\n${wo(t)}${s}` : `${i}${o}${s}`;
|
|
3236
|
+
}, Eo = (e, t, n, r = !1) => {
|
|
3186
3237
|
let i = [];
|
|
3187
3238
|
for (let r of Array.from(e.childNodes)) {
|
|
3188
3239
|
if (r.nodeType === Node.TEXT_NODE) {
|
|
3189
3240
|
let e = r.textContent ?? "";
|
|
3190
3241
|
if (n) {
|
|
3191
|
-
i.push(
|
|
3242
|
+
i.push(So(e));
|
|
3192
3243
|
continue;
|
|
3193
3244
|
}
|
|
3194
|
-
e.trim() && i.push(
|
|
3245
|
+
e.trim() && i.push(So(e));
|
|
3195
3246
|
continue;
|
|
3196
3247
|
}
|
|
3197
3248
|
if (r.nodeType === Node.COMMENT_NODE) {
|
|
3198
3249
|
i.push(`<!--${r.data}-->`);
|
|
3199
3250
|
continue;
|
|
3200
3251
|
}
|
|
3201
|
-
r.nodeType === Node.ELEMENT_NODE && i.push(
|
|
3252
|
+
r.nodeType === Node.ELEMENT_NODE && i.push(To(r, t, n));
|
|
3202
3253
|
}
|
|
3203
|
-
return n || !r ? i.join("") : i.map((e) => `${
|
|
3254
|
+
return n || !r ? i.join("") : i.map((e) => `${wo(t)}${e}`).join("\n");
|
|
3204
3255
|
};
|
|
3205
|
-
function
|
|
3206
|
-
return e.trim() ?
|
|
3256
|
+
function Do(e) {
|
|
3257
|
+
return e.trim() ? Eo(new DOMParser().parseFromString(Qi(e), "text/html").body, 0, !1, !0).trimEnd() : e;
|
|
3207
3258
|
}
|
|
3208
3259
|
//#endregion
|
|
3209
3260
|
//#region src/components/Editor/utils/writeHtmlSource.ts
|
|
3210
|
-
function
|
|
3211
|
-
|
|
3212
|
-
let t =
|
|
3213
|
-
if (
|
|
3261
|
+
function Oo(e) {
|
|
3262
|
+
I().clear();
|
|
3263
|
+
let t = St("html");
|
|
3264
|
+
if (I().append(t), !e) return;
|
|
3214
3265
|
t.select();
|
|
3215
|
-
let n =
|
|
3216
|
-
|
|
3266
|
+
let n = L();
|
|
3267
|
+
R(n) && n.insertRawText(e);
|
|
3217
3268
|
}
|
|
3218
3269
|
//#endregion
|
|
3219
3270
|
//#region src/components/Editor/plugins/SourceModePlugin.tsx
|
|
3220
|
-
function
|
|
3221
|
-
let [r] =
|
|
3271
|
+
function ko({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
3272
|
+
let [r] = z(), [i, a] = M(!1), o = j(!1), s = j(n);
|
|
3222
3273
|
s.current = n;
|
|
3223
|
-
let c =
|
|
3274
|
+
let c = ho(t) ? t : void 0, l = T(() => {
|
|
3224
3275
|
if (o.current) return;
|
|
3225
3276
|
let e = "", t = "";
|
|
3226
3277
|
r.getEditorState().read(() => {
|
|
3227
|
-
t =
|
|
3278
|
+
t = I().getTextContent(), e = he(r, null);
|
|
3228
3279
|
}, { editor: r });
|
|
3229
|
-
let n =
|
|
3280
|
+
let n = wi(e, t) ? "" : X(e);
|
|
3230
3281
|
o.current = !0, a(!0), r.update(() => {
|
|
3231
|
-
|
|
3232
|
-
}), r.dispatchCommand(
|
|
3282
|
+
Oo(Do(n));
|
|
3283
|
+
}), r.dispatchCommand(Le, void 0);
|
|
3233
3284
|
}, [r]), u = T(() => {
|
|
3234
3285
|
if (!o.current) return;
|
|
3235
3286
|
let e = !1;
|
|
3236
3287
|
o.current = !1, r.update(() => {
|
|
3237
|
-
|
|
3238
|
-
}), a(!1), r.dispatchCommand(
|
|
3288
|
+
Ci(r, X(I().getTextContent())), c !== void 0 && (e = go(r, c)), On(!0);
|
|
3289
|
+
}), a(!1), r.dispatchCommand(Le, void 0), e && s.current?.();
|
|
3239
3290
|
}, [r, c]), d = T(() => {
|
|
3240
3291
|
if (o.current) {
|
|
3241
3292
|
u();
|
|
@@ -3253,51 +3304,51 @@ function _o({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
|
3253
3304
|
if (!n) return !0;
|
|
3254
3305
|
let i = X(n);
|
|
3255
3306
|
return r.update(() => {
|
|
3256
|
-
let e =
|
|
3257
|
-
|
|
3258
|
-
}, { tag:
|
|
3307
|
+
let e = L();
|
|
3308
|
+
R(e) && i && e.insertRawText(i);
|
|
3309
|
+
}, { tag: $e }), !0;
|
|
3259
3310
|
};
|
|
3260
3311
|
return Xt(r.registerNodeTransform(nt, () => {
|
|
3261
3312
|
if (!o.current) return;
|
|
3262
|
-
let e =
|
|
3263
|
-
|
|
3264
|
-
}), r.registerCommand(
|
|
3313
|
+
let e = I(), t = e.getChildrenSize() === 1 ? e.getFirstChild() : null;
|
|
3314
|
+
V(t) && t.getLanguage() === "html" || Oo(e.getTextContent());
|
|
3315
|
+
}), r.registerCommand(Qe, e, Re), r.registerCommand(He, e, Re));
|
|
3265
3316
|
}, [r]);
|
|
3266
3317
|
let f = A(() => ({
|
|
3267
3318
|
isSourceMode: i,
|
|
3268
3319
|
isSourceModeRef: o,
|
|
3269
3320
|
toggleSourceMode: d
|
|
3270
3321
|
}), [i, d]);
|
|
3271
|
-
return /* @__PURE__ */ y(
|
|
3322
|
+
return /* @__PURE__ */ y(Ur.Provider, {
|
|
3272
3323
|
value: f,
|
|
3273
3324
|
children: e
|
|
3274
3325
|
});
|
|
3275
3326
|
}
|
|
3276
3327
|
//#endregion
|
|
3277
3328
|
//#region src/components/Editor/plugins/HeadingPlugin.tsx
|
|
3278
|
-
function
|
|
3329
|
+
function Ao(e) {
|
|
3279
3330
|
let t = e.getTag();
|
|
3280
3331
|
if (t === "h4" || t === "h5" || t === "h6") {
|
|
3281
|
-
e.replace(
|
|
3332
|
+
e.replace(ye(), !0);
|
|
3282
3333
|
return;
|
|
3283
3334
|
}
|
|
3284
3335
|
for (let t of e.getAllTextNodes()) {
|
|
3285
3336
|
let e = t.getStyle();
|
|
3286
3337
|
if (!e) continue;
|
|
3287
|
-
let n =
|
|
3338
|
+
let n = Ia(e, "font-size");
|
|
3288
3339
|
n !== e && t.setStyle(n);
|
|
3289
3340
|
}
|
|
3290
3341
|
}
|
|
3291
|
-
function
|
|
3292
|
-
let [e] =
|
|
3293
|
-
return O(() => e.registerNodeTransform(
|
|
3342
|
+
function jo() {
|
|
3343
|
+
let [e] = z();
|
|
3344
|
+
return O(() => e.registerNodeTransform(qt, Ao), [e]), null;
|
|
3294
3345
|
}
|
|
3295
3346
|
//#endregion
|
|
3296
3347
|
//#region src/components/Editor/LengthBadge.tsx
|
|
3297
|
-
var
|
|
3348
|
+
var Mo = ({ current: e, maxLength: t }) => {
|
|
3298
3349
|
let n = e > t;
|
|
3299
3350
|
return /* @__PURE__ */ b("div", {
|
|
3300
|
-
className:
|
|
3351
|
+
className: F($["bsy-lexical-editor__length-badge"], n && $["bsy-lexical-editor__length-badge--exceeded"]),
|
|
3301
3352
|
"aria-live": "polite",
|
|
3302
3353
|
children: [
|
|
3303
3354
|
e,
|
|
@@ -3306,33 +3357,33 @@ var bo = ({ current: e, maxLength: t }) => {
|
|
|
3306
3357
|
]
|
|
3307
3358
|
});
|
|
3308
3359
|
};
|
|
3309
|
-
|
|
3360
|
+
Mo.displayName = "BsyLexicalEditorLengthBadge";
|
|
3310
3361
|
//#endregion
|
|
3311
3362
|
//#region src/components/Editor/utils/unwrapTypesetFence.ts
|
|
3312
|
-
var
|
|
3363
|
+
var No = /^\uFEFF/, Po = /^ {0,3}`{1,3}[A-Za-z]*$/, Fo = /^( {0,3})([^`<]*?)```[ \t]*([A-Za-z0-9_-]*)[ \t]*(.*)$/, Io = /^ {0,3}```[ \t]*$/, Lo = /<\/?[a-zA-Z]/, Ro = /<[a-zA-Z!]/, zo = (e) => Ro.test(e), Bo = (e) => Lo.test(e), Vo = (e) => e.replace(No, "").replace(/\r\n/g, "\n"), Ho = (e) => {
|
|
3313
3364
|
let t = e.replace(/\n+$/, ""), n = t.lastIndexOf("\n"), r = n === -1 ? t : t.slice(n + 1);
|
|
3314
|
-
return
|
|
3365
|
+
return Po.test(r) ? {
|
|
3315
3366
|
text: n === -1 ? "" : t.slice(0, n),
|
|
3316
3367
|
withheld: !0
|
|
3317
3368
|
} : {
|
|
3318
3369
|
text: e,
|
|
3319
3370
|
withheld: !1
|
|
3320
3371
|
};
|
|
3321
|
-
},
|
|
3322
|
-
let t =
|
|
3372
|
+
}, Uo = (e) => {
|
|
3373
|
+
let t = Fo.exec(e);
|
|
3323
3374
|
return t ? { sameLineBody: t[4] ?? "" } : null;
|
|
3324
|
-
},
|
|
3375
|
+
}, Wo = (e) => {
|
|
3325
3376
|
let t = e.replace(/[ \t]*```[ \t]*$/, "");
|
|
3326
3377
|
return t === e ? e : t;
|
|
3327
|
-
},
|
|
3378
|
+
}, Go = (e) => zo(e) ? e.replace(/^\n/, "") : "", Ko = (e) => {
|
|
3328
3379
|
let t = e.split("\n"), n = [], r = 0;
|
|
3329
3380
|
for (; r < t.length;) {
|
|
3330
|
-
let e = t[r], i =
|
|
3381
|
+
let e = t[r], i = Uo(e);
|
|
3331
3382
|
if (i) {
|
|
3332
3383
|
let e = i.sameLineBody;
|
|
3333
|
-
if (e !==
|
|
3334
|
-
e =
|
|
3335
|
-
let i =
|
|
3384
|
+
if (e !== Wo(e)) {
|
|
3385
|
+
e = Wo(e);
|
|
3386
|
+
let i = Go(t.slice(r + 1).join("\n"));
|
|
3336
3387
|
return [
|
|
3337
3388
|
...n,
|
|
3338
3389
|
e,
|
|
@@ -3340,38 +3391,38 @@ var xo = /^\uFEFF/, So = /^ {0,3}`{1,3}[A-Za-z]*$/, Co = /^( {0,3})([^`<]*?)```[
|
|
|
3340
3391
|
].filter(Boolean).join("\n");
|
|
3341
3392
|
}
|
|
3342
3393
|
let a = [];
|
|
3343
|
-
for (e && a.push(e), r += 1; r < t.length && !
|
|
3344
|
-
let o = r < t.length ?
|
|
3394
|
+
for (e && a.push(e), r += 1; r < t.length && !Io.test(t[r]);) a.push(t[r]), r += 1;
|
|
3395
|
+
let o = r < t.length ? Go(t.slice(r + 1).join("\n")) : "";
|
|
3345
3396
|
return [
|
|
3346
3397
|
...n,
|
|
3347
3398
|
a.join("\n"),
|
|
3348
3399
|
o
|
|
3349
3400
|
].filter(Boolean).join("\n");
|
|
3350
3401
|
}
|
|
3351
|
-
if (
|
|
3352
|
-
|
|
3402
|
+
if (Bo(e)) return qo([...n, ...t.slice(r)].join("\n"));
|
|
3403
|
+
zo(e) && n.push(e), r += 1;
|
|
3353
3404
|
}
|
|
3354
3405
|
return n.length ? n.join("\n") : null;
|
|
3355
|
-
},
|
|
3406
|
+
}, qo = (e) => {
|
|
3356
3407
|
let t = e.split("\n");
|
|
3357
3408
|
if (!t.length) return e;
|
|
3358
|
-
let n =
|
|
3359
|
-
return n && !
|
|
3409
|
+
let n = Uo(t[0]);
|
|
3410
|
+
return n && !Bo(t[0].slice(0, t[0].indexOf("```"))) && (t.shift(), n.sameLineBody && t.unshift(Wo(n.sameLineBody))), t.length && Io.test(t[t.length - 1] ?? "") && t.pop(), t.join("\n");
|
|
3360
3411
|
};
|
|
3361
|
-
function
|
|
3412
|
+
function Jo(e) {
|
|
3362
3413
|
if (!e) return {
|
|
3363
3414
|
html: "",
|
|
3364
3415
|
pending: !1
|
|
3365
3416
|
};
|
|
3366
|
-
let { text: t, withheld: n } =
|
|
3417
|
+
let { text: t, withheld: n } = Ho(Vo(e));
|
|
3367
3418
|
if (!t.trim()) return {
|
|
3368
3419
|
html: "",
|
|
3369
|
-
pending: n ||
|
|
3420
|
+
pending: n || Po.test(Vo(e).trim())
|
|
3370
3421
|
};
|
|
3371
|
-
let r =
|
|
3422
|
+
let r = Ko(t) ?? t, i = Ko(r);
|
|
3372
3423
|
i !== null && i !== r && (r = i);
|
|
3373
3424
|
let a = r.trim();
|
|
3374
|
-
return
|
|
3425
|
+
return zo(a) ? {
|
|
3375
3426
|
html: a,
|
|
3376
3427
|
pending: !1
|
|
3377
3428
|
} : {
|
|
@@ -3381,21 +3432,21 @@ function Io(e) {
|
|
|
3381
3432
|
}
|
|
3382
3433
|
//#endregion
|
|
3383
3434
|
//#region src/components/Editor/utils/prepareTypesetProposed.ts
|
|
3384
|
-
var
|
|
3385
|
-
let { html: n } =
|
|
3386
|
-
return n ?
|
|
3435
|
+
var Yo = (e, t) => {
|
|
3436
|
+
let { html: n } = Jo(e);
|
|
3437
|
+
return n ? di(ci(n, t)) : "";
|
|
3387
3438
|
};
|
|
3388
3439
|
//#endregion
|
|
3389
3440
|
//#region src/components/Editor/utils/applyAiTypeset.ts
|
|
3390
|
-
function
|
|
3391
|
-
let i = X(
|
|
3392
|
-
if (!i.trim() ||
|
|
3441
|
+
function Xo(e, t, n, r) {
|
|
3442
|
+
let i = X(Yo(t, n));
|
|
3443
|
+
if (!i.trim() || wi(i, "")) return {
|
|
3393
3444
|
applied: !1,
|
|
3394
3445
|
truncated: !1
|
|
3395
3446
|
};
|
|
3396
3447
|
let a = !1;
|
|
3397
3448
|
return e.update(() => {
|
|
3398
|
-
|
|
3449
|
+
Ci(e, i), ho(r) && (a = go(e, r)), On(!0);
|
|
3399
3450
|
}, { discrete: !0 }), {
|
|
3400
3451
|
applied: !0,
|
|
3401
3452
|
truncated: a
|
|
@@ -3403,15 +3454,15 @@ function Ro(e, t, n, r) {
|
|
|
3403
3454
|
}
|
|
3404
3455
|
//#endregion
|
|
3405
3456
|
//#region src/components/Editor/Preview/useAiPreviewHtml.ts
|
|
3406
|
-
var
|
|
3407
|
-
if (!e ||
|
|
3457
|
+
var Zo = (e, t) => {
|
|
3458
|
+
if (!e || yi(e)) return e;
|
|
3408
3459
|
let n = X(e);
|
|
3409
|
-
return t === "ready" || t === "error" ?
|
|
3410
|
-
},
|
|
3460
|
+
return t === "ready" || t === "error" ? Qi(n) : n;
|
|
3461
|
+
}, Qo = ({ enabled: e, status: t, revision: n, compute: r }) => {
|
|
3411
3462
|
let [i, a] = M(""), o = j(r);
|
|
3412
3463
|
o.current = r;
|
|
3413
3464
|
let s = j(null);
|
|
3414
|
-
return
|
|
3465
|
+
return k(() => {
|
|
3415
3466
|
let n = () => {
|
|
3416
3467
|
s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
|
|
3417
3468
|
};
|
|
@@ -3434,12 +3485,12 @@ var zo = (e, t) => {
|
|
|
3434
3485
|
]), O(() => () => {
|
|
3435
3486
|
s.current !== null && cancelAnimationFrame(s.current);
|
|
3436
3487
|
}, []), i;
|
|
3437
|
-
},
|
|
3488
|
+
}, $o = [
|
|
3438
3489
|
.26,
|
|
3439
3490
|
.02,
|
|
3440
3491
|
.23,
|
|
3441
3492
|
.94
|
|
3442
|
-
],
|
|
3493
|
+
], es = () => {
|
|
3443
3494
|
let e = `${ee().replace(/:/g, "")}g`;
|
|
3444
3495
|
return /* @__PURE__ */ y("span", {
|
|
3445
3496
|
className: Q["bsy-lexical-ai__think-icon"],
|
|
@@ -3478,7 +3529,7 @@ var zo = (e, t) => {
|
|
|
3478
3529
|
}) })]
|
|
3479
3530
|
})
|
|
3480
3531
|
});
|
|
3481
|
-
},
|
|
3532
|
+
}, ts = (e, t) => {
|
|
3482
3533
|
let { t: n } = a(), r = e.status === "loading" && !t, [i, o] = M(!0), [s, c] = M(0), l = j(Date.now()), u = j(null), d = e.reasoning ?? "", f = r || i, p = (r || !!d) && !(e.status === "error" && !d);
|
|
3483
3534
|
return O(() => {
|
|
3484
3535
|
if (!r) {
|
|
@@ -3498,21 +3549,21 @@ var zo = (e, t) => {
|
|
|
3498
3549
|
reasoning: d,
|
|
3499
3550
|
toggle: () => o((e) => !e)
|
|
3500
3551
|
};
|
|
3501
|
-
},
|
|
3552
|
+
}, ns = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
3502
3553
|
type: "button",
|
|
3503
3554
|
className: Q["bsy-lexical-ai__think-head"],
|
|
3504
3555
|
disabled: t.thinking,
|
|
3505
3556
|
onClick: t.toggle,
|
|
3506
|
-
children: [t.thinking ? /* @__PURE__ */ y(
|
|
3557
|
+
children: [t.thinking ? /* @__PURE__ */ y(es, {}) : /* @__PURE__ */ y(e, {
|
|
3507
3558
|
name: "arrow-down",
|
|
3508
3559
|
size: 12,
|
|
3509
|
-
className:
|
|
3560
|
+
className: F(Q["bsy-lexical-ai__think-arrow"], t.open && Q["bsy-lexical-ai__think-arrow--open"])
|
|
3510
3561
|
}), /* @__PURE__ */ y("span", {
|
|
3511
3562
|
className: Q["bsy-lexical-ai__think-label"],
|
|
3512
|
-
children: /* @__PURE__ */ y(
|
|
3563
|
+
children: /* @__PURE__ */ y(ae, {
|
|
3513
3564
|
mode: "popLayout",
|
|
3514
3565
|
initial: !1,
|
|
3515
|
-
children: /* @__PURE__ */ y(
|
|
3566
|
+
children: /* @__PURE__ */ y(oe.span, {
|
|
3516
3567
|
initial: {
|
|
3517
3568
|
opacity: 0,
|
|
3518
3569
|
y: 6
|
|
@@ -3527,7 +3578,7 @@ var zo = (e, t) => {
|
|
|
3527
3578
|
},
|
|
3528
3579
|
transition: {
|
|
3529
3580
|
duration: .22,
|
|
3530
|
-
ease:
|
|
3581
|
+
ease: $o
|
|
3531
3582
|
},
|
|
3532
3583
|
children: /* @__PURE__ */ y("span", {
|
|
3533
3584
|
className: t.thinking ? Q["bsy-lexical-ai__think-label--shimmer"] : void 0,
|
|
@@ -3536,7 +3587,7 @@ var zo = (e, t) => {
|
|
|
3536
3587
|
}, t.label)
|
|
3537
3588
|
})
|
|
3538
3589
|
})]
|
|
3539
|
-
}) : null,
|
|
3590
|
+
}) : null, rs = ({ model: e }) => {
|
|
3540
3591
|
let [t, n] = M(!0), r = D(e.reasoning);
|
|
3541
3592
|
if (O(() => {
|
|
3542
3593
|
e.open || n(!0);
|
|
@@ -3546,11 +3597,11 @@ var zo = (e, t) => {
|
|
|
3546
3597
|
children: r
|
|
3547
3598
|
});
|
|
3548
3599
|
return !t && e.open && e.reasoning ? /* @__PURE__ */ y("div", {
|
|
3549
|
-
className:
|
|
3600
|
+
className: F(Q["bsy-lexical-ai__think-collapse"], Q["bsy-lexical-ai__think-collapse--grown"]),
|
|
3550
3601
|
children: i
|
|
3551
|
-
}) : /* @__PURE__ */ y(
|
|
3602
|
+
}) : /* @__PURE__ */ y(ae, {
|
|
3552
3603
|
initial: !1,
|
|
3553
|
-
children: e.open && e.reasoning ? /* @__PURE__ */ y(
|
|
3604
|
+
children: e.open && e.reasoning ? /* @__PURE__ */ y(oe.div, {
|
|
3554
3605
|
initial: {
|
|
3555
3606
|
height: 0,
|
|
3556
3607
|
opacity: 0
|
|
@@ -3578,7 +3629,7 @@ var zo = (e, t) => {
|
|
|
3578
3629
|
children: i
|
|
3579
3630
|
}, "think-body") : null
|
|
3580
3631
|
});
|
|
3581
|
-
},
|
|
3632
|
+
}, is = 32, as = .25, os = 2, ss = ({ viewportRef: e, enabled: t, revision: n }) => {
|
|
3582
3633
|
let r = j(!0), i = j(!1), a = j(0), o = T(() => e.current ?? void 0, [e]), s = T(() => {
|
|
3583
3634
|
let t = e.current;
|
|
3584
3635
|
return t?.closest("[data-overlayscrollbars]") ?? t ?? void 0;
|
|
@@ -3591,7 +3642,7 @@ var zo = (e, t) => {
|
|
|
3591
3642
|
t.scrollTop = n;
|
|
3592
3643
|
return;
|
|
3593
3644
|
}
|
|
3594
|
-
t.scrollTop += Math.max(i *
|
|
3645
|
+
t.scrollTop += Math.max(i * as, Math.min(i, os)), a.current = requestAnimationFrame(c);
|
|
3595
3646
|
}, [e]), l = T(() => {
|
|
3596
3647
|
!a.current && r.current && (a.current = requestAnimationFrame(c));
|
|
3597
3648
|
}, [c]);
|
|
@@ -3618,71 +3669,244 @@ var zo = (e, t) => {
|
|
|
3618
3669
|
let u = () => {
|
|
3619
3670
|
let t = e.current;
|
|
3620
3671
|
if (!t) return;
|
|
3621
|
-
let n = t.scrollHeight - t.clientHeight - t.scrollTop <=
|
|
3672
|
+
let n = t.scrollHeight - t.clientHeight - t.scrollTop <= is;
|
|
3622
3673
|
i.current ? (i.current = !1, r.current = n, !n && a.current && (cancelAnimationFrame(a.current), a.current = 0)) : n && (r.current = !0);
|
|
3623
3674
|
}, d = () => {
|
|
3624
3675
|
i.current = !0;
|
|
3625
3676
|
};
|
|
3626
|
-
return
|
|
3677
|
+
return ie("wheel", d, {
|
|
3627
3678
|
target: s,
|
|
3628
3679
|
passive: !0,
|
|
3629
3680
|
enable: t
|
|
3630
|
-
}),
|
|
3681
|
+
}), ie("touchstart", d, {
|
|
3631
3682
|
target: o,
|
|
3632
3683
|
passive: !0,
|
|
3633
3684
|
enable: t
|
|
3634
|
-
}),
|
|
3685
|
+
}), ie("pointerdown", (e) => {
|
|
3635
3686
|
e.target instanceof Element && e.target.closest(".os-scrollbar") && d();
|
|
3636
3687
|
}, {
|
|
3637
3688
|
target: s,
|
|
3638
3689
|
passive: !0,
|
|
3639
3690
|
enable: t
|
|
3640
|
-
}),
|
|
3691
|
+
}), ie("scroll", u, {
|
|
3641
3692
|
target: o,
|
|
3642
3693
|
passive: !0,
|
|
3643
3694
|
enable: t
|
|
3644
3695
|
}), { onScroll: u };
|
|
3645
|
-
},
|
|
3696
|
+
}, cs = `
|
|
3697
|
+
:host {
|
|
3698
|
+
all: initial;
|
|
3699
|
+
display: block;
|
|
3700
|
+
width: 100%;
|
|
3701
|
+
max-width: 100%;
|
|
3702
|
+
min-width: 0;
|
|
3703
|
+
}
|
|
3704
|
+
.bsy-editor-html-preview__body {
|
|
3705
|
+
color: #030303;
|
|
3706
|
+
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
|
|
3707
|
+
font-size: 15px;
|
|
3708
|
+
line-height: 1.6;
|
|
3709
|
+
overflow-wrap: anywhere;
|
|
3710
|
+
word-break: break-word;
|
|
3711
|
+
}
|
|
3712
|
+
.bsy-editor-html-preview__body p,
|
|
3713
|
+
.bsy-editor-html-preview__body li,
|
|
3714
|
+
.bsy-editor-html-preview__body h1,
|
|
3715
|
+
.bsy-editor-html-preview__body h2,
|
|
3716
|
+
.bsy-editor-html-preview__body h3,
|
|
3717
|
+
.bsy-editor-html-preview__body h4,
|
|
3718
|
+
.bsy-editor-html-preview__body h5,
|
|
3719
|
+
.bsy-editor-html-preview__body h6 {
|
|
3720
|
+
box-sizing: border-box;
|
|
3721
|
+
max-width: 100%;
|
|
3722
|
+
}
|
|
3723
|
+
.bsy-editor-html-preview__body p {
|
|
3724
|
+
margin: 0;
|
|
3725
|
+
}
|
|
3726
|
+
.bsy-editor-html-preview__body .editor-text-bold {
|
|
3727
|
+
font-weight: 700;
|
|
3728
|
+
}
|
|
3729
|
+
.bsy-editor-html-preview__body .editor-text-italic {
|
|
3730
|
+
font-style: italic;
|
|
3731
|
+
}
|
|
3732
|
+
.bsy-editor-html-preview__body .editor-text-underline {
|
|
3733
|
+
text-decoration: underline;
|
|
3734
|
+
}
|
|
3735
|
+
.bsy-editor-html-preview__body .editor-text-strikethrough {
|
|
3736
|
+
text-decoration: line-through;
|
|
3737
|
+
}
|
|
3738
|
+
.bsy-editor-html-preview__body .editor-text-underline-strikethrough {
|
|
3739
|
+
text-decoration: underline line-through;
|
|
3740
|
+
}
|
|
3741
|
+
.bsy-editor-html-preview__body sup,
|
|
3742
|
+
.bsy-editor-html-preview__body sub {
|
|
3743
|
+
display: inline-block;
|
|
3744
|
+
position: static;
|
|
3745
|
+
top: auto;
|
|
3746
|
+
bottom: auto;
|
|
3747
|
+
font-size: 0.75em;
|
|
3748
|
+
line-height: 1;
|
|
3749
|
+
}
|
|
3750
|
+
.bsy-editor-html-preview__body sup {
|
|
3751
|
+
vertical-align: super;
|
|
3752
|
+
}
|
|
3753
|
+
.bsy-editor-html-preview__body sub {
|
|
3754
|
+
vertical-align: sub;
|
|
3755
|
+
}
|
|
3756
|
+
.bsy-editor-html-preview__body .editor-heading-h1,
|
|
3757
|
+
.bsy-editor-html-preview__body .editor-heading-h2,
|
|
3758
|
+
.bsy-editor-html-preview__body .editor-heading-h3,
|
|
3759
|
+
.bsy-editor-html-preview__body .editor-heading-h4,
|
|
3760
|
+
.bsy-editor-html-preview__body .editor-heading-h5,
|
|
3761
|
+
.bsy-editor-html-preview__body .editor-heading-h6 {
|
|
3762
|
+
margin: 0.6em 0 0.4em;
|
|
3763
|
+
font-weight: 600;
|
|
3764
|
+
line-height: 1.35;
|
|
3765
|
+
}
|
|
3766
|
+
.bsy-editor-html-preview__body .editor-heading-h1 {
|
|
3767
|
+
font-size: 2em;
|
|
3768
|
+
}
|
|
3769
|
+
.bsy-editor-html-preview__body .editor-heading-h2 {
|
|
3770
|
+
font-size: 1.5em;
|
|
3771
|
+
}
|
|
3772
|
+
.bsy-editor-html-preview__body .editor-heading-h3 {
|
|
3773
|
+
font-size: 1.25em;
|
|
3774
|
+
}
|
|
3775
|
+
.bsy-editor-html-preview__body .editor-heading-h4 {
|
|
3776
|
+
font-size: 1.125em;
|
|
3777
|
+
}
|
|
3778
|
+
.bsy-editor-html-preview__body .editor-heading-h5 {
|
|
3779
|
+
font-size: 1em;
|
|
3780
|
+
}
|
|
3781
|
+
.bsy-editor-html-preview__body .editor-heading-h6 {
|
|
3782
|
+
font-size: 0.875em;
|
|
3783
|
+
}
|
|
3784
|
+
.bsy-editor-html-preview__body ul,
|
|
3785
|
+
.bsy-editor-html-preview__body ol,
|
|
3786
|
+
.bsy-editor-html-preview__body .editor-list-ul,
|
|
3787
|
+
.bsy-editor-html-preview__body .editor-list-ol {
|
|
3788
|
+
margin: 0;
|
|
3789
|
+
padding-inline-start: 0;
|
|
3790
|
+
list-style-position: outside;
|
|
3791
|
+
}
|
|
3792
|
+
.bsy-editor-html-preview__body .editor-list-ul {
|
|
3793
|
+
list-style-type: disc;
|
|
3794
|
+
}
|
|
3795
|
+
.bsy-editor-html-preview__body .editor-list-ol {
|
|
3796
|
+
list-style-type: decimal;
|
|
3797
|
+
}
|
|
3798
|
+
.bsy-editor-html-preview__body li,
|
|
3799
|
+
.bsy-editor-html-preview__body .editor-listitem {
|
|
3800
|
+
margin: 0;
|
|
3801
|
+
margin-inline-start: ${pi};
|
|
3802
|
+
list-style: inherit;
|
|
3803
|
+
}
|
|
3804
|
+
.bsy-editor-html-preview__body .editor-nested-listitem {
|
|
3805
|
+
margin-inline-start: 0;
|
|
3806
|
+
list-style-type: none;
|
|
3807
|
+
}
|
|
3808
|
+
.bsy-editor-html-preview__body li::marker,
|
|
3809
|
+
.bsy-editor-html-preview__body .editor-listitem::marker {
|
|
3810
|
+
color: var(--listitem-marker-color);
|
|
3811
|
+
background-color: var(--listitem-marker-background-color);
|
|
3812
|
+
font-family: var(--listitem-marker-font-family);
|
|
3813
|
+
font-size: var(--listitem-marker-font-size);
|
|
3814
|
+
}
|
|
3815
|
+
.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul {
|
|
3816
|
+
list-style-type: circle;
|
|
3817
|
+
}
|
|
3818
|
+
.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul .editor-list-ul {
|
|
3819
|
+
list-style-type: square;
|
|
3820
|
+
}
|
|
3821
|
+
.bsy-editor-html-preview__body .editor-link,
|
|
3822
|
+
.bsy-editor-html-preview__body .editor-link:link,
|
|
3823
|
+
.bsy-editor-html-preview__body .editor-link:visited,
|
|
3824
|
+
.bsy-editor-html-preview__body .editor-link:hover,
|
|
3825
|
+
.bsy-editor-html-preview__body .editor-link:active,
|
|
3826
|
+
.bsy-editor-html-preview__body .editor-link:focus {
|
|
3827
|
+
color: #0269ff;
|
|
3828
|
+
cursor: pointer;
|
|
3829
|
+
}
|
|
3830
|
+
.bsy-editor-html-preview__body .editor-link * {
|
|
3831
|
+
color: #0269ff !important;
|
|
3832
|
+
}
|
|
3833
|
+
.bsy-editor-html-preview__body pre,
|
|
3834
|
+
.bsy-editor-html-preview__body .editor-code {
|
|
3835
|
+
display: block;
|
|
3836
|
+
box-sizing: border-box;
|
|
3837
|
+
max-width: 100%;
|
|
3838
|
+
margin: 8px 0;
|
|
3839
|
+
padding: 8px 12px;
|
|
3840
|
+
overflow-x: auto;
|
|
3841
|
+
border-radius: 4px;
|
|
3842
|
+
background: rgb(240, 242, 245);
|
|
3843
|
+
color: #1f2328;
|
|
3844
|
+
font-family: Menlo, Consolas, Monaco, monospace;
|
|
3845
|
+
font-size: 13px;
|
|
3846
|
+
line-height: 1.53;
|
|
3847
|
+
tab-size: 2;
|
|
3848
|
+
white-space: pre;
|
|
3849
|
+
}
|
|
3850
|
+
.bsy-editor-html-preview__body .editor-table-scrollable-wrapper {
|
|
3851
|
+
max-width: 100%;
|
|
3852
|
+
margin: 8px 0;
|
|
3853
|
+
overflow-x: auto;
|
|
3854
|
+
}
|
|
3855
|
+
.bsy-editor-html-preview__body table {
|
|
3856
|
+
width: max-content;
|
|
3857
|
+
min-width: 100%;
|
|
3858
|
+
margin: 0;
|
|
3859
|
+
border-collapse: collapse;
|
|
3860
|
+
table-layout: fixed;
|
|
3861
|
+
}
|
|
3862
|
+
.bsy-editor-html-preview__body td,
|
|
3863
|
+
.bsy-editor-html-preview__body th {
|
|
3864
|
+
box-sizing: border-box;
|
|
3865
|
+
min-width: 75px;
|
|
3866
|
+
min-height: 32px;
|
|
3867
|
+
padding: 4px 8px;
|
|
3868
|
+
border: 1px solid #d9d9d9;
|
|
3869
|
+
vertical-align: top;
|
|
3870
|
+
}
|
|
3871
|
+
.bsy-editor-html-preview__body th {
|
|
3872
|
+
background: #f2f3f5;
|
|
3873
|
+
font-weight: 600;
|
|
3874
|
+
}
|
|
3875
|
+
.bsy-editor-html-preview__body img {
|
|
3876
|
+
max-width: 100%;
|
|
3877
|
+
height: auto;
|
|
3878
|
+
vertical-align: baseline;
|
|
3879
|
+
}
|
|
3880
|
+
`, ls = ({ html: e }) => {
|
|
3646
3881
|
let t = j(null);
|
|
3647
|
-
return
|
|
3648
|
-
|
|
3649
|
-
if (!n) return;
|
|
3650
|
-
let r = n.shadowRoot ?? n.attachShadow({ mode: "open" }), i = document.createElement("div");
|
|
3651
|
-
i.className = "bsy-editor-html-preview__body", i.innerHTML = X(e);
|
|
3652
|
-
for (let e of Array.from(i.querySelectorAll("table"))) {
|
|
3653
|
-
if (e.parentElement?.classList.contains("editor-table-scrollable-wrapper")) continue;
|
|
3654
|
-
let t = document.createElement("div");
|
|
3655
|
-
t.className = "editor-table-scrollable-wrapper", e.replaceWith(t), t.append(e);
|
|
3656
|
-
}
|
|
3657
|
-
r.replaceChildren();
|
|
3658
|
-
let a = document.createElement("style");
|
|
3659
|
-
a.textContent = Xo, r.append(a, i);
|
|
3882
|
+
return k(() => {
|
|
3883
|
+
vi(t.current, e, X, cs);
|
|
3660
3884
|
}, [e]), /* @__PURE__ */ y("div", {
|
|
3661
3885
|
ref: t,
|
|
3662
3886
|
className: "bsy-editor-html-preview"
|
|
3663
3887
|
});
|
|
3664
|
-
},
|
|
3665
|
-
let [t, n] = M(() => e && !
|
|
3888
|
+
}, us = ({ html: e }) => {
|
|
3889
|
+
let [t, n] = M(() => e && !yi(e) ? e : "");
|
|
3666
3890
|
return O(() => {
|
|
3667
|
-
!e ||
|
|
3668
|
-
}, [e]), t ? /* @__PURE__ */ y(
|
|
3669
|
-
},
|
|
3891
|
+
!e || yi(e) || n(e);
|
|
3892
|
+
}, [e]), t ? /* @__PURE__ */ y(ls, { html: t }) : null;
|
|
3893
|
+
}, ds = {
|
|
3670
3894
|
paddingAbsolute: !0,
|
|
3671
3895
|
overflow: {
|
|
3672
3896
|
x: "hidden",
|
|
3673
3897
|
y: "scroll"
|
|
3674
3898
|
}
|
|
3675
|
-
},
|
|
3676
|
-
let { t: p } = a(), m =
|
|
3899
|
+
}, fs = ({ status: t, errorMessage: n, originalHtml: i, proposedHtml: o, preset: s, onPresetChange: c, onCancel: l, onApply: d }) => {
|
|
3900
|
+
let { t: p } = a(), m = vr(), [h, g] = M(!0), _ = j(null), v = !!o.trim(), x = t === "ready" && v, S = ts({
|
|
3677
3901
|
status: t,
|
|
3678
3902
|
reasoning: m
|
|
3679
|
-
}, v), C =
|
|
3903
|
+
}, v), C = ss({
|
|
3680
3904
|
viewportRef: _,
|
|
3681
3905
|
enabled: t === "loading",
|
|
3682
3906
|
revision: `${m ?? ""}\0${o}`
|
|
3683
|
-
}), w =
|
|
3907
|
+
}), w = Yr.map((e) => ({
|
|
3684
3908
|
key: e,
|
|
3685
|
-
label: p(
|
|
3909
|
+
label: p(Xr[e])
|
|
3686
3910
|
}));
|
|
3687
3911
|
return /* @__PURE__ */ y(r, {
|
|
3688
3912
|
title: p("editor.aiPolish"),
|
|
@@ -3698,19 +3922,19 @@ var zo = (e, t) => {
|
|
|
3698
3922
|
children: [/* @__PURE__ */ b("div", {
|
|
3699
3923
|
className: Q["bsy-lexical-ai__column"],
|
|
3700
3924
|
children: [/* @__PURE__ */ b("div", {
|
|
3701
|
-
className:
|
|
3925
|
+
className: F(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--before"]),
|
|
3702
3926
|
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), p("editor.aiOriginal")]
|
|
3703
3927
|
}), /* @__PURE__ */ y(u, {
|
|
3704
3928
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3705
|
-
options:
|
|
3706
|
-
children: /* @__PURE__ */ y(
|
|
3929
|
+
options: ds,
|
|
3930
|
+
children: /* @__PURE__ */ y(us, { html: i })
|
|
3707
3931
|
})]
|
|
3708
3932
|
}), /* @__PURE__ */ b("div", {
|
|
3709
3933
|
className: Q["bsy-lexical-ai__column"],
|
|
3710
3934
|
children: [/* @__PURE__ */ b("div", {
|
|
3711
3935
|
className: Q["bsy-lexical-ai__column-head"],
|
|
3712
3936
|
children: [/* @__PURE__ */ b("div", {
|
|
3713
|
-
className:
|
|
3937
|
+
className: F(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--after"]),
|
|
3714
3938
|
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), p("editor.aiOptimized")]
|
|
3715
3939
|
}), /* @__PURE__ */ y(f, {
|
|
3716
3940
|
menus: w,
|
|
@@ -3729,7 +3953,7 @@ var zo = (e, t) => {
|
|
|
3729
3953
|
type: "button",
|
|
3730
3954
|
className: Q["bsy-lexical-ai__preset"],
|
|
3731
3955
|
title: p("editor.aiPolish"),
|
|
3732
|
-
children: [p(
|
|
3956
|
+
children: [p(Xr[s]), /* @__PURE__ */ y(e, {
|
|
3733
3957
|
name: "arrow-down",
|
|
3734
3958
|
size: 16
|
|
3735
3959
|
})]
|
|
@@ -3739,16 +3963,16 @@ var zo = (e, t) => {
|
|
|
3739
3963
|
className: Q["bsy-lexical-ai__column-stack"],
|
|
3740
3964
|
children: [S.visible ? /* @__PURE__ */ y("div", {
|
|
3741
3965
|
className: Q["bsy-lexical-ai__think-pin"],
|
|
3742
|
-
children: /* @__PURE__ */ y(
|
|
3966
|
+
children: /* @__PURE__ */ y(ns, { model: S })
|
|
3743
3967
|
}) : null, /* @__PURE__ */ b(u, {
|
|
3744
3968
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3745
|
-
options:
|
|
3969
|
+
options: ds,
|
|
3746
3970
|
viewportRef: _,
|
|
3747
3971
|
onScroll: C.onScroll,
|
|
3748
3972
|
children: [t === "error" ? /* @__PURE__ */ y("div", {
|
|
3749
3973
|
className: Q["bsy-lexical-ai__error"],
|
|
3750
3974
|
children: n || p("editor.aiError")
|
|
3751
|
-
}) : /* @__PURE__ */ y(
|
|
3975
|
+
}) : /* @__PURE__ */ y(rs, { model: S }), v ? /* @__PURE__ */ y(us, { html: o }) : null]
|
|
3752
3976
|
})]
|
|
3753
3977
|
})]
|
|
3754
3978
|
})]
|
|
@@ -3766,17 +3990,17 @@ var zo = (e, t) => {
|
|
|
3766
3990
|
})]
|
|
3767
3991
|
})
|
|
3768
3992
|
});
|
|
3769
|
-
},
|
|
3993
|
+
}, ps = {
|
|
3770
3994
|
paddingAbsolute: !0,
|
|
3771
3995
|
overflow: {
|
|
3772
3996
|
x: "hidden",
|
|
3773
3997
|
y: "scroll"
|
|
3774
3998
|
}
|
|
3775
|
-
},
|
|
3776
|
-
let { t: c } = a(), l =
|
|
3999
|
+
}, ms = ({ status: e, errorMessage: t, originalHtml: n, proposedHtml: i, onCancel: o, onApply: s }) => {
|
|
4000
|
+
let { t: c } = a(), l = vr(), [d, f] = M(!0), p = j(null), m = !!i.trim(), h = e === "ready" && m, g = ts({
|
|
3777
4001
|
status: e,
|
|
3778
4002
|
reasoning: l
|
|
3779
|
-
}, m), _ =
|
|
4003
|
+
}, m), _ = ss({
|
|
3780
4004
|
viewportRef: p,
|
|
3781
4005
|
enabled: e === "loading",
|
|
3782
4006
|
revision: `${l ?? ""}\0${i}`
|
|
@@ -3795,32 +4019,32 @@ var zo = (e, t) => {
|
|
|
3795
4019
|
children: [/* @__PURE__ */ b("div", {
|
|
3796
4020
|
className: Q["bsy-lexical-ai__column"],
|
|
3797
4021
|
children: [/* @__PURE__ */ b("div", {
|
|
3798
|
-
className:
|
|
4022
|
+
className: F(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--before"]),
|
|
3799
4023
|
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), c("editor.aiOriginal")]
|
|
3800
4024
|
}), /* @__PURE__ */ y(u, {
|
|
3801
4025
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3802
|
-
options:
|
|
3803
|
-
children: /* @__PURE__ */ y(
|
|
4026
|
+
options: ps,
|
|
4027
|
+
children: /* @__PURE__ */ y(us, { html: n })
|
|
3804
4028
|
})]
|
|
3805
4029
|
}), /* @__PURE__ */ b("div", {
|
|
3806
4030
|
className: Q["bsy-lexical-ai__column"],
|
|
3807
4031
|
children: [/* @__PURE__ */ b("div", {
|
|
3808
|
-
className:
|
|
4032
|
+
className: F(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--after"]),
|
|
3809
4033
|
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), c("editor.aiOptimized")]
|
|
3810
4034
|
}), /* @__PURE__ */ b("div", {
|
|
3811
4035
|
className: Q["bsy-lexical-ai__column-stack"],
|
|
3812
4036
|
children: [g.visible ? /* @__PURE__ */ y("div", {
|
|
3813
4037
|
className: Q["bsy-lexical-ai__think-pin"],
|
|
3814
|
-
children: /* @__PURE__ */ y(
|
|
4038
|
+
children: /* @__PURE__ */ y(ns, { model: g })
|
|
3815
4039
|
}) : null, /* @__PURE__ */ b(u, {
|
|
3816
4040
|
className: Q["bsy-lexical-ai__column-body"],
|
|
3817
|
-
options:
|
|
4041
|
+
options: ps,
|
|
3818
4042
|
viewportRef: p,
|
|
3819
4043
|
onScroll: _.onScroll,
|
|
3820
4044
|
children: [e === "error" ? /* @__PURE__ */ y("div", {
|
|
3821
4045
|
className: Q["bsy-lexical-ai__error"],
|
|
3822
4046
|
children: t || c("editor.aiError")
|
|
3823
|
-
}) : /* @__PURE__ */ y(
|
|
4047
|
+
}) : /* @__PURE__ */ y(rs, { model: g }), m ? /* @__PURE__ */ y(us, { html: i }) : null]
|
|
3824
4048
|
})]
|
|
3825
4049
|
})]
|
|
3826
4050
|
})]
|
|
@@ -3838,21 +4062,21 @@ var zo = (e, t) => {
|
|
|
3838
4062
|
})]
|
|
3839
4063
|
})
|
|
3840
4064
|
});
|
|
3841
|
-
},
|
|
3842
|
-
let [n] =
|
|
4065
|
+
}, hs = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
4066
|
+
let [n] = z(), { aiOpen: r, setAiOpen: i, aiSessionRef: o, stop: s, polish: c } = gr(), { t: l } = a(), [u, d] = P.useMessage(), f = o.current, { text: p, status: m, errorMessage: h } = _r(), g = !m || m === "idle" ? "loading" : m, _ = A(() => r ? Zo(o.current?.originalHtml || "", "ready") : "", [r, o]), x = Qo({
|
|
3843
4067
|
enabled: r === "typeset",
|
|
3844
4068
|
status: g,
|
|
3845
4069
|
revision: p,
|
|
3846
|
-
compute: () =>
|
|
3847
|
-
}), S =
|
|
4070
|
+
compute: () => Zo(Yo(p, f?.codeBlocks ?? []), g)
|
|
4071
|
+
}), S = Qo({
|
|
3848
4072
|
enabled: r === "polish",
|
|
3849
4073
|
status: g,
|
|
3850
4074
|
revision: p,
|
|
3851
|
-
compute: () =>
|
|
4075
|
+
compute: () => Zo(da(f?.originalHtml || "", p), g)
|
|
3852
4076
|
});
|
|
3853
4077
|
O(() => {
|
|
3854
4078
|
if (r) return n.setEditable(!1), n.update(() => {
|
|
3855
|
-
|
|
4079
|
+
Ne(null);
|
|
3856
4080
|
}), window.getSelection()?.removeAllRanges(), n.getRootElement()?.blur(), () => {
|
|
3857
4081
|
n.setEditable(!0);
|
|
3858
4082
|
};
|
|
@@ -3866,7 +4090,7 @@ var zo = (e, t) => {
|
|
|
3866
4090
|
]), w = T(() => {
|
|
3867
4091
|
if (r !== "typeset" || g !== "ready") return !1;
|
|
3868
4092
|
n.setEditable(!0);
|
|
3869
|
-
let { applied: i, truncated: a } =
|
|
4093
|
+
let { applied: i, truncated: a } = Xo(n, p, o.current?.codeBlocks ?? [], e);
|
|
3870
4094
|
return i ? (a && t?.(), !0) : (n.setEditable(!1), u.warning(l("editor.aiApplyEmpty")), !1);
|
|
3871
4095
|
}, [
|
|
3872
4096
|
r,
|
|
@@ -3878,7 +4102,7 @@ var zo = (e, t) => {
|
|
|
3878
4102
|
g,
|
|
3879
4103
|
l,
|
|
3880
4104
|
p
|
|
3881
|
-
]), E = T(() => r !== "polish" || g !== "ready" ? !1 :
|
|
4105
|
+
]), E = T(() => r !== "polish" || g !== "ready" ? !1 : fa(n, p) ? !0 : (u.warning(l("editor.aiApplyEmpty")), !1), [
|
|
3882
4106
|
r,
|
|
3883
4107
|
n,
|
|
3884
4108
|
u,
|
|
@@ -3890,21 +4114,21 @@ var zo = (e, t) => {
|
|
|
3890
4114
|
!t?.originalText || !c || (t.preset = e, s?.(), c({
|
|
3891
4115
|
text: t.originalText,
|
|
3892
4116
|
preset: e,
|
|
3893
|
-
prompt:
|
|
4117
|
+
prompt: ei(e)
|
|
3894
4118
|
}));
|
|
3895
4119
|
}, [
|
|
3896
4120
|
o,
|
|
3897
4121
|
c,
|
|
3898
4122
|
s
|
|
3899
4123
|
]);
|
|
3900
|
-
return r ? /* @__PURE__ */ b(v, { children: [d, r === "typeset" ? /* @__PURE__ */ y(
|
|
4124
|
+
return r ? /* @__PURE__ */ b(v, { children: [d, r === "typeset" ? /* @__PURE__ */ y(ms, {
|
|
3901
4125
|
status: g,
|
|
3902
4126
|
errorMessage: h,
|
|
3903
4127
|
originalHtml: _,
|
|
3904
4128
|
proposedHtml: x,
|
|
3905
4129
|
onCancel: C,
|
|
3906
4130
|
onApply: w
|
|
3907
|
-
}) : /* @__PURE__ */ y(
|
|
4131
|
+
}) : /* @__PURE__ */ y(fs, {
|
|
3908
4132
|
status: g,
|
|
3909
4133
|
errorMessage: h,
|
|
3910
4134
|
originalHtml: _,
|
|
@@ -3914,20 +4138,20 @@ var zo = (e, t) => {
|
|
|
3914
4138
|
onCancel: C,
|
|
3915
4139
|
onApply: E
|
|
3916
4140
|
})] }) : d;
|
|
3917
|
-
},
|
|
3918
|
-
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s, upload: c, ai: l } = e, [u] =
|
|
4141
|
+
}, gs = [], _s = (e) => {
|
|
4142
|
+
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s, upload: c, ai: l } = e, [u] = z(), { isSourceMode: d, isSourceModeRef: f } = Wr(), p = j(null), m = j(null), h = j(/* @__PURE__ */ new Map()), g = j(null), _ = j(null), v = j(s);
|
|
3919
4143
|
v.current = s;
|
|
3920
|
-
let x =
|
|
3921
|
-
|
|
3922
|
-
let
|
|
3923
|
-
|
|
4144
|
+
let x = ho(o) ? o : void 0, [S, C] = M(0), [w, E] = M(null), D = i?.mode === "floating", ee = x !== void 0 && !d, te = j(l);
|
|
4145
|
+
te.current = l;
|
|
4146
|
+
let k = j(r);
|
|
4147
|
+
k.current = r;
|
|
3924
4148
|
let N = T((e) => {
|
|
3925
|
-
|
|
4149
|
+
te.current?.typeset?.(e);
|
|
3926
4150
|
}, []), ne = T((e) => {
|
|
3927
|
-
|
|
4151
|
+
te.current?.polish?.(e);
|
|
3928
4152
|
}, []), re = T(() => {
|
|
3929
|
-
|
|
3930
|
-
}, []),
|
|
4153
|
+
te.current?.stop?.();
|
|
4154
|
+
}, []), P = !!l?.typeset, F = !!l?.polish, ie = A(() => ({
|
|
3931
4155
|
containerRef: p,
|
|
3932
4156
|
toolbarRef: m,
|
|
3933
4157
|
upload: c,
|
|
@@ -3938,17 +4162,17 @@ var zo = (e, t) => {
|
|
|
3938
4162
|
typeset: N,
|
|
3939
4163
|
polish: ne,
|
|
3940
4164
|
stop: re,
|
|
3941
|
-
canTypeset:
|
|
3942
|
-
canPolish:
|
|
4165
|
+
canTypeset: P,
|
|
4166
|
+
canPolish: F
|
|
3943
4167
|
}), [
|
|
3944
4168
|
w,
|
|
4169
|
+
F,
|
|
3945
4170
|
P,
|
|
3946
|
-
ie,
|
|
3947
4171
|
ne,
|
|
3948
4172
|
re,
|
|
3949
4173
|
N,
|
|
3950
4174
|
c
|
|
3951
|
-
]),
|
|
4175
|
+
]), ae = A(() => ({
|
|
3952
4176
|
text: l?.text ?? "",
|
|
3953
4177
|
status: l?.status,
|
|
3954
4178
|
errorMessage: l?.errorMessage
|
|
@@ -3956,12 +4180,12 @@ var zo = (e, t) => {
|
|
|
3956
4180
|
l?.text,
|
|
3957
4181
|
l?.status,
|
|
3958
4182
|
l?.errorMessage
|
|
3959
|
-
]),
|
|
4183
|
+
]), oe = T((e) => {
|
|
3960
4184
|
f.current || e.read(() => {
|
|
3961
|
-
let t =
|
|
4185
|
+
let t = I().getTextContent(), n = Qi(X(he(u, null))), r = wi(n, t) ? null : n;
|
|
3962
4186
|
_.current = r, x !== void 0 && C(t.length);
|
|
3963
|
-
let i =
|
|
3964
|
-
|
|
4187
|
+
let i = je(nn).map((e) => h.current.get(e.getSrc())).filter((e) => e !== void 0);
|
|
4188
|
+
k.current({
|
|
3965
4189
|
text: t,
|
|
3966
4190
|
html: r,
|
|
3967
4191
|
attachments: i
|
|
@@ -3974,7 +4198,7 @@ var zo = (e, t) => {
|
|
|
3974
4198
|
]);
|
|
3975
4199
|
O(() => {
|
|
3976
4200
|
x === void 0 || d || u.getEditorState().read(() => {
|
|
3977
|
-
C(
|
|
4201
|
+
C(I().getTextContentSize());
|
|
3978
4202
|
}, { editor: u });
|
|
3979
4203
|
}, [
|
|
3980
4204
|
u,
|
|
@@ -3985,33 +4209,33 @@ var zo = (e, t) => {
|
|
|
3985
4209
|
if (f.current) {
|
|
3986
4210
|
let t = e.value?.trim() ? X(e.value) : "";
|
|
3987
4211
|
_.current = e.value, u.update(() => {
|
|
3988
|
-
|
|
4212
|
+
Oo(Do(t));
|
|
3989
4213
|
});
|
|
3990
4214
|
return;
|
|
3991
4215
|
}
|
|
3992
4216
|
let t = !1, n = _.current === null;
|
|
3993
4217
|
u.update(() => {
|
|
3994
|
-
|
|
3995
|
-
}), n && u.dispatchCommand(
|
|
4218
|
+
Ci(u, e.value?.trim() ? X(e.value) : ""), x !== void 0 && (t = go(u, x)), kn(u);
|
|
4219
|
+
}), n && u.dispatchCommand(Le, void 0), t && v.current?.();
|
|
3996
4220
|
}, [
|
|
3997
4221
|
e.value,
|
|
3998
4222
|
u,
|
|
3999
4223
|
x,
|
|
4000
4224
|
f
|
|
4001
4225
|
]);
|
|
4002
|
-
let
|
|
4226
|
+
let se = i?.config?.length ? i.config : gs, ce = T(() => {
|
|
4003
4227
|
v.current?.();
|
|
4004
4228
|
}, []);
|
|
4005
|
-
return /* @__PURE__ */ y(
|
|
4006
|
-
value:
|
|
4007
|
-
children: /* @__PURE__ */ y(
|
|
4008
|
-
value:
|
|
4009
|
-
children: /* @__PURE__ */ b(
|
|
4229
|
+
return /* @__PURE__ */ y(pr.Provider, {
|
|
4230
|
+
value: ie,
|
|
4231
|
+
children: /* @__PURE__ */ y(mr.Provider, {
|
|
4232
|
+
value: ae,
|
|
4233
|
+
children: /* @__PURE__ */ b(hr.Provider, {
|
|
4010
4234
|
value: l?.reasoning,
|
|
4011
|
-
children: [/* @__PURE__ */ y(
|
|
4235
|
+
children: [/* @__PURE__ */ y(vs, {
|
|
4012
4236
|
containerRef: p,
|
|
4013
4237
|
isFloating: D,
|
|
4014
|
-
toolbarConfig:
|
|
4238
|
+
toolbarConfig: se,
|
|
4015
4239
|
toolbarTheme: a?.toolbar,
|
|
4016
4240
|
containerTheme: a?.container,
|
|
4017
4241
|
toolbarStyle: i?.style,
|
|
@@ -4024,31 +4248,31 @@ var zo = (e, t) => {
|
|
|
4024
4248
|
showLengthBadge: ee,
|
|
4025
4249
|
textLength: S,
|
|
4026
4250
|
validMaxLength: x,
|
|
4027
|
-
onMaxLengthExceed:
|
|
4028
|
-
onChange:
|
|
4029
|
-
}), /* @__PURE__ */ y(
|
|
4251
|
+
onMaxLengthExceed: ce,
|
|
4252
|
+
onChange: oe
|
|
4253
|
+
}), /* @__PURE__ */ y(hs, {
|
|
4030
4254
|
maxLength: x,
|
|
4031
|
-
onMaxLengthExceed:
|
|
4255
|
+
onMaxLengthExceed: ce
|
|
4032
4256
|
})]
|
|
4033
4257
|
})
|
|
4034
4258
|
})
|
|
4035
4259
|
});
|
|
4036
|
-
},
|
|
4037
|
-
let [_] =
|
|
4260
|
+
}, vs = w(function({ containerRef: e, isFloating: t, toolbarConfig: n, toolbarTheme: r, containerTheme: i, toolbarStyle: a, toolbarSize: o, toolbarMode: s, toolbarFloating: c, toolbarStickyOffset: l, height: u, minHeight: d, showLengthBadge: f, textLength: p, validMaxLength: m, onMaxLengthExceed: h, onChange: g }) {
|
|
4261
|
+
let [_] = z(), v = Qt(), x = typeof u == "number" ? u : void 0, S = !t && x === void 0 && l !== void 0, C = j(!1);
|
|
4038
4262
|
O(() => {
|
|
4039
4263
|
v && C.current && (C.current = !1, _.focus());
|
|
4040
4264
|
}, [v, _]);
|
|
4041
|
-
let w = A(() =>
|
|
4265
|
+
let w = A(() => Ma(i), [i]);
|
|
4042
4266
|
return /* @__PURE__ */ b("div", {
|
|
4043
4267
|
ref: e,
|
|
4044
|
-
className:
|
|
4268
|
+
className: F("bsy-lexical-editor", $["bsy-lexical-editor"], t && $["bsy-lexical-editor--floating"], S && $["bsy-lexical-editor--sticky-toolbar"]),
|
|
4045
4269
|
style: w,
|
|
4046
4270
|
onClick: (e) => {
|
|
4047
4271
|
let t = _.getRootElement(), n = e.target;
|
|
4048
4272
|
!t || !n || !t.contains(n) || _.isEditable() || (C.current = !0, _.setEditable(!0));
|
|
4049
4273
|
},
|
|
4050
4274
|
children: [
|
|
4051
|
-
n && n.length > 0 ? /* @__PURE__ */ y(
|
|
4275
|
+
n && n.length > 0 ? /* @__PURE__ */ y(Aa, {
|
|
4052
4276
|
config: n,
|
|
4053
4277
|
theme: r,
|
|
4054
4278
|
style: a,
|
|
@@ -4058,56 +4282,57 @@ var zo = (e, t) => {
|
|
|
4058
4282
|
stickyOffset: S ? l : void 0
|
|
4059
4283
|
}) : null,
|
|
4060
4284
|
/* @__PURE__ */ b("div", {
|
|
4061
|
-
className:
|
|
4285
|
+
className: F($["bsy-lexical-editor__body"], x !== void 0 && $["bsy-lexical-editor__body--fixed"]),
|
|
4062
4286
|
style: { height: x },
|
|
4063
4287
|
children: [/* @__PURE__ */ y("div", {
|
|
4064
4288
|
className: $["bsy-lexical-editor__editable-wrap"],
|
|
4065
|
-
children: /* @__PURE__ */ y(
|
|
4066
|
-
contentEditable: /* @__PURE__ */ y(
|
|
4289
|
+
children: /* @__PURE__ */ y(ue, {
|
|
4290
|
+
contentEditable: /* @__PURE__ */ y(de, {
|
|
4067
4291
|
className: $["bsy-lexical-editor__content-editable"],
|
|
4068
4292
|
style: {
|
|
4069
4293
|
minHeight: x === void 0 ? d : void 0,
|
|
4070
4294
|
cursor: v ? "auto" : "text"
|
|
4071
4295
|
}
|
|
4072
4296
|
}),
|
|
4073
|
-
ErrorBoundary:
|
|
4297
|
+
ErrorBoundary: me
|
|
4074
4298
|
})
|
|
4075
|
-
}), f && m !== void 0 ? /* @__PURE__ */ y(
|
|
4299
|
+
}), f && m !== void 0 ? /* @__PURE__ */ y(Mo, {
|
|
4076
4300
|
current: p,
|
|
4077
4301
|
maxLength: m
|
|
4078
4302
|
}) : null]
|
|
4079
4303
|
}),
|
|
4080
4304
|
/* @__PURE__ */ y($t, {}),
|
|
4081
4305
|
/* @__PURE__ */ y(en, {}),
|
|
4082
|
-
/* @__PURE__ */ y(
|
|
4083
|
-
/* @__PURE__ */ y(
|
|
4084
|
-
/* @__PURE__ */ y(
|
|
4085
|
-
/* @__PURE__ */ y(
|
|
4086
|
-
/* @__PURE__ */ y(
|
|
4087
|
-
/* @__PURE__ */ y(
|
|
4088
|
-
/* @__PURE__ */ y(
|
|
4089
|
-
/* @__PURE__ */ y(
|
|
4090
|
-
|
|
4306
|
+
/* @__PURE__ */ y(Ra, {}),
|
|
4307
|
+
/* @__PURE__ */ y(jo, {}),
|
|
4308
|
+
/* @__PURE__ */ y(za, {}),
|
|
4309
|
+
/* @__PURE__ */ y(Ha, {}),
|
|
4310
|
+
/* @__PURE__ */ y(Ua, {}),
|
|
4311
|
+
/* @__PURE__ */ y(oo, {}),
|
|
4312
|
+
/* @__PURE__ */ y(so, {}),
|
|
4313
|
+
/* @__PURE__ */ y(fo, {}),
|
|
4314
|
+
/* @__PURE__ */ y(po, {}),
|
|
4315
|
+
f && m !== void 0 ? /* @__PURE__ */ y(mo, {
|
|
4091
4316
|
maxLength: m,
|
|
4092
4317
|
onMaxLengthExceed: h
|
|
4093
4318
|
}) : null,
|
|
4094
|
-
/* @__PURE__ */ y(
|
|
4095
|
-
/* @__PURE__ */ y(
|
|
4319
|
+
/* @__PURE__ */ y(fe, {}),
|
|
4320
|
+
/* @__PURE__ */ y(pe, {
|
|
4096
4321
|
onChange: g,
|
|
4097
4322
|
ignoreSelectionChange: !0,
|
|
4098
4323
|
ignoreHistoryMergeTagChange: !1
|
|
4099
4324
|
})
|
|
4100
4325
|
]
|
|
4101
4326
|
});
|
|
4102
|
-
}),
|
|
4327
|
+
}), ys = (e) => /* @__PURE__ */ y(ko, {
|
|
4103
4328
|
maxLength: e.maxLength,
|
|
4104
4329
|
onMaxLengthExceed: e.onMaxLengthExceed,
|
|
4105
|
-
children: /* @__PURE__ */ y(
|
|
4330
|
+
children: /* @__PURE__ */ y(_s, { ...e })
|
|
4106
4331
|
});
|
|
4107
|
-
|
|
4332
|
+
ys.displayName = "BsyLexicalEditorCore";
|
|
4108
4333
|
//#endregion
|
|
4109
4334
|
//#region src/components/Editor/nodes/ExtendedLinkNode.ts
|
|
4110
|
-
var
|
|
4335
|
+
var bs = class e extends pt {
|
|
4111
4336
|
constructor(e = "", t = {}, n) {
|
|
4112
4337
|
super(e, t, n);
|
|
4113
4338
|
}
|
|
@@ -4122,17 +4347,17 @@ var cs = class e extends pt {
|
|
|
4122
4347
|
}, t.__key);
|
|
4123
4348
|
}
|
|
4124
4349
|
static importJSON(e) {
|
|
4125
|
-
return
|
|
4350
|
+
return xs().updateFromJSON(e);
|
|
4126
4351
|
}
|
|
4127
4352
|
sanitizeUrl(e) {
|
|
4128
4353
|
return e.startsWith("@") ? e : super.sanitizeUrl(e);
|
|
4129
4354
|
}
|
|
4130
|
-
},
|
|
4355
|
+
}, xs = (e = "", t = {}) => _e(new bs(e, t)), Ss = "1px solid #d9d9d9", Cs = { export: new Map([[Rt, (e, t) => {
|
|
4131
4356
|
let n = t.exportDOM(e);
|
|
4132
|
-
return ot(n.element) && (n.element.style.border =
|
|
4133
|
-
}]]) },
|
|
4357
|
+
return ot(n.element) && (n.element.style.border = Ss), n;
|
|
4358
|
+
}]]) }, ws = (e) => {
|
|
4134
4359
|
let { autoFocus: t = !1 } = e;
|
|
4135
|
-
return /* @__PURE__ */ y(
|
|
4360
|
+
return /* @__PURE__ */ y(le, {
|
|
4136
4361
|
initialConfig: A(() => ({
|
|
4137
4362
|
namespace: "bsyLexicalEditor",
|
|
4138
4363
|
onError: (e) => {
|
|
@@ -4169,39 +4394,39 @@ var cs = class e extends pt {
|
|
|
4169
4394
|
tableRow: "editor-table-row",
|
|
4170
4395
|
tableScrollableWrapper: "editor-table-scrollable-wrapper"
|
|
4171
4396
|
},
|
|
4172
|
-
html:
|
|
4397
|
+
html: Cs,
|
|
4173
4398
|
nodes: [
|
|
4174
|
-
|
|
4399
|
+
bs,
|
|
4175
4400
|
{
|
|
4176
4401
|
replace: pt,
|
|
4177
|
-
with: (e) => new
|
|
4402
|
+
with: (e) => new bs(e.__url, {
|
|
4178
4403
|
rel: e.__rel,
|
|
4179
4404
|
target: e.__target,
|
|
4180
4405
|
title: e.__title
|
|
4181
4406
|
}),
|
|
4182
|
-
withKlass:
|
|
4407
|
+
withKlass: bs
|
|
4183
4408
|
},
|
|
4184
4409
|
ft,
|
|
4185
|
-
bt,
|
|
4186
4410
|
yt,
|
|
4187
|
-
|
|
4188
|
-
|
|
4411
|
+
vt,
|
|
4412
|
+
qt,
|
|
4189
4413
|
Et,
|
|
4190
|
-
|
|
4191
|
-
Vt,
|
|
4414
|
+
Tt,
|
|
4192
4415
|
zt,
|
|
4416
|
+
Bt,
|
|
4417
|
+
Rt,
|
|
4193
4418
|
nn,
|
|
4194
|
-
|
|
4419
|
+
Na,
|
|
4195
4420
|
{
|
|
4196
4421
|
replace: rt,
|
|
4197
|
-
with: (e) => new
|
|
4198
|
-
withKlass:
|
|
4422
|
+
with: (e) => new Na(e.__text),
|
|
4423
|
+
withKlass: Na
|
|
4199
4424
|
}
|
|
4200
4425
|
]
|
|
4201
4426
|
}), [t]),
|
|
4202
|
-
children: /* @__PURE__ */ y(
|
|
4427
|
+
children: /* @__PURE__ */ y(ys, { ...e })
|
|
4203
4428
|
});
|
|
4204
4429
|
};
|
|
4205
|
-
|
|
4430
|
+
ws.displayName = "BsyLexicalEditor";
|
|
4206
4431
|
//#endregion
|
|
4207
|
-
export {
|
|
4432
|
+
export { we as $getRoot, q as BaseButton, ls as EditorHtmlPreview, ws as default, Sa as listRegisteredToolbarButtons, ya as registerToolbarButton, ba as unregisterToolbarButton, ct as useLexicalComposerContext };
|