@baishuyun/ui-base 6.11.1 → 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.
Files changed (153) hide show
  1. package/dist/Amap/AmapCircle/index.js +1 -1
  2. package/dist/Amap/AmapMarker/index.js +1 -1
  3. package/dist/Amap/AmapMarkerCluster/index.js +1 -1
  4. package/dist/Amap/AmapProvider/index.js +4 -4
  5. package/dist/Amap/{AmapProvider-CvRHhN42.js → AmapProvider-BwyzXpEj.js} +1 -1
  6. package/dist/Amap/hooks/index.js +1 -1
  7. package/dist/Amap/index.js +4 -4
  8. package/dist/Calendar/{AllDaySection-CTaXpCmK.js → AllDaySection-D9YHhwIa.js} +1 -1
  9. package/dist/Calendar/{Calendar-BAojDII3.js → Calendar-DEjopu9G.js} +5 -5
  10. package/dist/Calendar/{TimeGrid-Ci8Dfama.js → TimeGrid-5zMy9Hks.js} +1 -1
  11. package/dist/Calendar/context/index.js +1 -1
  12. package/dist/Calendar/index.js +8 -8
  13. package/dist/Calendar/subcomponents/AllDaySection/index.js +3 -3
  14. package/dist/Calendar/subcomponents/CurrentTimeIndicator/index.js +1 -1
  15. package/dist/Calendar/subcomponents/EventCard/index.js +1 -1
  16. package/dist/Calendar/subcomponents/TimeAxis/index.js +1 -1
  17. package/dist/Calendar/subcomponents/TimeGrid/index.js +3 -3
  18. package/dist/Calendar/utils/index.js +1 -1
  19. package/dist/Calendar/utils/layout/index.js +1 -1
  20. package/dist/Calendar/utils/theme/index.js +1 -1
  21. package/dist/Card/{Card-C8A4XaJZ.js → Card-DDbQQsCc.js} +1 -1
  22. package/dist/Card/index.js +3 -3
  23. package/dist/CheckBox/{CheckBox-DBzTOuRy.js → CheckBox-CwfrMEFb.js} +1 -1
  24. package/dist/CheckBox/{CheckBox-Dt4x6IqH.js → CheckBox-DFfNiPGM.js} +1 -1
  25. package/dist/CheckBox/index.js +4 -4
  26. package/dist/ColorPicker/{ColorPicker-Buku806Y.js → ColorPicker-Cm_-e0Hz.js} +34 -31
  27. package/dist/ColorPicker/index.js +5 -5
  28. package/dist/ConfigProvider/index.js +3 -3
  29. package/dist/DatePicker/{DatePicker-E9HxZcGE.js → DatePicker-BUvDkVjx.js} +9 -9
  30. package/dist/DatePicker/{DatePickerPanel-DM5Bje8r.js → DatePickerPanel-BHTPcE6R.js} +4 -4
  31. package/dist/DatePicker/index.js +4 -4
  32. package/dist/DatePicker/style/index.js +1 -1
  33. package/dist/DropDown/DropDown-DV1IuuQD.js +290 -0
  34. package/dist/DropDown/index.js +7 -7
  35. package/dist/DropDown/style/index.js +1 -1
  36. package/dist/Editor/Buttons-BUC9qQY1.js +1732 -0
  37. package/dist/Editor/ToolbarPlugin/Buttons/index.js +12 -12
  38. package/dist/Editor/constants/index.js +10 -3
  39. package/dist/Editor/index.js +1574 -907
  40. package/dist/Gantt/GanttChart/index.js +9 -9
  41. package/dist/Gantt/{GanttChart-WIrD6Z7O.js → GanttChart-DEGOIgRD.js} +3 -3
  42. package/dist/Gantt/GanttTable/index.js +5 -5
  43. package/dist/Gantt/{GanttTable-CdXhMHF6.js → GanttTable-Dwb00N8Z.js} +1 -1
  44. package/dist/Gantt/GanttToolBar/index.js +8 -8
  45. package/dist/Gantt/{GanttToolBar-C1gAS9v2.js → GanttToolBar-BcJB6sKY.js} +3 -3
  46. package/dist/Gantt/index.js +11 -11
  47. package/dist/Gantt/utils/index.js +1 -1
  48. package/dist/Gantt/utils/theme/index.js +1 -1
  49. package/dist/Icon/{Icon-oQ_uBooE.js → Icon-DDHx0R18.js} +1 -1
  50. package/dist/Icon/index.js +2 -2
  51. package/dist/InputTag/{InputTag-BQpIRPtc.js → InputTag-CBnG1R7g.js} +2 -2
  52. package/dist/InputTag/index.js +5 -5
  53. package/dist/Loading/{Loading-CiRe7i2R.js → Loading-DYayeRbT.js} +1 -1
  54. package/dist/Loading/index.js +4 -4
  55. package/dist/Modal/{Modal-17rLsxN4.js → Modal-BnF6CUrn.js} +20 -17
  56. package/dist/Modal/index.js +3 -3
  57. package/dist/NotFoundContent/index.js +1 -1
  58. package/dist/Overlay/index.js +1 -1
  59. package/dist/Radio/index.js +1 -1
  60. package/dist/ScrollBar/index.js +1 -1
  61. package/dist/Segmented/index.js +1 -1
  62. package/dist/Select/{Select-p_ly7xmz.js → Select-CG5wFTL4.js} +13 -13
  63. package/dist/Select/{SelectInputSearch-BBwVIb8u.js → SelectInputSearch-DiuwwOWz.js} +2 -2
  64. package/dist/Select/index.js +10 -10
  65. package/dist/Table/{Table-CSPdFGYn.js → Table-B7J-IK2_.js} +1 -1
  66. package/dist/Table/hooks/index.js +1 -1
  67. package/dist/Table/index.js +4 -4
  68. package/dist/Table/style/index.js +1 -1
  69. package/dist/Table/utils/index.js +1 -1
  70. package/dist/Tabs/{Tabs-D2A8nJl8.js → Tabs-CObQtF37.js} +7 -7
  71. package/dist/Tabs/index.js +6 -6
  72. package/dist/Tooltip/index.js +1 -1
  73. package/dist/Tree/index.js +4 -4
  74. package/dist/Tree/utils/index.js +1 -1
  75. package/dist/components/ColorPicker/ColorPicker.type.d.ts +2 -0
  76. package/dist/components/ColorPicker/useFloatingColorPicker.d.ts +1 -1
  77. package/dist/components/DropDown/DropDownOpenContext.d.ts +4 -0
  78. package/dist/components/DropDown/MenuItem/MenuItem.d.ts +4 -0
  79. package/dist/components/DropDown/interface.d.ts +5 -1
  80. package/dist/components/Editor/Preview/EditorPreview.d.ts +9 -0
  81. package/dist/components/Editor/Preview/HtmlPreview.d.ts +5 -0
  82. package/dist/components/Editor/Preview/PolishModal.d.ts +14 -0
  83. package/dist/components/Editor/Preview/Thinking.d.ts +23 -0
  84. package/dist/components/Editor/Preview/TypesetModal.d.ts +12 -0
  85. package/dist/components/Editor/ToolbarPlugin/BaseButton/BaseButton.d.ts +5 -1
  86. package/dist/components/Editor/ToolbarPlugin/Buttons/AiButton.d.ts +3 -0
  87. package/dist/components/Editor/ToolbarPlugin/Buttons/AlignButton.d.ts +2 -1
  88. package/dist/components/Editor/ToolbarPlugin/Buttons/BoldButton.d.ts +2 -1
  89. package/dist/components/Editor/ToolbarPlugin/Buttons/BulletListButton.d.ts +2 -1
  90. package/dist/components/Editor/ToolbarPlugin/Buttons/ClearFormatButton.d.ts +3 -0
  91. package/dist/components/Editor/ToolbarPlugin/Buttons/CodeButton.d.ts +2 -1
  92. package/dist/components/Editor/ToolbarPlugin/Buttons/FillButton.d.ts +2 -1
  93. package/dist/components/Editor/ToolbarPlugin/Buttons/FontColorButton.d.ts +2 -1
  94. package/dist/components/Editor/ToolbarPlugin/Buttons/FontSizeButton.d.ts +2 -1
  95. package/dist/components/Editor/ToolbarPlugin/Buttons/HeadingButton.d.ts +2 -1
  96. package/dist/components/Editor/ToolbarPlugin/Buttons/IndentButton.d.ts +2 -1
  97. package/dist/components/Editor/ToolbarPlugin/Buttons/ItalicButton.d.ts +2 -1
  98. package/dist/components/Editor/ToolbarPlugin/Buttons/LinkButton.d.ts +2 -1
  99. package/dist/components/Editor/ToolbarPlugin/Buttons/NumberListButton.d.ts +2 -1
  100. package/dist/components/Editor/ToolbarPlugin/Buttons/OutdentButton.d.ts +2 -1
  101. package/dist/components/Editor/ToolbarPlugin/Buttons/PictureButton/PictureButton.d.ts +2 -1
  102. package/dist/components/Editor/ToolbarPlugin/Buttons/PictureButton/UploadImage.d.ts +1 -0
  103. package/dist/components/Editor/ToolbarPlugin/Buttons/RedoButton.d.ts +2 -1
  104. package/dist/components/Editor/ToolbarPlugin/Buttons/SourceButton.d.ts +2 -1
  105. package/dist/components/Editor/ToolbarPlugin/Buttons/StrikeThroughButton.d.ts +2 -1
  106. package/dist/components/Editor/ToolbarPlugin/Buttons/SubscriptButton.d.ts +2 -1
  107. package/dist/components/Editor/ToolbarPlugin/Buttons/SuperscriptButton.d.ts +2 -1
  108. package/dist/components/Editor/ToolbarPlugin/Buttons/TableButton.d.ts +2 -1
  109. package/dist/components/Editor/ToolbarPlugin/Buttons/UnLinkButton.d.ts +2 -1
  110. package/dist/components/Editor/ToolbarPlugin/Buttons/UnderLineButton.d.ts +2 -1
  111. package/dist/components/Editor/ToolbarPlugin/Buttons/UndoButton.d.ts +2 -1
  112. package/dist/components/Editor/ToolbarPlugin/Buttons/index.d.ts +26 -23
  113. package/dist/components/Editor/ToolbarPlugin/Buttons/registry.d.ts +4 -1
  114. package/dist/components/Editor/ToolbarPlugin/context/TextFormatsContext.d.ts +1 -0
  115. package/dist/components/Editor/ToolbarPlugin/interface.d.ts +2 -2
  116. package/dist/components/Editor/constants/ai.d.ts +12 -0
  117. package/dist/components/Editor/constants/index.d.ts +3 -0
  118. package/dist/components/Editor/constants/portableEditorStyles.d.ts +11 -0
  119. package/dist/components/Editor/constants/toolbarSize.d.ts +12 -0
  120. package/dist/components/Editor/context/EditorContainerContext.d.ts +27 -1
  121. package/dist/components/Editor/index.d.ts +2 -2
  122. package/dist/components/Editor/interface.d.ts +69 -15
  123. package/dist/components/Editor/utils/applyAiPolish.d.ts +8 -0
  124. package/dist/components/Editor/utils/applyAiTypeset.d.ts +5 -0
  125. package/dist/components/Editor/utils/clearInlineTextFormat.d.ts +1 -0
  126. package/dist/components/Editor/utils/computeToolbarOverflowSplit.d.ts +12 -0
  127. package/dist/components/Editor/utils/extractCodePlaceholders.d.ts +6 -0
  128. package/dist/components/Editor/utils/formatEditorHtml.d.ts +1 -1
  129. package/dist/components/Editor/utils/htmlText.d.ts +2 -0
  130. package/dist/components/Editor/utils/prepareTypesetProposed.d.ts +2 -0
  131. package/dist/components/Editor/utils/readEditorAiSnapshot.d.ts +9 -0
  132. package/dist/components/Editor/utils/resolveEditorAlign.d.ts +3 -0
  133. package/dist/components/Editor/utils/resolveEditorImageUpload.d.ts +8 -0
  134. package/dist/components/Editor/utils/resolveEditorToolbarThemeVars.d.ts +5 -5
  135. package/dist/components/Editor/utils/stitchCodePlaceholders.d.ts +6 -0
  136. package/dist/components/Editor/utils/toPortableEditorHtml.d.ts +1 -0
  137. package/dist/components/Editor/utils/unwrapTypesetFence.d.ts +5 -0
  138. package/dist/components/Modal/Modal.type.d.ts +1 -0
  139. package/dist/hooks/useFloatingPortal.d.ts +2 -0
  140. package/dist/index.js +24 -24
  141. package/dist/locale/lang/en-US.json.d.ts +22 -2
  142. package/dist/locale/lang/zh-CN.json.d.ts +22 -2
  143. package/dist/locale/lang/zh-TW.json.d.ts +22 -2
  144. package/dist/style.css +1 -1
  145. package/dist/vendors/{ConfigProvider-4xHyyeop.js → ConfigProvider-BDyxjj6K.js} +45 -5
  146. package/dist/vendors/{LocaleContext-I4PW9j4M.js → LocaleContext-w5ODGcJX.js} +22 -2
  147. package/dist/vendors/{Tree-B8cR9y6U.js → Tree-B7XeC9Mi.js} +2 -2
  148. package/dist/vendors/{useFloatingPortal-CmVJbuRm.js → useFloatingPortal-B3N1viK2.js} +8 -7
  149. package/dist/vendors/{useLocale-FGYsRWSe.js → useLocale-CEDl6cUK.js} +1 -1
  150. package/dist/vendors/{version-DU4mlk3q.js → version-B14EcH7v.js} +1 -1
  151. package/package.json +2 -3
  152. package/dist/DropDown/DropDown-CuL1Qq25.js +0 -178
  153. package/dist/Editor/Buttons-CMkFTv6y.js +0 -1016
