@baishuyun/ui-base 6.12.0 → 6.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Amap/AmapCircle/index.js +1 -1
- package/dist/Amap/AmapMarker/index.js +1 -1
- package/dist/Amap/AmapMarkerCluster/index.js +1 -1
- package/dist/Amap/AmapProvider/index.js +4 -4
- package/dist/Amap/{AmapProvider-CvRHhN42.js → AmapProvider-BwyzXpEj.js} +1 -1
- package/dist/Amap/hooks/index.js +1 -1
- package/dist/Amap/index.js +4 -4
- package/dist/Calendar/{AllDaySection-CTaXpCmK.js → AllDaySection-D9YHhwIa.js} +1 -1
- package/dist/Calendar/{Calendar-BOLbbip1.js → Calendar-DEjopu9G.js} +5 -5
- package/dist/Calendar/{TimeGrid-Ci8Dfama.js → TimeGrid-5zMy9Hks.js} +1 -1
- package/dist/Calendar/context/index.js +1 -1
- package/dist/Calendar/index.js +8 -8
- package/dist/Calendar/subcomponents/AllDaySection/index.js +3 -3
- package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +1 -1
- package/dist/Calendar/subcomponents/EventCard/index.js +1 -1
- package/dist/Calendar/subcomponents/TimeAxis/index.js +1 -1
- package/dist/Calendar/subcomponents/TimeGrid/index.js +3 -3
- package/dist/Calendar/utils/index.js +1 -1
- package/dist/Calendar/utils/layout/index.js +1 -1
- package/dist/Calendar/utils/theme/index.js +1 -1
- package/dist/Card/{Card-C8A4XaJZ.js → Card-DDbQQsCc.js} +1 -1
- package/dist/Card/index.js +3 -3
- package/dist/CheckBox/{CheckBox-DBzTOuRy.js → CheckBox-CwfrMEFb.js} +1 -1
- package/dist/CheckBox/{CheckBox-Dt4x6IqH.js → CheckBox-DFfNiPGM.js} +1 -1
- package/dist/CheckBox/index.js +4 -4
- package/dist/ColorPicker/{ColorPicker-Buku806Y.js → ColorPicker-Cm_-e0Hz.js} +34 -31
- package/dist/ColorPicker/index.js +5 -5
- package/dist/ConfigProvider/index.js +3 -3
- package/dist/DatePicker/{DatePicker-Vi3wfsfz.js → DatePicker-BUvDkVjx.js} +9 -9
- package/dist/DatePicker/{DatePickerPanel-Cwmb-4UR.js → DatePickerPanel-BHTPcE6R.js} +4 -4
- package/dist/DatePicker/index.js +4 -4
- package/dist/DatePicker/style/index.js +1 -1
- package/dist/DropDown/DropDown-DV1IuuQD.js +290 -0
- package/dist/DropDown/index.js +7 -7
- package/dist/DropDown/style/index.js +1 -1
- package/dist/Editor/Buttons-BUC9qQY1.js +1732 -0
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +12 -12
- package/dist/Editor/constants/index.js +10 -3
- package/dist/Editor/index.js +1572 -909
- package/dist/Gantt/GanttChart/index.js +9 -9
- package/dist/Gantt/{GanttChart-WIrD6Z7O.js → GanttChart-DEGOIgRD.js} +3 -3
- package/dist/Gantt/GanttTable/index.js +5 -5
- package/dist/Gantt/{GanttTable-CdXhMHF6.js → GanttTable-Dwb00N8Z.js} +1 -1
- package/dist/Gantt/GanttToolBar/index.js +8 -8
- package/dist/Gantt/{GanttToolBar-C1gAS9v2.js → GanttToolBar-BcJB6sKY.js} +3 -3
- package/dist/Gantt/index.js +11 -11
- package/dist/Gantt/utils/index.js +1 -1
- package/dist/Gantt/utils/theme/index.js +1 -1
- package/dist/Icon/{Icon-oQ_uBooE.js → Icon-DDHx0R18.js} +1 -1
- package/dist/Icon/index.js +2 -2
- package/dist/InputTag/{InputTag-BQpIRPtc.js → InputTag-CBnG1R7g.js} +2 -2
- package/dist/InputTag/index.js +5 -5
- package/dist/Loading/{Loading-CiRe7i2R.js → Loading-DYayeRbT.js} +1 -1
- package/dist/Loading/index.js +4 -4
- package/dist/Modal/{Modal-17rLsxN4.js → Modal-BnF6CUrn.js} +20 -17
- package/dist/Modal/index.js +3 -3
- package/dist/NotFoundContent/index.js +1 -1
- package/dist/Overlay/index.js +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/ScrollBar/index.js +1 -1
- package/dist/Segmented/index.js +1 -1
- package/dist/Select/{Select-p_ly7xmz.js → Select-CG5wFTL4.js} +13 -13
- package/dist/Select/{SelectInputSearch-BBwVIb8u.js → SelectInputSearch-DiuwwOWz.js} +2 -2
- package/dist/Select/index.js +10 -10
- package/dist/Table/{Table-CSPdFGYn.js → Table-B7J-IK2_.js} +1 -1
- package/dist/Table/hooks/index.js +1 -1
- package/dist/Table/index.js +4 -4
- package/dist/Table/style/index.js +1 -1
- package/dist/Table/utils/index.js +1 -1
- package/dist/Tabs/{Tabs-D2A8nJl8.js → Tabs-CObQtF37.js} +7 -7
- package/dist/Tabs/index.js +6 -6
- package/dist/Tooltip/index.js +1 -1
- package/dist/Tree/index.js +4 -4
- package/dist/Tree/utils/index.js +1 -1
- package/dist/components/ColorPicker/ColorPicker.type.d.ts +2 -0
- package/dist/components/ColorPicker/useFloatingColorPicker.d.ts +1 -1
- package/dist/components/DropDown/DropDownOpenContext.d.ts +4 -0
- package/dist/components/DropDown/MenuItem/MenuItem.d.ts +4 -0
- package/dist/components/DropDown/interface.d.ts +5 -1
- package/dist/components/Editor/Preview/EditorPreview.d.ts +9 -0
- package/dist/components/Editor/Preview/HtmlPreview.d.ts +5 -0
- package/dist/components/Editor/Preview/PolishModal.d.ts +14 -0
- package/dist/components/Editor/Preview/Thinking.d.ts +23 -0
- package/dist/components/Editor/Preview/TypesetModal.d.ts +12 -0
- package/dist/components/Editor/ToolbarPlugin/BaseButton/BaseButton.d.ts +5 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/AiButton.d.ts +3 -0
- package/dist/components/Editor/ToolbarPlugin/Buttons/AlignButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/BoldButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/BulletListButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/ClearFormatButton.d.ts +3 -0
- package/dist/components/Editor/ToolbarPlugin/Buttons/CodeButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/FillButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/FontColorButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/FontSizeButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/HeadingButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/IndentButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/ItalicButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/LinkButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/NumberListButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/OutdentButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/PictureButton/PictureButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/PictureButton/UploadImage.d.ts +1 -0
- package/dist/components/Editor/ToolbarPlugin/Buttons/RedoButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/SourceButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/StrikeThroughButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/SubscriptButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/SuperscriptButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/TableButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/UnLinkButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/UnderLineButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/UndoButton.d.ts +2 -1
- package/dist/components/Editor/ToolbarPlugin/Buttons/index.d.ts +26 -23
- package/dist/components/Editor/ToolbarPlugin/Buttons/registry.d.ts +4 -1
- package/dist/components/Editor/ToolbarPlugin/context/TextFormatsContext.d.ts +1 -0
- package/dist/components/Editor/ToolbarPlugin/interface.d.ts +2 -2
- package/dist/components/Editor/constants/ai.d.ts +12 -0
- package/dist/components/Editor/constants/index.d.ts +3 -0
- package/dist/components/Editor/constants/portableEditorStyles.d.ts +11 -0
- package/dist/components/Editor/constants/toolbarSize.d.ts +12 -0
- package/dist/components/Editor/context/EditorContainerContext.d.ts +27 -1
- package/dist/components/Editor/index.d.ts +2 -2
- package/dist/components/Editor/interface.d.ts +60 -13
- package/dist/components/Editor/utils/applyAiPolish.d.ts +8 -0
- package/dist/components/Editor/utils/applyAiTypeset.d.ts +5 -0
- package/dist/components/Editor/utils/clearInlineTextFormat.d.ts +1 -0
- package/dist/components/Editor/utils/computeToolbarOverflowSplit.d.ts +12 -0
- package/dist/components/Editor/utils/extractCodePlaceholders.d.ts +6 -0
- package/dist/components/Editor/utils/formatEditorHtml.d.ts +1 -1
- package/dist/components/Editor/utils/htmlText.d.ts +2 -0
- package/dist/components/Editor/utils/prepareTypesetProposed.d.ts +2 -0
- package/dist/components/Editor/utils/readEditorAiSnapshot.d.ts +9 -0
- package/dist/components/Editor/utils/resolveEditorAlign.d.ts +3 -0
- package/dist/components/Editor/utils/resolveEditorImageUpload.d.ts +8 -0
- package/dist/components/Editor/utils/resolveEditorToolbarThemeVars.d.ts +5 -5
- package/dist/components/Editor/utils/stitchCodePlaceholders.d.ts +6 -0
- package/dist/components/Editor/utils/toPortableEditorHtml.d.ts +1 -0
- package/dist/components/Editor/utils/unwrapTypesetFence.d.ts +5 -0
- package/dist/components/Modal/Modal.type.d.ts +1 -0
- package/dist/hooks/useFloatingPortal.d.ts +2 -0
- package/dist/index.js +24 -24
- package/dist/locale/lang/en-US.json.d.ts +22 -2
- package/dist/locale/lang/zh-CN.json.d.ts +22 -2
- package/dist/locale/lang/zh-TW.json.d.ts +22 -2
- package/dist/style.css +1 -1
- package/dist/vendors/{ConfigProvider-4xHyyeop.js → ConfigProvider-BDyxjj6K.js} +45 -5
- package/dist/vendors/{LocaleContext-I4PW9j4M.js → LocaleContext-w5ODGcJX.js} +22 -2
- package/dist/vendors/{Tree-B8cR9y6U.js → Tree-B7XeC9Mi.js} +2 -2
- package/dist/vendors/{useFloatingPortal-CmVJbuRm.js → useFloatingPortal-B3N1viK2.js} +8 -7
- package/dist/vendors/{useLocale-FGYsRWSe.js → useLocale-CEDl6cUK.js} +1 -1
- package/dist/vendors/{version-CJyzNHuS.js → version-B14EcH7v.js} +1 -1
- package/package.json +2 -3
- package/dist/DropDown/DropDown-CuL1Qq25.js +0 -178
- package/dist/Editor/Buttons-CMkFTv6y.js +0 -1016
package/dist/Editor/index.js
CHANGED
|
@@ -1,64 +1,311 @@
|
|
|
1
|
-
import "../vendors/version-
|
|
1
|
+
import "../vendors/version-B14EcH7v.js";
|
|
2
2
|
import "../ScrollBar/style-D26azwz6.js";
|
|
3
|
-
import { t as e } from "../Icon/Icon-
|
|
4
|
-
import "../vendors/LocaleContext-
|
|
3
|
+
import { t as e } from "../Icon/Icon-DDHx0R18.js";
|
|
4
|
+
import "../vendors/LocaleContext-w5ODGcJX.js";
|
|
5
5
|
import "../Overlay/OverlayContext-CVSFoyqN.js";
|
|
6
|
-
import "../Modal/Modal-
|
|
7
|
-
import "../ColorPicker/ColorPicker-
|
|
6
|
+
import { t } from "../Modal/Modal-BnF6CUrn.js";
|
|
7
|
+
import "../ColorPicker/ColorPicker-Cm_-e0Hz.js";
|
|
8
8
|
import "../vendors/useFloatingOverlay-B3M9k8nj.js";
|
|
9
|
-
import { t } from "../vendors/useLocale-
|
|
9
|
+
import { t as n } from "../vendors/useLocale-CEDl6cUK.js";
|
|
10
10
|
import "../vendors/useLatchedPopupPortalRoot-4fVhqVT4.js";
|
|
11
|
-
import { t as
|
|
12
|
-
import "../Select/SelectInputSearch-
|
|
13
|
-
import "../CheckBox/CheckBox-
|
|
14
|
-
import "../CheckBox/CheckBox-
|
|
11
|
+
import { t as r } from "../vendors/cssVars-l4-kP_14.js";
|
|
12
|
+
import "../Select/SelectInputSearch-DiuwwOWz.js";
|
|
13
|
+
import "../CheckBox/CheckBox-DFfNiPGM.js";
|
|
14
|
+
import "../CheckBox/CheckBox-CwfrMEFb.js";
|
|
15
15
|
import "../NotFoundContent/NotFoundContent-BLmzWNBi.js";
|
|
16
|
-
import "../ScrollBar/ScrollBar-N2pOLv-8.js";
|
|
17
|
-
import "../vendors/useFloatingPortal-
|
|
18
|
-
import { t as
|
|
16
|
+
import { t as i } from "../ScrollBar/ScrollBar-N2pOLv-8.js";
|
|
17
|
+
import "../vendors/useFloatingPortal-B3N1viK2.js";
|
|
18
|
+
import { t as a } from "../DropDown/DropDown-DV1IuuQD.js";
|
|
19
19
|
import "../DropDown/style-LLDVPpPa.js";
|
|
20
|
-
import { _ as
|
|
21
|
-
import { DEFAULT_BACKGROUND_COLOR as
|
|
22
|
-
import { omit as
|
|
23
|
-
import { Fragment as
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import { $
|
|
37
|
-
import {
|
|
38
|
-
import { $
|
|
39
|
-
import { $
|
|
40
|
-
import { $
|
|
41
|
-
import { $
|
|
42
|
-
import { $
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import
|
|
20
|
+
import { A as o, B as s, C as c, D as l, E as u, F as d, I as f, L as p, M as m, N as h, O as g, P as _, R as v, S as y, T as b, _ as x, a as S, b as C, c as w, d as T, f as E, g as D, h as O, i as k, j as A, k as ee, l as te, m as ne, n as re, o as j, p as ie, r as ae, s as oe, u as se, v as ce, w as le, x as ue, y as M, z as de } from "./Buttons-BUC9qQY1.js";
|
|
21
|
+
import { DEFAULT_BACKGROUND_COLOR as fe, DEFAULT_FONT_COLOR as pe, DEFAULT_FONT_SIZE as me } from "./constants/index.js";
|
|
22
|
+
import { dropRightWhile as he, dropWhile as ge, omit as _e } from "lodash-es";
|
|
23
|
+
import { Fragment as ve, jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
24
|
+
import ye, { forwardRef as be, memo as xe, useCallback as F, useDeferredValue as Se, useEffect as I, useId as Ce, useLayoutEffect as we, useMemo as L, useRef as R, useState as z } from "react";
|
|
25
|
+
import { Button as Te, message as Ee } from "antd";
|
|
26
|
+
import B from "clsx";
|
|
27
|
+
import { useDocumentVisibility as De, useEventListener as Oe } from "ahooks";
|
|
28
|
+
import { AnimatePresence as ke, motion as Ae, useReducedMotion as je } from "motion/react";
|
|
29
|
+
import { LexicalComposer as Me } from "@lexical/react/LexicalComposer";
|
|
30
|
+
import { RichTextPlugin as Ne } from "@lexical/react/LexicalRichTextPlugin";
|
|
31
|
+
import { ContentEditable as Pe } from "@lexical/react/LexicalContentEditable";
|
|
32
|
+
import { HistoryPlugin as Fe } from "@lexical/react/LexicalHistoryPlugin";
|
|
33
|
+
import { OnChangePlugin as Ie } from "@lexical/react/LexicalOnChangePlugin";
|
|
34
|
+
import { LexicalErrorBoundary as Le } from "@lexical/react/LexicalErrorBoundary";
|
|
35
|
+
import { $generateHtmlFromNodes as Re, $generateNodesFromDOM as ze } from "@lexical/html";
|
|
36
|
+
import { $applyNodeReplacement as Be, $createLineBreakNode as Ve, $createParagraphNode as He, $createTabNode as Ue, $createTextNode as We, $getNearestNodeFromDOMNode as Ge, $getNodeByKey as V, $getRoot as Ke, $getRoot as H, $getSelection as U, $insertNodes as qe, $isElementNode as Je, $isLineBreakNode as Ye, $isRangeSelection as W, $isRootOrShadowRoot as Xe, $isTabNode as Ze, $isTextNode as Qe, $nodesOfType as $e, $onUpdate as et, $setSelection as tt, CLEAR_HISTORY_COMMAND as nt, COMMAND_PRIORITY_CRITICAL as rt, COMMAND_PRIORITY_EDITOR as it, COMMAND_PRIORITY_HIGH as at, COMMAND_PRIORITY_LOW as ot, DROP_COMMAND as st, DecoratorNode as ct, HISTORY_MERGE_TAG as lt, INDENT_CONTENT_COMMAND as ut, KEY_ENTER_COMMAND as dt, KEY_TAB_COMMAND as ft, PASTE_COMMAND as pt, PASTE_TAG as mt, RootNode as ht, TextNode as gt, isHTMLElement as _t, mergeRegister as vt } from "lexical";
|
|
37
|
+
import { useLexicalComposerContext as yt, useLexicalComposerContext as G } from "@lexical/react/LexicalComposerContext";
|
|
38
|
+
import { $getSelectionStyleValueForProperty as bt, $patchStyleText as xt, $trimTextContentFromAnchor as St } from "@lexical/selection";
|
|
39
|
+
import { $findMatchingParent as K, $restoreEditorState as Ct, mergeRegister as wt } from "@lexical/utils";
|
|
40
|
+
import { $isLinkNode as Tt, AutoLinkNode as Et, LinkNode as Dt } from "@lexical/link";
|
|
41
|
+
import { $isListItemNode as q, $isListNode as Ot, ListItemNode as kt, ListNode as At } from "@lexical/list";
|
|
42
|
+
import { $createCodeHighlightNode as jt, $createCodeNode as Mt, $isCodeHighlightNode as Nt, $isCodeNode as J, $plainifyCodeContent as Pt, CodeHighlightNode as Ft, CodeNode as It, registerCodeIndentation as Lt } from "@lexical/code-core";
|
|
43
|
+
import { $findCellNode as Rt, $isTableCellNode as zt, $isTableNode as Bt, $isTableRowNode as Vt, $isTableSelection as Ht, TableCellNode as Ut, TableNode as Wt, TableRowNode as Gt, registerTableCellUnmergeTransform as Kt, registerTablePlugin as qt, registerTableSelectionObserver as Jt, setScrollableTablesActive as Yt } from "@lexical/table";
|
|
44
|
+
import { $isHeadingNode as Xt, HeadingNode as Zt } from "@lexical/rich-text";
|
|
45
|
+
import { useLexicalEditable as Qt } from "@lexical/react/useLexicalEditable";
|
|
46
|
+
import { LinkPlugin as $t } from "@lexical/react/LexicalLinkPlugin";
|
|
47
|
+
import { ListPlugin as en } from "@lexical/react/LexicalListPlugin";
|
|
48
|
+
var Y = {
|
|
49
|
+
imageWrapper: "_imageWrapper_y06h3_1",
|
|
50
|
+
selected: "_selected_y06h3_8",
|
|
51
|
+
resizing: "_resizing_y06h3_12",
|
|
52
|
+
image: "_image_y06h3_1",
|
|
53
|
+
resizeHandle: "_resizeHandle_y06h3_30",
|
|
54
|
+
topLeft: "_topLeft_y06h3_44",
|
|
55
|
+
topRight: "_topRight_y06h3_49",
|
|
56
|
+
bottomLeft: "_bottomLeft_y06h3_54",
|
|
57
|
+
bottomRight: "_bottomRight_y06h3_59"
|
|
58
|
+
}, tn = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
|
|
59
|
+
let [a] = G(), [o, s] = z(!1), [c, l] = z(null), u = R(null), [d, f] = z({
|
|
60
|
+
width: n || void 0,
|
|
61
|
+
height: r || void 0
|
|
62
|
+
}), p = F(() => {
|
|
63
|
+
n && r && f({
|
|
64
|
+
width: n,
|
|
65
|
+
height: r
|
|
66
|
+
});
|
|
67
|
+
}, [n, r]), m = F((e, t) => {
|
|
68
|
+
if (e.preventDefault(), e.stopPropagation(), !u.current) return;
|
|
69
|
+
let n = d.width || u.current.offsetWidth, r = d.height || u.current.offsetHeight, i = n / r;
|
|
70
|
+
(!d.width || !d.height) && f({
|
|
71
|
+
width: n,
|
|
72
|
+
height: r
|
|
73
|
+
}), l({
|
|
74
|
+
isResizing: !0,
|
|
75
|
+
startX: e.clientX,
|
|
76
|
+
startY: e.clientY,
|
|
77
|
+
startWidth: n,
|
|
78
|
+
startHeight: r,
|
|
79
|
+
aspectRatio: i,
|
|
80
|
+
direction: t
|
|
81
|
+
});
|
|
82
|
+
}, [d]), h = F((e) => {
|
|
83
|
+
if (!c?.isResizing) return;
|
|
84
|
+
let t = e.clientX - c.startX, n;
|
|
85
|
+
switch (c.direction) {
|
|
86
|
+
case "bottom-right":
|
|
87
|
+
n = Math.max(50, c.startWidth + t);
|
|
88
|
+
break;
|
|
89
|
+
case "bottom-left":
|
|
90
|
+
n = Math.max(50, c.startWidth - t);
|
|
91
|
+
break;
|
|
92
|
+
case "top-right":
|
|
93
|
+
n = Math.max(50, c.startWidth + t);
|
|
94
|
+
break;
|
|
95
|
+
case "top-left":
|
|
96
|
+
n = Math.max(50, c.startWidth - t);
|
|
97
|
+
break;
|
|
98
|
+
default: n = Math.max(50, c.startWidth + t);
|
|
99
|
+
}
|
|
100
|
+
let r = n / c.aspectRatio;
|
|
101
|
+
f({
|
|
102
|
+
width: n,
|
|
103
|
+
height: r
|
|
104
|
+
});
|
|
105
|
+
}, [c]), g = F(() => {
|
|
106
|
+
c?.isResizing && (a.update(() => {
|
|
107
|
+
let e = V(i);
|
|
108
|
+
an(e) && e.setWidthAndHeight(d.width, d.height);
|
|
109
|
+
}), l(null));
|
|
110
|
+
}, [
|
|
111
|
+
a,
|
|
112
|
+
i,
|
|
113
|
+
d,
|
|
114
|
+
c
|
|
115
|
+
]);
|
|
116
|
+
ye.useEffect(() => {
|
|
117
|
+
if (c?.isResizing) return document.addEventListener("mousemove", h), document.addEventListener("mouseup", g), () => {
|
|
118
|
+
document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", g);
|
|
119
|
+
};
|
|
120
|
+
}, [
|
|
121
|
+
c,
|
|
122
|
+
h,
|
|
123
|
+
g
|
|
124
|
+
]);
|
|
125
|
+
let _ = F(() => {
|
|
126
|
+
s(!0);
|
|
127
|
+
}, []);
|
|
128
|
+
return I(() => a.registerUpdateListener(({ editorState: e }) => {
|
|
129
|
+
e.read(() => {
|
|
130
|
+
let e = U();
|
|
131
|
+
W(e) && !e.getNodes().some((e) => e.getKey() === i || e.getParent() && e.getParent()?.getKey() === i) && o && s(!1);
|
|
132
|
+
});
|
|
133
|
+
}), [
|
|
134
|
+
a,
|
|
135
|
+
i,
|
|
136
|
+
o
|
|
137
|
+
]), I(() => {
|
|
138
|
+
let e = (e) => {
|
|
139
|
+
o && u.current && !u.current.contains(e.target) && s(!1);
|
|
140
|
+
};
|
|
141
|
+
if (o) return document.addEventListener("mousedown", e), () => {
|
|
142
|
+
document.removeEventListener("mousedown", e);
|
|
143
|
+
};
|
|
144
|
+
}, [o]), /* @__PURE__ */ P("div", {
|
|
145
|
+
className: B(Y.imageWrapper, {
|
|
146
|
+
[Y.selected]: o,
|
|
147
|
+
[Y.resizing]: c?.isResizing
|
|
148
|
+
}),
|
|
149
|
+
children: [/* @__PURE__ */ N("img", {
|
|
150
|
+
ref: u,
|
|
151
|
+
src: e,
|
|
152
|
+
alt: t,
|
|
153
|
+
className: Y.image,
|
|
154
|
+
style: {
|
|
155
|
+
width: d.width,
|
|
156
|
+
height: d.height
|
|
157
|
+
},
|
|
158
|
+
onLoad: p,
|
|
159
|
+
onClick: _,
|
|
160
|
+
draggable: !1
|
|
161
|
+
}), o && /* @__PURE__ */ P(ve, { children: [
|
|
162
|
+
/* @__PURE__ */ N("div", {
|
|
163
|
+
className: B(Y.resizeHandle, Y.bottomRight),
|
|
164
|
+
onMouseDown: (e) => m(e, "bottom-right")
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ N("div", {
|
|
167
|
+
className: B(Y.resizeHandle, Y.bottomLeft),
|
|
168
|
+
onMouseDown: (e) => m(e, "bottom-left")
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ N("div", {
|
|
171
|
+
className: B(Y.resizeHandle, Y.topRight),
|
|
172
|
+
onMouseDown: (e) => m(e, "top-right")
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ N("div", {
|
|
175
|
+
className: B(Y.resizeHandle, Y.topLeft),
|
|
176
|
+
onMouseDown: (e) => m(e, "top-left")
|
|
177
|
+
})
|
|
178
|
+
] })]
|
|
179
|
+
});
|
|
180
|
+
}, nn = class e extends ct {
|
|
181
|
+
static getType() {
|
|
182
|
+
return "image";
|
|
183
|
+
}
|
|
184
|
+
static clone(t) {
|
|
185
|
+
return new e(t.__src, t.__altText, t.__width, t.__height, t.__key);
|
|
186
|
+
}
|
|
187
|
+
constructor(e, t, n, r, i) {
|
|
188
|
+
super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r;
|
|
189
|
+
}
|
|
190
|
+
createDOM() {
|
|
191
|
+
let e = document.createElement("div");
|
|
192
|
+
return e.style.display = "inline-block", e;
|
|
193
|
+
}
|
|
194
|
+
updateDOM() {
|
|
195
|
+
return !1;
|
|
196
|
+
}
|
|
197
|
+
exportDOM() {
|
|
198
|
+
let e = document.createElement("img");
|
|
199
|
+
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()), { element: e };
|
|
200
|
+
}
|
|
201
|
+
getSrc() {
|
|
202
|
+
return this.__src;
|
|
203
|
+
}
|
|
204
|
+
getAltText() {
|
|
205
|
+
return this.__altText;
|
|
206
|
+
}
|
|
207
|
+
getWidth() {
|
|
208
|
+
return this.__width;
|
|
209
|
+
}
|
|
210
|
+
getHeight() {
|
|
211
|
+
return this.__height;
|
|
212
|
+
}
|
|
213
|
+
setSrc(e) {
|
|
214
|
+
let t = this.getWritable();
|
|
215
|
+
t.__src = e;
|
|
216
|
+
}
|
|
217
|
+
setAltText(e) {
|
|
218
|
+
let t = this.getWritable();
|
|
219
|
+
t.__altText = e;
|
|
220
|
+
}
|
|
221
|
+
setWidthAndHeight(e, t) {
|
|
222
|
+
let n = this.getWritable();
|
|
223
|
+
n.__width = e, n.__height = t;
|
|
224
|
+
}
|
|
225
|
+
decorate() {
|
|
226
|
+
return /* @__PURE__ */ N(tn, {
|
|
227
|
+
src: this.__src,
|
|
228
|
+
altText: this.__altText,
|
|
229
|
+
width: this.__width,
|
|
230
|
+
height: this.__height,
|
|
231
|
+
nodeKey: this.getKey()
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
static importDOM() {
|
|
235
|
+
return { img: () => ({
|
|
236
|
+
conversion: on,
|
|
237
|
+
priority: 0
|
|
238
|
+
}) };
|
|
239
|
+
}
|
|
240
|
+
static importJSON(e) {
|
|
241
|
+
let { src: t, altText: n, width: r, height: i } = e;
|
|
242
|
+
return rn({
|
|
243
|
+
src: t,
|
|
244
|
+
altText: n,
|
|
245
|
+
width: r,
|
|
246
|
+
height: i
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
exportJSON() {
|
|
250
|
+
return {
|
|
251
|
+
src: this.getSrc(),
|
|
252
|
+
altText: this.getAltText(),
|
|
253
|
+
width: this.getWidth(),
|
|
254
|
+
height: this.getHeight(),
|
|
255
|
+
type: "image",
|
|
256
|
+
version: 1
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
isInline() {
|
|
260
|
+
return !0;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
function rn({ src: e, altText: t, width: n, height: r, key: i }) {
|
|
264
|
+
return new nn(e, t, n, r, i);
|
|
265
|
+
}
|
|
266
|
+
function an(e) {
|
|
267
|
+
return e instanceof nn;
|
|
268
|
+
}
|
|
269
|
+
function on(e) {
|
|
270
|
+
if (e instanceof HTMLImageElement) {
|
|
271
|
+
let { src: t, alt: n, style: r } = e, i, a;
|
|
272
|
+
if (r.width) {
|
|
273
|
+
let e = parseInt(r.width, 10);
|
|
274
|
+
isNaN(e) || (i = e);
|
|
275
|
+
}
|
|
276
|
+
if (r.height) {
|
|
277
|
+
let e = parseInt(r.height, 10);
|
|
278
|
+
isNaN(e) || (a = e);
|
|
279
|
+
}
|
|
280
|
+
return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: rn({
|
|
281
|
+
src: t,
|
|
282
|
+
altText: n,
|
|
283
|
+
width: i,
|
|
284
|
+
height: a
|
|
285
|
+
}) };
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
47
290
|
//#region src/components/Editor/utils/resolveEditorToolbarThemeVars.ts
|
|
48
|
-
var
|
|
291
|
+
var X = (e) => {
|
|
49
292
|
if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
293
|
+
}, sn = (e, t = v) => {
|
|
294
|
+
let n = s[t], i = X(e?.itemHeight) ?? `${n.itemHeight}px`, a = X(e?.iconSize) ?? `${n.iconSize}px`, o = {
|
|
295
|
+
"--bsy-editor-toolbar-item-height": i,
|
|
296
|
+
"--bsy-editor-toolbar-icon-size": a,
|
|
297
|
+
"--bsy-editor-toolbar-divider-color": "#e0e0e0",
|
|
298
|
+
"--bsy-editor-toolbar-item-highlight-color": "#0265ff"
|
|
299
|
+
};
|
|
300
|
+
return e ? (r(o, "--bsy-editor-toolbar-bg", e.bg), r(o, "--bsy-editor-toolbar-border-color", e.borderColor), r(o, "--bsy-editor-toolbar-padding", e.padding), r(o, "--bsy-editor-toolbar-gap", X(e.gap)), r(o, "--bsy-editor-toolbar-group-gap", X(e.groupGap)), r(o, "--bsy-editor-toolbar-divider-color", e.dividerColor), r(o, "--bsy-editor-toolbar-divider-margin", X(e.dividerMargin)), r(o, "--bsy-editor-toolbar-color-icon", e.colorIcon), r(o, "--bsy-editor-toolbar-item-hover-bg", e.itemHoverBg), r(o, "--bsy-editor-toolbar-item-hover-color", e.itemHoverColor), r(o, "--bsy-editor-toolbar-item-active-bg", e.itemActiveBg), r(o, "--bsy-editor-toolbar-item-active-color", e.itemActiveColor), r(o, "--bsy-editor-toolbar-item-highlight-color", e.itemHighlightColor), r(o, "--bsy-editor-toolbar-item-padding", X(e.itemPadding)), r(o, "--bsy-editor-toolbar-item-border-radius", X(e.itemBorderRadius)), o) : o;
|
|
301
|
+
}, cn = (e, t = v) => {
|
|
55
302
|
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
56
303
|
if (typeof e == "string") {
|
|
57
304
|
let t = Number.parseFloat(e);
|
|
58
305
|
if (Number.isFinite(t)) return t;
|
|
59
306
|
}
|
|
60
|
-
return
|
|
61
|
-
},
|
|
307
|
+
return s[t].iconSize;
|
|
308
|
+
}, ln = (e) => {
|
|
62
309
|
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 = {
|
|
63
310
|
position: "absolute",
|
|
64
311
|
[a ? "bottom" : "top"]: "100%",
|
|
@@ -68,59 +315,77 @@ var J = (e) => {
|
|
|
68
315
|
width: "100%"
|
|
69
316
|
};
|
|
70
317
|
return r && (o.transform = `translateX(${r}px)`), o;
|
|
318
|
+
}, un = (e, t, n, r) => {
|
|
319
|
+
if (e.length === 0 || t <= 0 || e.reduce((e, t, n) => e + t.width + (n > 0 ? r : 0), 0) <= t) return e.length;
|
|
320
|
+
let i = 0, a = 0;
|
|
321
|
+
for (let o = 0; o < e.length; o++) {
|
|
322
|
+
let s = i + (a > 0 ? r : 0) + e[o].width;
|
|
323
|
+
if (s + r + n > t) break;
|
|
324
|
+
i = s, a += 1;
|
|
325
|
+
}
|
|
326
|
+
for (; a > 0 && e[a - 1]?.isDivider;) --a;
|
|
327
|
+
return a;
|
|
328
|
+
}, dn = (e, t) => {
|
|
329
|
+
let n = (e) => e.kind === "divider";
|
|
330
|
+
return {
|
|
331
|
+
visible: e.slice(0, t),
|
|
332
|
+
overflow: he(ge(e.slice(t), n), n)
|
|
333
|
+
};
|
|
71
334
|
};
|
|
72
335
|
//#endregion
|
|
73
336
|
//#region src/components/Editor/hooks/useTextFormatsState.ts
|
|
74
|
-
function
|
|
75
|
-
let [e] =
|
|
337
|
+
function fn() {
|
|
338
|
+
let [e] = G(), [t, n] = z({
|
|
76
339
|
bold: !1,
|
|
77
340
|
italic: !1,
|
|
78
341
|
underline: !1,
|
|
79
342
|
strikethrough: !1,
|
|
80
343
|
superscript: !1,
|
|
81
344
|
subscript: !1,
|
|
82
|
-
fontSize:
|
|
83
|
-
fontColor:
|
|
84
|
-
backgroundColor:
|
|
345
|
+
fontSize: me,
|
|
346
|
+
fontColor: pe,
|
|
347
|
+
backgroundColor: fe,
|
|
85
348
|
align: "left",
|
|
86
349
|
listType: !1,
|
|
87
350
|
canOutdent: !1,
|
|
88
351
|
isCodeBlock: !1,
|
|
89
352
|
isInTable: !1,
|
|
90
353
|
headingTag: !1,
|
|
91
|
-
codeLanguage:
|
|
354
|
+
codeLanguage: _,
|
|
355
|
+
hasEditorText: !1,
|
|
92
356
|
link: void 0
|
|
93
357
|
});
|
|
94
|
-
return
|
|
358
|
+
return I(() => e.registerUpdateListener(({ editorState: e }) => {
|
|
95
359
|
e.read(() => {
|
|
96
|
-
let e =
|
|
97
|
-
if (
|
|
360
|
+
let e = U(), t = !!H().getTextContent().trim();
|
|
361
|
+
if (Ht(e)) {
|
|
98
362
|
n((e) => ({
|
|
99
363
|
...e,
|
|
100
364
|
isCodeBlock: !1,
|
|
101
365
|
isInTable: !0,
|
|
102
|
-
headingTag: !1
|
|
366
|
+
headingTag: !1,
|
|
367
|
+
hasEditorText: t
|
|
103
368
|
}));
|
|
104
369
|
return;
|
|
105
370
|
}
|
|
106
|
-
if (
|
|
107
|
-
let
|
|
371
|
+
if (W(e)) {
|
|
372
|
+
let r = bt(e, "font-size", me), i = bt(e, "color", pe), a = bt(e, "background-color", fe), s = e.anchor.getNode(), c = s.getKey() === "root" ? s : K(s, (e) => {
|
|
108
373
|
let t = e.getParent();
|
|
109
|
-
return t !== null &&
|
|
374
|
+
return t !== null && Xe(t);
|
|
110
375
|
});
|
|
111
|
-
|
|
112
|
-
let
|
|
113
|
-
|
|
114
|
-
let
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
let e =
|
|
118
|
-
if (
|
|
376
|
+
c === null && (c = s.getTopLevelElementOrThrow());
|
|
377
|
+
let l = {}, u = K(s, Tt);
|
|
378
|
+
u ? (l.link = u.getURL(), l.linkText = u.getTextContent(), l.newBlank = u.getTarget() === "_blank") : l.linkText = e.getTextContent();
|
|
379
|
+
let f = K(s, q), p = !1, m = Je(c) ? c.getIndent() : 0;
|
|
380
|
+
if (q(f)) {
|
|
381
|
+
m = f.getIndent();
|
|
382
|
+
let e = f.getParent();
|
|
383
|
+
if (Ot(e)) {
|
|
119
384
|
let t = e.getListType();
|
|
120
|
-
|
|
385
|
+
p = t === "number" || t === "bullet" ? t : !1;
|
|
121
386
|
}
|
|
122
387
|
}
|
|
123
|
-
let
|
|
388
|
+
let h = K(s, J), g = K(s, Xt), _ = Xt(g) ? g.getTag() : void 0;
|
|
124
389
|
n({
|
|
125
390
|
bold: e.hasFormat("bold"),
|
|
126
391
|
italic: e.hasFormat("italic"),
|
|
@@ -128,71 +393,72 @@ function Dt() {
|
|
|
128
393
|
strikethrough: e.hasFormat("strikethrough"),
|
|
129
394
|
superscript: e.hasFormat("superscript"),
|
|
130
395
|
subscript: e.hasFormat("subscript"),
|
|
131
|
-
fontSize:
|
|
132
|
-
fontColor:
|
|
133
|
-
backgroundColor:
|
|
134
|
-
align:
|
|
135
|
-
listType:
|
|
136
|
-
canOutdent:
|
|
137
|
-
isCodeBlock: !!
|
|
138
|
-
isInTable: !!
|
|
139
|
-
headingTag:
|
|
140
|
-
codeLanguage:
|
|
141
|
-
|
|
396
|
+
fontSize: r,
|
|
397
|
+
fontColor: i,
|
|
398
|
+
backgroundColor: a,
|
|
399
|
+
align: o(Je(c) ? c.getFormatType() : ""),
|
|
400
|
+
listType: p,
|
|
401
|
+
canOutdent: m > 0 || p !== !1,
|
|
402
|
+
isCodeBlock: !!h,
|
|
403
|
+
isInTable: !!K(s, zt),
|
|
404
|
+
headingTag: _ === "h1" || _ === "h2" || _ === "h3" ? _ : !1,
|
|
405
|
+
codeLanguage: d(h?.getLanguage()),
|
|
406
|
+
hasEditorText: t,
|
|
407
|
+
link: l
|
|
142
408
|
});
|
|
143
|
-
}
|
|
409
|
+
} else n((e) => ({
|
|
410
|
+
...e,
|
|
411
|
+
hasEditorText: t
|
|
412
|
+
}));
|
|
144
413
|
});
|
|
145
414
|
}), [e]), t;
|
|
146
415
|
}
|
|
147
416
|
//#endregion
|
|
148
417
|
//#region src/components/Editor/ToolbarPlugin/context/TextFormatProvider.tsx
|
|
149
|
-
var
|
|
150
|
-
let t =
|
|
151
|
-
return /* @__PURE__ */
|
|
418
|
+
var pn = (e) => {
|
|
419
|
+
let t = fn();
|
|
420
|
+
return /* @__PURE__ */ N(f.Provider, {
|
|
152
421
|
value: t,
|
|
153
422
|
children: e.children
|
|
154
423
|
});
|
|
155
|
-
},
|
|
156
|
-
let e = se(kt);
|
|
157
|
-
if (!e) throw Error("useEditorContainer must be used within EditorContainerProvider");
|
|
158
|
-
return e;
|
|
159
|
-
}, jt = d.map((e) => ({
|
|
424
|
+
}, mn = m.map((e) => ({
|
|
160
425
|
key: e.id,
|
|
161
426
|
label: e.label
|
|
162
|
-
})),
|
|
163
|
-
let [
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
let e =
|
|
167
|
-
|
|
427
|
+
})), hn = () => {
|
|
428
|
+
let [t] = G(), { codeLanguage: r } = b(), { t: i } = n(), { iconSize: o } = g(), s = F((e) => {
|
|
429
|
+
let n = e.key;
|
|
430
|
+
t.update(() => {
|
|
431
|
+
let e = U();
|
|
432
|
+
W(e) && K(e.anchor.getNode(), J)?.setLanguage(n);
|
|
168
433
|
});
|
|
169
|
-
}, [
|
|
170
|
-
return /* @__PURE__ */
|
|
171
|
-
menus:
|
|
172
|
-
onClick:
|
|
173
|
-
activeKey: [
|
|
434
|
+
}, [t]), c = h[r].label;
|
|
435
|
+
return /* @__PURE__ */ N(a, {
|
|
436
|
+
menus: mn,
|
|
437
|
+
onClick: s,
|
|
438
|
+
activeKey: [r],
|
|
174
439
|
showSearch: !1,
|
|
440
|
+
offset: de,
|
|
175
441
|
style: {
|
|
176
442
|
width: 120,
|
|
177
443
|
minWidth: 120
|
|
178
444
|
},
|
|
179
|
-
children: /* @__PURE__ */
|
|
180
|
-
className:
|
|
445
|
+
children: /* @__PURE__ */ N("div", {
|
|
446
|
+
className: p["bsy-lexical__toolbar-select"],
|
|
181
447
|
style: { width: 120 },
|
|
182
|
-
children: /* @__PURE__ */
|
|
183
|
-
icon: /* @__PURE__ */
|
|
184
|
-
className:
|
|
185
|
-
children:
|
|
186
|
-
}), /* @__PURE__ */
|
|
448
|
+
children: /* @__PURE__ */ N(u, {
|
|
449
|
+
icon: /* @__PURE__ */ P(ve, { children: [/* @__PURE__ */ N("span", {
|
|
450
|
+
className: p["bsy-lexical__toolbar-select-label"],
|
|
451
|
+
children: c
|
|
452
|
+
}), /* @__PURE__ */ N(e, {
|
|
187
453
|
name: "arrow-down",
|
|
188
|
-
size:
|
|
189
|
-
className:
|
|
454
|
+
size: o,
|
|
455
|
+
className: p["bsy-lexical__toolbar-select-arrow"]
|
|
190
456
|
})] }),
|
|
191
|
-
tooltip:
|
|
457
|
+
tooltip: i("editor.codeLanguage")
|
|
192
458
|
})
|
|
193
459
|
})
|
|
194
460
|
});
|
|
195
|
-
},
|
|
461
|
+
}, gn = {
|
|
196
462
|
initial: {
|
|
197
463
|
opacity: 0,
|
|
198
464
|
x: 6
|
|
@@ -205,7 +471,7 @@ var Ot = (e) => {
|
|
|
205
471
|
opacity: 0,
|
|
206
472
|
x: -6
|
|
207
473
|
}
|
|
208
|
-
},
|
|
474
|
+
}, _n = (e, t, n) => {
|
|
209
475
|
if (n) return [
|
|
210
476
|
{
|
|
211
477
|
kind: "button",
|
|
@@ -251,7 +517,7 @@ var Ot = (e) => {
|
|
|
251
517
|
let r = [];
|
|
252
518
|
return e.forEach((t, n) => {
|
|
253
519
|
t.buttons.forEach((e) => {
|
|
254
|
-
let t =
|
|
520
|
+
let t = typeof e == "string" ? e : e.name;
|
|
255
521
|
r.push({
|
|
256
522
|
kind: "button",
|
|
257
523
|
key: t,
|
|
@@ -263,461 +529,321 @@ var Ot = (e) => {
|
|
|
263
529
|
key: `divider-${t.key}`
|
|
264
530
|
});
|
|
265
531
|
}), r;
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
532
|
+
}, vn = (e) => {
|
|
533
|
+
if (e.kind === "divider") return /* @__PURE__ */ N("div", { className: p["bsy-lexical__toolbar-divider"] });
|
|
534
|
+
if (e.kind === "language") return /* @__PURE__ */ N(hn, {});
|
|
535
|
+
let t = re(e.name);
|
|
536
|
+
return t ? /* @__PURE__ */ N(t, { ...e.props }) : (console.warn(`[ToolbarPlugin] Button "${e.name}" is not registered.`), null);
|
|
537
|
+
}, yn = be(function({ item: e, motionProps: t, transition: n }, r) {
|
|
538
|
+
let i = vn(e);
|
|
539
|
+
return i === null ? null : /* @__PURE__ */ N(Ae.div, {
|
|
540
|
+
ref: r,
|
|
541
|
+
"data-toolbar-item-key": e.key,
|
|
542
|
+
className: B(p["bsy-lexical__toolbar-item"], e.kind === "button" && e.props?.disabled && p["bsy-lexical__toolbar-item--disabled"]),
|
|
543
|
+
layout: "position",
|
|
544
|
+
transition: n,
|
|
545
|
+
...t,
|
|
546
|
+
children: i
|
|
547
|
+
}, e.key);
|
|
548
|
+
}), bn = ({ config: e, sizeToken: t }) => {
|
|
549
|
+
let { isCodeBlock: r } = b(), { isSourceMode: i } = M(), a = je(), o = L(() => _n(e, r, i), [
|
|
550
|
+
e,
|
|
551
|
+
r,
|
|
552
|
+
i
|
|
553
|
+
]), s = o.map((e) => e.key).join("|"), { t: c } = n(), l = R(null), d = R({}), f = R(null), m = R(!0), [h, g] = z({
|
|
554
|
+
keys: s,
|
|
555
|
+
count: o.length
|
|
287
556
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
ease: "easeOut"
|
|
292
|
-
}, f = D(() => wt(r), [r]), p = D(() => ({ iconSize: Tt(r?.iconSize) }), [r?.iconSize]), m = l ? Et(a) : void 0, h = l ? re(n, [
|
|
293
|
-
"position",
|
|
294
|
-
"left",
|
|
295
|
-
"top",
|
|
296
|
-
"right",
|
|
297
|
-
"bottom",
|
|
298
|
-
"inset",
|
|
299
|
-
"transform",
|
|
300
|
-
"marginTop",
|
|
301
|
-
"marginBottom"
|
|
302
|
-
]) : n;
|
|
303
|
-
return /* @__PURE__ */ C(c, {
|
|
304
|
-
value: p,
|
|
305
|
-
children: /* @__PURE__ */ C(_, { children: /* @__PURE__ */ C(Ot, { children: /* @__PURE__ */ C(le.div, {
|
|
306
|
-
ref: s,
|
|
307
|
-
layout: !u,
|
|
308
|
-
transition: d,
|
|
309
|
-
className: A(o["bsy-lexical__toolbar"], l && o["bsy-lexical__toolbar--floating"]),
|
|
310
|
-
style: {
|
|
311
|
-
...f,
|
|
312
|
-
...m,
|
|
313
|
-
...h
|
|
314
|
-
},
|
|
315
|
-
children: /* @__PURE__ */ C(Lt, { config: t })
|
|
316
|
-
}) }) })
|
|
557
|
+
h.keys !== s && g({
|
|
558
|
+
keys: s,
|
|
559
|
+
count: o.length
|
|
317
560
|
});
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
static clone(t) {
|
|
334
|
-
return new e(t.__text, t.__key);
|
|
335
|
-
}
|
|
336
|
-
static importDOM() {
|
|
337
|
-
let e = L.importDOM();
|
|
338
|
-
return {
|
|
339
|
-
...e,
|
|
340
|
-
code: () => ({
|
|
341
|
-
conversion: Z(e?.code),
|
|
342
|
-
priority: 1
|
|
343
|
-
}),
|
|
344
|
-
em: () => ({
|
|
345
|
-
conversion: Z(e?.em),
|
|
346
|
-
priority: 1
|
|
347
|
-
}),
|
|
348
|
-
span: () => ({
|
|
349
|
-
conversion: Z(e?.span),
|
|
350
|
-
priority: 1
|
|
351
|
-
}),
|
|
352
|
-
strong: () => ({
|
|
353
|
-
conversion: Z(e?.strong),
|
|
354
|
-
priority: 1
|
|
355
|
-
}),
|
|
356
|
-
sub: () => ({
|
|
357
|
-
conversion: Z(e?.sub),
|
|
358
|
-
priority: 1
|
|
359
|
-
}),
|
|
360
|
-
sup: () => ({
|
|
361
|
-
conversion: Z(e?.sup),
|
|
362
|
-
priority: 1
|
|
363
|
-
})
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
static importJSON(e) {
|
|
367
|
-
return zt().updateFromJSON(e);
|
|
368
|
-
}
|
|
369
|
-
isSimpleText() {
|
|
370
|
-
return this.__type === "extended-text" && this.__mode === 0;
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
function zt(e = "") {
|
|
374
|
-
return ye(new X(e));
|
|
375
|
-
}
|
|
376
|
-
function Z(e) {
|
|
377
|
-
return (t) => {
|
|
378
|
-
let n = e?.(t);
|
|
379
|
-
if (!n) return null;
|
|
380
|
-
let r = n.conversion(t);
|
|
381
|
-
if (!r) return r;
|
|
382
|
-
let i = t.style.backgroundColor, a = t.style.color, o = t.style.fontFamily, s = t.style.fontWeight, c = t.style.fontSize, l = t.style.textDecoration;
|
|
383
|
-
return {
|
|
384
|
-
...r,
|
|
385
|
-
forChild: (e, t) => {
|
|
386
|
-
let n = (r?.forChild ?? ((e) => e))(e, t);
|
|
387
|
-
if (ke(n)) {
|
|
388
|
-
let e = [
|
|
389
|
-
i ? `background-color: ${i}` : null,
|
|
390
|
-
a ? `color: ${a}` : null,
|
|
391
|
-
o ? `font-family: ${o}` : null,
|
|
392
|
-
s ? `font-weight: ${s}` : null,
|
|
393
|
-
c ? `font-size: ${c}` : null,
|
|
394
|
-
l ? `text-decoration: ${l}` : null
|
|
395
|
-
].filter((e) => e !== null).join("; ");
|
|
396
|
-
if (e.length) return n.setStyle(e);
|
|
397
|
-
}
|
|
398
|
-
return n;
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
//#endregion
|
|
404
|
-
//#region src/components/Editor/utils/stripInlineStyleProperty.ts
|
|
405
|
-
function Bt(e, t) {
|
|
406
|
-
return e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; ");
|
|
407
|
-
}
|
|
408
|
-
//#endregion
|
|
409
|
-
//#region src/components/Editor/plugins/LinkColorPlugin.tsx
|
|
410
|
-
function Vt(e) {
|
|
411
|
-
if (!z(e, Qe)) return;
|
|
412
|
-
let t = e.getStyle();
|
|
413
|
-
if (!t) return;
|
|
414
|
-
let n = Bt(t, "color");
|
|
415
|
-
n !== t && e.setStyle(n);
|
|
416
|
-
}
|
|
417
|
-
function Ht() {
|
|
418
|
-
let [e] = R();
|
|
419
|
-
return E(() => e.registerNodeTransform(X, Vt), [e]), null;
|
|
420
|
-
}
|
|
421
|
-
var Q = {
|
|
422
|
-
imageWrapper: "_imageWrapper_y06h3_1",
|
|
423
|
-
selected: "_selected_y06h3_8",
|
|
424
|
-
resizing: "_resizing_y06h3_12",
|
|
425
|
-
image: "_image_y06h3_1",
|
|
426
|
-
resizeHandle: "_resizeHandle_y06h3_30",
|
|
427
|
-
topLeft: "_topLeft_y06h3_44",
|
|
428
|
-
topRight: "_topRight_y06h3_49",
|
|
429
|
-
bottomLeft: "_bottomLeft_y06h3_54",
|
|
430
|
-
bottomRight: "_bottomRight_y06h3_59"
|
|
431
|
-
}, Ut = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
|
|
432
|
-
let [a] = R(), [o, s] = k(!1), [c, l] = k(null), u = O(null), [d, f] = k({
|
|
433
|
-
width: n || void 0,
|
|
434
|
-
height: r || void 0
|
|
435
|
-
}), p = T(() => {
|
|
436
|
-
n && r && f({
|
|
437
|
-
width: n,
|
|
438
|
-
height: r
|
|
439
|
-
});
|
|
440
|
-
}, [n, r]), m = T((e, t) => {
|
|
441
|
-
if (e.preventDefault(), e.stopPropagation(), !u.current) return;
|
|
442
|
-
let n = d.width || u.current.offsetWidth, r = d.height || u.current.offsetHeight, i = n / r;
|
|
443
|
-
(!d.width || !d.height) && f({
|
|
444
|
-
width: n,
|
|
445
|
-
height: r
|
|
446
|
-
}), l({
|
|
447
|
-
isResizing: !0,
|
|
448
|
-
startX: e.clientX,
|
|
449
|
-
startY: e.clientY,
|
|
450
|
-
startWidth: n,
|
|
451
|
-
startHeight: r,
|
|
452
|
-
aspectRatio: i,
|
|
453
|
-
direction: t
|
|
454
|
-
});
|
|
455
|
-
}, [d]), h = T((e) => {
|
|
456
|
-
if (!c?.isResizing) return;
|
|
457
|
-
let t = e.clientX - c.startX, n;
|
|
458
|
-
switch (c.direction) {
|
|
459
|
-
case "bottom-right":
|
|
460
|
-
n = Math.max(50, c.startWidth + t);
|
|
461
|
-
break;
|
|
462
|
-
case "bottom-left":
|
|
463
|
-
n = Math.max(50, c.startWidth - t);
|
|
464
|
-
break;
|
|
465
|
-
case "top-right":
|
|
466
|
-
n = Math.max(50, c.startWidth + t);
|
|
467
|
-
break;
|
|
468
|
-
case "top-left":
|
|
469
|
-
n = Math.max(50, c.startWidth - t);
|
|
470
|
-
break;
|
|
471
|
-
default: n = Math.max(50, c.startWidth + t);
|
|
472
|
-
}
|
|
473
|
-
let r = n / c.aspectRatio;
|
|
474
|
-
f({
|
|
475
|
-
width: n,
|
|
476
|
-
height: r
|
|
561
|
+
let _ = h.keys === s ? h.count : o.length, v = R(_);
|
|
562
|
+
v.current = _;
|
|
563
|
+
let [y, x] = z(!1), S = {
|
|
564
|
+
duration: a ? 0 : .16,
|
|
565
|
+
ease: "easeOut"
|
|
566
|
+
}, C = a ? {} : gn, w = F(() => {
|
|
567
|
+
let e = l.current;
|
|
568
|
+
if (!e || m.current && v.current !== o.length) return;
|
|
569
|
+
let t = getComputedStyle(e), n = Number.parseFloat(t.columnGap || t.gap) || 0, r = e.clientWidth, i = new Set(o.map((e) => e.key));
|
|
570
|
+
e.querySelectorAll("[data-toolbar-item-key]").forEach((e) => {
|
|
571
|
+
let t = e.dataset.toolbarItemKey;
|
|
572
|
+
if (!t || !i.has(t)) return;
|
|
573
|
+
let n = e.getBoundingClientRect().width;
|
|
574
|
+
(n > 0 || m.current) && (d.current[t] = n);
|
|
477
575
|
});
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
576
|
+
let a = f.current?.offsetWidth ?? 0, c = o.map((e) => ({
|
|
577
|
+
width: d.current[e.key] ?? 0,
|
|
578
|
+
isDivider: e.kind === "divider"
|
|
579
|
+
}));
|
|
580
|
+
m.current && o.length > 0 && c.every((e) => e.width <= 0) || (m.current = !1, g({
|
|
581
|
+
keys: s,
|
|
582
|
+
count: un(c, r, a, n)
|
|
583
|
+
}));
|
|
584
|
+
}, [s, o]);
|
|
585
|
+
we(() => {
|
|
586
|
+
m.current = !0, d.current = {};
|
|
483
587
|
}, [
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
if (
|
|
491
|
-
|
|
492
|
-
|
|
588
|
+
s,
|
|
589
|
+
o.length,
|
|
590
|
+
t
|
|
591
|
+
]), we(() => {
|
|
592
|
+
w();
|
|
593
|
+
let e = l.current;
|
|
594
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
595
|
+
let t = new ResizeObserver(() => w());
|
|
596
|
+
return t.observe(e), () => t.disconnect();
|
|
493
597
|
}, [
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
598
|
+
w,
|
|
599
|
+
s,
|
|
600
|
+
t
|
|
497
601
|
]);
|
|
498
|
-
let
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
className: A(Q.resizeHandle, Q.topRight),
|
|
545
|
-
onMouseDown: (e) => m(e, "top-right")
|
|
546
|
-
}),
|
|
547
|
-
/* @__PURE__ */ C("div", {
|
|
548
|
-
className: A(Q.resizeHandle, Q.topLeft),
|
|
549
|
-
onMouseDown: (e) => m(e, "top-left")
|
|
602
|
+
let { visible: T, overflow: E } = dn(o, _), D = E.length > 0, O = R(E);
|
|
603
|
+
E.length > 0 && (O.current = E);
|
|
604
|
+
let k = y && D, A = D || y && O.current.length > 0, ee = D ? E : O.current;
|
|
605
|
+
return /* @__PURE__ */ P("div", {
|
|
606
|
+
className: B(p["bsy-lexical__toolbar-stack"], a && p["bsy-lexical__toolbar-stack--instant"]),
|
|
607
|
+
children: [/* @__PURE__ */ P("div", {
|
|
608
|
+
ref: l,
|
|
609
|
+
className: p["bsy-lexical__toolbar-items"],
|
|
610
|
+
children: [
|
|
611
|
+
/* @__PURE__ */ N(ke, {
|
|
612
|
+
initial: !1,
|
|
613
|
+
mode: "popLayout",
|
|
614
|
+
children: T.map((e) => /* @__PURE__ */ N(yn, {
|
|
615
|
+
item: e,
|
|
616
|
+
motionProps: C,
|
|
617
|
+
transition: S
|
|
618
|
+
}, e.key))
|
|
619
|
+
}),
|
|
620
|
+
D ? /* @__PURE__ */ P("div", {
|
|
621
|
+
className: B(p["bsy-lexical__toolbar-overflow"], p["bsy-lexical__toolbar-with-divider"]),
|
|
622
|
+
children: [/* @__PURE__ */ N("div", { className: p["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ N(u, {
|
|
623
|
+
icon: k ? "packupeverything" : "expandall",
|
|
624
|
+
tooltip: c("editor.more"),
|
|
625
|
+
highlight: k,
|
|
626
|
+
onClick: () => x((e) => !e)
|
|
627
|
+
})]
|
|
628
|
+
}) : null,
|
|
629
|
+
/* @__PURE__ */ P("div", {
|
|
630
|
+
ref: f,
|
|
631
|
+
className: B(p["bsy-lexical__toolbar-more-sizer"], p["bsy-lexical__toolbar-with-divider"]),
|
|
632
|
+
"aria-hidden": !0,
|
|
633
|
+
children: [/* @__PURE__ */ N("div", { className: p["bsy-lexical__toolbar-divider"] }), /* @__PURE__ */ N(u, {
|
|
634
|
+
icon: "expandall",
|
|
635
|
+
tooltip: ""
|
|
636
|
+
})]
|
|
637
|
+
})
|
|
638
|
+
]
|
|
639
|
+
}), A ? /* @__PURE__ */ N("div", {
|
|
640
|
+
className: B(p["bsy-lexical__toolbar-overflow-row"], k && p["bsy-lexical__toolbar-overflow-row--open"], a && p["bsy-lexical__toolbar-overflow-row--instant"]),
|
|
641
|
+
children: /* @__PURE__ */ N("div", {
|
|
642
|
+
className: p["bsy-lexical__toolbar-overflow-inner"],
|
|
643
|
+
children: ee.map((e) => /* @__PURE__ */ N(yn, {
|
|
644
|
+
item: e,
|
|
645
|
+
motionProps: {},
|
|
646
|
+
transition: S
|
|
647
|
+
}, `overflow-${e.key}`))
|
|
550
648
|
})
|
|
551
|
-
|
|
649
|
+
}) : null]
|
|
552
650
|
});
|
|
553
|
-
},
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
651
|
+
}, xn = (e) => {
|
|
652
|
+
let { config: t = [], style: n, theme: r, mode: i, floating: a, size: o = v } = e, { toolbarRef: s } = le(), c = i === "floating", u = je(), d = {
|
|
653
|
+
duration: u ? 0 : .16,
|
|
654
|
+
ease: "easeOut"
|
|
655
|
+
}, f = L(() => sn(r, o), [r, o]), m = L(() => ({ iconSize: cn(r?.iconSize, o) }), [r?.iconSize, o]), h = c ? ln(a) : void 0, g = c ? _e(n, [
|
|
656
|
+
"position",
|
|
657
|
+
"left",
|
|
658
|
+
"top",
|
|
659
|
+
"right",
|
|
660
|
+
"bottom",
|
|
661
|
+
"inset",
|
|
662
|
+
"transform",
|
|
663
|
+
"marginTop",
|
|
664
|
+
"marginBottom"
|
|
665
|
+
]) : n;
|
|
666
|
+
return /* @__PURE__ */ N(l, {
|
|
667
|
+
value: m,
|
|
668
|
+
children: /* @__PURE__ */ N(ee, { children: /* @__PURE__ */ N(pn, { children: /* @__PURE__ */ N(Ae.div, {
|
|
669
|
+
ref: s,
|
|
670
|
+
layout: u ? !1 : "position",
|
|
671
|
+
transition: d,
|
|
672
|
+
className: B(p["bsy-lexical__toolbar"], c && p["bsy-lexical__toolbar--floating"]),
|
|
673
|
+
style: {
|
|
674
|
+
...f,
|
|
675
|
+
...h,
|
|
676
|
+
...g
|
|
677
|
+
},
|
|
678
|
+
children: /* @__PURE__ */ N(bn, {
|
|
679
|
+
config: t,
|
|
680
|
+
sizeToken: `${o}|${r?.itemHeight ?? ""}|${r?.iconSize ?? ""}`
|
|
681
|
+
})
|
|
682
|
+
}) }) })
|
|
683
|
+
});
|
|
684
|
+
}, Z = {
|
|
685
|
+
"bsy-lexical-editor": "_bsy-lexical-editor_ivndp_1",
|
|
686
|
+
"bsy-lexical-editor--floating": "_bsy-lexical-editor--floating_ivndp_7",
|
|
687
|
+
"bsy-lexical-editor__body": "_bsy-lexical-editor__body_ivndp_10",
|
|
688
|
+
"bsy-lexical-editor__body--fixed": "_bsy-lexical-editor__body--fixed_ivndp_15",
|
|
689
|
+
"bsy-lexical-editor__editable-wrap": "_bsy-lexical-editor__editable-wrap_ivndp_18",
|
|
690
|
+
"bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_ivndp_27",
|
|
691
|
+
"bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_ivndp_37",
|
|
692
|
+
"bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_ivndp_49"
|
|
693
|
+
}, Q = class e extends gt {
|
|
694
|
+
constructor(e, t) {
|
|
695
|
+
super(e, t);
|
|
593
696
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
n.__width = e, n.__height = t;
|
|
697
|
+
static getType() {
|
|
698
|
+
return "extended-text";
|
|
597
699
|
}
|
|
598
|
-
|
|
599
|
-
return
|
|
600
|
-
src: this.__src,
|
|
601
|
-
altText: this.__altText,
|
|
602
|
-
width: this.__width,
|
|
603
|
-
height: this.__height,
|
|
604
|
-
nodeKey: this.getKey()
|
|
605
|
-
});
|
|
700
|
+
static clone(t) {
|
|
701
|
+
return new e(t.__text, t.__key);
|
|
606
702
|
}
|
|
607
703
|
static importDOM() {
|
|
608
|
-
|
|
609
|
-
conversion: qt,
|
|
610
|
-
priority: 0
|
|
611
|
-
}) };
|
|
612
|
-
}
|
|
613
|
-
static importJSON(e) {
|
|
614
|
-
let { src: t, altText: n, width: r, height: i } = e;
|
|
615
|
-
return Gt({
|
|
616
|
-
src: t,
|
|
617
|
-
altText: n,
|
|
618
|
-
width: r,
|
|
619
|
-
height: i
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
exportJSON() {
|
|
704
|
+
let e = gt.importDOM();
|
|
623
705
|
return {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
706
|
+
...e,
|
|
707
|
+
code: () => ({
|
|
708
|
+
conversion: $(e?.code),
|
|
709
|
+
priority: 1
|
|
710
|
+
}),
|
|
711
|
+
em: () => ({
|
|
712
|
+
conversion: $(e?.em),
|
|
713
|
+
priority: 1
|
|
714
|
+
}),
|
|
715
|
+
span: () => ({
|
|
716
|
+
conversion: $(e?.span),
|
|
717
|
+
priority: 1
|
|
718
|
+
}),
|
|
719
|
+
strong: () => ({
|
|
720
|
+
conversion: $(e?.strong),
|
|
721
|
+
priority: 1
|
|
722
|
+
}),
|
|
723
|
+
sub: () => ({
|
|
724
|
+
conversion: $(e?.sub),
|
|
725
|
+
priority: 1
|
|
726
|
+
}),
|
|
727
|
+
sup: () => ({
|
|
728
|
+
conversion: $(e?.sup),
|
|
729
|
+
priority: 1
|
|
730
|
+
})
|
|
630
731
|
};
|
|
631
732
|
}
|
|
632
|
-
|
|
633
|
-
return
|
|
733
|
+
static importJSON(e) {
|
|
734
|
+
return Sn().updateFromJSON(e);
|
|
735
|
+
}
|
|
736
|
+
isSimpleText() {
|
|
737
|
+
return this.__type === "extended-text" && this.__mode === 0;
|
|
634
738
|
}
|
|
635
739
|
};
|
|
636
|
-
function
|
|
637
|
-
return new
|
|
740
|
+
function Sn(e = "") {
|
|
741
|
+
return Be(new Q(e));
|
|
742
|
+
}
|
|
743
|
+
function $(e) {
|
|
744
|
+
return (t) => {
|
|
745
|
+
let n = e?.(t);
|
|
746
|
+
if (!n) return null;
|
|
747
|
+
let r = n.conversion(t);
|
|
748
|
+
if (!r) return r;
|
|
749
|
+
let i = t.style.backgroundColor, a = t.style.color, o = t.style.fontFamily, s = t.style.fontWeight, c = t.style.fontSize, l = t.style.textDecoration;
|
|
750
|
+
return {
|
|
751
|
+
...r,
|
|
752
|
+
forChild: (e, t) => {
|
|
753
|
+
let n = (r?.forChild ?? ((e) => e))(e, t);
|
|
754
|
+
if (Qe(n)) {
|
|
755
|
+
let e = [
|
|
756
|
+
i ? `background-color: ${i}` : null,
|
|
757
|
+
a ? `color: ${a}` : null,
|
|
758
|
+
o ? `font-family: ${o}` : null,
|
|
759
|
+
s ? `font-weight: ${s}` : null,
|
|
760
|
+
c ? `font-size: ${c}` : null,
|
|
761
|
+
l ? `text-decoration: ${l}` : null
|
|
762
|
+
].filter((e) => e !== null).join("; ");
|
|
763
|
+
if (e.length) return n.setStyle(e);
|
|
764
|
+
}
|
|
765
|
+
return n;
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
};
|
|
638
769
|
}
|
|
639
|
-
|
|
640
|
-
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/components/Editor/utils/stripInlineStyleProperty.ts
|
|
772
|
+
function Cn(e, t) {
|
|
773
|
+
return e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; ");
|
|
641
774
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
src: t,
|
|
655
|
-
altText: n,
|
|
656
|
-
width: i,
|
|
657
|
-
height: a
|
|
658
|
-
}) };
|
|
659
|
-
}
|
|
660
|
-
return null;
|
|
775
|
+
//#endregion
|
|
776
|
+
//#region src/components/Editor/plugins/LinkColorPlugin.tsx
|
|
777
|
+
function wn(e) {
|
|
778
|
+
if (!K(e, Tt)) return;
|
|
779
|
+
let t = e.getStyle();
|
|
780
|
+
if (!t) return;
|
|
781
|
+
let n = Cn(t, "color");
|
|
782
|
+
n !== t && e.setStyle(n);
|
|
783
|
+
}
|
|
784
|
+
function Tn() {
|
|
785
|
+
let [e] = G();
|
|
786
|
+
return I(() => e.registerNodeTransform(Q, wn), [e]), null;
|
|
661
787
|
}
|
|
662
788
|
//#endregion
|
|
663
789
|
//#region src/components/Editor/plugins/ImagePlugin.tsx
|
|
664
|
-
function
|
|
665
|
-
let [e] =
|
|
666
|
-
return
|
|
790
|
+
function En() {
|
|
791
|
+
let [e] = G();
|
|
792
|
+
return I(() => e.registerCommand(C, (e) => (qe([rn(e)]), !0), it), [e]), null;
|
|
667
793
|
}
|
|
668
794
|
//#endregion
|
|
669
795
|
//#region src/components/Editor/utils/stripImagesFromHtml.ts
|
|
670
|
-
function
|
|
796
|
+
function Dn(e) {
|
|
671
797
|
let t = new DOMParser().parseFromString(e, "text/html");
|
|
672
798
|
return t.querySelectorAll("img, picture").forEach((e) => e.remove()), t.body.innerHTML;
|
|
673
799
|
}
|
|
674
800
|
//#endregion
|
|
675
801
|
//#region src/components/Editor/plugins/PasteStripImagePlugin.tsx
|
|
676
|
-
var
|
|
677
|
-
function
|
|
678
|
-
let [e] =
|
|
679
|
-
return
|
|
802
|
+
var On = /<img\b|<picture\b/i;
|
|
803
|
+
function kn() {
|
|
804
|
+
let [e] = G(), { isSourceModeRef: t } = M();
|
|
805
|
+
return I(() => {
|
|
680
806
|
let n = (n) => {
|
|
681
807
|
if (t.current) return !1;
|
|
682
808
|
let r = "clipboardData" in n ? n.clipboardData : "dataTransfer" in n ? n.dataTransfer : null;
|
|
683
809
|
if (!r || r.getData("application/x-lexical-editor") || r.getData("application/x-lexical-drag")) return !1;
|
|
684
810
|
let i = r.getData("text/html");
|
|
685
|
-
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) ||
|
|
811
|
+
if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) || On.test(i))) return !1;
|
|
686
812
|
n.preventDefault();
|
|
687
813
|
let a = r.getData("text/plain");
|
|
688
|
-
return !
|
|
689
|
-
let t =
|
|
814
|
+
return !On.test(i) && !a || e.update(() => {
|
|
815
|
+
let t = U();
|
|
690
816
|
if (t === null) return;
|
|
691
|
-
let n = i ?
|
|
817
|
+
let n = i ? Dn(i) : "", r = document.createElement("div");
|
|
692
818
|
if (r.innerHTML = n, n && r.textContent?.trim()) {
|
|
693
|
-
let t =
|
|
819
|
+
let t = ze(e, new DOMParser().parseFromString(n, "text/html"));
|
|
694
820
|
if (t.length) {
|
|
695
|
-
|
|
821
|
+
qe(t);
|
|
696
822
|
return;
|
|
697
823
|
}
|
|
698
824
|
}
|
|
699
825
|
a && t.insertRawText(a);
|
|
700
|
-
}, { tag:
|
|
826
|
+
}, { tag: mt }), !0;
|
|
701
827
|
};
|
|
702
|
-
return
|
|
828
|
+
return wt(e.registerCommand(pt, (e) => n(e), at), e.registerCommand(st, (e) => n(e), at));
|
|
703
829
|
}, [e, t]), null;
|
|
704
830
|
}
|
|
705
831
|
//#endregion
|
|
706
832
|
//#region src/components/Editor/plugins/EnterKeyPlugin.tsx
|
|
707
|
-
function
|
|
708
|
-
let [e] =
|
|
709
|
-
return
|
|
833
|
+
function An() {
|
|
834
|
+
let [e] = G(), t = R(0);
|
|
835
|
+
return I(() => e.registerCommand(dt, (n) => {
|
|
710
836
|
let r = Date.now(), i = r - t.current;
|
|
711
837
|
return t.current = r, i < 250 && i > 0 ? e.getEditorState().read(() => {
|
|
712
|
-
let e =
|
|
713
|
-
return
|
|
838
|
+
let e = U();
|
|
839
|
+
return W(e) ? !!K(e.anchor.getNode(), (e) => q(e) || J(e) || zt(e)) : !1;
|
|
714
840
|
}, { editor: e }) ? !1 : (e.update(() => {
|
|
715
|
-
let e =
|
|
716
|
-
if (
|
|
841
|
+
let e = U();
|
|
842
|
+
if (W(e)) {
|
|
717
843
|
let t = e.anchor.getNode().getTopLevelElement();
|
|
718
844
|
if (t && t.getTextContent().trim() === "") {
|
|
719
|
-
let n =
|
|
720
|
-
|
|
845
|
+
let n = He();
|
|
846
|
+
xt(e, {
|
|
721
847
|
"background-color": "",
|
|
722
848
|
color: "",
|
|
723
849
|
"font-size": "",
|
|
@@ -730,11 +856,11 @@ function Qt() {
|
|
|
730
856
|
}
|
|
731
857
|
}
|
|
732
858
|
}), n?.preventDefault(), !0) : !1;
|
|
733
|
-
},
|
|
859
|
+
}, ot), [e]), null;
|
|
734
860
|
}
|
|
735
861
|
//#endregion
|
|
736
862
|
//#region src/components/Editor/utils/codeHighlighter.ts
|
|
737
|
-
var
|
|
863
|
+
var jn = {
|
|
738
864
|
css: () => import("@shikijs/langs/css"),
|
|
739
865
|
html: () => import("@shikijs/langs/html"),
|
|
740
866
|
xml: () => import("@shikijs/langs/xml"),
|
|
@@ -755,65 +881,65 @@ var $t = {
|
|
|
755
881
|
bash: () => import("@shikijs/langs/shellscript"),
|
|
756
882
|
lua: () => import("@shikijs/langs/lua"),
|
|
757
883
|
markdown: () => import("@shikijs/langs/markdown")
|
|
758
|
-
},
|
|
884
|
+
}, Mn = (e) => e === "bash" ? "shellscript" : e, Nn = (e) => e in jn, Pn = null, Fn = null, In = /* @__PURE__ */ new Map(), Ln = () => (Pn ||= Promise.all([import("@shikijs/core"), import("@shikijs/engine-javascript")]).then(([{ createHighlighterCoreSync: e }, { createJavaScriptRegexEngine: t }]) => e({
|
|
759
885
|
engine: t(),
|
|
760
886
|
langs: [],
|
|
761
887
|
themes: []
|
|
762
888
|
})).catch((e) => {
|
|
763
|
-
throw
|
|
764
|
-
}),
|
|
765
|
-
let t =
|
|
766
|
-
return t || (t =
|
|
767
|
-
let n =
|
|
889
|
+
throw Pn = null, e;
|
|
890
|
+
}), Pn), Rn = (e, t) => Nn(t) && e.getLoadedLanguages().includes(Mn(t)), zn = (e) => {
|
|
891
|
+
let t = In.get(e);
|
|
892
|
+
return t || (t = Ln().then(async (t) => {
|
|
893
|
+
let n = Mn(e);
|
|
768
894
|
if (!t.getLoadedLanguages().includes(n)) {
|
|
769
|
-
let n = await
|
|
895
|
+
let n = await jn[e]();
|
|
770
896
|
await t.loadLanguage(n.default);
|
|
771
897
|
}
|
|
772
898
|
return t;
|
|
773
899
|
}).catch((t) => {
|
|
774
|
-
throw
|
|
775
|
-
}),
|
|
776
|
-
},
|
|
900
|
+
throw In.delete(e), t;
|
|
901
|
+
}), In.set(e, t)), t;
|
|
902
|
+
}, Bn = () => (Fn ||= Ln().then(async (e) => {
|
|
777
903
|
if (!e.getLoadedThemes().includes("github-light")) {
|
|
778
904
|
let t = await import("@shikijs/themes/github-light");
|
|
779
905
|
await e.loadTheme(t.default);
|
|
780
906
|
}
|
|
781
907
|
return e;
|
|
782
908
|
}).catch((e) => {
|
|
783
|
-
throw
|
|
784
|
-
}),
|
|
909
|
+
throw Fn = null, e;
|
|
910
|
+
}), Fn), Vn = (e, t, n) => {
|
|
785
911
|
let r = e.getTextContent();
|
|
786
|
-
if (e.getStyle() && e.setStyle(""), !n || !
|
|
787
|
-
let i =
|
|
912
|
+
if (e.getStyle() && e.setStyle(""), !n || !Rn(n, t)) return Pt(r);
|
|
913
|
+
let i = Mn(t), a = n.codeToTokens(r, {
|
|
788
914
|
lang: i,
|
|
789
|
-
theme:
|
|
915
|
+
theme: A
|
|
790
916
|
}), o = [];
|
|
791
917
|
return a.tokens.forEach((e, t) => {
|
|
792
|
-
t && o.push(
|
|
918
|
+
t && o.push(Ve()), e.forEach((e) => {
|
|
793
919
|
e.content.split(" ").forEach((t, n) => {
|
|
794
|
-
if (n && o.push(
|
|
795
|
-
let r =
|
|
920
|
+
if (n && o.push(Ue()), t === "") return;
|
|
921
|
+
let r = jt(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}` : "";
|
|
796
922
|
i && r.setStyle(i), o.push(r);
|
|
797
923
|
});
|
|
798
924
|
});
|
|
799
925
|
}), o;
|
|
800
|
-
},
|
|
801
|
-
let n =
|
|
802
|
-
if (!
|
|
803
|
-
let r =
|
|
804
|
-
if (!
|
|
926
|
+
}, Hn = (e, t) => {
|
|
927
|
+
let n = V(e);
|
|
928
|
+
if (!J(n) || !n.isAttached()) return;
|
|
929
|
+
let r = U();
|
|
930
|
+
if (!W(r)) {
|
|
805
931
|
t();
|
|
806
932
|
return;
|
|
807
933
|
}
|
|
808
|
-
let { anchor: i } = r, a = i.offset, o = i.type === "element" &&
|
|
934
|
+
let { anchor: i } = r, a = i.offset, o = i.type === "element" && Ye(n.getChildAtIndex(i.offset - 1)), s = 0;
|
|
809
935
|
if (o || (s = a + i.getNode().getPreviousSiblings().reduce((e, t) => e + t.getTextContentSize(), 0)), t()) {
|
|
810
936
|
if (o) {
|
|
811
937
|
i.getNode().select(a, a);
|
|
812
938
|
return;
|
|
813
939
|
}
|
|
814
940
|
n.getChildren().some((e) => {
|
|
815
|
-
let t =
|
|
816
|
-
if (t ||
|
|
941
|
+
let t = Qe(e);
|
|
942
|
+
if (t || Ye(e)) {
|
|
817
943
|
let n = e.getTextContentSize();
|
|
818
944
|
if (t && n >= s) return e.select(s, s), !0;
|
|
819
945
|
s -= n;
|
|
@@ -821,11 +947,11 @@ var $t = {
|
|
|
821
947
|
return !1;
|
|
822
948
|
});
|
|
823
949
|
}
|
|
824
|
-
},
|
|
950
|
+
}, Un = (e, t) => Nt(e) && Nt(t) && e.__text === t.__text && e.__highlightType === t.__highlightType && e.__style === t.__style || Ze(e) && Ze(t) || Ye(e) && Ye(t), Wn = (e, t) => {
|
|
825
951
|
let n = 0;
|
|
826
|
-
for (; n < e.length &&
|
|
952
|
+
for (; n < e.length && Un(e[n], t[n]);) n++;
|
|
827
953
|
let r = e.length, i = t.length, a = Math.min(r, i) - n, o = 0;
|
|
828
|
-
for (; o < a;) if (o++, !
|
|
954
|
+
for (; o < a;) if (o++, !Un(e[r - o], t[i - o])) {
|
|
829
955
|
o--;
|
|
830
956
|
break;
|
|
831
957
|
}
|
|
@@ -834,21 +960,21 @@ var $t = {
|
|
|
834
960
|
to: r - o,
|
|
835
961
|
nodesForReplacement: t.slice(n, i - o)
|
|
836
962
|
};
|
|
837
|
-
},
|
|
838
|
-
let a = i.getKey(), o =
|
|
963
|
+
}, Gn = (e, t, n, r, i) => {
|
|
964
|
+
let a = i.getKey(), o = d(i.getLanguage());
|
|
839
965
|
if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
|
|
840
966
|
else {
|
|
841
|
-
i.getTheme() !== "github-light" && i.setTheme(
|
|
842
|
-
let s = t ? t.getLoadedThemes().includes("github-light") ?
|
|
967
|
+
i.getTheme() !== "github-light" && i.setTheme(A);
|
|
968
|
+
let s = t ? t.getLoadedThemes().includes("github-light") ? Nn(o) && !Rn(t, o) ? zn(o) : null : Bn() : Ln();
|
|
843
969
|
if (s) {
|
|
844
970
|
i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1), n.pendingKeys.add(a), n.loading !== s && (n.loading = s, s.then((t) => {
|
|
845
971
|
r(t);
|
|
846
972
|
let i = [...n.pendingKeys];
|
|
847
973
|
n.pendingKeys.clear(), n.loading = null, e.update(() => {
|
|
848
974
|
i.forEach((e) => {
|
|
849
|
-
|
|
975
|
+
V(e)?.markDirty();
|
|
850
976
|
});
|
|
851
|
-
}, { tag:
|
|
977
|
+
}, { tag: lt });
|
|
852
978
|
}, () => {
|
|
853
979
|
n.pendingKeys.clear(), n.loading = null;
|
|
854
980
|
}));
|
|
@@ -856,22 +982,22 @@ var $t = {
|
|
|
856
982
|
}
|
|
857
983
|
i.getIsSyntaxHighlightSupported() || i.setIsSyntaxHighlightSupported(!0);
|
|
858
984
|
}
|
|
859
|
-
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0,
|
|
985
|
+
n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, et(() => {
|
|
860
986
|
n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
|
|
861
|
-
})),
|
|
862
|
-
let e =
|
|
863
|
-
if (!
|
|
864
|
-
let n =
|
|
987
|
+
})), Hn(a, () => {
|
|
988
|
+
let e = V(a);
|
|
989
|
+
if (!J(e) || !e.isAttached()) return !1;
|
|
990
|
+
let n = Vn(e, d(e.getLanguage()), t), { from: r, to: i, nodesForReplacement: o } = Wn(e.getChildren(), n);
|
|
865
991
|
return r !== i || o.length ? (e.splice(r, i - r, o), !0) : !1;
|
|
866
992
|
}));
|
|
867
|
-
},
|
|
993
|
+
}, Kn = (e, t, n, r, i) => {
|
|
868
994
|
let a = i.getParent();
|
|
869
|
-
|
|
995
|
+
J(a) ? Gn(e, t, n, r, a) : Nt(i) && i.replace(We(i.__text));
|
|
870
996
|
};
|
|
871
|
-
function
|
|
872
|
-
let [e] =
|
|
873
|
-
return
|
|
874
|
-
if (!e.hasNodes([
|
|
997
|
+
function qn() {
|
|
998
|
+
let [e] = G();
|
|
999
|
+
return I(() => {
|
|
1000
|
+
if (!e.hasNodes([It, Ft])) throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");
|
|
875
1001
|
let t = null, n = {
|
|
876
1002
|
didTransform: !1,
|
|
877
1003
|
nodesCurrentlyHighlighting: /* @__PURE__ */ new Set(),
|
|
@@ -880,16 +1006,16 @@ function gn() {
|
|
|
880
1006
|
}, r = (e) => {
|
|
881
1007
|
t = e;
|
|
882
1008
|
}, i = (e) => {
|
|
883
|
-
let t =
|
|
884
|
-
if (!
|
|
1009
|
+
let t = V(e);
|
|
1010
|
+
if (!J(t)) return;
|
|
885
1011
|
let n = t.getChildrenSize();
|
|
886
1012
|
n === 0 ? t.selectStart() : t.select(0, n);
|
|
887
1013
|
}, a = (t) => {
|
|
888
1014
|
if (!(t instanceof Node) || !e.getRootElement()?.contains(t)) return null;
|
|
889
1015
|
let n = null;
|
|
890
1016
|
return e.getEditorState().read(() => {
|
|
891
|
-
let e =
|
|
892
|
-
|
|
1017
|
+
let e = Ge(t), r = e ? K(e, J) : null;
|
|
1018
|
+
J(r) && (n = r.getKey());
|
|
893
1019
|
}, { editor: e }), n;
|
|
894
1020
|
}, o = null, s = (t, n, r) => {
|
|
895
1021
|
t.preventDefault(), r && (o = n), e.update(() => {
|
|
@@ -911,12 +1037,12 @@ function gn() {
|
|
|
911
1037
|
}, d = (e, t) => {
|
|
912
1038
|
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);
|
|
913
1039
|
};
|
|
914
|
-
return
|
|
915
|
-
|
|
916
|
-
}), e.registerNodeTransform(
|
|
917
|
-
|
|
918
|
-
}), e.registerNodeTransform(
|
|
919
|
-
|
|
1040
|
+
return vt(Lt(e), e.registerNodeTransform(It, (i) => {
|
|
1041
|
+
Gn(e, t, n, r, i);
|
|
1042
|
+
}), e.registerNodeTransform(gt, (i) => {
|
|
1043
|
+
Kn(e, t, n, r, i);
|
|
1044
|
+
}), e.registerNodeTransform(Ft, (i) => {
|
|
1045
|
+
Kn(e, t, n, r, i);
|
|
920
1046
|
}), e.registerRootListener(d), () => {
|
|
921
1047
|
d(null, e.getRootElement());
|
|
922
1048
|
});
|
|
@@ -924,23 +1050,23 @@ function gn() {
|
|
|
924
1050
|
}
|
|
925
1051
|
//#endregion
|
|
926
1052
|
//#region src/components/Editor/plugins/TablePlugin.tsx
|
|
927
|
-
function
|
|
928
|
-
let [e] =
|
|
929
|
-
return
|
|
1053
|
+
function Jn() {
|
|
1054
|
+
let [e] = G();
|
|
1055
|
+
return I(() => (Yt(e, !0), wt(qt(e), Jt(e, !1), Kt(e), e.registerNodeTransform(Ut, (e) => {
|
|
930
1056
|
e.getBackgroundColor() !== null && e.setBackgroundColor(null);
|
|
931
|
-
}), e.registerCommand(
|
|
932
|
-
let t =
|
|
933
|
-
if (!
|
|
934
|
-
let n =
|
|
1057
|
+
}), e.registerCommand(ft, (e) => {
|
|
1058
|
+
let t = U();
|
|
1059
|
+
if (!W(t) || !t.isCollapsed()) return !1;
|
|
1060
|
+
let n = Rt(t.anchor.getNode());
|
|
935
1061
|
if (n === null) return !1;
|
|
936
1062
|
let r = e.shiftKey ? "previous" : "next", i = r === "next" ? "getNextSibling" : "getPreviousSibling", a = r === "next" ? "getFirstChild" : "getLastChild", o = n[i](), s = null;
|
|
937
|
-
if (
|
|
1063
|
+
if (zt(o)) s = o;
|
|
938
1064
|
else {
|
|
939
|
-
let e =
|
|
1065
|
+
let e = K(n, Vt);
|
|
940
1066
|
if (e !== null) for (let t = e[i](); t !== null; t = t[i]()) {
|
|
941
|
-
if (!
|
|
1067
|
+
if (!Vt(t)) continue;
|
|
942
1068
|
let e = t[a]();
|
|
943
|
-
if (
|
|
1069
|
+
if (zt(e)) {
|
|
944
1070
|
s = e;
|
|
945
1071
|
break;
|
|
946
1072
|
}
|
|
@@ -950,60 +1076,60 @@ function _n() {
|
|
|
950
1076
|
let e = s.getFirstDescendant();
|
|
951
1077
|
e ? e.selectStart() : s.selectStart();
|
|
952
1078
|
} else {
|
|
953
|
-
let e =
|
|
1079
|
+
let e = K(n, Bt);
|
|
954
1080
|
e && (r === "next" ? e.selectNext() : e.selectPrevious());
|
|
955
1081
|
}
|
|
956
1082
|
return !0;
|
|
957
|
-
},
|
|
1083
|
+
}, at))), [e]), null;
|
|
958
1084
|
}
|
|
959
1085
|
//#endregion
|
|
960
1086
|
//#region src/components/Editor/plugins/TabIndentPlugin.tsx
|
|
961
|
-
var
|
|
962
|
-
function
|
|
963
|
-
let [e] =
|
|
964
|
-
return
|
|
1087
|
+
var Yn = "\xA0".repeat(4);
|
|
1088
|
+
function Xn() {
|
|
1089
|
+
let [e] = G();
|
|
1090
|
+
return I(() => e.registerCommand(ft, (t) => {
|
|
965
1091
|
if (t.shiftKey) return !1;
|
|
966
|
-
let n =
|
|
967
|
-
if (!
|
|
1092
|
+
let n = U();
|
|
1093
|
+
if (!W(n)) return !1;
|
|
968
1094
|
let r = n.anchor.getNode();
|
|
969
|
-
if (
|
|
1095
|
+
if (Rt(r) !== null || K(r, J)) return !1;
|
|
970
1096
|
t.preventDefault();
|
|
971
|
-
let i =
|
|
972
|
-
if (
|
|
1097
|
+
let i = K(r, q);
|
|
1098
|
+
if (q(i)) {
|
|
973
1099
|
let e = new Set([i]);
|
|
974
1100
|
for (let t of n.getNodes()) {
|
|
975
|
-
let n =
|
|
976
|
-
|
|
1101
|
+
let n = K(t, q);
|
|
1102
|
+
q(n) && e.add(n);
|
|
977
1103
|
}
|
|
978
1104
|
for (let t of e) t.setIndent(t.getIndent() + 1);
|
|
979
1105
|
return !0;
|
|
980
1106
|
}
|
|
981
1107
|
let a = r.getTopLevelElement(), o = n.focus.getNode().getTopLevelElement();
|
|
982
|
-
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(
|
|
983
|
-
},
|
|
1108
|
+
return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(ut, void 0) : (n.insertText(Yn), !0);
|
|
1109
|
+
}, it), [e]), null;
|
|
984
1110
|
}
|
|
985
1111
|
//#endregion
|
|
986
1112
|
//#region src/components/Editor/plugins/MaxLengthPlugin.tsx
|
|
987
|
-
function
|
|
988
|
-
let [n] =
|
|
989
|
-
return i.current = t,
|
|
1113
|
+
function Zn({ maxLength: e, onMaxLengthExceed: t }) {
|
|
1114
|
+
let [n] = G(), { isSourceModeRef: r } = M(), i = R(t);
|
|
1115
|
+
return i.current = t, I(() => {
|
|
990
1116
|
let t = null;
|
|
991
|
-
return n.registerNodeTransform(
|
|
1117
|
+
return n.registerNodeTransform(ht, (a) => {
|
|
992
1118
|
if (r.current) return;
|
|
993
1119
|
let o = a.getTextContentSize();
|
|
994
1120
|
if (o <= e) return;
|
|
995
|
-
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u =
|
|
1121
|
+
let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u = U();
|
|
996
1122
|
if (c === e && t !== s) {
|
|
997
|
-
t = s,
|
|
1123
|
+
t = s, Ct(n, s), i.current?.();
|
|
998
1124
|
return;
|
|
999
1125
|
}
|
|
1000
|
-
if (
|
|
1001
|
-
|
|
1126
|
+
if (W(u) && u.isCollapsed()) {
|
|
1127
|
+
St(n, u.anchor, l), i.current?.();
|
|
1002
1128
|
return;
|
|
1003
1129
|
}
|
|
1004
1130
|
a.selectEnd();
|
|
1005
|
-
let d =
|
|
1006
|
-
|
|
1131
|
+
let d = U();
|
|
1132
|
+
W(d) && (St(n, d.anchor, l), i.current?.());
|
|
1007
1133
|
});
|
|
1008
1134
|
}, [
|
|
1009
1135
|
n,
|
|
@@ -1012,121 +1138,20 @@ function bn({ maxLength: e, onMaxLengthExceed: t }) {
|
|
|
1012
1138
|
]), null;
|
|
1013
1139
|
}
|
|
1014
1140
|
//#endregion
|
|
1015
|
-
//#region src/components/Editor/utils/fillRootFromHtml.ts
|
|
1016
|
-
var xn = [
|
|
1017
|
-
"color",
|
|
1018
|
-
"background-color",
|
|
1019
|
-
"font-size",
|
|
1020
|
-
"font-family",
|
|
1021
|
-
"font-weight",
|
|
1022
|
-
"text-decoration"
|
|
1023
|
-
], Sn = (e) => {
|
|
1024
|
-
let t = e.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, td, th");
|
|
1025
|
-
for (let n of Array.from(t)) {
|
|
1026
|
-
let t = n, r = [];
|
|
1027
|
-
for (let e of xn) {
|
|
1028
|
-
let n = t.style.getPropertyValue(e);
|
|
1029
|
-
n && (r.push(`${e}: ${n}`), t.style.removeProperty(e));
|
|
1030
|
-
}
|
|
1031
|
-
if (!r.length) continue;
|
|
1032
|
-
let i = r.join("; ");
|
|
1033
|
-
for (let n of Array.from(t.childNodes)) {
|
|
1034
|
-
if (n.nodeType === Node.TEXT_NODE && n.textContent) {
|
|
1035
|
-
let r = e.createElement("span");
|
|
1036
|
-
r.setAttribute("style", i), t.insertBefore(r, n), r.appendChild(n);
|
|
1037
|
-
continue;
|
|
1038
|
-
}
|
|
1039
|
-
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
1040
|
-
let e = n, t = e.getAttribute("style");
|
|
1041
|
-
e.setAttribute("style", t ? `${t}; ${i}` : i);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
function Cn(e, t) {
|
|
1047
|
-
let n = M();
|
|
1048
|
-
if (n.clear(), !t.trim()) return;
|
|
1049
|
-
let r = new DOMParser().parseFromString(t, "text/html");
|
|
1050
|
-
Sn(r);
|
|
1051
|
-
let i = ve(e, r);
|
|
1052
|
-
i.length && (n.select(), P(i));
|
|
1053
|
-
}
|
|
1054
|
-
//#endregion
|
|
1055
|
-
//#region src/components/Editor/utils/isEmptyEditorHtml.ts
|
|
1056
|
-
function wn(e, t) {
|
|
1057
|
-
return !t.trim() && (e === "<p><br></p>" || e === "<p></p>" || e === "" || /^<p>\s*<br>\s*<\/p>$/.test(e));
|
|
1058
|
-
}
|
|
1059
|
-
//#endregion
|
|
1060
|
-
//#region src/components/Editor/utils/sanitizeEditorHtml.ts
|
|
1061
|
-
var Tn = /* @__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("."), En = [
|
|
1062
|
-
"href",
|
|
1063
|
-
"src",
|
|
1064
|
-
"alt",
|
|
1065
|
-
"target",
|
|
1066
|
-
"rel",
|
|
1067
|
-
"colspan",
|
|
1068
|
-
"rowspan",
|
|
1069
|
-
"data-language",
|
|
1070
|
-
"class",
|
|
1071
|
-
"style",
|
|
1072
|
-
"width",
|
|
1073
|
-
"height"
|
|
1074
|
-
], Dn = new Set([
|
|
1075
|
-
"color",
|
|
1076
|
-
"background-color",
|
|
1077
|
-
"font-size",
|
|
1078
|
-
"font-family",
|
|
1079
|
-
"font-weight",
|
|
1080
|
-
"text-decoration",
|
|
1081
|
-
"text-align",
|
|
1082
|
-
"max-width",
|
|
1083
|
-
"display",
|
|
1084
|
-
"vertical-align",
|
|
1085
|
-
"width",
|
|
1086
|
-
"height",
|
|
1087
|
-
"border"
|
|
1088
|
-
]), On = /^(?:(?:(?:f|ht)tps?|mailto|blob):|data:image\/[a-z0-9.+-]+[;,].*|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i, kn = (e) => e.split(";").map((e) => e.trim()).filter(Boolean).map((e) => {
|
|
1089
|
-
let t = e.indexOf(":");
|
|
1090
|
-
if (t === -1) return null;
|
|
1091
|
-
let n = e.slice(0, t).trim().toLowerCase(), r = e.slice(t + 1).trim();
|
|
1092
|
-
if (n === "background") {
|
|
1093
|
-
if (/url\s*\(/i.test(r)) return null;
|
|
1094
|
-
n = "background-color";
|
|
1095
|
-
}
|
|
1096
|
-
return !Dn.has(n) || /expression|javascript:|url\s*\(\s*['"]?\s*javascript/i.test(r) ? null : `${n}: ${r}`;
|
|
1097
|
-
}).filter((e) => e !== null).join("; "), An = !1, jn = () => {
|
|
1098
|
-
An ||= (Ct.addHook("uponSanitizeAttribute", (e, t) => {
|
|
1099
|
-
if (t.attrName === "href" && /^data:/i.test(t.attrValue)) {
|
|
1100
|
-
t.keepAttr = !1;
|
|
1101
|
-
return;
|
|
1102
|
-
}
|
|
1103
|
-
t.attrName === "style" && (t.attrValue = kn(t.attrValue), t.attrValue || (t.keepAttr = !1));
|
|
1104
|
-
}), !0);
|
|
1105
|
-
};
|
|
1106
|
-
function $(e) {
|
|
1107
|
-
return e ? (jn(), Ct.sanitize(e, {
|
|
1108
|
-
ALLOWED_TAGS: Tn,
|
|
1109
|
-
ALLOWED_ATTR: En,
|
|
1110
|
-
ALLOW_DATA_ATTR: !1,
|
|
1111
|
-
ADD_ATTR: ["data-language"],
|
|
1112
|
-
ALLOWED_URI_REGEXP: On
|
|
1113
|
-
})) : "";
|
|
1114
|
-
}
|
|
1115
|
-
//#endregion
|
|
1116
1141
|
//#region src/components/Editor/utils/textLength.ts
|
|
1117
|
-
function
|
|
1142
|
+
function Qn(e) {
|
|
1118
1143
|
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
1119
1144
|
}
|
|
1120
|
-
function
|
|
1121
|
-
let n =
|
|
1145
|
+
function $n(e, t) {
|
|
1146
|
+
let n = H(), r = n.getTextContentSize();
|
|
1122
1147
|
if (r <= t) return !1;
|
|
1123
1148
|
let i = r - t;
|
|
1124
1149
|
n.selectEnd();
|
|
1125
|
-
let a =
|
|
1126
|
-
return
|
|
1150
|
+
let a = U();
|
|
1151
|
+
return W(a) ? St(e, a.anchor, i) : er(i), !0;
|
|
1127
1152
|
}
|
|
1128
|
-
function
|
|
1129
|
-
let t = e, n =
|
|
1153
|
+
function er(e) {
|
|
1154
|
+
let t = e, n = H().getAllTextNodes();
|
|
1130
1155
|
for (let e = n.length - 1; e >= 0 && t > 0; e--) {
|
|
1131
1156
|
let r = n[e], i = r.getTextContent();
|
|
1132
1157
|
i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
|
|
@@ -1134,87 +1159,88 @@ function Pn(e) {
|
|
|
1134
1159
|
}
|
|
1135
1160
|
//#endregion
|
|
1136
1161
|
//#region src/components/Editor/utils/formatEditorHtml.ts
|
|
1137
|
-
var
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1162
|
+
var tr = new Set([
|
|
1163
|
+
"area",
|
|
1164
|
+
"base",
|
|
1165
|
+
"br",
|
|
1166
|
+
"col",
|
|
1167
|
+
"embed",
|
|
1168
|
+
"hr",
|
|
1169
|
+
"img",
|
|
1170
|
+
"input",
|
|
1171
|
+
"link",
|
|
1172
|
+
"meta",
|
|
1173
|
+
"param",
|
|
1174
|
+
"source",
|
|
1175
|
+
"track",
|
|
1176
|
+
"wbr"
|
|
1177
|
+
]), nr = 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(".")), rr = 80, ir = (e) => e.replace(/&/g, "&").replace(/"/g, """), ar = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), or = (e) => Array.from(e.attributes).map((e) => ` ${e.name}="${ir(e.value)}"`).join(""), sr = (e) => " ".repeat(e), cr = (e, t, n) => {
|
|
1178
|
+
let r = e.tagName.toLowerCase(), i = `<${r}${or(e)}>`;
|
|
1179
|
+
if (tr.has(r)) return i;
|
|
1180
|
+
let a = n || r === "pre", o = lr(e, t + 1, a), s = `</${r}>`;
|
|
1181
|
+
return a || !nr.has(r) ? `${i}${o}${s}` : Array.from(e.children).some((e) => nr.has(e.tagName.toLowerCase())) ? `${i}\n${lr(e, t + 1, !1, !0)}\n${sr(t)}${s}` : i.length + o.length + s.length > rr ? `${i}\n${sr(t + 1)}${o}\n${sr(t)}${s}` : `${i}${o}${s}`;
|
|
1182
|
+
}, lr = (e, t, n, r = !1) => {
|
|
1183
|
+
let i = [];
|
|
1184
|
+
for (let r of Array.from(e.childNodes)) {
|
|
1185
|
+
if (r.nodeType === Node.TEXT_NODE) {
|
|
1186
|
+
let e = r.textContent ?? "";
|
|
1187
|
+
if (n) {
|
|
1188
|
+
i.push(ar(e));
|
|
1157
1189
|
continue;
|
|
1158
1190
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
(t === "b" && r?.tagName === "STRONG" || t === "i" && r?.tagName === "EM") && (Fn(e), n = !0);
|
|
1191
|
+
e.trim() && i.push(ar(e));
|
|
1192
|
+
continue;
|
|
1162
1193
|
}
|
|
1194
|
+
if (r.nodeType === Node.COMMENT_NODE) {
|
|
1195
|
+
i.push(`<!--${r.data}-->`);
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
r.nodeType === Node.ELEMENT_NODE && i.push(cr(r, t, n));
|
|
1163
1199
|
}
|
|
1164
|
-
return t.
|
|
1200
|
+
return n || !r ? i.join("") : i.map((e) => `${sr(t)}${e}`).join("\n");
|
|
1165
1201
|
};
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
let t = In(e);
|
|
1169
|
-
try {
|
|
1170
|
-
let [{ format: e }, n] = await Promise.all([import("prettier/standalone"), import("prettier/plugins/html")]);
|
|
1171
|
-
return (await e(t, {
|
|
1172
|
-
parser: "html",
|
|
1173
|
-
plugins: [n]
|
|
1174
|
-
})).trimEnd();
|
|
1175
|
-
} catch {
|
|
1176
|
-
return t;
|
|
1177
|
-
}
|
|
1202
|
+
function ur(e) {
|
|
1203
|
+
return e.trim() ? lr(new DOMParser().parseFromString(te(e), "text/html").body, 0, !1, !0).trimEnd() : e;
|
|
1178
1204
|
}
|
|
1179
1205
|
//#endregion
|
|
1180
1206
|
//#region src/components/Editor/utils/writeHtmlSource.ts
|
|
1181
|
-
function
|
|
1182
|
-
|
|
1183
|
-
let t =
|
|
1184
|
-
if (
|
|
1207
|
+
function dr(e) {
|
|
1208
|
+
H().clear();
|
|
1209
|
+
let t = Mt("html");
|
|
1210
|
+
if (H().append(t), !e) return;
|
|
1185
1211
|
t.select();
|
|
1186
|
-
let n =
|
|
1187
|
-
|
|
1212
|
+
let n = U();
|
|
1213
|
+
W(n) && n.insertRawText(e);
|
|
1188
1214
|
}
|
|
1189
1215
|
//#endregion
|
|
1190
1216
|
//#region src/components/Editor/plugins/SourceModePlugin.tsx
|
|
1191
|
-
function
|
|
1192
|
-
let [r] =
|
|
1217
|
+
function fr({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
1218
|
+
let [r] = G(), [i, a] = z(!1), o = R(!1), s = R(n);
|
|
1193
1219
|
s.current = n;
|
|
1194
|
-
let c =
|
|
1220
|
+
let c = Qn(t) ? t : void 0, l = F(() => {
|
|
1195
1221
|
if (o.current) return;
|
|
1196
1222
|
let e = "", t = "";
|
|
1197
1223
|
r.getEditorState().read(() => {
|
|
1198
|
-
t =
|
|
1199
|
-
}, { editor: r })
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
});
|
|
1204
|
-
}, [r]), u =
|
|
1224
|
+
t = H().getTextContent(), e = Re(r, null);
|
|
1225
|
+
}, { editor: r });
|
|
1226
|
+
let n = ie(e, t) ? "" : E(e);
|
|
1227
|
+
o.current = !0, a(!0), r.update(() => {
|
|
1228
|
+
dr(ur(n));
|
|
1229
|
+
}), r.dispatchCommand(nt, void 0);
|
|
1230
|
+
}, [r]), u = F(() => {
|
|
1205
1231
|
if (!o.current) return;
|
|
1206
1232
|
let e = !1;
|
|
1207
1233
|
o.current = !1, r.update(() => {
|
|
1208
|
-
|
|
1209
|
-
}), a(!1), r.dispatchCommand(
|
|
1210
|
-
}, [r, c]), d =
|
|
1234
|
+
ne(r, E(H().getTextContent())), c !== void 0 && (e = $n(r, c));
|
|
1235
|
+
}), a(!1), r.dispatchCommand(nt, void 0), e && s.current?.();
|
|
1236
|
+
}, [r, c]), d = F(() => {
|
|
1211
1237
|
if (o.current) {
|
|
1212
1238
|
u();
|
|
1213
1239
|
return;
|
|
1214
1240
|
}
|
|
1215
1241
|
l();
|
|
1216
1242
|
}, [l, u]);
|
|
1217
|
-
|
|
1243
|
+
I(() => {
|
|
1218
1244
|
let e = (e) => {
|
|
1219
1245
|
if (!o.current) return !1;
|
|
1220
1246
|
let t = "clipboardData" in e ? e.clipboardData : "dataTransfer" in e ? e.dataTransfer : null;
|
|
@@ -1222,53 +1248,53 @@ function zn({ children: e, maxLength: t, onMaxLengthExceed: n }) {
|
|
|
1222
1248
|
e.preventDefault();
|
|
1223
1249
|
let n = t.getData("text/html") || t.getData("text/plain");
|
|
1224
1250
|
if (!n) return !0;
|
|
1225
|
-
let i =
|
|
1251
|
+
let i = E(n);
|
|
1226
1252
|
return r.update(() => {
|
|
1227
|
-
let e =
|
|
1228
|
-
|
|
1229
|
-
}, { tag:
|
|
1253
|
+
let e = U();
|
|
1254
|
+
W(e) && i && e.insertRawText(i);
|
|
1255
|
+
}, { tag: mt }), !0;
|
|
1230
1256
|
};
|
|
1231
|
-
return
|
|
1257
|
+
return wt(r.registerNodeTransform(ht, () => {
|
|
1232
1258
|
if (!o.current) return;
|
|
1233
|
-
let e =
|
|
1234
|
-
|
|
1235
|
-
}), r.registerCommand(
|
|
1259
|
+
let e = H(), t = e.getChildrenSize() === 1 ? e.getFirstChild() : null;
|
|
1260
|
+
J(t) && t.getLanguage() === "html" || dr(e.getTextContent());
|
|
1261
|
+
}), r.registerCommand(pt, e, rt), r.registerCommand(st, e, rt));
|
|
1236
1262
|
}, [r]);
|
|
1237
|
-
let f =
|
|
1263
|
+
let f = L(() => ({
|
|
1238
1264
|
isSourceMode: i,
|
|
1239
1265
|
isSourceModeRef: o,
|
|
1240
1266
|
toggleSourceMode: d
|
|
1241
1267
|
}), [i, d]);
|
|
1242
|
-
return /* @__PURE__ */
|
|
1268
|
+
return /* @__PURE__ */ N(ce.Provider, {
|
|
1243
1269
|
value: f,
|
|
1244
1270
|
children: e
|
|
1245
1271
|
});
|
|
1246
1272
|
}
|
|
1247
1273
|
//#endregion
|
|
1248
1274
|
//#region src/components/Editor/plugins/HeadingPlugin.tsx
|
|
1249
|
-
function
|
|
1275
|
+
function pr(e) {
|
|
1250
1276
|
let t = e.getTag();
|
|
1251
1277
|
if (t === "h4" || t === "h5" || t === "h6") {
|
|
1252
|
-
e.replace(
|
|
1278
|
+
e.replace(He(), !0);
|
|
1253
1279
|
return;
|
|
1254
1280
|
}
|
|
1255
1281
|
for (let t of e.getAllTextNodes()) {
|
|
1256
1282
|
let e = t.getStyle();
|
|
1257
1283
|
if (!e) continue;
|
|
1258
|
-
let n =
|
|
1284
|
+
let n = Cn(e, "font-size");
|
|
1259
1285
|
n !== e && t.setStyle(n);
|
|
1260
1286
|
}
|
|
1261
1287
|
}
|
|
1262
|
-
function
|
|
1263
|
-
let [e] =
|
|
1264
|
-
return
|
|
1288
|
+
function mr() {
|
|
1289
|
+
let [e] = G();
|
|
1290
|
+
return I(() => e.registerNodeTransform(Zt, pr), [e]), null;
|
|
1265
1291
|
}
|
|
1266
1292
|
//#endregion
|
|
1267
1293
|
//#region src/components/Editor/LengthBadge.tsx
|
|
1268
|
-
var
|
|
1294
|
+
var hr = ({ current: e, maxLength: t }) => {
|
|
1269
1295
|
let n = e > t;
|
|
1270
|
-
return /* @__PURE__ */
|
|
1271
|
-
className:
|
|
1296
|
+
return /* @__PURE__ */ P("div", {
|
|
1297
|
+
className: B(Z["bsy-lexical-editor__length-badge"], n && Z["bsy-lexical-editor__length-badge--exceeded"]),
|
|
1272
1298
|
"aria-live": "polite",
|
|
1273
1299
|
children: [
|
|
1274
1300
|
e,
|
|
@@ -1277,127 +1303,764 @@ var Hn = ({ current: e, maxLength: t }) => {
|
|
|
1277
1303
|
]
|
|
1278
1304
|
});
|
|
1279
1305
|
};
|
|
1280
|
-
|
|
1306
|
+
hr.displayName = "BsyLexicalEditorLengthBadge";
|
|
1307
|
+
//#endregion
|
|
1308
|
+
//#region src/components/Editor/utils/unwrapTypesetFence.ts
|
|
1309
|
+
var gr = /^\uFEFF/, _r = /^ {0,3}`{1,3}[A-Za-z]*$/, vr = /^( {0,3})([^`<]*?)```[ \t]*([A-Za-z0-9_-]*)[ \t]*(.*)$/, yr = /^ {0,3}```[ \t]*$/, br = /<\/?[a-zA-Z]/, xr = /<[a-zA-Z!]/, Sr = (e) => xr.test(e), Cr = (e) => br.test(e), wr = (e) => e.replace(gr, "").replace(/\r\n/g, "\n"), Tr = (e) => {
|
|
1310
|
+
let t = e.replace(/\n+$/, ""), n = t.lastIndexOf("\n"), r = n === -1 ? t : t.slice(n + 1);
|
|
1311
|
+
return _r.test(r) ? {
|
|
1312
|
+
text: n === -1 ? "" : t.slice(0, n),
|
|
1313
|
+
withheld: !0
|
|
1314
|
+
} : {
|
|
1315
|
+
text: e,
|
|
1316
|
+
withheld: !1
|
|
1317
|
+
};
|
|
1318
|
+
}, Er = (e) => {
|
|
1319
|
+
let t = vr.exec(e);
|
|
1320
|
+
return t ? { sameLineBody: t[4] ?? "" } : null;
|
|
1321
|
+
}, Dr = (e) => {
|
|
1322
|
+
let t = e.replace(/[ \t]*```[ \t]*$/, "");
|
|
1323
|
+
return t === e ? e : t;
|
|
1324
|
+
}, Or = (e) => Sr(e) ? e.replace(/^\n/, "") : "", kr = (e) => {
|
|
1325
|
+
let t = e.split("\n"), n = [], r = 0;
|
|
1326
|
+
for (; r < t.length;) {
|
|
1327
|
+
let e = t[r], i = Er(e);
|
|
1328
|
+
if (i) {
|
|
1329
|
+
let e = i.sameLineBody;
|
|
1330
|
+
if (e !== Dr(e)) {
|
|
1331
|
+
e = Dr(e);
|
|
1332
|
+
let i = Or(t.slice(r + 1).join("\n"));
|
|
1333
|
+
return [
|
|
1334
|
+
...n,
|
|
1335
|
+
e,
|
|
1336
|
+
i
|
|
1337
|
+
].filter(Boolean).join("\n");
|
|
1338
|
+
}
|
|
1339
|
+
let a = [];
|
|
1340
|
+
for (e && a.push(e), r += 1; r < t.length && !yr.test(t[r]);) a.push(t[r]), r += 1;
|
|
1341
|
+
let o = r < t.length ? Or(t.slice(r + 1).join("\n")) : "";
|
|
1342
|
+
return [
|
|
1343
|
+
...n,
|
|
1344
|
+
a.join("\n"),
|
|
1345
|
+
o
|
|
1346
|
+
].filter(Boolean).join("\n");
|
|
1347
|
+
}
|
|
1348
|
+
if (Cr(e)) return Ar([...n, ...t.slice(r)].join("\n"));
|
|
1349
|
+
Sr(e) && n.push(e), r += 1;
|
|
1350
|
+
}
|
|
1351
|
+
return n.length ? n.join("\n") : null;
|
|
1352
|
+
}, Ar = (e) => {
|
|
1353
|
+
let t = e.split("\n");
|
|
1354
|
+
if (!t.length) return e;
|
|
1355
|
+
let n = Er(t[0]);
|
|
1356
|
+
return n && !Cr(t[0].slice(0, t[0].indexOf("```"))) && (t.shift(), n.sameLineBody && t.unshift(Dr(n.sameLineBody))), t.length && yr.test(t[t.length - 1] ?? "") && t.pop(), t.join("\n");
|
|
1357
|
+
};
|
|
1358
|
+
function jr(e) {
|
|
1359
|
+
if (!e) return {
|
|
1360
|
+
html: "",
|
|
1361
|
+
pending: !1
|
|
1362
|
+
};
|
|
1363
|
+
let { text: t, withheld: n } = Tr(wr(e));
|
|
1364
|
+
if (!t.trim()) return {
|
|
1365
|
+
html: "",
|
|
1366
|
+
pending: n || _r.test(wr(e).trim())
|
|
1367
|
+
};
|
|
1368
|
+
let r = kr(t) ?? t, i = kr(r);
|
|
1369
|
+
i !== null && i !== r && (r = i);
|
|
1370
|
+
let a = r.trim();
|
|
1371
|
+
return Sr(a) ? {
|
|
1372
|
+
html: a,
|
|
1373
|
+
pending: !1
|
|
1374
|
+
} : {
|
|
1375
|
+
html: "",
|
|
1376
|
+
pending: !0
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
//#endregion
|
|
1380
|
+
//#region src/components/Editor/utils/prepareTypesetProposed.ts
|
|
1381
|
+
var Mr = "p, h1, h2, h3, li", Nr = /background(-color)?\s*:/i;
|
|
1382
|
+
function Pr(e) {
|
|
1383
|
+
if (!e.trim() || !Nr.test(e)) return e;
|
|
1384
|
+
let t = se(e);
|
|
1385
|
+
if (!t) return e;
|
|
1386
|
+
for (let e of Array.from(t.querySelectorAll(Mr))) {
|
|
1387
|
+
let t = e;
|
|
1388
|
+
t.style.removeProperty("background-color"), t.style.removeProperty("background"), t.getAttribute("style")?.trim() || t.removeAttribute("style");
|
|
1389
|
+
}
|
|
1390
|
+
return t.innerHTML;
|
|
1391
|
+
}
|
|
1392
|
+
function Fr(e, t) {
|
|
1393
|
+
let { html: n } = jr(e);
|
|
1394
|
+
return n ? Pr(T(n, t)) : "";
|
|
1395
|
+
}
|
|
1281
1396
|
//#endregion
|
|
1282
|
-
//#region src/components/Editor/
|
|
1283
|
-
|
|
1284
|
-
let
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1397
|
+
//#region src/components/Editor/utils/applyAiTypeset.ts
|
|
1398
|
+
function Ir(e, t, n, r) {
|
|
1399
|
+
let i = E(Fr(t, n));
|
|
1400
|
+
if (!i.trim() || ie(i, "")) return {
|
|
1401
|
+
applied: !1,
|
|
1402
|
+
truncated: !1
|
|
1403
|
+
};
|
|
1404
|
+
let a = !1;
|
|
1405
|
+
return e.update(() => {
|
|
1406
|
+
ne(e, i), Qn(r) && (a = $n(e, r));
|
|
1407
|
+
}, { discrete: !0 }), {
|
|
1408
|
+
applied: !0,
|
|
1409
|
+
truncated: a
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
//#endregion
|
|
1413
|
+
//#region src/components/Editor/Preview/Thinking.tsx
|
|
1414
|
+
var Lr = [
|
|
1415
|
+
.26,
|
|
1416
|
+
.02,
|
|
1417
|
+
.23,
|
|
1418
|
+
.94
|
|
1419
|
+
], Rr = () => {
|
|
1420
|
+
let e = `${Ce().replace(/:/g, "")}g`;
|
|
1421
|
+
return /* @__PURE__ */ N("span", {
|
|
1422
|
+
className: j["bsy-lexical-ai__think-icon"],
|
|
1423
|
+
"aria-hidden": "true",
|
|
1424
|
+
children: /* @__PURE__ */ P("svg", {
|
|
1425
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1426
|
+
width: "16",
|
|
1427
|
+
height: "16",
|
|
1428
|
+
viewBox: "0 0 16 16",
|
|
1429
|
+
fill: "none",
|
|
1430
|
+
children: [/* @__PURE__ */ N("path", {
|
|
1431
|
+
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",
|
|
1432
|
+
fill: `url(#${e})`
|
|
1433
|
+
}), /* @__PURE__ */ N("defs", { children: /* @__PURE__ */ P("linearGradient", {
|
|
1434
|
+
id: e,
|
|
1435
|
+
x1: "8.00059",
|
|
1436
|
+
y1: "1",
|
|
1437
|
+
x2: "8.00059",
|
|
1438
|
+
y2: "14.8072",
|
|
1439
|
+
gradientUnits: "userSpaceOnUse",
|
|
1440
|
+
children: [
|
|
1441
|
+
/* @__PURE__ */ N("stop", { stopColor: "#0265FF" }),
|
|
1442
|
+
/* @__PURE__ */ N("stop", {
|
|
1443
|
+
offset: "1",
|
|
1444
|
+
stopColor: "#A6FFFF"
|
|
1445
|
+
}),
|
|
1446
|
+
/* @__PURE__ */ N("animateTransform", {
|
|
1447
|
+
attributeName: "gradientTransform",
|
|
1448
|
+
type: "rotate",
|
|
1449
|
+
from: "0 8 8",
|
|
1450
|
+
to: "360 8 8",
|
|
1451
|
+
dur: "1.8s",
|
|
1452
|
+
repeatCount: "indefinite"
|
|
1453
|
+
})
|
|
1454
|
+
]
|
|
1455
|
+
}) })]
|
|
1456
|
+
})
|
|
1457
|
+
});
|
|
1458
|
+
};
|
|
1459
|
+
function zr(e, t, r) {
|
|
1460
|
+
let { t: i } = n(), a = e.status === "loading" && !t, [o, s] = z(!0), [c, l] = z(0), u = R(Date.now()), d = R(null), f = R(!1), p = R(!1), m = e.reasoning ?? "", h = a || o, g = (a || !!m) && !(e.status === "error" && !m), _ = (e) => {
|
|
1461
|
+
!e || !p.current || (p.current = !1, e.scrollHeight - e.scrollTop - e.clientHeight > 8 && (f.current = !0));
|
|
1462
|
+
}, v = F(() => r?.current ?? void 0, [r]), y = F(() => {
|
|
1463
|
+
let e = v();
|
|
1464
|
+
return e?.closest("[data-overlayscrollbars]") ?? e;
|
|
1465
|
+
}, [v]);
|
|
1466
|
+
return I(() => {
|
|
1467
|
+
if (!a) {
|
|
1468
|
+
d.current === null && (d.current = Math.max(1, Math.round((Date.now() - u.current) / 1e3)), l(d.current)), s(!1);
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
u.current = Date.now(), d.current = null, s(!0), f.current = !1, p.current = !1;
|
|
1472
|
+
let e = window.setInterval(() => {
|
|
1473
|
+
l(Math.max(1, Math.round((Date.now() - u.current) / 1e3)));
|
|
1474
|
+
}, 500);
|
|
1475
|
+
return () => window.clearInterval(e);
|
|
1476
|
+
}, [a]), I(() => {
|
|
1477
|
+
p.current = !1;
|
|
1478
|
+
}, [De()]), Oe("wheel", () => {
|
|
1479
|
+
p.current = !0;
|
|
1480
|
+
}, {
|
|
1481
|
+
target: y,
|
|
1482
|
+
passive: !0,
|
|
1483
|
+
enable: a
|
|
1484
|
+
}), Oe("pointerdown", (e) => {
|
|
1485
|
+
let t = e.target;
|
|
1486
|
+
t instanceof Element && t.closest(".os-scrollbar") && (p.current = !0);
|
|
1487
|
+
}, {
|
|
1488
|
+
target: y,
|
|
1489
|
+
passive: !0,
|
|
1490
|
+
enable: a
|
|
1491
|
+
}), Oe("scroll", () => _(v()), {
|
|
1492
|
+
target: v,
|
|
1493
|
+
passive: !0,
|
|
1494
|
+
enable: a
|
|
1495
|
+
}), I(() => {
|
|
1496
|
+
if (!a || f.current || !r?.current) return;
|
|
1497
|
+
let e = window.requestAnimationFrame(() => {
|
|
1498
|
+
if (f.current) return;
|
|
1499
|
+
let e = r?.current;
|
|
1500
|
+
e && e.scrollHeight - e.scrollTop - e.clientHeight > 1 && (e.scrollTop = e.scrollHeight);
|
|
1501
|
+
});
|
|
1502
|
+
return () => window.cancelAnimationFrame(e);
|
|
1503
|
+
}, [
|
|
1504
|
+
m,
|
|
1505
|
+
r,
|
|
1506
|
+
a
|
|
1507
|
+
]), {
|
|
1508
|
+
visible: g,
|
|
1509
|
+
thinking: a,
|
|
1510
|
+
open: h,
|
|
1511
|
+
label: a ? i("editor.aiThinking") : i("editor.aiThoughtSeconds", { seconds: c }),
|
|
1512
|
+
reasoning: m,
|
|
1513
|
+
toggle: () => s((e) => !e),
|
|
1514
|
+
onViewportScroll: () => _(r?.current)
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
var Br = ({ model: t }) => t.visible ? /* @__PURE__ */ P("button", {
|
|
1518
|
+
type: "button",
|
|
1519
|
+
className: j["bsy-lexical-ai__think-head"],
|
|
1520
|
+
disabled: t.thinking,
|
|
1521
|
+
onClick: t.toggle,
|
|
1522
|
+
children: [t.thinking ? /* @__PURE__ */ N(Rr, {}) : /* @__PURE__ */ N(e, {
|
|
1523
|
+
name: "arrow-down",
|
|
1524
|
+
size: 12,
|
|
1525
|
+
className: B(j["bsy-lexical-ai__think-arrow"], t.open && j["bsy-lexical-ai__think-arrow--open"])
|
|
1526
|
+
}), /* @__PURE__ */ N("span", {
|
|
1527
|
+
className: j["bsy-lexical-ai__think-label"],
|
|
1528
|
+
children: /* @__PURE__ */ N(ke, {
|
|
1529
|
+
mode: "popLayout",
|
|
1530
|
+
initial: !1,
|
|
1531
|
+
children: /* @__PURE__ */ N(Ae.span, {
|
|
1532
|
+
initial: {
|
|
1533
|
+
opacity: 0,
|
|
1534
|
+
y: 6
|
|
1535
|
+
},
|
|
1536
|
+
animate: {
|
|
1537
|
+
opacity: 1,
|
|
1538
|
+
y: 0
|
|
1539
|
+
},
|
|
1540
|
+
exit: {
|
|
1541
|
+
opacity: 0,
|
|
1542
|
+
y: -6
|
|
1543
|
+
},
|
|
1544
|
+
transition: {
|
|
1545
|
+
duration: .22,
|
|
1546
|
+
ease: Lr
|
|
1547
|
+
},
|
|
1548
|
+
children: /* @__PURE__ */ N("span", {
|
|
1549
|
+
className: t.thinking ? j["bsy-lexical-ai__think-label--shimmer"] : void 0,
|
|
1550
|
+
children: t.label
|
|
1551
|
+
})
|
|
1552
|
+
}, t.label)
|
|
1553
|
+
})
|
|
1554
|
+
})]
|
|
1555
|
+
}) : null, Vr = ({ model: e }) => {
|
|
1556
|
+
let [t, n] = z(!0), r = Se(e.reasoning);
|
|
1557
|
+
if (I(() => {
|
|
1558
|
+
e.open || n(!0);
|
|
1559
|
+
}, [e.open]), !e.visible) return null;
|
|
1560
|
+
let i = /* @__PURE__ */ N("div", {
|
|
1561
|
+
className: j["bsy-lexical-ai__think-body"],
|
|
1562
|
+
children: r
|
|
1563
|
+
});
|
|
1564
|
+
return !t && e.open && e.reasoning ? /* @__PURE__ */ N("div", {
|
|
1565
|
+
className: B(j["bsy-lexical-ai__think-collapse"], j["bsy-lexical-ai__think-collapse--grown"]),
|
|
1566
|
+
children: i
|
|
1567
|
+
}) : /* @__PURE__ */ N(ke, {
|
|
1568
|
+
initial: !1,
|
|
1569
|
+
children: e.open && e.reasoning ? /* @__PURE__ */ N(Ae.div, {
|
|
1570
|
+
initial: {
|
|
1571
|
+
height: 0,
|
|
1572
|
+
opacity: 0
|
|
1573
|
+
},
|
|
1574
|
+
animate: {
|
|
1575
|
+
height: "auto",
|
|
1576
|
+
opacity: 1
|
|
1577
|
+
},
|
|
1578
|
+
exit: {
|
|
1579
|
+
height: 0,
|
|
1580
|
+
opacity: 0,
|
|
1581
|
+
transition: {
|
|
1582
|
+
duration: .2,
|
|
1583
|
+
ease: "easeOut"
|
|
1584
|
+
}
|
|
1585
|
+
},
|
|
1586
|
+
transition: {
|
|
1587
|
+
duration: .2,
|
|
1588
|
+
ease: "easeOut"
|
|
1589
|
+
},
|
|
1590
|
+
onAnimationComplete: () => {
|
|
1591
|
+
e.open && n(!1);
|
|
1592
|
+
},
|
|
1593
|
+
className: j["bsy-lexical-ai__think-collapse"],
|
|
1594
|
+
children: i
|
|
1595
|
+
}, "think-body") : null
|
|
1596
|
+
});
|
|
1597
|
+
}, Hr = ({ html: e }) => {
|
|
1598
|
+
let [t, n] = z(() => e && !O(e) ? E(e) : "");
|
|
1599
|
+
return I(() => {
|
|
1600
|
+
!e || O(e) || n(E(e));
|
|
1601
|
+
}, [e]), t ? /* @__PURE__ */ N("div", {
|
|
1602
|
+
className: B("bsy-lexical-editor", j["bsy-lexical-ai__html"]),
|
|
1603
|
+
dangerouslySetInnerHTML: { __html: t }
|
|
1604
|
+
}) : null;
|
|
1605
|
+
}, Ur = {
|
|
1606
|
+
paddingAbsolute: !0,
|
|
1607
|
+
overflow: {
|
|
1608
|
+
x: "hidden",
|
|
1609
|
+
y: "scroll"
|
|
1610
|
+
}
|
|
1611
|
+
}, Wr = ({ status: r, reasoning: o, errorMessage: s, originalHtml: c, proposedHtml: l, preset: u, onPresetChange: d, onCancel: f, onApply: p }) => {
|
|
1612
|
+
let { t: m } = n(), [h, g] = z(!0), _ = R(null), v = !!l.trim(), y = r === "ready" && v, b = zr({
|
|
1613
|
+
status: r,
|
|
1614
|
+
reasoning: o
|
|
1615
|
+
}, v, _), S = D.map((e) => ({
|
|
1616
|
+
key: e,
|
|
1617
|
+
label: m(x[e])
|
|
1618
|
+
}));
|
|
1619
|
+
return /* @__PURE__ */ N(t, {
|
|
1620
|
+
title: m("editor.aiPolish"),
|
|
1621
|
+
open: h,
|
|
1622
|
+
width: "800px",
|
|
1623
|
+
fullSwitch: !0,
|
|
1624
|
+
afterClose: f,
|
|
1625
|
+
onOpenChange: g,
|
|
1626
|
+
children: /* @__PURE__ */ P("div", {
|
|
1627
|
+
className: j["bsy-lexical-ai__dialog"],
|
|
1628
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1629
|
+
className: j["bsy-lexical-ai__pane"],
|
|
1630
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1631
|
+
className: j["bsy-lexical-ai__column"],
|
|
1632
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1633
|
+
className: B(j["bsy-lexical-ai__column-title"], j["bsy-lexical-ai__column-title--before"]),
|
|
1634
|
+
children: [/* @__PURE__ */ N("span", { className: j["bsy-lexical-ai__column-dot"] }), m("editor.aiOriginal")]
|
|
1635
|
+
}), /* @__PURE__ */ N(i, {
|
|
1636
|
+
className: j["bsy-lexical-ai__column-body"],
|
|
1637
|
+
options: Ur,
|
|
1638
|
+
children: /* @__PURE__ */ N(Hr, { html: c })
|
|
1639
|
+
})]
|
|
1640
|
+
}), /* @__PURE__ */ P("div", {
|
|
1641
|
+
className: j["bsy-lexical-ai__column"],
|
|
1642
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1643
|
+
className: j["bsy-lexical-ai__column-head"],
|
|
1644
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1645
|
+
className: B(j["bsy-lexical-ai__column-title"], j["bsy-lexical-ai__column-title--after"]),
|
|
1646
|
+
children: [/* @__PURE__ */ N("span", { className: j["bsy-lexical-ai__column-dot"] }), m("editor.aiOptimized")]
|
|
1647
|
+
}), /* @__PURE__ */ N(a, {
|
|
1648
|
+
menus: S,
|
|
1649
|
+
showSearch: !1,
|
|
1650
|
+
activeKey: [u],
|
|
1651
|
+
offset: {
|
|
1652
|
+
x: 0,
|
|
1653
|
+
y: 4
|
|
1654
|
+
},
|
|
1655
|
+
style: {
|
|
1656
|
+
width: 90,
|
|
1657
|
+
minWidth: 90
|
|
1658
|
+
},
|
|
1659
|
+
onClick: (e) => d(e.key),
|
|
1660
|
+
children: /* @__PURE__ */ P("button", {
|
|
1661
|
+
type: "button",
|
|
1662
|
+
className: j["bsy-lexical-ai__preset"],
|
|
1663
|
+
title: m("editor.aiPolish"),
|
|
1664
|
+
children: [m(x[u]), /* @__PURE__ */ N(e, {
|
|
1665
|
+
name: "arrow-down",
|
|
1666
|
+
size: 16
|
|
1667
|
+
})]
|
|
1668
|
+
})
|
|
1669
|
+
})]
|
|
1670
|
+
}), /* @__PURE__ */ P("div", {
|
|
1671
|
+
className: j["bsy-lexical-ai__column-stack"],
|
|
1672
|
+
children: [b.visible ? /* @__PURE__ */ N("div", {
|
|
1673
|
+
className: j["bsy-lexical-ai__think-pin"],
|
|
1674
|
+
children: /* @__PURE__ */ N(Br, { model: b })
|
|
1675
|
+
}) : null, /* @__PURE__ */ P(i, {
|
|
1676
|
+
className: j["bsy-lexical-ai__column-body"],
|
|
1677
|
+
options: Ur,
|
|
1678
|
+
viewportRef: _,
|
|
1679
|
+
onScroll: b.onViewportScroll,
|
|
1680
|
+
children: [r === "error" ? /* @__PURE__ */ N("div", {
|
|
1681
|
+
className: j["bsy-lexical-ai__error"],
|
|
1682
|
+
children: s || m("editor.aiError")
|
|
1683
|
+
}) : /* @__PURE__ */ N(Vr, { model: b }), v ? /* @__PURE__ */ N(Hr, { html: l }) : null]
|
|
1684
|
+
})]
|
|
1685
|
+
})]
|
|
1686
|
+
})]
|
|
1687
|
+
}), /* @__PURE__ */ P("div", {
|
|
1688
|
+
className: j["bsy-lexical-ai__footer"],
|
|
1689
|
+
children: [/* @__PURE__ */ N(Te, {
|
|
1690
|
+
onClick: () => g(!1),
|
|
1691
|
+
children: m("editor.aiAbandon")
|
|
1692
|
+
}), /* @__PURE__ */ N(Te, {
|
|
1693
|
+
type: "primary",
|
|
1694
|
+
disabled: !y,
|
|
1695
|
+
onClick: () => p() && g(!1),
|
|
1696
|
+
children: m("editor.aiApply")
|
|
1697
|
+
})]
|
|
1698
|
+
})]
|
|
1699
|
+
})
|
|
1700
|
+
});
|
|
1701
|
+
}, Gr = {
|
|
1702
|
+
paddingAbsolute: !0,
|
|
1703
|
+
overflow: {
|
|
1704
|
+
x: "hidden",
|
|
1705
|
+
y: "scroll"
|
|
1706
|
+
}
|
|
1707
|
+
}, Kr = ({ status: e, reasoning: r, errorMessage: a, originalHtml: o, proposedHtml: s, onCancel: c, onApply: l }) => {
|
|
1708
|
+
let { t: u } = n(), [d, f] = z(!0), p = R(null), m = !!s.trim(), h = e === "ready" && m, g = zr({
|
|
1709
|
+
status: e,
|
|
1710
|
+
reasoning: r
|
|
1711
|
+
}, m, p);
|
|
1712
|
+
return /* @__PURE__ */ N(t, {
|
|
1713
|
+
title: u("editor.aiPreview"),
|
|
1714
|
+
open: d,
|
|
1715
|
+
width: "800px",
|
|
1716
|
+
fullSwitch: !0,
|
|
1717
|
+
afterClose: c,
|
|
1718
|
+
onOpenChange: f,
|
|
1719
|
+
children: /* @__PURE__ */ P("div", {
|
|
1720
|
+
className: j["bsy-lexical-ai__dialog"],
|
|
1721
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1722
|
+
className: j["bsy-lexical-ai__pane"],
|
|
1723
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1724
|
+
className: j["bsy-lexical-ai__column"],
|
|
1725
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1726
|
+
className: B(j["bsy-lexical-ai__column-title"], j["bsy-lexical-ai__column-title--before"]),
|
|
1727
|
+
children: [/* @__PURE__ */ N("span", { className: j["bsy-lexical-ai__column-dot"] }), u("editor.aiOriginal")]
|
|
1728
|
+
}), /* @__PURE__ */ N(i, {
|
|
1729
|
+
className: j["bsy-lexical-ai__column-body"],
|
|
1730
|
+
options: Gr,
|
|
1731
|
+
children: /* @__PURE__ */ N(Hr, { html: o })
|
|
1732
|
+
})]
|
|
1733
|
+
}), /* @__PURE__ */ P("div", {
|
|
1734
|
+
className: j["bsy-lexical-ai__column"],
|
|
1735
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1736
|
+
className: B(j["bsy-lexical-ai__column-title"], j["bsy-lexical-ai__column-title--after"]),
|
|
1737
|
+
children: [/* @__PURE__ */ N("span", { className: j["bsy-lexical-ai__column-dot"] }), u("editor.aiOptimized")]
|
|
1738
|
+
}), /* @__PURE__ */ P("div", {
|
|
1739
|
+
className: j["bsy-lexical-ai__column-stack"],
|
|
1740
|
+
children: [g.visible ? /* @__PURE__ */ N("div", {
|
|
1741
|
+
className: j["bsy-lexical-ai__think-pin"],
|
|
1742
|
+
children: /* @__PURE__ */ N(Br, { model: g })
|
|
1743
|
+
}) : null, /* @__PURE__ */ P(i, {
|
|
1744
|
+
className: j["bsy-lexical-ai__column-body"],
|
|
1745
|
+
options: Gr,
|
|
1746
|
+
viewportRef: p,
|
|
1747
|
+
onScroll: g.onViewportScroll,
|
|
1748
|
+
children: [e === "error" ? /* @__PURE__ */ N("div", {
|
|
1749
|
+
className: j["bsy-lexical-ai__error"],
|
|
1750
|
+
children: a || u("editor.aiError")
|
|
1751
|
+
}) : /* @__PURE__ */ N(Vr, { model: g }), m ? /* @__PURE__ */ N(Hr, { html: s }) : null]
|
|
1752
|
+
})]
|
|
1753
|
+
})]
|
|
1754
|
+
})]
|
|
1755
|
+
}), /* @__PURE__ */ P("div", {
|
|
1756
|
+
className: j["bsy-lexical-ai__footer"],
|
|
1757
|
+
children: [/* @__PURE__ */ N(Te, {
|
|
1758
|
+
onClick: () => f(!1),
|
|
1759
|
+
children: u("editor.aiAbandon")
|
|
1760
|
+
}), /* @__PURE__ */ N(Te, {
|
|
1761
|
+
type: "primary",
|
|
1762
|
+
disabled: !h,
|
|
1763
|
+
onClick: () => l() && f(!1),
|
|
1764
|
+
children: u("editor.aiApply")
|
|
1765
|
+
})]
|
|
1766
|
+
})]
|
|
1767
|
+
})
|
|
1768
|
+
});
|
|
1769
|
+
}, qr = (e) => !e || O(e) ? e : te(E(e));
|
|
1770
|
+
function Jr(e, t, n, r) {
|
|
1771
|
+
let [i, a] = z(""), o = R({
|
|
1772
|
+
originalHtml: t,
|
|
1773
|
+
text: n
|
|
1774
|
+
});
|
|
1775
|
+
o.current = {
|
|
1776
|
+
originalHtml: t,
|
|
1777
|
+
text: n
|
|
1778
|
+
};
|
|
1779
|
+
let s = R(null);
|
|
1780
|
+
return we(() => {
|
|
1781
|
+
let t = () => {
|
|
1782
|
+
s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
|
|
1783
|
+
};
|
|
1784
|
+
if (!e) {
|
|
1785
|
+
t(), a("");
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
let n = () => {
|
|
1789
|
+
s.current = null;
|
|
1790
|
+
let e = o.current;
|
|
1791
|
+
a(qr(w(e.originalHtml, e.text)));
|
|
1792
|
+
};
|
|
1793
|
+
if (r === "ready" || r === "error") {
|
|
1794
|
+
t(), n();
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
s.current === null && (s.current = requestAnimationFrame(n));
|
|
1798
|
+
}, [
|
|
1799
|
+
e,
|
|
1800
|
+
t,
|
|
1801
|
+
r,
|
|
1802
|
+
n
|
|
1803
|
+
]), I(() => () => {
|
|
1804
|
+
s.current !== null && cancelAnimationFrame(s.current);
|
|
1805
|
+
}, []), i;
|
|
1806
|
+
}
|
|
1807
|
+
var Yr = ({ maxLength: e, onMaxLengthExceed: t }) => {
|
|
1808
|
+
let [r] = G(), { aiOpen: i, setAiOpen: a, aiSessionRef: o, stop: s, polish: l } = le(), { t: u } = n(), [d, f] = Ee.useMessage(), p = o.current, { text: m, reasoning: h, status: g, errorMessage: _ } = c(), v = !g || g === "idle" ? "loading" : g, y = m, b = qr(i === "typeset" ? Fr(y, p?.codeBlocks ?? []) : ""), x = qr(p?.originalHtml || ""), S = i === "polish" ? qr(p?.originalHtml || "") : "", C = Jr(i === "polish", p?.originalHtml || "", y, v);
|
|
1809
|
+
I(() => {
|
|
1810
|
+
if (i) return r.setEditable(!1), r.update(() => {
|
|
1811
|
+
tt(null);
|
|
1812
|
+
}), window.getSelection()?.removeAllRanges(), r.getRootElement()?.blur(), () => {
|
|
1813
|
+
r.setEditable(!0);
|
|
1814
|
+
};
|
|
1815
|
+
}, [i, r]);
|
|
1816
|
+
let w = F(() => {
|
|
1817
|
+
s?.(), o.current = null, a(null);
|
|
1818
|
+
}, [
|
|
1819
|
+
o,
|
|
1820
|
+
a,
|
|
1821
|
+
s
|
|
1822
|
+
]), T = F(() => {
|
|
1823
|
+
if (i !== "typeset" || v !== "ready") return !1;
|
|
1824
|
+
r.setEditable(!0);
|
|
1825
|
+
let { applied: n, truncated: a } = Ir(r, y, o.current?.codeBlocks ?? [], e);
|
|
1826
|
+
return n ? (a && t?.(), !0) : (r.setEditable(!1), d.warning(u("editor.aiApplyEmpty")), !1);
|
|
1827
|
+
}, [
|
|
1828
|
+
i,
|
|
1829
|
+
o,
|
|
1830
|
+
r,
|
|
1831
|
+
e,
|
|
1832
|
+
d,
|
|
1833
|
+
t,
|
|
1834
|
+
v,
|
|
1835
|
+
u,
|
|
1836
|
+
y
|
|
1837
|
+
]), E = F(() => i !== "polish" || v !== "ready" ? !1 : oe(r, y) ? !0 : (d.warning(u("editor.aiApplyEmpty")), !1), [
|
|
1838
|
+
i,
|
|
1839
|
+
r,
|
|
1840
|
+
d,
|
|
1841
|
+
v,
|
|
1842
|
+
u,
|
|
1843
|
+
y
|
|
1844
|
+
]), D = F((e) => {
|
|
1845
|
+
let t = o.current;
|
|
1846
|
+
!t?.originalText || !l || (t.preset = e, s?.(), l({
|
|
1847
|
+
text: t.originalText,
|
|
1848
|
+
preset: e
|
|
1849
|
+
}));
|
|
1850
|
+
}, [
|
|
1851
|
+
o,
|
|
1852
|
+
l,
|
|
1853
|
+
s
|
|
1854
|
+
]);
|
|
1855
|
+
return i ? /* @__PURE__ */ P(ve, { children: [f, i === "typeset" ? /* @__PURE__ */ N(Kr, {
|
|
1856
|
+
status: v,
|
|
1857
|
+
reasoning: h,
|
|
1858
|
+
errorMessage: _,
|
|
1859
|
+
originalHtml: x,
|
|
1860
|
+
proposedHtml: b,
|
|
1861
|
+
onCancel: w,
|
|
1862
|
+
onApply: T
|
|
1863
|
+
}) : /* @__PURE__ */ N(Wr, {
|
|
1864
|
+
status: v,
|
|
1865
|
+
reasoning: h,
|
|
1866
|
+
errorMessage: _,
|
|
1867
|
+
originalHtml: S,
|
|
1868
|
+
proposedHtml: C,
|
|
1869
|
+
preset: p?.preset ?? "quick",
|
|
1870
|
+
onPresetChange: D,
|
|
1871
|
+
onCancel: w,
|
|
1872
|
+
onApply: E
|
|
1873
|
+
})] }) : f;
|
|
1874
|
+
}, Xr = [], Zr = (e) => {
|
|
1875
|
+
let { height: t = "auto", minHeight: n, onChange: r, toolbar: i, theme: a, maxLength: o, onMaxLengthExceed: s, upload: c, ai: l } = e, [u] = G(), { isSourceMode: d, isSourceModeRef: f } = M(), p = R(null), m = R(null), h = R(/* @__PURE__ */ new Map()), g = R(null), _ = R(null), v = R(s);
|
|
1876
|
+
v.current = s;
|
|
1877
|
+
let b = Qn(o) ? o : void 0, [x, S] = z(0), [C, w] = z(null), T = i?.mode === "floating", D = b !== void 0 && !d, O = R(l);
|
|
1878
|
+
O.current = l;
|
|
1879
|
+
let k = R(r);
|
|
1880
|
+
k.current = r;
|
|
1881
|
+
let A = F((e) => {
|
|
1882
|
+
O.current?.typeset?.(e);
|
|
1883
|
+
}, []), ee = F((e) => {
|
|
1884
|
+
O.current?.polish?.(e);
|
|
1885
|
+
}, []), re = F(() => {
|
|
1886
|
+
O.current?.stop?.();
|
|
1887
|
+
}, []), j = !!l?.typeset, ae = !!l?.polish, oe = L(() => ({
|
|
1888
|
+
containerRef: p,
|
|
1889
|
+
toolbarRef: m,
|
|
1890
|
+
upload: c,
|
|
1891
|
+
aiOpen: C,
|
|
1892
|
+
setAiOpen: w,
|
|
1893
|
+
aiSessionRef: g,
|
|
1894
|
+
attachmentsBySrcRef: h,
|
|
1895
|
+
typeset: A,
|
|
1896
|
+
polish: ee,
|
|
1897
|
+
stop: re,
|
|
1898
|
+
canTypeset: j,
|
|
1899
|
+
canPolish: ae
|
|
1900
|
+
}), [
|
|
1901
|
+
C,
|
|
1902
|
+
ae,
|
|
1903
|
+
j,
|
|
1904
|
+
ee,
|
|
1905
|
+
re,
|
|
1906
|
+
A,
|
|
1907
|
+
c
|
|
1908
|
+
]), se = L(() => ({
|
|
1909
|
+
text: l?.text ?? "",
|
|
1910
|
+
reasoning: l?.reasoning,
|
|
1911
|
+
status: l?.status,
|
|
1912
|
+
errorMessage: l?.errorMessage
|
|
1913
|
+
}), [
|
|
1914
|
+
l?.text,
|
|
1915
|
+
l?.reasoning,
|
|
1916
|
+
l?.status,
|
|
1917
|
+
l?.errorMessage
|
|
1918
|
+
]), ce = F((e) => {
|
|
1919
|
+
f.current || e.read(() => {
|
|
1920
|
+
let t = H().getTextContent(), n = te(E(Re(u, null))), r = ie(n, t) ? null : n;
|
|
1921
|
+
_.current = r, b !== void 0 && S(t.length);
|
|
1922
|
+
let i = $e(nn).map((e) => h.current.get(e.getSrc())).filter((e) => e !== void 0);
|
|
1923
|
+
k.current({
|
|
1293
1924
|
text: t,
|
|
1294
|
-
html:
|
|
1925
|
+
html: r,
|
|
1926
|
+
attachment: i
|
|
1295
1927
|
}, e);
|
|
1296
|
-
}, { editor:
|
|
1928
|
+
}, { editor: u });
|
|
1297
1929
|
}, [
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
u
|
|
1930
|
+
u,
|
|
1931
|
+
b,
|
|
1932
|
+
f
|
|
1302
1933
|
]);
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
}, { editor:
|
|
1934
|
+
I(() => {
|
|
1935
|
+
b === void 0 || d || u.getEditorState().read(() => {
|
|
1936
|
+
S(H().getTextContentSize());
|
|
1937
|
+
}, { editor: u });
|
|
1307
1938
|
}, [
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
]),
|
|
1312
|
-
if (e.value === void 0 || e.value ===
|
|
1313
|
-
if (
|
|
1314
|
-
let t = e.value?.trim() ?
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
});
|
|
1319
|
-
}), p.current = e.value;
|
|
1939
|
+
u,
|
|
1940
|
+
b,
|
|
1941
|
+
d
|
|
1942
|
+
]), I(() => {
|
|
1943
|
+
if (e.value === void 0 || e.value === _.current) return;
|
|
1944
|
+
if (f.current) {
|
|
1945
|
+
let t = e.value?.trim() ? E(e.value) : "";
|
|
1946
|
+
_.current = e.value, u.update(() => {
|
|
1947
|
+
dr(ur(t));
|
|
1948
|
+
});
|
|
1320
1949
|
return;
|
|
1321
1950
|
}
|
|
1322
1951
|
let t = !1;
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
}), t &&
|
|
1952
|
+
u.update(() => {
|
|
1953
|
+
ne(u, e.value?.trim() ? E(e.value) : ""), b !== void 0 && (t = $n(u, b));
|
|
1954
|
+
}), t && v.current?.();
|
|
1326
1955
|
}, [
|
|
1327
1956
|
e.value,
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1957
|
+
u,
|
|
1958
|
+
b,
|
|
1959
|
+
f
|
|
1331
1960
|
]);
|
|
1332
|
-
let
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1961
|
+
let le = i?.config?.length ? i.config : Xr, de = F(() => {
|
|
1962
|
+
v.current?.();
|
|
1963
|
+
}, []);
|
|
1964
|
+
return /* @__PURE__ */ N(y.Provider, {
|
|
1965
|
+
value: oe,
|
|
1966
|
+
children: /* @__PURE__ */ P(ue.Provider, {
|
|
1967
|
+
value: se,
|
|
1968
|
+
children: [/* @__PURE__ */ N(Qr, {
|
|
1969
|
+
containerRef: p,
|
|
1970
|
+
isFloating: T,
|
|
1971
|
+
toolbarConfig: le,
|
|
1972
|
+
toolbarTheme: a?.toolbar,
|
|
1973
|
+
toolbarStyle: i?.style,
|
|
1974
|
+
toolbarSize: i?.size,
|
|
1975
|
+
toolbarMode: i?.mode,
|
|
1976
|
+
toolbarFloating: i?.floating,
|
|
1977
|
+
height: t,
|
|
1978
|
+
minHeight: n,
|
|
1979
|
+
showLengthBadge: D,
|
|
1980
|
+
textLength: x,
|
|
1981
|
+
validMaxLength: b,
|
|
1982
|
+
onMaxLengthExceed: de,
|
|
1983
|
+
onChange: ce
|
|
1984
|
+
}), /* @__PURE__ */ N(Yr, {
|
|
1985
|
+
maxLength: b,
|
|
1986
|
+
onMaxLengthExceed: de
|
|
1987
|
+
})]
|
|
1988
|
+
})
|
|
1989
|
+
});
|
|
1990
|
+
}, Qr = xe(function({ containerRef: e, isFloating: t, toolbarConfig: n, toolbarTheme: r, toolbarStyle: i, toolbarSize: a, toolbarMode: o, toolbarFloating: s, height: c, minHeight: l, showLengthBadge: u, textLength: d, validMaxLength: f, onMaxLengthExceed: p, onChange: m }) {
|
|
1991
|
+
let [h] = G(), g = Qt(), _ = typeof c == "number" ? c : void 0;
|
|
1992
|
+
return /* @__PURE__ */ P("div", {
|
|
1993
|
+
ref: e,
|
|
1994
|
+
className: B("bsy-lexical-editor", Z["bsy-lexical-editor"], t && Z["bsy-lexical-editor--floating"]),
|
|
1995
|
+
onClick: (e) => {
|
|
1996
|
+
let t = h.getRootElement(), n = e.target;
|
|
1997
|
+
!t || !n || !t.contains(n) || h.isEditable() || h.setEditable(!0);
|
|
1998
|
+
},
|
|
1999
|
+
children: [
|
|
2000
|
+
n && n.length > 0 ? /* @__PURE__ */ N(xn, {
|
|
2001
|
+
config: n,
|
|
2002
|
+
theme: r,
|
|
2003
|
+
style: i,
|
|
2004
|
+
size: a,
|
|
2005
|
+
mode: o,
|
|
2006
|
+
floating: s
|
|
2007
|
+
}) : null,
|
|
2008
|
+
/* @__PURE__ */ P("div", {
|
|
2009
|
+
className: B(Z["bsy-lexical-editor__body"], _ !== void 0 && Z["bsy-lexical-editor__body--fixed"]),
|
|
2010
|
+
style: { height: _ },
|
|
2011
|
+
children: [/* @__PURE__ */ N("div", {
|
|
2012
|
+
className: Z["bsy-lexical-editor__editable-wrap"],
|
|
2013
|
+
children: /* @__PURE__ */ N(Ne, {
|
|
2014
|
+
contentEditable: /* @__PURE__ */ N(Pe, {
|
|
2015
|
+
className: Z["bsy-lexical-editor__content-editable"],
|
|
1356
2016
|
style: {
|
|
1357
|
-
minHeight:
|
|
1358
|
-
cursor:
|
|
2017
|
+
minHeight: _ === void 0 ? l : void 0,
|
|
2018
|
+
cursor: g ? "auto" : "text"
|
|
1359
2019
|
}
|
|
1360
2020
|
}),
|
|
1361
|
-
ErrorBoundary:
|
|
1362
|
-
})
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
})
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
2021
|
+
ErrorBoundary: Le
|
|
2022
|
+
})
|
|
2023
|
+
}), u && f !== void 0 ? /* @__PURE__ */ N(hr, {
|
|
2024
|
+
current: d,
|
|
2025
|
+
maxLength: f
|
|
2026
|
+
}) : null]
|
|
2027
|
+
}),
|
|
2028
|
+
/* @__PURE__ */ N($t, {}),
|
|
2029
|
+
/* @__PURE__ */ N(en, {}),
|
|
2030
|
+
/* @__PURE__ */ N(Tn, {}),
|
|
2031
|
+
/* @__PURE__ */ N(mr, {}),
|
|
2032
|
+
/* @__PURE__ */ N(En, {}),
|
|
2033
|
+
/* @__PURE__ */ N(kn, {}),
|
|
2034
|
+
/* @__PURE__ */ N(An, {}),
|
|
2035
|
+
/* @__PURE__ */ N(qn, {}),
|
|
2036
|
+
/* @__PURE__ */ N(Jn, {}),
|
|
2037
|
+
/* @__PURE__ */ N(Xn, {}),
|
|
2038
|
+
u && f !== void 0 ? /* @__PURE__ */ N(Zn, {
|
|
2039
|
+
maxLength: f,
|
|
2040
|
+
onMaxLengthExceed: p
|
|
2041
|
+
}) : null,
|
|
2042
|
+
/* @__PURE__ */ N(Fe, {}),
|
|
2043
|
+
/* @__PURE__ */ N(Ie, {
|
|
2044
|
+
onChange: m,
|
|
2045
|
+
ignoreSelectionChange: !0
|
|
2046
|
+
})
|
|
2047
|
+
]
|
|
1385
2048
|
});
|
|
1386
|
-
},
|
|
2049
|
+
}), $r = (e) => /* @__PURE__ */ N(fr, {
|
|
1387
2050
|
maxLength: e.maxLength,
|
|
1388
2051
|
onMaxLengthExceed: e.onMaxLengthExceed,
|
|
1389
|
-
children: /* @__PURE__ */
|
|
2052
|
+
children: /* @__PURE__ */ N(Zr, { ...e })
|
|
1390
2053
|
});
|
|
1391
|
-
|
|
2054
|
+
$r.displayName = "BsyLexicalEditorCore";
|
|
1392
2055
|
//#endregion
|
|
1393
2056
|
//#region src/components/Editor/htmlConfig.ts
|
|
1394
|
-
var
|
|
2057
|
+
var ei = "1px solid #d9d9d9", ti = { export: new Map([[Ut, (e, t) => {
|
|
1395
2058
|
let n = t.exportDOM(e);
|
|
1396
|
-
return
|
|
1397
|
-
}]]) },
|
|
2059
|
+
return _t(n.element) && (n.element.style.border = ei), n;
|
|
2060
|
+
}]]) }, ni = (e) => {
|
|
1398
2061
|
let { autoFocus: t = !1 } = e;
|
|
1399
|
-
return /* @__PURE__ */
|
|
1400
|
-
initialConfig:
|
|
2062
|
+
return /* @__PURE__ */ N(Me, {
|
|
2063
|
+
initialConfig: L(() => ({
|
|
1401
2064
|
namespace: "bsyLexicalEditor",
|
|
1402
2065
|
onError: (e) => {
|
|
1403
2066
|
console.error("Lexical error", e);
|
|
@@ -1433,30 +2096,30 @@ var Gn = "1px solid #d9d9d9", Kn = { export: new Map([[q, (e, t) => {
|
|
|
1433
2096
|
tableRow: "editor-table-row",
|
|
1434
2097
|
tableScrollableWrapper: "editor-table-scrollable-wrapper"
|
|
1435
2098
|
},
|
|
1436
|
-
html:
|
|
2099
|
+
html: ti,
|
|
1437
2100
|
nodes: [
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
ft,
|
|
1446
|
-
pt,
|
|
1447
|
-
q,
|
|
2101
|
+
Dt,
|
|
2102
|
+
Et,
|
|
2103
|
+
At,
|
|
2104
|
+
kt,
|
|
2105
|
+
Zt,
|
|
2106
|
+
It,
|
|
2107
|
+
Ft,
|
|
1448
2108
|
Wt,
|
|
1449
|
-
|
|
2109
|
+
Gt,
|
|
2110
|
+
Ut,
|
|
2111
|
+
nn,
|
|
2112
|
+
Q,
|
|
1450
2113
|
{
|
|
1451
|
-
replace:
|
|
1452
|
-
with: (e) => new
|
|
1453
|
-
withKlass:
|
|
2114
|
+
replace: gt,
|
|
2115
|
+
with: (e) => new Q(e.__text),
|
|
2116
|
+
withKlass: Q
|
|
1454
2117
|
}
|
|
1455
2118
|
]
|
|
1456
2119
|
}), [t]),
|
|
1457
|
-
children: /* @__PURE__ */
|
|
2120
|
+
children: /* @__PURE__ */ N($r, { ...e })
|
|
1458
2121
|
});
|
|
1459
2122
|
};
|
|
1460
|
-
|
|
2123
|
+
ni.displayName = "BsyLexicalEditor";
|
|
1461
2124
|
//#endregion
|
|
1462
|
-
export {
|
|
2125
|
+
export { Ke as $getRoot, u as BaseButton, ni as default, ae as listRegisteredToolbarButtons, k as registerToolbarButton, S as unregisterToolbarButton, yt as useLexicalComposerContext };
|