@baishuyun/ui-base 6.16.1 → 6.18.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/Amap-CNsoge6e.js +826 -0
- package/dist/Amap/index.js +3 -10
- package/dist/Calendar/Calendar-Dk6FVbJ2.js +1608 -0
- package/dist/Calendar/index.js +10 -20
- package/dist/Card/index.js +2 -2
- package/dist/CheckBox/{CheckBox-B92dxWNo.js → CheckBox-CM24-quL.js} +1 -1
- package/dist/CheckBox/index.js +3 -3
- package/dist/ColorPicker/{ColorPicker-CPr5j6ZN.js → ColorPicker-B_wLqurt.js} +5 -5
- package/dist/ColorPicker/index.js +5 -5
- package/dist/ConfigProvider/index.js +1 -1
- package/dist/DatePicker/DatePicker-CItkTpdZ.js +111 -0
- package/dist/DatePicker/{DatePickerPanel-CtLwYPmz.js → DatePickerPanel-DJXmFihs.js} +3 -4
- package/dist/DatePicker/index.js +6 -8
- package/dist/DatePicker/pickerLocale-Brf7_Tnd.js +30 -0
- package/dist/DropDown/{DropDown-Bi0TsCc_.js → DropDown-B_szM67V.js} +86 -82
- package/dist/DropDown/index.js +8 -9
- package/dist/Editor/index.js +2934 -961
- package/dist/Gantt/index.js +3055 -197
- package/dist/Icon/index.js +1 -1
- package/dist/InputTag/{InputTag-BfZycXw4.js → InputTag-C_5nm0eo.js} +2 -2
- package/dist/InputTag/index.js +4 -4
- package/dist/Loading/{Loading-DpbJSRYf.js → Loading-Cherk9Ax.js} +1 -1
- package/dist/Loading/index.js +3 -3
- package/dist/Modal/index.js +2 -2
- package/dist/NotFoundContent/index.js +2 -2
- package/dist/Overlay/index.js +1 -1
- package/dist/Radio/index.js +2 -2
- package/dist/ScrollBar/{ScrollBar-N2pOLv-8.js → ScrollBar-IMTuAOF5.js} +1 -1
- package/dist/ScrollBar/index.js +2 -2
- package/dist/Segmented/{Segmented-BCQRrc65.js → Segmented-DpmwFerw.js} +1 -1
- package/dist/Segmented/index.js +2 -2
- package/dist/Select/{Select-CB5FqBui.js → Select-VIy6OKEj.js} +257 -253
- package/dist/Select/{SelectInputSearch-DUAv2vE4.js → SelectInputSearch-MApQHnU9.js} +1 -1
- package/dist/Select/index.js +12 -13
- package/dist/Table/Table-8ac6xLZv.js +808 -0
- package/dist/Table/index.js +4 -8
- package/dist/Tabs/{Tabs-B9uCGlxM.js → Tabs-DnoZ8BO0.js} +3 -3
- package/dist/Tabs/index.js +4 -4
- package/dist/Tooltip/{Tooltip-nJU13gX4.js → Tooltip-DBrt3t2r.js} +3 -3
- package/dist/Tooltip/index.js +3 -3
- package/dist/Tree/index.js +4 -4
- package/dist/components/Editor/EditorHtmlPreview.d.ts +3 -0
- package/dist/components/Editor/Preview/EditorPreview.d.ts +1 -1
- package/dist/components/Editor/Preview/HtmlPreview.d.ts +2 -3
- package/dist/components/Editor/Preview/PolishModal.d.ts +0 -1
- package/dist/components/Editor/Preview/TypesetModal.d.ts +0 -1
- package/dist/components/Editor/Preview/useAiPreviewHtml.d.ts +8 -0
- package/dist/components/Editor/__tests__/createTestEditor.d.ts +1 -0
- package/dist/components/Editor/commands/ImageCommands.d.ts +1 -0
- package/dist/components/Editor/constants/portableEditorStyles.d.ts +2 -0
- package/dist/components/Editor/context/EditorContainerContext.d.ts +3 -2
- package/dist/components/Editor/hooks/useEditorFocus.d.ts +1 -0
- package/dist/components/Editor/hooks/useTextFormatsState.d.ts +1 -2
- package/dist/components/Editor/index.d.ts +1 -0
- package/dist/components/Editor/nodes/ExtendedLinkNode.d.ts +9 -0
- package/dist/components/Editor/nodes/ImageComponent.d.ts +1 -0
- package/dist/components/Editor/nodes/ImageNode.d.ts +5 -2
- package/dist/components/Editor/utils/getToolbarItems.d.ts +14 -0
- package/dist/components/Editor/utils/placeProgrammaticCaret.d.ts +5 -0
- package/dist/components/Editor/utils/readTextFormats.d.ts +6 -0
- package/dist/components/Editor/utils/retainCodeSelection.d.ts +3 -0
- package/dist/index.js +28 -50
- package/dist/style.css +1 -1
- package/dist/vendors/Tree-D0Q1IZ2D.js +267 -0
- package/dist/vendors/{version-Dzs4mguZ.js → version-BucxnUKs.js} +1 -1
- package/package.json +1 -1
- package/dist/Amap/Amap-BLSziesG.js +0 -77
- package/dist/Amap/AmapCircle/index.js +0 -5
- package/dist/Amap/AmapCircle-2qupysHe.js +0 -55
- package/dist/Amap/AmapContext-CJBe6lld.js +0 -11
- package/dist/Amap/AmapMarker/index.js +0 -6
- package/dist/Amap/AmapMarker-xEqoVnFR.js +0 -153
- package/dist/Amap/AmapMarkerCluster/index.js +0 -6
- package/dist/Amap/AmapMarkerCluster-CvEQa3o9.js +0 -240
- package/dist/Amap/AmapProvider/index.js +0 -7
- package/dist/Amap/AmapProvider-B-R2DrkJ.js +0 -107
- package/dist/Amap/hooks/index.js +0 -4
- package/dist/Amap/hooks-BTcFpdd0.js +0 -121
- package/dist/Amap/useMarkerInfoWindowController-Cjx0xQXw.js +0 -94
- package/dist/Calendar/AllDaySection-pO7suGJM.js +0 -53
- package/dist/Calendar/Calendar-Cjagi7mU.js +0 -795
- package/dist/Calendar/CurrentTimeIndicator-BF3_INSL.js +0 -65
- package/dist/Calendar/EventCard-DKEZQRTp.js +0 -155
- package/dist/Calendar/TimeAxis-DUc6EL-j.js +0 -13
- package/dist/Calendar/TimeGrid-BV8x9VnF.js +0 -47
- package/dist/Calendar/colorUtils-BbeSMnOs.js +0 -55
- package/dist/Calendar/context/index.js +0 -3
- package/dist/Calendar/context-CamSpkj3.js +0 -21
- package/dist/Calendar/layout-CpOabFQ2.js +0 -300
- package/dist/Calendar/subcomponents/AllDaySection/index.js +0 -11
- package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +0 -8
- package/dist/Calendar/subcomponents/EventCard/index.js +0 -9
- package/dist/Calendar/subcomponents/TimeAxis/index.js +0 -5
- package/dist/Calendar/subcomponents/TimeGrid/index.js +0 -7
- package/dist/Calendar/theme-Dc8hjcdo.js +0 -71
- package/dist/Calendar/utils/index.js +0 -111
- package/dist/Calendar/utils/layout/index.js +0 -4
- package/dist/Calendar/utils/theme/index.js +0 -3
- package/dist/DatePicker/DatePicker-neAwNSsc.js +0 -101
- package/dist/DatePicker/ensureDayjsPlugins-CSqhjLS7.js +0 -15
- package/dist/DatePicker/pickerLocale-CcPLUbZO.js +0 -15
- package/dist/DatePicker/style/index.js +0 -3
- package/dist/DatePicker/style-W7f5wyUb.js +0 -15
- package/dist/DropDown/style/index.js +0 -3
- package/dist/DropDown/style-DZpkarne.js +0 -9
- package/dist/Editor/Buttons-OwLs5bxR.js +0 -1841
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +0 -21
- package/dist/Editor/constants/index.js +0 -61
- package/dist/Gantt/GanttChart/index.js +0 -21
- package/dist/Gantt/GanttChart-CDnF5qcc.js +0 -2292
- package/dist/Gantt/GanttHighlightContext-dtyoq-oj.js +0 -12
- package/dist/Gantt/GanttTable/index.js +0 -13
- package/dist/Gantt/GanttTable-fOv1Zn2-.js +0 -84
- package/dist/Gantt/GanttToolBar/index.js +0 -17
- package/dist/Gantt/GanttToolBar-BAoiWAHI.js +0 -120
- package/dist/Gantt/collapseKeys-BV_8sIA-.js +0 -160
- package/dist/Gantt/columnResize-Bkenlbab.js +0 -46
- package/dist/Gantt/constants-mEGQ1U1Q.js +0 -39
- package/dist/Gantt/highlightTarget-D3Nf9_7S.js +0 -25
- package/dist/Gantt/theme-B7Iap-tZ.js +0 -31
- package/dist/Gantt/timelineViewConfig-DNt7yi83.js +0 -118
- package/dist/Gantt/utils/index.js +0 -7
- package/dist/Gantt/utils/theme/index.js +0 -3
- package/dist/Select/style/index.js +0 -3
- package/dist/Select/style-C4A8kUd1.js +0 -9
- package/dist/Table/Table-3LSO0xSH.js +0 -545
- package/dist/Table/constants-D7wLH8Qy.js +0 -25
- package/dist/Table/hooks/index.js +0 -3
- package/dist/Table/hooks-DSBl2e4O.js +0 -108
- package/dist/Table/processRowspan-B6HMqw0Q.js +0 -144
- package/dist/Table/style/index.js +0 -3
- package/dist/Table/style-B8Cw8HJe.js +0 -9
- package/dist/Table/utils/index.js +0 -3
- package/dist/Tree/utils/index.js +0 -26
- package/dist/vendors/Tree-DSl4lDjx.js +0 -248
- /package/dist/Card/{Card-rJeWgxu5.js → Card-DAz0dvA3.js} +0 -0
- /package/dist/CheckBox/{CheckBox-DOK5N7z6.js → CheckBox-CcHskTz_.js} +0 -0
- /package/dist/Modal/{Modal-CRKitOOj.js → Modal-eZijJ7CB.js} +0 -0
- /package/dist/NotFoundContent/{NotFoundContent-BLmzWNBi.js → NotFoundContent-DJUQ0_2D.js} +0 -0
- /package/dist/Radio/{Radio-CX9cUqb7.js → Radio-D9jhW7K6.js} +0 -0
- /package/dist/vendors/{animations-Dn_5xJ7B.js → animations-ISccYUE3.js} +0 -0
- /package/dist/vendors/{cssVars-l4-kP_14.js → cssVars-UpriQzph.js} +0 -0
- /package/dist/vendors/{mergeRefs-TiJ0xjUN.js → mergeRefs-mEH9TBYV.js} +0 -0
- /package/dist/vendors/{useFloatingOverlay-B3M9k8nj.js → useFloatingOverlay-B66lOL8v.js} +0 -0
- /package/dist/vendors/{useFloatingPortal-VpzL-EPh.js → useFloatingPortal-DJ1iKmW-.js} +0 -0
- /package/dist/vendors/{useLatchedPopupPortalRoot-4fVhqVT4.js → useLatchedPopupPortalRoot-CC6af8t-.js} +0 -0
- /package/dist/vendors/{useLocale-D31qCCff.js → useLocale-Be4e7Xfn.js} +0 -0
package/dist/Editor/index.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-BucxnUKs.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";
|
|
5
|
-
import "../Overlay/OverlayContext-CVSFoyqN.js";
|
|
6
|
-
import
|
|
7
|
-
import "../
|
|
8
|
-
import "../
|
|
9
|
-
import
|
|
10
|
-
import "../vendors/
|
|
11
|
-
import {
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
16
|
-
import "../
|
|
17
|
-
import { t as
|
|
18
|
-
import "../
|
|
19
|
-
import { t as
|
|
20
|
-
import "../
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
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
|
|
39
|
-
import { $
|
|
40
|
-
import { $
|
|
41
|
-
import { $
|
|
42
|
-
import { $
|
|
43
|
-
import { $
|
|
44
|
-
import { $
|
|
45
|
-
import { $
|
|
46
|
-
import
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
|
|
5
|
+
import { a as t, i as n } from "../Overlay/OverlayContext-CVSFoyqN.js";
|
|
6
|
+
import "../Overlay/index.js";
|
|
7
|
+
import { t as r } from "../Modal/Modal-eZijJ7CB.js";
|
|
8
|
+
import { t as i } from "../ColorPicker/ColorPicker-B_wLqurt.js";
|
|
9
|
+
import "../vendors/useFloatingOverlay-B66lOL8v.js";
|
|
10
|
+
import { t as a } from "../vendors/useLocale-Be4e7Xfn.js";
|
|
11
|
+
import { r as o } from "../vendors/animations-ISccYUE3.js";
|
|
12
|
+
import "../vendors/useLatchedPopupPortalRoot-CC6af8t-.js";
|
|
13
|
+
import { t as s } from "../vendors/cssVars-UpriQzph.js";
|
|
14
|
+
import { t as c } from "../Tooltip/Tooltip-DBrt3t2r.js";
|
|
15
|
+
import "../Select/SelectInputSearch-MApQHnU9.js";
|
|
16
|
+
import "../CheckBox/CheckBox-CcHskTz_.js";
|
|
17
|
+
import { t as l } from "../CheckBox/CheckBox-CM24-quL.js";
|
|
18
|
+
import "../NotFoundContent/NotFoundContent-DJUQ0_2D.js";
|
|
19
|
+
import { t as u } from "../ScrollBar/ScrollBar-IMTuAOF5.js";
|
|
20
|
+
import { t as d } from "../vendors/useFloatingPortal-DJ1iKmW-.js";
|
|
21
|
+
import { t as f } from "../DropDown/DropDown-B_szM67V.js";
|
|
22
|
+
import { dropRightWhile as p, dropWhile as m, keyBy as h, omit as g, range as _ } from "lodash-es";
|
|
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 k, useImperativeHandle as A, useLayoutEffect as j, useMemo as M, useRef as N, useState as P } from "react";
|
|
25
|
+
import { Button as F, Form as ee, Input as te, message as ne } from "antd";
|
|
26
|
+
import I from "clsx";
|
|
27
|
+
import { useDocumentVisibility as re, 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 L, $getSelection as R, $insertNodes as Te, $isElementNode as Ee, $isLineBreakNode as De, $isRangeSelection as z, $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, REDO_COMMAND as et, RootNode as tt, TextNode as nt, UNDO_COMMAND as rt, createCommand as it, isHTMLElement as at, mergeRegister as ot } from "lexical";
|
|
38
|
+
import { useLexicalComposerContext as st, useLexicalComposerContext as B } from "@lexical/react/LexicalComposerContext";
|
|
39
|
+
import { $createLinkNode as ct, $isLinkNode as lt, $toggleLink as ut, AutoLinkNode as dt, LinkNode as ft, TOGGLE_LINK_COMMAND as pt } from "@lexical/link";
|
|
40
|
+
import { $isListItemNode as mt, $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, $restoreEditorState as Jt, mergeRegister as Yt } from "@lexical/utils";
|
|
46
|
+
import Xt from "dompurify";
|
|
47
|
+
import { useLexicalEditable as Zt } from "@lexical/react/useLexicalEditable";
|
|
48
|
+
import { LinkPlugin as Qt } from "@lexical/react/LexicalLinkPlugin";
|
|
49
|
+
import { ListPlugin as $t } from "@lexical/react/LexicalListPlugin";
|
|
50
|
+
var U = {
|
|
50
51
|
imageWrapper: "_imageWrapper_y06h3_1",
|
|
51
52
|
selected: "_selected_y06h3_8",
|
|
52
53
|
resizing: "_resizing_y06h3_12",
|
|
@@ -56,22 +57,22 @@ var J = {
|
|
|
56
57
|
topRight: "_topRight_y06h3_49",
|
|
57
58
|
bottomLeft: "_bottomLeft_y06h3_54",
|
|
58
59
|
bottomRight: "_bottomRight_y06h3_59"
|
|
59
|
-
},
|
|
60
|
-
let [
|
|
60
|
+
}, en = ({ src: e, altText: t, width: n, height: r, dataId: i, dataSrc: a, nodeKey: o }) => {
|
|
61
|
+
let [s] = B(), [c, l] = P(!1), [u, d] = P(null), f = N(null), [p, m] = P({
|
|
61
62
|
width: n || void 0,
|
|
62
63
|
height: r || void 0
|
|
63
|
-
}),
|
|
64
|
-
n && r &&
|
|
64
|
+
}), h = T(() => {
|
|
65
|
+
n && r && m({
|
|
65
66
|
width: n,
|
|
66
67
|
height: r
|
|
67
68
|
});
|
|
68
|
-
}, [n, r]),
|
|
69
|
-
if (e.preventDefault(), e.stopPropagation(), !
|
|
70
|
-
let n =
|
|
71
|
-
(!
|
|
69
|
+
}, [n, r]), g = T((e, t) => {
|
|
70
|
+
if (e.preventDefault(), e.stopPropagation(), !f.current) return;
|
|
71
|
+
let n = p.width || f.current.offsetWidth, r = p.height || f.current.offsetHeight, i = n / r;
|
|
72
|
+
(!p.width || !p.height) && m({
|
|
72
73
|
width: n,
|
|
73
74
|
height: r
|
|
74
|
-
}),
|
|
75
|
+
}), d({
|
|
75
76
|
isResizing: !0,
|
|
76
77
|
startX: e.clientX,
|
|
77
78
|
startY: e.clientY,
|
|
@@ -80,119 +81,121 @@ var J = {
|
|
|
80
81
|
aspectRatio: i,
|
|
81
82
|
direction: t
|
|
82
83
|
});
|
|
83
|
-
}, [
|
|
84
|
-
if (!
|
|
85
|
-
let t = e.clientX -
|
|
86
|
-
switch (
|
|
84
|
+
}, [p]), _ = T((e) => {
|
|
85
|
+
if (!u?.isResizing) return;
|
|
86
|
+
let t = e.clientX - u.startX, n;
|
|
87
|
+
switch (u.direction) {
|
|
87
88
|
case "bottom-right":
|
|
88
|
-
n = Math.max(50,
|
|
89
|
+
n = Math.max(50, u.startWidth + t);
|
|
89
90
|
break;
|
|
90
91
|
case "bottom-left":
|
|
91
|
-
n = Math.max(50,
|
|
92
|
+
n = Math.max(50, u.startWidth - t);
|
|
92
93
|
break;
|
|
93
94
|
case "top-right":
|
|
94
|
-
n = Math.max(50,
|
|
95
|
+
n = Math.max(50, u.startWidth + t);
|
|
95
96
|
break;
|
|
96
97
|
case "top-left":
|
|
97
|
-
n = Math.max(50,
|
|
98
|
+
n = Math.max(50, u.startWidth - t);
|
|
98
99
|
break;
|
|
99
|
-
default: n = Math.max(50,
|
|
100
|
+
default: n = Math.max(50, u.startWidth + t);
|
|
100
101
|
}
|
|
101
|
-
let r = n /
|
|
102
|
-
|
|
102
|
+
let r = n / u.aspectRatio;
|
|
103
|
+
m({
|
|
103
104
|
width: n,
|
|
104
105
|
height: r
|
|
105
106
|
});
|
|
106
|
-
}, [
|
|
107
|
-
|
|
108
|
-
let e =
|
|
109
|
-
|
|
110
|
-
}),
|
|
107
|
+
}, [u]), S = T(() => {
|
|
108
|
+
u?.isResizing && (s.update(() => {
|
|
109
|
+
let e = Ce(o);
|
|
110
|
+
rn(e) && e.setWidthAndHeight(p.width, p.height);
|
|
111
|
+
}), d(null));
|
|
111
112
|
}, [
|
|
113
|
+
s,
|
|
112
114
|
o,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
l
|
|
115
|
+
p,
|
|
116
|
+
u
|
|
116
117
|
]);
|
|
117
|
-
|
|
118
|
-
if (
|
|
119
|
-
document.removeEventListener("mousemove",
|
|
118
|
+
x.useEffect(() => {
|
|
119
|
+
if (u?.isResizing) return document.addEventListener("mousemove", _), document.addEventListener("mouseup", S), () => {
|
|
120
|
+
document.removeEventListener("mousemove", _), document.removeEventListener("mouseup", S);
|
|
120
121
|
};
|
|
121
122
|
}, [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
u,
|
|
124
|
+
_,
|
|
125
|
+
S
|
|
125
126
|
]);
|
|
126
|
-
let
|
|
127
|
-
|
|
127
|
+
let C = T(() => {
|
|
128
|
+
l(!0);
|
|
128
129
|
}, []);
|
|
129
|
-
return
|
|
130
|
+
return O(() => s.registerUpdateListener(({ editorState: e }) => {
|
|
130
131
|
e.read(() => {
|
|
131
|
-
let e =
|
|
132
|
-
|
|
132
|
+
let e = R();
|
|
133
|
+
z(e) && !e.getNodes().some((e) => e.getKey() === o || e.getParent() && e.getParent()?.getKey() === o) && c && l(!1);
|
|
133
134
|
});
|
|
134
135
|
}), [
|
|
136
|
+
s,
|
|
135
137
|
o,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
]), F(() => {
|
|
138
|
+
c
|
|
139
|
+
]), O(() => {
|
|
139
140
|
let e = (e) => {
|
|
140
|
-
|
|
141
|
+
c && f.current && !f.current.contains(e.target) && l(!1);
|
|
141
142
|
};
|
|
142
|
-
if (
|
|
143
|
+
if (c) return document.addEventListener("mousedown", e), () => {
|
|
143
144
|
document.removeEventListener("mousedown", e);
|
|
144
145
|
};
|
|
145
|
-
}, [
|
|
146
|
-
className:
|
|
147
|
-
[
|
|
148
|
-
[
|
|
146
|
+
}, [c]), /* @__PURE__ */ b("div", {
|
|
147
|
+
className: I(U.imageWrapper, {
|
|
148
|
+
[U.selected]: c,
|
|
149
|
+
[U.resizing]: u?.isResizing
|
|
149
150
|
}),
|
|
150
|
-
children: [/* @__PURE__ */
|
|
151
|
-
ref:
|
|
151
|
+
children: [/* @__PURE__ */ y("img", {
|
|
152
|
+
ref: f,
|
|
152
153
|
src: e,
|
|
153
154
|
alt: t,
|
|
154
155
|
"data-id": i,
|
|
155
|
-
|
|
156
|
+
"data-src": a,
|
|
157
|
+
className: U.image,
|
|
156
158
|
style: {
|
|
157
|
-
width:
|
|
158
|
-
height:
|
|
159
|
+
width: p.width,
|
|
160
|
+
height: p.height
|
|
159
161
|
},
|
|
160
|
-
onLoad:
|
|
161
|
-
onClick:
|
|
162
|
+
onLoad: h,
|
|
163
|
+
onClick: C,
|
|
162
164
|
draggable: !1
|
|
163
|
-
}),
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
className:
|
|
166
|
-
onMouseDown: (e) =>
|
|
165
|
+
}), c && /* @__PURE__ */ b(v, { children: [
|
|
166
|
+
/* @__PURE__ */ y("div", {
|
|
167
|
+
className: I(U.resizeHandle, U.bottomRight),
|
|
168
|
+
onMouseDown: (e) => g(e, "bottom-right")
|
|
167
169
|
}),
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
className:
|
|
170
|
-
onMouseDown: (e) =>
|
|
170
|
+
/* @__PURE__ */ y("div", {
|
|
171
|
+
className: I(U.resizeHandle, U.bottomLeft),
|
|
172
|
+
onMouseDown: (e) => g(e, "bottom-left")
|
|
171
173
|
}),
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
className:
|
|
174
|
-
onMouseDown: (e) =>
|
|
174
|
+
/* @__PURE__ */ y("div", {
|
|
175
|
+
className: I(U.resizeHandle, U.topRight),
|
|
176
|
+
onMouseDown: (e) => g(e, "top-right")
|
|
175
177
|
}),
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
className:
|
|
178
|
-
onMouseDown: (e) =>
|
|
178
|
+
/* @__PURE__ */ y("div", {
|
|
179
|
+
className: I(U.resizeHandle, U.topLeft),
|
|
180
|
+
onMouseDown: (e) => g(e, "top-left")
|
|
179
181
|
})
|
|
180
182
|
] })]
|
|
181
183
|
});
|
|
182
|
-
},
|
|
184
|
+
}, tn = class e extends Ue {
|
|
183
185
|
__src;
|
|
184
186
|
__altText;
|
|
185
187
|
__width;
|
|
186
188
|
__height;
|
|
187
189
|
__dataId;
|
|
190
|
+
__dataSrc;
|
|
188
191
|
static getType() {
|
|
189
192
|
return "image";
|
|
190
193
|
}
|
|
191
194
|
static clone(t) {
|
|
192
|
-
return new e(t.__src, t.__altText, t.__width, t.__height, t.__key, t.__dataId);
|
|
195
|
+
return new e(t.__src, t.__altText, t.__width, t.__height, t.__key, t.__dataId, t.__dataSrc);
|
|
193
196
|
}
|
|
194
|
-
constructor(e, t, n, r, i, a) {
|
|
195
|
-
super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r, this.__dataId = a;
|
|
197
|
+
constructor(e, t, n, r, i, a, o) {
|
|
198
|
+
super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r, this.__dataId = a, this.__dataSrc = o;
|
|
196
199
|
}
|
|
197
200
|
createDOM() {
|
|
198
201
|
let e = document.createElement("div");
|
|
@@ -203,7 +206,7 @@ var J = {
|
|
|
203
206
|
}
|
|
204
207
|
exportDOM() {
|
|
205
208
|
let e = document.createElement("img");
|
|
206
|
-
return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.style.maxWidth = "100%", e.style.display = "inline", e.style.verticalAlign = "baseline", this.__width && e.setAttribute("width", this.__width.toString()), this.__height && e.setAttribute("height", this.__height.toString()), this.__dataId && e.setAttribute("data-id", this.__dataId), { element: e };
|
|
209
|
+
return e.setAttribute("src", this.__src), e.setAttribute("alt", this.__altText), e.style.maxWidth = "100%", e.style.display = "inline", e.style.verticalAlign = "baseline", this.__width && e.setAttribute("width", this.__width.toString()), this.__height && e.setAttribute("height", this.__height.toString()), this.__dataId && e.setAttribute("data-id", this.__dataId), this.__dataSrc && e.setAttribute("data-src", this.__dataSrc), { element: e };
|
|
207
210
|
}
|
|
208
211
|
getSrc() {
|
|
209
212
|
return this.__src;
|
|
@@ -233,29 +236,31 @@ var J = {
|
|
|
233
236
|
n.__width = e, n.__height = t;
|
|
234
237
|
}
|
|
235
238
|
decorate() {
|
|
236
|
-
return /* @__PURE__ */
|
|
239
|
+
return /* @__PURE__ */ y(en, {
|
|
237
240
|
src: this.__src,
|
|
238
241
|
altText: this.__altText,
|
|
239
242
|
width: this.__width,
|
|
240
243
|
height: this.__height,
|
|
241
244
|
dataId: this.__dataId,
|
|
245
|
+
dataSrc: this.__dataSrc,
|
|
242
246
|
nodeKey: this.getKey()
|
|
243
247
|
});
|
|
244
248
|
}
|
|
245
249
|
static importDOM() {
|
|
246
250
|
return { img: () => ({
|
|
247
|
-
conversion:
|
|
251
|
+
conversion: an,
|
|
248
252
|
priority: 0
|
|
249
253
|
}) };
|
|
250
254
|
}
|
|
251
255
|
static importJSON(e) {
|
|
252
|
-
let { src: t, altText: n, width: r, height: i, dataId: a } = e;
|
|
253
|
-
return
|
|
256
|
+
let { src: t, altText: n, width: r, height: i, dataId: a, dataSrc: o } = e;
|
|
257
|
+
return nn({
|
|
254
258
|
src: t,
|
|
255
259
|
altText: n,
|
|
256
260
|
width: r,
|
|
257
261
|
height: i,
|
|
258
|
-
dataId: a
|
|
262
|
+
dataId: a,
|
|
263
|
+
dataSrc: o
|
|
259
264
|
});
|
|
260
265
|
}
|
|
261
266
|
exportJSON() {
|
|
@@ -265,6 +270,7 @@ var J = {
|
|
|
265
270
|
width: this.getWidth(),
|
|
266
271
|
height: this.getHeight(),
|
|
267
272
|
dataId: this.getDataId(),
|
|
273
|
+
dataSrc: this.__dataSrc,
|
|
268
274
|
type: "image",
|
|
269
275
|
version: 1
|
|
270
276
|
};
|
|
@@ -273,13 +279,13 @@ var J = {
|
|
|
273
279
|
return !0;
|
|
274
280
|
}
|
|
275
281
|
};
|
|
276
|
-
function
|
|
277
|
-
return new
|
|
282
|
+
function nn({ src: e, altText: t, width: n, height: r, dataId: i, dataSrc: a, key: o }) {
|
|
283
|
+
return new tn(e, t, n, r, o, i, a);
|
|
278
284
|
}
|
|
279
|
-
function
|
|
280
|
-
return e instanceof
|
|
285
|
+
function rn(e) {
|
|
286
|
+
return e instanceof tn;
|
|
281
287
|
}
|
|
282
|
-
function
|
|
288
|
+
function an(e) {
|
|
283
289
|
if (e instanceof HTMLImageElement) {
|
|
284
290
|
let { src: t, alt: n, style: r } = e, i, a;
|
|
285
291
|
if (r.width) {
|
|
@@ -291,37 +297,50 @@ function sn(e) {
|
|
|
291
297
|
isNaN(e) || (a = e);
|
|
292
298
|
}
|
|
293
299
|
i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height);
|
|
294
|
-
let o = e.getAttribute("data-id") || void 0;
|
|
295
|
-
return { node:
|
|
300
|
+
let o = e.getAttribute("data-id") || void 0, s = e.getAttribute("data-src") || void 0;
|
|
301
|
+
return { node: nn({
|
|
296
302
|
src: t,
|
|
297
303
|
altText: n,
|
|
298
304
|
width: i,
|
|
299
305
|
height: a,
|
|
300
|
-
dataId: o
|
|
306
|
+
dataId: o,
|
|
307
|
+
dataSrc: s
|
|
301
308
|
}) };
|
|
302
309
|
}
|
|
303
310
|
return null;
|
|
304
311
|
}
|
|
305
312
|
//#endregion
|
|
306
|
-
//#region src/components/Editor/
|
|
307
|
-
var
|
|
313
|
+
//#region src/components/Editor/constants/toolbarSize.ts
|
|
314
|
+
var on = "default", W = {
|
|
315
|
+
x: 0,
|
|
316
|
+
y: 5
|
|
317
|
+
}, sn = {
|
|
318
|
+
small: {
|
|
319
|
+
itemHeight: 20,
|
|
320
|
+
iconSize: 14
|
|
321
|
+
},
|
|
322
|
+
default: {
|
|
323
|
+
itemHeight: 30,
|
|
324
|
+
iconSize: 16
|
|
325
|
+
}
|
|
326
|
+
}, cn = (e) => {
|
|
308
327
|
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
309
|
-
},
|
|
310
|
-
let n =
|
|
311
|
-
"--bsy-editor-toolbar-item-height":
|
|
312
|
-
"--bsy-editor-toolbar-icon-size":
|
|
328
|
+
}, ln = (e, t = on) => {
|
|
329
|
+
let n = sn[t], r = cn(e?.itemHeight) ?? `${n.itemHeight}px`, i = cn(e?.iconSize) ?? `${n.iconSize}px`, a = {
|
|
330
|
+
"--bsy-editor-toolbar-item-height": r,
|
|
331
|
+
"--bsy-editor-toolbar-icon-size": i,
|
|
313
332
|
"--bsy-editor-toolbar-divider-color": "#e0e0e0",
|
|
314
333
|
"--bsy-editor-toolbar-item-highlight-color": "#0265ff"
|
|
315
334
|
};
|
|
316
|
-
return e ? (
|
|
317
|
-
},
|
|
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", cn(e.gap)), s(a, "--bsy-editor-toolbar-group-gap", cn(e.groupGap)), s(a, "--bsy-editor-toolbar-divider-color", e.dividerColor), s(a, "--bsy-editor-toolbar-divider-margin", cn(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", cn(e.itemPadding)), s(a, "--bsy-editor-toolbar-item-border-radius", cn(e.itemBorderRadius)), a) : a;
|
|
336
|
+
}, un = (e, t = on) => {
|
|
318
337
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
319
338
|
if (typeof e == "string") {
|
|
320
339
|
let t = Number.parseFloat(e);
|
|
321
340
|
if (Number.isFinite(t)) return t;
|
|
322
341
|
}
|
|
323
|
-
return
|
|
324
|
-
},
|
|
342
|
+
return sn[t].iconSize;
|
|
343
|
+
}, dn = (e) => {
|
|
325
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 = {
|
|
326
345
|
position: "absolute",
|
|
327
346
|
[a ? "bottom" : "top"]: "100%",
|
|
@@ -331,7 +350,7 @@ var Y = (e) => {
|
|
|
331
350
|
width: "100%"
|
|
332
351
|
};
|
|
333
352
|
return r && (o.transform = `translateX(${r}px)`), o;
|
|
334
|
-
},
|
|
353
|
+
}, fn = (e, t, n, r) => {
|
|
335
354
|
if (e.length === 0 || t <= 0 || e.reduce((e, t, n) => e + t.width + (n > 0 ? r : 0), 0) <= t) return e.length;
|
|
336
355
|
let i = 0, a = 0;
|
|
337
356
|
for (let o = 0; o < e.length; o++) {
|
|
@@ -341,153 +360,1999 @@ var Y = (e) => {
|
|
|
341
360
|
}
|
|
342
361
|
for (; a > 0 && e[a - 1]?.isDivider;) --a;
|
|
343
362
|
return a;
|
|
344
|
-
},
|
|
363
|
+
}, pn = (e, t) => {
|
|
345
364
|
let n = (e) => e.kind === "divider";
|
|
346
365
|
return {
|
|
347
366
|
visible: e.slice(0, t),
|
|
348
|
-
overflow:
|
|
367
|
+
overflow: p(m(e.slice(t), n), n)
|
|
349
368
|
};
|
|
350
|
-
}
|
|
369
|
+
}, G = {
|
|
370
|
+
"bsy-lexical__toolbar": "_bsy-lexical__toolbar_1wqto_1",
|
|
371
|
+
"bsy-lexical__toolbar--floating": "_bsy-lexical__toolbar--floating_1wqto_14",
|
|
372
|
+
"bsy-lexical__toolbar--sticky": "_bsy-lexical__toolbar--sticky_1wqto_19",
|
|
373
|
+
"bsy-lexical__toolbar-stack": "_bsy-lexical__toolbar-stack_1wqto_24",
|
|
374
|
+
"bsy-lexical__toolbar-items": "_bsy-lexical__toolbar-items_1wqto_34",
|
|
375
|
+
"bsy-lexical__toolbar-item": "_bsy-lexical__toolbar-item_1wqto_34",
|
|
376
|
+
"bsy-lexical__toolbar-item--disabled": "_bsy-lexical__toolbar-item--disabled_1wqto_49",
|
|
377
|
+
"bsy-lexical__toolbar-group": "_bsy-lexical__toolbar-group_1wqto_53",
|
|
378
|
+
"bsy-lexical__toolbar-divider": "_bsy-lexical__toolbar-divider_1wqto_59",
|
|
379
|
+
"bsy-lexical__toolbar-select": "_bsy-lexical__toolbar-select_1wqto_66",
|
|
380
|
+
"bsy-lexical__toolbar-select-label": "_bsy-lexical__toolbar-select-label_1wqto_84",
|
|
381
|
+
"bsy-lexical__toolbar-select-arrow": "_bsy-lexical__toolbar-select-arrow_1wqto_94",
|
|
382
|
+
"bsy-lexical__toolbar-select--ai": "_bsy-lexical__toolbar-select--ai_1wqto_98",
|
|
383
|
+
"bsy-lexical__toolbar-more-sizer": "_bsy-lexical__toolbar-more-sizer_1wqto_104",
|
|
384
|
+
"bsy-lexical__toolbar-overflow": "_bsy-lexical__toolbar-overflow_1wqto_112",
|
|
385
|
+
"bsy-lexical__toolbar-overflow-row": "_bsy-lexical__toolbar-overflow-row_1wqto_116",
|
|
386
|
+
"bsy-lexical__toolbar-overflow-row--open": "_bsy-lexical__toolbar-overflow-row--open_1wqto_124",
|
|
387
|
+
"bsy-lexical__toolbar-overflow-row--instant": "_bsy-lexical__toolbar-overflow-row--instant_1wqto_128",
|
|
388
|
+
"bsy-lexical__toolbar-overflow-inner": "_bsy-lexical__toolbar-overflow-inner_1wqto_132",
|
|
389
|
+
"bsy-lexical__toolbar-with-divider": "_bsy-lexical__toolbar-with-divider_1wqto_140"
|
|
390
|
+
}, mn = S(null), hn = [
|
|
391
|
+
{
|
|
392
|
+
label: "12",
|
|
393
|
+
value: "12px"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
label: "14",
|
|
397
|
+
value: "14px"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
label: "16",
|
|
401
|
+
value: "16px"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
label: "18",
|
|
405
|
+
value: "18px"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
label: "20",
|
|
409
|
+
value: "20px"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
label: "22",
|
|
413
|
+
value: "22px"
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
label: "24",
|
|
417
|
+
value: "24px"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
label: "28",
|
|
421
|
+
value: "28px"
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
label: "32",
|
|
425
|
+
value: "32px"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
label: "36",
|
|
429
|
+
value: "36px"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
label: "64",
|
|
433
|
+
value: "64px"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
label: "128",
|
|
437
|
+
value: "128px"
|
|
438
|
+
}
|
|
439
|
+
], gn = "16px", _n = "#000", vn = "transparent", yn = [
|
|
440
|
+
"jpg",
|
|
441
|
+
"jpeg",
|
|
442
|
+
"png",
|
|
443
|
+
"gif",
|
|
444
|
+
"bmp",
|
|
445
|
+
"tif"
|
|
446
|
+
], bn = yn.map((e) => `.${e}`).join(","), xn = "plaintext", Sn = "github-light", Cn = [
|
|
447
|
+
{
|
|
448
|
+
id: "plaintext",
|
|
449
|
+
label: "Plain text"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
id: "css",
|
|
453
|
+
label: "CSS"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
id: "html",
|
|
457
|
+
label: "HTML"
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
id: "xml",
|
|
461
|
+
label: "XML"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
id: "javascript",
|
|
465
|
+
label: "JavaScript"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
id: "typescript",
|
|
469
|
+
label: "TypeScript"
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
id: "jsx",
|
|
473
|
+
label: "JSX"
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
id: "go",
|
|
477
|
+
label: "Go"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
id: "php",
|
|
481
|
+
label: "PHP"
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
id: "c",
|
|
485
|
+
label: "C"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
id: "python",
|
|
489
|
+
label: "Python"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
id: "java",
|
|
493
|
+
label: "Java"
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
id: "cpp",
|
|
497
|
+
label: "C++"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
id: "csharp",
|
|
501
|
+
label: "C#"
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
id: "vb",
|
|
505
|
+
label: "Visual Basic"
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
id: "sql",
|
|
509
|
+
label: "SQL"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
id: "ruby",
|
|
513
|
+
label: "Ruby"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
id: "swift",
|
|
517
|
+
label: "Swift"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
id: "bash",
|
|
521
|
+
label: "Bash"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
id: "lua",
|
|
525
|
+
label: "Lua"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
id: "markdown",
|
|
529
|
+
label: "Markdown"
|
|
530
|
+
}
|
|
531
|
+
], wn = h(Cn, "id"), Tn = (e) => e && wn[e] ? e : xn, En = (e) => e === "center" || e === "right" || e === "left" ? e : e === "end" ? "right" : "left", Dn = (e) => {
|
|
532
|
+
if (e) {
|
|
533
|
+
L().selectStart();
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
Ne(null);
|
|
537
|
+
}, On = (e) => {
|
|
538
|
+
let t = e.getRootElement();
|
|
539
|
+
Dn(!!(t && document.activeElement && t.contains(document.activeElement)));
|
|
540
|
+
}, kn = () => {
|
|
541
|
+
R() === null && L().selectStart();
|
|
542
|
+
}, K = (e) => {
|
|
543
|
+
e.isEditable() || e.setEditable(!0), e.update(() => {
|
|
544
|
+
kn();
|
|
545
|
+
}), e.focus(void 0, { defaultSelection: "rootStart" });
|
|
546
|
+
}, An = {
|
|
547
|
+
bold: !1,
|
|
548
|
+
italic: !1,
|
|
549
|
+
underline: !1,
|
|
550
|
+
strikethrough: !1,
|
|
551
|
+
superscript: !1,
|
|
552
|
+
subscript: !1,
|
|
553
|
+
fontSize: gn,
|
|
554
|
+
fontColor: _n,
|
|
555
|
+
backgroundColor: vn,
|
|
556
|
+
align: "left",
|
|
557
|
+
listType: !1,
|
|
558
|
+
canOutdent: !1,
|
|
559
|
+
isCodeBlock: !1,
|
|
560
|
+
isInTable: !1,
|
|
561
|
+
headingTag: !1,
|
|
562
|
+
codeLanguage: xn,
|
|
563
|
+
hasEditorText: !1,
|
|
564
|
+
link: void 0
|
|
565
|
+
}, jn = (e) => {
|
|
566
|
+
let t = !!L().getTextContent().trim(), n = {
|
|
567
|
+
...An,
|
|
568
|
+
hasEditorText: t
|
|
569
|
+
};
|
|
570
|
+
if (!e) return n;
|
|
571
|
+
let r = R();
|
|
572
|
+
if (It(r)) return {
|
|
573
|
+
...n,
|
|
574
|
+
isInTable: !0
|
|
575
|
+
};
|
|
576
|
+
if (!z(r)) return n;
|
|
577
|
+
let i = Ot(r, "font-size", gn), a = Ot(r, "color", _n), o = Ot(r, "background-color", vn), s = r.anchor.getNode(), c = s.getKey() === "root" ? s : H(s, (e) => {
|
|
578
|
+
let t = e.getParent();
|
|
579
|
+
return t !== null && Oe(t);
|
|
580
|
+
});
|
|
581
|
+
c === null && (c = s.getTopLevelElementOrThrow());
|
|
582
|
+
let l = {}, u = H(s, lt);
|
|
583
|
+
u ? (l.link = u.getURL(), l.linkText = u.getTextContent(), l.newBlank = u.getTarget() === "_blank") : l.linkText = r.getTextContent();
|
|
584
|
+
let d = H(s, mt), f = !1, p = Ee(c) ? c.getIndent() : 0;
|
|
585
|
+
if (mt(d)) {
|
|
586
|
+
p = d.getIndent();
|
|
587
|
+
let e = d.getParent();
|
|
588
|
+
if (ht(e)) {
|
|
589
|
+
let t = e.getListType();
|
|
590
|
+
f = t === "number" || t === "bullet" ? t : !1;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
let m = H(s, V), h = H(s, Kt), g = Kt(h) ? h.getTag() : void 0;
|
|
594
|
+
return {
|
|
595
|
+
bold: r.hasFormat("bold"),
|
|
596
|
+
italic: r.hasFormat("italic"),
|
|
597
|
+
underline: r.hasFormat("underline"),
|
|
598
|
+
strikethrough: r.hasFormat("strikethrough"),
|
|
599
|
+
superscript: r.hasFormat("superscript"),
|
|
600
|
+
subscript: r.hasFormat("subscript"),
|
|
601
|
+
fontSize: i,
|
|
602
|
+
fontColor: a,
|
|
603
|
+
backgroundColor: o,
|
|
604
|
+
align: En(Ee(c) ? c.getFormatType() : ""),
|
|
605
|
+
listType: f,
|
|
606
|
+
canOutdent: p > 0 || f !== !1,
|
|
607
|
+
isCodeBlock: !!m,
|
|
608
|
+
isInTable: !!H(s, Nt),
|
|
609
|
+
headingTag: g === "h1" || g === "h2" || g === "h3" ? g : !1,
|
|
610
|
+
codeLanguage: Tn(m?.getLanguage()),
|
|
611
|
+
hasEditorText: t,
|
|
612
|
+
link: l
|
|
613
|
+
};
|
|
614
|
+
}, Mn = (e, t) => {
|
|
615
|
+
e.isEditable() || e.setEditable(!0), e.update(() => {
|
|
616
|
+
kn(), t(jn(!0));
|
|
617
|
+
}), e.focus(void 0, { defaultSelection: "rootStart" });
|
|
618
|
+
}, Nn = (e) => {
|
|
619
|
+
let t = An;
|
|
620
|
+
return Mn(e, (e) => {
|
|
621
|
+
t = e;
|
|
622
|
+
}), t;
|
|
623
|
+
}, Pn = () => {
|
|
624
|
+
let [e] = B(), [t, n] = P(!1);
|
|
625
|
+
return O(() => Yt(e.registerCommand(We, () => (n(!0), !1), Ve), e.registerCommand(Pe, () => (n(!1), !1), Ve)), [e]), t;
|
|
626
|
+
}, Fn = () => {
|
|
627
|
+
let [e] = B(), t = Pn(), [n, r] = P(An);
|
|
628
|
+
return O(() => (e.getEditorState().read(() => {
|
|
629
|
+
r(jn(t));
|
|
630
|
+
}, { editor: e }), e.registerUpdateListener(({ editorState: n }) => {
|
|
631
|
+
n.read(() => {
|
|
632
|
+
r(jn(t));
|
|
633
|
+
}, { editor: e });
|
|
634
|
+
})), [e, t]), n;
|
|
635
|
+
}, In = (e) => {
|
|
636
|
+
let t = Fn();
|
|
637
|
+
return /* @__PURE__ */ y(mn.Provider, {
|
|
638
|
+
value: t,
|
|
639
|
+
children: e.children
|
|
640
|
+
});
|
|
641
|
+
}, Ln = S(null), Rn = () => {
|
|
642
|
+
let e = E(Ln);
|
|
643
|
+
if (!e) throw Error("useHistoryStateContext must be used within HistoryStateProvider");
|
|
644
|
+
return e;
|
|
645
|
+
}, zn = ({ children: e }) => {
|
|
646
|
+
let [t] = B(), [n, r] = P({
|
|
647
|
+
canUndo: !1,
|
|
648
|
+
canRedo: !1
|
|
649
|
+
});
|
|
650
|
+
return O(() => ot(t.registerCommand(Ie, (e) => (r((t) => t.canUndo === e ? t : {
|
|
651
|
+
...t,
|
|
652
|
+
canUndo: e
|
|
653
|
+
}), !1), Re), t.registerCommand(Fe, (e) => (r((t) => t.canRedo === e ? t : {
|
|
654
|
+
...t,
|
|
655
|
+
canRedo: e
|
|
656
|
+
}), !1), Re)), [t]), /* @__PURE__ */ y(Ln.Provider, {
|
|
657
|
+
value: n,
|
|
658
|
+
children: e
|
|
659
|
+
});
|
|
660
|
+
}, Bn = S({ iconSize: sn.default.iconSize }), Vn = Bn.Provider, Hn = () => E(Bn), Un = {
|
|
661
|
+
"lexical-editor__toolbar-button": "_lexical-editor__toolbar-button_dp4a1_1",
|
|
662
|
+
"lexical-editor__toolbar-button-active": "_lexical-editor__toolbar-button-active_dp4a1_26",
|
|
663
|
+
"lexical-editor__toolbar-button-highlight": "_lexical-editor__toolbar-button-highlight_dp4a1_30",
|
|
664
|
+
"lexical-editor__toolbar-button-tooltip-trigger": "_lexical-editor__toolbar-button-tooltip-trigger_dp4a1_36"
|
|
665
|
+
}, q = ({ icon: t, tooltip: n, onClick: r, disabled: i, showDisabledTooltip: a, active: o, highlight: s, size: l }) => {
|
|
666
|
+
let { iconSize: u } = Hn(), d = /* @__PURE__ */ y("button", {
|
|
667
|
+
className: I(Un["lexical-editor__toolbar-button"], {
|
|
668
|
+
[Un["lexical-editor__toolbar-button-active"]]: o,
|
|
669
|
+
[Un["lexical-editor__toolbar-button-highlight"]]: s
|
|
670
|
+
}),
|
|
671
|
+
type: "button",
|
|
672
|
+
onClick: r,
|
|
673
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
674
|
+
disabled: i,
|
|
675
|
+
children: x.isValidElement(t) ? t : /* @__PURE__ */ y(e, {
|
|
676
|
+
name: t,
|
|
677
|
+
size: l ?? u
|
|
678
|
+
})
|
|
679
|
+
});
|
|
680
|
+
return !n || i && !a ? d : /* @__PURE__ */ y(c, {
|
|
681
|
+
content: n,
|
|
682
|
+
minWidth: "auto",
|
|
683
|
+
children: i ? /* @__PURE__ */ y("span", {
|
|
684
|
+
className: Un["lexical-editor__toolbar-button-tooltip-trigger"],
|
|
685
|
+
children: d
|
|
686
|
+
}) : d
|
|
687
|
+
});
|
|
688
|
+
}, J = () => {
|
|
689
|
+
let e = E(mn);
|
|
690
|
+
if (!e) throw Error("useTextFormatsContext must be used within TextFormatsProvider");
|
|
691
|
+
return e;
|
|
692
|
+
}, Wn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
693
|
+
let [r] = B(), i = J(), { t: o } = a(), s = i.bold;
|
|
694
|
+
return /* @__PURE__ */ y(q, {
|
|
695
|
+
icon: "bold",
|
|
696
|
+
tooltip: t ?? o("editor.bold"),
|
|
697
|
+
showDisabledTooltip: n,
|
|
698
|
+
active: s,
|
|
699
|
+
disabled: e,
|
|
700
|
+
onClick: () => {
|
|
701
|
+
K(r), r.dispatchCommand(Ke, "bold");
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}, Gn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
705
|
+
let [r] = B(), i = J(), { t: o } = a(), s = i.underline;
|
|
706
|
+
return /* @__PURE__ */ y(q, {
|
|
707
|
+
icon: "underline",
|
|
708
|
+
tooltip: t ?? o("editor.underline"),
|
|
709
|
+
showDisabledTooltip: n,
|
|
710
|
+
active: s,
|
|
711
|
+
disabled: e,
|
|
712
|
+
onClick: () => {
|
|
713
|
+
K(r), r.dispatchCommand(Ke, "underline");
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}, Kn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
717
|
+
let [r] = B(), i = J(), { t: o } = a(), s = i.italic;
|
|
718
|
+
return /* @__PURE__ */ y(q, {
|
|
719
|
+
icon: "italic",
|
|
720
|
+
tooltip: t ?? o("editor.italic"),
|
|
721
|
+
showDisabledTooltip: n,
|
|
722
|
+
active: s,
|
|
723
|
+
disabled: e,
|
|
724
|
+
onClick: () => {
|
|
725
|
+
K(r), r.dispatchCommand(Ke, "italic");
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
}, qn = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
729
|
+
let [r] = B(), { t: i } = a(), { fontSize: o, headingTag: s } = J(), c = M(() => hn.map((e) => ({
|
|
730
|
+
key: e.value,
|
|
731
|
+
label: e.label
|
|
732
|
+
})), []), l = T((e) => {
|
|
733
|
+
let t = e.key;
|
|
734
|
+
K(r), r.update(() => {
|
|
735
|
+
let e = R();
|
|
736
|
+
z(e) && kt(e, { "font-size": t });
|
|
737
|
+
});
|
|
738
|
+
}, [r]);
|
|
739
|
+
return s || e ? /* @__PURE__ */ y(q, {
|
|
740
|
+
icon: "fontsize",
|
|
741
|
+
tooltip: t ?? i("editor.fontSize"),
|
|
742
|
+
showDisabledTooltip: n,
|
|
743
|
+
disabled: !0
|
|
744
|
+
}) : /* @__PURE__ */ y(f, {
|
|
745
|
+
menus: c,
|
|
746
|
+
onClick: l,
|
|
747
|
+
activeKey: [o],
|
|
748
|
+
showSearch: !1,
|
|
749
|
+
offset: W,
|
|
750
|
+
style: {
|
|
751
|
+
width: "60px",
|
|
752
|
+
minWidth: "60px"
|
|
753
|
+
},
|
|
754
|
+
children: /* @__PURE__ */ y("div", {
|
|
755
|
+
className: "dropdown__trigger inline-flex",
|
|
756
|
+
children: /* @__PURE__ */ y(q, {
|
|
757
|
+
icon: "fontsize",
|
|
758
|
+
tooltip: t ?? i("editor.fontSize"),
|
|
759
|
+
showDisabledTooltip: n,
|
|
760
|
+
active: !1
|
|
761
|
+
})
|
|
762
|
+
})
|
|
763
|
+
});
|
|
764
|
+
}, Jn = "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", Yn = "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", Xn = 860.48, Zn = 99.52, Qn = /rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0(?:\.0+)?\s*\)/, $n = {
|
|
765
|
+
fontColor: {
|
|
766
|
+
path: Jn,
|
|
767
|
+
clipHeight: Xn,
|
|
768
|
+
x: 128,
|
|
769
|
+
width: 768,
|
|
770
|
+
rx: 0
|
|
771
|
+
},
|
|
772
|
+
fill: {
|
|
773
|
+
path: Yn,
|
|
774
|
+
clipHeight: 816,
|
|
775
|
+
x: 112,
|
|
776
|
+
width: 800,
|
|
777
|
+
rx: 8
|
|
778
|
+
}
|
|
779
|
+
}, er = (e, t) => {
|
|
780
|
+
let n = t.trim().toLowerCase();
|
|
781
|
+
if (e === "fill") return !n || n === "transparent" || Qn.test(n);
|
|
782
|
+
let r = n.replace(/\s+/g, "");
|
|
783
|
+
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
|
+
}, tr = ({ variant: e, barColor: t, size: n }) => {
|
|
785
|
+
let r = `${k().replace(/:/g, "")}clip`, i = $n[e];
|
|
786
|
+
return /* @__PURE__ */ b("svg", {
|
|
787
|
+
width: n,
|
|
788
|
+
height: n,
|
|
789
|
+
viewBox: "0 0 1024 1024",
|
|
790
|
+
"aria-hidden": "true",
|
|
791
|
+
children: [
|
|
792
|
+
/* @__PURE__ */ y("defs", { children: /* @__PURE__ */ y("clipPath", {
|
|
793
|
+
id: r,
|
|
794
|
+
children: /* @__PURE__ */ y("rect", {
|
|
795
|
+
x: 0,
|
|
796
|
+
y: 0,
|
|
797
|
+
width: 1024,
|
|
798
|
+
height: i.clipHeight
|
|
799
|
+
})
|
|
800
|
+
}) }),
|
|
801
|
+
/* @__PURE__ */ y("path", {
|
|
802
|
+
d: i.path,
|
|
803
|
+
fill: "currentColor",
|
|
804
|
+
clipPath: `url(#${r})`
|
|
805
|
+
}),
|
|
806
|
+
/* @__PURE__ */ y("rect", {
|
|
807
|
+
x: i.x,
|
|
808
|
+
y: Xn,
|
|
809
|
+
width: i.width,
|
|
810
|
+
height: Zn,
|
|
811
|
+
rx: i.rx,
|
|
812
|
+
fill: er(e, t) ? "currentColor" : t
|
|
813
|
+
})
|
|
814
|
+
]
|
|
815
|
+
});
|
|
816
|
+
}, nr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
817
|
+
let [r] = B(), o = J(), { iconSize: s } = Hn(), { t: c } = a(), l = T((e) => {
|
|
818
|
+
K(r), r.update(() => {
|
|
819
|
+
let t = R();
|
|
820
|
+
z(t) && kt(t, { color: e });
|
|
821
|
+
});
|
|
822
|
+
}, [r]);
|
|
823
|
+
return /* @__PURE__ */ y(i, {
|
|
824
|
+
value: o.fontColor,
|
|
825
|
+
onChange: l,
|
|
826
|
+
placement: "bottom-start",
|
|
827
|
+
offset: W.y,
|
|
828
|
+
presetColors: "basic",
|
|
829
|
+
disabled: e,
|
|
830
|
+
children: /* @__PURE__ */ y("div", {
|
|
831
|
+
className: "trigger-picker inline-flex",
|
|
832
|
+
children: /* @__PURE__ */ y(q, {
|
|
833
|
+
icon: /* @__PURE__ */ y(tr, {
|
|
834
|
+
variant: "fontColor",
|
|
835
|
+
barColor: o.fontColor,
|
|
836
|
+
size: s
|
|
837
|
+
}),
|
|
838
|
+
tooltip: t ?? c("editor.fontColor"),
|
|
839
|
+
showDisabledTooltip: n,
|
|
840
|
+
disabled: e
|
|
841
|
+
})
|
|
842
|
+
})
|
|
843
|
+
});
|
|
844
|
+
}, rr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
845
|
+
let [r] = B(), o = J(), { iconSize: s } = Hn(), { t: c } = a(), l = T((e) => {
|
|
846
|
+
K(r), r.update(() => {
|
|
847
|
+
let t = R();
|
|
848
|
+
z(t) && kt(t, { "background-color": e });
|
|
849
|
+
});
|
|
850
|
+
}, [r]);
|
|
851
|
+
return /* @__PURE__ */ y(i, {
|
|
852
|
+
value: o.backgroundColor,
|
|
853
|
+
onChange: l,
|
|
854
|
+
placement: "bottom-start",
|
|
855
|
+
offset: W.y,
|
|
856
|
+
presetColors: "basic",
|
|
857
|
+
disabled: e,
|
|
858
|
+
children: /* @__PURE__ */ y("div", {
|
|
859
|
+
className: "trigger-picker inline-flex",
|
|
860
|
+
children: /* @__PURE__ */ y(q, {
|
|
861
|
+
icon: /* @__PURE__ */ y(tr, {
|
|
862
|
+
variant: "fill",
|
|
863
|
+
barColor: o.backgroundColor,
|
|
864
|
+
size: s
|
|
865
|
+
}),
|
|
866
|
+
tooltip: t ?? c("editor.fill"),
|
|
867
|
+
showDisabledTooltip: n,
|
|
868
|
+
disabled: e
|
|
869
|
+
})
|
|
870
|
+
})
|
|
871
|
+
});
|
|
872
|
+
}, ir = {
|
|
873
|
+
left: "paragraph",
|
|
874
|
+
center: "paragraphmiddle",
|
|
875
|
+
right: "paragraphright"
|
|
876
|
+
}, ar = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
877
|
+
let [i] = B(), { align: o } = J(), { iconSize: s } = Hn(), { t: c } = a(), l = M(() => [
|
|
878
|
+
{
|
|
879
|
+
key: "left",
|
|
880
|
+
label: c("leftAlign"),
|
|
881
|
+
icon: /* @__PURE__ */ y(e, {
|
|
882
|
+
name: ir.left,
|
|
883
|
+
size: s
|
|
884
|
+
})
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
key: "center",
|
|
888
|
+
label: c("editor.centerAlign"),
|
|
889
|
+
icon: /* @__PURE__ */ y(e, {
|
|
890
|
+
name: ir.center,
|
|
891
|
+
size: s
|
|
892
|
+
})
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
key: "right",
|
|
896
|
+
label: c("editor.rightAlign"),
|
|
897
|
+
icon: /* @__PURE__ */ y(e, {
|
|
898
|
+
name: ir.right,
|
|
899
|
+
size: s
|
|
900
|
+
})
|
|
901
|
+
}
|
|
902
|
+
], [s, c]), u = T((e) => {
|
|
903
|
+
K(i), i.dispatchCommand(Ge, e.key);
|
|
904
|
+
}, [i]), d = /* @__PURE__ */ y("div", {
|
|
905
|
+
className: G["bsy-lexical__toolbar-select"],
|
|
906
|
+
style: { width: 50 },
|
|
907
|
+
children: /* @__PURE__ */ y(q, {
|
|
908
|
+
icon: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(e, {
|
|
909
|
+
name: ir[En(o)],
|
|
910
|
+
size: s
|
|
911
|
+
}), /* @__PURE__ */ y(e, {
|
|
912
|
+
name: "arrow-down",
|
|
913
|
+
size: s,
|
|
914
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
915
|
+
})] }),
|
|
916
|
+
tooltip: n ?? c("editor.alignment"),
|
|
917
|
+
showDisabledTooltip: r,
|
|
918
|
+
disabled: t
|
|
919
|
+
})
|
|
920
|
+
});
|
|
921
|
+
return t ? d : /* @__PURE__ */ y(f, {
|
|
922
|
+
menus: l,
|
|
923
|
+
onClick: u,
|
|
924
|
+
showSearch: !1,
|
|
925
|
+
activeKey: [o],
|
|
926
|
+
offset: W,
|
|
927
|
+
style: {
|
|
928
|
+
width: "110px",
|
|
929
|
+
minWidth: "110px"
|
|
930
|
+
},
|
|
931
|
+
children: d
|
|
932
|
+
});
|
|
933
|
+
}, or = (e) => e ? e.startsWith("@") || e.match(/^https?:\/\//) ? e : `http://${e}` : "", sr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
934
|
+
let [i] = B(), { link: o } = J(), { t: s } = a(), [c, u] = P(!1), [d, f] = P(""), [p, m] = P(""), [h, g] = P(!0), [_, x] = ne.useMessage(), S = N(null), C = T((e) => {
|
|
935
|
+
u(e), e || i.setEditable(!0);
|
|
936
|
+
}, [i]), w = () => {
|
|
937
|
+
if (!d) {
|
|
938
|
+
_.warning(s("editor.linkAddressEmpty"));
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
let e = or(d);
|
|
942
|
+
i.setEditable(!0), i.update(() => {
|
|
943
|
+
let t = h ? {
|
|
944
|
+
target: "_blank",
|
|
945
|
+
rel: "noopener noreferrer",
|
|
946
|
+
title: d
|
|
947
|
+
} : { title: d }, n = S.current;
|
|
948
|
+
n !== null && Ne(n);
|
|
949
|
+
let r = R();
|
|
950
|
+
if (z(r)) {
|
|
951
|
+
let n = p || d, i = r.getTextContent();
|
|
952
|
+
if (!r.isCollapsed() && n === i) ut(e, t);
|
|
953
|
+
else {
|
|
954
|
+
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 = ct(e, t), l = xe(n);
|
|
955
|
+
l.setFormat(s), l.setStyle(o), c.append(l), r.insertNodes([c]);
|
|
956
|
+
}
|
|
957
|
+
} else {
|
|
958
|
+
let n = ct(e, t);
|
|
959
|
+
n.append(xe(p || d));
|
|
960
|
+
let r = L(), i = r.getLastChild();
|
|
961
|
+
if (Ee(i) && i.isEmpty()) i.append(n);
|
|
962
|
+
else {
|
|
963
|
+
let e = ye();
|
|
964
|
+
e.append(n), r.append(e);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}), S.current = null, f(""), m(""), C(!1);
|
|
968
|
+
}, E = T(() => {
|
|
969
|
+
let e = "";
|
|
970
|
+
i.getEditorState().read(() => {
|
|
971
|
+
let t = R();
|
|
972
|
+
S.current = t ? t.clone() : null, z(t) && !t.isCollapsed() && (e = t.getTextContent());
|
|
973
|
+
}), i.setEditable(!1), i.update(() => {
|
|
974
|
+
Ne(null);
|
|
975
|
+
}), window.getSelection()?.removeAllRanges(), i.getRootElement()?.blur(), o ? (f(o.link ?? ""), m(o.linkText ?? "")) : (f(""), m(e)), u(!0);
|
|
976
|
+
}, [o, i]);
|
|
977
|
+
return /* @__PURE__ */ b(v, { children: [
|
|
978
|
+
/* @__PURE__ */ y(q, {
|
|
979
|
+
icon: "Insertlink",
|
|
980
|
+
tooltip: t ?? s("link"),
|
|
981
|
+
showDisabledTooltip: n,
|
|
982
|
+
onClick: E,
|
|
983
|
+
disabled: e,
|
|
984
|
+
active: !!o?.link
|
|
985
|
+
}),
|
|
986
|
+
x,
|
|
987
|
+
/* @__PURE__ */ y(r, {
|
|
988
|
+
title: s("link"),
|
|
989
|
+
open: c,
|
|
990
|
+
onOpenChange: C,
|
|
991
|
+
children: /* @__PURE__ */ b("div", { children: [/* @__PURE__ */ b("div", {
|
|
992
|
+
className: "px-[20px] pb-[60px] pt-[40px]",
|
|
993
|
+
children: [/* @__PURE__ */ b("div", {
|
|
994
|
+
className: "flex items-center relative",
|
|
995
|
+
children: [
|
|
996
|
+
/* @__PURE__ */ y("label", {
|
|
997
|
+
className: "w-[80px] shrink-0",
|
|
998
|
+
children: s("linkAddress")
|
|
999
|
+
}),
|
|
1000
|
+
/* @__PURE__ */ y(te, {
|
|
1001
|
+
value: d,
|
|
1002
|
+
onChange: (e) => f(e.target.value),
|
|
1003
|
+
placeholder: s("editor.linkTip")
|
|
1004
|
+
}),
|
|
1005
|
+
/* @__PURE__ */ y("div", {
|
|
1006
|
+
className: "absolute bottom-[-30px] left-[80px]",
|
|
1007
|
+
children: /* @__PURE__ */ y("p", {
|
|
1008
|
+
className: "text-[#999]",
|
|
1009
|
+
children: s("editor.linkAliasTip")
|
|
1010
|
+
})
|
|
1011
|
+
})
|
|
1012
|
+
]
|
|
1013
|
+
}), /* @__PURE__ */ b("div", {
|
|
1014
|
+
className: "flex items-center mt-[40px]",
|
|
1015
|
+
children: [/* @__PURE__ */ y("label", {
|
|
1016
|
+
className: "w-[80px] shrink-0",
|
|
1017
|
+
children: s("showContent")
|
|
1018
|
+
}), /* @__PURE__ */ y(te, {
|
|
1019
|
+
value: p,
|
|
1020
|
+
onChange: (e) => m(e.target.value)
|
|
1021
|
+
})]
|
|
1022
|
+
})]
|
|
1023
|
+
}), /* @__PURE__ */ b("div", {
|
|
1024
|
+
className: "py-[14px] px-[20px] flex justify-between items-center border-t-[1px] border-solid border-[#e0e0e0]",
|
|
1025
|
+
children: [/* @__PURE__ */ y("div", { children: /* @__PURE__ */ y(l, {
|
|
1026
|
+
checked: h,
|
|
1027
|
+
onChange: (e) => g(e),
|
|
1028
|
+
children: s("openInNewTab")
|
|
1029
|
+
}) }), /* @__PURE__ */ b("div", {
|
|
1030
|
+
className: "flex gap-[15px]",
|
|
1031
|
+
children: [/* @__PURE__ */ y(F, {
|
|
1032
|
+
onClick: () => C(!1),
|
|
1033
|
+
children: s("cancel")
|
|
1034
|
+
}), /* @__PURE__ */ y(F, {
|
|
1035
|
+
type: "primary",
|
|
1036
|
+
onClick: w,
|
|
1037
|
+
children: s("confirm")
|
|
1038
|
+
})]
|
|
1039
|
+
})]
|
|
1040
|
+
})] })
|
|
1041
|
+
})
|
|
1042
|
+
] });
|
|
1043
|
+
}, cr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1044
|
+
let [r] = B(), { link: i } = J(), { t: o } = a();
|
|
1045
|
+
return /* @__PURE__ */ y(q, {
|
|
1046
|
+
icon: "cancellink",
|
|
1047
|
+
tooltip: t ?? o("cancelLink"),
|
|
1048
|
+
showDisabledTooltip: n,
|
|
1049
|
+
disabled: e,
|
|
1050
|
+
onClick: () => {
|
|
1051
|
+
i && (K(r), r.dispatchCommand(pt, null));
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}, Y = {
|
|
1055
|
+
"picture-modal__container": "_picture-modal__container_1067t_1",
|
|
1056
|
+
"picture-modal__sidebar": "_picture-modal__sidebar_1067t_4",
|
|
1057
|
+
"picture-modal__menu-list": "_picture-modal__menu-list_1067t_8",
|
|
1058
|
+
"picture-modal__menu-item": "_picture-modal__menu-item_1067t_13",
|
|
1059
|
+
"picture-modal__menu-item--active": "_picture-modal__menu-item--active_1067t_22",
|
|
1060
|
+
"picture-modal__content": "_picture-modal__content_1067t_25",
|
|
1061
|
+
"picture-modal__content-body": "_picture-modal__content-body_1067t_31",
|
|
1062
|
+
"picture-modal__ops": "_picture-modal__ops_1067t_34",
|
|
1063
|
+
"picture-modal__content-title": "_picture-modal__content-title_1067t_42",
|
|
1064
|
+
"picture-modal__upload-area": "_picture-modal__upload-area_1067t_53",
|
|
1065
|
+
"picture-modal__upload-area--dragging": "_picture-modal__upload-area--dragging_1067t_69",
|
|
1066
|
+
"picture-modal__preview-list": "_picture-modal__preview-list_1067t_75",
|
|
1067
|
+
"picture-modal__preview": "_picture-modal__preview_1067t_75",
|
|
1068
|
+
"picture-modal__preview--error": "_picture-modal__preview--error_1067t_89",
|
|
1069
|
+
"picture-modal__preview-image": "_picture-modal__preview-image_1067t_92",
|
|
1070
|
+
"picture-modal__preview-mask": "_picture-modal__preview-mask_1067t_106",
|
|
1071
|
+
"picture-modal__preview-spinner": "_picture-modal__preview-spinner_1067t_116",
|
|
1072
|
+
"picture-modal-spin": "_picture-modal-spin_1067t_1",
|
|
1073
|
+
"picture-modal__preview-info": "_picture-modal__preview-info_1067t_124",
|
|
1074
|
+
"picture-modal__preview-filename": "_picture-modal__preview-filename_1067t_128",
|
|
1075
|
+
"picture-modal__preview-filename--error": "_picture-modal__preview-filename--error_1067t_136",
|
|
1076
|
+
"picture-modal__preview-size": "_picture-modal__preview-size_1067t_139",
|
|
1077
|
+
"picture-modal__preview-delete": "_picture-modal__preview-delete_1067t_143",
|
|
1078
|
+
"picture-modal__upload-text": "_picture-modal__upload-text_1067t_151",
|
|
1079
|
+
"picture-modal__footer": "_picture-modal__footer_1067t_155"
|
|
1080
|
+
}, lr = C((e, t) => {
|
|
1081
|
+
let [n] = ee.useForm(), [r, i] = P(""), { t: o } = a(), s = (e) => /^https?:\/\/.+/i.test(e);
|
|
1082
|
+
return A(t, () => ({ getValue: async () => {
|
|
1083
|
+
try {
|
|
1084
|
+
return await n.validateFields(), r;
|
|
1085
|
+
} catch {
|
|
1086
|
+
throw Error("URL validation failed");
|
|
1087
|
+
}
|
|
1088
|
+
} })), /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("div", {
|
|
1089
|
+
className: Y["picture-modal__content-title"],
|
|
1090
|
+
"data-title": o("editor.imageUrlNote"),
|
|
1091
|
+
children: o("editor.enterImageUrl")
|
|
1092
|
+
}), /* @__PURE__ */ y(ee, {
|
|
1093
|
+
form: n,
|
|
1094
|
+
children: /* @__PURE__ */ y(ee.Item, {
|
|
1095
|
+
name: "url",
|
|
1096
|
+
rules: [{
|
|
1097
|
+
required: !0,
|
|
1098
|
+
message: o("editor.pleaseEnterImageUrl")
|
|
1099
|
+
}, { validator: (e, t) => !t || s(t) ? Promise.resolve() : Promise.reject(Error(o("editor.pleaseEnterValidImageUrl"))) }],
|
|
1100
|
+
children: /* @__PURE__ */ y(te, {
|
|
1101
|
+
placeholder: o("editor.pleaseEnterImageUrl"),
|
|
1102
|
+
value: r,
|
|
1103
|
+
onChange: (e) => i(e.target.value)
|
|
1104
|
+
})
|
|
1105
|
+
})
|
|
1106
|
+
})] });
|
|
1107
|
+
});
|
|
1108
|
+
lr.displayName = "LinkInput";
|
|
351
1109
|
//#endregion
|
|
352
|
-
//#region src/components/Editor/
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
1110
|
+
//#region src/components/Editor/utils/formatTruncatedFilename.ts
|
|
1111
|
+
var ur = "......", dr = (e, t, n) => {
|
|
1112
|
+
if (t <= 0 || n(e) <= t) return {
|
|
1113
|
+
display: e,
|
|
1114
|
+
truncated: !1
|
|
1115
|
+
};
|
|
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}${ur}${s}${o}`, u = (e) => n(e) <= t;
|
|
1117
|
+
if (!u(l(""))) {
|
|
1118
|
+
let t = `${ur}${o}`;
|
|
1119
|
+
return {
|
|
1120
|
+
display: u(t) ? t : e,
|
|
1121
|
+
truncated: !0
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
let d = 0, f = c.length, p = 0;
|
|
1125
|
+
for (; d <= f;) {
|
|
1126
|
+
let e = d + f >> 1;
|
|
1127
|
+
u(l(c.slice(0, e))) ? (p = e, d = e + 1) : f = e - 1;
|
|
1128
|
+
}
|
|
1129
|
+
return {
|
|
1130
|
+
display: l(c.slice(0, p)),
|
|
1131
|
+
truncated: !0
|
|
1132
|
+
};
|
|
1133
|
+
}, fr = S(null), pr = S({ text: "" }), mr = S(void 0), hr = () => {
|
|
1134
|
+
let e = E(fr);
|
|
1135
|
+
if (!e) throw Error("useEditorContainer must be used within EditorContainerProvider");
|
|
1136
|
+
return e;
|
|
1137
|
+
}, gr = () => E(pr), _r = () => E(mr), vr = "EditorImageUploadingError";
|
|
1138
|
+
function yr(e) {
|
|
1139
|
+
if (!e || typeof e != "object" || !("name" in e)) return !1;
|
|
1140
|
+
let t = String(e.name);
|
|
1141
|
+
return t === "AbortError" || t === "CanceledError";
|
|
1142
|
+
}
|
|
1143
|
+
function br(e) {
|
|
1144
|
+
return yn.includes(e.name.split(".").pop()?.toLowerCase() ?? "");
|
|
1145
|
+
}
|
|
1146
|
+
function xr(e) {
|
|
1147
|
+
if (Number.isFinite(e)) return Math.min(100, Math.max(0, e));
|
|
1148
|
+
}
|
|
1149
|
+
function Sr(e) {
|
|
1150
|
+
return e === void 0 ? .55 : .55 * (1 - e / 100);
|
|
1151
|
+
}
|
|
1152
|
+
//#endregion
|
|
1153
|
+
//#region src/components/Editor/ToolbarPlugin/Buttons/PictureButton/UploadImage.tsx
|
|
1154
|
+
var Cr = {
|
|
1155
|
+
duration: .2,
|
|
1156
|
+
ease: [
|
|
1157
|
+
.4,
|
|
1158
|
+
0,
|
|
1159
|
+
.2,
|
|
1160
|
+
1
|
|
1161
|
+
]
|
|
1162
|
+
}, wr = ({ name: e, error: t }) => {
|
|
1163
|
+
let n = N(null), [r, i] = P(e), [a, o] = P(!1);
|
|
1164
|
+
return j(() => {
|
|
1165
|
+
let t = n.current, r = document.createElement("canvas").getContext("2d");
|
|
1166
|
+
if (!t || !r) return;
|
|
1167
|
+
let a = () => {
|
|
1168
|
+
r.font = getComputedStyle(t).font;
|
|
1169
|
+
let n = dr(e, t.clientWidth, (e) => r.measureText(e).width);
|
|
1170
|
+
i(n.display), o(n.truncated);
|
|
1171
|
+
};
|
|
1172
|
+
a();
|
|
1173
|
+
let s = new ResizeObserver(a);
|
|
1174
|
+
return s.observe(t), () => s.disconnect();
|
|
1175
|
+
}, [e]), /* @__PURE__ */ y("div", {
|
|
1176
|
+
ref: n,
|
|
1177
|
+
className: I(Y["picture-modal__preview-filename"], t && Y["picture-modal__preview-filename--error"]),
|
|
1178
|
+
title: a ? e : void 0,
|
|
1179
|
+
children: r
|
|
373
1180
|
});
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
1181
|
+
}, Tr = (e) => new Promise((t, n) => {
|
|
1182
|
+
let r = new FileReader();
|
|
1183
|
+
r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsDataURL(e);
|
|
1184
|
+
}), Er = C((t, n) => {
|
|
1185
|
+
let { upload: r } = hr(), [i, o] = P(!1), [s, c] = P([]), l = N(s);
|
|
1186
|
+
l.current = s;
|
|
1187
|
+
let u = N(null), d = N(/* @__PURE__ */ new Map()), f = r?.customRequest, [p, m] = ne.useMessage(), { t: h } = a(), g = (e) => (e / 1024).toFixed(1) + "kb", _ = (e, t) => {
|
|
1188
|
+
c((n) => n.map((n) => n.id === e ? {
|
|
1189
|
+
...n,
|
|
1190
|
+
...t
|
|
1191
|
+
} : n));
|
|
1192
|
+
}, v = (e, t) => {
|
|
1193
|
+
if (!f) {
|
|
1194
|
+
_(e, { status: "success" });
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
let n = new AbortController();
|
|
1198
|
+
d.current.set(e, n), f(t, {
|
|
1199
|
+
signal: n.signal,
|
|
1200
|
+
onProgress: (t) => {
|
|
1201
|
+
let n = xr(t);
|
|
1202
|
+
n !== void 0 && _(e, { percent: n });
|
|
386
1203
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
1204
|
+
}).then((t) => {
|
|
1205
|
+
n.signal.aborted || _(e, {
|
|
1206
|
+
status: "success",
|
|
1207
|
+
src: typeof t == "string" ? t : t.url,
|
|
1208
|
+
percent: 100,
|
|
1209
|
+
attachment: typeof t == "string" ? void 0 : t.attachment
|
|
1210
|
+
});
|
|
1211
|
+
}).catch((t) => {
|
|
1212
|
+
n.signal.aborted || yr(t) || _(e, { status: "error" });
|
|
1213
|
+
}).finally(() => {
|
|
1214
|
+
d.current.delete(e);
|
|
1215
|
+
});
|
|
1216
|
+
}, x = (e) => br(e) ? e.size > 5242880 ? (p.warning(h("editor.imageSizeNote")), !1) : !0 : (p.warning(h("editor.onlyImageFormatsSupported")), !1), S = (e) => {
|
|
1217
|
+
let t = 10 - l.current.length;
|
|
1218
|
+
if (t <= 0) {
|
|
1219
|
+
p.warning(h("editor.imageCountNote", { count: 10 }));
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
let n = Array.from(e).filter(x), r = n.slice(0, t);
|
|
1223
|
+
if (n.length > t && p.warning(h("editor.imageCountNote", { count: 10 })), !r.length) return;
|
|
1224
|
+
let i = r.map((e) => ({
|
|
1225
|
+
id: `${e.name}-${e.size}-${e.lastModified}-${Math.random()}`,
|
|
1226
|
+
file: e,
|
|
1227
|
+
url: URL.createObjectURL(e),
|
|
1228
|
+
status: f ? "uploading" : "success"
|
|
1229
|
+
}));
|
|
1230
|
+
c((e) => [...e, ...i]), i.forEach((e) => {
|
|
1231
|
+
v(e.id, e.file);
|
|
1232
|
+
});
|
|
1233
|
+
}, C = (e) => {
|
|
1234
|
+
d.current.get(e)?.abort(), d.current.delete(e), c((t) => {
|
|
1235
|
+
let n = t.find((t) => t.id === e);
|
|
1236
|
+
return n && URL.revokeObjectURL(n.url), t.filter((t) => t.id !== e);
|
|
1237
|
+
});
|
|
1238
|
+
}, w = () => {
|
|
1239
|
+
u.current?.click();
|
|
1240
|
+
}, T = (e) => {
|
|
1241
|
+
e.target.files?.length && S(e.target.files), e.target.value = "";
|
|
1242
|
+
};
|
|
1243
|
+
return O(() => () => {
|
|
1244
|
+
d.current.forEach((e) => e.abort()), d.current.clear(), l.current.forEach((e) => URL.revokeObjectURL(e.url));
|
|
1245
|
+
}, []), A(n, () => ({ getValue: async () => {
|
|
1246
|
+
if (s.some((e) => e.status === "uploading")) {
|
|
1247
|
+
let e = Error(h("editor.imageUploading"));
|
|
1248
|
+
throw e.name = vr, e;
|
|
1249
|
+
}
|
|
1250
|
+
let e = s.filter((e) => e.status === "success");
|
|
1251
|
+
if (!e.length) throw p.warning(h("editor.pleaseUploadImageFirst")), Error(h("editor.pleaseUploadImageFirst"));
|
|
1252
|
+
try {
|
|
1253
|
+
return await Promise.all(e.map(async (e) => ({
|
|
1254
|
+
src: e.src ?? await Tr(e.file),
|
|
1255
|
+
fileName: e.file.name,
|
|
1256
|
+
attachment: e.attachment
|
|
1257
|
+
})));
|
|
1258
|
+
} catch {
|
|
1259
|
+
throw Error(h("editor.operationFailed"));
|
|
1260
|
+
}
|
|
1261
|
+
} }), [
|
|
1262
|
+
s,
|
|
1263
|
+
p,
|
|
1264
|
+
h
|
|
1265
|
+
]), /* @__PURE__ */ b("div", {
|
|
1266
|
+
onDragOver: (e) => {
|
|
1267
|
+
e.preventDefault(), o(!0);
|
|
1268
|
+
},
|
|
1269
|
+
onDragLeave: (e) => {
|
|
1270
|
+
e.preventDefault(), o(!1);
|
|
1271
|
+
},
|
|
1272
|
+
onDrop: (e) => {
|
|
1273
|
+
e.preventDefault(), o(!1), e.dataTransfer.files.length && S(e.dataTransfer.files);
|
|
1274
|
+
},
|
|
1275
|
+
children: [
|
|
1276
|
+
/* @__PURE__ */ b("div", {
|
|
1277
|
+
className: Y["picture-modal__ops"],
|
|
1278
|
+
children: [/* @__PURE__ */ y("div", {
|
|
1279
|
+
className: Y["picture-modal__content-title"],
|
|
1280
|
+
"data-title": h("editor.imageSizeNote"),
|
|
1281
|
+
children: h("editor.uploadImage")
|
|
1282
|
+
}), /* @__PURE__ */ b("div", {
|
|
1283
|
+
className: `${Y["picture-modal__upload-area"]} ${i ? Y["picture-modal__upload-area--dragging"] : ""}`,
|
|
1284
|
+
onClick: w,
|
|
1285
|
+
children: [/* @__PURE__ */ y(e, { name: "upload" }), /* @__PURE__ */ y("span", {
|
|
1286
|
+
className: Y["picture-modal__upload-text"],
|
|
1287
|
+
children: h("editor.clickOrDragToUpload")
|
|
1288
|
+
})]
|
|
1289
|
+
})]
|
|
1290
|
+
}),
|
|
1291
|
+
s.length > 0 ? /* @__PURE__ */ y("div", {
|
|
1292
|
+
className: Y["picture-modal__preview-list"],
|
|
1293
|
+
children: /* @__PURE__ */ y(ae, {
|
|
1294
|
+
mode: "popLayout",
|
|
1295
|
+
children: s.map((t) => /* @__PURE__ */ b(oe.div, {
|
|
1296
|
+
layout: "position",
|
|
1297
|
+
className: I(Y["picture-modal__preview"], t.status === "error" && Y["picture-modal__preview--error"]),
|
|
1298
|
+
initial: {
|
|
1299
|
+
opacity: 0,
|
|
1300
|
+
y: 12
|
|
1301
|
+
},
|
|
1302
|
+
animate: {
|
|
1303
|
+
opacity: 1,
|
|
1304
|
+
y: 0
|
|
1305
|
+
},
|
|
1306
|
+
exit: {
|
|
1307
|
+
opacity: 0,
|
|
1308
|
+
y: -8
|
|
1309
|
+
},
|
|
1310
|
+
transition: Cr,
|
|
1311
|
+
children: [
|
|
1312
|
+
/* @__PURE__ */ b("div", {
|
|
1313
|
+
className: Y["picture-modal__preview-image"],
|
|
1314
|
+
children: [/* @__PURE__ */ y("img", {
|
|
1315
|
+
src: t.url,
|
|
1316
|
+
alt: h("editor.previewImage")
|
|
1317
|
+
}), t.status === "uploading" ? /* @__PURE__ */ y("div", {
|
|
1318
|
+
className: Y["picture-modal__preview-mask"],
|
|
1319
|
+
style: { opacity: Sr(t.percent) },
|
|
1320
|
+
children: t.percent === void 0 ? /* @__PURE__ */ y("span", { className: Y["picture-modal__preview-spinner"] }) : null
|
|
1321
|
+
}) : null]
|
|
1322
|
+
}),
|
|
1323
|
+
/* @__PURE__ */ b("div", {
|
|
1324
|
+
className: Y["picture-modal__preview-info"],
|
|
1325
|
+
children: [/* @__PURE__ */ y(wr, {
|
|
1326
|
+
name: t.file.name,
|
|
1327
|
+
error: t.status === "error"
|
|
1328
|
+
}), /* @__PURE__ */ y("div", {
|
|
1329
|
+
className: Y["picture-modal__preview-size"],
|
|
1330
|
+
children: g(t.file.size)
|
|
1331
|
+
})]
|
|
1332
|
+
}),
|
|
1333
|
+
/* @__PURE__ */ y("div", {
|
|
1334
|
+
className: Y["picture-modal__preview-delete"],
|
|
1335
|
+
role: "button",
|
|
1336
|
+
onClick: () => C(t.id),
|
|
1337
|
+
children: /* @__PURE__ */ y(e, { name: "delete" })
|
|
1338
|
+
})
|
|
1339
|
+
]
|
|
1340
|
+
}, t.id))
|
|
1341
|
+
})
|
|
1342
|
+
}) : null,
|
|
1343
|
+
/* @__PURE__ */ y("input", {
|
|
1344
|
+
ref: u,
|
|
1345
|
+
type: "file",
|
|
1346
|
+
accept: bn,
|
|
1347
|
+
multiple: !0,
|
|
1348
|
+
style: { display: "none" },
|
|
1349
|
+
onChange: T
|
|
1350
|
+
}),
|
|
1351
|
+
m
|
|
1352
|
+
]
|
|
1353
|
+
});
|
|
1354
|
+
});
|
|
1355
|
+
Er.displayName = "UploadImage";
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region src/components/Editor/commands/ImageCommands.ts
|
|
1358
|
+
var Dr = it("INSERT_INLINE_IMAGE_COMMAND"), Or = ({ disabled: t, tooltip: n, showDisabledTooltip: i }) => {
|
|
1359
|
+
let { t: o } = a(), [s] = B(), { attachmentsBySrcRef: c } = hr(), [l, d] = P(!1), f = N(null), p = N(null), m = [{
|
|
1360
|
+
key: "upload",
|
|
1361
|
+
title: o("editor.uploadImage"),
|
|
1362
|
+
icon: /* @__PURE__ */ y(e, { name: "picture" })
|
|
1363
|
+
}, {
|
|
1364
|
+
key: "url",
|
|
1365
|
+
title: o("editor.imageUrl"),
|
|
1366
|
+
icon: /* @__PURE__ */ y(e, { name: "Insertlink" })
|
|
1367
|
+
}], [h, g] = P(m[0].key), _ = async () => {
|
|
1368
|
+
try {
|
|
1369
|
+
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(Dr, {
|
|
1371
|
+
src: e.src,
|
|
1372
|
+
altText: e.fileName,
|
|
1373
|
+
dataId: e.attachment?._id
|
|
391
1374
|
});
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
let e = f.getParent();
|
|
399
|
-
if (kt(e)) {
|
|
400
|
-
let t = e.getListType();
|
|
401
|
-
p = t === "number" || t === "bullet" ? t : !1;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
let h = G(s, q), g = G(s, Zt), _ = Zt(g) ? g.getTag() : void 0;
|
|
405
|
-
n({
|
|
406
|
-
bold: e.hasFormat("bold"),
|
|
407
|
-
italic: e.hasFormat("italic"),
|
|
408
|
-
underline: e.hasFormat("underline"),
|
|
409
|
-
strikethrough: e.hasFormat("strikethrough"),
|
|
410
|
-
superscript: e.hasFormat("superscript"),
|
|
411
|
-
subscript: e.hasFormat("subscript"),
|
|
412
|
-
fontSize: r,
|
|
413
|
-
fontColor: i,
|
|
414
|
-
backgroundColor: a,
|
|
415
|
-
align: o(Ye(c) ? c.getFormatType() : ""),
|
|
416
|
-
listType: p,
|
|
417
|
-
canOutdent: m > 0 || p !== !1,
|
|
418
|
-
isCodeBlock: !!h,
|
|
419
|
-
isInTable: !!G(s, Bt),
|
|
420
|
-
headingTag: _ === "h1" || _ === "h2" || _ === "h3" ? _ : !1,
|
|
421
|
-
codeLanguage: d(h?.getLanguage()),
|
|
422
|
-
hasEditorText: t,
|
|
423
|
-
link: l
|
|
1375
|
+
});
|
|
1376
|
+
else if (f.current) {
|
|
1377
|
+
let e = await f.current.getValue();
|
|
1378
|
+
s.dispatchCommand(Dr, {
|
|
1379
|
+
src: e,
|
|
1380
|
+
dataSrc: e
|
|
424
1381
|
});
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
1382
|
+
}
|
|
1383
|
+
d(!1);
|
|
1384
|
+
} catch (e) {
|
|
1385
|
+
let t = e instanceof Error ? e.message : o("editor.operationFailed");
|
|
1386
|
+
if (e instanceof Error && e.name === "EditorImageUploadingError") {
|
|
1387
|
+
ne.warning(t);
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
ne.error(t);
|
|
1391
|
+
}
|
|
1392
|
+
}, x = {
|
|
1393
|
+
upload: /* @__PURE__ */ y(Er, { ref: p }),
|
|
1394
|
+
url: /* @__PURE__ */ y(lr, { ref: f })
|
|
1395
|
+
};
|
|
1396
|
+
return /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(q, {
|
|
1397
|
+
icon: "picture",
|
|
1398
|
+
tooltip: n ?? o("picture"),
|
|
1399
|
+
showDisabledTooltip: i,
|
|
1400
|
+
disabled: t,
|
|
1401
|
+
onClick: () => d(!0)
|
|
1402
|
+
}), /* @__PURE__ */ b(r, {
|
|
1403
|
+
title: o("addPicture"),
|
|
1404
|
+
open: l,
|
|
1405
|
+
onOpenChange: d,
|
|
1406
|
+
width: "620px",
|
|
1407
|
+
children: [/* @__PURE__ */ b("div", {
|
|
1408
|
+
className: Y["picture-modal__container"],
|
|
1409
|
+
children: [/* @__PURE__ */ y("div", {
|
|
1410
|
+
className: Y["picture-modal__sidebar"],
|
|
1411
|
+
children: /* @__PURE__ */ y("ul", {
|
|
1412
|
+
className: Y["picture-modal__menu-list"],
|
|
1413
|
+
children: m.map((e) => /* @__PURE__ */ b("li", {
|
|
1414
|
+
className: `${Y["picture-modal__menu-item"]} ${h === e.key ? Y["picture-modal__menu-item--active"] : ""}`,
|
|
1415
|
+
onClick: () => g(e.key),
|
|
1416
|
+
children: [/* @__PURE__ */ y("span", {
|
|
1417
|
+
className: Y["picture-modal__menu-icon"],
|
|
1418
|
+
children: e.icon
|
|
1419
|
+
}), /* @__PURE__ */ y("span", { children: e.title })]
|
|
1420
|
+
}, e.title))
|
|
1421
|
+
})
|
|
1422
|
+
}), /* @__PURE__ */ y(u, {
|
|
1423
|
+
className: Y["picture-modal__content"],
|
|
1424
|
+
contentClassName: Y["picture-modal__content-body"],
|
|
1425
|
+
children: x[h]
|
|
1426
|
+
})]
|
|
1427
|
+
}), /* @__PURE__ */ b("div", {
|
|
1428
|
+
className: Y["picture-modal__footer"],
|
|
1429
|
+
children: [/* @__PURE__ */ y(F, {
|
|
1430
|
+
onClick: () => d(!1),
|
|
1431
|
+
children: o("cancel")
|
|
1432
|
+
}), /* @__PURE__ */ y(F, {
|
|
1433
|
+
type: "primary",
|
|
1434
|
+
onClick: _,
|
|
1435
|
+
children: o("confirm")
|
|
1436
|
+
})]
|
|
1437
|
+
})]
|
|
1438
|
+
})] });
|
|
1439
|
+
}, kr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1440
|
+
let [r] = B(), { canUndo: i } = Rn(), { t: o } = a();
|
|
1441
|
+
return /* @__PURE__ */ y(q, {
|
|
1442
|
+
icon: "chexiao",
|
|
1443
|
+
tooltip: t ?? o("editor.undo"),
|
|
1444
|
+
showDisabledTooltip: n,
|
|
1445
|
+
disabled: e || !i,
|
|
1446
|
+
onClick: () => {
|
|
1447
|
+
r.dispatchCommand(rt, void 0);
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
}, Ar = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1451
|
+
let [r] = B(), { canRedo: i } = Rn(), { t: o } = a();
|
|
1452
|
+
return /* @__PURE__ */ y(q, {
|
|
1453
|
+
icon: "fanhui",
|
|
1454
|
+
tooltip: t ?? o("editor.redo"),
|
|
1455
|
+
showDisabledTooltip: n,
|
|
1456
|
+
disabled: e || !i,
|
|
1457
|
+
onClick: () => r.dispatchCommand(et, void 0)
|
|
1458
|
+
});
|
|
1459
|
+
}, jr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1460
|
+
let [r] = B(), { strikethrough: i } = J(), { t: o } = a();
|
|
1461
|
+
return /* @__PURE__ */ y(q, {
|
|
1462
|
+
icon: "shanchuxian",
|
|
1463
|
+
tooltip: t ?? o("editor.strikethrough"),
|
|
1464
|
+
showDisabledTooltip: n,
|
|
1465
|
+
active: i,
|
|
1466
|
+
disabled: e,
|
|
1467
|
+
onClick: () => {
|
|
1468
|
+
K(r), r.dispatchCommand(Ke, "strikethrough");
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
}, Mr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1472
|
+
let [r] = B(), { superscript: i } = J(), { t: o } = a();
|
|
1473
|
+
return /* @__PURE__ */ y(q, {
|
|
1474
|
+
icon: "shangbiao",
|
|
1475
|
+
tooltip: t ?? o("editor.superscript"),
|
|
1476
|
+
showDisabledTooltip: n,
|
|
1477
|
+
active: i,
|
|
1478
|
+
disabled: e,
|
|
1479
|
+
onClick: () => {
|
|
1480
|
+
K(r), r.dispatchCommand(Ke, "superscript");
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
}, Nr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1484
|
+
let [r] = B(), { subscript: i } = J(), { t: o } = a();
|
|
1485
|
+
return /* @__PURE__ */ y(q, {
|
|
1486
|
+
icon: "xiabiao",
|
|
1487
|
+
tooltip: t ?? o("editor.subscript"),
|
|
1488
|
+
showDisabledTooltip: n,
|
|
1489
|
+
active: i,
|
|
1490
|
+
disabled: e,
|
|
1491
|
+
onClick: () => {
|
|
1492
|
+
K(r), r.dispatchCommand(Ke, "subscript");
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
}, Pr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1496
|
+
let [r] = B(), { t: i } = a();
|
|
1497
|
+
return /* @__PURE__ */ y(q, {
|
|
1498
|
+
icon: "zengjiasuojin",
|
|
1499
|
+
tooltip: t ?? i("editor.indent"),
|
|
1500
|
+
showDisabledTooltip: n,
|
|
1501
|
+
disabled: e,
|
|
1502
|
+
onClick: () => {
|
|
1503
|
+
K(r), r.dispatchCommand(Je, void 0);
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
}, Fr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1507
|
+
let [r] = B(), { canOutdent: i } = J(), o = Pn(), { t: s } = a();
|
|
1508
|
+
return /* @__PURE__ */ b("div", {
|
|
1509
|
+
className: G["bsy-lexical__toolbar-with-divider"],
|
|
1510
|
+
children: [/* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ y(q, {
|
|
1511
|
+
icon: "jianshaosuojin",
|
|
1512
|
+
tooltip: t ?? s("editor.outdent"),
|
|
1513
|
+
showDisabledTooltip: n,
|
|
1514
|
+
disabled: e || o && !i,
|
|
1515
|
+
onClick: () => {
|
|
1516
|
+
K(r), r.dispatchCommand(Ze, void 0);
|
|
1517
|
+
}
|
|
1518
|
+
})]
|
|
1519
|
+
});
|
|
1520
|
+
}, Ir = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1521
|
+
let [r] = B(), { listType: i } = J(), { t: o } = a(), s = i === "bullet";
|
|
1522
|
+
return /* @__PURE__ */ y(q, {
|
|
1523
|
+
icon: "xuhaoliebiao",
|
|
1524
|
+
tooltip: t ?? o("editor.bulletList"),
|
|
1525
|
+
showDisabledTooltip: n,
|
|
1526
|
+
active: s,
|
|
1527
|
+
disabled: e,
|
|
1528
|
+
onClick: () => {
|
|
1529
|
+
let e = Nn(r);
|
|
1530
|
+
r.dispatchCommand(e.listType === "bullet" ? bt : _t, void 0);
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
}, Lr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1534
|
+
let [r] = B(), { listType: i } = J(), { t: o } = a(), s = i === "number";
|
|
1535
|
+
return /* @__PURE__ */ y(q, {
|
|
1536
|
+
icon: "bianhaoliebiao",
|
|
1537
|
+
tooltip: t ?? o("editor.numberList"),
|
|
1538
|
+
showDisabledTooltip: n,
|
|
1539
|
+
active: s,
|
|
1540
|
+
disabled: e,
|
|
1541
|
+
onClick: () => {
|
|
1542
|
+
let e = Nn(r);
|
|
1543
|
+
r.dispatchCommand(e.listType === "number" ? bt : gt, void 0);
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
}, Rr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1547
|
+
let [r] = B(), { isCodeBlock: i } = J(), { t: o } = a();
|
|
1548
|
+
return /* @__PURE__ */ y(q, {
|
|
1549
|
+
icon: "daima",
|
|
1550
|
+
tooltip: t ?? o("editor.codeBlock"),
|
|
1551
|
+
showDisabledTooltip: n,
|
|
1552
|
+
active: i,
|
|
1553
|
+
disabled: e,
|
|
1554
|
+
onClick: () => {
|
|
1555
|
+
Mn(r, (e) => {
|
|
1556
|
+
At(R(), () => e.isCodeBlock ? ye() : St(xn));
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
}, zr = {
|
|
1561
|
+
"bsy-lexical__table-picker": "_bsy-lexical__table-picker_mv0nn_1",
|
|
1562
|
+
"bsy-lexical__table-picker-grid": "_bsy-lexical__table-picker-grid_mv0nn_9",
|
|
1563
|
+
"bsy-lexical__table-picker-cell": "_bsy-lexical__table-picker-cell_mv0nn_15",
|
|
1564
|
+
"bsy-lexical__table-picker-cell--active": "_bsy-lexical__table-picker-cell--active_mv0nn_24",
|
|
1565
|
+
"bsy-lexical__table-picker-label": "_bsy-lexical__table-picker-label_mv0nn_28"
|
|
1566
|
+
}, Br = _(1, 11), Vr = ({ disabled: e, tooltip: r, showDisabledTooltip: i }) => {
|
|
1567
|
+
let [s] = B(), { isInTable: c } = J(), { t: l } = a(), u = t(), [f, p] = P(!1), [m, h] = P({
|
|
1568
|
+
rows: 0,
|
|
1569
|
+
cols: 0
|
|
1570
|
+
});
|
|
1571
|
+
O(() => {
|
|
1572
|
+
c && p(!1);
|
|
1573
|
+
}, [c]);
|
|
1574
|
+
let g = () => {
|
|
1575
|
+
p(!1), h({
|
|
1576
|
+
rows: 0,
|
|
1577
|
+
cols: 0
|
|
429
1578
|
});
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
value: t,
|
|
438
|
-
children: e.children
|
|
1579
|
+
}, { refs: _, floatingStyles: x, getReferenceProps: S, getFloatingProps: C } = d({
|
|
1580
|
+
isOpen: f,
|
|
1581
|
+
close: g,
|
|
1582
|
+
showMask: !1,
|
|
1583
|
+
zIndex: u,
|
|
1584
|
+
popupMinWidth: "220px",
|
|
1585
|
+
offset: W
|
|
439
1586
|
});
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
1587
|
+
return c ? /* @__PURE__ */ y(q, {
|
|
1588
|
+
icon: "charubiaoge",
|
|
1589
|
+
tooltip: r ?? l("editor.table"),
|
|
1590
|
+
showDisabledTooltip: i,
|
|
1591
|
+
disabled: !0
|
|
1592
|
+
}) : /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("div", {
|
|
1593
|
+
className: "inline-flex",
|
|
1594
|
+
ref: _.setReference,
|
|
1595
|
+
...S({ onClick: () => p((e) => !e) }),
|
|
1596
|
+
children: /* @__PURE__ */ y(q, {
|
|
1597
|
+
icon: "charubiaoge",
|
|
1598
|
+
tooltip: r ?? l("editor.table"),
|
|
1599
|
+
showDisabledTooltip: i,
|
|
1600
|
+
disabled: e
|
|
1601
|
+
})
|
|
1602
|
+
}), /* @__PURE__ */ y(ce, { children: /* @__PURE__ */ y(n, {
|
|
1603
|
+
zIndex: u,
|
|
1604
|
+
children: /* @__PURE__ */ y(ae, { children: f ? /* @__PURE__ */ y(oe.div, {
|
|
1605
|
+
ref: _.setFloating,
|
|
1606
|
+
...C(),
|
|
1607
|
+
style: {
|
|
1608
|
+
...x,
|
|
1609
|
+
zIndex: u
|
|
1610
|
+
},
|
|
1611
|
+
...o,
|
|
1612
|
+
children: /* @__PURE__ */ b("div", {
|
|
1613
|
+
className: zr["bsy-lexical__table-picker"],
|
|
1614
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
1615
|
+
onMouseLeave: () => h({
|
|
1616
|
+
rows: 0,
|
|
1617
|
+
cols: 0
|
|
1618
|
+
}),
|
|
1619
|
+
children: [/* @__PURE__ */ y("div", {
|
|
1620
|
+
className: zr["bsy-lexical__table-picker-grid"],
|
|
1621
|
+
children: Br.map((e) => Br.map((t) => /* @__PURE__ */ y("button", {
|
|
1622
|
+
type: "button",
|
|
1623
|
+
className: I(zr["bsy-lexical__table-picker-cell"], m.rows >= e && m.cols >= t && zr["bsy-lexical__table-picker-cell--active"]),
|
|
1624
|
+
onMouseEnter: () => h({
|
|
1625
|
+
rows: e,
|
|
1626
|
+
cols: t
|
|
1627
|
+
}),
|
|
1628
|
+
onClick: () => {
|
|
1629
|
+
s.dispatchCommand(Lt, {
|
|
1630
|
+
rows: String(e),
|
|
1631
|
+
columns: String(t),
|
|
1632
|
+
includeHeaders: !1
|
|
1633
|
+
}), g();
|
|
1634
|
+
}
|
|
1635
|
+
}, `${e}-${t}`)))
|
|
1636
|
+
}), /* @__PURE__ */ b("div", {
|
|
1637
|
+
className: zr["bsy-lexical__table-picker-label"],
|
|
1638
|
+
children: [
|
|
1639
|
+
m.rows,
|
|
1640
|
+
" × ",
|
|
1641
|
+
m.cols
|
|
1642
|
+
]
|
|
1643
|
+
})]
|
|
1644
|
+
})
|
|
1645
|
+
}, "bsy-lexical-table-picker") : null })
|
|
1646
|
+
}) })] });
|
|
1647
|
+
}, Hr = S(null), Ur = () => {
|
|
1648
|
+
let e = E(Hr);
|
|
1649
|
+
if (!e) throw Error("useSourceMode must be used within SourceModeProvider");
|
|
1650
|
+
return e;
|
|
1651
|
+
}, Wr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1652
|
+
let { t: r } = a(), { isSourceMode: i, toggleSourceMode: o } = Ur();
|
|
1653
|
+
return /* @__PURE__ */ y(q, {
|
|
1654
|
+
icon: "yuanmamoshi",
|
|
1655
|
+
tooltip: t ?? r("editor.sourceMode"),
|
|
1656
|
+
showDisabledTooltip: n,
|
|
1657
|
+
active: i,
|
|
1658
|
+
disabled: e,
|
|
1659
|
+
onClick: o
|
|
1660
|
+
});
|
|
1661
|
+
}, Gr = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
1662
|
+
let [i] = B(), { headingTag: o, isInTable: s } = J(), { t: c } = a(), { iconSize: l } = Hn(), u = o || "paragraph", d = [
|
|
1663
|
+
{
|
|
1664
|
+
key: "paragraph",
|
|
1665
|
+
label: c("editor.paragraph")
|
|
1666
|
+
},
|
|
1667
|
+
{
|
|
1668
|
+
key: "h1",
|
|
1669
|
+
label: c("editor.heading1")
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
key: "h2",
|
|
1673
|
+
label: c("editor.heading2")
|
|
1674
|
+
},
|
|
1675
|
+
{
|
|
1676
|
+
key: "h3",
|
|
1677
|
+
label: c("editor.heading3")
|
|
1678
|
+
}
|
|
1679
|
+
], p = d.find((e) => e.key === u)?.label, m = T((e) => {
|
|
1680
|
+
let t = e.key;
|
|
1681
|
+
K(i), i.update(() => {
|
|
1682
|
+
At(R(), () => t === "paragraph" ? ye() : Gt(t));
|
|
449
1683
|
});
|
|
450
|
-
}, [
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
1684
|
+
}, [i]), h = /* @__PURE__ */ y("div", {
|
|
1685
|
+
className: G["bsy-lexical__toolbar-select"],
|
|
1686
|
+
style: { width: 62 },
|
|
1687
|
+
children: /* @__PURE__ */ y(q, {
|
|
1688
|
+
icon: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("span", {
|
|
1689
|
+
className: G["bsy-lexical__toolbar-select-label"],
|
|
1690
|
+
children: p
|
|
1691
|
+
}), /* @__PURE__ */ y(e, {
|
|
1692
|
+
name: "arrow-down",
|
|
1693
|
+
size: l,
|
|
1694
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
1695
|
+
})] }),
|
|
1696
|
+
tooltip: n,
|
|
1697
|
+
showDisabledTooltip: r,
|
|
1698
|
+
disabled: t || s
|
|
1699
|
+
})
|
|
1700
|
+
});
|
|
1701
|
+
return t || s ? h : /* @__PURE__ */ y(f, {
|
|
1702
|
+
menus: d,
|
|
1703
|
+
onClick: m,
|
|
455
1704
|
showSearch: !1,
|
|
456
|
-
|
|
1705
|
+
activeKey: [u],
|
|
1706
|
+
offset: W,
|
|
457
1707
|
style: {
|
|
458
|
-
width:
|
|
459
|
-
minWidth:
|
|
1708
|
+
width: "62px",
|
|
1709
|
+
minWidth: "62px"
|
|
460
1710
|
},
|
|
461
|
-
children:
|
|
462
|
-
className: p["bsy-lexical__toolbar-select"],
|
|
463
|
-
style: { width: 120 },
|
|
464
|
-
children: /* @__PURE__ */ M(u, {
|
|
465
|
-
icon: /* @__PURE__ */ N(ye, { children: [/* @__PURE__ */ M("span", {
|
|
466
|
-
className: p["bsy-lexical__toolbar-select-label"],
|
|
467
|
-
children: c
|
|
468
|
-
}), /* @__PURE__ */ M(e, {
|
|
469
|
-
name: "arrow-down",
|
|
470
|
-
size: o,
|
|
471
|
-
className: p["bsy-lexical__toolbar-select-arrow"]
|
|
472
|
-
})] }),
|
|
473
|
-
tooltip: i("editor.codeLanguage")
|
|
474
|
-
})
|
|
475
|
-
})
|
|
1711
|
+
children: h
|
|
476
1712
|
});
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
1713
|
+
};
|
|
1714
|
+
//#endregion
|
|
1715
|
+
//#region src/components/Editor/utils/clearInlineTextFormat.ts
|
|
1716
|
+
function Kr() {
|
|
1717
|
+
let e = R();
|
|
1718
|
+
if (z(e)) {
|
|
1719
|
+
kt(e, {
|
|
1720
|
+
"font-size": null,
|
|
1721
|
+
color: null,
|
|
1722
|
+
"background-color": null
|
|
1723
|
+
});
|
|
1724
|
+
for (let t of e.getNodes()) Ae(t) && t.setFormat(0);
|
|
1725
|
+
e.setFormat(0);
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
//#endregion
|
|
1729
|
+
//#region src/components/Editor/ToolbarPlugin/Buttons/ClearFormatButton.tsx
|
|
1730
|
+
var qr = ({ disabled: e, tooltip: t, showDisabledTooltip: n }) => {
|
|
1731
|
+
let [r] = B(), { t: i } = a();
|
|
1732
|
+
return /* @__PURE__ */ y(q, {
|
|
1733
|
+
icon: "clearTree",
|
|
1734
|
+
tooltip: t ?? i("editor.clearFormat"),
|
|
1735
|
+
showDisabledTooltip: n,
|
|
1736
|
+
disabled: e,
|
|
1737
|
+
onClick: () => {
|
|
1738
|
+
K(r), r.update(() => {
|
|
1739
|
+
Kr();
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
}, Jr = /<!--bsy-code-(\d+)-->/g, Yr = [
|
|
1744
|
+
"quick",
|
|
1745
|
+
"formal",
|
|
1746
|
+
"colloquial",
|
|
1747
|
+
"lively",
|
|
1748
|
+
"literary",
|
|
1749
|
+
"retro"
|
|
1750
|
+
], Xr = {
|
|
1751
|
+
quick: "editor.aiPresetQuick",
|
|
1752
|
+
formal: "editor.aiPresetFormal",
|
|
1753
|
+
colloquial: "editor.aiPresetColloquial",
|
|
1754
|
+
lively: "editor.aiPresetLively",
|
|
1755
|
+
literary: "editor.aiPresetLiterary",
|
|
1756
|
+
retro: "editor.aiPresetRetro"
|
|
1757
|
+
};
|
|
1758
|
+
//#endregion
|
|
1759
|
+
//#region src/components/Editor/utils/htmlText.ts
|
|
1760
|
+
function Zr(e) {
|
|
1761
|
+
return /<[^>]*$/.test(e.trim());
|
|
1762
|
+
}
|
|
1763
|
+
function Qr(e) {
|
|
1764
|
+
return e ? new DOMParser().parseFromString(e, "text/html").body.textContent ?? "" : "";
|
|
1765
|
+
}
|
|
1766
|
+
//#endregion
|
|
1767
|
+
//#region src/components/Editor/utils/fillRootFromHtml.ts
|
|
1768
|
+
var $r = [
|
|
1769
|
+
"color",
|
|
1770
|
+
"background-color",
|
|
1771
|
+
"font-size",
|
|
1772
|
+
"font-family",
|
|
1773
|
+
"font-weight",
|
|
1774
|
+
"text-decoration"
|
|
1775
|
+
], ei = (e) => {
|
|
1776
|
+
let t = e.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, td, th");
|
|
1777
|
+
for (let n of Array.from(t)) {
|
|
1778
|
+
let t = n, r = [];
|
|
1779
|
+
for (let e of $r) {
|
|
1780
|
+
let n = t.style.getPropertyValue(e);
|
|
1781
|
+
n && (r.push(`${e}: ${n}`), t.style.removeProperty(e));
|
|
1782
|
+
}
|
|
1783
|
+
if (!r.length) continue;
|
|
1784
|
+
let i = r.join("; ");
|
|
1785
|
+
for (let n of Array.from(t.childNodes)) {
|
|
1786
|
+
if (n.nodeType === Node.TEXT_NODE && n.textContent) {
|
|
1787
|
+
let r = e.createElement("span");
|
|
1788
|
+
r.setAttribute("style", i), t.insertBefore(r, n), r.appendChild(n);
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
1792
|
+
let e = n, t = e.getAttribute("style");
|
|
1793
|
+
e.setAttribute("style", t ? `${t}; ${i}` : i);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
}, ti = (e, t) => {
|
|
1798
|
+
let n = L();
|
|
1799
|
+
if (n.clear(), t.trim()) {
|
|
1800
|
+
let r = new DOMParser().parseFromString(t, "text/html");
|
|
1801
|
+
ei(r);
|
|
1802
|
+
let i = ge(e, r);
|
|
1803
|
+
if (i.length) {
|
|
1804
|
+
n.select(), Te(i), Ne(null);
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
let r = ye();
|
|
1809
|
+
n.append(r), Ne(null);
|
|
1810
|
+
};
|
|
1811
|
+
//#endregion
|
|
1812
|
+
//#region src/components/Editor/utils/isEmptyEditorHtml.ts
|
|
1813
|
+
function ni(e, t) {
|
|
1814
|
+
return !t.trim() && (e === "<p><br></p>" || e === "<p></p>" || e === "" || /^<p>\s*<br>\s*<\/p>$/.test(e));
|
|
1815
|
+
}
|
|
1816
|
+
//#endregion
|
|
1817
|
+
//#region src/components/Editor/utils/sanitizeEditorHtml.ts
|
|
1818
|
+
var ri = /* @__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("."), ii = [
|
|
1819
|
+
"href",
|
|
1820
|
+
"src",
|
|
1821
|
+
"alt",
|
|
1822
|
+
"title",
|
|
1823
|
+
"target",
|
|
1824
|
+
"rel",
|
|
1825
|
+
"colspan",
|
|
1826
|
+
"rowspan",
|
|
1827
|
+
"data-language",
|
|
1828
|
+
"data-id",
|
|
1829
|
+
"data-src",
|
|
1830
|
+
"class",
|
|
1831
|
+
"style",
|
|
1832
|
+
"width",
|
|
1833
|
+
"height"
|
|
1834
|
+
], ai = 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.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, si = new Set([
|
|
1835
|
+
"pre",
|
|
1836
|
+
"code",
|
|
1837
|
+
"td",
|
|
1838
|
+
"th"
|
|
1839
|
+
]), ci = new Set(["pre", "code"]), li = new Set(["sup", "sub"]), ui = (e, t) => ai.has(e) ? e === "padding-inline-start" ? !0 : e === "padding" || e.startsWith("padding-") ? si.has(t) : e === "border-radius" ? ci.has(t) : e === "position" || e === "top" || e === "bottom" ? li.has(t) : !0 : !1, di = (e, t) => e.split(";").map((e) => e.trim()).filter(Boolean).map((e) => {
|
|
1840
|
+
let n = e.indexOf(":");
|
|
1841
|
+
if (n === -1) return null;
|
|
1842
|
+
let r = e.slice(0, n).trim().toLowerCase(), i = e.slice(n + 1).trim();
|
|
1843
|
+
if (r === "background") {
|
|
1844
|
+
if (/url\s*\(/i.test(i)) return null;
|
|
1845
|
+
r = "background-color";
|
|
1846
|
+
}
|
|
1847
|
+
return !ui(r, t) || /expression|javascript:|url\s*\(\s*['"]?\s*javascript/i.test(i) ? null : `${r}: ${i}`;
|
|
1848
|
+
}).filter((e) => e !== null).join("; "), fi = !1, pi = () => {
|
|
1849
|
+
fi ||= (Xt.addHook("uponSanitizeAttribute", (e, t) => {
|
|
1850
|
+
if (t.attrName === "href" && /^data:/i.test(t.attrValue)) {
|
|
1851
|
+
t.keepAttr = !1;
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
t.attrName === "style" && (t.attrValue = di(t.attrValue, e.nodeName.toLowerCase()), t.attrValue || (t.keepAttr = !1));
|
|
1855
|
+
}), !0);
|
|
1856
|
+
};
|
|
1857
|
+
function X(e) {
|
|
1858
|
+
return e ? (pi(), Xt.sanitize(e, {
|
|
1859
|
+
ALLOWED_TAGS: ri,
|
|
1860
|
+
ALLOWED_ATTR: ii,
|
|
1861
|
+
ALLOW_DATA_ATTR: !1,
|
|
1862
|
+
ADD_ATTR: [
|
|
1863
|
+
"data-language",
|
|
1864
|
+
"data-id",
|
|
1865
|
+
"data-src"
|
|
1866
|
+
],
|
|
1867
|
+
ALLOWED_URI_REGEXP: oi
|
|
1868
|
+
})) : "";
|
|
1869
|
+
}
|
|
1870
|
+
//#endregion
|
|
1871
|
+
//#region src/components/Editor/utils/stitchCodePlaceholders.ts
|
|
1872
|
+
var mi = "bsy-html-root";
|
|
1873
|
+
function hi(e) {
|
|
1874
|
+
return new DOMParser().parseFromString(`<${mi}>${e}</${mi}>`, "text/html").body.querySelector(mi);
|
|
1875
|
+
}
|
|
1876
|
+
function gi(e, t) {
|
|
1877
|
+
if (!t.length) return e;
|
|
1878
|
+
let n = /* @__PURE__ */ new Set(), r = e.replace(Jr, (e, r) => {
|
|
1879
|
+
let i = Number(r), a = t[i];
|
|
1880
|
+
return a === void 0 ? "" : (n.add(i), a);
|
|
1881
|
+
}), i = t.filter((e, t) => !n.has(t)).join("");
|
|
1882
|
+
return i ? `${r}${i}` : r;
|
|
1883
|
+
}
|
|
1884
|
+
function _i(e, t) {
|
|
1885
|
+
return gi(vi(e), t);
|
|
1886
|
+
}
|
|
1887
|
+
function vi(e) {
|
|
1888
|
+
if (!/<pre[\s>/]/i.test(e)) return e;
|
|
1889
|
+
let t = hi(e);
|
|
1890
|
+
if (!t) return e;
|
|
1891
|
+
let n = t.ownerDocument;
|
|
1892
|
+
for (let e of Array.from(t.querySelectorAll("pre"))) {
|
|
1893
|
+
let t = n.createComment("bsy-code-dropped");
|
|
1894
|
+
e.replaceWith(t);
|
|
1895
|
+
}
|
|
1896
|
+
return t.innerHTML.replace(/<!--bsy-code-dropped-->/g, "");
|
|
1897
|
+
}
|
|
1898
|
+
//#endregion
|
|
1899
|
+
//#region src/components/Editor/constants/portableEditorStyles.ts
|
|
1900
|
+
var yi = {
|
|
1901
|
+
margin: "0.6em 0 0.4em",
|
|
1902
|
+
"font-weight": "600",
|
|
1903
|
+
"line-height": "1.35"
|
|
1904
|
+
}, bi = {
|
|
1905
|
+
h1: {
|
|
1906
|
+
...yi,
|
|
1907
|
+
"font-size": "2em"
|
|
481
1908
|
},
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
1909
|
+
h2: {
|
|
1910
|
+
...yi,
|
|
1911
|
+
"font-size": "1.5em"
|
|
485
1912
|
},
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
1913
|
+
h3: {
|
|
1914
|
+
...yi,
|
|
1915
|
+
"font-size": "1.25em"
|
|
1916
|
+
},
|
|
1917
|
+
h4: {
|
|
1918
|
+
...yi,
|
|
1919
|
+
"font-size": "1.125em"
|
|
1920
|
+
},
|
|
1921
|
+
h5: {
|
|
1922
|
+
...yi,
|
|
1923
|
+
"font-size": "1em"
|
|
1924
|
+
},
|
|
1925
|
+
h6: {
|
|
1926
|
+
...yi,
|
|
1927
|
+
"font-size": "0.875em"
|
|
1928
|
+
}
|
|
1929
|
+
}, xi = {
|
|
1930
|
+
color: "#0269ff",
|
|
1931
|
+
cursor: "pointer"
|
|
1932
|
+
}, Si = {
|
|
1933
|
+
margin: "0",
|
|
1934
|
+
"padding-inline-start": "24px",
|
|
1935
|
+
"list-style-position": "outside"
|
|
1936
|
+
}, Ci = [
|
|
1937
|
+
"disc",
|
|
1938
|
+
"circle",
|
|
1939
|
+
"square"
|
|
1940
|
+
], wi = {
|
|
1941
|
+
margin: "0",
|
|
1942
|
+
"list-style": "inherit"
|
|
1943
|
+
}, Ti = {
|
|
1944
|
+
margin: "0",
|
|
1945
|
+
"list-style-type": "none"
|
|
1946
|
+
}, Ei = {
|
|
1947
|
+
display: "block",
|
|
1948
|
+
"box-sizing": "border-box",
|
|
1949
|
+
"max-width": "100%",
|
|
1950
|
+
margin: "8px 0",
|
|
1951
|
+
padding: "8px 12px",
|
|
1952
|
+
"overflow-x": "auto",
|
|
1953
|
+
"font-family": "Menlo, Consolas, Monaco, monospace",
|
|
1954
|
+
"font-size": "13px",
|
|
1955
|
+
"line-height": "1.53",
|
|
1956
|
+
"white-space": "pre",
|
|
1957
|
+
"tab-size": "2",
|
|
1958
|
+
"border-radius": "4px",
|
|
1959
|
+
"background-color": "rgb(240, 242, 245)",
|
|
1960
|
+
color: "#1f2328"
|
|
1961
|
+
}, Di = {
|
|
1962
|
+
"border-collapse": "collapse",
|
|
1963
|
+
"table-layout": "fixed",
|
|
1964
|
+
width: "100%",
|
|
1965
|
+
"overflow-x": "auto",
|
|
1966
|
+
margin: "8px 0"
|
|
1967
|
+
}, Oi = {
|
|
1968
|
+
"box-sizing": "border-box",
|
|
1969
|
+
"min-width": "75px",
|
|
1970
|
+
"min-height": "32px",
|
|
1971
|
+
padding: "4px 8px",
|
|
1972
|
+
border: "1px solid #d9d9d9",
|
|
1973
|
+
"vertical-align": "top"
|
|
1974
|
+
}, ki = {
|
|
1975
|
+
"font-weight": "600",
|
|
1976
|
+
"background-color": "#f2f3f5"
|
|
1977
|
+
}, Ai = {
|
|
1978
|
+
display: "inline-block",
|
|
1979
|
+
position: "static",
|
|
1980
|
+
top: "auto",
|
|
1981
|
+
bottom: "auto",
|
|
1982
|
+
"font-size": "0.75em",
|
|
1983
|
+
"line-height": "1"
|
|
1984
|
+
}, Z = (e, t) => {
|
|
1985
|
+
for (let [n, r] of Object.entries(t)) e.style.getPropertyValue(n) || e.style.setProperty(n, r);
|
|
1986
|
+
}, ji = (e) => {
|
|
1987
|
+
let t = 0, n = e;
|
|
1988
|
+
for (; n;) n.tagName === "UL" && (t += 1), n = n.parentElement;
|
|
1989
|
+
return t;
|
|
1990
|
+
}, Mi = (e) => {
|
|
1991
|
+
for (let t of Array.from(e.querySelectorAll("*"))) {
|
|
1992
|
+
if (!(t instanceof HTMLElement)) continue;
|
|
1993
|
+
let e = t.tagName.toLowerCase(), n = bi[e];
|
|
1994
|
+
if (n && Z(t, n), e === "a" && Z(t, xi), e === "ul") {
|
|
1995
|
+
let e = Math.min(Math.max(ji(t), 1), Ci.length);
|
|
1996
|
+
Z(t, {
|
|
1997
|
+
...Si,
|
|
1998
|
+
"list-style-type": Ci[e - 1]
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
e === "ol" && Z(t, {
|
|
2002
|
+
...Si,
|
|
2003
|
+
"list-style-type": "decimal"
|
|
2004
|
+
}), e === "li" && Z(t, t.classList.contains("editor-nested-listitem") ? Ti : wi), e === "pre" && Z(t, Ei), (e === "sup" || e === "sub") && Z(t, {
|
|
2005
|
+
...Ai,
|
|
2006
|
+
"vertical-align": e === "sup" ? "super" : "sub"
|
|
2007
|
+
}), e === "table" && Z(t, Di), (e === "td" || e === "th") && (Z(t, Oi), (e === "th" || t.classList.contains("editor-table-cell-header")) && Z(t, ki)), t.classList.contains("editor-text-underline-strikethrough") ? Z(t, { "text-decoration": "underline line-through" }) : t.classList.contains("editor-text-underline") ? Z(t, { "text-decoration": "underline" }) : t.classList.contains("editor-text-strikethrough") && Z(t, { "text-decoration": "line-through" });
|
|
2008
|
+
for (let e of Array.from(t.classList)) e.startsWith("editor-") && t.classList.remove(e);
|
|
2009
|
+
t.classList.length === 0 && t.removeAttribute("class");
|
|
2010
|
+
}
|
|
2011
|
+
}, Ni = (e) => {
|
|
2012
|
+
let t = e.parentNode;
|
|
2013
|
+
if (t) {
|
|
2014
|
+
for (; e.firstChild;) t.insertBefore(e.firstChild, e);
|
|
2015
|
+
t.removeChild(e);
|
|
489
2016
|
}
|
|
490
|
-
},
|
|
2017
|
+
}, Pi = (e) => {
|
|
2018
|
+
let t = !0;
|
|
2019
|
+
for (; t;) {
|
|
2020
|
+
t = !1;
|
|
2021
|
+
for (let n of Array.from(e.querySelectorAll("span, b, i"))) {
|
|
2022
|
+
if (n.attributes.length > 0) continue;
|
|
2023
|
+
let e = n.tagName.toLowerCase();
|
|
2024
|
+
if (e === "span") {
|
|
2025
|
+
Ni(n), t = !0;
|
|
2026
|
+
continue;
|
|
2027
|
+
}
|
|
2028
|
+
if (n.childElementCount !== 1 || n.childNodes.length !== 1) continue;
|
|
2029
|
+
let r = n.firstElementChild;
|
|
2030
|
+
(e === "b" && r?.tagName === "STRONG" || e === "i" && r?.tagName === "EM") && (Ni(n), t = !0);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
};
|
|
2034
|
+
function Fi(e) {
|
|
2035
|
+
if (!e.trim()) return e;
|
|
2036
|
+
let t = new DOMParser().parseFromString(e, "text/html");
|
|
2037
|
+
Mi(t.body), Pi(t.body);
|
|
2038
|
+
for (let e of Array.from(t.body.querySelectorAll("pre"))) e.textContent?.trim() || e.remove();
|
|
2039
|
+
return t.body.innerHTML;
|
|
2040
|
+
}
|
|
2041
|
+
//#endregion
|
|
2042
|
+
//#region src/components/Editor/utils/applyAiPolish.ts
|
|
2043
|
+
var Ii = "<!--bsy-block-->";
|
|
2044
|
+
function Li(e) {
|
|
2045
|
+
return e.join(`\n\n${Ii}\n\n`);
|
|
2046
|
+
}
|
|
2047
|
+
function Ri(e) {
|
|
2048
|
+
return e.includes("<!--bsy-block-->") ? e.split(Ii).map((e) => e.trim()) : [e];
|
|
2049
|
+
}
|
|
2050
|
+
function zi(e) {
|
|
2051
|
+
return e.split(Ii).join("").trim().length > 0;
|
|
2052
|
+
}
|
|
2053
|
+
function Bi(e, t) {
|
|
2054
|
+
let n = e.map(() => "");
|
|
2055
|
+
if (e.length === 0) return n;
|
|
2056
|
+
let r = [], i = [];
|
|
2057
|
+
if (e.forEach((e, t) => {
|
|
2058
|
+
for (let n of Array.from(e)) i.push(n), r.push(t);
|
|
2059
|
+
}), i.length === 0) return n[0] = t, n;
|
|
2060
|
+
let a = i, o = Array.from(t), s = a.length, c = o.length, l = Array.from({ length: s + 1 }, () => Array(c + 1).fill(0));
|
|
2061
|
+
for (let e = s - 1; e >= 0; e--) for (let t = c - 1; t >= 0; t--) l[e][t] = a[e] === o[t] ? l[e + 1][t + 1] + 1 : Math.max(l[e + 1][t], l[e][t + 1]);
|
|
2062
|
+
let u = 0, d = 0, f = r[0];
|
|
2063
|
+
for (; u < s && d < c;) a[u] === o[d] ? (f = r[u], n[f] += o[d], u += 1, d += 1) : l[u + 1][d] >= l[u][d + 1] ? (f = r[u], u += 1) : (n[f] += o[d], d += 1);
|
|
2064
|
+
for (; d < c;) n[n.length - 1] += o[d], d += 1;
|
|
2065
|
+
return n;
|
|
2066
|
+
}
|
|
2067
|
+
var Vi = new Set(["PRE"]), Hi = new Set([
|
|
2068
|
+
"PRE",
|
|
2069
|
+
"TABLE",
|
|
2070
|
+
"THEAD",
|
|
2071
|
+
"TBODY",
|
|
2072
|
+
"TR",
|
|
2073
|
+
"TD",
|
|
2074
|
+
"TH",
|
|
2075
|
+
"IMG",
|
|
2076
|
+
"BR"
|
|
2077
|
+
]);
|
|
2078
|
+
function Ui(e) {
|
|
2079
|
+
let t = [], n = (e) => {
|
|
2080
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
2081
|
+
let t = e.tagName;
|
|
2082
|
+
if (Vi.has(t)) return;
|
|
2083
|
+
for (let t of Array.from(e.childNodes)) n(t);
|
|
2084
|
+
return;
|
|
2085
|
+
}
|
|
2086
|
+
e.nodeType === Node.TEXT_NODE && t.push(e);
|
|
2087
|
+
};
|
|
2088
|
+
return n(e), t;
|
|
2089
|
+
}
|
|
2090
|
+
function Wi(e, t) {
|
|
2091
|
+
let n = e;
|
|
2092
|
+
for (; n && n !== t && !Hi.has(n.tagName) && !(n.textContent ?? "").trim() && !n.querySelector("img, pre, table, br");) {
|
|
2093
|
+
let e = n.parentElement;
|
|
2094
|
+
n.remove(), n = e;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
function Gi(e) {
|
|
2098
|
+
let t = e.tagName;
|
|
2099
|
+
return t === "PRE" || t === "IMG" || t === "TABLE";
|
|
2100
|
+
}
|
|
2101
|
+
function Ki(e) {
|
|
2102
|
+
let t = hi(e);
|
|
2103
|
+
return t ? Array.from(t.children).filter((e) => !Gi(e)).map((e) => e.textContent ?? "") : [];
|
|
2104
|
+
}
|
|
2105
|
+
function qi(e) {
|
|
2106
|
+
return e.includes("<!--bsy-block-->") ? e : Qr(e) || e;
|
|
2107
|
+
}
|
|
2108
|
+
function Ji(e, t) {
|
|
2109
|
+
let n = Ui(e);
|
|
2110
|
+
if (n.length === 0) {
|
|
2111
|
+
t && (e.querySelector("br")?.remove(), e.append(e.ownerDocument.createTextNode(t)));
|
|
2112
|
+
return;
|
|
2113
|
+
}
|
|
2114
|
+
let r = Bi(n.map((e) => e.textContent ?? ""), t);
|
|
2115
|
+
for (let t = 0; t < n.length; t++) {
|
|
2116
|
+
let i = r[t], a = n[t];
|
|
2117
|
+
if (i) {
|
|
2118
|
+
a.textContent = i;
|
|
2119
|
+
continue;
|
|
2120
|
+
}
|
|
2121
|
+
let o = a.parentElement;
|
|
2122
|
+
a.remove(), Wi(o, e);
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
function Yi(e, t) {
|
|
2126
|
+
let n = qi(t);
|
|
2127
|
+
if (!zi(n) || !e.trim()) return "";
|
|
2128
|
+
let r = hi(e);
|
|
2129
|
+
if (!r) return "";
|
|
2130
|
+
let i = Array.from(r.children).filter((e) => !Gi(e));
|
|
2131
|
+
if (i.length === 0) return "";
|
|
2132
|
+
let a = Ri(n), o = a.length === i.length ? a : Bi(i.map((e) => e.textContent ?? ""), a.join(""));
|
|
2133
|
+
for (let e = 0; e < i.length; e++) Ji(i[e], o[e] ?? "");
|
|
2134
|
+
return r.innerHTML;
|
|
2135
|
+
}
|
|
2136
|
+
function Xi(e, t) {
|
|
2137
|
+
let n = "";
|
|
2138
|
+
e.getEditorState().read(() => {
|
|
2139
|
+
n = Fi(X(he(e, null)));
|
|
2140
|
+
}, { editor: e });
|
|
2141
|
+
let r = X(Yi(n, t));
|
|
2142
|
+
return !r.trim() || ni(r, Qr(r)) ? !1 : (e.update(() => {
|
|
2143
|
+
ti(e, r), Dn(!0);
|
|
2144
|
+
}, { discrete: !0 }), !0);
|
|
2145
|
+
}
|
|
2146
|
+
//#endregion
|
|
2147
|
+
//#region src/components/Editor/utils/extractCodePlaceholders.ts
|
|
2148
|
+
function Zi(e) {
|
|
2149
|
+
if (!e.trim()) return {
|
|
2150
|
+
html: e,
|
|
2151
|
+
blocks: []
|
|
2152
|
+
};
|
|
2153
|
+
let t = new DOMParser().parseFromString(e, "text/html"), n = [], r = Array.from(t.body.querySelectorAll("pre"));
|
|
2154
|
+
for (let e of r) {
|
|
2155
|
+
n.push(e.outerHTML);
|
|
2156
|
+
let r = t.createComment(`bsy-code-${n.length - 1}`);
|
|
2157
|
+
e.replaceWith(r);
|
|
2158
|
+
}
|
|
2159
|
+
return {
|
|
2160
|
+
html: t.body.innerHTML,
|
|
2161
|
+
blocks: n
|
|
2162
|
+
};
|
|
2163
|
+
}
|
|
2164
|
+
//#endregion
|
|
2165
|
+
//#region src/components/Editor/utils/readEditorAiSnapshot.ts
|
|
2166
|
+
function Qi(e) {
|
|
2167
|
+
let t = "", n = "", r = "";
|
|
2168
|
+
e.getEditorState().read(() => {
|
|
2169
|
+
n = L().getTextContent(), t = Fi(X(he(e, null))), r = Li(Ki(t));
|
|
2170
|
+
}, { editor: e });
|
|
2171
|
+
let i = Zi(t);
|
|
2172
|
+
return {
|
|
2173
|
+
html: t,
|
|
2174
|
+
text: n,
|
|
2175
|
+
polishText: r,
|
|
2176
|
+
htmlWithoutCode: i.html,
|
|
2177
|
+
codeBlocks: i.blocks
|
|
2178
|
+
};
|
|
2179
|
+
}
|
|
2180
|
+
//#endregion
|
|
2181
|
+
//#region src/components/Editor/Preview/preview.module.scss
|
|
2182
|
+
var Q = {
|
|
2183
|
+
"bsy-lexical-ai__trigger": "_bsy-lexical-ai__trigger_p7v4i_1",
|
|
2184
|
+
"bsy-lexical-ai__icon": "_bsy-lexical-ai__icon_p7v4i_4",
|
|
2185
|
+
"bsy-lexical-ai__dialog": "_bsy-lexical-ai__dialog_p7v4i_11",
|
|
2186
|
+
"bsy-lexical-ai__pane": "_bsy-lexical-ai__pane_p7v4i_16",
|
|
2187
|
+
"bsy-lexical-ai__column": "_bsy-lexical-ai__column_p7v4i_22",
|
|
2188
|
+
"bsy-lexical-ai__column-head": "_bsy-lexical-ai__column-head_p7v4i_32",
|
|
2189
|
+
"bsy-lexical-ai__column-title": "_bsy-lexical-ai__column-title_p7v4i_39",
|
|
2190
|
+
"bsy-lexical-ai__column-title--before": "_bsy-lexical-ai__column-title--before_p7v4i_53",
|
|
2191
|
+
"bsy-lexical-ai__column-dot": "_bsy-lexical-ai__column-dot_p7v4i_57",
|
|
2192
|
+
"bsy-lexical-ai__column-title--after": "_bsy-lexical-ai__column-title--after_p7v4i_60",
|
|
2193
|
+
"bsy-lexical-ai__column-stack": "_bsy-lexical-ai__column-stack_p7v4i_73",
|
|
2194
|
+
"bsy-lexical-ai__column-body": "_bsy-lexical-ai__column-body_p7v4i_79",
|
|
2195
|
+
"bsy-lexical-ai__think-pin": "_bsy-lexical-ai__think-pin_p7v4i_86",
|
|
2196
|
+
"bsy-lexical-ai__think-head": "_bsy-lexical-ai__think-head_p7v4i_90",
|
|
2197
|
+
"bsy-lexical-ai__think-label": "_bsy-lexical-ai__think-label_p7v4i_109",
|
|
2198
|
+
"bsy-lexical-ai__think-label--shimmer": "_bsy-lexical-ai__think-label--shimmer_p7v4i_113",
|
|
2199
|
+
"bsy-lexical-ai-think-shimmer": "_bsy-lexical-ai-think-shimmer_p7v4i_1",
|
|
2200
|
+
"bsy-lexical-ai__think-arrow": "_bsy-lexical-ai__think-arrow_p7v4i_124",
|
|
2201
|
+
"bsy-lexical-ai__think-arrow--open": "_bsy-lexical-ai__think-arrow--open_p7v4i_131",
|
|
2202
|
+
"bsy-lexical-ai__think-icon": "_bsy-lexical-ai__think-icon_p7v4i_134",
|
|
2203
|
+
"bsy-lexical-ai-think": "_bsy-lexical-ai-think_p7v4i_1",
|
|
2204
|
+
"bsy-lexical-ai__think-collapse": "_bsy-lexical-ai__think-collapse_p7v4i_146",
|
|
2205
|
+
"bsy-lexical-ai__think-collapse--grown": "_bsy-lexical-ai__think-collapse--grown_p7v4i_151",
|
|
2206
|
+
"bsy-lexical-ai__think-body": "_bsy-lexical-ai__think-body_p7v4i_155",
|
|
2207
|
+
"bsy-lexical-ai__footer": "_bsy-lexical-ai__footer_p7v4i_165",
|
|
2208
|
+
"bsy-lexical-ai__error": "_bsy-lexical-ai__error_p7v4i_173",
|
|
2209
|
+
"bsy-lexical-ai__preset": "_bsy-lexical-ai__preset_p7v4i_178"
|
|
2210
|
+
}, $i = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAYAAACohjseAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAADNBJREFUeAG1WuuvXUUV/619dqEPaG+pUFqg3AKFIoFWkKeKLWLRaKD6vVGMMcYQC8EPmBge/4A0fpEQEkmMz0QjH8CoIa3WUGwQ2oAiFWiFthb77qXvy1nOY83MWrP3qY2hk3vu3mfPzJr1+K3HzD6EqrXf5GVg3MPASncdd4+YCMTsvgHk7sEcx/r71Hy/H6e+Q49Nj/00RTPTSfOreXpNPcfw4q6b3GXTFMJjx56gbXrBzNDY/Tx2+DgecQ9WG96psCVCJqZILcqum1gtDM7CyMOusJlhP5ZEcKFDijdGpYg4prCmFD1krJlxNh47sIYOZAG9cCcmsdbdLmVYZhMj2jJ9FqkE1yPYjCCQ0pkhZHSalFdWybIwzH1RmAjeNM6aDZZ7IVvfM8l4ZDBwwhVN6sVIM8MVsTQm94UV4q2MISWoZaorhFkXfQqoeSx0tcWXDoFH3O0DNPYQj+MEtnJli5GQUlTo1LA1nDIsbS1TR0AF77BGZ7CaXrmD4sUrennbfOAkbawzF9ag2LKISg+bbh80Y1QGm2DVO54z04R+VzBT9H+1jqa5sh00WIKu9JSALjSowj1Vy3egXXOiAkUdlCLBJgwzUdKyFAKIiQfod2VtmLu9gB8zXgLLKidpklblv4mgKrqpcX1yjn5mwmI/jabHimHtYQw8SXjlXgvbZiAdrMhDBEkCa7xnETOMyOiMsmJ0yC/jOM8K9wILUgpSdi0jb10IumUceHxtXioruGmFTzb8h2vbtpFRkZqyNQvDQVC3OhNLkJF7pQSlU9T2CHSzDqgOlpEtE5alLyd991lwHvDgHSEFYM26KECA+DDAOyqKuyhpGxvSI+NNWDZpkwzrKH1h/QbqcRSYipropoXgFYuAFYuBmVPDhw4dA/6+C/jVZuD3W4BDR8Xv+3wqrkULZscHDywDbh0HXvwXsP0AaMdB4C/vyMweWLftIFtCR4OSU1hhmjKMsuUYHSjmtvgC4Oerulr1gnq4+c/qg6C7nwImjlfrWrp0zbwyP8317fl/gl/artZIiJN5Psj0O7fygGxZJRwL6qkISkRKKe76tZvxP9vFs4C7nHV//ZogSSOGol6/cgNw55Xdud56Dz0LckUKS64MXAmqgpDtoBViSnVJg6HDwjQLYkI9ST5nRcJ9u2kBCKfRvnwd8MzrJWcSFZ+aPxO475PdOd7iX/0FcORk8EuSSG8QFywYoigkwGgRSWnTLyhBxVgMJiea2HrP1aCLZuG02o2XALOngQSmkWZECn/2KtCWPcC5ZwNXnV/m7DwE7HrfCTdArxaTkiNEJbAkhqkqU9hcJJAACb5pgRT1wvUzi9Db3thtGU1t5bXAT142/h7az1wg+umm+H2mE/KxFcDyy5yAEy6ADExg08KVwtsHGYfhMNhfHWR9XnEd7jqIYTmMaeI4GYPU5xXkx+a57vslY46Jy7tCeAt9fz16m2e6bYXmoFpziqPvnh+eBH/nWeDJjc56E4W3NvLDmT/3zH8Pff4GXKCltJGgKPYpkTNYmoolWRcBrt24oF+IP24FXtkVBfWQ081bdda0HE1LoxILkls89RIw/9xswRzsuOLNP2+8loL1/FU01pQPi2U5aLMRK8n4NDYhIKHgi4v7BfztlkjruS3dPi+wt3peL1kjoUS+J7T854iymkJXGEfyvfGW7E5mESiZGlq4rJAieCbs5180Br5+flcAHxA2vxdp/vmdfgV84arMS2a4LfdRGMqKjUoXnhutkDbzB58m2FQtVMFDp4iqnNKb1QTVZeP9zL/y77igb2/vB94/AZxzlh2zaI6D6dTYp3kQ6OXdvL93FVosuBx/D90OPP2KU+Jhy6+/81HUpnkuohLMxjWVdJ19V6Lg/z63qD/3/eHtKKAnevQD4C0n5JK5dowX+Mrzg6X1QUeptNID71vpi2ufujR+3twHenitVVDKgzlYJA11ONQJXwUkPeTy2aArzuvMDAu+ujtCPDm/E5hqAROzr+1W1Yy6+n9DDpVKprPqWlBCwgvbnfKGAbKZr3YwsAWgG0wP3x79ZYObcMEM4LoLYkh+4q/KvigKTdPvugK9bcOO6BthrJwe+Gd9bYVLF0++jJHZu4lU8lbt+W1gr5AHb3FF9868ThzNPoUMLLNHZSPrNAP/Se3xjdG5Aw5lB+JrAwnJ4cFtF/fDc6uD47yZGd7Zz992B3uXjdmx3hpL50WLK/UVR0G+81sl2u12JnvcbuS7Dpp7jhXrsaS7DFGp/QIJr4lrq2pj464YtToLSQ5cOBs8dwZ62zeuj5/TbR66f9tniu8+xREGJTc64UIE1rWjb23blISeSq6m6VJLuUaXQZrQnZf2W+//abdcBPzyDVU66EDHvfFBnz4UHn0t6oVJu+Z0CnTzvP5F171bIKZwHabePB8fWls4Kyb+I5PWyTkGmLKjS+ZTwVEHST8u5EHZ6gTGp09xgWU68NxWt+veB8xw/R+/EOR9Zf0OKYMAFcNBH5ka53yY7Y5LIw/ZXFqj8Xssz0jtVTVjMitCVBn9uMugq/9UCHkB1u+M96FuVduotJCz3kh4bjsULTGqnT8tfup2k0PR795VfkjqVEGOMXQ+1gpn9T0W21D5TR8QpUveD+Womed4gjfO7WfeR7fvvaiUX4ri7Md3ucJ8VU/tOj5TYHrSKE+vm9EEFGtajqWSUeeIlGoiVo5bCpWOwjyE6eqe5O7b6/ul4re+Au0rm/a6ZN0TJae7evKymaDXD4hQmj+UfSAA8yoAFar9sWHpFEY4aaGRLoEEbJUTIPLRORjZHPNQ27G0DBVAgPefAPkQ7/24bjc4ZGyZKMwyYM/Qk0TU6csBp/EMpI1r2rCmyr1t1FZE7n1/05StyoyzRgv41oTaVjVS/cfKP60ZdgMb3uuf/4kLy06mqXkpOxrbJxtdatLOxx7YJD3nkkqtZyJ2eviqg+FeZ4E5lQW2uBMv9zhUFvlQWXm7Cna01m2Cb5vbpeFbShc1N8mHEz8J+pBU0iTi39rAw9xZZndfWxbJuIF9QTrnbNB17mD2Eqlk9rpd+WaXYrYfiVMUMwZieQEOwvHyeaDpsqVyc/lFV2M64QwPOc/ppC9lW3YvxRvdt5GHVPaDOdLB5pO+94WnbtV89B/zj6pMimKsijtR0tDq3iHnwZ63Q2xYTeGdBB5JVZQDj5nF9fsLfeqjAlVHEUrwhBbTI9wILHTl0ksrF9uAYYFQEy4LpCzIPFTvIaQvHbgqRAT9wVYd/Y2qlyhabWxgWaAJdBWkBZT9IDMbZplVjsnVkaogwnFFk8s8KIYoi6tZl//M6JxjpjVhgaiLykitKX0yOq5dbQ5y3uX08sWSNxjKBLgLQ5A2UhyjIFsUg55CAnYcwSpXH10qxs3bLDUXnUApi7eDemuk4JDgFi5yTCDZ3hToU91n8bmKQuHM/p4FnbiVU4XhQP75s5utR2J9nPnuK7Lt266iKcjLF/n5SHLasCNJRc2wrEg90MEsN/9e925hrMUZaQfcy5Wnd7iK52Q5N8oKE/8eshEqu7//3oZXT2yzgH47Y19P5HyWNf6lC8+ccL6Nue3byrmgH+8quVmEzOhokOOCxKisBXeYTYL3FDwgWmpKoEHlCxpq49NwxptfY6BgJS3xR0YwVS0hQHSQmY7zBYgqimpBkZ6lMQcnI0zPZPNrND4YDov/JJdJ/KV3F7DFBWUBUZzb5JgsKAruff6TaMgvTIA+PxtntK2biIWzHFeQYphR3CkHSB1ofJowL0UJlWCDnNCzbrgpaeEfJ8B73YnyNa5QPkvZuYqYJpLWbVSedufF/OYx0LvH5cgSJWcrGGoCpHOiH9s2JQ/q1GzCtvxMg1SyyXD2i+110Fl/pDCrI5oRRPuQzR8ZHNzDhxz5Z9LGErDKzBFUihJvwW3sf/iqy6BuEVz7Zgk+KeF1fffUxbk1cZmD8lze1RfB1VhDqvihDTyMzd4Hn3FEVhPMIY7RlGKYKsYN6nRfJzilGhYg4w9KCX58I3iSV+FlL2mNhFFCKp783E30wwle5jaHa1PQ0D9GUEKl43nSYmn/1s9HNaHfx2Q9M+8bNU8mDnA13io6zBlOYmF4+NQEr3HH4N9WNWBK/lDs6A0mdGJVkMLQ5iq7eNfviu/XfWn3UI+B6pd7sTybgmaIH3z9HLo/ZLDBOXiUTuDTbsQSIVUzFIMAqWCjRVeaa6xKyj1B66YewyaPFTat8F216ViRBXb/N2MaHoWe9iPmscFk+Bnw/Yp9eywAVRKp/VmPcxiWSogcna/UOP3GGXWq6RAvqog3znLDKXj0XlI/StfNCTo+ZegEJSx11lhSa1XxmbYpdDoJT+/RRlqlh/+6PFPQpaITbBsSfsOTeGbVFFqnif0XGylI3w1jW9QAAAAASUVORK5CYII=", ea = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAACb9JREFUeAHtW09sHFcZ/739Y9nxJt4WQv8g1WO1ICQOXquiqAeU3Z6QENhWhUThYPsCpAVsl1RqeiBrCQhIiBqlLVWRakccegDJTi8gkLobLkTlYPuAesObXJB6aDZq0rSOd79+b+b9m9lZe707jp3Kv3Y7M2/evHnf733/3jcucIQjHOEIR0gO/XPk4R5CCgkiz8Ify6Jy8gUq4B5BsgR8Dt6JHLzBHNYe+yXN4R5ABgkiz8JDmMvfP36Bxvlyk8+vpdJY3/oE1fV5UcchQrIE5DEqj8T/suCCj6cgf8S0CFTffVas4pAhMQK+u0KFTwizUmqG1gPBTBD/U9vawkzcc4NzVMgCtfriwWhGIgT8+N/kfXQLKwPygiI3pfANPPX206IW9+wXT2JCZDD+2AWaFynU//OcWMddRM8ElNcof72BSvY4PCHC9yQX7GUv/+GJeOElHn0U440GCqwz72zdwQI33WMEjIk6kzC2NQCv2USeSSiww5tNpTCsCLja7tlnr9BsYxsFyVuzgY03TokF3GUI7APOb5KX6cMKq3SB1WDyzMPtnV95k/I8ibm+NApnHxET0fucW+Q/vIUJJnOI+1z6+PX22tQN9oUAjTc+pMVGBqunB0R1t75Lt8mbGbDCScE/2sIsn86BNcu6VZS3XktOU/aVgG4x8DOaTRHKRCx4AD+Q8jWxiQk2sdLNxd1J7QSJ5gES+TLlUeeJ83/r5b2FtvwZKlIDSyyo5zS7cUUvmDSVKhJAogTc/wLN4ibKPGqej/J6nVesxgJVedU2cv1Yr8WQ8vkXfcHPcb8i0n6TFNoXltSZo6oyrxhCQkjMBB58iabZk78pR5STlqrqT1UYQUjJUWfnKEOdH+6awCgnT6XQYEZ8dUmBFqgxJdbf/60YQwJITAPSKQ59QosLq7gCwZpZSLsucntR6G4BYWa1o8/6zcLvgiZf83s8JITENGC4TNdlqJJrLtPfYNk7GF+vqdPXf16PE+gQ6Z56bM4v7q+Ve0+fk9OANGp8KKgFjBfcGoXViHiSRNxRaYBgEyLOCaQmHR4CMhls8CFaCIlYM6xn6BJpNU4z5b+rhh6RpAassZFOmQYW1HeGWnnlygV2bvyEr9H22vUAliCj/GpU3UwYRgJIjgCBDQ51UWdmVVgJ6du2fUyEhFPRg1yhgzFEyDkGGEECiCUg9xMqiiyG04TLvE+vyTZZ7+OQNcHOZ1W3hQbKYD2Viax0K9w2TZNw7lKINDiERu5z+ygSQKwtemXyKChlyRfJeJ2X2Rn/6tcWxH3tBnviVdqEClHRBVPXRhRXMO3hjKARzxGNrPo+h8PSldO9pcSxGsDhpfb116gmheFJjQqlgNTE5Ws7DZb1yfJgZ06c6ZiVlAeKukUJx0+o54JW5zpEgjWRpeISlaoz3e8Q2/qAB76AS/ySWbihiFDBToNleO9vJxc8l47x+jGxPySk9gWw/Rzfos1MkilrEO8wCU91S0JbAh56EKMU9sByUjs6HukHEKkJwjlxEhwYZ6gF0vVDuGkPoiS5PkCblCcX5ptvUenvz+ydhJ004JSaiJkQz3gccn/eBhwKh4Q7UWG9vrA8+EeXDMAhAY647lhBgxmLwg5TmmpXJMQS8PotGt/ewo3GHVzkguYqhzePOxa5yvOdP14n7/R98S/JZv0KkJmpWeGmUmFlvZoMirg7x3GafuSwQqIljNp9BPy8oDKxQqXVyc5JiI0CK0T5SRGfZ/NmPT8Tc49fLO3xf8KJ/+GwHU6DtckbEtwV1dFBhLMjZyRjKNEIwdc1TpUnmYSOiqsCCeHpt0kWMqbUoCaZEW72pg/KqcXlfmrrK/Sz5NqEGzrtthtW2YL+3FbnnKT0l2/tTkIimeD3/uav/pTrrY2au4JE9gEtSQ4C5yiPWvUp2q5vOeSq0OhGiiHu/zKflXabeyIEcBp8jv1ESJuieQyFnRmCOYd8QFgprHTCURRy/IvbX7hEqXtFdICeCZiucNbYwDShRd1tJHBSXrOCStGDDAvGKfjnvN0VTfNZTZhM0QptVd6OJ4Q1I98MOpl/zwTw6i/JUSji4JRamqwuNFl1T0RVQSiLCPb81i/AFkhAlkzYwot9lSWhow+xPRHww3/RBE+6qK9JRQA1EWOfQll4JOaHbAFO9uj4Ba0Vtn84TsZslP2iSXVwG/PoAD0RwHmBdDQkqDXB8Sdp7dJENv2faL/QM2RzBfd9rtKYNjdT5e+QnLss/OkbnW+QuiZg7l0qkFOcpHCaGlbV6KSDg7Fnx5uRm0O4TtF9T6heGNyu8jfGhVee3PvOsGsCOOuTJW04zs+dp4gIE05+nKX0fUfK72sSG4ostXURamwYYnzBF7/W/Za4awLucMbFhcm6H3NhHRWM9ZukJJgsOTmBGzHshdufRMgrWGVQ0eVSqoH534z1/qFUoAe89B5N84yW9EiOl7d22WY3F2oD3DqxGQuRnZ9PImHh118VZSSEngiQKL/HeUDarxsUeJLyU7epDIugMLrrO0L9AgadZDKE5YUvixl5Ir8e397CFHt8Ly0/m7/SnRn0TEAc+Jt/AdvIpzNct2tCltBG2c5HeRlHIl3DPs5qCLmJjSYow/WIsyOqRvk8rfDD48Fj/MU4hfkPficWsUfsCwHt8KtNmuaJnuNTb4c3682SLRkGNC2ffSRYfa5ZFhpNrJlIoU4yaUzXzomL2APuKgES5/9PHlebK8L5BK6EDRwdRdyewnaKV/+hYPW/cp48keaiLUX68TkTPP3fM52TcNcJkHiZSeBaYQWKBC2HIcLdIQaErM4/ICbdMR6/QMv8QXZKxddQbsBb4ekrP+qMhAMhQEKSwJnkGmD+CsSgxXk2UfrpyVYnx8XQZV7xKUB7DqMPN9j/lP75g93rAQdGgMSrN6kgGmwO8P/gIZTwGScoUD19QpTajfHtv1KF+50CQTgjyHB8oy/FRZFdKkOJ/rH0XvFcTqxnuXzF1WTBP/g//ryWzQSZJh+J7y/vNAaHwMncIDaOHwedyAHyd5x/3JbvO4bK9/+x81+uH6gGaCzd5oQqhTfJbpa0L6jN9IuR3Z7nmkS+L4MKfykqOH9ToJ1LrZ81YfHJ+KzxUBAg8edtf2std5fDavtbvZPGDBdga508P7dGeVYeaQ5yxcndavPp1cEhjJVHWou5h4YAjbeIinyoPSP2nue/yFlpf9b/euXJ69DujDD/iy+1JkqHjoBeIfOMPtYElswTzq6av2s+//OHWwk4UCe4H5DJUqofpVwONXaEgo8YzOHqsYH4EtlnTgM0+COFl26gyD5hiLPIizPicP2fKkc4whGOcCjwKViIGaRSStOhAAAAAElFTkSuQmCC", ta = 16, na = ({ disabled: t, tooltip: n, showDisabledTooltip: r }) => {
|
|
2211
|
+
let [i] = B(), { typeset: o, polish: s, canTypeset: c, canPolish: l, aiOpen: u, setAiOpen: d, aiSessionRef: p } = hr(), { hasEditorText: m } = J(), { t: h } = a(), { iconSize: g } = Hn(), _ = t || !c || !m, x = t || !l || !m, S = t || !!u, C = T(() => {
|
|
2212
|
+
if (t || !c || !o) return;
|
|
2213
|
+
let e = Qi(i);
|
|
2214
|
+
e.text.trim() && (p.current = {
|
|
2215
|
+
originalHtml: e.html,
|
|
2216
|
+
codeBlocks: e.codeBlocks
|
|
2217
|
+
}, d("typeset"), o({
|
|
2218
|
+
text: e.text,
|
|
2219
|
+
html: e.htmlWithoutCode
|
|
2220
|
+
}));
|
|
2221
|
+
}, [
|
|
2222
|
+
p,
|
|
2223
|
+
c,
|
|
2224
|
+
t,
|
|
2225
|
+
i,
|
|
2226
|
+
d,
|
|
2227
|
+
o
|
|
2228
|
+
]), w = T((e) => {
|
|
2229
|
+
if (t || !l || !s) return;
|
|
2230
|
+
let n = Qi(i);
|
|
2231
|
+
zi(n.polishText) && (p.current = {
|
|
2232
|
+
originalHtml: n.html,
|
|
2233
|
+
originalText: n.polishText,
|
|
2234
|
+
preset: e
|
|
2235
|
+
}, d("polish"), s({
|
|
2236
|
+
text: n.polishText,
|
|
2237
|
+
preset: e
|
|
2238
|
+
}));
|
|
2239
|
+
}, [
|
|
2240
|
+
p,
|
|
2241
|
+
l,
|
|
2242
|
+
t,
|
|
2243
|
+
i,
|
|
2244
|
+
s,
|
|
2245
|
+
d
|
|
2246
|
+
]), E = T((e) => {
|
|
2247
|
+
if (e.key === "typeset") {
|
|
2248
|
+
C();
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
Yr.includes(e.key) && w(e.key);
|
|
2252
|
+
}, [w, C]), D = [{
|
|
2253
|
+
key: "typeset",
|
|
2254
|
+
label: h("editor.aiTypeset"),
|
|
2255
|
+
disabled: _,
|
|
2256
|
+
icon: /* @__PURE__ */ y("img", {
|
|
2257
|
+
src: $i,
|
|
2258
|
+
alt: "",
|
|
2259
|
+
width: ta,
|
|
2260
|
+
height: ta,
|
|
2261
|
+
className: Q["bsy-lexical-ai__icon"],
|
|
2262
|
+
draggable: !1
|
|
2263
|
+
})
|
|
2264
|
+
}, {
|
|
2265
|
+
key: "polish",
|
|
2266
|
+
label: h("editor.aiPolish"),
|
|
2267
|
+
disabled: x,
|
|
2268
|
+
icon: /* @__PURE__ */ y("img", {
|
|
2269
|
+
src: ea,
|
|
2270
|
+
alt: "",
|
|
2271
|
+
width: ta,
|
|
2272
|
+
height: ta,
|
|
2273
|
+
className: Q["bsy-lexical-ai__icon"],
|
|
2274
|
+
draggable: !1
|
|
2275
|
+
}),
|
|
2276
|
+
children: Yr.map((e) => ({
|
|
2277
|
+
key: e,
|
|
2278
|
+
label: h(Xr[e])
|
|
2279
|
+
}))
|
|
2280
|
+
}], O = /* @__PURE__ */ y("div", {
|
|
2281
|
+
className: I(G["bsy-lexical__toolbar-select"], G["bsy-lexical__toolbar-select--ai"], Q["bsy-lexical-ai__trigger"]),
|
|
2282
|
+
children: /* @__PURE__ */ y(q, {
|
|
2283
|
+
tooltip: n,
|
|
2284
|
+
showDisabledTooltip: r,
|
|
2285
|
+
disabled: S,
|
|
2286
|
+
icon: /* @__PURE__ */ b(v, { children: [
|
|
2287
|
+
/* @__PURE__ */ y("img", {
|
|
2288
|
+
src: $i,
|
|
2289
|
+
alt: "",
|
|
2290
|
+
width: ta,
|
|
2291
|
+
height: ta,
|
|
2292
|
+
className: Q["bsy-lexical-ai__icon"],
|
|
2293
|
+
draggable: !1
|
|
2294
|
+
}),
|
|
2295
|
+
/* @__PURE__ */ y("span", {
|
|
2296
|
+
className: G["bsy-lexical__toolbar-select-label"],
|
|
2297
|
+
children: h("editor.aiTypeset")
|
|
2298
|
+
}),
|
|
2299
|
+
/* @__PURE__ */ y(e, {
|
|
2300
|
+
name: "arrow-down",
|
|
2301
|
+
size: g,
|
|
2302
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
2303
|
+
})
|
|
2304
|
+
] })
|
|
2305
|
+
})
|
|
2306
|
+
});
|
|
2307
|
+
return S ? O : /* @__PURE__ */ y(f, {
|
|
2308
|
+
menus: D,
|
|
2309
|
+
onClick: E,
|
|
2310
|
+
showSearch: !1,
|
|
2311
|
+
offset: W,
|
|
2312
|
+
style: {
|
|
2313
|
+
width: 147,
|
|
2314
|
+
minWidth: 147
|
|
2315
|
+
},
|
|
2316
|
+
children: O
|
|
2317
|
+
});
|
|
2318
|
+
}, ra = /* @__PURE__ */ new Map(), ia = (e, t) => {
|
|
2319
|
+
if (!e) throw Error("registerToolbarButton: name is required");
|
|
2320
|
+
ra.set(e, t);
|
|
2321
|
+
}, aa = (e) => {
|
|
2322
|
+
ra.delete(e);
|
|
2323
|
+
}, oa = (e) => ra.get(e), sa = () => Array.from(ra.keys());
|
|
2324
|
+
Object.entries({
|
|
2325
|
+
undo: kr,
|
|
2326
|
+
redo: Ar,
|
|
2327
|
+
bold: Wn,
|
|
2328
|
+
underline: Gn,
|
|
2329
|
+
italic: Kn,
|
|
2330
|
+
strikethrough: jr,
|
|
2331
|
+
superscript: Mr,
|
|
2332
|
+
subscript: Nr,
|
|
2333
|
+
heading: Gr,
|
|
2334
|
+
fontSize: qn,
|
|
2335
|
+
fontColor: nr,
|
|
2336
|
+
fill: rr,
|
|
2337
|
+
clearFormat: qr,
|
|
2338
|
+
bullet: Ir,
|
|
2339
|
+
number: Lr,
|
|
2340
|
+
outdent: Fr,
|
|
2341
|
+
indent: Pr,
|
|
2342
|
+
align: ar,
|
|
2343
|
+
link: sr,
|
|
2344
|
+
unLink: cr,
|
|
2345
|
+
picture: Or,
|
|
2346
|
+
code: Rr,
|
|
2347
|
+
table: Vr,
|
|
2348
|
+
source: Wr,
|
|
2349
|
+
ai: na
|
|
2350
|
+
}).forEach(([e, t]) => {
|
|
2351
|
+
ia(e, t);
|
|
2352
|
+
});
|
|
2353
|
+
//#endregion
|
|
2354
|
+
//#region src/components/Editor/utils/getToolbarItems.ts
|
|
2355
|
+
var ca = (e, t, n) => {
|
|
491
2356
|
if (n) return [
|
|
492
2357
|
{
|
|
493
2358
|
kind: "button",
|
|
@@ -545,130 +2410,180 @@ var mn = (e) => {
|
|
|
545
2410
|
key: `divider-${t.key}`
|
|
546
2411
|
});
|
|
547
2412
|
}), r;
|
|
548
|
-
},
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
2413
|
+
}, la = Cn.map((e) => ({
|
|
2414
|
+
key: e.id,
|
|
2415
|
+
label: e.label
|
|
2416
|
+
})), ua = () => {
|
|
2417
|
+
let [t] = B(), { codeLanguage: n } = J(), { t: r } = a(), { iconSize: i } = Hn(), o = T((e) => {
|
|
2418
|
+
let n = e.key;
|
|
2419
|
+
K(t), t.update(() => {
|
|
2420
|
+
let e = R();
|
|
2421
|
+
z(e) && H(e.anchor.getNode(), V)?.setLanguage(n);
|
|
2422
|
+
});
|
|
2423
|
+
}, [t]), s = wn[n].label;
|
|
2424
|
+
return /* @__PURE__ */ y(f, {
|
|
2425
|
+
menus: la,
|
|
2426
|
+
onClick: o,
|
|
2427
|
+
activeKey: [n],
|
|
2428
|
+
showSearch: !1,
|
|
2429
|
+
offset: W,
|
|
2430
|
+
style: {
|
|
2431
|
+
width: 120,
|
|
2432
|
+
minWidth: 120
|
|
2433
|
+
},
|
|
2434
|
+
children: /* @__PURE__ */ y("div", {
|
|
2435
|
+
className: G["bsy-lexical__toolbar-select"],
|
|
2436
|
+
style: { width: 120 },
|
|
2437
|
+
children: /* @__PURE__ */ y(q, {
|
|
2438
|
+
icon: /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("span", {
|
|
2439
|
+
className: G["bsy-lexical__toolbar-select-label"],
|
|
2440
|
+
children: s
|
|
2441
|
+
}), /* @__PURE__ */ y(e, {
|
|
2442
|
+
name: "arrow-down",
|
|
2443
|
+
size: i,
|
|
2444
|
+
className: G["bsy-lexical__toolbar-select-arrow"]
|
|
2445
|
+
})] }),
|
|
2446
|
+
tooltip: r("editor.codeLanguage")
|
|
2447
|
+
})
|
|
2448
|
+
})
|
|
2449
|
+
});
|
|
2450
|
+
}, da = {
|
|
2451
|
+
initial: {
|
|
2452
|
+
opacity: 0,
|
|
2453
|
+
x: 6
|
|
2454
|
+
},
|
|
2455
|
+
animate: {
|
|
2456
|
+
opacity: 1,
|
|
2457
|
+
x: 0
|
|
2458
|
+
},
|
|
2459
|
+
exit: {
|
|
2460
|
+
opacity: 0,
|
|
2461
|
+
x: -6
|
|
2462
|
+
}
|
|
2463
|
+
}, fa = (e) => {
|
|
2464
|
+
if (e.kind === "divider") return /* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] });
|
|
2465
|
+
if (e.kind === "language") return /* @__PURE__ */ y(ua, {});
|
|
2466
|
+
let t = oa(e.name);
|
|
2467
|
+
return t ? /* @__PURE__ */ y(t, { ...e.props }) : (console.warn(`[ToolbarPlugin] Button "${e.name}" is not registered.`), null);
|
|
2468
|
+
}, pa = C(function({ item: e, motionProps: t, transition: n }, r) {
|
|
2469
|
+
let i = fa(e);
|
|
2470
|
+
return i === null ? null : /* @__PURE__ */ y(oe.div, {
|
|
556
2471
|
ref: r,
|
|
557
2472
|
"data-toolbar-item-key": e.key,
|
|
558
|
-
className:
|
|
2473
|
+
className: I(G["bsy-lexical__toolbar-item"], e.kind === "button" && e.props?.disabled && G["bsy-lexical__toolbar-item--disabled"]),
|
|
559
2474
|
layout: "position",
|
|
560
2475
|
transition: n,
|
|
561
2476
|
...t,
|
|
562
2477
|
children: i
|
|
563
2478
|
}, e.key);
|
|
564
|
-
}),
|
|
565
|
-
let { isCodeBlock:
|
|
2479
|
+
}), ma = ({ config: e, sizeToken: t }) => {
|
|
2480
|
+
let { isCodeBlock: n } = J(), { isSourceMode: r } = Ur(), i = se(), o = M(() => ca(e, n, r), [
|
|
566
2481
|
e,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
]), s = o.map((e) => e.key).join("|"), { t: c } =
|
|
2482
|
+
n,
|
|
2483
|
+
r
|
|
2484
|
+
]), s = o.map((e) => e.key).join("|"), { t: c } = a(), l = N(null), u = N({}), d = N(null), f = N(!0), [p, m] = P({
|
|
570
2485
|
keys: s,
|
|
571
2486
|
count: o.length
|
|
572
2487
|
});
|
|
573
|
-
|
|
2488
|
+
p.keys !== s && m({
|
|
574
2489
|
keys: s,
|
|
575
2490
|
count: o.length
|
|
576
2491
|
});
|
|
577
|
-
let
|
|
578
|
-
|
|
579
|
-
let [
|
|
580
|
-
duration:
|
|
2492
|
+
let h = p.keys === s ? p.count : o.length, g = N(h);
|
|
2493
|
+
g.current = h;
|
|
2494
|
+
let [_, v] = P(!1), x = {
|
|
2495
|
+
duration: i ? 0 : .16,
|
|
581
2496
|
ease: "easeOut"
|
|
582
|
-
},
|
|
2497
|
+
}, S = i ? {} : da, C = T(() => {
|
|
583
2498
|
let e = l.current;
|
|
584
|
-
if (!e ||
|
|
2499
|
+
if (!e || f.current && g.current !== o.length) return;
|
|
585
2500
|
let t = getComputedStyle(e), n = Number.parseFloat(t.columnGap || t.gap) || 0, r = e.clientWidth, i = new Set(o.map((e) => e.key));
|
|
586
2501
|
e.querySelectorAll("[data-toolbar-item-key]").forEach((e) => {
|
|
587
2502
|
let t = e.dataset.toolbarItemKey;
|
|
588
2503
|
if (!t || !i.has(t)) return;
|
|
589
2504
|
let n = e.getBoundingClientRect().width;
|
|
590
|
-
(n > 0 ||
|
|
2505
|
+
(n > 0 || f.current) && (u.current[t] = n);
|
|
591
2506
|
});
|
|
592
|
-
let a =
|
|
593
|
-
width:
|
|
2507
|
+
let a = d.current?.offsetWidth ?? 0, c = o.map((e) => ({
|
|
2508
|
+
width: u.current[e.key] ?? 0,
|
|
594
2509
|
isDivider: e.kind === "divider"
|
|
595
2510
|
}));
|
|
596
|
-
|
|
2511
|
+
f.current && o.length > 0 && c.every((e) => e.width <= 0) || (f.current = !1, m({
|
|
597
2512
|
keys: s,
|
|
598
|
-
count:
|
|
2513
|
+
count: fn(c, r, a, n)
|
|
599
2514
|
}));
|
|
600
2515
|
}, [s, o]);
|
|
601
|
-
|
|
602
|
-
|
|
2516
|
+
j(() => {
|
|
2517
|
+
f.current = !0, u.current = {};
|
|
603
2518
|
}, [
|
|
604
2519
|
s,
|
|
605
2520
|
o.length,
|
|
606
2521
|
t
|
|
607
|
-
]),
|
|
608
|
-
|
|
2522
|
+
]), j(() => {
|
|
2523
|
+
C();
|
|
609
2524
|
let e = l.current;
|
|
610
2525
|
if (!e || typeof ResizeObserver > "u") return;
|
|
611
|
-
let t = new ResizeObserver(() =>
|
|
2526
|
+
let t = new ResizeObserver(() => C());
|
|
612
2527
|
return t.observe(e), () => t.disconnect();
|
|
613
2528
|
}, [
|
|
614
|
-
|
|
2529
|
+
C,
|
|
615
2530
|
s,
|
|
616
2531
|
t
|
|
617
2532
|
]);
|
|
618
|
-
let { visible:
|
|
619
|
-
|
|
620
|
-
let
|
|
621
|
-
return /* @__PURE__ */
|
|
622
|
-
className:
|
|
623
|
-
children: [/* @__PURE__ */
|
|
2533
|
+
let { visible: w, overflow: E } = pn(o, h), D = E.length > 0, O = N(E);
|
|
2534
|
+
E.length > 0 && (O.current = E);
|
|
2535
|
+
let k = _ && D, A = D || _ && O.current.length > 0, F = D ? E : O.current;
|
|
2536
|
+
return /* @__PURE__ */ b("div", {
|
|
2537
|
+
className: I(G["bsy-lexical__toolbar-stack"], i && G["bsy-lexical__toolbar-stack--instant"]),
|
|
2538
|
+
children: [/* @__PURE__ */ b("div", {
|
|
624
2539
|
ref: l,
|
|
625
|
-
className:
|
|
2540
|
+
className: G["bsy-lexical__toolbar-items"],
|
|
626
2541
|
children: [
|
|
627
|
-
/* @__PURE__ */
|
|
2542
|
+
/* @__PURE__ */ y(ae, {
|
|
628
2543
|
initial: !1,
|
|
629
2544
|
mode: "popLayout",
|
|
630
|
-
children:
|
|
2545
|
+
children: w.map((e) => /* @__PURE__ */ y(pa, {
|
|
631
2546
|
item: e,
|
|
632
|
-
motionProps:
|
|
633
|
-
transition:
|
|
2547
|
+
motionProps: S,
|
|
2548
|
+
transition: x
|
|
634
2549
|
}, e.key))
|
|
635
2550
|
}),
|
|
636
|
-
|
|
637
|
-
className:
|
|
638
|
-
children: [/* @__PURE__ */
|
|
639
|
-
icon:
|
|
640
|
-
tooltip: c(
|
|
641
|
-
highlight:
|
|
642
|
-
onClick: () =>
|
|
2551
|
+
D ? /* @__PURE__ */ b("div", {
|
|
2552
|
+
className: I(G["bsy-lexical__toolbar-overflow"], G["bsy-lexical__toolbar-with-divider"]),
|
|
2553
|
+
children: [/* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ y(q, {
|
|
2554
|
+
icon: k ? "packupeverything" : "expandall",
|
|
2555
|
+
tooltip: c(k ? "editor.collapse" : "editor.expand"),
|
|
2556
|
+
highlight: k,
|
|
2557
|
+
onClick: () => v((e) => !e)
|
|
643
2558
|
})]
|
|
644
2559
|
}) : null,
|
|
645
|
-
/* @__PURE__ */
|
|
646
|
-
ref:
|
|
647
|
-
className:
|
|
2560
|
+
/* @__PURE__ */ b("div", {
|
|
2561
|
+
ref: d,
|
|
2562
|
+
className: I(G["bsy-lexical__toolbar-more-sizer"], G["bsy-lexical__toolbar-with-divider"]),
|
|
648
2563
|
"aria-hidden": !0,
|
|
649
|
-
children: [/* @__PURE__ */
|
|
2564
|
+
children: [/* @__PURE__ */ y("div", { className: G["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ y(q, {
|
|
650
2565
|
icon: "expandall",
|
|
651
2566
|
tooltip: ""
|
|
652
2567
|
})]
|
|
653
2568
|
})
|
|
654
2569
|
]
|
|
655
|
-
}),
|
|
656
|
-
className:
|
|
657
|
-
children: /* @__PURE__ */
|
|
658
|
-
className:
|
|
659
|
-
children:
|
|
2570
|
+
}), A ? /* @__PURE__ */ y("div", {
|
|
2571
|
+
className: I(G["bsy-lexical__toolbar-overflow-row"], k && G["bsy-lexical__toolbar-overflow-row--open"], i && G["bsy-lexical__toolbar-overflow-row--instant"]),
|
|
2572
|
+
children: /* @__PURE__ */ y("div", {
|
|
2573
|
+
className: G["bsy-lexical__toolbar-overflow-inner"],
|
|
2574
|
+
children: F.map((e) => /* @__PURE__ */ y(pa, {
|
|
660
2575
|
item: e,
|
|
661
2576
|
motionProps: {},
|
|
662
|
-
transition:
|
|
2577
|
+
transition: x
|
|
663
2578
|
}, `overflow-${e.key}`))
|
|
664
2579
|
})
|
|
665
2580
|
}) : null]
|
|
666
2581
|
});
|
|
667
|
-
},
|
|
668
|
-
let { config: t = [], style: n, theme: r, mode: i, floating: a, stickyOffset: o, size: s =
|
|
669
|
-
duration:
|
|
2582
|
+
}, ha = (e) => {
|
|
2583
|
+
let { config: t = [], style: n, theme: r, mode: i, floating: a, stickyOffset: o, size: s = on } = e, { toolbarRef: c } = hr(), l = i === "floating", u = o !== void 0, d = se(), f = {
|
|
2584
|
+
duration: d ? 0 : .16,
|
|
670
2585
|
ease: "easeOut"
|
|
671
|
-
},
|
|
2586
|
+
}, p = M(() => ln(r, s), [r, s]), m = M(() => ({ iconSize: un(r?.iconSize, s) }), [r?.iconSize, s]), h = l ? dn(a) : void 0, _ = l ? g(n, [
|
|
672
2587
|
"position",
|
|
673
2588
|
"left",
|
|
674
2589
|
"top",
|
|
@@ -679,26 +2594,26 @@ var mn = (e) => {
|
|
|
679
2594
|
"marginTop",
|
|
680
2595
|
"marginBottom"
|
|
681
2596
|
]) : n;
|
|
682
|
-
return /* @__PURE__ */
|
|
683
|
-
value:
|
|
684
|
-
children: /* @__PURE__ */
|
|
2597
|
+
return /* @__PURE__ */ y(Vn, {
|
|
2598
|
+
value: m,
|
|
2599
|
+
children: /* @__PURE__ */ y(zn, { children: /* @__PURE__ */ y(In, { children: /* @__PURE__ */ y(oe.div, {
|
|
685
2600
|
ref: c,
|
|
686
|
-
layout:
|
|
687
|
-
transition:
|
|
688
|
-
className:
|
|
2601
|
+
layout: d || u ? !1 : "position",
|
|
2602
|
+
transition: f,
|
|
2603
|
+
className: I(G["bsy-lexical__toolbar"], l && G["bsy-lexical__toolbar--floating"], u && G["bsy-lexical__toolbar--sticky"]),
|
|
689
2604
|
style: {
|
|
2605
|
+
...p,
|
|
2606
|
+
...u ? { top: o } : null,
|
|
690
2607
|
...h,
|
|
691
|
-
...
|
|
692
|
-
..._,
|
|
693
|
-
...y
|
|
2608
|
+
..._
|
|
694
2609
|
},
|
|
695
|
-
children: /* @__PURE__ */
|
|
2610
|
+
children: /* @__PURE__ */ y(ma, {
|
|
696
2611
|
config: t,
|
|
697
2612
|
sizeToken: `${s}|${r?.itemHeight ?? ""}|${r?.iconSize ?? ""}`
|
|
698
2613
|
})
|
|
699
2614
|
}) }) })
|
|
700
2615
|
});
|
|
701
|
-
},
|
|
2616
|
+
}, $ = {
|
|
702
2617
|
"bsy-lexical-editor": "_bsy-lexical-editor_1l05x_1",
|
|
703
2618
|
"bsy-lexical-editor--floating": "_bsy-lexical-editor--floating_1l05x_8",
|
|
704
2619
|
"bsy-lexical-editor--sticky-toolbar": "_bsy-lexical-editor--sticky-toolbar_1l05x_8",
|
|
@@ -708,12 +2623,12 @@ var mn = (e) => {
|
|
|
708
2623
|
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_1l05x_28",
|
|
709
2624
|
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_1l05x_41",
|
|
710
2625
|
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_1l05x_53"
|
|
711
|
-
},
|
|
2626
|
+
}, ga = (e) => {
|
|
712
2627
|
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
713
|
-
},
|
|
2628
|
+
}, _a = (e) => {
|
|
714
2629
|
let t = {};
|
|
715
|
-
return e ? (
|
|
716
|
-
},
|
|
2630
|
+
return e ? (s(t, "--bsy-editor-container-border-color", e.borderColor), s(t, "--bsy-editor-container-border-width", ga(e.borderWidth)), s(t, "--bsy-editor-container-border-radius", ga(e.borderRadius)), t) : t;
|
|
2631
|
+
}, va = class e extends nt {
|
|
717
2632
|
constructor(e, t) {
|
|
718
2633
|
super(e, t);
|
|
719
2634
|
}
|
|
@@ -724,46 +2639,46 @@ var mn = (e) => {
|
|
|
724
2639
|
return new e(t.__text, t.__key);
|
|
725
2640
|
}
|
|
726
2641
|
static importDOM() {
|
|
727
|
-
let e =
|
|
2642
|
+
let e = nt.importDOM();
|
|
728
2643
|
return {
|
|
729
2644
|
...e,
|
|
730
2645
|
code: () => ({
|
|
731
|
-
conversion:
|
|
2646
|
+
conversion: ba(e?.code),
|
|
732
2647
|
priority: 1
|
|
733
2648
|
}),
|
|
734
2649
|
em: () => ({
|
|
735
|
-
conversion:
|
|
2650
|
+
conversion: ba(e?.em),
|
|
736
2651
|
priority: 1
|
|
737
2652
|
}),
|
|
738
2653
|
span: () => ({
|
|
739
|
-
conversion:
|
|
2654
|
+
conversion: ba(e?.span),
|
|
740
2655
|
priority: 1
|
|
741
2656
|
}),
|
|
742
2657
|
strong: () => ({
|
|
743
|
-
conversion:
|
|
2658
|
+
conversion: ba(e?.strong),
|
|
744
2659
|
priority: 1
|
|
745
2660
|
}),
|
|
746
2661
|
sub: () => ({
|
|
747
|
-
conversion:
|
|
2662
|
+
conversion: ba(e?.sub),
|
|
748
2663
|
priority: 1
|
|
749
2664
|
}),
|
|
750
2665
|
sup: () => ({
|
|
751
|
-
conversion:
|
|
2666
|
+
conversion: ba(e?.sup),
|
|
752
2667
|
priority: 1
|
|
753
2668
|
})
|
|
754
2669
|
};
|
|
755
2670
|
}
|
|
756
2671
|
static importJSON(e) {
|
|
757
|
-
return
|
|
2672
|
+
return ya().updateFromJSON(e);
|
|
758
2673
|
}
|
|
759
2674
|
isSimpleText() {
|
|
760
2675
|
return this.__type === "extended-text" && this.__mode === 0;
|
|
761
2676
|
}
|
|
762
2677
|
};
|
|
763
|
-
function
|
|
764
|
-
return
|
|
2678
|
+
function ya(e = "") {
|
|
2679
|
+
return _e(new va(e));
|
|
765
2680
|
}
|
|
766
|
-
function
|
|
2681
|
+
function ba(e) {
|
|
767
2682
|
return (t) => {
|
|
768
2683
|
let n = e?.(t);
|
|
769
2684
|
if (!n) return null;
|
|
@@ -774,7 +2689,7 @@ function Q(e) {
|
|
|
774
2689
|
...r,
|
|
775
2690
|
forChild: (e, t) => {
|
|
776
2691
|
let n = (r?.forChild ?? ((e) => e))(e, t);
|
|
777
|
-
if (
|
|
2692
|
+
if (Ae(n)) {
|
|
778
2693
|
let e = [
|
|
779
2694
|
i ? `background-color: ${i}` : null,
|
|
780
2695
|
a ? `color: ${a}` : null,
|
|
@@ -792,81 +2707,81 @@ function Q(e) {
|
|
|
792
2707
|
}
|
|
793
2708
|
//#endregion
|
|
794
2709
|
//#region src/components/Editor/utils/stripInlineStyleProperty.ts
|
|
795
|
-
function
|
|
2710
|
+
function xa(e, t) {
|
|
796
2711
|
return e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; ");
|
|
797
2712
|
}
|
|
798
2713
|
//#endregion
|
|
799
2714
|
//#region src/components/Editor/plugins/LinkColorPlugin.tsx
|
|
800
|
-
function
|
|
801
|
-
if (!
|
|
2715
|
+
function Sa(e) {
|
|
2716
|
+
if (!H(e, lt)) return;
|
|
802
2717
|
let t = e.getStyle();
|
|
803
2718
|
if (!t) return;
|
|
804
|
-
let n =
|
|
2719
|
+
let n = xa(t, "color");
|
|
805
2720
|
n !== t && e.setStyle(n);
|
|
806
2721
|
}
|
|
807
|
-
function
|
|
808
|
-
let [e] =
|
|
809
|
-
return
|
|
2722
|
+
function Ca() {
|
|
2723
|
+
let [e] = B();
|
|
2724
|
+
return O(() => e.registerNodeTransform(va, Sa), [e]), null;
|
|
810
2725
|
}
|
|
811
2726
|
//#endregion
|
|
812
2727
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
813
|
-
function
|
|
814
|
-
let [e] =
|
|
815
|
-
return
|
|
2728
|
+
function wa() {
|
|
2729
|
+
let [e] = B();
|
|
2730
|
+
return O(() => e.registerCommand(Dr, (e) => (Te([nn(e)]), !0), ze), [e]), null;
|
|
816
2731
|
}
|
|
817
2732
|
//#endregion
|
|
818
2733
|
//#region src/components/Editor/utils/stripImagesFromHtml.ts
|
|
819
|
-
function
|
|
2734
|
+
function Ta(e) {
|
|
820
2735
|
let t = new DOMParser().parseFromString(e, "text/html");
|
|
821
2736
|
return t.querySelectorAll("img, picture").forEach((e) => e.remove()), t.body.innerHTML;
|
|
822
2737
|
}
|
|
823
2738
|
//#endregion
|
|
824
2739
|
//#region src/components/Editor/plugins/PasteStripImagePlugin.tsx
|
|
825
|
-
var
|
|
826
|
-
function
|
|
827
|
-
let [e] =
|
|
828
|
-
return
|
|
2740
|
+
var Ea = /<img\b|<picture\b/i;
|
|
2741
|
+
function Da() {
|
|
2742
|
+
let [e] = B(), { isSourceModeRef: t } = Ur();
|
|
2743
|
+
return O(() => {
|
|
829
2744
|
let n = (n) => {
|
|
830
2745
|
if (t.current) return !1;
|
|
831
2746
|
let r = "clipboardData" in n ? n.clipboardData : "dataTransfer" in n ? n.dataTransfer : null;
|
|
832
2747
|
if (!r || r.getData("application/x-lexical-editor") || r.getData("application/x-lexical-drag")) return !1;
|
|
833
2748
|
let i = r.getData("text/html");
|
|
834
|
-
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) ||
|
|
2749
|
+
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) || Ea.test(i))) return !1;
|
|
835
2750
|
n.preventDefault();
|
|
836
2751
|
let a = r.getData("text/plain");
|
|
837
|
-
return !
|
|
838
|
-
let t =
|
|
2752
|
+
return !Ea.test(i) && !a || e.update(() => {
|
|
2753
|
+
let t = R();
|
|
839
2754
|
if (t === null) return;
|
|
840
|
-
let n = i ?
|
|
2755
|
+
let n = i ? Ta(i) : "", r = document.createElement("div");
|
|
841
2756
|
if (r.innerHTML = n, n && r.textContent?.trim()) {
|
|
842
|
-
let t =
|
|
2757
|
+
let t = ge(e, new DOMParser().parseFromString(n, "text/html"));
|
|
843
2758
|
if (t.length) {
|
|
844
|
-
|
|
2759
|
+
Te(t);
|
|
845
2760
|
return;
|
|
846
2761
|
}
|
|
847
2762
|
}
|
|
848
2763
|
a && t.insertRawText(a);
|
|
849
|
-
}, { tag:
|
|
2764
|
+
}, { tag: $e }), !0;
|
|
850
2765
|
};
|
|
851
|
-
return
|
|
2766
|
+
return Yt(e.registerCommand(Qe, (e) => n(e), Be), e.registerCommand(He, (e) => n(e), Be));
|
|
852
2767
|
}, [e, t]), null;
|
|
853
2768
|
}
|
|
854
2769
|
//#endregion
|
|
855
2770
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
856
|
-
function
|
|
857
|
-
let [e] =
|
|
858
|
-
return
|
|
2771
|
+
function Oa() {
|
|
2772
|
+
let [e] = B(), t = N(0);
|
|
2773
|
+
return O(() => e.registerCommand(Ye, (n) => {
|
|
859
2774
|
let r = Date.now(), i = r - t.current;
|
|
860
2775
|
return t.current = r, i < 250 && i > 0 ? e.getEditorState().read(() => {
|
|
861
|
-
let e =
|
|
862
|
-
return
|
|
2776
|
+
let e = R();
|
|
2777
|
+
return z(e) ? !!H(e.anchor.getNode(), (e) => mt(e) || V(e) || Nt(e)) : !1;
|
|
863
2778
|
}, { editor: e }) ? !1 : (e.update(() => {
|
|
864
|
-
let e =
|
|
865
|
-
if (
|
|
2779
|
+
let e = R();
|
|
2780
|
+
if (z(e)) {
|
|
866
2781
|
let t = e.anchor.getNode().getTopLevelElement();
|
|
867
2782
|
if (t && t.getTextContent().trim() === "") {
|
|
868
|
-
let n =
|
|
869
|
-
|
|
2783
|
+
let n = ye();
|
|
2784
|
+
kt(e, {
|
|
870
2785
|
"background-color": "",
|
|
871
2786
|
color: "",
|
|
872
2787
|
"font-size": "",
|
|
@@ -879,11 +2794,11 @@ function Nn() {
|
|
|
879
2794
|
}
|
|
880
2795
|
}
|
|
881
2796
|
}), n?.preventDefault(), !0) : !1;
|
|
882
|
-
},
|
|
2797
|
+
}, Ve), [e]), null;
|
|
883
2798
|
}
|
|
884
2799
|
//#endregion
|
|
885
2800
|
//#region src/components/Editor/utils/codeHighlighter.ts
|
|
886
|
-
var
|
|
2801
|
+
var ka = {
|
|
887
2802
|
css: () => import("@shikijs/langs/css"),
|
|
888
2803
|
html: () => import("@shikijs/langs/html"),
|
|
889
2804
|
xml: () => import("@shikijs/langs/xml"),
|
|
@@ -904,65 +2819,70 @@ var Pn = {
|
|
|
904
2819
|
bash: () => import("@shikijs/langs/shellscript"),
|
|
905
2820
|
lua: () => import("@shikijs/langs/lua"),
|
|
906
2821
|
markdown: () => import("@shikijs/langs/markdown")
|
|
907
|
-
},
|
|
2822
|
+
}, Aa = (e) => e === "bash" ? "shellscript" : e, ja = (e) => e in ka, Ma = null, Na = null, Pa = /* @__PURE__ */ new Map(), Fa = () => (Ma ||= Promise.all([import("@shikijs/core"), import("@shikijs/engine-javascript")]).then(([{ createHighlighterCoreSync: e }, { createJavaScriptRegexEngine: t }]) => e({
|
|
908
2823
|
engine: t(),
|
|
909
2824
|
langs: [],
|
|
910
2825
|
themes: []
|
|
911
2826
|
})).catch((e) => {
|
|
912
|
-
throw
|
|
913
|
-
}),
|
|
914
|
-
let t =
|
|
915
|
-
return t || (t =
|
|
916
|
-
let n =
|
|
2827
|
+
throw Ma = null, e;
|
|
2828
|
+
}), Ma), Ia = (e, t) => ja(t) && e.getLoadedLanguages().includes(Aa(t)), La = (e) => {
|
|
2829
|
+
let t = Pa.get(e);
|
|
2830
|
+
return t || (t = Fa().then(async (t) => {
|
|
2831
|
+
let n = Aa(e);
|
|
917
2832
|
if (!t.getLoadedLanguages().includes(n)) {
|
|
918
|
-
let n = await
|
|
2833
|
+
let n = await ka[e]();
|
|
919
2834
|
await t.loadLanguage(n.default);
|
|
920
2835
|
}
|
|
921
2836
|
return t;
|
|
922
2837
|
}).catch((t) => {
|
|
923
|
-
throw
|
|
924
|
-
}),
|
|
925
|
-
},
|
|
2838
|
+
throw Pa.delete(e), t;
|
|
2839
|
+
}), Pa.set(e, t)), t;
|
|
2840
|
+
}, Ra = () => (Na ||= Fa().then(async (e) => {
|
|
926
2841
|
if (!e.getLoadedThemes().includes("github-light")) {
|
|
927
2842
|
let t = await import("@shikijs/themes/github-light");
|
|
928
2843
|
await e.loadTheme(t.default);
|
|
929
2844
|
}
|
|
930
2845
|
return e;
|
|
931
2846
|
}).catch((e) => {
|
|
932
|
-
throw
|
|
933
|
-
}),
|
|
2847
|
+
throw Na = null, e;
|
|
2848
|
+
}), Na), za = (e, t, n) => {
|
|
934
2849
|
let r = e.getTextContent();
|
|
935
|
-
if (e.getStyle() && e.setStyle(""), !n || !
|
|
936
|
-
let i =
|
|
2850
|
+
if (e.getStyle() && e.setStyle(""), !n || !Ia(n, t)) return wt(r);
|
|
2851
|
+
let i = Aa(t), a = n.codeToTokens(r, {
|
|
937
2852
|
lang: i,
|
|
938
|
-
theme:
|
|
2853
|
+
theme: Sn
|
|
939
2854
|
}), o = [];
|
|
940
2855
|
return a.tokens.forEach((e, t) => {
|
|
941
|
-
t && o.push(
|
|
2856
|
+
t && o.push(ve()), e.forEach((e) => {
|
|
942
2857
|
e.content.split(" ").forEach((t, n) => {
|
|
943
|
-
if (n && o.push(
|
|
944
|
-
let r =
|
|
2858
|
+
if (n && o.push(be()), t === "") return;
|
|
2859
|
+
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}` : "";
|
|
945
2860
|
i && r.setStyle(i), o.push(r);
|
|
946
2861
|
});
|
|
947
2862
|
});
|
|
948
2863
|
}), o;
|
|
949
|
-
},
|
|
950
|
-
let n =
|
|
951
|
-
if (!
|
|
952
|
-
let r =
|
|
953
|
-
if (!
|
|
2864
|
+
}, Ba = (e, t) => {
|
|
2865
|
+
let n = Ce(e);
|
|
2866
|
+
if (!V(n) || !n.isAttached()) return;
|
|
2867
|
+
let r = R();
|
|
2868
|
+
if (!z(r)) {
|
|
954
2869
|
t();
|
|
955
2870
|
return;
|
|
956
2871
|
}
|
|
957
|
-
let { anchor: i } = r
|
|
2872
|
+
let { anchor: i } = r;
|
|
2873
|
+
if (H(i.getNode(), V) !== n) {
|
|
2874
|
+
t();
|
|
2875
|
+
return;
|
|
2876
|
+
}
|
|
2877
|
+
let a = i.offset, o = i.type === "element" && De(n.getChildAtIndex(i.offset - 1)), s = 0;
|
|
958
2878
|
if (o || (s = a + i.getNode().getPreviousSiblings().reduce((e, t) => e + t.getTextContentSize(), 0)), t()) {
|
|
959
2879
|
if (o) {
|
|
960
2880
|
i.getNode().select(a, a);
|
|
961
2881
|
return;
|
|
962
2882
|
}
|
|
963
2883
|
n.getChildren().some((e) => {
|
|
964
|
-
let t =
|
|
965
|
-
if (t ||
|
|
2884
|
+
let t = Ae(e);
|
|
2885
|
+
if (t || De(e)) {
|
|
966
2886
|
let n = e.getTextContentSize();
|
|
967
2887
|
if (t && n >= s) return e.select(s, s), !0;
|
|
968
2888
|
s -= n;
|
|
@@ -970,11 +2890,11 @@ var Pn = {
|
|
|
970
2890
|
return !1;
|
|
971
2891
|
});
|
|
972
2892
|
}
|
|
973
|
-
},
|
|
2893
|
+
}, Va = (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), Ha = (e, t) => {
|
|
974
2894
|
let n = 0;
|
|
975
|
-
for (; n < e.length &&
|
|
2895
|
+
for (; n < e.length && Va(e[n], t[n]);) n++;
|
|
976
2896
|
let r = e.length, i = t.length, a = Math.min(r, i) - n, o = 0;
|
|
977
|
-
for (; o < a;) if (o++, !
|
|
2897
|
+
for (; o < a;) if (o++, !Va(e[r - o], t[i - o])) {
|
|
978
2898
|
o--;
|
|
979
2899
|
break;
|
|
980
2900
|
}
|
|
@@ -983,21 +2903,21 @@ var Pn = {
|
|
|
983
2903
|
to: r - o,
|
|
984
2904
|
nodesForReplacement: t.slice(n, i - o)
|
|
985
2905
|
};
|
|
986
|
-
},
|
|
987
|
-
let a = i.getKey(), o =
|
|
2906
|
+
}, Ua = (e, t, n, r, i) => {
|
|
2907
|
+
let a = i.getKey(), o = Tn(i.getLanguage());
|
|
988
2908
|
if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
|
|
989
2909
|
else {
|
|
990
|
-
i.getTheme() !== "github-light" && i.setTheme(
|
|
991
|
-
let s = t ? t.getLoadedThemes().includes("github-light") ?
|
|
2910
|
+
i.getTheme() !== "github-light" && i.setTheme(Sn);
|
|
2911
|
+
let s = t ? t.getLoadedThemes().includes("github-light") ? ja(o) && !Ia(t, o) ? La(o) : null : Ra() : Fa();
|
|
992
2912
|
if (s) {
|
|
993
2913
|
i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1), n.pendingKeys.add(a), n.loading !== s && (n.loading = s, s.then((t) => {
|
|
994
2914
|
r(t);
|
|
995
2915
|
let i = [...n.pendingKeys];
|
|
996
2916
|
n.pendingKeys.clear(), n.loading = null, e.update(() => {
|
|
997
2917
|
i.forEach((e) => {
|
|
998
|
-
|
|
2918
|
+
Ce(e)?.markDirty();
|
|
999
2919
|
});
|
|
1000
|
-
}, { tag:
|
|
2920
|
+
}, { tag: qe });
|
|
1001
2921
|
}, () => {
|
|
1002
2922
|
n.pendingKeys.clear(), n.loading = null;
|
|
1003
2923
|
}));
|
|
@@ -1005,22 +2925,22 @@ var Pn = {
|
|
|
1005
2925
|
}
|
|
1006
2926
|
i.getIsSyntaxHighlightSupported() || i.setIsSyntaxHighlightSupported(!0);
|
|
1007
2927
|
}
|
|
1008
|
-
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0,
|
|
2928
|
+
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, Me(() => {
|
|
1009
2929
|
n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
|
|
1010
|
-
})),
|
|
1011
|
-
let e =
|
|
1012
|
-
if (!
|
|
1013
|
-
let n =
|
|
2930
|
+
})), Ba(a, () => {
|
|
2931
|
+
let e = Ce(a);
|
|
2932
|
+
if (!V(e) || !e.isAttached()) return !1;
|
|
2933
|
+
let n = za(e, Tn(e.getLanguage()), t), { from: r, to: i, nodesForReplacement: o } = Ha(e.getChildren(), n);
|
|
1014
2934
|
return r !== i || o.length ? (e.splice(r, i - r, o), !0) : !1;
|
|
1015
2935
|
}));
|
|
1016
|
-
},
|
|
2936
|
+
}, Wa = (e, t, n, r, i) => {
|
|
1017
2937
|
let a = i.getParent();
|
|
1018
|
-
|
|
2938
|
+
V(a) ? Ua(e, t, n, r, a) : Ct(i) && i.replace(xe(i.__text));
|
|
1019
2939
|
};
|
|
1020
|
-
function
|
|
1021
|
-
let [e] =
|
|
1022
|
-
return
|
|
1023
|
-
if (!e.hasNodes([
|
|
2940
|
+
function Ga() {
|
|
2941
|
+
let [e] = B();
|
|
2942
|
+
return O(() => {
|
|
2943
|
+
if (!e.hasNodes([Et, Tt])) throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");
|
|
1024
2944
|
let t = null, n = {
|
|
1025
2945
|
didTransform: !1,
|
|
1026
2946
|
nodesCurrentlyHighlighting: /* @__PURE__ */ new Set(),
|
|
@@ -1029,16 +2949,16 @@ function Xn() {
|
|
|
1029
2949
|
}, r = (e) => {
|
|
1030
2950
|
t = e;
|
|
1031
2951
|
}, i = (e) => {
|
|
1032
|
-
let t =
|
|
1033
|
-
if (!
|
|
2952
|
+
let t = Ce(e);
|
|
2953
|
+
if (!V(t)) return;
|
|
1034
2954
|
let n = t.getChildrenSize();
|
|
1035
2955
|
n === 0 ? t.selectStart() : t.select(0, n);
|
|
1036
2956
|
}, a = (t) => {
|
|
1037
2957
|
if (!(t instanceof Node) || !e.getRootElement()?.contains(t)) return null;
|
|
1038
2958
|
let n = null;
|
|
1039
2959
|
return e.getEditorState().read(() => {
|
|
1040
|
-
let e =
|
|
1041
|
-
|
|
2960
|
+
let e = Se(t), r = e ? H(e, V) : null;
|
|
2961
|
+
V(r) && (n = r.getKey());
|
|
1042
2962
|
}, { editor: e }), n;
|
|
1043
2963
|
}, o = null, s = (t, n, r) => {
|
|
1044
2964
|
t.preventDefault(), r && (o = n), e.update(() => {
|
|
@@ -1060,12 +2980,12 @@ function Xn() {
|
|
|
1060
2980
|
}, d = (e, t) => {
|
|
1061
2981
|
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);
|
|
1062
2982
|
};
|
|
1063
|
-
return
|
|
1064
|
-
|
|
1065
|
-
}), e.registerNodeTransform(
|
|
1066
|
-
|
|
1067
|
-
}), e.registerNodeTransform(
|
|
1068
|
-
|
|
2983
|
+
return ot(Dt(e), e.registerNodeTransform(Et, (i) => {
|
|
2984
|
+
Ua(e, t, n, r, i);
|
|
2985
|
+
}), e.registerNodeTransform(nt, (i) => {
|
|
2986
|
+
Wa(e, t, n, r, i);
|
|
2987
|
+
}), e.registerNodeTransform(Tt, (i) => {
|
|
2988
|
+
Wa(e, t, n, r, i);
|
|
1069
2989
|
}), e.registerRootListener(d), () => {
|
|
1070
2990
|
d(null, e.getRootElement());
|
|
1071
2991
|
});
|
|
@@ -1073,23 +2993,23 @@ function Xn() {
|
|
|
1073
2993
|
}
|
|
1074
2994
|
//#endregion
|
|
1075
2995
|
//#region src/components/Editor/plugins/TablePlugin.tsx
|
|
1076
|
-
function
|
|
1077
|
-
let [e] =
|
|
1078
|
-
return
|
|
2996
|
+
function Ka() {
|
|
2997
|
+
let [e] = B();
|
|
2998
|
+
return O(() => (Wt(e, !0), Yt(Ht(e), Ut(e, !1), Vt(e), e.registerNodeTransform(Rt, (e) => {
|
|
1079
2999
|
e.getBackgroundColor() !== null && e.setBackgroundColor(null);
|
|
1080
|
-
}), e.registerCommand(
|
|
1081
|
-
let t =
|
|
1082
|
-
if (!
|
|
1083
|
-
let n =
|
|
3000
|
+
}), e.registerCommand(Xe, (e) => {
|
|
3001
|
+
let t = R();
|
|
3002
|
+
if (!z(t) || !t.isCollapsed()) return !1;
|
|
3003
|
+
let n = Mt(t.anchor.getNode());
|
|
1084
3004
|
if (n === null) return !1;
|
|
1085
3005
|
let r = e.shiftKey ? "previous" : "next", i = r === "next" ? "getNextSibling" : "getPreviousSibling", a = r === "next" ? "getFirstChild" : "getLastChild", o = n[i](), s = null;
|
|
1086
|
-
if (
|
|
3006
|
+
if (Nt(o)) s = o;
|
|
1087
3007
|
else {
|
|
1088
|
-
let e =
|
|
3008
|
+
let e = H(n, Ft);
|
|
1089
3009
|
if (e !== null) for (let t = e[i](); t !== null; t = t[i]()) {
|
|
1090
|
-
if (!
|
|
3010
|
+
if (!Ft(t)) continue;
|
|
1091
3011
|
let e = t[a]();
|
|
1092
|
-
if (
|
|
3012
|
+
if (Nt(e)) {
|
|
1093
3013
|
s = e;
|
|
1094
3014
|
break;
|
|
1095
3015
|
}
|
|
@@ -1099,60 +3019,60 @@ function Zn() {
|
|
|
1099
3019
|
let e = s.getFirstDescendant();
|
|
1100
3020
|
e ? e.selectStart() : s.selectStart();
|
|
1101
3021
|
} else {
|
|
1102
|
-
let e =
|
|
3022
|
+
let e = H(n, Pt);
|
|
1103
3023
|
e && (r === "next" ? e.selectNext() : e.selectPrevious());
|
|
1104
3024
|
}
|
|
1105
3025
|
return !0;
|
|
1106
|
-
},
|
|
3026
|
+
}, Be))), [e]), null;
|
|
1107
3027
|
}
|
|
1108
3028
|
//#endregion
|
|
1109
3029
|
//#region src/components/Editor/plugins/TabIndentPlugin.tsx
|
|
1110
|
-
var
|
|
1111
|
-
function
|
|
1112
|
-
let [e] =
|
|
1113
|
-
return
|
|
3030
|
+
var qa = "\xA0".repeat(4);
|
|
3031
|
+
function Ja() {
|
|
3032
|
+
let [e] = B();
|
|
3033
|
+
return O(() => e.registerCommand(Xe, (t) => {
|
|
1114
3034
|
if (t.shiftKey) return !1;
|
|
1115
|
-
let n =
|
|
1116
|
-
if (!
|
|
3035
|
+
let n = R();
|
|
3036
|
+
if (!z(n)) return !1;
|
|
1117
3037
|
let r = n.anchor.getNode();
|
|
1118
|
-
if (
|
|
3038
|
+
if (Mt(r) !== null || H(r, V)) return !1;
|
|
1119
3039
|
t.preventDefault();
|
|
1120
|
-
let i =
|
|
1121
|
-
if (
|
|
3040
|
+
let i = H(r, mt);
|
|
3041
|
+
if (mt(i)) {
|
|
1122
3042
|
let e = new Set([i]);
|
|
1123
3043
|
for (let t of n.getNodes()) {
|
|
1124
|
-
let n =
|
|
1125
|
-
|
|
3044
|
+
let n = H(t, mt);
|
|
3045
|
+
mt(n) && e.add(n);
|
|
1126
3046
|
}
|
|
1127
3047
|
for (let t of e) t.setIndent(t.getIndent() + 1);
|
|
1128
3048
|
return !0;
|
|
1129
3049
|
}
|
|
1130
3050
|
let a = r.getTopLevelElement(), o = n.focus.getNode().getTopLevelElement();
|
|
1131
|
-
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(
|
|
1132
|
-
},
|
|
3051
|
+
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(Je, void 0) : (n.insertText(qa), !0);
|
|
3052
|
+
}, ze), [e]), null;
|
|
1133
3053
|
}
|
|
1134
3054
|
//#endregion
|
|
1135
3055
|
//#region src/components/Editor/plugins/MaxLengthPlugin.tsx
|
|
1136
|
-
function
|
|
1137
|
-
let [n] =
|
|
1138
|
-
return i.current = t,
|
|
3056
|
+
function Ya({ maxLength: e, onMaxLengthExceed: t }) {
|
|
3057
|
+
let [n] = B(), { isSourceModeRef: r } = Ur(), i = N(t);
|
|
3058
|
+
return i.current = t, O(() => {
|
|
1139
3059
|
let t = null;
|
|
1140
|
-
return n.registerNodeTransform(
|
|
3060
|
+
return n.registerNodeTransform(tt, (a) => {
|
|
1141
3061
|
if (r.current) return;
|
|
1142
3062
|
let o = a.getTextContentSize();
|
|
1143
3063
|
if (o <= e) return;
|
|
1144
|
-
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u =
|
|
3064
|
+
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u = R();
|
|
1145
3065
|
if (c === e && t !== s) {
|
|
1146
|
-
t = s,
|
|
3066
|
+
t = s, Jt(n, s), i.current?.();
|
|
1147
3067
|
return;
|
|
1148
3068
|
}
|
|
1149
|
-
if (
|
|
1150
|
-
|
|
3069
|
+
if (z(u) && u.isCollapsed()) {
|
|
3070
|
+
jt(n, u.anchor, l), i.current?.();
|
|
1151
3071
|
return;
|
|
1152
3072
|
}
|
|
1153
3073
|
a.selectEnd();
|
|
1154
|
-
let d =
|
|
1155
|
-
|
|
3074
|
+
let d = R();
|
|
3075
|
+
z(d) && (jt(n, d.anchor, l), i.current?.());
|
|
1156
3076
|
});
|
|
1157
3077
|
}, [
|
|
1158
3078
|
n,
|
|
@@ -1162,19 +3082,19 @@ function er({ maxLength: e, onMaxLengthExceed: t }) {
|
|
|
1162
3082
|
}
|
|
1163
3083
|
//#endregion
|
|
1164
3084
|
//#region src/components/Editor/utils/textLength.ts
|
|
1165
|
-
function
|
|
3085
|
+
function Xa(e) {
|
|
1166
3086
|
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
1167
3087
|
}
|
|
1168
|
-
function
|
|
1169
|
-
let n =
|
|
3088
|
+
function Za(e, t) {
|
|
3089
|
+
let n = L(), r = n.getTextContentSize();
|
|
1170
3090
|
if (r <= t) return !1;
|
|
1171
3091
|
let i = r - t;
|
|
1172
3092
|
n.selectEnd();
|
|
1173
|
-
let a =
|
|
1174
|
-
return
|
|
3093
|
+
let a = R();
|
|
3094
|
+
return z(a) ? jt(e, a.anchor, i) : Qa(i), !0;
|
|
1175
3095
|
}
|
|
1176
|
-
function
|
|
1177
|
-
let t = e, n =
|
|
3096
|
+
function Qa(e) {
|
|
3097
|
+
let t = e, n = L().getAllTextNodes();
|
|
1178
3098
|
for (let e = n.length - 1; e >= 0 && t > 0; e--) {
|
|
1179
3099
|
let r = n[e], i = r.getTextContent();
|
|
1180
3100
|
i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
|
|
@@ -1182,7 +3102,7 @@ function rr(e) {
|
|
|
1182
3102
|
}
|
|
1183
3103
|
//#endregion
|
|
1184
3104
|
//#region src/components/Editor/utils/formatEditorHtml.ts
|
|
1185
|
-
var
|
|
3105
|
+
var $a = new Set([
|
|
1186
3106
|
"area",
|
|
1187
3107
|
"base",
|
|
1188
3108
|
"br",
|
|
@@ -1197,73 +3117,73 @@ var ir = new Set([
|
|
|
1197
3117
|
"source",
|
|
1198
3118
|
"track",
|
|
1199
3119
|
"wbr"
|
|
1200
|
-
]),
|
|
1201
|
-
let r = e.tagName.toLowerCase(), i = `<${r}${
|
|
1202
|
-
if (
|
|
1203
|
-
let a = n || r === "pre", o =
|
|
1204
|
-
return a || !
|
|
1205
|
-
},
|
|
3120
|
+
]), eo = 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(".")), to = 80, no = (e) => e.replace(/&/g, "&").replace(/"/g, """), ro = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), io = (e) => Array.from(e.attributes).map((e) => ` ${e.name}="${no(e.value)}"`).join(""), ao = (e) => " ".repeat(e), oo = (e, t, n) => {
|
|
3121
|
+
let r = e.tagName.toLowerCase(), i = `<${r}${io(e)}>`;
|
|
3122
|
+
if ($a.has(r)) return i;
|
|
3123
|
+
let a = n || r === "pre", o = so(e, t + 1, a), s = `</${r}>`;
|
|
3124
|
+
return a || !eo.has(r) ? `${i}${o}${s}` : Array.from(e.children).some((e) => eo.has(e.tagName.toLowerCase())) ? `${i}\n${so(e, t + 1, !1, !0)}\n${ao(t)}${s}` : i.length + o.length + s.length > to ? `${i}\n${ao(t + 1)}${o}\n${ao(t)}${s}` : `${i}${o}${s}`;
|
|
3125
|
+
}, so = (e, t, n, r = !1) => {
|
|
1206
3126
|
let i = [];
|
|
1207
3127
|
for (let r of Array.from(e.childNodes)) {
|
|
1208
3128
|
if (r.nodeType === Node.TEXT_NODE) {
|
|
1209
3129
|
let e = r.textContent ?? "";
|
|
1210
3130
|
if (n) {
|
|
1211
|
-
i.push(
|
|
3131
|
+
i.push(ro(e));
|
|
1212
3132
|
continue;
|
|
1213
3133
|
}
|
|
1214
|
-
e.trim() && i.push(
|
|
3134
|
+
e.trim() && i.push(ro(e));
|
|
1215
3135
|
continue;
|
|
1216
3136
|
}
|
|
1217
3137
|
if (r.nodeType === Node.COMMENT_NODE) {
|
|
1218
3138
|
i.push(`<!--${r.data}-->`);
|
|
1219
3139
|
continue;
|
|
1220
3140
|
}
|
|
1221
|
-
r.nodeType === Node.ELEMENT_NODE && i.push(
|
|
3141
|
+
r.nodeType === Node.ELEMENT_NODE && i.push(oo(r, t, n));
|
|
1222
3142
|
}
|
|
1223
|
-
return n || !r ? i.join("") : i.map((e) => `${
|
|
3143
|
+
return n || !r ? i.join("") : i.map((e) => `${ao(t)}${e}`).join("\n");
|
|
1224
3144
|
};
|
|
1225
|
-
function
|
|
1226
|
-
return e.trim() ?
|
|
3145
|
+
function co(e) {
|
|
3146
|
+
return e.trim() ? so(new DOMParser().parseFromString(Fi(e), "text/html").body, 0, !1, !0).trimEnd() : e;
|
|
1227
3147
|
}
|
|
1228
3148
|
//#endregion
|
|
1229
3149
|
//#region src/components/Editor/utils/writeHtmlSource.ts
|
|
1230
|
-
function
|
|
1231
|
-
|
|
1232
|
-
let t =
|
|
1233
|
-
if (
|
|
3150
|
+
function lo(e) {
|
|
3151
|
+
L().clear();
|
|
3152
|
+
let t = St("html");
|
|
3153
|
+
if (L().append(t), !e) return;
|
|
1234
3154
|
t.select();
|
|
1235
|
-
let n =
|
|
1236
|
-
|
|
3155
|
+
let n = R();
|
|
3156
|
+
z(n) && n.insertRawText(e);
|
|
1237
3157
|
}
|
|
1238
3158
|
//#endregion
|
|
1239
3159
|
//#region src/components/Editor/plugins/SourceModePlugin.tsx
|
|
1240
|
-
function
|
|
1241
|
-
let [r] =
|
|
3160
|
+
function uo({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
3161
|
+
let [r] = B(), [i, a] = P(!1), o = N(!1), s = N(n);
|
|
1242
3162
|
s.current = n;
|
|
1243
|
-
let c =
|
|
3163
|
+
let c = Xa(t) ? t : void 0, l = T(() => {
|
|
1244
3164
|
if (o.current) return;
|
|
1245
3165
|
let e = "", t = "";
|
|
1246
3166
|
r.getEditorState().read(() => {
|
|
1247
|
-
t =
|
|
3167
|
+
t = L().getTextContent(), e = he(r, null);
|
|
1248
3168
|
}, { editor: r });
|
|
1249
|
-
let n =
|
|
3169
|
+
let n = ni(e, t) ? "" : X(e);
|
|
1250
3170
|
o.current = !0, a(!0), r.update(() => {
|
|
1251
|
-
|
|
1252
|
-
}), r.dispatchCommand(
|
|
1253
|
-
}, [r]), u =
|
|
3171
|
+
lo(co(n));
|
|
3172
|
+
}), r.dispatchCommand(Le, void 0);
|
|
3173
|
+
}, [r]), u = T(() => {
|
|
1254
3174
|
if (!o.current) return;
|
|
1255
3175
|
let e = !1;
|
|
1256
3176
|
o.current = !1, r.update(() => {
|
|
1257
|
-
|
|
1258
|
-
}), a(!1), r.dispatchCommand(
|
|
1259
|
-
}, [r, c]), d =
|
|
3177
|
+
ti(r, X(L().getTextContent())), c !== void 0 && (e = Za(r, c)), Dn(!0);
|
|
3178
|
+
}), a(!1), r.dispatchCommand(Le, void 0), e && s.current?.();
|
|
3179
|
+
}, [r, c]), d = T(() => {
|
|
1260
3180
|
if (o.current) {
|
|
1261
3181
|
u();
|
|
1262
3182
|
return;
|
|
1263
3183
|
}
|
|
1264
3184
|
l();
|
|
1265
3185
|
}, [l, u]);
|
|
1266
|
-
|
|
3186
|
+
O(() => {
|
|
1267
3187
|
let e = (e) => {
|
|
1268
3188
|
if (!o.current) return !1;
|
|
1269
3189
|
let t = "clipboardData" in e ? e.clipboardData : "dataTransfer" in e ? e.dataTransfer : null;
|
|
@@ -1271,53 +3191,53 @@ function hr({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
|
1271
3191
|
e.preventDefault();
|
|
1272
3192
|
let n = t.getData("text/html") || t.getData("text/plain");
|
|
1273
3193
|
if (!n) return !0;
|
|
1274
|
-
let i =
|
|
3194
|
+
let i = X(n);
|
|
1275
3195
|
return r.update(() => {
|
|
1276
|
-
let e =
|
|
1277
|
-
|
|
1278
|
-
}, { tag:
|
|
3196
|
+
let e = R();
|
|
3197
|
+
z(e) && i && e.insertRawText(i);
|
|
3198
|
+
}, { tag: $e }), !0;
|
|
1279
3199
|
};
|
|
1280
|
-
return
|
|
3200
|
+
return Yt(r.registerNodeTransform(tt, () => {
|
|
1281
3201
|
if (!o.current) return;
|
|
1282
|
-
let e =
|
|
1283
|
-
|
|
1284
|
-
}), r.registerCommand(
|
|
3202
|
+
let e = L(), t = e.getChildrenSize() === 1 ? e.getFirstChild() : null;
|
|
3203
|
+
V(t) && t.getLanguage() === "html" || lo(e.getTextContent());
|
|
3204
|
+
}), r.registerCommand(Qe, e, Re), r.registerCommand(He, e, Re));
|
|
1285
3205
|
}, [r]);
|
|
1286
|
-
let f =
|
|
3206
|
+
let f = M(() => ({
|
|
1287
3207
|
isSourceMode: i,
|
|
1288
3208
|
isSourceModeRef: o,
|
|
1289
3209
|
toggleSourceMode: d
|
|
1290
3210
|
}), [i, d]);
|
|
1291
|
-
return /* @__PURE__ */
|
|
3211
|
+
return /* @__PURE__ */ y(Hr.Provider, {
|
|
1292
3212
|
value: f,
|
|
1293
3213
|
children: e
|
|
1294
3214
|
});
|
|
1295
3215
|
}
|
|
1296
3216
|
//#endregion
|
|
1297
3217
|
//#region src/components/Editor/plugins/HeadingPlugin.tsx
|
|
1298
|
-
function
|
|
3218
|
+
function fo(e) {
|
|
1299
3219
|
let t = e.getTag();
|
|
1300
3220
|
if (t === "h4" || t === "h5" || t === "h6") {
|
|
1301
|
-
e.replace(
|
|
3221
|
+
e.replace(ye(), !0);
|
|
1302
3222
|
return;
|
|
1303
3223
|
}
|
|
1304
3224
|
for (let t of e.getAllTextNodes()) {
|
|
1305
3225
|
let e = t.getStyle();
|
|
1306
3226
|
if (!e) continue;
|
|
1307
|
-
let n =
|
|
3227
|
+
let n = xa(e, "font-size");
|
|
1308
3228
|
n !== e && t.setStyle(n);
|
|
1309
3229
|
}
|
|
1310
3230
|
}
|
|
1311
|
-
function
|
|
1312
|
-
let [e] =
|
|
1313
|
-
return
|
|
3231
|
+
function po() {
|
|
3232
|
+
let [e] = B();
|
|
3233
|
+
return O(() => e.registerNodeTransform(qt, fo), [e]), null;
|
|
1314
3234
|
}
|
|
1315
3235
|
//#endregion
|
|
1316
3236
|
//#region src/components/Editor/LengthBadge.tsx
|
|
1317
|
-
var
|
|
3237
|
+
var mo = ({ current: e, maxLength: t }) => {
|
|
1318
3238
|
let n = e > t;
|
|
1319
|
-
return /* @__PURE__ */
|
|
1320
|
-
className:
|
|
3239
|
+
return /* @__PURE__ */ b("div", {
|
|
3240
|
+
className: I($["bsy-lexical-editor__length-badge"], n && $["bsy-lexical-editor__length-badge--exceeded"]),
|
|
1321
3241
|
"aria-live": "polite",
|
|
1322
3242
|
children: [
|
|
1323
3243
|
e,
|
|
@@ -1326,33 +3246,33 @@ var vr = ({ current: e, maxLength: t }) => {
|
|
|
1326
3246
|
]
|
|
1327
3247
|
});
|
|
1328
3248
|
};
|
|
1329
|
-
|
|
3249
|
+
mo.displayName = "BsyLexicalEditorLengthBadge";
|
|
1330
3250
|
//#endregion
|
|
1331
3251
|
//#region src/components/Editor/utils/unwrapTypesetFence.ts
|
|
1332
|
-
var
|
|
3252
|
+
var ho = /^\uFEFF/, go = /^ {0,3}`{1,3}[A-Za-z]*$/, _o = /^( {0,3})([^`<]*?)```[ \t]*([A-Za-z0-9_-]*)[ \t]*(.*)$/, vo = /^ {0,3}```[ \t]*$/, yo = /<\/?[a-zA-Z]/, bo = /<[a-zA-Z!]/, xo = (e) => bo.test(e), So = (e) => yo.test(e), Co = (e) => e.replace(ho, "").replace(/\r\n/g, "\n"), wo = (e) => {
|
|
1333
3253
|
let t = e.replace(/\n+$/, ""), n = t.lastIndexOf("\n"), r = n === -1 ? t : t.slice(n + 1);
|
|
1334
|
-
return
|
|
3254
|
+
return go.test(r) ? {
|
|
1335
3255
|
text: n === -1 ? "" : t.slice(0, n),
|
|
1336
3256
|
withheld: !0
|
|
1337
3257
|
} : {
|
|
1338
3258
|
text: e,
|
|
1339
3259
|
withheld: !1
|
|
1340
3260
|
};
|
|
1341
|
-
},
|
|
1342
|
-
let t =
|
|
3261
|
+
}, To = (e) => {
|
|
3262
|
+
let t = _o.exec(e);
|
|
1343
3263
|
return t ? { sameLineBody: t[4] ?? "" } : null;
|
|
1344
|
-
},
|
|
3264
|
+
}, Eo = (e) => {
|
|
1345
3265
|
let t = e.replace(/[ \t]*```[ \t]*$/, "");
|
|
1346
3266
|
return t === e ? e : t;
|
|
1347
|
-
},
|
|
3267
|
+
}, Do = (e) => xo(e) ? e.replace(/^\n/, "") : "", Oo = (e) => {
|
|
1348
3268
|
let t = e.split("\n"), n = [], r = 0;
|
|
1349
3269
|
for (; r < t.length;) {
|
|
1350
|
-
let e = t[r], i =
|
|
3270
|
+
let e = t[r], i = To(e);
|
|
1351
3271
|
if (i) {
|
|
1352
3272
|
let e = i.sameLineBody;
|
|
1353
|
-
if (e !==
|
|
1354
|
-
e =
|
|
1355
|
-
let i =
|
|
3273
|
+
if (e !== Eo(e)) {
|
|
3274
|
+
e = Eo(e);
|
|
3275
|
+
let i = Do(t.slice(r + 1).join("\n"));
|
|
1356
3276
|
return [
|
|
1357
3277
|
...n,
|
|
1358
3278
|
e,
|
|
@@ -1360,38 +3280,38 @@ var yr = /^\uFEFF/, br = /^ {0,3}`{1,3}[A-Za-z]*$/, xr = /^( {0,3})([^`<]*?)```[
|
|
|
1360
3280
|
].filter(Boolean).join("\n");
|
|
1361
3281
|
}
|
|
1362
3282
|
let a = [];
|
|
1363
|
-
for (e && a.push(e), r += 1; r < t.length && !
|
|
1364
|
-
let o = r < t.length ?
|
|
3283
|
+
for (e && a.push(e), r += 1; r < t.length && !vo.test(t[r]);) a.push(t[r]), r += 1;
|
|
3284
|
+
let o = r < t.length ? Do(t.slice(r + 1).join("\n")) : "";
|
|
1365
3285
|
return [
|
|
1366
3286
|
...n,
|
|
1367
3287
|
a.join("\n"),
|
|
1368
3288
|
o
|
|
1369
3289
|
].filter(Boolean).join("\n");
|
|
1370
3290
|
}
|
|
1371
|
-
if (
|
|
1372
|
-
|
|
3291
|
+
if (So(e)) return ko([...n, ...t.slice(r)].join("\n"));
|
|
3292
|
+
xo(e) && n.push(e), r += 1;
|
|
1373
3293
|
}
|
|
1374
3294
|
return n.length ? n.join("\n") : null;
|
|
1375
|
-
},
|
|
3295
|
+
}, ko = (e) => {
|
|
1376
3296
|
let t = e.split("\n");
|
|
1377
3297
|
if (!t.length) return e;
|
|
1378
|
-
let n =
|
|
1379
|
-
return n && !
|
|
3298
|
+
let n = To(t[0]);
|
|
3299
|
+
return n && !So(t[0].slice(0, t[0].indexOf("```"))) && (t.shift(), n.sameLineBody && t.unshift(Eo(n.sameLineBody))), t.length && vo.test(t[t.length - 1] ?? "") && t.pop(), t.join("\n");
|
|
1380
3300
|
};
|
|
1381
|
-
function
|
|
3301
|
+
function Ao(e) {
|
|
1382
3302
|
if (!e) return {
|
|
1383
3303
|
html: "",
|
|
1384
3304
|
pending: !1
|
|
1385
3305
|
};
|
|
1386
|
-
let { text: t, withheld: n } =
|
|
3306
|
+
let { text: t, withheld: n } = wo(Co(e));
|
|
1387
3307
|
if (!t.trim()) return {
|
|
1388
3308
|
html: "",
|
|
1389
|
-
pending: n ||
|
|
3309
|
+
pending: n || go.test(Co(e).trim())
|
|
1390
3310
|
};
|
|
1391
|
-
let r =
|
|
3311
|
+
let r = Oo(t) ?? t, i = Oo(r);
|
|
1392
3312
|
i !== null && i !== r && (r = i);
|
|
1393
3313
|
let a = r.trim();
|
|
1394
|
-
return
|
|
3314
|
+
return xo(a) ? {
|
|
1395
3315
|
html: a,
|
|
1396
3316
|
pending: !1
|
|
1397
3317
|
} : {
|
|
@@ -1401,59 +3321,90 @@ function Pr(e) {
|
|
|
1401
3321
|
}
|
|
1402
3322
|
//#endregion
|
|
1403
3323
|
//#region src/components/Editor/utils/prepareTypesetProposed.ts
|
|
1404
|
-
var
|
|
1405
|
-
function
|
|
1406
|
-
if (!e.trim() || !
|
|
1407
|
-
let t =
|
|
3324
|
+
var jo = "p, h1, h2, h3, li", Mo = /background(-color)?\s*:/i;
|
|
3325
|
+
function No(e) {
|
|
3326
|
+
if (!e.trim() || !Mo.test(e)) return e;
|
|
3327
|
+
let t = hi(e);
|
|
1408
3328
|
if (!t) return e;
|
|
1409
|
-
for (let e of Array.from(t.querySelectorAll(
|
|
3329
|
+
for (let e of Array.from(t.querySelectorAll(jo))) {
|
|
1410
3330
|
let t = e;
|
|
1411
3331
|
t.style.removeProperty("background-color"), t.style.removeProperty("background"), t.getAttribute("style")?.trim() || t.removeAttribute("style");
|
|
1412
3332
|
}
|
|
1413
3333
|
return t.innerHTML;
|
|
1414
3334
|
}
|
|
1415
|
-
function
|
|
1416
|
-
let { html: n } =
|
|
1417
|
-
return n ?
|
|
3335
|
+
function Po(e, t) {
|
|
3336
|
+
let { html: n } = Ao(e);
|
|
3337
|
+
return n ? No(_i(n, t)) : "";
|
|
1418
3338
|
}
|
|
1419
3339
|
//#endregion
|
|
1420
3340
|
//#region src/components/Editor/utils/applyAiTypeset.ts
|
|
1421
|
-
function
|
|
1422
|
-
let i =
|
|
1423
|
-
if (!i.trim() ||
|
|
3341
|
+
function Fo(e, t, n, r) {
|
|
3342
|
+
let i = X(Po(t, n));
|
|
3343
|
+
if (!i.trim() || ni(i, "")) return {
|
|
1424
3344
|
applied: !1,
|
|
1425
3345
|
truncated: !1
|
|
1426
3346
|
};
|
|
1427
3347
|
let a = !1;
|
|
1428
3348
|
return e.update(() => {
|
|
1429
|
-
|
|
3349
|
+
ti(e, i), Xa(r) && (a = Za(e, r)), Dn(!0);
|
|
1430
3350
|
}, { discrete: !0 }), {
|
|
1431
3351
|
applied: !0,
|
|
1432
3352
|
truncated: a
|
|
1433
3353
|
};
|
|
1434
3354
|
}
|
|
1435
3355
|
//#endregion
|
|
1436
|
-
//#region src/components/Editor/Preview/
|
|
1437
|
-
var
|
|
3356
|
+
//#region src/components/Editor/Preview/useAiPreviewHtml.ts
|
|
3357
|
+
var Io = (e, t) => {
|
|
3358
|
+
if (!e || Zr(e)) return e;
|
|
3359
|
+
let n = X(e);
|
|
3360
|
+
return t === "ready" || t === "error" ? Fi(n) : n;
|
|
3361
|
+
}, Lo = ({ enabled: e, status: t, revision: n, compute: r }) => {
|
|
3362
|
+
let [i, a] = P(""), o = N(r);
|
|
3363
|
+
o.current = r;
|
|
3364
|
+
let s = N(null);
|
|
3365
|
+
return j(() => {
|
|
3366
|
+
let n = () => {
|
|
3367
|
+
s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
|
|
3368
|
+
};
|
|
3369
|
+
if (!e) {
|
|
3370
|
+
n(), a("");
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
let r = () => {
|
|
3374
|
+
s.current = null, a(o.current());
|
|
3375
|
+
};
|
|
3376
|
+
if (t === "ready" || t === "error") {
|
|
3377
|
+
n(), r();
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
s.current === null && (s.current = requestAnimationFrame(r));
|
|
3381
|
+
}, [
|
|
3382
|
+
e,
|
|
3383
|
+
n,
|
|
3384
|
+
t
|
|
3385
|
+
]), O(() => () => {
|
|
3386
|
+
s.current !== null && cancelAnimationFrame(s.current);
|
|
3387
|
+
}, []), i;
|
|
3388
|
+
}, Ro = [
|
|
1438
3389
|
.26,
|
|
1439
3390
|
.02,
|
|
1440
3391
|
.23,
|
|
1441
3392
|
.94
|
|
1442
|
-
],
|
|
1443
|
-
let e = `${
|
|
1444
|
-
return /* @__PURE__ */
|
|
1445
|
-
className:
|
|
3393
|
+
], zo = () => {
|
|
3394
|
+
let e = `${k().replace(/:/g, "")}g`;
|
|
3395
|
+
return /* @__PURE__ */ y("span", {
|
|
3396
|
+
className: Q["bsy-lexical-ai__think-icon"],
|
|
1446
3397
|
"aria-hidden": "true",
|
|
1447
|
-
children: /* @__PURE__ */
|
|
3398
|
+
children: /* @__PURE__ */ b("svg", {
|
|
1448
3399
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1449
3400
|
width: "16",
|
|
1450
3401
|
height: "16",
|
|
1451
3402
|
viewBox: "0 0 16 16",
|
|
1452
3403
|
fill: "none",
|
|
1453
|
-
children: [/* @__PURE__ */
|
|
3404
|
+
children: [/* @__PURE__ */ y("path", {
|
|
1454
3405
|
d: "M6.33965 13.3C6.27366 13.4143 6.23082 13.5404 6.21357 13.6712C6.19633 13.802 6.20502 13.9349 6.23914 14.0624C6.30806 14.3198 6.47641 14.5392 6.70715 14.6725C6.93788 14.8058 7.21211 14.8419 7.46951 14.773C7.59696 14.7389 7.71644 14.68 7.82112 14.5997C7.92581 14.5194 8.01366 14.4193 8.07965 14.305C8.21292 14.0743 8.24907 13.8 8.18015 13.5426C8.11123 13.2852 7.94288 13.0658 7.71215 12.9325C7.48141 12.7992 7.20718 12.7631 6.94978 12.832C6.69239 12.9009 6.47292 13.0693 6.33965 13.3ZM8.97265 1C7.44126 0.999778 5.95165 1.4994 4.73011 2.42295C3.69009 3.20927 2.89277 4.26631 2.4213 5.47246C2.33326 5.69768 2.00678 5.72579 1.89765 5.51L1.80165 5.356C1.64959 5.15708 1.42869 5.02215 1.18228 4.97769C0.935881 4.93323 0.681756 4.98244 0.469763 5.11567C0.25777 5.24891 0.103209 5.45654 0.0364008 5.69785C-0.0304072 5.93915 -0.00464041 6.19671 0.108646 6.42L1.34765 8.852L1.45565 9.032C1.86065 9.598 2.61765 9.782 3.23665 9.467L5.62665 8.25L5.78165 8.153C5.98057 8.00094 6.11549 7.78004 6.15995 7.53364C6.20442 7.28723 6.1552 7.03311 6.02197 6.82112C5.88874 6.60912 5.68111 6.45456 5.4398 6.38775C5.19849 6.32095 4.94093 6.34671 4.71765 6.46C4.48237 6.579 4.22662 6.36717 4.32655 6.12317C4.56067 5.55153 4.899 5.02613 5.32623 4.57461C5.90933 3.95836 6.63902 3.49984 7.44723 3.24183C8.25544 2.98382 9.11583 2.93472 9.94815 3.09912C10.7805 3.26352 11.5576 3.63606 12.207 4.18198C12.8564 4.7279 13.357 5.42942 13.662 6.22109C13.967 7.01276 14.0665 7.86879 13.9512 8.70932C13.836 9.54985 13.5097 10.3475 13.0028 11.0278C12.496 11.7082 11.8251 12.249 11.0526 12.6C10.9326 12.654 10.7796 12.71 10.5976 12.766C10.3241 12.8507 10.0934 13.0371 9.95295 13.2867C9.81252 13.5363 9.77305 13.8302 9.84265 14.108C9.90673 14.3421 10.0611 14.5412 10.2718 14.6615C10.4826 14.7819 10.7325 14.8137 10.9666 14.75C11.2736 14.666 11.5226 14.584 11.7136 14.503C13.2066 13.8705 14.435 12.7413 15.1908 11.3067C15.9466 9.87221 16.1832 8.22052 15.8607 6.63149C15.5381 5.04246 14.6762 3.61377 13.4209 2.58747C12.1656 1.56117 10.5941 1.00034 8.97265 1ZM4.16665 10.876C3.90024 10.876 3.64474 10.9818 3.45636 11.1702C3.26798 11.3586 3.16215 11.6141 3.16215 11.8805C3.16215 12.1469 3.26798 12.4024 3.45636 12.5908C3.64474 12.7792 3.90024 12.885 4.16665 12.885C4.43306 12.885 4.68855 12.7792 4.87694 12.5908C5.06532 12.4024 5.17115 12.1469 5.17115 11.8805C5.17115 11.6141 5.06532 11.3586 4.87694 11.1702C4.68855 10.9818 4.43306 10.876 4.16665 10.876Z",
|
|
1455
3406
|
fill: `url(#${e})`
|
|
1456
|
-
}), /* @__PURE__ */
|
|
3407
|
+
}), /* @__PURE__ */ y("defs", { children: /* @__PURE__ */ b("linearGradient", {
|
|
1457
3408
|
id: e,
|
|
1458
3409
|
x1: "8.00059",
|
|
1459
3410
|
y1: "1",
|
|
@@ -1461,12 +3412,12 @@ var Br = [
|
|
|
1461
3412
|
y2: "14.8072",
|
|
1462
3413
|
gradientUnits: "userSpaceOnUse",
|
|
1463
3414
|
children: [
|
|
1464
|
-
/* @__PURE__ */
|
|
1465
|
-
/* @__PURE__ */
|
|
3415
|
+
/* @__PURE__ */ y("stop", { stopColor: "#0265FF" }),
|
|
3416
|
+
/* @__PURE__ */ y("stop", {
|
|
1466
3417
|
offset: "1",
|
|
1467
3418
|
stopColor: "#A6FFFF"
|
|
1468
3419
|
}),
|
|
1469
|
-
/* @__PURE__ */
|
|
3420
|
+
/* @__PURE__ */ y("animateTransform", {
|
|
1470
3421
|
attributeName: "gradientTransform",
|
|
1471
3422
|
type: "rotate",
|
|
1472
3423
|
from: "0 8 8",
|
|
@@ -1479,15 +3430,15 @@ var Br = [
|
|
|
1479
3430
|
})
|
|
1480
3431
|
});
|
|
1481
3432
|
};
|
|
1482
|
-
function
|
|
1483
|
-
let { t:
|
|
3433
|
+
function Bo(e, t, n) {
|
|
3434
|
+
let { t: r } = a(), i = e.status === "loading" && !t, [o, s] = P(!0), [c, l] = P(0), u = N(Date.now()), d = N(null), f = N(!1), p = N(!1), m = e.reasoning ?? "", h = i || o, g = (i || !!m) && !(e.status === "error" && !m), _ = (e) => {
|
|
1484
3435
|
!e || !p.current || (p.current = !1, e.scrollHeight - e.scrollTop - e.clientHeight > 8 && (f.current = !0));
|
|
1485
|
-
}, v =
|
|
3436
|
+
}, v = T(() => n?.current ?? void 0, [n]), y = T(() => {
|
|
1486
3437
|
let e = v();
|
|
1487
3438
|
return e?.closest("[data-overlayscrollbars]") ?? e;
|
|
1488
3439
|
}, [v]);
|
|
1489
|
-
return
|
|
1490
|
-
if (!
|
|
3440
|
+
return O(() => {
|
|
3441
|
+
if (!i) {
|
|
1491
3442
|
d.current === null && (d.current = Math.max(1, Math.round((Date.now() - u.current) / 1e3)), l(d.current)), s(!1);
|
|
1492
3443
|
return;
|
|
1493
3444
|
}
|
|
@@ -1496,62 +3447,62 @@ function Hr(e, t, r) {
|
|
|
1496
3447
|
l(Math.max(1, Math.round((Date.now() - u.current) / 1e3)));
|
|
1497
3448
|
}, 500);
|
|
1498
3449
|
return () => window.clearInterval(e);
|
|
1499
|
-
}, [
|
|
3450
|
+
}, [i]), O(() => {
|
|
1500
3451
|
p.current = !1;
|
|
1501
|
-
}, [
|
|
3452
|
+
}, [re()]), ie("wheel", () => {
|
|
1502
3453
|
p.current = !0;
|
|
1503
3454
|
}, {
|
|
1504
3455
|
target: y,
|
|
1505
3456
|
passive: !0,
|
|
1506
|
-
enable:
|
|
1507
|
-
}),
|
|
3457
|
+
enable: i
|
|
3458
|
+
}), ie("pointerdown", (e) => {
|
|
1508
3459
|
let t = e.target;
|
|
1509
3460
|
t instanceof Element && t.closest(".os-scrollbar") && (p.current = !0);
|
|
1510
3461
|
}, {
|
|
1511
3462
|
target: y,
|
|
1512
3463
|
passive: !0,
|
|
1513
|
-
enable:
|
|
1514
|
-
}),
|
|
3464
|
+
enable: i
|
|
3465
|
+
}), ie("scroll", () => _(v()), {
|
|
1515
3466
|
target: v,
|
|
1516
3467
|
passive: !0,
|
|
1517
|
-
enable:
|
|
1518
|
-
}),
|
|
1519
|
-
if (!
|
|
3468
|
+
enable: i
|
|
3469
|
+
}), O(() => {
|
|
3470
|
+
if (!i || f.current || !n?.current) return;
|
|
1520
3471
|
let e = window.requestAnimationFrame(() => {
|
|
1521
3472
|
if (f.current) return;
|
|
1522
|
-
let e =
|
|
3473
|
+
let e = n?.current;
|
|
1523
3474
|
e && e.scrollHeight - e.scrollTop - e.clientHeight > 1 && (e.scrollTop = e.scrollHeight);
|
|
1524
3475
|
});
|
|
1525
3476
|
return () => window.cancelAnimationFrame(e);
|
|
1526
3477
|
}, [
|
|
1527
3478
|
m,
|
|
1528
|
-
|
|
1529
|
-
|
|
3479
|
+
n,
|
|
3480
|
+
i
|
|
1530
3481
|
]), {
|
|
1531
3482
|
visible: g,
|
|
1532
|
-
thinking:
|
|
3483
|
+
thinking: i,
|
|
1533
3484
|
open: h,
|
|
1534
|
-
label:
|
|
3485
|
+
label: i ? r("editor.aiThinking") : r("editor.aiThoughtSeconds", { seconds: c }),
|
|
1535
3486
|
reasoning: m,
|
|
1536
3487
|
toggle: () => s((e) => !e),
|
|
1537
|
-
onViewportScroll: () => _(
|
|
3488
|
+
onViewportScroll: () => _(n?.current)
|
|
1538
3489
|
};
|
|
1539
3490
|
}
|
|
1540
|
-
var
|
|
3491
|
+
var Vo = ({ model: t }) => t.visible ? /* @__PURE__ */ b("button", {
|
|
1541
3492
|
type: "button",
|
|
1542
|
-
className:
|
|
3493
|
+
className: Q["bsy-lexical-ai__think-head"],
|
|
1543
3494
|
disabled: t.thinking,
|
|
1544
3495
|
onClick: t.toggle,
|
|
1545
|
-
children: [t.thinking ? /* @__PURE__ */
|
|
3496
|
+
children: [t.thinking ? /* @__PURE__ */ y(zo, {}) : /* @__PURE__ */ y(e, {
|
|
1546
3497
|
name: "arrow-down",
|
|
1547
3498
|
size: 12,
|
|
1548
|
-
className:
|
|
1549
|
-
}), /* @__PURE__ */
|
|
1550
|
-
className:
|
|
1551
|
-
children: /* @__PURE__ */
|
|
3499
|
+
className: I(Q["bsy-lexical-ai__think-arrow"], t.open && Q["bsy-lexical-ai__think-arrow--open"])
|
|
3500
|
+
}), /* @__PURE__ */ y("span", {
|
|
3501
|
+
className: Q["bsy-lexical-ai__think-label"],
|
|
3502
|
+
children: /* @__PURE__ */ y(ae, {
|
|
1552
3503
|
mode: "popLayout",
|
|
1553
3504
|
initial: !1,
|
|
1554
|
-
children: /* @__PURE__ */
|
|
3505
|
+
children: /* @__PURE__ */ y(oe.span, {
|
|
1555
3506
|
initial: {
|
|
1556
3507
|
opacity: 0,
|
|
1557
3508
|
y: 6
|
|
@@ -1566,30 +3517,30 @@ var Ur = ({ model: t }) => t.visible ? /* @__PURE__ */ N("button", {
|
|
|
1566
3517
|
},
|
|
1567
3518
|
transition: {
|
|
1568
3519
|
duration: .22,
|
|
1569
|
-
ease:
|
|
3520
|
+
ease: Ro
|
|
1570
3521
|
},
|
|
1571
|
-
children: /* @__PURE__ */
|
|
1572
|
-
className: t.thinking ?
|
|
3522
|
+
children: /* @__PURE__ */ y("span", {
|
|
3523
|
+
className: t.thinking ? Q["bsy-lexical-ai__think-label--shimmer"] : void 0,
|
|
1573
3524
|
children: t.label
|
|
1574
3525
|
})
|
|
1575
3526
|
}, t.label)
|
|
1576
3527
|
})
|
|
1577
3528
|
})]
|
|
1578
|
-
}) : null,
|
|
1579
|
-
let [t, n] =
|
|
1580
|
-
if (
|
|
3529
|
+
}) : null, Ho = ({ model: e }) => {
|
|
3530
|
+
let [t, n] = P(!0), r = D(e.reasoning);
|
|
3531
|
+
if (O(() => {
|
|
1581
3532
|
e.open || n(!0);
|
|
1582
3533
|
}, [e.open]), !e.visible) return null;
|
|
1583
|
-
let i = /* @__PURE__ */
|
|
1584
|
-
className:
|
|
3534
|
+
let i = /* @__PURE__ */ y("div", {
|
|
3535
|
+
className: Q["bsy-lexical-ai__think-body"],
|
|
1585
3536
|
children: r
|
|
1586
3537
|
});
|
|
1587
|
-
return !t && e.open && e.reasoning ? /* @__PURE__ */
|
|
1588
|
-
className:
|
|
3538
|
+
return !t && e.open && e.reasoning ? /* @__PURE__ */ y("div", {
|
|
3539
|
+
className: I(Q["bsy-lexical-ai__think-collapse"], Q["bsy-lexical-ai__think-collapse--grown"]),
|
|
1589
3540
|
children: i
|
|
1590
|
-
}) : /* @__PURE__ */
|
|
3541
|
+
}) : /* @__PURE__ */ y(ae, {
|
|
1591
3542
|
initial: !1,
|
|
1592
|
-
children: e.open && e.reasoning ? /* @__PURE__ */
|
|
3543
|
+
children: e.open && e.reasoning ? /* @__PURE__ */ y(oe.div, {
|
|
1593
3544
|
initial: {
|
|
1594
3545
|
height: 0,
|
|
1595
3546
|
opacity: 0
|
|
@@ -1613,64 +3564,80 @@ var Ur = ({ model: t }) => t.visible ? /* @__PURE__ */ N("button", {
|
|
|
1613
3564
|
onAnimationComplete: () => {
|
|
1614
3565
|
e.open && n(!1);
|
|
1615
3566
|
},
|
|
1616
|
-
className:
|
|
3567
|
+
className: Q["bsy-lexical-ai__think-collapse"],
|
|
1617
3568
|
children: i
|
|
1618
3569
|
}, "think-body") : null
|
|
1619
3570
|
});
|
|
1620
|
-
},
|
|
1621
|
-
let
|
|
1622
|
-
return
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
3571
|
+
}, Uo = "\n:host {\n all: initial;\n display: block;\n width: 100%;\n max-width: 100%;\n min-width: 0;\n}\n.bsy-editor-html-preview__body {\n color: #030303;\n font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;\n font-size: 15px;\n line-height: 1.6;\n word-break: break-word;\n}\n.bsy-editor-html-preview__body p {\n margin: 0;\n}\n.bsy-editor-html-preview__body .editor-text-bold {\n font-weight: 700;\n}\n.bsy-editor-html-preview__body .editor-text-italic {\n font-style: italic;\n}\n.bsy-editor-html-preview__body .editor-text-underline {\n text-decoration: underline;\n}\n.bsy-editor-html-preview__body .editor-text-strikethrough {\n text-decoration: line-through;\n}\n.bsy-editor-html-preview__body .editor-text-underline-strikethrough {\n text-decoration: underline line-through;\n}\n.bsy-editor-html-preview__body sup,\n.bsy-editor-html-preview__body sub {\n display: inline-block;\n position: static;\n top: auto;\n bottom: auto;\n font-size: 0.75em;\n line-height: 1;\n}\n.bsy-editor-html-preview__body sup {\n vertical-align: super;\n}\n.bsy-editor-html-preview__body sub {\n vertical-align: sub;\n}\n.bsy-editor-html-preview__body .editor-heading-h1,\n.bsy-editor-html-preview__body .editor-heading-h2,\n.bsy-editor-html-preview__body .editor-heading-h3,\n.bsy-editor-html-preview__body .editor-heading-h4,\n.bsy-editor-html-preview__body .editor-heading-h5,\n.bsy-editor-html-preview__body .editor-heading-h6 {\n margin: 0.6em 0 0.4em;\n font-weight: 600;\n line-height: 1.35;\n}\n.bsy-editor-html-preview__body .editor-heading-h1 {\n font-size: 2em;\n}\n.bsy-editor-html-preview__body .editor-heading-h2 {\n font-size: 1.5em;\n}\n.bsy-editor-html-preview__body .editor-heading-h3 {\n font-size: 1.25em;\n}\n.bsy-editor-html-preview__body .editor-heading-h4 {\n font-size: 1.125em;\n}\n.bsy-editor-html-preview__body .editor-heading-h5 {\n font-size: 1em;\n}\n.bsy-editor-html-preview__body .editor-heading-h6 {\n font-size: 0.875em;\n}\n.bsy-editor-html-preview__body .editor-list-ul,\n.bsy-editor-html-preview__body .editor-list-ol {\n margin: 0;\n padding-inline-start: 24px;\n list-style-position: outside;\n}\n.bsy-editor-html-preview__body .editor-list-ul {\n list-style-type: disc;\n}\n.bsy-editor-html-preview__body .editor-list-ol {\n list-style-type: decimal;\n}\n.bsy-editor-html-preview__body .editor-listitem {\n margin: 0;\n list-style: inherit;\n}\n.bsy-editor-html-preview__body .editor-nested-listitem {\n list-style-type: none;\n}\n.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul {\n list-style-type: circle;\n}\n.bsy-editor-html-preview__body .editor-list-ul .editor-list-ul .editor-list-ul {\n list-style-type: square;\n}\n.bsy-editor-html-preview__body .editor-link,\n.bsy-editor-html-preview__body .editor-link:link,\n.bsy-editor-html-preview__body .editor-link:visited,\n.bsy-editor-html-preview__body .editor-link:hover,\n.bsy-editor-html-preview__body .editor-link:active,\n.bsy-editor-html-preview__body .editor-link:focus {\n color: #0269ff;\n cursor: pointer;\n}\n.bsy-editor-html-preview__body .editor-link * {\n color: #0269ff !important;\n}\n.bsy-editor-html-preview__body pre,\n.bsy-editor-html-preview__body .editor-code {\n display: block;\n box-sizing: border-box;\n max-width: 100%;\n margin: 8px 0;\n padding: 8px 12px;\n overflow-x: auto;\n border-radius: 4px;\n background: rgb(240, 242, 245);\n color: #1f2328;\n font-family: Menlo, Consolas, Monaco, monospace;\n font-size: 13px;\n line-height: 1.53;\n tab-size: 2;\n white-space: pre;\n}\n.bsy-editor-html-preview__body .editor-table-scrollable-wrapper {\n max-width: 100%;\n margin: 8px 0;\n overflow-x: auto;\n}\n.bsy-editor-html-preview__body table {\n width: max-content;\n min-width: 100%;\n margin: 0;\n border-collapse: collapse;\n table-layout: fixed;\n}\n.bsy-editor-html-preview__body td,\n.bsy-editor-html-preview__body th {\n box-sizing: border-box;\n min-width: 75px;\n min-height: 32px;\n padding: 4px 8px;\n border: 1px solid #d9d9d9;\n vertical-align: top;\n}\n.bsy-editor-html-preview__body th {\n background: #f2f3f5;\n font-weight: 600;\n}\n.bsy-editor-html-preview__body img {\n max-width: 100%;\n height: auto;\n vertical-align: baseline;\n}\n", Wo = ({ html: e }) => {
|
|
3572
|
+
let t = N(null);
|
|
3573
|
+
return j(() => {
|
|
3574
|
+
let n = t.current;
|
|
3575
|
+
if (!n) return;
|
|
3576
|
+
let r = n.shadowRoot ?? n.attachShadow({ mode: "open" }), i = document.createElement("div");
|
|
3577
|
+
i.className = "bsy-editor-html-preview__body", i.innerHTML = X(e);
|
|
3578
|
+
for (let e of Array.from(i.querySelectorAll("table"))) {
|
|
3579
|
+
if (e.parentElement?.classList.contains("editor-table-scrollable-wrapper")) continue;
|
|
3580
|
+
let t = document.createElement("div");
|
|
3581
|
+
t.className = "editor-table-scrollable-wrapper", e.replaceWith(t), t.append(e);
|
|
3582
|
+
}
|
|
3583
|
+
r.replaceChildren();
|
|
3584
|
+
let a = document.createElement("style");
|
|
3585
|
+
a.textContent = Uo, r.append(a, i);
|
|
3586
|
+
}, [e]), /* @__PURE__ */ y("div", {
|
|
3587
|
+
ref: t,
|
|
3588
|
+
className: "bsy-editor-html-preview"
|
|
3589
|
+
});
|
|
3590
|
+
}, Go = ({ html: e }) => {
|
|
3591
|
+
let [t, n] = P(() => e && !Zr(e) ? e : "");
|
|
3592
|
+
return O(() => {
|
|
3593
|
+
!e || Zr(e) || n(e);
|
|
3594
|
+
}, [e]), t ? /* @__PURE__ */ y(Wo, { html: t }) : null;
|
|
3595
|
+
}, Ko = {
|
|
1629
3596
|
paddingAbsolute: !0,
|
|
1630
3597
|
overflow: {
|
|
1631
3598
|
x: "hidden",
|
|
1632
3599
|
y: "scroll"
|
|
1633
3600
|
}
|
|
1634
|
-
},
|
|
1635
|
-
let { t:
|
|
1636
|
-
status:
|
|
1637
|
-
reasoning:
|
|
1638
|
-
}, v, _),
|
|
3601
|
+
}, qo = ({ status: t, errorMessage: n, originalHtml: i, proposedHtml: o, preset: s, onPresetChange: c, onCancel: l, onApply: d }) => {
|
|
3602
|
+
let { t: p } = a(), m = _r(), [h, g] = P(!0), _ = N(null), v = !!o.trim(), x = t === "ready" && v, S = Bo({
|
|
3603
|
+
status: t,
|
|
3604
|
+
reasoning: m
|
|
3605
|
+
}, v, _), C = Yr.map((e) => ({
|
|
1639
3606
|
key: e,
|
|
1640
|
-
label:
|
|
3607
|
+
label: p(Xr[e])
|
|
1641
3608
|
}));
|
|
1642
|
-
return /* @__PURE__ */
|
|
1643
|
-
title:
|
|
3609
|
+
return /* @__PURE__ */ y(r, {
|
|
3610
|
+
title: p("editor.aiPolish"),
|
|
1644
3611
|
open: h,
|
|
1645
3612
|
width: "800px",
|
|
1646
3613
|
fullSwitch: !0,
|
|
1647
|
-
afterClose:
|
|
3614
|
+
afterClose: l,
|
|
1648
3615
|
onOpenChange: g,
|
|
1649
|
-
children: /* @__PURE__ */
|
|
1650
|
-
className:
|
|
1651
|
-
children: [/* @__PURE__ */
|
|
1652
|
-
className:
|
|
1653
|
-
children: [/* @__PURE__ */
|
|
1654
|
-
className:
|
|
1655
|
-
children: [/* @__PURE__ */
|
|
1656
|
-
className:
|
|
1657
|
-
children: [/* @__PURE__ */
|
|
1658
|
-
}), /* @__PURE__ */
|
|
1659
|
-
className:
|
|
1660
|
-
options:
|
|
1661
|
-
children: /* @__PURE__ */
|
|
3616
|
+
children: /* @__PURE__ */ b("div", {
|
|
3617
|
+
className: Q["bsy-lexical-ai__dialog"],
|
|
3618
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3619
|
+
className: Q["bsy-lexical-ai__pane"],
|
|
3620
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3621
|
+
className: Q["bsy-lexical-ai__column"],
|
|
3622
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3623
|
+
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--before"]),
|
|
3624
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), p("editor.aiOriginal")]
|
|
3625
|
+
}), /* @__PURE__ */ y(u, {
|
|
3626
|
+
className: Q["bsy-lexical-ai__column-body"],
|
|
3627
|
+
options: Ko,
|
|
3628
|
+
children: /* @__PURE__ */ y(Go, { html: i })
|
|
1662
3629
|
})]
|
|
1663
|
-
}), /* @__PURE__ */
|
|
1664
|
-
className:
|
|
1665
|
-
children: [/* @__PURE__ */
|
|
1666
|
-
className:
|
|
1667
|
-
children: [/* @__PURE__ */
|
|
1668
|
-
className:
|
|
1669
|
-
children: [/* @__PURE__ */
|
|
1670
|
-
}), /* @__PURE__ */
|
|
1671
|
-
menus:
|
|
3630
|
+
}), /* @__PURE__ */ b("div", {
|
|
3631
|
+
className: Q["bsy-lexical-ai__column"],
|
|
3632
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3633
|
+
className: Q["bsy-lexical-ai__column-head"],
|
|
3634
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3635
|
+
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--after"]),
|
|
3636
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), p("editor.aiOptimized")]
|
|
3637
|
+
}), /* @__PURE__ */ y(f, {
|
|
3638
|
+
menus: C,
|
|
1672
3639
|
showSearch: !1,
|
|
1673
|
-
activeKey: [
|
|
3640
|
+
activeKey: [s],
|
|
1674
3641
|
offset: {
|
|
1675
3642
|
x: 0,
|
|
1676
3643
|
y: 4
|
|
@@ -1679,271 +3646,245 @@ var Ur = ({ model: t }) => t.visible ? /* @__PURE__ */ N("button", {
|
|
|
1679
3646
|
width: 90,
|
|
1680
3647
|
minWidth: 90
|
|
1681
3648
|
},
|
|
1682
|
-
onClick: (e) =>
|
|
1683
|
-
children: /* @__PURE__ */
|
|
3649
|
+
onClick: (e) => c(e.key),
|
|
3650
|
+
children: /* @__PURE__ */ b("button", {
|
|
1684
3651
|
type: "button",
|
|
1685
|
-
className:
|
|
1686
|
-
title:
|
|
1687
|
-
children: [
|
|
3652
|
+
className: Q["bsy-lexical-ai__preset"],
|
|
3653
|
+
title: p("editor.aiPolish"),
|
|
3654
|
+
children: [p(Xr[s]), /* @__PURE__ */ y(e, {
|
|
1688
3655
|
name: "arrow-down",
|
|
1689
3656
|
size: 16
|
|
1690
3657
|
})]
|
|
1691
3658
|
})
|
|
1692
3659
|
})]
|
|
1693
|
-
}), /* @__PURE__ */
|
|
1694
|
-
className:
|
|
1695
|
-
children: [
|
|
1696
|
-
className:
|
|
1697
|
-
children: /* @__PURE__ */
|
|
1698
|
-
}) : null, /* @__PURE__ */
|
|
1699
|
-
className:
|
|
1700
|
-
options:
|
|
3660
|
+
}), /* @__PURE__ */ b("div", {
|
|
3661
|
+
className: Q["bsy-lexical-ai__column-stack"],
|
|
3662
|
+
children: [S.visible ? /* @__PURE__ */ y("div", {
|
|
3663
|
+
className: Q["bsy-lexical-ai__think-pin"],
|
|
3664
|
+
children: /* @__PURE__ */ y(Vo, { model: S })
|
|
3665
|
+
}) : null, /* @__PURE__ */ b(u, {
|
|
3666
|
+
className: Q["bsy-lexical-ai__column-body"],
|
|
3667
|
+
options: Ko,
|
|
1701
3668
|
viewportRef: _,
|
|
1702
|
-
onScroll:
|
|
1703
|
-
children: [
|
|
1704
|
-
className:
|
|
1705
|
-
children:
|
|
1706
|
-
}) : /* @__PURE__ */
|
|
3669
|
+
onScroll: S.onViewportScroll,
|
|
3670
|
+
children: [t === "error" ? /* @__PURE__ */ y("div", {
|
|
3671
|
+
className: Q["bsy-lexical-ai__error"],
|
|
3672
|
+
children: n || p("editor.aiError")
|
|
3673
|
+
}) : /* @__PURE__ */ y(Ho, { model: S }), v ? /* @__PURE__ */ y(Go, { html: o }) : null]
|
|
1707
3674
|
})]
|
|
1708
3675
|
})]
|
|
1709
3676
|
})]
|
|
1710
|
-
}), /* @__PURE__ */
|
|
1711
|
-
className:
|
|
1712
|
-
children: [/* @__PURE__ */
|
|
3677
|
+
}), /* @__PURE__ */ b("div", {
|
|
3678
|
+
className: Q["bsy-lexical-ai__footer"],
|
|
3679
|
+
children: [/* @__PURE__ */ y(F, {
|
|
1713
3680
|
onClick: () => g(!1),
|
|
1714
|
-
children:
|
|
1715
|
-
}), /* @__PURE__ */
|
|
3681
|
+
children: p("editor.aiAbandon")
|
|
3682
|
+
}), /* @__PURE__ */ y(F, {
|
|
1716
3683
|
type: "primary",
|
|
1717
|
-
disabled: !
|
|
1718
|
-
onClick: () =>
|
|
1719
|
-
children:
|
|
3684
|
+
disabled: !x,
|
|
3685
|
+
onClick: () => d() && g(!1),
|
|
3686
|
+
children: p("editor.aiApply")
|
|
1720
3687
|
})]
|
|
1721
3688
|
})]
|
|
1722
3689
|
})
|
|
1723
3690
|
});
|
|
1724
|
-
},
|
|
3691
|
+
}, Jo = {
|
|
1725
3692
|
paddingAbsolute: !0,
|
|
1726
3693
|
overflow: {
|
|
1727
3694
|
x: "hidden",
|
|
1728
3695
|
y: "scroll"
|
|
1729
3696
|
}
|
|
1730
|
-
},
|
|
1731
|
-
let { t:
|
|
3697
|
+
}, Yo = ({ status: e, errorMessage: t, originalHtml: n, proposedHtml: i, onCancel: o, onApply: s }) => {
|
|
3698
|
+
let { t: c } = a(), l = _r(), [d, f] = P(!0), p = N(null), m = !!i.trim(), h = e === "ready" && m, g = Bo({
|
|
1732
3699
|
status: e,
|
|
1733
|
-
reasoning:
|
|
3700
|
+
reasoning: l
|
|
1734
3701
|
}, m, p);
|
|
1735
|
-
return /* @__PURE__ */
|
|
1736
|
-
title:
|
|
3702
|
+
return /* @__PURE__ */ y(r, {
|
|
3703
|
+
title: c("editor.aiPreview"),
|
|
1737
3704
|
open: d,
|
|
1738
3705
|
width: "800px",
|
|
1739
3706
|
fullSwitch: !0,
|
|
1740
|
-
afterClose:
|
|
3707
|
+
afterClose: o,
|
|
1741
3708
|
onOpenChange: f,
|
|
1742
|
-
children: /* @__PURE__ */
|
|
1743
|
-
className:
|
|
1744
|
-
children: [/* @__PURE__ */
|
|
1745
|
-
className:
|
|
1746
|
-
children: [/* @__PURE__ */
|
|
1747
|
-
className:
|
|
1748
|
-
children: [/* @__PURE__ */
|
|
1749
|
-
className:
|
|
1750
|
-
children: [/* @__PURE__ */
|
|
1751
|
-
}), /* @__PURE__ */
|
|
1752
|
-
className:
|
|
1753
|
-
options:
|
|
1754
|
-
children: /* @__PURE__ */
|
|
3709
|
+
children: /* @__PURE__ */ b("div", {
|
|
3710
|
+
className: Q["bsy-lexical-ai__dialog"],
|
|
3711
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3712
|
+
className: Q["bsy-lexical-ai__pane"],
|
|
3713
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3714
|
+
className: Q["bsy-lexical-ai__column"],
|
|
3715
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3716
|
+
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--before"]),
|
|
3717
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), c("editor.aiOriginal")]
|
|
3718
|
+
}), /* @__PURE__ */ y(u, {
|
|
3719
|
+
className: Q["bsy-lexical-ai__column-body"],
|
|
3720
|
+
options: Jo,
|
|
3721
|
+
children: /* @__PURE__ */ y(Go, { html: n })
|
|
1755
3722
|
})]
|
|
1756
|
-
}), /* @__PURE__ */
|
|
1757
|
-
className:
|
|
1758
|
-
children: [/* @__PURE__ */
|
|
1759
|
-
className:
|
|
1760
|
-
children: [/* @__PURE__ */
|
|
1761
|
-
}), /* @__PURE__ */
|
|
1762
|
-
className:
|
|
1763
|
-
children: [g.visible ? /* @__PURE__ */
|
|
1764
|
-
className:
|
|
1765
|
-
children: /* @__PURE__ */
|
|
1766
|
-
}) : null, /* @__PURE__ */
|
|
1767
|
-
className:
|
|
1768
|
-
options:
|
|
3723
|
+
}), /* @__PURE__ */ b("div", {
|
|
3724
|
+
className: Q["bsy-lexical-ai__column"],
|
|
3725
|
+
children: [/* @__PURE__ */ b("div", {
|
|
3726
|
+
className: I(Q["bsy-lexical-ai__column-title"], Q["bsy-lexical-ai__column-title--after"]),
|
|
3727
|
+
children: [/* @__PURE__ */ y("span", { className: Q["bsy-lexical-ai__column-dot"] }), c("editor.aiOptimized")]
|
|
3728
|
+
}), /* @__PURE__ */ b("div", {
|
|
3729
|
+
className: Q["bsy-lexical-ai__column-stack"],
|
|
3730
|
+
children: [g.visible ? /* @__PURE__ */ y("div", {
|
|
3731
|
+
className: Q["bsy-lexical-ai__think-pin"],
|
|
3732
|
+
children: /* @__PURE__ */ y(Vo, { model: g })
|
|
3733
|
+
}) : null, /* @__PURE__ */ b(u, {
|
|
3734
|
+
className: Q["bsy-lexical-ai__column-body"],
|
|
3735
|
+
options: Jo,
|
|
1769
3736
|
viewportRef: p,
|
|
1770
3737
|
onScroll: g.onViewportScroll,
|
|
1771
|
-
children: [e === "error" ? /* @__PURE__ */
|
|
1772
|
-
className:
|
|
1773
|
-
children:
|
|
1774
|
-
}) : /* @__PURE__ */
|
|
3738
|
+
children: [e === "error" ? /* @__PURE__ */ y("div", {
|
|
3739
|
+
className: Q["bsy-lexical-ai__error"],
|
|
3740
|
+
children: t || c("editor.aiError")
|
|
3741
|
+
}) : /* @__PURE__ */ y(Ho, { model: g }), m ? /* @__PURE__ */ y(Go, { html: i }) : null]
|
|
1775
3742
|
})]
|
|
1776
3743
|
})]
|
|
1777
3744
|
})]
|
|
1778
|
-
}), /* @__PURE__ */
|
|
1779
|
-
className:
|
|
1780
|
-
children: [/* @__PURE__ */
|
|
3745
|
+
}), /* @__PURE__ */ b("div", {
|
|
3746
|
+
className: Q["bsy-lexical-ai__footer"],
|
|
3747
|
+
children: [/* @__PURE__ */ y(F, {
|
|
1781
3748
|
onClick: () => f(!1),
|
|
1782
|
-
children:
|
|
1783
|
-
}), /* @__PURE__ */
|
|
3749
|
+
children: c("editor.aiAbandon")
|
|
3750
|
+
}), /* @__PURE__ */ y(F, {
|
|
1784
3751
|
type: "primary",
|
|
1785
3752
|
disabled: !h,
|
|
1786
|
-
onClick: () =>
|
|
1787
|
-
children:
|
|
3753
|
+
onClick: () => s() && f(!1),
|
|
3754
|
+
children: c("editor.aiApply")
|
|
1788
3755
|
})]
|
|
1789
3756
|
})]
|
|
1790
3757
|
})
|
|
1791
3758
|
});
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
3759
|
+
};
|
|
3760
|
+
//#endregion
|
|
3761
|
+
//#region src/components/Editor/Preview/EditorPreview.tsx
|
|
3762
|
+
function Xo(e, t, n, r) {
|
|
3763
|
+
return Lo({
|
|
3764
|
+
enabled: e,
|
|
3765
|
+
status: r,
|
|
3766
|
+
revision: n,
|
|
3767
|
+
compute: () => Io(Yi(t, n), r)
|
|
1797
3768
|
});
|
|
1798
|
-
o.current = {
|
|
1799
|
-
originalHtml: t,
|
|
1800
|
-
text: n
|
|
1801
|
-
};
|
|
1802
|
-
let s = L(null);
|
|
1803
|
-
return Te(() => {
|
|
1804
|
-
let t = () => {
|
|
1805
|
-
s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
|
|
1806
|
-
};
|
|
1807
|
-
if (!e) {
|
|
1808
|
-
t(), a("");
|
|
1809
|
-
return;
|
|
1810
|
-
}
|
|
1811
|
-
let n = () => {
|
|
1812
|
-
s.current = null;
|
|
1813
|
-
let e = o.current;
|
|
1814
|
-
a($(w(e.originalHtml, e.text)));
|
|
1815
|
-
};
|
|
1816
|
-
if (r === "ready" || r === "error") {
|
|
1817
|
-
t(), n();
|
|
1818
|
-
return;
|
|
1819
|
-
}
|
|
1820
|
-
s.current === null && (s.current = requestAnimationFrame(n));
|
|
1821
|
-
}, [
|
|
1822
|
-
e,
|
|
1823
|
-
t,
|
|
1824
|
-
r,
|
|
1825
|
-
n
|
|
1826
|
-
]), F(() => () => {
|
|
1827
|
-
s.current !== null && cancelAnimationFrame(s.current);
|
|
1828
|
-
}, []), i;
|
|
1829
3769
|
}
|
|
1830
|
-
var
|
|
1831
|
-
let [
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
3770
|
+
var Zo = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
3771
|
+
let [n] = B(), { aiOpen: r, setAiOpen: i, aiSessionRef: o, stop: s, polish: c } = hr(), { t: l } = a(), [u, d] = ne.useMessage(), f = o.current, { text: p, status: m, errorMessage: h } = gr(), g = !m || m === "idle" ? "loading" : m, _ = p, x = M(() => r ? Io(o.current?.originalHtml || "", "ready") : "", [r, o]), S = Lo({
|
|
3772
|
+
enabled: r === "typeset",
|
|
3773
|
+
status: g,
|
|
3774
|
+
revision: _,
|
|
3775
|
+
compute: () => Io(Po(_, f?.codeBlocks ?? []), g)
|
|
3776
|
+
}), C = Xo(r === "polish", f?.originalHtml || "", _, g);
|
|
3777
|
+
O(() => {
|
|
3778
|
+
if (r) return n.setEditable(!1), n.update(() => {
|
|
3779
|
+
Ne(null);
|
|
3780
|
+
}), window.getSelection()?.removeAllRanges(), n.getRootElement()?.blur(), () => {
|
|
3781
|
+
n.setEditable(!0);
|
|
1837
3782
|
};
|
|
1838
|
-
}, [
|
|
1839
|
-
let w =
|
|
1840
|
-
s?.(), o.current = null,
|
|
3783
|
+
}, [r, n]);
|
|
3784
|
+
let w = T(() => {
|
|
3785
|
+
s?.(), o.current = null, i(null);
|
|
1841
3786
|
}, [
|
|
1842
3787
|
o,
|
|
1843
|
-
|
|
3788
|
+
i,
|
|
1844
3789
|
s
|
|
1845
|
-
]),
|
|
1846
|
-
if (
|
|
1847
|
-
|
|
1848
|
-
let { applied:
|
|
1849
|
-
return
|
|
3790
|
+
]), E = T(() => {
|
|
3791
|
+
if (r !== "typeset" || g !== "ready") return !1;
|
|
3792
|
+
n.setEditable(!0);
|
|
3793
|
+
let { applied: i, truncated: a } = Fo(n, _, o.current?.codeBlocks ?? [], e);
|
|
3794
|
+
return i ? (a && t?.(), !0) : (n.setEditable(!1), u.warning(l("editor.aiApplyEmpty")), !1);
|
|
1850
3795
|
}, [
|
|
1851
|
-
i,
|
|
1852
|
-
o,
|
|
1853
3796
|
r,
|
|
3797
|
+
o,
|
|
3798
|
+
n,
|
|
1854
3799
|
e,
|
|
1855
|
-
d,
|
|
1856
|
-
t,
|
|
1857
|
-
v,
|
|
1858
3800
|
u,
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
3801
|
+
t,
|
|
3802
|
+
g,
|
|
3803
|
+
l,
|
|
3804
|
+
_
|
|
3805
|
+
]), D = T(() => r !== "polish" || g !== "ready" ? !1 : Xi(n, _) ? !0 : (u.warning(l("editor.aiApplyEmpty")), !1), [
|
|
1862
3806
|
r,
|
|
1863
|
-
|
|
1864
|
-
v,
|
|
3807
|
+
n,
|
|
1865
3808
|
u,
|
|
1866
|
-
|
|
1867
|
-
|
|
3809
|
+
g,
|
|
3810
|
+
l,
|
|
3811
|
+
_
|
|
3812
|
+
]), k = T((e) => {
|
|
1868
3813
|
let t = o.current;
|
|
1869
|
-
!t?.originalText || !
|
|
3814
|
+
!t?.originalText || !c || (t.preset = e, s?.(), c({
|
|
1870
3815
|
text: t.originalText,
|
|
1871
3816
|
preset: e
|
|
1872
3817
|
}));
|
|
1873
3818
|
}, [
|
|
1874
3819
|
o,
|
|
1875
|
-
|
|
3820
|
+
c,
|
|
1876
3821
|
s
|
|
1877
3822
|
]);
|
|
1878
|
-
return
|
|
1879
|
-
status:
|
|
1880
|
-
|
|
1881
|
-
errorMessage: _,
|
|
3823
|
+
return r ? /* @__PURE__ */ b(v, { children: [d, r === "typeset" ? /* @__PURE__ */ y(Yo, {
|
|
3824
|
+
status: g,
|
|
3825
|
+
errorMessage: h,
|
|
1882
3826
|
originalHtml: x,
|
|
1883
|
-
proposedHtml:
|
|
3827
|
+
proposedHtml: S,
|
|
1884
3828
|
onCancel: w,
|
|
1885
|
-
onApply:
|
|
1886
|
-
}) : /* @__PURE__ */
|
|
1887
|
-
status:
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
originalHtml: S,
|
|
3829
|
+
onApply: E
|
|
3830
|
+
}) : /* @__PURE__ */ y(qo, {
|
|
3831
|
+
status: g,
|
|
3832
|
+
errorMessage: h,
|
|
3833
|
+
originalHtml: x,
|
|
1891
3834
|
proposedHtml: C,
|
|
1892
|
-
preset:
|
|
1893
|
-
onPresetChange:
|
|
3835
|
+
preset: f?.preset ?? "quick",
|
|
3836
|
+
onPresetChange: k,
|
|
1894
3837
|
onCancel: w,
|
|
1895
|
-
onApply:
|
|
1896
|
-
})] }) :
|
|
1897
|
-
},
|
|
1898
|
-
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s, upload: c, ai: l } = e, [u] =
|
|
3838
|
+
onApply: D
|
|
3839
|
+
})] }) : d;
|
|
3840
|
+
}, Qo = [], $o = (e) => {
|
|
3841
|
+
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s, upload: c, ai: l } = e, [u] = B(), { isSourceMode: d, isSourceModeRef: f } = Ur(), p = N(null), m = N(null), h = N(/* @__PURE__ */ new Map()), g = N(null), _ = N(null), v = N(s);
|
|
1899
3842
|
v.current = s;
|
|
1900
|
-
let
|
|
1901
|
-
|
|
1902
|
-
let
|
|
1903
|
-
|
|
1904
|
-
let
|
|
1905
|
-
|
|
1906
|
-
}, []),
|
|
1907
|
-
|
|
1908
|
-
}, []),
|
|
1909
|
-
|
|
1910
|
-
}, []),
|
|
3843
|
+
let x = Xa(o) ? o : void 0, [S, C] = P(0), [w, E] = P(null), D = i?.mode === "floating", k = x !== void 0 && !d, A = N(l);
|
|
3844
|
+
A.current = l;
|
|
3845
|
+
let j = N(r);
|
|
3846
|
+
j.current = r;
|
|
3847
|
+
let F = T((e) => {
|
|
3848
|
+
A.current?.typeset?.(e);
|
|
3849
|
+
}, []), ee = T((e) => {
|
|
3850
|
+
A.current?.polish?.(e);
|
|
3851
|
+
}, []), te = T(() => {
|
|
3852
|
+
A.current?.stop?.();
|
|
3853
|
+
}, []), ne = !!l?.typeset, I = !!l?.polish, re = M(() => ({
|
|
1911
3854
|
containerRef: p,
|
|
1912
3855
|
toolbarRef: m,
|
|
1913
3856
|
upload: c,
|
|
1914
|
-
aiOpen:
|
|
1915
|
-
setAiOpen:
|
|
3857
|
+
aiOpen: w,
|
|
3858
|
+
setAiOpen: E,
|
|
1916
3859
|
aiSessionRef: g,
|
|
1917
3860
|
attachmentsBySrcRef: h,
|
|
1918
|
-
typeset:
|
|
1919
|
-
polish:
|
|
1920
|
-
stop:
|
|
1921
|
-
canTypeset:
|
|
1922
|
-
canPolish:
|
|
3861
|
+
typeset: F,
|
|
3862
|
+
polish: ee,
|
|
3863
|
+
stop: te,
|
|
3864
|
+
canTypeset: ne,
|
|
3865
|
+
canPolish: I
|
|
1923
3866
|
}), [
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
3867
|
+
w,
|
|
3868
|
+
I,
|
|
3869
|
+
ne,
|
|
3870
|
+
ee,
|
|
3871
|
+
te,
|
|
3872
|
+
F,
|
|
1930
3873
|
c
|
|
1931
|
-
]),
|
|
3874
|
+
]), ie = M(() => ({
|
|
1932
3875
|
text: l?.text ?? "",
|
|
1933
|
-
reasoning: l?.reasoning,
|
|
1934
3876
|
status: l?.status,
|
|
1935
3877
|
errorMessage: l?.errorMessage
|
|
1936
3878
|
}), [
|
|
1937
3879
|
l?.text,
|
|
1938
|
-
l?.reasoning,
|
|
1939
3880
|
l?.status,
|
|
1940
3881
|
l?.errorMessage
|
|
1941
|
-
]),
|
|
3882
|
+
]), ae = T((e) => {
|
|
1942
3883
|
f.current || e.read(() => {
|
|
1943
|
-
let t =
|
|
1944
|
-
_.current = r,
|
|
1945
|
-
let i =
|
|
1946
|
-
|
|
3884
|
+
let t = L().getTextContent(), n = Fi(X(he(u, null))), r = ni(n, t) ? null : n;
|
|
3885
|
+
_.current = r, x !== void 0 && C(t.length);
|
|
3886
|
+
let i = je(tn).map((e) => h.current.get(e.getSrc())).filter((e) => e !== void 0);
|
|
3887
|
+
j.current({
|
|
1947
3888
|
text: t,
|
|
1948
3889
|
html: r,
|
|
1949
3890
|
attachments: i
|
|
@@ -1951,148 +3892,171 @@ var Zr = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
|
1951
3892
|
}, { editor: u });
|
|
1952
3893
|
}, [
|
|
1953
3894
|
u,
|
|
1954
|
-
|
|
3895
|
+
x,
|
|
1955
3896
|
f
|
|
1956
3897
|
]);
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
3898
|
+
O(() => {
|
|
3899
|
+
x === void 0 || d || u.getEditorState().read(() => {
|
|
3900
|
+
C(L().getTextContentSize());
|
|
1960
3901
|
}, { editor: u });
|
|
1961
3902
|
}, [
|
|
1962
3903
|
u,
|
|
1963
|
-
|
|
3904
|
+
x,
|
|
1964
3905
|
d
|
|
1965
|
-
]),
|
|
3906
|
+
]), O(() => {
|
|
1966
3907
|
if (e.value === void 0 || e.value === _.current) return;
|
|
1967
3908
|
if (f.current) {
|
|
1968
|
-
let t = e.value?.trim() ?
|
|
3909
|
+
let t = e.value?.trim() ? X(e.value) : "";
|
|
1969
3910
|
_.current = e.value, u.update(() => {
|
|
1970
|
-
|
|
3911
|
+
lo(co(t));
|
|
1971
3912
|
});
|
|
1972
3913
|
return;
|
|
1973
3914
|
}
|
|
1974
|
-
let t = !1;
|
|
3915
|
+
let t = !1, n = _.current === null;
|
|
1975
3916
|
u.update(() => {
|
|
1976
|
-
|
|
1977
|
-
}), t && v.current?.();
|
|
3917
|
+
ti(u, e.value?.trim() ? X(e.value) : ""), x !== void 0 && (t = Za(u, x)), On(u);
|
|
3918
|
+
}), n && u.dispatchCommand(Le, void 0), t && v.current?.();
|
|
1978
3919
|
}, [
|
|
1979
3920
|
e.value,
|
|
1980
3921
|
u,
|
|
1981
|
-
|
|
3922
|
+
x,
|
|
1982
3923
|
f
|
|
1983
3924
|
]);
|
|
1984
|
-
let
|
|
3925
|
+
let oe = i?.config?.length ? i.config : Qo, se = T(() => {
|
|
1985
3926
|
v.current?.();
|
|
1986
3927
|
}, []);
|
|
1987
|
-
return /* @__PURE__ */
|
|
1988
|
-
value:
|
|
1989
|
-
children: /* @__PURE__ */
|
|
1990
|
-
value:
|
|
1991
|
-
children:
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
3928
|
+
return /* @__PURE__ */ y(fr.Provider, {
|
|
3929
|
+
value: re,
|
|
3930
|
+
children: /* @__PURE__ */ y(pr.Provider, {
|
|
3931
|
+
value: ie,
|
|
3932
|
+
children: /* @__PURE__ */ b(mr.Provider, {
|
|
3933
|
+
value: l?.reasoning,
|
|
3934
|
+
children: [/* @__PURE__ */ y(es, {
|
|
3935
|
+
containerRef: p,
|
|
3936
|
+
isFloating: D,
|
|
3937
|
+
toolbarConfig: oe,
|
|
3938
|
+
toolbarTheme: a?.toolbar,
|
|
3939
|
+
containerTheme: a?.container,
|
|
3940
|
+
toolbarStyle: i?.style,
|
|
3941
|
+
toolbarSize: i?.size,
|
|
3942
|
+
toolbarMode: i?.mode,
|
|
3943
|
+
toolbarFloating: i?.floating,
|
|
3944
|
+
toolbarStickyOffset: i?.stickyOffset,
|
|
3945
|
+
height: t,
|
|
3946
|
+
minHeight: n,
|
|
3947
|
+
showLengthBadge: k,
|
|
3948
|
+
textLength: S,
|
|
3949
|
+
validMaxLength: x,
|
|
3950
|
+
onMaxLengthExceed: se,
|
|
3951
|
+
onChange: ae
|
|
3952
|
+
}), /* @__PURE__ */ y(Zo, {
|
|
3953
|
+
maxLength: x,
|
|
3954
|
+
onMaxLengthExceed: se
|
|
3955
|
+
})]
|
|
3956
|
+
})
|
|
2013
3957
|
})
|
|
2014
3958
|
});
|
|
2015
|
-
},
|
|
2016
|
-
let [_] =
|
|
2017
|
-
|
|
2018
|
-
v &&
|
|
3959
|
+
}, es = 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 }) {
|
|
3960
|
+
let [_] = B(), v = Zt(), x = typeof u == "number" ? u : void 0, S = !t && x === void 0 && l !== void 0, C = N(!1);
|
|
3961
|
+
O(() => {
|
|
3962
|
+
v && C.current && (C.current = !1, _.focus());
|
|
2019
3963
|
}, [v, _]);
|
|
2020
|
-
let
|
|
2021
|
-
return /* @__PURE__ */
|
|
3964
|
+
let w = M(() => _a(i), [i]);
|
|
3965
|
+
return /* @__PURE__ */ b("div", {
|
|
2022
3966
|
ref: e,
|
|
2023
|
-
className:
|
|
2024
|
-
style:
|
|
3967
|
+
className: I("bsy-lexical-editor", $["bsy-lexical-editor"], t && $["bsy-lexical-editor--floating"], S && $["bsy-lexical-editor--sticky-toolbar"]),
|
|
3968
|
+
style: w,
|
|
2025
3969
|
onClick: (e) => {
|
|
2026
3970
|
let t = _.getRootElement(), n = e.target;
|
|
2027
|
-
!t || !n || !t.contains(n) || _.isEditable() || (
|
|
3971
|
+
!t || !n || !t.contains(n) || _.isEditable() || (C.current = !0, _.setEditable(!0));
|
|
2028
3972
|
},
|
|
2029
3973
|
children: [
|
|
2030
|
-
n && n.length > 0 ? /* @__PURE__ */
|
|
3974
|
+
n && n.length > 0 ? /* @__PURE__ */ y(ha, {
|
|
2031
3975
|
config: n,
|
|
2032
3976
|
theme: r,
|
|
2033
3977
|
style: a,
|
|
2034
3978
|
size: o,
|
|
2035
3979
|
mode: s,
|
|
2036
3980
|
floating: c,
|
|
2037
|
-
stickyOffset:
|
|
3981
|
+
stickyOffset: S ? l : void 0
|
|
2038
3982
|
}) : null,
|
|
2039
|
-
/* @__PURE__ */
|
|
2040
|
-
className:
|
|
2041
|
-
style: { height:
|
|
2042
|
-
children: [/* @__PURE__ */
|
|
2043
|
-
className:
|
|
2044
|
-
children: /* @__PURE__ */
|
|
2045
|
-
contentEditable: /* @__PURE__ */
|
|
2046
|
-
className:
|
|
3983
|
+
/* @__PURE__ */ b("div", {
|
|
3984
|
+
className: I($["bsy-lexical-editor__body"], x !== void 0 && $["bsy-lexical-editor__body--fixed"]),
|
|
3985
|
+
style: { height: x },
|
|
3986
|
+
children: [/* @__PURE__ */ y("div", {
|
|
3987
|
+
className: $["bsy-lexical-editor__editable-wrap"],
|
|
3988
|
+
children: /* @__PURE__ */ y(ue, {
|
|
3989
|
+
contentEditable: /* @__PURE__ */ y(de, {
|
|
3990
|
+
className: $["bsy-lexical-editor__content-editable"],
|
|
2047
3991
|
style: {
|
|
2048
|
-
minHeight:
|
|
3992
|
+
minHeight: x === void 0 ? d : void 0,
|
|
2049
3993
|
cursor: v ? "auto" : "text"
|
|
2050
3994
|
}
|
|
2051
3995
|
}),
|
|
2052
|
-
ErrorBoundary:
|
|
3996
|
+
ErrorBoundary: me
|
|
2053
3997
|
})
|
|
2054
|
-
}), f && m !== void 0 ? /* @__PURE__ */
|
|
3998
|
+
}), f && m !== void 0 ? /* @__PURE__ */ y(mo, {
|
|
2055
3999
|
current: p,
|
|
2056
4000
|
maxLength: m
|
|
2057
4001
|
}) : null]
|
|
2058
4002
|
}),
|
|
2059
|
-
/* @__PURE__ */
|
|
2060
|
-
/* @__PURE__ */
|
|
2061
|
-
/* @__PURE__ */
|
|
2062
|
-
/* @__PURE__ */
|
|
2063
|
-
/* @__PURE__ */
|
|
2064
|
-
/* @__PURE__ */
|
|
2065
|
-
/* @__PURE__ */
|
|
2066
|
-
/* @__PURE__ */
|
|
2067
|
-
/* @__PURE__ */
|
|
2068
|
-
/* @__PURE__ */
|
|
2069
|
-
f && m !== void 0 ? /* @__PURE__ */
|
|
4003
|
+
/* @__PURE__ */ y(Qt, {}),
|
|
4004
|
+
/* @__PURE__ */ y($t, {}),
|
|
4005
|
+
/* @__PURE__ */ y(Ca, {}),
|
|
4006
|
+
/* @__PURE__ */ y(po, {}),
|
|
4007
|
+
/* @__PURE__ */ y(wa, {}),
|
|
4008
|
+
/* @__PURE__ */ y(Da, {}),
|
|
4009
|
+
/* @__PURE__ */ y(Oa, {}),
|
|
4010
|
+
/* @__PURE__ */ y(Ga, {}),
|
|
4011
|
+
/* @__PURE__ */ y(Ka, {}),
|
|
4012
|
+
/* @__PURE__ */ y(Ja, {}),
|
|
4013
|
+
f && m !== void 0 ? /* @__PURE__ */ y(Ya, {
|
|
2070
4014
|
maxLength: m,
|
|
2071
4015
|
onMaxLengthExceed: h
|
|
2072
4016
|
}) : null,
|
|
2073
|
-
/* @__PURE__ */
|
|
2074
|
-
/* @__PURE__ */
|
|
4017
|
+
/* @__PURE__ */ y(fe, {}),
|
|
4018
|
+
/* @__PURE__ */ y(pe, {
|
|
2075
4019
|
onChange: g,
|
|
2076
4020
|
ignoreSelectionChange: !0,
|
|
2077
4021
|
ignoreHistoryMergeTagChange: !1
|
|
2078
4022
|
})
|
|
2079
4023
|
]
|
|
2080
4024
|
});
|
|
2081
|
-
}),
|
|
4025
|
+
}), ts = (e) => /* @__PURE__ */ y(uo, {
|
|
2082
4026
|
maxLength: e.maxLength,
|
|
2083
4027
|
onMaxLengthExceed: e.onMaxLengthExceed,
|
|
2084
|
-
children: /* @__PURE__ */
|
|
4028
|
+
children: /* @__PURE__ */ y($o, { ...e })
|
|
2085
4029
|
});
|
|
2086
|
-
|
|
4030
|
+
ts.displayName = "BsyLexicalEditorCore";
|
|
2087
4031
|
//#endregion
|
|
2088
|
-
//#region src/components/Editor/
|
|
2089
|
-
var
|
|
4032
|
+
//#region src/components/Editor/nodes/ExtendedLinkNode.ts
|
|
4033
|
+
var ns = class e extends ft {
|
|
4034
|
+
constructor(e = "", t = {}, n) {
|
|
4035
|
+
super(e, t, n);
|
|
4036
|
+
}
|
|
4037
|
+
static getType() {
|
|
4038
|
+
return "extended-link";
|
|
4039
|
+
}
|
|
4040
|
+
static clone(t) {
|
|
4041
|
+
return new e(t.__url, {
|
|
4042
|
+
rel: t.__rel,
|
|
4043
|
+
target: t.__target,
|
|
4044
|
+
title: t.__title
|
|
4045
|
+
}, t.__key);
|
|
4046
|
+
}
|
|
4047
|
+
static importJSON(e) {
|
|
4048
|
+
return rs().updateFromJSON(e);
|
|
4049
|
+
}
|
|
4050
|
+
sanitizeUrl(e) {
|
|
4051
|
+
return e.startsWith("@") ? e : super.sanitizeUrl(e);
|
|
4052
|
+
}
|
|
4053
|
+
}, rs = (e = "", t = {}) => _e(new ns(e, t)), is = "1px solid #d9d9d9", as = { export: new Map([[Rt, (e, t) => {
|
|
2090
4054
|
let n = t.exportDOM(e);
|
|
2091
|
-
return
|
|
2092
|
-
}]]) },
|
|
4055
|
+
return at(n.element) && (n.element.style.border = is), n;
|
|
4056
|
+
}]]) }, os = (e) => {
|
|
2093
4057
|
let { autoFocus: t = !1 } = e;
|
|
2094
|
-
return /* @__PURE__ */
|
|
2095
|
-
initialConfig:
|
|
4058
|
+
return /* @__PURE__ */ y(le, {
|
|
4059
|
+
initialConfig: M(() => ({
|
|
2096
4060
|
namespace: "bsyLexicalEditor",
|
|
2097
4061
|
onError: (e) => {
|
|
2098
4062
|
console.error("Lexical error", e);
|
|
@@ -2128,30 +4092,39 @@ var ni = "1px solid #d9d9d9", ri = { export: new Map([[Wt, (e, t) => {
|
|
|
2128
4092
|
tableRow: "editor-table-row",
|
|
2129
4093
|
tableScrollableWrapper: "editor-table-scrollable-wrapper"
|
|
2130
4094
|
},
|
|
2131
|
-
html:
|
|
4095
|
+
html: as,
|
|
2132
4096
|
nodes: [
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
4097
|
+
ns,
|
|
4098
|
+
{
|
|
4099
|
+
replace: ft,
|
|
4100
|
+
with: (e) => new ns(e.__url, {
|
|
4101
|
+
rel: e.__rel,
|
|
4102
|
+
target: e.__target,
|
|
4103
|
+
title: e.__title
|
|
4104
|
+
}),
|
|
4105
|
+
withKlass: ns
|
|
4106
|
+
},
|
|
4107
|
+
dt,
|
|
4108
|
+
yt,
|
|
4109
|
+
vt,
|
|
4110
|
+
qt,
|
|
4111
|
+
Et,
|
|
4112
|
+
Tt,
|
|
4113
|
+
zt,
|
|
4114
|
+
Bt,
|
|
4115
|
+
Rt,
|
|
4116
|
+
tn,
|
|
4117
|
+
va,
|
|
2145
4118
|
{
|
|
2146
|
-
replace:
|
|
2147
|
-
with: (e) => new
|
|
2148
|
-
withKlass:
|
|
4119
|
+
replace: nt,
|
|
4120
|
+
with: (e) => new va(e.__text),
|
|
4121
|
+
withKlass: va
|
|
2149
4122
|
}
|
|
2150
4123
|
]
|
|
2151
4124
|
}), [t]),
|
|
2152
|
-
children: /* @__PURE__ */
|
|
4125
|
+
children: /* @__PURE__ */ y(ts, { ...e })
|
|
2153
4126
|
});
|
|
2154
4127
|
};
|
|
2155
|
-
|
|
4128
|
+
os.displayName = "BsyLexicalEditor";
|
|
2156
4129
|
//#endregion
|
|
2157
|
-
export {
|
|
4130
|
+
export { we as $getRoot, q as BaseButton, Wo as EditorHtmlPreview, os as default, sa as listRegisteredToolbarButtons, ia as registerToolbarButton, aa as unregisterToolbarButton, st as useLexicalComposerContext };
|