@@ -1,64 +1,311 @@
1
- import "../vendors/version-DU4mlk3q.js";
1
+ import "../vendors/version-B14EcH7v.js";
2
2
  import "../ScrollBar/style-D26azwz6.js";
3
- import { t as e } from "../Icon/Icon-oQ_uBooE.js";
4
- import "../vendors/LocaleContext-I4PW9j4M.js";
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-17rLsxN4.js";
7
- import "../ColorPicker/ColorPicker-Buku806Y.js";
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-FGYsRWSe.js";
9
+ import { t as n } from "../vendors/useLocale-CEDl6cUK.js";
10
10
  import "../vendors/useLatchedPopupPortalRoot-4fVhqVT4.js";
11
- import { t as n } from "../vendors/cssVars-l4-kP_14.js";
12
- import "../Select/SelectInputSearch-BBwVIb8u.js";
13
- import "../CheckBox/CheckBox-Dt4x6IqH.js";
14
- import "../CheckBox/CheckBox-DBzTOuRy.js";
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-CmVJbuRm.js";
18
- import { t as r } from "../DropDown/DropDown-CuL1Qq25.js";
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 i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as v, s as y, u as b, v as x, y as ee } from "./Buttons-CMkFTv6y.js";
21
- import { DEFAULT_BACKGROUND_COLOR as te, DEFAULT_FONT_COLOR as ne, DEFAULT_FONT_SIZE as re } from "./constants/index.js";
22
- import { omit as ie } from "lodash-es";
23
- import { Fragment as ae, jsx as S, jsxs as C } from "react/jsx-runtime";
24
- import oe, { createContext as se, useCallback as w, useContext as ce, useEffect as T, useMemo as E, useRef as D, useState as O } from "react";
25
- import k from "clsx";
26
- import { AnimatePresence as le, motion as ue, useReducedMotion as de } from "motion/react";
27
- import { LexicalComposer as fe } from "@lexical/react/LexicalComposer";
28
- import { RichTextPlugin as pe } from "@lexical/react/LexicalRichTextPlugin";
29
- import { ContentEditable as me } from "@lexical/react/LexicalContentEditable";
30
- import { HistoryPlugin as he } from "@lexical/react/LexicalHistoryPlugin";
31
- import { OnChangePlugin as ge } from "@lexical/react/LexicalOnChangePlugin";
32
- import { LexicalErrorBoundary as _e } from "@lexical/react/LexicalErrorBoundary";
33
- import { $generateHtmlFromNodes as ve, $generateNodesFromDOM as ye } from "@lexical/html";
34
- import { $applyNodeReplacement as be, $createLineBreakNode as xe, $createParagraphNode as Se, $createTabNode as Ce, $createTextNode as we, $getNearestNodeFromDOMNode as Te, $getNodeByKey as A, $getRoot as Ee, $getRoot as j, $getSelection as M, $insertNodes as N, $isElementNode as De, $isLineBreakNode as P, $isRangeSelection as F, $isRootOrShadowRoot as Oe, $isTabNode as ke, $isTextNode as Ae, $onUpdate as je, CLEAR_HISTORY_COMMAND as Me, COMMAND_PRIORITY_CRITICAL as Ne, COMMAND_PRIORITY_EDITOR as Pe, COMMAND_PRIORITY_HIGH as I, COMMAND_PRIORITY_LOW as Fe, DROP_COMMAND as Ie, DecoratorNode as Le, HISTORY_MERGE_TAG as Re, INDENT_CONTENT_COMMAND as ze, KEY_ENTER_COMMAND as Be, KEY_TAB_COMMAND as Ve, PASTE_COMMAND as He, PASTE_TAG as Ue, RootNode as We, TextNode as L, isHTMLElement as Ge, mergeRegister as Ke } from "lexical";
35
- import { useLexicalComposerContext as qe, useLexicalComposerContext as R } from "@lexical/react/LexicalComposerContext";
36
- import { $getSelectionStyleValueForProperty as z, $patchStyleText as Je, $trimTextContentFromAnchor as B } from "@lexical/selection";
37
- import { $findMatchingParent as V, $restoreEditorState as Ye, mergeRegister as Xe } from "@lexical/utils";
38
- import { $isLinkNode as Ze, AutoLinkNode as Qe, LinkNode as $e } from "@lexical/link";
39
- import { $isListItemNode as H, $isListNode as et, ListItemNode as tt, ListNode as nt } from "@lexical/list";
40
- import { $createCodeHighlightNode as rt, $createCodeNode as it, $isCodeHighlightNode as at, $isCodeNode as U, $plainifyCodeContent as ot, CodeHighlightNode as W, CodeNode as G, registerCodeIndentation as st } from "@lexical/code-core";
41
- import { $findCellNode as ct, $isTableCellNode as K, $isTableNode as lt, $isTableRowNode as ut, $isTableSelection as dt, TableCellNode as q, TableNode as ft, TableRowNode as pt, registerTableCellUnmergeTransform as mt, registerTablePlugin as ht, registerTableSelectionObserver as gt, setScrollableTablesActive as _t } from "@lexical/table";
42
- import { $isHeadingNode as vt, HeadingNode as yt } from "@lexical/rich-text";
43
- import { useLexicalEditable as bt } from "@lexical/react/useLexicalEditable";
44
- import { LinkPlugin as xt } from "@lexical/react/LexicalLinkPlugin";
45
- import { ListPlugin as St } from "@lexical/react/LexicalListPlugin";
46
- import Ct from "dompurify";
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 J = (e) => {
291
+ var X = (e) => {
49
292
  if (!(e === void 0 || e === "")) return typeof e == "number" ? `${e}px` : e;
50
- }, wt = (e) => {
51
- if (!e) return {};
52
- let t = {};
53
- return n(t, "--bsy-editor-toolbar-bg", e.bg), n(t, "--bsy-editor-toolbar-border-color", e.borderColor), n(t, "--bsy-editor-toolbar-padding", e.padding), n(t, "--bsy-editor-toolbar-gap", J(e.gap)), n(t, "--bsy-editor-toolbar-group-gap", J(e.groupGap)), n(t, "--bsy-editor-toolbar-divider-color", e.dividerColor), n(t, "--bsy-editor-toolbar-divider-size", J(e.dividerSize)), n(t, "--bsy-editor-toolbar-divider-margin", J(e.dividerMargin)), n(t, "--bsy-editor-toolbar-color-icon", e.colorIcon), n(t, "--bsy-editor-toolbar-item-hover-bg", e.itemHoverBg), n(t, "--bsy-editor-toolbar-item-hover-color", e.itemHoverColor), n(t, "--bsy-editor-toolbar-item-active-bg", e.itemActiveBg), n(t, "--bsy-editor-toolbar-item-active-color", e.itemActiveColor), n(t, "--bsy-editor-toolbar-item-padding", J(e.itemPadding)), n(t, "--bsy-editor-toolbar-item-border-radius", J(e.itemBorderRadius)), n(t, "--bsy-editor-toolbar-icon-size", J(e.iconSize)), t;
54
- }, Tt = (e) => {
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 14;
61
- }, Et = (e) => {
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 Dt() {
75
- let [e] = R(), [t, n] = O({
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: re,
83
- fontColor: ne,
84
- backgroundColor: te,
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: i,
354
+ codeLanguage: _,
355
+ hasEditorText: !1,
92
356
  link: void 0
93
357
  });
94
- return T(() => e.registerUpdateListener(({ editorState: e }) => {
358
+ return I(() => e.registerUpdateListener(({ editorState: e }) => {
95
359
  e.read(() => {
96
- let e = M();
97
- if (dt(e)) {
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 (F(e)) {
107
- let t = z(e, "font-size", re), r = z(e, "color", ne), i = z(e, "background-color", te), a = e.anchor.getNode(), o = a.getKey() === "root" ? a : V(a, (e) => {
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 && Oe(t);
374
+ return t !== null && Xe(t);
110
375
  });
111
- o === null && (o = a.getTopLevelElementOrThrow());
112
- let s = {}, c = V(a, Ze);
113
- c ? (s.link = c.getURL(), s.linkText = c.getTextContent(), s.newBlank = c.getTarget() === "_blank") : s.linkText = e.getTextContent();
114
- let l = V(a, H), u = !1, d = De(o) ? o.getIndent() : 0;
115
- if (H(l)) {
116
- d = l.getIndent();
117
- let e = l.getParent();
118
- if (et(e)) {
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
- u = t === "number" || t === "bullet" ? t : !1;
385
+ p = t === "number" || t === "bullet" ? t : !1;
121
386
  }
122
387
  }
123
- let f = V(a, U), p = V(a, vt), m = vt(p) ? p.getTag() : void 0;
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: t,
132
- fontColor: r,
133
- backgroundColor: i,
134
- align: De(o) ? o.getFormatType() : "left",
135
- listType: u,
136
- canOutdent: d > 0 || u !== !1,
137
- isCodeBlock: !!f,
138
- isInTable: !!V(a, K),
139
- headingTag: m === "h1" || m === "h2" || m === "h3" ? m : !1,
140
- codeLanguage: x(f?.getLanguage()),
141
- link: s
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 Ot = (e) => {
150
- let t = Dt();
151
- return /* @__PURE__ */ S(ee.Provider, {
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
- }, kt = se(null), At = () => {
156
- let e = ce(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
- })), Mt = () => {
163
- let [n] = R(), { codeLanguage: i } = p(), { t: a } = t(), { iconSize: s } = l(), c = w((e) => {
164
- let t = e.key;
165
- n.update(() => {
166
- let e = M();
167
- F(e) && V(e.anchor.getNode(), U)?.setLanguage(t);
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
- }, [n]), d = u[i].label;
170
- return /* @__PURE__ */ S(r, {
171
- menus: jt,
172
- onClick: c,
173
- activeKey: [i],
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__ */ S("div", {
180
- className: o["bsy-lexical__toolbar-select"],
445
+ children: /* @__PURE__ */ N("div", {
446
+ className: p["bsy-lexical__toolbar-select"],
181
447
  style: { width: 120 },
182
- children: /* @__PURE__ */ S(b, {
183
- icon: /* @__PURE__ */ C(ae, { children: [/* @__PURE__ */ S("span", {
184
- className: o["bsy-lexical__toolbar-select-label"],
185
- children: d
186
- }), /* @__PURE__ */ S(e, {
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: s,
189
- className: o["bsy-lexical__toolbar-select-arrow"]
454
+ size: o,
455
+ className: p["bsy-lexical__toolbar-select-arrow"]
190
456
  })] }),
191
- tooltip: a("editor.codeLanguage")
457
+ tooltip: i("editor.codeLanguage")
192
458
  })
193
459
  })
194
460
  });
195
- }, Nt = {
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
- }, Pt = (e) => typeof e == "string" ? e : e.name, Ft = (e, t, n) => {
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 = Pt(e);
520
+ let t = typeof e == "string" ? e : e.name;
255
521
  r.push({
256
522
  kind: "button",
257
523
  key: t,
@@ -263,460 +529,321 @@ var Ot = (e) => {
263
529
  key: `divider-${t.key}`
264
530
  });
265
531
  }), r;
266
- }, It = (e, t) => {
267
- let n = h(e);
268
- return n ? /* @__PURE__ */ S(n, { ...t }) : (console.warn(`[ToolbarPlugin] Button "${e}" is not registered.`), null);
269
- }, Lt = ({ config: e }) => {
270
- let { isCodeBlock: t } = p(), { isSourceMode: n } = y(), r = de(), i = Ft(e, t, n), a = {
271
- duration: r ? 0 : .16,
272
- ease: "easeOut"
273
- }, s = r ? {} : Nt;
274
- return /* @__PURE__ */ S(le, {
275
- initial: !1,
276
- mode: "popLayout",
277
- children: i.map((e) => {
278
- let t = null;
279
- return t = e.kind === "divider" ? /* @__PURE__ */ S("div", { className: o["bsy-lexical__toolbar-divider"] }) : e.kind === "language" ? /* @__PURE__ */ S(Mt, {}) : It(e.name, e.props), t === null ? null : /* @__PURE__ */ S(ue.div, {
280
- className: o["bsy-lexical__toolbar-item"],
281
- layout: "position",
282
- transition: a,
283
- ...s,
284
- children: t
285
- }, e.key);
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
- }, Rt = (e) => {
289
- let { config: t = [], style: n, theme: r, mode: i, floating: a } = e, { toolbarRef: s } = At(), l = i === "floating", u = de(), d = {
290
- duration: u ? 0 : .16,
291
- ease: "easeOut"
292
- }, f = E(() => wt(r), [r]), p = E(() => ({ iconSize: Tt(r?.iconSize) }), [r?.iconSize]), m = l ? Et(a) : void 0, h = l ? ie(n, [
293
- "position",
294
- "left",
295
- "top",
296
- "right",
297
- "bottom",
298
- "inset",
299
- "transform",
300
- "marginTop",
301
- "marginBottom"
302
- ]) : n;
303
- return /* @__PURE__ */ S(c, {
304
- value: p,
305
- children: /* @__PURE__ */ S(_, { children: /* @__PURE__ */ S(Ot, { children: /* @__PURE__ */ S(ue.div, {
306
- ref: s,
307
- layout: !u,
308
- transition: d,
309
- className: k(o["bsy-lexical__toolbar"], l && o["bsy-lexical__toolbar--floating"]),
310
- style: {
311
- ...f,
312
- ...m,
313
- ...h
314
- },
315
- children: /* @__PURE__ */ S(Lt, { config: t })
316
- }) }) })
557
+ h.keys !== s && g({
558
+ keys: s,
559
+ count: o.length
317
560
  });
318
- }, Y = {
319
- "bsy-lexical-editor": "_bsy-lexical-editor_1bhfo_1",
320
- "bsy-lexical-editor--floating": "_bsy-lexical-editor--floating_1bhfo_7",
321
- "bsy-lexical-editor__content-editable": "_bsy-lexical-editor__content-editable_1bhfo_10",
322
- "bsy-lexical-editor__content-editable--with-length-badge": "_bsy-lexical-editor__content-editable--with-length-badge_1bhfo_17",
323
- "bsy-lexical-editor__length-badge": "_bsy-lexical-editor__length-badge_1bhfo_20",
324
- "bsy-lexical-editor__length-badge--exceeded": "_bsy-lexical-editor__length-badge--exceeded_1bhfo_36"
325
- }, X = class e extends L {
326
- constructor(e, t) {
327
- super(e, t);
328
- }
329
- static getType() {
330
- return "extended-text";
331
- }
332
- static clone(t) {
333
- return new e(t.__text, t.__key);
334
- }
335
- static importDOM() {
336
- let e = L.importDOM();
337
- return {
338
- ...e,
339
- code: () => ({
340
- conversion: Z(e?.code),
341
- priority: 1
342
- }),
343
- em: () => ({
344
- conversion: Z(e?.em),
345
- priority: 1
346
- }),
347
- span: () => ({
348
- conversion: Z(e?.span),
349
- priority: 1
350
- }),
351
- strong: () => ({
352
- conversion: Z(e?.strong),
353
- priority: 1
354
- }),
355
- sub: () => ({
356
- conversion: Z(e?.sub),
357
- priority: 1
358
- }),
359
- sup: () => ({
360
- conversion: Z(e?.sup),
361
- priority: 1
362
- })
363
- };
364
- }
365
- static importJSON(e) {
366
- return zt().updateFromJSON(e);
367
- }
368
- isSimpleText() {
369
- return this.__type === "extended-text" && this.__mode === 0;
370
- }
371
- };
372
- function zt(e = "") {
373
- return be(new X(e));
374
- }
375
- function Z(e) {
376
- return (t) => {
377
- let n = e?.(t);
378
- if (!n) return null;
379
- let r = n.conversion(t);
380
- if (!r) return r;
381
- 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;
382
- return {
383
- ...r,
384
- forChild: (e, t) => {
385
- let n = (r?.forChild ?? ((e) => e))(e, t);
386
- if (Ae(n)) {
387
- let e = [
388
- i ? `background-color: ${i}` : null,
389
- a ? `color: ${a}` : null,
390
- o ? `font-family: ${o}` : null,
391
- s ? `font-weight: ${s}` : null,
392
- c ? `font-size: ${c}` : null,
393
- l ? `text-decoration: ${l}` : null
394
- ].filter((e) => e !== null).join("; ");
395
- if (e.length) return n.setStyle(e);
396
- }
397
- return n;
398
- }
399
- };
400
- };
401
- }
402
- //#endregion
403
- //#region src/components/Editor/utils/stripInlineStyleProperty.ts
404
- function Bt(e, t) {
405
- return e.split(";").map((e) => e.trim()).filter((e) => e && e.split(":")[0].trim().toLowerCase() !== t).join("; ");
406
- }
407
- //#endregion
408
- //#region src/components/Editor/plugins/LinkColorPlugin.tsx
409
- function Vt(e) {
410
- if (!V(e, Ze)) return;
411
- let t = e.getStyle();
412
- if (!t) return;
413
- let n = Bt(t, "color");
414
- n !== t && e.setStyle(n);
415
- }
416
- function Ht() {
417
- let [e] = R();
418
- return T(() => e.registerNodeTransform(X, Vt), [e]), null;
419
- }
420
- var Q = {
421
- imageWrapper: "_imageWrapper_y06h3_1",
422
- selected: "_selected_y06h3_8",
423
- resizing: "_resizing_y06h3_12",
424
- image: "_image_y06h3_1",
425
- resizeHandle: "_resizeHandle_y06h3_30",
426
- topLeft: "_topLeft_y06h3_44",
427
- topRight: "_topRight_y06h3_49",
428
- bottomLeft: "_bottomLeft_y06h3_54",
429
- bottomRight: "_bottomRight_y06h3_59"
430
- }, Ut = ({ src: e, altText: t, width: n, height: r, nodeKey: i }) => {
431
- let [a] = R(), [o, s] = O(!1), [c, l] = O(null), u = D(null), [d, f] = O({
432
- width: n || void 0,
433
- height: r || void 0
434
- }), p = w(() => {
435
- n && r && f({
436
- width: n,
437
- height: r
438
- });
439
- }, [n, r]), m = w((e, t) => {
440
- if (e.preventDefault(), e.stopPropagation(), !u.current) return;
441
- let n = d.width || u.current.offsetWidth, r = d.height || u.current.offsetHeight, i = n / r;
442
- (!d.width || !d.height) && f({
443
- width: n,
444
- height: r
445
- }), l({
446
- isResizing: !0,
447
- startX: e.clientX,
448
- startY: e.clientY,
449
- startWidth: n,
450
- startHeight: r,
451
- aspectRatio: i,
452
- direction: t
453
- });
454
- }, [d]), h = w((e) => {
455
- if (!c?.isResizing) return;
456
- let t = e.clientX - c.startX, n;
457
- switch (c.direction) {
458
- case "bottom-right":
459
- n = Math.max(50, c.startWidth + t);
460
- break;
461
- case "bottom-left":
462
- n = Math.max(50, c.startWidth - t);
463
- break;
464
- case "top-right":
465
- n = Math.max(50, c.startWidth + t);
466
- break;
467
- case "top-left":
468
- n = Math.max(50, c.startWidth - t);
469
- break;
470
- default: n = Math.max(50, c.startWidth + t);
471
- }
472
- let r = n / c.aspectRatio;
473
- f({
474
- width: n,
475
- 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);
476
575
  });
477
- }, [c]), g = w(() => {
478
- c?.isResizing && (a.update(() => {
479
- let e = A(i);
480
- Kt(e) && e.setWidthAndHeight(d.width, d.height);
481
- }), l(null));
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 = {};
482
587
  }, [
483
- a,
484
- i,
485
- d,
486
- c
487
- ]);
488
- oe.useEffect(() => {
489
- if (c?.isResizing) return document.addEventListener("mousemove", h), document.addEventListener("mouseup", g), () => {
490
- document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", g);
491
- };
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();
492
597
  }, [
493
- c,
494
- h,
495
- g
598
+ w,
599
+ s,
600
+ t
496
601
  ]);
497
- let _ = w(() => {
498
- s(!0);
499
- }, []);
500
- return T(() => a.registerUpdateListener(({ editorState: e }) => {
501
- e.read(() => {
502
- let e = M();
503
- F(e) && !e.getNodes().some((e) => e.getKey() === i || e.getParent() && e.getParent()?.getKey() === i) && o && s(!1);
504
- });
505
- }), [
506
- a,
507
- i,
508
- o
509
- ]), T(() => {
510
- let e = (e) => {
511
- o && u.current && !u.current.contains(e.target) && s(!1);
512
- };
513
- if (o) return document.addEventListener("mousedown", e), () => {
514
- document.removeEventListener("mousedown", e);
515
- };
516
- }, [o]), /* @__PURE__ */ C("div", {
517
- className: k(Q.imageWrapper, {
518
- [Q.selected]: o,
519
- [Q.resizing]: c?.isResizing
520
- }),
521
- children: [/* @__PURE__ */ S("img", {
522
- ref: u,
523
- src: e,
524
- alt: t,
525
- className: Q.image,
526
- style: {
527
- width: d.width,
528
- height: d.height
529
- },
530
- onLoad: p,
531
- onClick: _,
532
- draggable: !1
533
- }), o && /* @__PURE__ */ C(ae, { children: [
534
- /* @__PURE__ */ S("div", {
535
- className: k(Q.resizeHandle, Q.bottomRight),
536
- onMouseDown: (e) => m(e, "bottom-right")
537
- }),
538
- /* @__PURE__ */ S("div", {
539
- className: k(Q.resizeHandle, Q.bottomLeft),
540
- onMouseDown: (e) => m(e, "bottom-left")
541
- }),
542
- /* @__PURE__ */ S("div", {
543
- className: k(Q.resizeHandle, Q.topRight),
544
- onMouseDown: (e) => m(e, "top-right")
545
- }),
546
- /* @__PURE__ */ S("div", {
547
- className: k(Q.resizeHandle, Q.topLeft),
548
- 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}`))
549
648
  })
550
- ] })]
649
+ }) : null]
551
650
  });
552
- }, Wt = class e extends Le {
553
- static getType() {
554
- return "image";
555
- }
556
- static clone(t) {
557
- return new e(t.__src, t.__altText, t.__width, t.__height, t.__key);
558
- }
559
- constructor(e, t, n, r, i) {
560
- super(i), this.__src = e, this.__altText = t || "", this.__width = n, this.__height = r;
561
- }
562
- createDOM() {
563
- let e = document.createElement("div");
564
- return e.style.display = "inline-block", e;
565
- }
566
- updateDOM() {
567
- return !1;
568
- }
569
- exportDOM() {
570
- let e = document.createElement("img");
571
- 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 };
572
- }
573
- getSrc() {
574
- return this.__src;
575
- }
576
- getAltText() {
577
- return this.__altText;
578
- }
579
- getWidth() {
580
- return this.__width;
581
- }
582
- getHeight() {
583
- return this.__height;
584
- }
585
- setSrc(e) {
586
- let t = this.getWritable();
587
- t.__src = e;
588
- }
589
- setAltText(e) {
590
- let t = this.getWritable();
591
- t.__altText = e;
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);
592
696
  }
593
- setWidthAndHeight(e, t) {
594
- let n = this.getWritable();
595
- n.__width = e, n.__height = t;
697
+ static getType() {
698
+ return "extended-text";
596
699
  }
597
- decorate() {
598
- return /* @__PURE__ */ S(Ut, {
599
- src: this.__src,
600
- altText: this.__altText,
601
- width: this.__width,
602
- height: this.__height,
603
- nodeKey: this.getKey()
604
- });
700
+ static clone(t) {
701
+ return new e(t.__text, t.__key);
605
702
  }
606
703
  static importDOM() {
607
- return { img: () => ({
608
- conversion: qt,
609
- priority: 0
610
- }) };
611
- }
612
- static importJSON(e) {
613
- let { src: t, altText: n, width: r, height: i } = e;
614
- return Gt({
615
- src: t,
616
- altText: n,
617
- width: r,
618
- height: i
619
- });
620
- }
621
- exportJSON() {
704
+ let e = gt.importDOM();
622
705
  return {
623
- src: this.getSrc(),
624
- altText: this.getAltText(),
625
- width: this.getWidth(),
626
- height: this.getHeight(),
627
- type: "image",
628
- version: 1
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
+ })
629
731
  };
630
732
  }
631
- isInline() {
632
- return !0;
733
+ static importJSON(e) {
734
+ return Sn().updateFromJSON(e);
735
+ }
736
+ isSimpleText() {
737
+ return this.__type === "extended-text" && this.__mode === 0;
633
738
  }
634
739
  };
635
- function Gt({ src: e, altText: t, width: n, height: r, key: i }) {
636
- return new Wt(e, t, n, r, i);
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
+ };
637
769
  }
638
- function Kt(e) {
639
- return e instanceof Wt;
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("; ");
640
774
  }
641
- function qt(e) {
642
- if (e instanceof HTMLImageElement) {
643
- let { src: t, alt: n, style: r } = e, i, a;
644
- if (r.width) {
645
- let e = parseInt(r.width, 10);
646
- isNaN(e) || (i = e);
647
- }
648
- if (r.height) {
649
- let e = parseInt(r.height, 10);
650
- isNaN(e) || (a = e);
651
- }
652
- return i === void 0 && e.width && (i = e.width), a === void 0 && e.height && (a = e.height), { node: Gt({
653
- src: t,
654
- altText: n,
655
- width: i,
656
- height: a
657
- }) };
658
- }
659
- 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;
660
787
  }
661
788
  //#endregion
662
789
  //#region src/components/Editor/plugins/ImagePlugin.tsx
663
- function Jt() {
664
- let [e] = R();
665
- return T(() => e.registerCommand(s, (e) => (N([Gt(e)]), !0), Pe), [e]), null;
790
+ function En() {
791
+ let [e] = G();
792
+ return I(() => e.registerCommand(C, (e) => (qe([rn(e)]), !0), it), [e]), null;
666
793
  }
667
794
  //#endregion
668
795
  //#region src/components/Editor/utils/stripImagesFromHtml.ts
669
- function Yt(e) {
796
+ function Dn(e) {
670
797
  let t = new DOMParser().parseFromString(e, "text/html");
671
798
  return t.querySelectorAll("img, picture").forEach((e) => e.remove()), t.body.innerHTML;
672
799
  }
673
800
  //#endregion
674
801
  //#region src/components/Editor/plugins/PasteStripImagePlugin.tsx
675
- var Xt = /<img\b|<picture\b/i;
676
- function Zt() {
677
- let [e] = R(), { isSourceModeRef: t } = y();
678
- return T(() => {
802
+ var On = /<img\b|<picture\b/i;
803
+ function kn() {
804
+ let [e] = G(), { isSourceModeRef: t } = M();
805
+ return I(() => {
679
806
  let n = (n) => {
680
807
  if (t.current) return !1;
681
808
  let r = "clipboardData" in n ? n.clipboardData : "dataTransfer" in n ? n.dataTransfer : null;
682
809
  if (!r || r.getData("application/x-lexical-editor") || r.getData("application/x-lexical-drag")) return !1;
683
810
  let i = r.getData("text/html");
684
- if (!(Array.from(r.files).some((e) => e.type.startsWith("image/")) || Array.from(r.items).some((e) => e.type.startsWith("image/")) || Xt.test(i))) return !1;
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;
685
812
  n.preventDefault();
686
813
  let a = r.getData("text/plain");
687
- return !Xt.test(i) && !a || e.update(() => {
688
- let t = M();
814
+ return !On.test(i) && !a || e.update(() => {
815
+ let t = U();
689
816
  if (t === null) return;
690
- let n = i ? Yt(i) : "", r = document.createElement("div");
817
+ let n = i ? Dn(i) : "", r = document.createElement("div");
691
818
  if (r.innerHTML = n, n && r.textContent?.trim()) {
692
- let t = ye(e, new DOMParser().parseFromString(n, "text/html"));
819
+ let t = ze(e, new DOMParser().parseFromString(n, "text/html"));
693
820
  if (t.length) {
694
- N(t);
821
+ qe(t);
695
822
  return;
696
823
  }
697
824
  }
698
825
  a && t.insertRawText(a);
699
- }, { tag: Ue }), !0;
826
+ }, { tag: mt }), !0;
700
827
  };
701
- return Xe(e.registerCommand(He, (e) => n(e), I), e.registerCommand(Ie, (e) => n(e), I));
828
+ return wt(e.registerCommand(pt, (e) => n(e), at), e.registerCommand(st, (e) => n(e), at));
702
829
  }, [e, t]), null;
703
830
  }
704
831
  //#endregion
705
832
  //#region src/components/Editor/plugins/EnterKeyPlugin.tsx
706
- function Qt() {
707
- let [e] = R(), t = D(0);
708
- return T(() => e.registerCommand(Be, (n) => {
833
+ function An() {
834
+ let [e] = G(), t = R(0);
835
+ return I(() => e.registerCommand(dt, (n) => {
709
836
  let r = Date.now(), i = r - t.current;
710
837
  return t.current = r, i < 250 && i > 0 ? e.getEditorState().read(() => {
711
- let e = M();
712
- return F(e) ? !!V(e.anchor.getNode(), (e) => H(e) || U(e) || K(e)) : !1;
838
+ let e = U();
839
+ return W(e) ? !!K(e.anchor.getNode(), (e) => q(e) || J(e) || zt(e)) : !1;
713
840
  }, { editor: e }) ? !1 : (e.update(() => {
714
- let e = M();
715
- if (F(e)) {
841
+ let e = U();
842
+ if (W(e)) {
716
843
  let t = e.anchor.getNode().getTopLevelElement();
717
844
  if (t && t.getTextContent().trim() === "") {
718
- let n = Se();
719
- Je(e, {
845
+ let n = He();
846
+ xt(e, {
720
847
  "background-color": "",
721
848
  color: "",
722
849
  "font-size": "",
@@ -729,11 +856,11 @@ function Qt() {
729
856
  }
730
857
  }
731
858
  }), n?.preventDefault(), !0) : !1;
732
- }, Fe), [e]), null;
859
+ }, ot), [e]), null;
733
860
  }
734
861
  //#endregion
735
862
  //#region src/components/Editor/utils/codeHighlighter.ts
736
- var $t = {
863
+ var jn = {
737
864
  css: () => import("@shikijs/langs/css"),
738
865
  html: () => import("@shikijs/langs/html"),
739
866
  xml: () => import("@shikijs/langs/xml"),
@@ -754,65 +881,65 @@ var $t = {
754
881
  bash: () => import("@shikijs/langs/shellscript"),
755
882
  lua: () => import("@shikijs/langs/lua"),
756
883
  markdown: () => import("@shikijs/langs/markdown")
757
- }, en = (e) => e === "bash" ? "shellscript" : e, tn = (e) => e in $t, nn = null, rn = null, an = /* @__PURE__ */ new Map(), on = () => (nn ||= Promise.all([import("@shikijs/core"), import("@shikijs/engine-javascript")]).then(([{ createHighlighterCoreSync: e }, { createJavaScriptRegexEngine: t }]) => e({
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({
758
885
  engine: t(),
759
886
  langs: [],
760
887
  themes: []
761
888
  })).catch((e) => {
762
- throw nn = null, e;
763
- }), nn), sn = (e, t) => tn(t) && e.getLoadedLanguages().includes(en(t)), cn = (e) => {
764
- let t = an.get(e);
765
- return t || (t = on().then(async (t) => {
766
- let n = en(e);
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);
767
894
  if (!t.getLoadedLanguages().includes(n)) {
768
- let n = await $t[e]();
895
+ let n = await jn[e]();
769
896
  await t.loadLanguage(n.default);
770
897
  }
771
898
  return t;
772
899
  }).catch((t) => {
773
- throw an.delete(e), t;
774
- }), an.set(e, t)), t;
775
- }, ln = () => (rn ||= on().then(async (e) => {
900
+ throw In.delete(e), t;
901
+ }), In.set(e, t)), t;
902
+ }, Bn = () => (Fn ||= Ln().then(async (e) => {
776
903
  if (!e.getLoadedThemes().includes("github-light")) {
777
904
  let t = await import("@shikijs/themes/github-light");
778
905
  await e.loadTheme(t.default);
779
906
  }
780
907
  return e;
781
908
  }).catch((e) => {
782
- throw rn = null, e;
783
- }), rn), un = (e, t, n) => {
909
+ throw Fn = null, e;
910
+ }), Fn), Vn = (e, t, n) => {
784
911
  let r = e.getTextContent();
785
- if (e.getStyle() && e.setStyle(""), !n || !sn(n, t)) return ot(r);
786
- let i = en(t), a = n.codeToTokens(r, {
912
+ if (e.getStyle() && e.setStyle(""), !n || !Rn(n, t)) return Pt(r);
913
+ let i = Mn(t), a = n.codeToTokens(r, {
787
914
  lang: i,
788
- theme: m
915
+ theme: A
789
916
  }), o = [];
790
917
  return a.tokens.forEach((e, t) => {
791
- t && o.push(xe()), e.forEach((e) => {
918
+ t && o.push(Ve()), e.forEach((e) => {
792
919
  e.content.split(" ").forEach((t, n) => {
793
- if (n && o.push(Ce()), t === "") return;
794
- let r = rt(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}` : "";
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}` : "";
795
922
  i && r.setStyle(i), o.push(r);
796
923
  });
797
924
  });
798
925
  }), o;
799
- }, dn = (e, t) => {
800
- let n = A(e);
801
- if (!U(n) || !n.isAttached()) return;
802
- let r = M();
803
- if (!F(r)) {
926
+ }, Hn = (e, t) => {
927
+ let n = V(e);
928
+ if (!J(n) || !n.isAttached()) return;
929
+ let r = U();
930
+ if (!W(r)) {
804
931
  t();
805
932
  return;
806
933
  }
807
- let { anchor: i } = r, a = i.offset, o = i.type === "element" && P(n.getChildAtIndex(i.offset - 1)), s = 0;
934
+ let { anchor: i } = r, a = i.offset, o = i.type === "element" && Ye(n.getChildAtIndex(i.offset - 1)), s = 0;
808
935
  if (o || (s = a + i.getNode().getPreviousSiblings().reduce((e, t) => e + t.getTextContentSize(), 0)), t()) {
809
936
  if (o) {
810
937
  i.getNode().select(a, a);
811
938
  return;
812
939
  }
813
940
  n.getChildren().some((e) => {
814
- let t = Ae(e);
815
- if (t || P(e)) {
941
+ let t = Qe(e);
942
+ if (t || Ye(e)) {
816
943
  let n = e.getTextContentSize();
817
944
  if (t && n >= s) return e.select(s, s), !0;
818
945
  s -= n;
@@ -820,11 +947,11 @@ var $t = {
820
947
  return !1;
821
948
  });
822
949
  }
823
- }, fn = (e, t) => at(e) && at(t) && e.__text === t.__text && e.__highlightType === t.__highlightType && e.__style === t.__style || ke(e) && ke(t) || P(e) && P(t), pn = (e, t) => {
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) => {
824
951
  let n = 0;
825
- for (; n < e.length && fn(e[n], t[n]);) n++;
952
+ for (; n < e.length && Un(e[n], t[n]);) n++;
826
953
  let r = e.length, i = t.length, a = Math.min(r, i) - n, o = 0;
827
- for (; o < a;) if (o++, !fn(e[r - o], t[i - o])) {
954
+ for (; o < a;) if (o++, !Un(e[r - o], t[i - o])) {
828
955
  o--;
829
956
  break;
830
957
  }
@@ -833,21 +960,21 @@ var $t = {
833
960
  to: r - o,
834
961
  nodesForReplacement: t.slice(n, i - o)
835
962
  };
836
- }, mn = (e, t, n, r, i) => {
837
- let a = i.getKey(), o = x(i.getLanguage());
963
+ }, Gn = (e, t, n, r, i) => {
964
+ let a = i.getKey(), o = d(i.getLanguage());
838
965
  if (i.getLanguage() !== o && i.setLanguage(o), o === "plaintext") i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1);
839
966
  else {
840
- i.getTheme() !== "github-light" && i.setTheme(m);
841
- let s = t ? t.getLoadedThemes().includes("github-light") ? tn(o) && !sn(t, o) ? cn(o) : null : ln() : on();
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();
842
969
  if (s) {
843
970
  i.getIsSyntaxHighlightSupported() && i.setIsSyntaxHighlightSupported(!1), n.pendingKeys.add(a), n.loading !== s && (n.loading = s, s.then((t) => {
844
971
  r(t);
845
972
  let i = [...n.pendingKeys];
846
973
  n.pendingKeys.clear(), n.loading = null, e.update(() => {
847
974
  i.forEach((e) => {
848
- A(e)?.markDirty();
975
+ V(e)?.markDirty();
849
976
  });
850
- }, { tag: Re });
977
+ }, { tag: lt });
851
978
  }, () => {
852
979
  n.pendingKeys.clear(), n.loading = null;
853
980
  }));
@@ -855,22 +982,22 @@ var $t = {
855
982
  }
856
983
  i.getIsSyntaxHighlightSupported() || i.setIsSyntaxHighlightSupported(!0);
857
984
  }
858
- n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, je(() => {
985
+ n.nodesCurrentlyHighlighting.has(a) || (n.nodesCurrentlyHighlighting.add(a), n.didTransform || (n.didTransform = !0, et(() => {
859
986
  n.didTransform = !1, n.nodesCurrentlyHighlighting.clear();
860
- })), dn(a, () => {
861
- let e = A(a);
862
- if (!U(e) || !e.isAttached()) return !1;
863
- let n = un(e, x(e.getLanguage()), t), { from: r, to: i, nodesForReplacement: o } = pn(e.getChildren(), 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);
864
991
  return r !== i || o.length ? (e.splice(r, i - r, o), !0) : !1;
865
992
  }));
866
- }, hn = (e, t, n, r, i) => {
993
+ }, Kn = (e, t, n, r, i) => {
867
994
  let a = i.getParent();
868
- U(a) ? mn(e, t, n, r, a) : at(i) && i.replace(we(i.__text));
995
+ J(a) ? Gn(e, t, n, r, a) : Nt(i) && i.replace(We(i.__text));
869
996
  };
870
- function gn() {
871
- let [e] = R();
872
- return T(() => {
873
- if (!e.hasNodes([G, W])) throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");
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");
874
1001
  let t = null, n = {
875
1002
  didTransform: !1,
876
1003
  nodesCurrentlyHighlighting: /* @__PURE__ */ new Set(),
@@ -879,16 +1006,16 @@ function gn() {
879
1006
  }, r = (e) => {
880
1007
  t = e;
881
1008
  }, i = (e) => {
882
- let t = A(e);
883
- if (!U(t)) return;
1009
+ let t = V(e);
1010
+ if (!J(t)) return;
884
1011
  let n = t.getChildrenSize();
885
1012
  n === 0 ? t.selectStart() : t.select(0, n);
886
1013
  }, a = (t) => {
887
1014
  if (!(t instanceof Node) || !e.getRootElement()?.contains(t)) return null;
888
1015
  let n = null;
889
1016
  return e.getEditorState().read(() => {
890
- let e = Te(t), r = e ? V(e, U) : null;
891
- U(r) && (n = r.getKey());
1017
+ let e = Ge(t), r = e ? K(e, J) : null;
1018
+ J(r) && (n = r.getKey());
892
1019
  }, { editor: e }), n;
893
1020
  }, o = null, s = (t, n, r) => {
894
1021
  t.preventDefault(), r && (o = n), e.update(() => {
@@ -910,12 +1037,12 @@ function gn() {
910
1037
  }, d = (e, t) => {
911
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);
912
1039
  };
913
- return Ke(st(e), e.registerNodeTransform(G, (i) => {
914
- mn(e, t, n, r, i);
915
- }), e.registerNodeTransform(L, (i) => {
916
- hn(e, t, n, r, i);
917
- }), e.registerNodeTransform(W, (i) => {
918
- hn(e, t, n, r, i);
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);
919
1046
  }), e.registerRootListener(d), () => {
920
1047
  d(null, e.getRootElement());
921
1048
  });
@@ -923,23 +1050,23 @@ function gn() {
923
1050
  }
924
1051
  //#endregion
925
1052
  //#region src/components/Editor/plugins/TablePlugin.tsx
926
- function _n() {
927
- let [e] = R();
928
- return T(() => (_t(e, !0), Xe(ht(e), gt(e, !1), mt(e), e.registerNodeTransform(q, (e) => {
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) => {
929
1056
  e.getBackgroundColor() !== null && e.setBackgroundColor(null);
930
- }), e.registerCommand(Ve, (e) => {
931
- let t = M();
932
- if (!F(t) || !t.isCollapsed()) return !1;
933
- let n = ct(t.anchor.getNode());
1057
+ }), e.registerCommand(ft, (e) => {
1058
+ let t = U();
1059
+ if (!W(t) || !t.isCollapsed()) return !1;
1060
+ let n = Rt(t.anchor.getNode());
934
1061
  if (n === null) return !1;
935
1062
  let r = e.shiftKey ? "previous" : "next", i = r === "next" ? "getNextSibling" : "getPreviousSibling", a = r === "next" ? "getFirstChild" : "getLastChild", o = n[i](), s = null;
936
- if (K(o)) s = o;
1063
+ if (zt(o)) s = o;
937
1064
  else {
938
- let e = V(n, ut);
1065
+ let e = K(n, Vt);
939
1066
  if (e !== null) for (let t = e[i](); t !== null; t = t[i]()) {
940
- if (!ut(t)) continue;
1067
+ if (!Vt(t)) continue;
941
1068
  let e = t[a]();
942
- if (K(e)) {
1069
+ if (zt(e)) {
943
1070
  s = e;
944
1071
  break;
945
1072
  }
@@ -949,60 +1076,60 @@ function _n() {
949
1076
  let e = s.getFirstDescendant();
950
1077
  e ? e.selectStart() : s.selectStart();
951
1078
  } else {
952
- let e = V(n, lt);
1079
+ let e = K(n, Bt);
953
1080
  e && (r === "next" ? e.selectNext() : e.selectPrevious());
954
1081
  }
955
1082
  return !0;
956
- }, I))), [e]), null;
1083
+ }, at))), [e]), null;
957
1084
  }
958
1085
  //#endregion
959
1086
  //#region src/components/Editor/plugins/TabIndentPlugin.tsx
960
- var vn = "\xA0".repeat(4);
961
- function yn() {
962
- let [e] = R();
963
- return T(() => e.registerCommand(Ve, (t) => {
1087
+ var Yn = "\xA0".repeat(4);
1088
+ function Xn() {
1089
+ let [e] = G();
1090
+ return I(() => e.registerCommand(ft, (t) => {
964
1091
  if (t.shiftKey) return !1;
965
- let n = M();
966
- if (!F(n)) return !1;
1092
+ let n = U();
1093
+ if (!W(n)) return !1;
967
1094
  let r = n.anchor.getNode();
968
- if (ct(r) !== null || V(r, U)) return !1;
1095
+ if (Rt(r) !== null || K(r, J)) return !1;
969
1096
  t.preventDefault();
970
- let i = V(r, H);
971
- if (H(i)) {
1097
+ let i = K(r, q);
1098
+ if (q(i)) {
972
1099
  let e = new Set([i]);
973
1100
  for (let t of n.getNodes()) {
974
- let n = V(t, H);
975
- H(n) && e.add(n);
1101
+ let n = K(t, q);
1102
+ q(n) && e.add(n);
976
1103
  }
977
1104
  for (let t of e) t.setIndent(t.getIndent() + 1);
978
1105
  return !0;
979
1106
  }
980
1107
  let a = r.getTopLevelElement(), o = n.focus.getNode().getTopLevelElement();
981
- return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(ze, void 0) : (n.insertText(vn), !0);
982
- }, Pe), [e]), null;
1108
+ return !n.isCollapsed() && a && o && a !== o ? e.dispatchCommand(ut, void 0) : (n.insertText(Yn), !0);
1109
+ }, it), [e]), null;
983
1110
  }
984
1111
  //#endregion
985
1112
  //#region src/components/Editor/plugins/MaxLengthPlugin.tsx
986
- function bn({ maxLength: e, onMaxLengthExceed: t }) {
987
- let [n] = R(), { isSourceModeRef: r } = y(), i = D(t);
988
- return i.current = t, T(() => {
1113
+ function Zn({ maxLength: e, onMaxLengthExceed: t }) {
1114
+ let [n] = G(), { isSourceModeRef: r } = M(), i = R(t);
1115
+ return i.current = t, I(() => {
989
1116
  let t = null;
990
- return n.registerNodeTransform(We, (a) => {
1117
+ return n.registerNodeTransform(ht, (a) => {
991
1118
  if (r.current) return;
992
1119
  let o = a.getTextContentSize();
993
1120
  if (o <= e) return;
994
- let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u = M();
1121
+ let s = n.getEditorState(), c = s.read(() => a.getTextContentSize()), l = o - e, u = U();
995
1122
  if (c === e && t !== s) {
996
- t = s, Ye(n, s), i.current?.();
1123
+ t = s, Ct(n, s), i.current?.();
997
1124
  return;
998
1125
  }
999
- if (F(u) && u.isCollapsed()) {
1000
- B(n, u.anchor, l), i.current?.();
1126
+ if (W(u) && u.isCollapsed()) {
1127
+ St(n, u.anchor, l), i.current?.();
1001
1128
  return;
1002
1129
  }
1003
1130
  a.selectEnd();
1004
- let d = M();
1005
- F(d) && (B(n, d.anchor, l), i.current?.());
1131
+ let d = U();
1132
+ W(d) && (St(n, d.anchor, l), i.current?.());
1006
1133
  });
1007
1134
  }, [
1008
1135
  n,
@@ -1011,121 +1138,20 @@ function bn({ maxLength: e, onMaxLengthExceed: t }) {
1011
1138
  ]), null;
1012
1139
  }
1013
1140
  //#endregion
1014
- //#region src/components/Editor/utils/fillRootFromHtml.ts
1015
- var xn = [
1016
- "color",
1017
- "background-color",
1018
- "font-size",
1019
- "font-family",
1020
- "font-weight",
1021
- "text-decoration"
1022
- ], Sn = (e) => {
1023
- let t = e.body.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li, td, th");
1024
- for (let n of Array.from(t)) {
1025
- let t = n, r = [];
1026
- for (let e of xn) {
1027
- let n = t.style.getPropertyValue(e);
1028
- n && (r.push(`${e}: ${n}`), t.style.removeProperty(e));
1029
- }
1030
- if (!r.length) continue;
1031
- let i = r.join("; ");
1032
- for (let n of Array.from(t.childNodes)) {
1033
- if (n.nodeType === Node.TEXT_NODE && n.textContent) {
1034
- let r = e.createElement("span");
1035
- r.setAttribute("style", i), t.insertBefore(r, n), r.appendChild(n);
1036
- continue;
1037
- }
1038
- if (n.nodeType === Node.ELEMENT_NODE) {
1039
- let e = n, t = e.getAttribute("style");
1040
- e.setAttribute("style", t ? `${t}; ${i}` : i);
1041
- }
1042
- }
1043
- }
1044
- };
1045
- function Cn(e, t) {
1046
- let n = j();
1047
- if (n.clear(), !t.trim()) return;
1048
- let r = new DOMParser().parseFromString(t, "text/html");
1049
- Sn(r);
1050
- let i = ye(e, r);
1051
- i.length && (n.select(), N(i));
1052
- }
1053
- //#endregion
1054
- //#region src/components/Editor/utils/isEmptyEditorHtml.ts
1055
- function wn(e, t) {
1056
- return !t.trim() && (e === "<p><br></p>" || e === "<p></p>" || e === "" || /^<p>\s*<br>\s*<\/p>$/.test(e));
1057
- }
1058
- //#endregion
1059
- //#region src/components/Editor/utils/sanitizeEditorHtml.ts
1060
- 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 = [
1061
- "href",
1062
- "src",
1063
- "alt",
1064
- "target",
1065
- "rel",
1066
- "colspan",
1067
- "rowspan",
1068
- "data-language",
1069
- "class",
1070
- "style",
1071
- "width",
1072
- "height"
1073
- ], Dn = new Set([
1074
- "color",
1075
- "background-color",
1076
- "font-size",
1077
- "font-family",
1078
- "font-weight",
1079
- "text-decoration",
1080
- "text-align",
1081
- "max-width",
1082
- "display",
1083
- "vertical-align",
1084
- "width",
1085
- "height",
1086
- "border"
1087
- ]), 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) => {
1088
- let t = e.indexOf(":");
1089
- if (t === -1) return null;
1090
- let n = e.slice(0, t).trim().toLowerCase(), r = e.slice(t + 1).trim();
1091
- if (n === "background") {
1092
- if (/url\s*\(/i.test(r)) return null;
1093
- n = "background-color";
1094
- }
1095
- return !Dn.has(n) || /expression|javascript:|url\s*\(\s*['"]?\s*javascript/i.test(r) ? null : `${n}: ${r}`;
1096
- }).filter((e) => e !== null).join("; "), An = !1, jn = () => {
1097
- An ||= (Ct.addHook("uponSanitizeAttribute", (e, t) => {
1098
- if (t.attrName === "href" && /^data:/i.test(t.attrValue)) {
1099
- t.keepAttr = !1;
1100
- return;
1101
- }
1102
- t.attrName === "style" && (t.attrValue = kn(t.attrValue), t.attrValue || (t.keepAttr = !1));
1103
- }), !0);
1104
- };
1105
- function $(e) {
1106
- return e ? (jn(), Ct.sanitize(e, {
1107
- ALLOWED_TAGS: Tn,
1108
- ALLOWED_ATTR: En,
1109
- ALLOW_DATA_ATTR: !1,
1110
- ADD_ATTR: ["data-language"],
1111
- ALLOWED_URI_REGEXP: On
1112
- })) : "";
1113
- }
1114
- //#endregion
1115
1141
  //#region src/components/Editor/utils/textLength.ts
1116
- function Mn(e) {
1142
+ function Qn(e) {
1117
1143
  return typeof e == "number" && Number.isFinite(e) && e > 0;
1118
1144
  }
1119
- function Nn(e, t) {
1120
- let n = j(), r = n.getTextContentSize();
1145
+ function $n(e, t) {
1146
+ let n = H(), r = n.getTextContentSize();
1121
1147
  if (r <= t) return !1;
1122
1148
  let i = r - t;
1123
1149
  n.selectEnd();
1124
- let a = M();
1125
- return F(a) ? B(e, a.anchor, i) : Pn(i), !0;
1150
+ let a = U();
1151
+ return W(a) ? St(e, a.anchor, i) : er(i), !0;
1126
1152
  }
1127
- function Pn(e) {
1128
- let t = e, n = j().getAllTextNodes();
1153
+ function er(e) {
1154
+ let t = e, n = H().getAllTextNodes();
1129
1155
  for (let e = n.length - 1; e >= 0 && t > 0; e--) {
1130
1156
  let r = n[e], i = r.getTextContent();
1131
1157
  i.length !== 0 && (i.length <= t ? (t -= i.length, r.remove()) : (r.setTextContent(i.slice(0, i.length - t)), t = 0));
@@ -1133,87 +1159,88 @@ function Pn(e) {
1133
1159
  }
1134
1160
  //#endregion
1135
1161
  //#region src/components/Editor/utils/formatEditorHtml.ts
1136
- var Fn = (e) => {
1137
- let t = e.parentNode;
1138
- if (t) {
1139
- for (; e.firstChild;) t.insertBefore(e.firstChild, e);
1140
- t.removeChild(e);
1141
- }
1142
- }, In = (e) => {
1143
- let t = new DOMParser().parseFromString(e, "text/html");
1144
- for (let e of Array.from(t.body.querySelectorAll("*"))) {
1145
- for (let t of Array.from(e.classList)) t.startsWith("editor-") && e.classList.remove(t);
1146
- e.classList.length === 0 && e.removeAttribute("class");
1147
- }
1148
- let n = !0;
1149
- for (; n;) {
1150
- n = !1;
1151
- for (let e of Array.from(t.body.querySelectorAll("span, b, i"))) {
1152
- if (e.attributes.length > 0) continue;
1153
- let t = e.tagName.toLowerCase();
1154
- if (t === "span") {
1155
- Fn(e), n = !0;
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, "&amp;").replace(/"/g, "&quot;"), ar = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), 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));
1156
1189
  continue;
1157
1190
  }
1158
- if (e.childElementCount !== 1 || e.childNodes.length !== 1) continue;
1159
- let r = e.firstElementChild;
1160
- (t === "b" && r?.tagName === "STRONG" || t === "i" && r?.tagName === "EM") && (Fn(e), n = !0);
1191
+ e.trim() && i.push(ar(e));
1192
+ continue;
1161
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));
1162
1199
  }
1163
- return t.body.innerHTML;
1200
+ return n || !r ? i.join("") : i.map((e) => `${sr(t)}${e}`).join("\n");
1164
1201
  };
1165
- async function Ln(e) {
1166
- if (!e.trim()) return e;
1167
- let t = In(e);
1168
- try {
1169
- let [{ format: e }, n] = await Promise.all([import("prettier/standalone"), import("prettier/plugins/html")]);
1170
- return (await e(t, {
1171
- parser: "html",
1172
- plugins: [n]
1173
- })).trimEnd();
1174
- } catch {
1175
- return t;
1176
- }
1202
+ function ur(e) {
1203
+ return e.trim() ? lr(new DOMParser().parseFromString(te(e), "text/html").body, 0, !1, !0).trimEnd() : e;
1177
1204
  }
1178
1205
  //#endregion
1179
1206
  //#region src/components/Editor/utils/writeHtmlSource.ts
1180
- function Rn(e) {
1181
- j().clear();
1182
- let t = it("html");
1183
- if (j().append(t), !e) return;
1207
+ function dr(e) {
1208
+ H().clear();
1209
+ let t = Mt("html");
1210
+ if (H().append(t), !e) return;
1184
1211
  t.select();
1185
- let n = M();
1186
- F(n) && n.insertRawText(e);
1212
+ let n = U();
1213
+ W(n) && n.insertRawText(e);
1187
1214
  }
1188
1215
  //#endregion
1189
1216
  //#region src/components/Editor/plugins/SourceModePlugin.tsx
1190
- function zn({ children: e, maxLength: t, onMaxLengthExceed: n }) {
1191
- let [r] = R(), [i, a] = O(!1), o = D(!1), s = D(n);
1217
+ function fr({ children: e, maxLength: t, onMaxLengthExceed: n }) {
1218
+ let [r] = G(), [i, a] = z(!1), o = R(!1), s = R(n);
1192
1219
  s.current = n;
1193
- let c = Mn(t) ? t : void 0, l = w(() => {
1220
+ let c = Qn(t) ? t : void 0, l = F(() => {
1194
1221
  if (o.current) return;
1195
1222
  let e = "", t = "";
1196
1223
  r.getEditorState().read(() => {
1197
- t = j().getTextContent(), e = ve(r, null);
1198
- }, { editor: r }), Ln(wn(e, t) ? "" : $(e)).then((e) => {
1199
- o.current || (o.current = !0, a(!0), r.update(() => {
1200
- Rn(e);
1201
- }), r.dispatchCommand(Me, void 0));
1202
- });
1203
- }, [r]), u = w(() => {
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(() => {
1204
1231
  if (!o.current) return;
1205
1232
  let e = !1;
1206
1233
  o.current = !1, r.update(() => {
1207
- Cn(r, $(j().getTextContent())), c !== void 0 && (e = Nn(r, c));
1208
- }), a(!1), r.dispatchCommand(Me, void 0), e && s.current?.();
1209
- }, [r, c]), d = w(() => {
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(() => {
1210
1237
  if (o.current) {
1211
1238
  u();
1212
1239
  return;
1213
1240
  }
1214
1241
  l();
1215
1242
  }, [l, u]);
1216
- T(() => {
1243
+ I(() => {
1217
1244
  let e = (e) => {
1218
1245
  if (!o.current) return !1;
1219
1246
  let t = "clipboardData" in e ? e.clipboardData : "dataTransfer" in e ? e.dataTransfer : null;
@@ -1221,53 +1248,53 @@ function zn({ children: e, maxLength: t, onMaxLengthExceed: n }) {
1221
1248
  e.preventDefault();
1222
1249
  let n = t.getData("text/html") || t.getData("text/plain");
1223
1250
  if (!n) return !0;
1224
- let i = $(n);
1251
+ let i = E(n);
1225
1252
  return r.update(() => {
1226
- let e = M();
1227
- F(e) && i && e.insertRawText(i);
1228
- }, { tag: Ue }), !0;
1253
+ let e = U();
1254
+ W(e) && i && e.insertRawText(i);
1255
+ }, { tag: mt }), !0;
1229
1256
  };
1230
- return Xe(r.registerNodeTransform(We, () => {
1257
+ return wt(r.registerNodeTransform(ht, () => {
1231
1258
  if (!o.current) return;
1232
- let e = j(), t = e.getChildrenSize() === 1 ? e.getFirstChild() : null;
1233
- U(t) && t.getLanguage() === "html" || Rn(e.getTextContent());
1234
- }), r.registerCommand(He, e, Ne), r.registerCommand(Ie, e, Ne));
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));
1235
1262
  }, [r]);
1236
- let f = E(() => ({
1263
+ let f = L(() => ({
1237
1264
  isSourceMode: i,
1238
1265
  isSourceModeRef: o,
1239
1266
  toggleSourceMode: d
1240
1267
  }), [i, d]);
1241
- return /* @__PURE__ */ S(g.Provider, {
1268
+ return /* @__PURE__ */ N(ce.Provider, {
1242
1269
  value: f,
1243
1270
  children: e
1244
1271
  });
1245
1272
  }
1246
1273
  //#endregion
1247
1274
  //#region src/components/Editor/plugins/HeadingPlugin.tsx
1248
- function Bn(e) {
1275
+ function pr(e) {
1249
1276
  let t = e.getTag();
1250
1277
  if (t === "h4" || t === "h5" || t === "h6") {
1251
- e.replace(Se(), !0);
1278
+ e.replace(He(), !0);
1252
1279
  return;
1253
1280
  }
1254
1281
  for (let t of e.getAllTextNodes()) {
1255
1282
  let e = t.getStyle();
1256
1283
  if (!e) continue;
1257
- let n = Bt(e, "font-size");
1284
+ let n = Cn(e, "font-size");
1258
1285
  n !== e && t.setStyle(n);
1259
1286
  }
1260
1287
  }
1261
- function Vn() {
1262
- let [e] = R();
1263
- return T(() => e.registerNodeTransform(yt, Bn), [e]), null;
1288
+ function mr() {
1289
+ let [e] = G();
1290
+ return I(() => e.registerNodeTransform(Zt, pr), [e]), null;
1264
1291
  }
1265
1292
  //#endregion
1266
1293
  //#region src/components/Editor/LengthBadge.tsx
1267
- var Hn = ({ current: e, maxLength: t }) => {
1294
+ var hr = ({ current: e, maxLength: t }) => {
1268
1295
  let n = e > t;
1269
- return /* @__PURE__ */ C("div", {
1270
- className: k(Y["bsy-lexical-editor__length-badge"], n && Y["bsy-lexical-editor__length-badge--exceeded"]),
1296
+ return /* @__PURE__ */ P("div", {
1297
+ className: B(Z["bsy-lexical-editor__length-badge"], n && Z["bsy-lexical-editor__length-badge--exceeded"]),
1271
1298
  "aria-live": "polite",
1272
1299
  children: [
1273
1300
  e,
@@ -1276,124 +1303,764 @@ var Hn = ({ current: e, maxLength: t }) => {
1276
1303
  ]
1277
1304
  });
1278
1305
  };
1279
- Hn.displayName = "BsyLexicalEditorLengthBadge";
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
+ }
1396
+ //#endregion
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
+ }
1280
1412
  //#endregion
1281
- //#region src/components/Editor/EditorCore.tsx
1282
- var Un = (e) => {
1283
- let { height: t = 126, onChange: n, toolbar: r, theme: i, maxLength: a, onMaxLengthExceed: o } = e, [s] = R(), { isSourceMode: c, isSourceModeRef: l } = y(), u = D(null), d = D(null), f = D(null), p = D(o);
1284
- p.current = o;
1285
- let m = Mn(a) ? a : void 0, [h, g] = O(0), _ = r?.mode === "floating", v = m !== void 0 && !c, b = E(() => ({
1286
- containerRef: u,
1287
- toolbarRef: d
1288
- }), []), x = w((e) => {
1289
- l.current || e.read(() => {
1290
- let t = j().getTextContent(), r = $(ve(s, null)), i = wn(r, t) ? null : r;
1291
- f.current = i, m !== void 0 && g(t.length), n({
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({
1292
1924
  text: t,
1293
- html: i
1925
+ html: r,
1926
+ attachment: i
1294
1927
  }, e);
1295
- }, { editor: s });
1928
+ }, { editor: u });
1296
1929
  }, [
1297
- n,
1298
- s,
1299
- m,
1300
- l
1930
+ u,
1931
+ b,
1932
+ f
1301
1933
  ]);
1302
- T(() => {
1303
- m === void 0 || c || s.getEditorState().read(() => {
1304
- g(j().getTextContentSize());
1305
- }, { editor: s });
1934
+ I(() => {
1935
+ b === void 0 || d || u.getEditorState().read(() => {
1936
+ S(H().getTextContentSize());
1937
+ }, { editor: u });
1306
1938
  }, [
1307
- s,
1308
- m,
1309
- c
1310
- ]), T(() => {
1311
- if (e.value === void 0 || e.value === f.current) return;
1312
- if (l.current) {
1313
- let t = e.value?.trim() ? $(e.value) : "", n = e.value;
1314
- Ln(t).then((e) => {
1315
- !l.current || f.current !== n || s.update(() => {
1316
- Rn(e);
1317
- });
1318
- }), f.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
+ });
1319
1949
  return;
1320
1950
  }
1321
1951
  let t = !1;
1322
- s.update(() => {
1323
- Cn(s, e.value?.trim() ? $(e.value) : ""), m !== void 0 && (t = Nn(s, m));
1324
- }), t && p.current?.();
1952
+ u.update(() => {
1953
+ ne(u, e.value?.trim() ? E(e.value) : ""), b !== void 0 && (t = $n(u, b));
1954
+ }), t && v.current?.();
1325
1955
  }, [
1326
1956
  e.value,
1327
- s,
1328
- m,
1329
- l
1957
+ u,
1958
+ b,
1959
+ f
1330
1960
  ]);
1331
- let ee = r?.config?.length ? r?.config : [], te = bt();
1332
- return /* @__PURE__ */ S(kt.Provider, {
1333
- value: b,
1334
- children: /* @__PURE__ */ C("div", {
1335
- ref: u,
1336
- className: k(Y["bsy-lexical-editor"], _ && Y["bsy-lexical-editor--floating"]),
1337
- onClick: (e) => {
1338
- let t = s.getRootElement(), n = e.target;
1339
- !t || !n || !t.contains(n) || s.isEditable() || s.setEditable(!0);
1340
- },
1341
- children: [
1342
- ee.length > 0 && /* @__PURE__ */ S(Rt, {
1343
- config: ee,
1344
- theme: i?.toolbar,
1345
- style: r?.style,
1346
- mode: r?.mode,
1347
- floating: r?.floating
1348
- }),
1349
- /* @__PURE__ */ S(pe, {
1350
- contentEditable: /* @__PURE__ */ S(me, {
1351
- className: k(Y["bsy-lexical-editor__content-editable"], v && Y["bsy-lexical-editor__content-editable--with-length-badge"]),
1352
- style: {
1353
- height: t,
1354
- cursor: te ? "auto" : "text"
1355
- }
1356
- }),
1357
- ErrorBoundary: _e
1358
- }),
1359
- /* @__PURE__ */ S(xt, {}),
1360
- /* @__PURE__ */ S(St, {}),
1361
- /* @__PURE__ */ S(Ht, {}),
1362
- /* @__PURE__ */ S(Vn, {}),
1363
- /* @__PURE__ */ S(Jt, {}),
1364
- /* @__PURE__ */ S(Zt, {}),
1365
- /* @__PURE__ */ S(Qt, {}),
1366
- /* @__PURE__ */ S(gn, {}),
1367
- /* @__PURE__ */ S(_n, {}),
1368
- /* @__PURE__ */ S(yn, {}),
1369
- v ? /* @__PURE__ */ S(bn, {
1370
- maxLength: m,
1371
- onMaxLengthExceed: o
1372
- }) : null,
1373
- /* @__PURE__ */ S(he, {}),
1374
- /* @__PURE__ */ S(ge, { onChange: x }),
1375
- v ? /* @__PURE__ */ S(Hn, {
1376
- current: h,
1377
- maxLength: m
1378
- }) : null
1379
- ]
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
+ })]
1380
1988
  })
1381
1989
  });
1382
- }, Wn = (e) => /* @__PURE__ */ S(zn, {
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"],
2016
+ style: {
2017
+ minHeight: _ === void 0 ? l : void 0,
2018
+ cursor: g ? "auto" : "text"
2019
+ }
2020
+ }),
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
+ ]
2048
+ });
2049
+ }), $r = (e) => /* @__PURE__ */ N(fr, {
1383
2050
  maxLength: e.maxLength,
1384
2051
  onMaxLengthExceed: e.onMaxLengthExceed,
1385
- children: /* @__PURE__ */ S(Un, { ...e })
2052
+ children: /* @__PURE__ */ N(Zr, { ...e })
1386
2053
  });
1387
- Wn.displayName = "BsyLexicalEditorCore";
2054
+ $r.displayName = "BsyLexicalEditorCore";
1388
2055
  //#endregion
1389
2056
  //#region src/components/Editor/htmlConfig.ts
1390
- var Gn = "1px solid #d9d9d9", Kn = { export: new Map([[q, (e, t) => {
2057
+ var ei = "1px solid #d9d9d9", ti = { export: new Map([[Ut, (e, t) => {
1391
2058
  let n = t.exportDOM(e);
1392
- return Ge(n.element) && (n.element.style.border = Gn), n;
1393
- }]]) }, qn = (e) => {
2059
+ return _t(n.element) && (n.element.style.border = ei), n;
2060
+ }]]) }, ni = (e) => {
1394
2061
  let { autoFocus: t = !1 } = e;
1395
- return /* @__PURE__ */ S(fe, {
1396
- initialConfig: E(() => ({
2062
+ return /* @__PURE__ */ N(Me, {
2063
+ initialConfig: L(() => ({
1397
2064
  namespace: "bsyLexicalEditor",
1398
2065
  onError: (e) => {
1399
2066
  console.error("Lexical error", e);
@@ -1429,30 +2096,30 @@ var Gn = "1px solid #d9d9d9", Kn = { export: new Map([[q, (e, t) => {
1429
2096
  tableRow: "editor-table-row",
1430
2097
  tableScrollableWrapper: "editor-table-scrollable-wrapper"
1431
2098
  },
1432
- html: Kn,
2099
+ html: ti,
1433
2100
  nodes: [
1434
- $e,
1435
- Qe,
1436
- nt,
1437
- tt,
1438
- yt,
1439
- G,
1440
- W,
1441
- ft,
1442
- pt,
1443
- q,
2101
+ Dt,
2102
+ Et,
2103
+ At,
2104
+ kt,
2105
+ Zt,
2106
+ It,
2107
+ Ft,
1444
2108
  Wt,
1445
- X,
2109
+ Gt,
2110
+ Ut,
2111
+ nn,
2112
+ Q,
1446
2113
  {
1447
- replace: L,
1448
- with: (e) => new X(e.__text),
1449
- withKlass: X
2114
+ replace: gt,
2115
+ with: (e) => new Q(e.__text),
2116
+ withKlass: Q
1450
2117
  }
1451
2118
  ]
1452
2119
  }), [t]),
1453
- children: /* @__PURE__ */ S(Wn, { ...e })
2120
+ children: /* @__PURE__ */ N($r, { ...e })
1454
2121
  });
1455
2122
  };
1456
- qn.displayName = "BsyLexicalEditor";
2123
+ ni.displayName = "BsyLexicalEditor";
1457
2124
  //#endregion
1458
- export { Ee as $getRoot, b as BaseButton, qn as default, v as listRegisteredToolbarButtons, f as registerToolbarButton, a as unregisterToolbarButton, qe as useLexicalComposerContext };
2125
+ export { Ke as $getRoot, u as BaseButton, ni as default, ae as listRegisteredToolbarButtons, k as registerToolbarButton, S as unregisterToolbarButton, yt as useLexicalComposerContext };