@lobehub/editor 4.15.0 → 4.15.2

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 (521) hide show
  1. package/es/_virtual/_rolldown/runtime.js +28 -0
  2. package/es/codemirror/components/CopyButton.d.ts +7 -0
  3. package/es/codemirror/components/CopyButton.js +24 -0
  4. package/es/codemirror/components/LanguageSelect.d.ts +7 -0
  5. package/es/codemirror/components/LanguageSelect.js +59 -0
  6. package/es/codemirror/components/MoreOptions.d.ts +7 -0
  7. package/es/codemirror/components/MoreOptions.js +66 -0
  8. package/es/codemirror/components/Toolbar.d.ts +7 -0
  9. package/es/codemirror/components/Toolbar.js +51 -0
  10. package/es/codemirror/components/style.js +7 -0
  11. package/es/codemirror/constants.d.ts +6 -0
  12. package/es/codemirror/constants.js +512 -0
  13. package/es/codemirror/loader.d.ts +61 -0
  14. package/es/codemirror/loader.js +77 -0
  15. package/es/codemirror/style.d.ts +4 -0
  16. package/es/codemirror/style.js +82 -0
  17. package/es/codemirror/theme.d.ts +132 -0
  18. package/es/codemirror/theme.js +75 -0
  19. package/es/codemirror/types.d.ts +53 -0
  20. package/es/codemirror.d.ts +9 -263
  21. package/es/codemirror.js +8 -1
  22. package/es/common/canUseDOM.js +11 -0
  23. package/es/common/sys.js +27 -0
  24. package/es/const/hotkey.js +100 -0
  25. package/es/editor-kernel/data-source.d.ts +15 -0
  26. package/es/editor-kernel/data-source.js +15 -0
  27. package/es/editor-kernel/event.d.ts +7 -0
  28. package/es/editor-kernel/event.js +19 -0
  29. package/es/editor-kernel/index.d.ts +5 -0
  30. package/es/editor-kernel/index.js +17 -0
  31. package/es/editor-kernel/inode/helper.js +87 -0
  32. package/es/editor-kernel/inode/i-element-node.d.ts +6 -0
  33. package/es/editor-kernel/inode/i-node.d.ts +6 -0
  34. package/es/editor-kernel/inode/index.d.ts +4 -0
  35. package/es/editor-kernel/inode/paragraph-node.d.ts +1 -0
  36. package/es/editor-kernel/inode/root-node.d.ts +9 -0
  37. package/es/editor-kernel/inode/text-node.d.ts +9 -0
  38. package/es/editor-kernel/kernel.d.ts +122 -0
  39. package/es/editor-kernel/kernel.js +661 -0
  40. package/es/editor-kernel/plugin.js +59 -0
  41. package/es/editor-kernel/react/LexicalErrorBoundary.d.ts +13 -0
  42. package/es/editor-kernel/react/LexicalErrorBoundary.js +19 -0
  43. package/es/editor-kernel/react/PortalAnchor.js +12 -0
  44. package/es/editor-kernel/react/PortalContainer.d.ts +14 -0
  45. package/es/editor-kernel/react/PortalContainer.js +25 -0
  46. package/es/editor-kernel/react/index.d.ts +5 -0
  47. package/es/editor-kernel/react/react-context.d.ts +11 -0
  48. package/es/editor-kernel/react/react-context.js +21 -0
  49. package/es/editor-kernel/react/react-editor.d.ts +16 -0
  50. package/es/editor-kernel/react/react-editor.js +32 -0
  51. package/es/editor-kernel/react/useAnchor.js +17 -0
  52. package/es/editor-kernel/react/useDecorators.js +54 -0
  53. package/es/editor-kernel/react/useEditable.js +25 -0
  54. package/es/editor-kernel/react/useLexicalEditor.d.ts +6 -0
  55. package/es/editor-kernel/react/useLexicalEditor.js +23 -0
  56. package/es/editor-kernel/react/useLexicalNodeSelection.js +86 -0
  57. package/es/editor-kernel/react/useTranslation.js +9 -0
  58. package/es/editor-kernel/utils.d.ts +46 -0
  59. package/es/editor-kernel/utils.js +138 -0
  60. package/es/headless/extract-media-from-editor-state.d.ts +22 -0
  61. package/es/headless/extract-media-from-editor-state.js +49 -0
  62. package/es/headless/index.d.ts +69 -0
  63. package/es/headless/index.js +189 -0
  64. package/es/headless/plugins/codeblock.js +82 -0
  65. package/es/headless.d.ts +20 -1
  66. package/es/headless.js +219 -20307
  67. package/es/index.d.ts +112 -3059
  68. package/es/index.js +100 -8484
  69. package/es/locale/index.d.ts +61 -0
  70. package/es/locale/index.js +62 -0
  71. package/es/node_modules/.pnpm/@types_mdast@4.0.4/node_modules/@types/mdast/index.d.ts +953 -0
  72. package/es/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +83 -0
  73. package/es/plugins/auto-complete/index.d.ts +2 -0
  74. package/es/plugins/auto-complete/node/placeholderNode.js +89 -0
  75. package/es/plugins/auto-complete/plugin/index.d.ts +31 -0
  76. package/es/plugins/auto-complete/plugin/index.js +395 -0
  77. package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.d.ts +7 -0
  78. package/es/plugins/auto-complete/react/ReactAutoCompletePlugin.js +60 -0
  79. package/es/plugins/auto-complete/react/index.d.ts +1 -0
  80. package/es/plugins/auto-complete/react/style.js +12 -0
  81. package/es/plugins/auto-complete/react/type.d.ts +25 -0
  82. package/es/plugins/block/command/index.d.ts +13 -0
  83. package/es/plugins/block/command/index.js +161 -0
  84. package/es/plugins/block/index.d.ts +5 -0
  85. package/es/plugins/block/plugin/index.d.ts +9 -0
  86. package/es/plugins/block/plugin/index.js +86 -0
  87. package/es/plugins/block/react/ReactBlockPlugin.d.ts +18 -0
  88. package/es/plugins/block/react/ReactBlockPlugin.js +457 -0
  89. package/es/plugins/block/react/core/runtime-context.js +19 -0
  90. package/es/plugins/block/react/core/types.d.ts +6 -0
  91. package/es/plugins/block/react/drag/drag-session.js +264 -0
  92. package/es/plugins/block/react/drag/drag-utils.js +95 -0
  93. package/es/plugins/block/react/index.d.ts +2 -0
  94. package/es/plugins/block/react/style.js +66 -0
  95. package/es/plugins/block/service/i-block-menu-service.d.ts +44 -0
  96. package/es/plugins/block/service/i-block-menu-service.js +43 -0
  97. package/es/plugins/block/service/index.d.ts +1 -0
  98. package/es/plugins/code/command/index.d.ts +7 -0
  99. package/es/plugins/code/command/index.js +30 -0
  100. package/es/plugins/code/index.d.ts +3 -0
  101. package/es/plugins/code/node/code.js +91 -0
  102. package/es/plugins/code/plugin/index.d.ts +9 -0
  103. package/es/plugins/code/plugin/index.js +74 -0
  104. package/es/plugins/code/plugin/registry.js +33 -0
  105. package/es/plugins/code/react/CodeReactPlugin.d.ts +7 -0
  106. package/es/plugins/code/react/CodeReactPlugin.js +27 -0
  107. package/es/plugins/code/react/index.d.ts +1 -0
  108. package/es/plugins/code/react/style.js +21 -0
  109. package/es/plugins/code/react/type.d.ts +7 -0
  110. package/es/plugins/codeblock/command/index.d.ts +8 -0
  111. package/es/plugins/codeblock/command/index.js +40 -0
  112. package/es/plugins/codeblock/index.d.ts +6 -0
  113. package/es/plugins/codeblock/index.js +5 -0
  114. package/es/plugins/codeblock/plugin/CodeHighlighterShiki.js +415 -0
  115. package/es/plugins/codeblock/plugin/FacadeShiki.js +193 -0
  116. package/es/plugins/codeblock/plugin/index.d.ts +16 -0
  117. package/es/plugins/codeblock/plugin/index.js +157 -0
  118. package/es/plugins/codeblock/plugin/invariant.js +14 -0
  119. package/es/plugins/codeblock/react/ReactCodeblockPlugin.d.ts +7 -0
  120. package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +27 -0
  121. package/es/plugins/codeblock/react/index.d.ts +2 -0
  122. package/es/plugins/codeblock/react/style.js +58 -0
  123. package/es/plugins/codeblock/react/type.d.ts +8 -0
  124. package/es/plugins/codeblock/utils/language.js +9 -0
  125. package/es/plugins/codemirror-block/command/index.d.ts +13 -0
  126. package/es/plugins/codemirror-block/command/index.js +67 -0
  127. package/es/plugins/codemirror-block/index.d.ts +3 -0
  128. package/es/plugins/codemirror-block/lib/mode.js +8 -0
  129. package/es/plugins/codemirror-block/node/CodeMirrorNode.d.ts +48 -0
  130. package/es/plugins/codemirror-block/node/CodeMirrorNode.js +205 -0
  131. package/es/plugins/codemirror-block/plugin/index.d.ts +12 -0
  132. package/es/plugins/codemirror-block/plugin/index.js +80 -0
  133. package/es/plugins/codemirror-block/react/CodemirrorNode.js +219 -0
  134. package/es/plugins/codemirror-block/react/ReactCodemirrorNode.d.ts +7 -0
  135. package/es/plugins/codemirror-block/react/ReactCodemirrorNode.js +26 -0
  136. package/es/plugins/codemirror-block/react/index.d.ts +1 -0
  137. package/es/plugins/codemirror-block/react/type.d.ts +6 -0
  138. package/es/plugins/common/command/index.d.ts +11 -0
  139. package/es/plugins/common/command/index.js +24 -0
  140. package/es/plugins/common/data-source/json-data-source.js +133 -0
  141. package/es/plugins/common/data-source/text-data-source.js +32 -0
  142. package/es/plugins/common/index.d.ts +6 -0
  143. package/es/plugins/common/node/ElementDOMSlot.js +30 -0
  144. package/es/plugins/common/node/cursor.d.ts +16 -0
  145. package/es/plugins/common/node/cursor.js +189 -0
  146. package/es/plugins/common/plugin/index.d.ts +43 -0
  147. package/es/plugins/common/plugin/index.js +338 -0
  148. package/es/plugins/common/plugin/mdReader.js +62 -0
  149. package/es/plugins/common/plugin/paste-handler.d.ts +11 -0
  150. package/es/plugins/common/plugin/paste-handler.js +61 -0
  151. package/es/plugins/common/plugin/register.js +306 -0
  152. package/es/plugins/common/react/Placeholder/index.js +65 -0
  153. package/es/plugins/common/react/Placeholder/style.js +22 -0
  154. package/es/plugins/common/react/ReactEditorContent.d.ts +7 -0
  155. package/es/plugins/common/react/ReactEditorContent.js +8 -0
  156. package/es/plugins/common/react/ReactPlainText.d.ts +7 -0
  157. package/es/plugins/common/react/ReactPlainText.js +192 -0
  158. package/es/plugins/common/react/index.d.ts +3 -0
  159. package/es/plugins/common/react/style.js +206 -0
  160. package/es/plugins/common/react/type.d.ts +94 -0
  161. package/es/plugins/common/utils/index.js +135 -0
  162. package/es/plugins/content-blocks/data-source/content-blocks-data-source.d.ts +15 -0
  163. package/es/plugins/content-blocks/data-source/content-blocks-data-source.js +21 -0
  164. package/es/plugins/content-blocks/index.d.ts +6 -0
  165. package/es/plugins/content-blocks/plugin/index.d.ts +10 -0
  166. package/es/plugins/content-blocks/plugin/index.js +24 -0
  167. package/es/plugins/content-blocks/types.d.ts +33 -0
  168. package/es/plugins/content-blocks/types.js +4 -0
  169. package/es/plugins/content-blocks/utils/extract-media-lists.d.ts +7 -0
  170. package/es/plugins/content-blocks/utils/extract-media-lists.js +32 -0
  171. package/es/plugins/content-blocks/utils/extract.d.ts +8 -0
  172. package/es/plugins/content-blocks/utils/extract.js +188 -0
  173. package/es/plugins/file/command/index.d.ts +9 -0
  174. package/es/plugins/file/command/index.js +31 -0
  175. package/es/plugins/file/index.d.ts +4 -0
  176. package/es/plugins/file/node/FileNode.d.ts +38 -0
  177. package/es/plugins/file/node/FileNode.js +106 -0
  178. package/es/plugins/file/plugin/index.d.ts +18 -0
  179. package/es/plugins/file/plugin/index.js +103 -0
  180. package/es/plugins/file/react/ReactFilePlugin.d.ts +7 -0
  181. package/es/plugins/file/react/ReactFilePlugin.js +35 -0
  182. package/es/plugins/file/react/components/ReactFile.js +50 -0
  183. package/es/plugins/file/react/index.d.ts +2 -0
  184. package/es/plugins/file/react/style.js +32 -0
  185. package/es/plugins/file/react/type.d.ts +17 -0
  186. package/es/plugins/file/utils/index.js +29 -0
  187. package/es/plugins/hr/command/index.d.ts +7 -0
  188. package/es/plugins/hr/command/index.js +14 -0
  189. package/es/plugins/hr/index.d.ts +4 -0
  190. package/es/plugins/hr/node/HorizontalRuleNode.d.ts +18 -0
  191. package/es/plugins/hr/node/HorizontalRuleNode.js +59 -0
  192. package/es/plugins/hr/plugin/index.d.ts +12 -0
  193. package/es/plugins/hr/plugin/index.js +60 -0
  194. package/es/plugins/hr/react/ReactHRPlugin.d.ts +7 -0
  195. package/es/plugins/hr/react/ReactHRPlugin.js +28 -0
  196. package/es/plugins/hr/react/components/HRNode.js +36 -0
  197. package/es/plugins/hr/react/index.d.ts +2 -0
  198. package/es/plugins/hr/react/style.js +32 -0
  199. package/es/plugins/hr/react/type.d.ts +6 -0
  200. package/es/plugins/image/command/index.d.ts +12 -0
  201. package/es/plugins/image/command/index.js +53 -0
  202. package/es/plugins/image/index.d.ts +4 -0
  203. package/es/plugins/image/node/basie-image-node.d.ts +33 -0
  204. package/es/plugins/image/node/basie-image-node.js +68 -0
  205. package/es/plugins/image/node/block-image-node.d.ts +43 -0
  206. package/es/plugins/image/node/block-image-node.js +137 -0
  207. package/es/plugins/image/node/image-node.d.ts +41 -0
  208. package/es/plugins/image/node/image-node.js +128 -0
  209. package/es/plugins/image/plugin/index.d.ts +24 -0
  210. package/es/plugins/image/plugin/index.js +183 -0
  211. package/es/plugins/image/react/ReactImagePlugin.d.ts +7 -0
  212. package/es/plugins/image/react/ReactImagePlugin.js +41 -0
  213. package/es/plugins/image/react/components/BrokenImage.js +16 -0
  214. package/es/plugins/image/react/components/Image.js +190 -0
  215. package/es/plugins/image/react/components/ImageEditPopover.js +160 -0
  216. package/es/plugins/image/react/components/LazyImage.js +73 -0
  217. package/es/plugins/image/react/components/ResizeHandle.js +62 -0
  218. package/es/plugins/image/react/components/style.js +135 -0
  219. package/es/plugins/image/react/components/useSupenseImage.js +22 -0
  220. package/es/plugins/image/react/index.d.ts +2 -0
  221. package/es/plugins/image/react/style.js +31 -0
  222. package/es/plugins/image/react/type.d.ts +23 -0
  223. package/es/plugins/inode/index.d.ts +3 -0
  224. package/es/plugins/inode/plugin/index.d.ts +19 -0
  225. package/es/plugins/inode/plugin/index.js +23 -0
  226. package/es/plugins/inode/react/index.d.ts +6 -0
  227. package/es/plugins/inode/react/index.js +15 -0
  228. package/es/plugins/inode/service/index.d.ts +17 -0
  229. package/es/plugins/inode/service/index.js +22 -0
  230. package/es/plugins/link/command/index.d.ts +10 -0
  231. package/es/plugins/link/command/index.js +33 -0
  232. package/es/plugins/link/index.d.ts +5 -0
  233. package/es/plugins/link/node/LinkNode.d.ts +10 -0
  234. package/es/plugins/link/node/LinkNode.js +448 -0
  235. package/es/plugins/link/plugin/index.d.ts +16 -0
  236. package/es/plugins/link/plugin/index.js +106 -0
  237. package/es/plugins/link/plugin/registry.js +82 -0
  238. package/es/plugins/link/react/ReactLinkPlugin.d.ts +7 -0
  239. package/es/plugins/link/react/ReactLinkPlugin.js +50 -0
  240. package/es/plugins/link/react/components/LinkEdit.js +204 -0
  241. package/es/plugins/link/react/components/LinkToolbar.js +148 -0
  242. package/es/plugins/link/react/index.d.ts +2 -0
  243. package/es/plugins/link/react/style.js +34 -0
  244. package/es/plugins/link/react/type.d.ts +14 -0
  245. package/es/plugins/link/service/i-link-service.d.ts +10 -0
  246. package/es/plugins/link/service/i-link-service.js +19 -0
  247. package/es/plugins/link/utils/index.js +45 -0
  248. package/es/plugins/link-highlight/command/index.d.ts +8 -0
  249. package/es/plugins/link-highlight/command/index.js +30 -0
  250. package/es/plugins/link-highlight/index.d.ts +3 -0
  251. package/es/plugins/link-highlight/node/link-highlight.js +80 -0
  252. package/es/plugins/link-highlight/plugin/index.d.ts +18 -0
  253. package/es/plugins/link-highlight/plugin/index.js +109 -0
  254. package/es/plugins/link-highlight/plugin/registry.js +33 -0
  255. package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.d.ts +7 -0
  256. package/es/plugins/link-highlight/react/ReactLinkHighlightPlugin.js +29 -0
  257. package/es/plugins/link-highlight/react/index.d.ts +1 -0
  258. package/es/plugins/link-highlight/react/style.js +14 -0
  259. package/es/plugins/link-highlight/react/type.d.ts +16 -0
  260. package/es/plugins/list/command/index.d.ts +3 -0
  261. package/es/plugins/list/command/index.js +3 -0
  262. package/es/plugins/list/index.d.ts +5 -0
  263. package/es/plugins/list/plugin/checkList.d.ts +6 -0
  264. package/es/plugins/list/plugin/checkList.js +140 -0
  265. package/es/plugins/list/plugin/index.d.ts +9 -0
  266. package/es/plugins/list/plugin/index.js +195 -0
  267. package/es/plugins/list/plugin/registry.js +68 -0
  268. package/es/plugins/list/react/ReactListPlugin.d.ts +7 -0
  269. package/es/plugins/list/react/ReactListPlugin.js +21 -0
  270. package/es/plugins/list/react/index.d.ts +2 -0
  271. package/es/plugins/list/react/style.js +123 -0
  272. package/es/plugins/list/react/type.d.ts +7 -0
  273. package/es/plugins/list/utils/index.js +58 -0
  274. package/es/plugins/litexml/command/diffCommand.d.ts +17 -0
  275. package/es/plugins/litexml/command/diffCommand.js +97 -0
  276. package/es/plugins/litexml/command/index.d.ts +38 -0
  277. package/es/plugins/litexml/command/index.js +333 -0
  278. package/es/plugins/litexml/data-source/litexml-data-source.d.ts +65 -0
  279. package/es/plugins/litexml/data-source/litexml-data-source.js +286 -0
  280. package/es/plugins/litexml/index.d.ts +7 -0
  281. package/es/plugins/litexml/node/DiffNode.d.ts +29 -0
  282. package/es/plugins/litexml/node/DiffNode.js +95 -0
  283. package/es/plugins/litexml/plugin/index.d.ts +24 -0
  284. package/es/plugins/litexml/plugin/index.js +100 -0
  285. package/es/plugins/litexml/react/DiffNodeToolbar/index.js +60 -0
  286. package/es/plugins/litexml/react/DiffNodeToolbar/style.js +24 -0
  287. package/es/plugins/litexml/react/hooks/useHasDiffNode.d.ts +7 -0
  288. package/es/plugins/litexml/react/hooks/useHasDiffNode.js +35 -0
  289. package/es/plugins/litexml/react/index.d.ts +6 -0
  290. package/es/plugins/litexml/react/index.js +26 -0
  291. package/es/plugins/litexml/react/style.js +124 -0
  292. package/es/plugins/litexml/service/litexml-service.d.ts +93 -0
  293. package/es/plugins/litexml/service/litexml-service.js +42 -0
  294. package/es/plugins/litexml/utils/index.js +59 -0
  295. package/es/plugins/markdown/command/index.d.ts +14 -0
  296. package/es/plugins/markdown/command/index.js +74 -0
  297. package/es/plugins/markdown/data-source/markdown/parse.d.ts +14 -0
  298. package/es/plugins/markdown/data-source/markdown/parse.js +195 -0
  299. package/es/plugins/markdown/data-source/markdown-data-source.js +148 -0
  300. package/es/plugins/markdown/data-source/markdown-writer-context.js +40 -0
  301. package/es/plugins/markdown/index.d.ts +7 -0
  302. package/es/plugins/markdown/plugin/index.d.ts +22 -0
  303. package/es/plugins/markdown/plugin/index.js +285 -0
  304. package/es/plugins/markdown/react/index.d.ts +6 -0
  305. package/es/plugins/markdown/react/index.js +31 -0
  306. package/es/plugins/markdown/service/shortcut.d.ts +57 -0
  307. package/es/plugins/markdown/service/shortcut.js +101 -0
  308. package/es/plugins/markdown/service/transformers.d.ts +61 -0
  309. package/es/plugins/markdown/service/transformers.js +119 -0
  310. package/es/plugins/markdown/utils/detectLanguage.d.ts +22 -0
  311. package/es/plugins/markdown/utils/detectLanguage.js +251 -0
  312. package/es/plugins/markdown/utils/index.d.ts +11 -0
  313. package/es/plugins/markdown/utils/index.js +143 -0
  314. package/es/plugins/markdown/utils/logger.js +6 -0
  315. package/es/plugins/math/command/index.d.ts +9 -0
  316. package/es/plugins/math/command/index.js +38 -0
  317. package/es/plugins/math/index.d.ts +3 -0
  318. package/es/plugins/math/node/index.d.ts +44 -0
  319. package/es/plugins/math/node/index.js +161 -0
  320. package/es/plugins/math/plugin/index.d.ts +15 -0
  321. package/es/plugins/math/plugin/index.js +119 -0
  322. package/es/plugins/math/react/components/MathEditor.js +198 -0
  323. package/es/plugins/math/react/components/MathEditorContainer.js +101 -0
  324. package/es/plugins/math/react/components/MathEditorContent.js +133 -0
  325. package/es/plugins/math/react/components/MathInline.js +86 -0
  326. package/es/plugins/math/react/components/Placeholder.js +24 -0
  327. package/es/plugins/math/react/index.d.ts +7 -0
  328. package/es/plugins/math/react/index.js +35 -0
  329. package/es/plugins/math/react/style.js +96 -0
  330. package/es/plugins/math/react/type.d.ts +17 -0
  331. package/es/plugins/math/utils/index.js +23 -0
  332. package/es/plugins/mention/command/index.d.ts +10 -0
  333. package/es/plugins/mention/command/index.js +18 -0
  334. package/es/plugins/mention/index.d.ts +5 -0
  335. package/es/plugins/mention/node/MentionNode.d.ts +28 -0
  336. package/es/plugins/mention/node/MentionNode.js +86 -0
  337. package/es/plugins/mention/plugin/index.d.ts +18 -0
  338. package/es/plugins/mention/plugin/index.js +63 -0
  339. package/es/plugins/mention/plugin/register.js +30 -0
  340. package/es/plugins/mention/react/ReactMentionPlugin.d.ts +7 -0
  341. package/es/plugins/mention/react/ReactMentionPlugin.js +36 -0
  342. package/es/plugins/mention/react/components/Mention.js +33 -0
  343. package/es/plugins/mention/react/index.d.ts +2 -0
  344. package/es/plugins/mention/react/style.js +34 -0
  345. package/es/plugins/mention/react/type.d.ts +12 -0
  346. package/es/plugins/slash/index.d.ts +6 -0
  347. package/es/plugins/slash/plugin/index.d.ts +27 -0
  348. package/es/plugins/slash/plugin/index.js +160 -0
  349. package/es/plugins/slash/react/ReactSlashOption.d.ts +7 -0
  350. package/es/plugins/slash/react/ReactSlashOption.js +8 -0
  351. package/es/plugins/slash/react/ReactSlashPlugin.d.ts +7 -0
  352. package/es/plugins/slash/react/ReactSlashPlugin.js +190 -0
  353. package/es/plugins/slash/react/components/DefaultSlashMenu.js +168 -0
  354. package/es/plugins/slash/react/components/SlashMenu.d.ts +11 -0
  355. package/es/plugins/slash/react/components/SlashMenu.js +40 -0
  356. package/es/plugins/slash/react/index.d.ts +4 -0
  357. package/es/plugins/slash/react/type.d.ts +114 -0
  358. package/es/plugins/slash/react/utils.js +18 -0
  359. package/es/plugins/slash/service/i-slash-service.d.ts +50 -0
  360. package/es/plugins/slash/service/i-slash-service.js +55 -0
  361. package/es/plugins/slash/utils/utils.d.ts +1 -0
  362. package/es/plugins/slash/utils/utils.js +97 -0
  363. package/es/plugins/table/command/index.d.ts +17 -0
  364. package/es/plugins/table/command/index.js +57 -0
  365. package/es/plugins/table/index.d.ts +3 -0
  366. package/es/plugins/table/node/index.js +18 -0
  367. package/es/plugins/table/plugin/index.d.ts +8 -0
  368. package/es/plugins/table/plugin/index.js +172 -0
  369. package/es/plugins/table/react/TableActionMenu/ActionMenu.js +220 -0
  370. package/es/plugins/table/react/TableActionMenu/index.js +128 -0
  371. package/es/plugins/table/react/TableActionMenu/style.js +20 -0
  372. package/es/plugins/table/react/TableActionMenu/utils.js +34 -0
  373. package/es/plugins/table/react/TableHoverActions/index.js +147 -0
  374. package/es/plugins/table/react/TableHoverActions/style.js +14 -0
  375. package/es/plugins/table/react/TableHoverActions/utils.js +32 -0
  376. package/es/plugins/table/react/TableResize/index.js +253 -0
  377. package/es/plugins/table/react/TableResize/style.js +16 -0
  378. package/es/plugins/table/react/TableResize/utils.js +9 -0
  379. package/es/plugins/table/react/index.d.ts +7 -0
  380. package/es/plugins/table/react/index.js +49 -0
  381. package/es/plugins/table/react/style.js +63 -0
  382. package/es/plugins/table/react/type.d.ts +8 -0
  383. package/es/plugins/table/utils/index.js +48 -0
  384. package/es/plugins/toolbar/command/index.d.ts +12 -0
  385. package/es/plugins/toolbar/command/index.js +17 -0
  386. package/es/plugins/toolbar/index.d.ts +2 -0
  387. package/es/plugins/toolbar/react/index.d.ts +7 -0
  388. package/es/plugins/toolbar/react/index.js +109 -0
  389. package/es/plugins/toolbar/react/style.js +55 -0
  390. package/es/plugins/toolbar/react/type.d.ts +9 -0
  391. package/es/plugins/toolbar/utils/getDOMRangeRect.js +20 -0
  392. package/es/plugins/toolbar/utils/setFloatingElemPosition.js +50 -0
  393. package/es/plugins/upload/index.d.ts +2 -0
  394. package/es/plugins/upload/plugin/index.d.ts +6 -0
  395. package/es/plugins/upload/plugin/index.js +47 -0
  396. package/es/plugins/upload/service/i-upload-service.d.ts +13 -0
  397. package/es/plugins/upload/service/i-upload-service.js +30 -0
  398. package/es/plugins/upload/utils/index.js +15 -0
  399. package/es/plugins/virtual-block/index.d.ts +2 -0
  400. package/es/plugins/virtual-block/plugin/index.d.ts +8 -0
  401. package/es/plugins/virtual-block/plugin/index.js +19 -0
  402. package/es/plugins/virtual-block/plugin/register.js +150 -0
  403. package/es/plugins/virtual-block/react/ReactVirtualBlock.d.ts +6 -0
  404. package/es/plugins/virtual-block/react/ReactVirtualBlock.js +15 -0
  405. package/es/plugins/virtual-block/react/index.d.ts +1 -0
  406. package/es/react/ChatInput/ChatInput.d.ts +7 -0
  407. package/es/react/ChatInput/ChatInput.js +91 -0
  408. package/es/react/ChatInput/index.d.ts +2 -0
  409. package/es/react/ChatInput/style.js +115 -0
  410. package/es/react/ChatInput/type.d.ts +32 -0
  411. package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +7 -0
  412. package/es/react/ChatInputActionBar/ChatInputActionBar.js +22 -0
  413. package/es/react/ChatInputActionBar/index.d.ts +2 -0
  414. package/es/react/ChatInputActionBar/style.js +7 -0
  415. package/es/react/ChatInputActionBar/type.d.ts +10 -0
  416. package/es/react/ChatInputActions/ChatInputActions.d.ts +7 -0
  417. package/es/react/ChatInputActions/ChatInputActions.js +65 -0
  418. package/es/react/ChatInputActions/components/ActionItem.js +46 -0
  419. package/es/react/ChatInputActions/components/ActionRender.js +45 -0
  420. package/es/react/ChatInputActions/components/CollapsedActions.js +60 -0
  421. package/es/react/ChatInputActions/components/useDisplayActionCount.js +45 -0
  422. package/es/react/ChatInputActions/index.d.ts +2 -0
  423. package/es/react/ChatInputActions/style.js +20 -0
  424. package/es/react/ChatInputActions/type.d.ts +36 -0
  425. package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +7 -0
  426. package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +67 -0
  427. package/es/react/CodeLanguageSelect/index.d.ts +2 -0
  428. package/es/react/CodeLanguageSelect/style.js +7 -0
  429. package/es/react/CodeLanguageSelect/type.d.ts +6 -0
  430. package/es/react/Editor/Editor.js +108 -0
  431. package/es/react/Editor/index.d.ts +16 -0
  432. package/es/react/Editor/index.js +11 -0
  433. package/es/react/Editor/type.d.ts +64 -0
  434. package/es/react/Editor/utils.d.ts +6 -0
  435. package/es/react/Editor/utils.js +6 -0
  436. package/es/react/EditorProvider/index.d.ts +28 -0
  437. package/es/react/EditorProvider/index.js +18 -0
  438. package/es/react/FloatActions/FloatActions.d.ts +7 -0
  439. package/es/react/FloatActions/FloatActions.js +34 -0
  440. package/es/react/FloatActions/components/ActionItem.js +46 -0
  441. package/es/react/FloatActions/components/ActionRender.js +45 -0
  442. package/es/react/FloatActions/components/CollapsedActions.js +60 -0
  443. package/es/react/FloatActions/index.d.ts +2 -0
  444. package/es/react/FloatActions/style.js +19 -0
  445. package/es/react/FloatActions/type.d.ts +33 -0
  446. package/es/react/FloatMenu/FloatMenu.d.ts +7 -0
  447. package/es/react/FloatMenu/FloatMenu.js +32 -0
  448. package/es/react/FloatMenu/index.d.ts +2 -0
  449. package/es/react/FloatMenu/style.js +28 -0
  450. package/es/react/FloatMenu/type.d.ts +25 -0
  451. package/es/react/SendButton/SendButton.d.ts +7 -0
  452. package/es/react/SendButton/SendButton.js +107 -0
  453. package/es/react/SendButton/components/SendIcon.js +23 -0
  454. package/es/react/SendButton/components/StopIcon.js +56 -0
  455. package/es/react/SendButton/index.d.ts +2 -0
  456. package/es/react/SendButton/style.js +68 -0
  457. package/es/react/SendButton/type.d.ts +12 -0
  458. package/es/react/SlashMenu/SlashMenu.d.ts +7 -0
  459. package/es/react/SlashMenu/SlashMenu.js +40 -0
  460. package/es/react/SlashMenu/index.d.ts +2 -0
  461. package/es/react/SlashMenu/type.d.ts +17 -0
  462. package/es/react/hooks/useEditor.d.ts +5 -0
  463. package/es/react/hooks/useEditor.js +8 -0
  464. package/es/react/hooks/useEditorState/index.d.ts +71 -0
  465. package/es/react/hooks/useEditorState/index.js +347 -0
  466. package/es/react/hooks/useEditorState/utils.js +28 -0
  467. package/es/react/hooks/useSize.js +61 -0
  468. package/es/react.d.ts +22 -334
  469. package/es/react.js +13 -1573
  470. package/es/renderer/LexicalDiff.d.ts +41 -0
  471. package/es/renderer/LexicalDiff.js +96 -0
  472. package/es/renderer/LexicalRenderer.d.ts +16 -0
  473. package/es/renderer/LexicalRenderer.js +48 -0
  474. package/es/renderer/diff/compute.js +396 -0
  475. package/es/renderer/diff/style.d.ts +4 -0
  476. package/es/renderer/diff/style.js +104 -0
  477. package/es/renderer/diff/types.d.ts +32 -0
  478. package/es/renderer/engine/render-builtin-node.js +196 -0
  479. package/es/renderer/engine/render-text-node.js +33 -0
  480. package/es/renderer/engine/render-tree.js +35 -0
  481. package/es/renderer/engine/shiki.d.ts +4 -0
  482. package/es/renderer/engine/shiki.js +24 -0
  483. package/es/renderer/engine/utils.js +16 -0
  484. package/es/renderer/nodes/index.d.ts +6 -0
  485. package/es/renderer/nodes/index.js +44 -0
  486. package/es/renderer/renderers/codeblock.js +21 -0
  487. package/es/renderer/renderers/file.js +29 -0
  488. package/es/renderer/renderers/horizontalrule.js +29 -0
  489. package/es/renderer/renderers/image.js +35 -0
  490. package/es/renderer/renderers/index.d.ts +6 -0
  491. package/es/renderer/renderers/index.js +21 -0
  492. package/es/renderer/renderers/math.js +19 -0
  493. package/es/renderer/renderers/mention.js +15 -0
  494. package/es/renderer/renderers/mermaid.js +17 -0
  495. package/es/renderer/style.js +52 -0
  496. package/es/renderer/types.d.ts +29 -0
  497. package/es/renderer.d.ts +8 -114
  498. package/es/renderer.js +5 -1153
  499. package/es/types/hotkey.d.ts +76 -0
  500. package/es/types/hotkey.js +65 -0
  501. package/es/types/index.d.ts +2 -0
  502. package/es/types/kernel.d.ts +359 -0
  503. package/es/types/locale.d.ts +11 -0
  504. package/es/utils/cx.js +4 -0
  505. package/es/utils/debug.d.ts +425 -0
  506. package/es/{debug-CIvbNHJu.js → utils/debug.js} +3 -35
  507. package/es/utils/hotkey/isHotkeyMatch.js +17 -0
  508. package/es/utils/hotkey/parseHotkeys.js +53 -0
  509. package/es/utils/hotkey/registerHotkey.d.ts +18 -0
  510. package/es/utils/hotkey/registerHotkey.js +35 -0
  511. package/es/utils/scrollIntoView.d.ts +8 -0
  512. package/es/utils/scrollIntoView.js +29 -0
  513. package/es/utils/updatePosition.js +26 -0
  514. package/es/utils/url.d.ts +18 -0
  515. package/es/utils/url.js +34 -0
  516. package/package.json +4 -1
  517. package/es/ReactSlashPlugin-BiVy_Iwf.js +0 -23072
  518. package/es/codemirror-3POv7f__.js +0 -923
  519. package/es/index-DHGp94p0.d.ts +0 -916
  520. package/es/style-DADgHVA1.js +0 -2889
  521. package/es/style-DMdPzCo-.js +0 -999
@@ -1,2889 +0,0 @@
1
- import { d as __exportAll, n as createDebugLogger, s as init_debug, u as __esmMin } from "./debug-CIvbNHJu.js";
2
- import { createStaticStyles, cx, keyframes } from "antd-style";
3
- import { createHeadlessEditor } from "@lexical/headless";
4
- import { createEmptyHistoryState } from "@lexical/history";
5
- import { $createTableSelection, $isTableCellNode, $isTableNode, $isTableSelection } from "@lexical/table";
6
- import { get, merge, template, templateSettings } from "es-toolkit/compat";
7
- import EventEmitter from "eventemitter3";
8
- import { $applyNodeReplacement, $createNodeSelection, $createRangeSelection, $createTextNode, $getNodeByKey, $getRoot, $getSelection, $isDecoratorNode, $isElementNode, $isNodeSelection, $isParagraphNode, $isRangeSelection, $isTextNode, $normalizeSelection__EXPERIMENTAL, $setSelection, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, DecoratorNode, ElementNode, HISTORY_MERGE_TAG, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DOWN_COMMAND, TextNode, createCommand, createEditor, isHTMLElement, isModifierMatch, resetRandomKey as resetRandomKey$1 } from "lexical";
9
- import { $isQuoteNode } from "@lexical/rich-text";
10
- import { $findMatchingParent, IS_APPLE, IS_APPLE as isApple, addClassNamesToElement, isHTMLAnchorElement, mergeRegister } from "@lexical/utils";
11
- //#region src/locale/index.ts
12
- var locale_default;
13
- var init_locale = __esmMin((() => {
14
- locale_default = {
15
- block: { delete: "Delete block" },
16
- cancel: "Cancel",
17
- codemirror: {
18
- copySuccess: "Code copied to clipboard",
19
- selectLanguage: "Select language",
20
- selectTheme: "Select theme",
21
- showLineNumbers: "Show Line Numbers",
22
- tabSize: "Tab Size",
23
- theme: "Theme",
24
- useTabs: "Use Tabs"
25
- },
26
- confirm: "Confirm",
27
- file: {
28
- error: "Error: {{message}}",
29
- uploading: "Uploading file..."
30
- },
31
- image: {
32
- broken: "Broken image",
33
- replace: "Replace"
34
- },
35
- link: {
36
- edit: "Edit Link",
37
- editLinkTitle: "Link",
38
- editTextTitle: "Text",
39
- open: "Open Link",
40
- placeholder: "Enter link URL",
41
- unlink: "Unlink Link"
42
- },
43
- markdown: {
44
- autoFormatMessage: "Markdown was converted automatically. Use Command/Ctrl + Z to undo this conversion.",
45
- autoFormatTitle: "Markdown Converted",
46
- cancel: "Cancel",
47
- confirm: "Confirm",
48
- parseMessage: "Convert to markdown format, existing content will be overwritten, confirm? (Auto close in 5 seconds)",
49
- parseTitle: "Parse Markdown"
50
- },
51
- math: { placeholder: "Enter TeX formula" },
52
- modifier: {
53
- accept: "Accept",
54
- acceptAll: "Accept All",
55
- reject: "Reject",
56
- rejectedAll: "Reject All"
57
- },
58
- table: {
59
- delete: "Delete table",
60
- deleteColumn: "Delete column",
61
- deleteRow: "Delete row",
62
- insertColumnLeft: "Insert {{count}} column(s) to the left",
63
- insertColumnRight: "Insert {{count}} column(s) to the right",
64
- insertRowAbove: "Insert {{count}} row(s) above",
65
- insertRowBelow: "Insert {{count}} row(s) below"
66
- }
67
- };
68
- }));
69
- //#endregion
70
- //#region src/editor-kernel/inode/helper.ts
71
- var BaseContent, INodeHelper;
72
- var init_helper = __esmMin((() => {
73
- BaseContent = {
74
- direction: "ltr",
75
- format: "",
76
- indent: 0,
77
- type: "",
78
- version: 1
79
- };
80
- INodeHelper = {
81
- appendChild(parent, ...child) {
82
- if (!parent.children) parent.children = [];
83
- parent.children.push(...child);
84
- },
85
- createElementNode(type, attrs = {}) {
86
- return {
87
- ...BaseContent,
88
- children: [],
89
- ...attrs,
90
- type
91
- };
92
- },
93
- createLikeTextNode(type, text, attrs = {}) {
94
- return {
95
- ...BaseContent,
96
- detail: 0,
97
- format: 0,
98
- mode: "normal",
99
- style: "",
100
- ...attrs,
101
- text,
102
- type
103
- };
104
- },
105
- createParagraph(attrs = {}) {
106
- return {
107
- ...BaseContent,
108
- children: [],
109
- textFormat: 0,
110
- textStyle: "",
111
- ...attrs,
112
- type: "paragraph"
113
- };
114
- },
115
- createRootNode(attrs = {}) {
116
- return {
117
- ...BaseContent,
118
- ...attrs,
119
- children: [],
120
- type: "root"
121
- };
122
- },
123
- createTextNode(text, attrs = {}) {
124
- return {
125
- ...BaseContent,
126
- detail: 0,
127
- format: 0,
128
- mode: "normal",
129
- style: "",
130
- ...attrs,
131
- text,
132
- type: "text"
133
- };
134
- },
135
- createTypeNode(type, attrs = {}) {
136
- return {
137
- ...BaseContent,
138
- ...attrs,
139
- type
140
- };
141
- },
142
- isParagraphNode(node) {
143
- return node.type === "paragraph";
144
- },
145
- isRootNode(node) {
146
- return node.type === "root";
147
- },
148
- isTextNode(node) {
149
- return node.type === "text";
150
- }
151
- };
152
- }));
153
- //#endregion
154
- //#region src/plugins/common/utils/index.ts
155
- /**
156
- * Returns the root's text content.
157
- * @returns The root's text content.
158
- */
159
- function $rootTextContent() {
160
- return $getRoot().getTextContent();
161
- }
162
- /**
163
- * Determines if the root has any text content and can trim any whitespace if it does.
164
- * @param isEditorComposing - Is the editor in composition mode due to an active Input Method Editor?
165
- * @param trim - Should the root text have its whitespaced trimmed? Defaults to true.
166
- * @returns true if text content is empty, false if there is text or isEditorComposing is true.
167
- */
168
- function $isRootTextContentEmpty(isEditorComposing, trim = true) {
169
- if (isEditorComposing) return false;
170
- let text = $rootTextContent();
171
- if (trim) text = text.trim();
172
- return text === "";
173
- }
174
- /**
175
- * Determines if the input should show the placeholder. If anything is in
176
- * in the root the placeholder should not be shown.
177
- * @param isComposing - Is the editor in composition mode due to an active Input Method Editor?
178
- * @returns true if the input should show the placeholder, false otherwise.
179
- */
180
- function $canShowPlaceholder(isComposing) {
181
- if (!$isRootTextContentEmpty(isComposing, false)) return false;
182
- const children = $getRoot().getChildren();
183
- const childrenLength = children.length;
184
- if (childrenLength > 1) return false;
185
- for (let i = 0; i < childrenLength; i++) {
186
- const topBlock = children[i];
187
- if ($isDecoratorNode(topBlock)) return false;
188
- if ($isElementNode(topBlock)) {
189
- if (!$isParagraphNode(topBlock)) return false;
190
- if (topBlock.__indent !== 0) return false;
191
- const topBlockChildren = topBlock.getChildren();
192
- const topBlockChildrenLength = topBlockChildren.length;
193
- for (let s = 0; s < topBlockChildrenLength; s++) {
194
- const child = topBlockChildren[i];
195
- if (!$isTextNode(child)) return false;
196
- }
197
- }
198
- }
199
- return true;
200
- }
201
- /**
202
- * Returns a function that executes {@link $canShowPlaceholder}
203
- * @param isEditorComposing - Is the editor in composition mode due to an active Input Method Editor?
204
- * @returns A function that executes $canShowPlaceholder with arguments.
205
- */
206
- function $canShowPlaceholderCurry(isEditorComposing) {
207
- return () => $canShowPlaceholder(isEditorComposing);
208
- }
209
- function $isCursorInTable(selection) {
210
- if (!$isRangeSelection(selection)) return {
211
- inCell: false,
212
- inTable: false
213
- };
214
- let currentNode = selection.focus.getNode();
215
- let inTable = false;
216
- let inCell = false;
217
- while (currentNode) {
218
- if ($isTableCellNode(currentNode)) {
219
- inCell = true;
220
- inTable = true;
221
- break;
222
- }
223
- if ($isTableNode(currentNode)) {
224
- inTable = true;
225
- break;
226
- }
227
- const parent = currentNode.getParent();
228
- if (!parent) break;
229
- currentNode = parent;
230
- }
231
- return {
232
- inCell,
233
- inTable
234
- };
235
- }
236
- function $isCursorInQuote(selection) {
237
- if (!$isRangeSelection(selection)) return false;
238
- let currentNode = selection.focus.getNode();
239
- while (currentNode) {
240
- if ($isQuoteNode(currentNode)) return true;
241
- const parent = currentNode.getParent();
242
- if (!parent) break;
243
- currentNode = parent;
244
- }
245
- return false;
246
- }
247
- function exportNodeToJSON(node) {
248
- const serializedNode = node.exportJSON();
249
- const nodeClass = node.constructor;
250
- serializedNode.id = node.getKey();
251
- if (serializedNode.type !== nodeClass.getType()) throw new Error(`LexicalNode: Node ${nodeClass.name} does not match the serialized type. Check if .exportJSON() is implemented and it is returning the correct type.`);
252
- if ($isElementNode(node)) {
253
- const serializedChildren = serializedNode.children;
254
- if (!Array.isArray(serializedChildren)) throw new Error(`LexicalNode: Node ${nodeClass.name} is an element but .exportJSON() does not have a children array.`);
255
- const children = node.getChildren();
256
- for (const child of children) {
257
- const serializedChildNode = exportNodeToJSON(child);
258
- serializedChildren.push(serializedChildNode);
259
- }
260
- }
261
- return serializedNode;
262
- }
263
- var sampleReader, createBlockNode;
264
- var init_utils$1 = __esmMin((() => {
265
- init_helper();
266
- sampleReader = (format, xmlElement, children) => {
267
- children.forEach((child) => {
268
- if (INodeHelper.isTextNode(child)) child.format = (child.format || 0) | format;
269
- });
270
- return children;
271
- };
272
- createBlockNode = (createNode) => {
273
- return (parentNode, children, match, isImport) => {
274
- const node = createNode(match, parentNode);
275
- node.append(...children);
276
- parentNode.replace(node);
277
- if (!isImport) node.select(0, 0);
278
- };
279
- };
280
- }));
281
- //#endregion
282
- //#region src/types/hotkey.ts
283
- var KeyEnum, HotkeyEnum, HotkeyScopeEnum;
284
- var init_hotkey$1 = __esmMin((() => {
285
- KeyEnum = {
286
- Alt: "alt",
287
- Backquote: "backquote",
288
- Backslash: "backslash",
289
- Backspace: "backspace",
290
- BracketLeft: "bracketleft",
291
- BracketRight: "bracketright",
292
- Comma: "comma",
293
- Ctrl: "ctrl",
294
- Down: "down",
295
- Enter: "enter",
296
- Equal: "equal",
297
- Esc: "esc",
298
- Left: "left",
299
- LeftClick: "left-click",
300
- LeftDoubleClick: "left-double-click",
301
- Meta: "meta",
302
- MiddleClick: "middle-click",
303
- Minus: "minus",
304
- Mod: "mod",
305
- Number: "1-9",
306
- Period: "period",
307
- Plus: "equal",
308
- QuestionMark: "slash",
309
- Quote: "quote",
310
- Right: "right",
311
- RightClick: "right-click",
312
- RightDoubleClick: "right-double-click",
313
- Semicolon: "semicolon",
314
- Shift: "shift",
315
- Slash: "slash",
316
- Space: "space",
317
- Tab: "tab",
318
- Up: "up",
319
- Zero: "0"
320
- };
321
- HotkeyEnum = {
322
- Bold: "bold",
323
- BulletList: "bulletList",
324
- CodeInline: "codeInline",
325
- Italic: "italic",
326
- Link: "link",
327
- Mention: "mention",
328
- NumberList: "numberList",
329
- PasteAsPlainText: "pasteAsPlainText",
330
- Redo: "redo",
331
- Slash: "slash",
332
- Strikethrough: "strikethrough",
333
- Underline: "underline",
334
- Undo: "undo"
335
- };
336
- HotkeyScopeEnum = {
337
- Format: "format",
338
- Insert: "insert",
339
- Plugin: "plugin",
340
- Slash: "slash"
341
- };
342
- }));
343
- //#endregion
344
- //#region src/const/hotkey.ts
345
- var combineKeys, HOTKEYS_REGISTRATION;
346
- var init_hotkey = __esmMin((() => {
347
- init_hotkey$1();
348
- combineKeys = (keys) => keys.join("+");
349
- HOTKEYS_REGISTRATION = [
350
- {
351
- id: HotkeyEnum.Undo,
352
- keys: combineKeys([KeyEnum.Mod, "z"]),
353
- priority: COMMAND_PRIORITY_LOW,
354
- scopes: [HotkeyScopeEnum.Format]
355
- },
356
- {
357
- id: HotkeyEnum.Redo,
358
- keys: combineKeys([KeyEnum.Mod, "y"]),
359
- priority: COMMAND_PRIORITY_LOW,
360
- scopes: [HotkeyScopeEnum.Format]
361
- },
362
- {
363
- id: HotkeyEnum.Bold,
364
- keys: combineKeys([KeyEnum.Mod, "b"]),
365
- priority: COMMAND_PRIORITY_LOW,
366
- scopes: [HotkeyScopeEnum.Format]
367
- },
368
- {
369
- id: HotkeyEnum.Italic,
370
- keys: combineKeys([KeyEnum.Mod, "i"]),
371
- priority: COMMAND_PRIORITY_LOW,
372
- scopes: [HotkeyScopeEnum.Format]
373
- },
374
- {
375
- id: HotkeyEnum.Underline,
376
- keys: combineKeys([KeyEnum.Mod, "u"]),
377
- priority: COMMAND_PRIORITY_LOW,
378
- scopes: [HotkeyScopeEnum.Format]
379
- },
380
- {
381
- id: HotkeyEnum.Strikethrough,
382
- keys: combineKeys([
383
- KeyEnum.Mod,
384
- KeyEnum.Shift,
385
- "x"
386
- ]),
387
- priority: COMMAND_PRIORITY_LOW,
388
- scopes: [HotkeyScopeEnum.Format]
389
- },
390
- {
391
- id: HotkeyEnum.CodeInline,
392
- keys: combineKeys([KeyEnum.Mod, "e"]),
393
- priority: COMMAND_PRIORITY_LOW,
394
- scopes: [HotkeyScopeEnum.Format, HotkeyScopeEnum.Plugin]
395
- },
396
- {
397
- id: HotkeyEnum.Link,
398
- keys: combineKeys([
399
- KeyEnum.Mod,
400
- KeyEnum.Shift,
401
- "k"
402
- ]),
403
- priority: COMMAND_PRIORITY_LOW,
404
- scopes: [HotkeyScopeEnum.Format, HotkeyScopeEnum.Plugin]
405
- },
406
- {
407
- id: HotkeyEnum.NumberList,
408
- keys: combineKeys([
409
- KeyEnum.Mod,
410
- KeyEnum.Shift,
411
- "7"
412
- ]),
413
- priority: COMMAND_PRIORITY_LOW,
414
- scopes: [HotkeyScopeEnum.Insert, HotkeyScopeEnum.Plugin]
415
- },
416
- {
417
- id: HotkeyEnum.BulletList,
418
- keys: combineKeys([
419
- KeyEnum.Mod,
420
- KeyEnum.Shift,
421
- "8"
422
- ]),
423
- priority: COMMAND_PRIORITY_LOW,
424
- scopes: [HotkeyScopeEnum.Insert, HotkeyScopeEnum.Plugin]
425
- },
426
- {
427
- id: HotkeyEnum.PasteAsPlainText,
428
- keys: combineKeys([
429
- KeyEnum.Mod,
430
- KeyEnum.Shift,
431
- "v"
432
- ]),
433
- priority: COMMAND_PRIORITY_LOW,
434
- scopes: [HotkeyScopeEnum.Format]
435
- }
436
- ];
437
- })), nodeDetect, browserDetect, isNode, isBrowser, macOSDetect, CONTROL_OR_META;
438
- var init_sys = __esmMin((() => {
439
- nodeDetect = () => {
440
- return typeof process !== "undefined" && process.versions && !!process.versions.node;
441
- };
442
- browserDetect = () => {
443
- return typeof window !== "undefined" && window.document !== void 0;
444
- };
445
- isNode = nodeDetect();
446
- isBrowser = browserDetect();
447
- macOSDetect = () => {
448
- if (isNode) return process.platform === "darwin";
449
- if (isBrowser) return window.navigator.platform.includes("Mac");
450
- return false;
451
- };
452
- macOSDetect();
453
- CONTROL_OR_META = {
454
- ctrlKey: !IS_APPLE,
455
- metaKey: IS_APPLE
456
- };
457
- }));
458
- //#endregion
459
- //#region src/utils/hotkey/parseHotkeys.ts
460
- function mapCode(key) {
461
- return (mappedKeys[key.trim()] || key.trim()).toLowerCase().replace(/key|digit|numpad/, "");
462
- }
463
- function parseHotkey(hotkey) {
464
- let keys = [];
465
- keys = hotkey.toLocaleLowerCase().split("+").map((k) => mapCode(k));
466
- const modifiers = {
467
- altKey: keys.includes("alt"),
468
- ctrlKey: keys.includes("ctrl") || keys.includes("control") || (!isApple ? keys.includes("mod") : false),
469
- metaKey: keys.includes("meta") || (isApple ? keys.includes("mod") : false),
470
- shiftKey: keys.includes("shift")
471
- };
472
- return {
473
- key: keys.find((k) => !reservedModifierKeywords.has(k)),
474
- modifiers
475
- };
476
- }
477
- var reservedModifierKeywords, mappedKeys;
478
- var init_parseHotkeys = __esmMin((() => {
479
- init_sys();
480
- reservedModifierKeywords = new Set([
481
- "shift",
482
- "alt",
483
- "meta",
484
- "mod",
485
- "ctrl",
486
- "control"
487
- ]);
488
- mappedKeys = {
489
- AltLeft: "alt",
490
- AltRight: "alt",
491
- ControlLeft: "ctrl",
492
- ControlRight: "ctrl",
493
- MetaLeft: "meta",
494
- MetaRight: "meta",
495
- OSLeft: "meta",
496
- OSRight: "meta",
497
- ShiftLeft: "shift",
498
- ShiftRight: "shift",
499
- down: "arrowdown",
500
- esc: "escape",
501
- left: "arrowleft",
502
- return: "enter",
503
- right: "arrowright",
504
- up: "arrowup"
505
- };
506
- }));
507
- //#endregion
508
- //#region src/utils/hotkey/isHotkeyMatch.ts
509
- var isHotkeyMatch;
510
- var init_isHotkeyMatch = __esmMin((() => {
511
- init_parseHotkeys();
512
- isHotkeyMatch = (event, hotkey) => {
513
- const keys = parseHotkey(hotkey);
514
- if (!isModifierMatch(event, keys.modifiers)) return false;
515
- if (mapCode(event.code) !== keys.key) return false;
516
- return true;
517
- };
518
- }));
519
- //#endregion
520
- //#region src/utils/hotkey/registerHotkey.ts
521
- var logger$3, registerHotkey, getHotkeyById;
522
- var init_registerHotkey = __esmMin((() => {
523
- init_hotkey();
524
- init_debug();
525
- init_parseHotkeys();
526
- init_isHotkeyMatch();
527
- logger$3 = createDebugLogger("hotkey");
528
- registerHotkey = (hotkey, callback, options = {}) => {
529
- return (e) => {
530
- if (!isHotkeyMatch(e, hotkey.keys)) return false;
531
- const keys = parseHotkey(hotkey.keys);
532
- if (options.preventDefault) e.preventDefault();
533
- if (options.stopPropagation) e.stopPropagation();
534
- callback(e, {
535
- keys: hotkey.keys,
536
- ...keys,
537
- scopes: hotkey.scopes
538
- });
539
- logger$3.debug(`⌨️ Hotkey matched: ${hotkey.id} [${hotkey.keys}]`, hotkey);
540
- return true;
541
- };
542
- };
543
- getHotkeyById = (id) => {
544
- return HOTKEYS_REGISTRATION.find((hotkey) => hotkey.id === id);
545
- };
546
- }));
547
- //#endregion
548
- //#region src/editor-kernel/event.ts
549
- function registerEvent(editor, dom) {
550
- const hoverHandler = (event) => {
551
- editor.dispatchCommand(HOVER_COMMAND, event);
552
- };
553
- dom.addEventListener("mouseenter", hoverHandler);
554
- return () => {
555
- dom.removeEventListener("mouseenter", hoverHandler);
556
- };
557
- }
558
- var HOVER_COMMAND;
559
- var init_event = __esmMin((() => {
560
- HOVER_COMMAND = createCommand();
561
- }));
562
- //#endregion
563
- //#region src/editor-kernel/plugin.ts
564
- var KernelPlugin;
565
- var init_plugin = __esmMin((() => {
566
- KernelPlugin = class extends EventEmitter {
567
- constructor(..._args) {
568
- super(..._args);
569
- this.clears = [];
570
- this.registeredDecorators = /* @__PURE__ */ new Set();
571
- }
572
- register(clear) {
573
- this.clears.push(clear);
574
- }
575
- registerClears(...clears) {
576
- clears.forEach((clear) => this.register(clear));
577
- }
578
- /**
579
- * Register a node transform and automatically clean it up on plugin destroy
580
- */
581
- registerNodeTransform(kernel, transform) {
582
- this.register(kernel.registerNodeTransform(transform));
583
- }
584
- /**
585
- * Register className(s) on contenteditable root and auto cleanup
586
- */
587
- registerRootClassName(kernel, className) {
588
- this.register(kernel.registerRootClassName(className));
589
- }
590
- /**
591
- * Register a decorator and track it for cleanup
592
- */
593
- registerDecorator(kernel, name, decorator) {
594
- kernel.registerDecorator(name, decorator);
595
- this.registeredDecorators.add(name);
596
- }
597
- /**
598
- * Unregister a specific decorator
599
- */
600
- unregisterDecorator(kernel, name) {
601
- const result = kernel.unregisterDecorator(name);
602
- if (result) this.registeredDecorators.delete(name);
603
- return result;
604
- }
605
- /**
606
- * Get all decorator names registered by this plugin
607
- */
608
- getRegisteredDecorators() {
609
- return Array.from(this.registeredDecorators);
610
- }
611
- destroy() {
612
- this.clears.forEach((clear) => clear());
613
- this.registeredDecorators.clear();
614
- }
615
- };
616
- }));
617
- //#endregion
618
- //#region src/editor-kernel/utils.ts
619
- function genServiceId(name) {
620
- return { __serviceId: name };
621
- }
622
- function createEmptyEditorState() {
623
- return createEditor().getEditorState();
624
- }
625
- function assert(cond, message) {
626
- if (cond) return;
627
- throw new Error(message);
628
- }
629
- function getNodeKeyFromDOMNode(dom, editor) {
630
- return dom[`__lexicalKey_${editor._key}`];
631
- }
632
- function $getNodeFromDOMNode(dom, editor, editorState) {
633
- const key = getNodeKeyFromDOMNode(dom, editor);
634
- if (key !== void 0) return $getNodeByKey(key, editorState);
635
- return null;
636
- }
637
- /**
638
- * @param x - The element being tested
639
- * @returns Returns true if x is a DOM Node, false otherwise.
640
- */
641
- function isDOMNode(x) {
642
- return typeof x === "object" && x !== null && "nodeType" in x && typeof x.nodeType === "number";
643
- }
644
- /**
645
- * @param x - The element being testing
646
- * @returns Returns true if x is a document fragment, false otherwise.
647
- */
648
- function isDocumentFragment(x) {
649
- return isDOMNode(x) && x.nodeType === 11;
650
- }
651
- function getParentElement(node) {
652
- const parentElement = node.assignedSlot || node.parentElement;
653
- return isDocumentFragment(parentElement) ? parentElement.host : parentElement;
654
- }
655
- function $getNearestNodeFromDOMNode$1(startingDOM, editor, editorState) {
656
- let dom = startingDOM;
657
- while (dom !== null) {
658
- const node = $getNodeFromDOMNode(dom, editor, editorState);
659
- if (node !== null) return node;
660
- dom = getParentElement(dom);
661
- }
662
- return null;
663
- }
664
- function getKernelFromEditor(editor) {
665
- return editor._createEditorArgs?.__kernel || editor._kernel;
666
- }
667
- function generateEditorId() {
668
- EditorId += 1;
669
- return `editor-${EditorId}`;
670
- }
671
- function registerEditorKernel(id, kernel) {
672
- EditorMap.set(id, kernel);
673
- }
674
- function unregisterEditorKernel(id) {
675
- EditorMap.delete(id);
676
- }
677
- function getKernelFromEditorConfig(config) {
678
- const id = config.theme[EDITOR_THEME_KEY];
679
- return EditorMap.get(id) || null;
680
- }
681
- /**
682
- *
683
- * @param nodeA
684
- * @param nodeB
685
- * @returns
686
- */
687
- function compareNodeOrder(nodeA, nodeB) {
688
- if (nodeA === nodeB) return 0;
689
- const pathA = [];
690
- const pathB = [];
691
- let currentA = nodeA;
692
- let currentB = nodeB;
693
- while (currentA) {
694
- pathA.unshift(currentA);
695
- currentA = currentA.getParent();
696
- }
697
- while (currentB) {
698
- pathB.unshift(currentB);
699
- currentB = currentB.getParent();
700
- }
701
- const minLength = Math.min(pathA.length, pathB.length);
702
- for (let i = 0; i < minLength; i++) if (pathA[i] !== pathB[i]) {
703
- const siblings = pathA[i].getParent()?.getChildren() || [];
704
- return siblings.indexOf(pathA[i]) - siblings.indexOf(pathB[i]);
705
- }
706
- if (pathA.length !== pathB.length) return pathA.length - pathB.length;
707
- return 0;
708
- }
709
- function $closest(node, test) {
710
- let current = node;
711
- while (current) {
712
- if (test(current)) return current;
713
- current = current.getParent();
714
- }
715
- return null;
716
- }
717
- function $closestNodeType(node, type) {
718
- return $closest(node, (n) => Array.isArray(type) ? type.includes(n.getType()) : n.getType() === type);
719
- }
720
- function moment() {
721
- return new Promise((resolve) => {
722
- queueMicrotask(() => resolve(true));
723
- });
724
- }
725
- function cloneDecorators(editor) {
726
- const currentDecorators = editor._decorators;
727
- const pendingDecorators = Object.assign({}, currentDecorators);
728
- editor._pendingDecorators = pendingDecorators;
729
- return pendingDecorators;
730
- }
731
- function reconcileDecorator(activeEditor, key, decorator) {
732
- let pendingDecorators = activeEditor._pendingDecorators;
733
- const currentDecorators = activeEditor._decorators;
734
- if (pendingDecorators === null) {
735
- if (currentDecorators[key] === decorator) return;
736
- pendingDecorators = cloneDecorators(activeEditor);
737
- }
738
- pendingDecorators[key] = decorator;
739
- }
740
- var DOM_ELEMENT_TYPE, DOM_TEXT_TYPE, DOM_DOCUMENT_TYPE, DOM_DOCUMENT_FRAGMENT_TYPE, noop, EditorId, EDITOR_THEME_KEY, EditorMap;
741
- var init_utils = __esmMin((() => {
742
- DOM_ELEMENT_TYPE = 1;
743
- DOM_TEXT_TYPE = 3;
744
- DOM_DOCUMENT_TYPE = 9;
745
- DOM_DOCUMENT_FRAGMENT_TYPE = 11;
746
- noop = () => {};
747
- EditorId = 0;
748
- EDITOR_THEME_KEY = "__editorId";
749
- EditorMap = /* @__PURE__ */ new Map();
750
- }));
751
- //#endregion
752
- //#region src/editor-kernel/kernel.ts
753
- var kernel_exports = /* @__PURE__ */ __exportAll({ Kernel: () => Kernel });
754
- var Kernel;
755
- var init_kernel = __esmMin((() => {
756
- init_locale();
757
- init_utils$1();
758
- init_debug();
759
- init_registerHotkey();
760
- init_event();
761
- init_plugin();
762
- init_utils();
763
- templateSettings.interpolate = /{{([\S\s]+?)}}/g;
764
- Kernel = class Kernel extends EventEmitter {
765
- static {
766
- this.globalHotReloadMode = void 0;
767
- }
768
- constructor() {
769
- super();
770
- this.plugins = [];
771
- this.pluginsConfig = /* @__PURE__ */ new Map();
772
- this.pluginsInstances = [];
773
- this.beforeEditorInitHooks = [];
774
- this.nodeTransforms = [];
775
- this.rootClassNames = /* @__PURE__ */ new Set();
776
- this.nodes = [];
777
- this.themes = { [EDITOR_THEME_KEY]: generateEditorId() };
778
- this.decorators = {};
779
- this.serviceMap = /* @__PURE__ */ new Map();
780
- this.localeMap = locale_default;
781
- this.hotReloadMode = false;
782
- this.logger = createDebugLogger("kernel");
783
- this.historyState = createEmptyHistoryState();
784
- this.headlessEditor = false;
785
- this._commands = /* @__PURE__ */ new Map();
786
- this._commandsClean = /* @__PURE__ */ new Map();
787
- this.dataTypeMap = /* @__PURE__ */ new Map();
788
- this.hotReloadMode = this.detectDevelopmentMode();
789
- this.logger.info(`🚀 Kernel initialized (hot reload: ${this.hotReloadMode})`);
790
- }
791
- cloneNodeEditor() {
792
- const newKernel = new Kernel();
793
- newKernel.registerPlugins(this.plugins);
794
- newKernel.initNodeEditor();
795
- newKernel.setDocument("json", this.getDocument("json") || "{}", { keepId: true });
796
- return newKernel;
797
- }
798
- getHistoryState() {
799
- return this.historyState;
800
- }
801
- isEditable() {
802
- return this.editor?.isEditable() || false;
803
- }
804
- detectDevelopmentMode() {
805
- if (Kernel.globalHotReloadMode !== void 0) return Kernel.globalHotReloadMode;
806
- if (typeof process !== "undefined" && true) return true;
807
- if (typeof window !== "undefined") {
808
- if (window.webpackHotUpdate) return true;
809
- if (window.__vite_plugin_react_preamble_installed__) return true;
810
- if (window.__NEXT_DATA__?.buildId === "development") return true;
811
- }
812
- if (typeof window !== "undefined" && window.location) {
813
- const hostname = window.location.hostname;
814
- if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.endsWith(".local")) return true;
815
- }
816
- return true;
817
- }
818
- /**
819
- * Globally enable or disable hot reload mode for all kernel instances
820
- * @param enabled Whether to enable hot reload mode globally
821
- */
822
- static setGlobalHotReloadMode(enabled) {
823
- Kernel.globalHotReloadMode = enabled;
824
- }
825
- /**
826
- * Reset global hot reload mode to automatic detection
827
- */
828
- static resetGlobalHotReloadMode() {
829
- Kernel.globalHotReloadMode = void 0;
830
- }
831
- getLexicalEditor() {
832
- return this.editor || null;
833
- }
834
- destroy() {
835
- unregisterEditorKernel(this.themes[EDITOR_THEME_KEY]);
836
- this.logger.info(`🗑️ Destroying editor with ${this.pluginsInstances.length} plugins`);
837
- try {
838
- this.editor?.setEditorState(createEmptyEditorState());
839
- } catch (error) {
840
- this.logger.warn("Failed to reset editor state during destroy:", error);
841
- }
842
- this.dataTypeMap.clear();
843
- this.pluginsInstances.forEach((plugin) => {
844
- if (plugin.destroy) plugin.destroy();
845
- });
846
- this.pluginsInstances = [];
847
- this.beforeEditorInitHooks = [];
848
- this.nodeTransforms = [];
849
- this.rootClassNames.clear();
850
- this.serviceMap.clear();
851
- this.decorators = {};
852
- this.themes = {};
853
- this.headlessEditor = false;
854
- this.logger.info("✅ Editor destroyed");
855
- }
856
- getRootElement() {
857
- if (this.headlessEditor) return null;
858
- return this.editor?.getRootElement() || null;
859
- }
860
- setRootElement(dom, editable = true) {
861
- if (this.editor) {
862
- if (this.headlessEditor) throw new Error("Headless editor cannot be attached to a root element.");
863
- this.logger.warn("[Editor] Editor is already initialized, updating root element only");
864
- this.editor.setRootElement(dom);
865
- this.applyRootClassNames(dom);
866
- return this.editor;
867
- }
868
- if (this.pluginsInstances.length === 0) {
869
- this.logger.info(`🔌 Initializing ${this.plugins.length} plugins`);
870
- for (const plugin of this.plugins) {
871
- const instance = new plugin(this, this.pluginsConfig.get(plugin));
872
- this.pluginsInstances.push(instance);
873
- }
874
- }
875
- this.runBeforeEditorInitLifecycle();
876
- const resolvedNodes = this.resolveNodesForInitialization();
877
- this.logger.info(`📝 Creating editor with ${resolvedNodes.length} nodes`);
878
- registerEditorKernel(this.themes[EDITOR_THEME_KEY], this);
879
- const editor = this.editor = createEditor({
880
- __kernel: this,
881
- editable,
882
- namespace: "lobehub",
883
- nodes: resolvedNodes,
884
- onError: (error) => {
885
- this.logger.error("❌ Lexical editor error:", error);
886
- this.emit("error", error);
887
- },
888
- theme: this.themes
889
- });
890
- this.headlessEditor = false;
891
- this.editor.setRootElement(dom);
892
- this.applyRootClassNames(dom);
893
- registerEvent(editor, dom);
894
- this.pluginsInstances.forEach((plugin) => {
895
- plugin.onInit?.(editor);
896
- });
897
- this.logger.info(`✅ Editor ready with ${this.pluginsInstances.length} plugins`);
898
- this.emit("initialized", editor);
899
- return this.editor;
900
- }
901
- setEditable(editable) {
902
- if (!this.editor) {
903
- this.logger.error("❌ Editor not initialized");
904
- throw new Error(`Editor is not initialized.`);
905
- }
906
- this.editor.setEditable(editable);
907
- this.emit("editableChange", editable);
908
- this.logger.debug(`✏️ Editor editable set to ${editable}`);
909
- }
910
- initNodeEditor() {
911
- if (this.editor) return this.editor;
912
- if (this.pluginsInstances.length === 0) {
913
- this.logger.info(`🔌 Initializing ${this.plugins.length} plugins`);
914
- for (const plugin of this.plugins) {
915
- const instance = new plugin(this, this.pluginsConfig.get(plugin));
916
- this.pluginsInstances.push(instance);
917
- }
918
- }
919
- this.runBeforeEditorInitLifecycle();
920
- const resolvedNodes = this.resolveNodesForInitialization();
921
- this.logger.info(`📝 Creating editor with ${resolvedNodes.length} nodes`);
922
- const editor = this.editor = createEditor({
923
- __kernel: this,
924
- namespace: "lobehub",
925
- nodes: resolvedNodes,
926
- onError: (error) => {
927
- this.logger.error("❌ Lexical editor error:", error);
928
- this.emit("error", error);
929
- },
930
- theme: this.themes
931
- });
932
- this.headlessEditor = false;
933
- this.pluginsInstances.forEach((plugin) => {
934
- plugin.onInit?.(editor);
935
- });
936
- this.logger.info(`✅ Editor ready with ${this.pluginsInstances.length} plugins`);
937
- this.emit("initialized", editor);
938
- return editor || null;
939
- }
940
- initHeadlessEditor() {
941
- if (this.editor) return this.editor;
942
- if (this.pluginsInstances.length === 0) {
943
- this.logger.info(`🔌 Initializing ${this.plugins.length} plugins`);
944
- for (const plugin of this.plugins) {
945
- const instance = new plugin(this, this.pluginsConfig.get(plugin));
946
- this.pluginsInstances.push(instance);
947
- }
948
- }
949
- this.runBeforeEditorInitLifecycle();
950
- const resolvedNodes = this.resolveNodesForInitialization();
951
- this.logger.info(`📝 Creating headless editor with ${resolvedNodes.length} nodes`);
952
- const editor = this.editor = createHeadlessEditor({
953
- __kernel: this,
954
- namespace: "lobehub-headless",
955
- nodes: resolvedNodes,
956
- onError: (error) => {
957
- this.logger.error("❌ Lexical headless editor error:", error);
958
- this.emit("error", error);
959
- },
960
- theme: this.themes
961
- });
962
- this.headlessEditor = true;
963
- this.pluginsInstances.forEach((plugin) => {
964
- plugin.onInit?.(editor);
965
- });
966
- this.logger.info(`✅ Headless editor ready with ${this.pluginsInstances.length} plugins`);
967
- this.emit("initialized", editor);
968
- return editor || null;
969
- }
970
- setDocument(type, content, options) {
971
- const datasource = this.dataTypeMap.get(type);
972
- if (!datasource) {
973
- this.logger.error(`❌ DataSource for type "${type}" not found`);
974
- throw new Error(`DataSource for type "${type}" is not registered.`);
975
- }
976
- if (!this.editor) {
977
- this.logger.error("❌ Editor not initialized");
978
- throw new Error(`Editor is not initialized.`);
979
- }
980
- if (!options?.keepHistory) {
981
- this.historyState.redoStack = [];
982
- this.historyState.undoStack = [];
983
- this.historyState.current = null;
984
- }
985
- datasource.read(this.editor, content, options);
986
- this.emit("documentChange", type, content);
987
- this.logger.debug(`📥 Set ${type} document`);
988
- }
989
- setSelection(selection, opt) {
990
- if (!this.editor) {
991
- this.logger.error("❌ Editor not initialized");
992
- throw new Error(`Editor is not initialized.`);
993
- }
994
- const editor = this.editor;
995
- return new Promise((resolve) => {
996
- editor.update(() => {
997
- try {
998
- if (selection.type === "range") {
999
- const startNodeId = opt?.collapseToEnd ? selection.endNodeId : selection.startNodeId;
1000
- const endNodeId = opt?.collapseToStart ? selection.startNodeId : selection.endNodeId;
1001
- const startOffset = opt?.collapseToEnd ? selection.endOffset : selection.startOffset;
1002
- const endOffset = opt?.collapseToStart ? selection.startOffset : selection.endOffset;
1003
- const anchorNode = $getNodeByKey(startNodeId);
1004
- const focusNode = $getNodeByKey(endNodeId);
1005
- if (!anchorNode || !focusNode) {
1006
- this.logger.error("❌ Nodes for selection not found");
1007
- resolve(false);
1008
- return;
1009
- }
1010
- const rng = $createRangeSelection();
1011
- rng.anchor.set(anchorNode.getKey(), startOffset, $isElementNode(anchorNode) ? "element" : "text");
1012
- rng.focus.set(focusNode.getKey(), endOffset, $isElementNode(focusNode) ? "element" : "text");
1013
- $setSelection(rng);
1014
- resolve(true);
1015
- return;
1016
- }
1017
- if (selection.type === "node") {
1018
- if (!$getNodeByKey(selection.startNodeId)) {
1019
- this.logger.error("❌ Node for selection not found");
1020
- resolve(false);
1021
- return;
1022
- }
1023
- const nodeSel = $createNodeSelection();
1024
- nodeSel.add(selection.startNodeId);
1025
- $setSelection(nodeSel);
1026
- resolve(true);
1027
- return;
1028
- }
1029
- if (selection.type === "table") {
1030
- const startNode = $getNodeByKey(selection.startNodeId);
1031
- if (!startNode) {
1032
- this.logger.error("❌ Node for selection not found");
1033
- resolve(false);
1034
- return;
1035
- }
1036
- const endNode = $getNodeByKey(selection.endNodeId);
1037
- if (!endNode) {
1038
- this.logger.error("❌ Node for selection not found");
1039
- resolve(false);
1040
- return;
1041
- }
1042
- const table1 = $closest(startNode, (n) => $isTableNode(n));
1043
- const table2 = $closest(endNode, (n) => $isTableNode(n));
1044
- if (!table1 || !table2 || table1 !== table2) {
1045
- this.logger.error("❌ Table nodes for selection not found or do not match");
1046
- resolve(false);
1047
- return;
1048
- }
1049
- const rng = $createTableSelection();
1050
- rng.set(table1.getKey(), selection.startNodeId, selection.endNodeId);
1051
- $setSelection(rng);
1052
- resolve(true);
1053
- return;
1054
- }
1055
- resolve(false);
1056
- } catch (error) {
1057
- this.logger.error("❌ Error setting selection:", error);
1058
- resolve(false);
1059
- }
1060
- });
1061
- });
1062
- }
1063
- getSelection() {
1064
- if (!this.editor) {
1065
- this.logger.error("❌ Editor not initialized");
1066
- throw new Error(`Editor is not initialized.`);
1067
- }
1068
- return this.editor.read(() => {
1069
- const selection = $getSelection();
1070
- if ($isRangeSelection(selection)) return {
1071
- endNodeId: selection.focus.getNode().getKey(),
1072
- endOffset: selection.focus.offset,
1073
- startNodeId: selection.anchor.getNode().getKey(),
1074
- startOffset: selection.anchor.offset,
1075
- type: "range"
1076
- };
1077
- if ($isNodeSelection(selection)) return {
1078
- endNodeId: selection.getNodes()[0].getKey(),
1079
- endOffset: 0,
1080
- startNodeId: selection.getNodes()[0].getKey(),
1081
- startOffset: 0,
1082
- type: "node"
1083
- };
1084
- if ($isTableSelection(selection)) {
1085
- const [start, end] = selection.getStartEndPoints();
1086
- return {
1087
- endNodeId: end.getNode().getKey(),
1088
- endOffset: end.offset,
1089
- startNodeId: start.getNode().getKey(),
1090
- startOffset: start.offset,
1091
- type: "table"
1092
- };
1093
- }
1094
- return null;
1095
- });
1096
- }
1097
- focus() {
1098
- if (this.headlessEditor) return;
1099
- this.editor?.focus();
1100
- }
1101
- blur() {
1102
- if (this.headlessEditor) return;
1103
- this.editor?.blur();
1104
- }
1105
- getDocument(type) {
1106
- const datasource = this.dataTypeMap.get(type);
1107
- if (!datasource) {
1108
- this.logger.error(`❌ DataSource for type "${type}" not found`);
1109
- throw new Error(`DataSource for type "${type}" is not registered.`);
1110
- }
1111
- if (!this.editor) {
1112
- this.logger.error("❌ Editor not initialized");
1113
- throw new Error(`Editor is not initialized.`);
1114
- }
1115
- return datasource.write(this.editor);
1116
- }
1117
- getSelectionDocument(type) {
1118
- const datasource = this.dataTypeMap.get(type);
1119
- if (!datasource) throw new Error(`DataSource for type "${type}" is not registered.`);
1120
- if (!this.editor) throw new Error(`Editor is not initialized.`);
1121
- return datasource.write(this.editor, { selection: true });
1122
- }
1123
- registerDecorator(name, decorator) {
1124
- if (this.decorators[name]) if (this.hotReloadMode) {
1125
- this.logger.warn(`🔄 Hot reload: decorator "${name}"`);
1126
- this.decorators[name] = decorator;
1127
- return this;
1128
- } else {
1129
- if (this.decorators[name] === decorator) {
1130
- this.logger.warn(`[Editor] Decorator "${name}" is already registered with the same function`);
1131
- return this;
1132
- }
1133
- this.logger.error(`[Editor] Attempting to register duplicate decorator "${name}". Enable hot reload mode if this is intended.`);
1134
- throw new Error(`Decorator with name "${name}" is already registered.`);
1135
- }
1136
- this.decorators[name] = decorator;
1137
- this.logger.debug(`🎭 Decorator: ${name}`);
1138
- return this;
1139
- }
1140
- getDecorator(name) {
1141
- return this.decorators[name];
1142
- }
1143
- /**
1144
- * Unregister a decorator
1145
- * @param name Decorator name
1146
- */
1147
- unregisterDecorator(name) {
1148
- if (this.decorators[name]) {
1149
- delete this.decorators[name];
1150
- this.logger.debug(`🗑️ Removed decorator: ${name}`);
1151
- return true;
1152
- }
1153
- this.logger.warn(`⚠️ Decorator "${name}" not found`);
1154
- return false;
1155
- }
1156
- /**
1157
- * Get all registered decorator names
1158
- */
1159
- getRegisteredDecorators() {
1160
- return Object.keys(this.decorators);
1161
- }
1162
- /**
1163
- * Support registering target data source
1164
- * @param dataSource Data source
1165
- */
1166
- registerDataSource(dataSource) {
1167
- this.dataTypeMap.set(dataSource.type, dataSource);
1168
- this.logger.debug(`📄 Data source: ${dataSource.type}`);
1169
- }
1170
- registerThemes(themes) {
1171
- this.themes = merge(this.themes, themes);
1172
- }
1173
- registerPlugin(plugin, config) {
1174
- const findPlugin = this.plugins.find((p) => p.pluginName === plugin.pluginName);
1175
- if (findPlugin) if (findPlugin !== plugin) if (this.hotReloadMode) {
1176
- this.logger.warn(`🔄 Hot reload: plugin "${plugin.pluginName}"`);
1177
- const index = this.plugins.findIndex((p) => p.pluginName === plugin.pluginName);
1178
- if (index !== -1) {
1179
- this.plugins.splice(index, 1);
1180
- const instanceIndex = this.pluginsInstances.findIndex((instance) => {
1181
- return instance.constructor.pluginName === plugin.pluginName;
1182
- });
1183
- if (instanceIndex !== -1) {
1184
- const oldInstance = this.pluginsInstances[instanceIndex];
1185
- if (oldInstance instanceof KernelPlugin) {
1186
- const decoratorNames = oldInstance.getRegisteredDecorators();
1187
- for (const decoratorName of decoratorNames) {
1188
- this.unregisterDecorator(decoratorName);
1189
- this.logger.debug(`🧨 Cleanup: decorator "${decoratorName}"`);
1190
- }
1191
- }
1192
- if (oldInstance.destroy) oldInstance.destroy();
1193
- this.pluginsInstances.splice(instanceIndex, 1);
1194
- }
1195
- }
1196
- } else throw new Error(`Plugin with name "${plugin.pluginName}" is already registered with a different implementation.`);
1197
- else {
1198
- if (config !== void 0) this.pluginsConfig.set(plugin, config);
1199
- return this;
1200
- }
1201
- this.pluginsConfig.set(plugin, config || {});
1202
- this.plugins.push(plugin);
1203
- this.logger.debug(`🔌 Plugin: ${plugin.pluginName}`);
1204
- return this;
1205
- }
1206
- registerPlugins(plugins) {
1207
- for (const plugin of plugins) if (Array.isArray(plugin)) this.registerPlugin(plugin[0], plugin[1]);
1208
- else this.registerPlugin(plugin);
1209
- this.logger.debug(`🔌 Registered ${plugins.length} plugins`);
1210
- return this;
1211
- }
1212
- registerNodes(nodes) {
1213
- const nodeTypes = nodes.map((node) => {
1214
- if (typeof node === "function" && node.getType) return node.getType();
1215
- else if (typeof node === "object" && node.replace && typeof node.replace === "function" && node.replace.getType) return node.replace.getType();
1216
- return "unknown";
1217
- }).filter((type) => type !== "unknown");
1218
- this.nodes.push(...nodes);
1219
- if (nodeTypes.length > 3) this.logger.debug(`🧩 Nodes: ${nodeTypes.length} types`);
1220
- else this.logger.debug(`🧩 Nodes: ${nodeTypes.join(", ")}`);
1221
- }
1222
- registerNodeTransform(transform) {
1223
- this.nodeTransforms.push(transform);
1224
- return () => {
1225
- this.nodeTransforms = this.nodeTransforms.filter((item) => item !== transform);
1226
- };
1227
- }
1228
- registerBeforeEditorInit(hook) {
1229
- this.beforeEditorInitHooks.push(hook);
1230
- return () => {
1231
- this.beforeEditorInitHooks = this.beforeEditorInitHooks.filter((item) => item !== hook);
1232
- };
1233
- }
1234
- registerRootClassName(className) {
1235
- const classNames = className.split(/\s+/).filter(Boolean);
1236
- for (const item of classNames) this.rootClassNames.add(item);
1237
- const rootElement = this.editor?.getRootElement();
1238
- if (rootElement) rootElement.classList.add(...classNames);
1239
- return () => {
1240
- for (const item of classNames) this.rootClassNames.delete(item);
1241
- const currentRootElement = this.editor?.getRootElement();
1242
- if (currentRootElement) currentRootElement.classList.remove(...classNames);
1243
- };
1244
- }
1245
- runBeforeEditorInitLifecycle() {
1246
- for (const hook of this.beforeEditorInitHooks) hook();
1247
- }
1248
- applyRootClassNames(dom) {
1249
- if (this.rootClassNames.size === 0) return;
1250
- dom.classList.add(...Array.from(this.rootClassNames));
1251
- }
1252
- resolveNodesForInitialization() {
1253
- const resolvedNodes = this.nodes.flatMap((node, index) => {
1254
- let transformedNode = node;
1255
- for (const transform of this.nodeTransforms) {
1256
- transformedNode = transform(transformedNode, index);
1257
- if (!transformedNode) return [];
1258
- }
1259
- return [transformedNode];
1260
- });
1261
- if (resolvedNodes.length !== this.nodes.length) this.logger.debug(`🧩 Node transform filtered ${this.nodes.length - resolvedNodes.length} nodes before editor initialization`);
1262
- return resolvedNodes;
1263
- }
1264
- registerService(serviceId, service) {
1265
- const serviceIdString = serviceId.__serviceId;
1266
- if (this.serviceMap.has(serviceIdString)) if (this.hotReloadMode) {
1267
- this.logger.warn(`🔄 Hot reload: service "${serviceIdString}"`);
1268
- this.serviceMap.set(serviceIdString, service);
1269
- return;
1270
- } else {
1271
- if (this.serviceMap.get(serviceIdString) === service) {
1272
- this.logger.warn(`[Editor] Service "${serviceIdString}" is already registered with the same instance`);
1273
- return;
1274
- }
1275
- this.logger.error(`[Editor] Attempting to register duplicate service "${serviceIdString}". Enable hot reload mode if this is intended.`);
1276
- throw new Error(`Service with ID "${serviceIdString}" is already registered.`);
1277
- }
1278
- this.serviceMap.set(serviceIdString, service);
1279
- this.logger.debug(`🔧 Service: ${serviceIdString}`);
1280
- }
1281
- /**
1282
- * Register service with hot reload support - allows overriding existing services
1283
- * @param serviceId Service identifier
1284
- * @param service Service instance
1285
- */
1286
- registerServiceHotReload(serviceId, service) {
1287
- this.serviceMap.set(serviceId.__serviceId, service);
1288
- this.logger.debug(`🔄 Hot-reload service: ${serviceId.__serviceId}`);
1289
- }
1290
- /**
1291
- * Enable or disable hot reload mode
1292
- * @param enabled Whether to enable hot reload mode
1293
- */
1294
- setHotReloadMode(enabled) {
1295
- this.hotReloadMode = enabled;
1296
- }
1297
- /**
1298
- * Check if hot reload mode is enabled
1299
- */
1300
- isHotReloadMode() {
1301
- return this.hotReloadMode;
1302
- }
1303
- /**
1304
- * Get service
1305
- * @param serviceId Service ID
1306
- */
1307
- requireService(serviceId) {
1308
- const service = this.serviceMap.get(serviceId.__serviceId);
1309
- if (!service) return null;
1310
- return service;
1311
- }
1312
- dispatchCommand(type, payload) {
1313
- if (!this.editor) throw new Error("Editor is not initialized.");
1314
- return this.editor.dispatchCommand(type, payload);
1315
- }
1316
- getTheme() {
1317
- return this.themes;
1318
- }
1319
- updateTheme(key, value) {
1320
- this.themes[key] = value;
1321
- }
1322
- registerLocale(locale) {
1323
- const localeKeys = Object.keys(locale);
1324
- this.localeMap = merge(this.localeMap, locale);
1325
- this.logger.debug(`🌐 Locale: ${localeKeys.length} keys`);
1326
- }
1327
- t(key, params) {
1328
- let translation = get(this.localeMap, key) || key;
1329
- if (params) translation = template(translation)(params);
1330
- return translation;
1331
- }
1332
- get isEmpty() {
1333
- if (!this.editor) return true;
1334
- return this.editor.getEditorState().read(() => {
1335
- return $isRootTextContentEmpty(this.editor.isComposing(), true);
1336
- });
1337
- }
1338
- get isSelected() {
1339
- if (!this.editor) return false;
1340
- return this.editor.getEditorState().read(() => {
1341
- const selection = $getSelection();
1342
- if ($isRangeSelection(selection)) return !!selection._cachedNodes;
1343
- return false;
1344
- });
1345
- }
1346
- cleanDocument() {
1347
- this.setDocument("text", "");
1348
- }
1349
- registerHotkey(hotkeyId, callback, options = {}) {
1350
- const lexicalEditor = this.editor;
1351
- if (!lexicalEditor) throw new Error("Editor is not initialized.");
1352
- const hotkey = getHotkeyById(hotkeyId);
1353
- if (!hotkey) return () => false;
1354
- if (options.enabled === false) return () => false;
1355
- this.logger.debug(`⌨️ Hotkey: ${hotkey.id}`);
1356
- return lexicalEditor.registerCommand(KEY_DOWN_COMMAND, registerHotkey(hotkey, callback, options), hotkey.priority);
1357
- }
1358
- registerHighCommand(command, listener, priority) {
1359
- const lexicalEditor = this.editor;
1360
- if (!lexicalEditor) throw new Error("Editor is not initialized.");
1361
- const commandsMap = this._commands;
1362
- if (!commandsMap.has(command)) {
1363
- commandsMap.set(command, [
1364
- /* @__PURE__ */ new Set(),
1365
- /* @__PURE__ */ new Set(),
1366
- /* @__PURE__ */ new Set(),
1367
- /* @__PURE__ */ new Set(),
1368
- /* @__PURE__ */ new Set()
1369
- ]);
1370
- this._commandsClean.set(command, lexicalEditor.registerCommand(command, (payload) => {
1371
- for (let i = 4; i >= 0; i--) {
1372
- const listenerInPriorityOrder = this._commands.get(command);
1373
- if (listenerInPriorityOrder !== void 0) {
1374
- const listenersSet = listenerInPriorityOrder[i];
1375
- for (const listener of listenersSet) if (listener(payload, lexicalEditor)) return true;
1376
- }
1377
- }
1378
- return false;
1379
- }, COMMAND_PRIORITY_CRITICAL));
1380
- if (!command.type?.includes("KEY")) this.logger.debug(`⚡ Command: ${command.type || "unknown"}`);
1381
- }
1382
- const listenersInPriorityOrder = commandsMap.get(command);
1383
- if (listenersInPriorityOrder === void 0) return noop;
1384
- const listeners = listenersInPriorityOrder[priority];
1385
- listeners.add(listener);
1386
- return () => {
1387
- listeners.delete(listener);
1388
- if (listenersInPriorityOrder.every((listenersSet) => listenersSet.size === 0)) {
1389
- commandsMap.delete(command);
1390
- this._commandsClean.get(command)?.();
1391
- }
1392
- };
1393
- }
1394
- };
1395
- }));
1396
- //#endregion
1397
- //#region src/editor-kernel/data-source.ts
1398
- init_kernel();
1399
- var DataSource = class {
1400
- constructor(dataType) {
1401
- this.dataType = dataType;
1402
- }
1403
- get type() {
1404
- return this.dataType;
1405
- }
1406
- read(editor, data, options) {}
1407
- write(editor, options) {
1408
- return null;
1409
- }
1410
- };
1411
- //#endregion
1412
- //#region src/editor-kernel/index.ts
1413
- init_utils();
1414
- init_event();
1415
- /**
1416
- * Editor object to create an instance of the editor
1417
- */
1418
- const Editor = { createEditor() {
1419
- return new Kernel();
1420
- } };
1421
- //#endregion
1422
- //#region src/plugins/common/node/cursor.ts
1423
- init_debug();
1424
- const logger$2 = createDebugLogger("common", "cursor");
1425
- var CardLikeElementNode = class extends ElementNode {
1426
- isCardLike() {
1427
- return true;
1428
- }
1429
- };
1430
- const cursorNodeSerialized = {
1431
- detail: 0,
1432
- format: 0,
1433
- mode: "normal",
1434
- style: "",
1435
- text: "",
1436
- type: "cursor",
1437
- version: 1
1438
- };
1439
- var CursorNode = class extends TextNode {
1440
- static getType() {
1441
- return "cursor";
1442
- }
1443
- isUnmergeable() {
1444
- return true;
1445
- }
1446
- };
1447
- function $createCursorNode() {
1448
- return new CursorNode("");
1449
- }
1450
- function $isCardLikeElementNode(node) {
1451
- return node instanceof CardLikeElementNode;
1452
- }
1453
- function $isCursorNode(node) {
1454
- return node instanceof CursorNode;
1455
- }
1456
- function registerCursorNode(editor) {
1457
- return mergeRegister(editor.registerUpdateListener(({ mutatedNodes }) => {
1458
- editor.getEditorState().read(() => {
1459
- if (!mutatedNodes) return;
1460
- const needAddCursor = [];
1461
- for (const [kClass, nodeMaps] of mutatedNodes) if (DecoratorNode.prototype.isPrototypeOf(kClass.prototype)) for (const [key, mutation] of nodeMaps) {
1462
- const node = $getNodeByKey(key);
1463
- logger$2.debug("🎭 DecoratorNode mutated:", node?.getType(), mutation, node);
1464
- if (mutation === "created" && node?.isInline() && node.getNextSibling() === null) needAddCursor.push(node);
1465
- }
1466
- if (needAddCursor.length > 0) editor.update(() => {
1467
- needAddCursor.forEach((node) => {
1468
- node.insertAfter($createCursorNode());
1469
- });
1470
- }, { tag: HISTORY_MERGE_TAG });
1471
- return false;
1472
- });
1473
- }), editor.registerUpdateListener(({ mutatedNodes }) => {
1474
- editor.getEditorState().read(() => {
1475
- const cursorNodes = mutatedNodes?.get(CursorNode);
1476
- const needRemove = /* @__PURE__ */ new Set();
1477
- if (cursorNodes) {
1478
- for (const [key, mutation] of cursorNodes) if (mutation === "updated") {
1479
- const cursorNode = $getNodeByKey(key);
1480
- if (cursorNode?.getIndexWithinParent() === 0) {
1481
- const nextElement = cursorNode.getNextSibling();
1482
- if (!$isCardLikeElementNode(nextElement) && !$isDecoratorNode(nextElement) && !$isCardLikeElementNode(cursorNode?.getParent())) needRemove.add(cursorNode);
1483
- else continue;
1484
- }
1485
- const element = cursorNode?.getPreviousSibling();
1486
- if (!$isCardLikeElementNode(element) && !$isDecoratorNode(element) && !$isCardLikeElementNode(cursorNode?.getParent())) needRemove.add(cursorNode);
1487
- }
1488
- }
1489
- if (needRemove.size > 0) editor.update(() => {
1490
- needRemove.forEach((node) => {
1491
- node.remove();
1492
- });
1493
- }, { tag: HISTORY_MERGE_TAG });
1494
- return false;
1495
- });
1496
- }), editor.registerUpdateListener(() => {
1497
- editor.getEditorState().read(() => {
1498
- const selection = $getSelection();
1499
- if (editor.isComposing()) return false;
1500
- if (!$isRangeSelection(selection) || !selection.isCollapsed()) return false;
1501
- const node = selection.anchor.getNode();
1502
- if (node instanceof CursorNode) {
1503
- if (node.__text !== "") editor.update(() => {
1504
- node.setTextContent("");
1505
- const data = node.__text.replace("", "");
1506
- if (data) {
1507
- const textNode = $createTextNode(data);
1508
- node.insertAfter(textNode);
1509
- textNode.selectEnd();
1510
- }
1511
- }, { tag: HISTORY_MERGE_TAG });
1512
- return false;
1513
- }
1514
- });
1515
- }), editor.registerCommand(KEY_BACKSPACE_COMMAND, (event) => {
1516
- const selection = $getSelection();
1517
- if (!$isRangeSelection(selection) || !selection.isCollapsed()) return false;
1518
- const node = selection.anchor.getNode();
1519
- if (node instanceof CursorNode) {
1520
- event.preventDefault();
1521
- const prev = node.getPreviousSibling();
1522
- const parent = node.getParent();
1523
- const parentPrev = parent?.getPreviousSibling();
1524
- let needDispatch = false;
1525
- if ($isDecoratorNode(prev)) {
1526
- prev.selectPrevious();
1527
- node.remove();
1528
- prev.remove();
1529
- event.preventDefault();
1530
- return true;
1531
- } else if (prev) {
1532
- prev.selectEnd();
1533
- needDispatch = true;
1534
- } else if (parent) {
1535
- if (parent.getChildrenSize() === 1) parent.remove();
1536
- else if (parentPrev) {
1537
- parentPrev.selectEnd();
1538
- needDispatch = true;
1539
- }
1540
- }
1541
- if (needDispatch) queueMicrotask(() => {
1542
- editor.dispatchCommand(KEY_BACKSPACE_COMMAND, event);
1543
- });
1544
- return true;
1545
- }
1546
- return false;
1547
- }, COMMAND_PRIORITY_HIGH), editor.registerCommand(KEY_ARROW_LEFT_COMMAND, (event) => {
1548
- const selection = $getSelection();
1549
- if (!$isRangeSelection(selection)) return false;
1550
- const focusNode = selection.focus.getNode();
1551
- if (!event.shiftKey) {
1552
- if (focusNode instanceof CursorNode && !$isCardLikeElementNode(focusNode.getParent()) && !$isCardLikeElementNode(focusNode.getPreviousSibling())) focusNode.selectStart();
1553
- return false;
1554
- }
1555
- const prev = focusNode.getPreviousSibling();
1556
- if (selection.focus.offset === 0 && $isCursorNode(prev)) try {
1557
- const { key: anchorKey, offset: anchorOffset, type: anchorType } = selection.anchor;
1558
- const sel = prev.selectPrevious();
1559
- const { key, offset, type } = sel.anchor;
1560
- sel.anchor.set(anchorKey, anchorOffset, anchorType);
1561
- sel.focus.set(key, offset, type);
1562
- $setSelection(sel);
1563
- return true;
1564
- } catch (error) {
1565
- logger$2.error("❌ Cursor selection error:", error);
1566
- }
1567
- else if ($isCursorNode(focusNode)) try {
1568
- const { key: anchorKey, offset: anchorOffset, type: anchorType } = selection.anchor;
1569
- const sel = focusNode.selectPrevious();
1570
- const { key, offset, type } = sel.anchor;
1571
- sel.anchor.set(anchorKey, anchorOffset, anchorType);
1572
- sel.focus.set(key, offset, type);
1573
- $setSelection(sel);
1574
- return true;
1575
- } catch (error) {
1576
- logger$2.error("❌ Cursor navigation error:", error);
1577
- }
1578
- return false;
1579
- }, COMMAND_PRIORITY_HIGH), editor.registerCommand(KEY_ARROW_RIGHT_COMMAND, (event) => {
1580
- const selection = $getSelection();
1581
- if (!$isRangeSelection(selection)) return false;
1582
- if (!event.shiftKey) {
1583
- const focusNode = selection.focus.getNode();
1584
- if (focusNode instanceof CursorNode && !$isCardLikeElementNode(focusNode.getParent()) && !$isCardLikeElementNode(focusNode.getPreviousSibling())) focusNode.selectEnd();
1585
- return false;
1586
- }
1587
- const { key: anchorKey, offset: anchorOffset, type: anchorType } = selection.anchor;
1588
- const { key: focusKey, offset: focusOffset, type: focusType } = selection.focus;
1589
- const focusNode = selection.focus.getNode();
1590
- if (focusType === "text" && focusOffset !== focusNode.getTextContentSize() || focusType === "element" && focusOffset !== focusNode.getChildrenSize()) return false;
1591
- const sel = focusNode.selectNext();
1592
- if ($isCursorNode(sel.focus.getNode())) {
1593
- sel.focus.getNode().selectNext();
1594
- const { key, offset, type } = sel.anchor;
1595
- sel.anchor.set(anchorKey, anchorOffset, anchorType);
1596
- sel.focus.set(key, offset, type);
1597
- $setSelection(sel);
1598
- return true;
1599
- } else {
1600
- selection.anchor.set(anchorKey, anchorOffset, anchorType);
1601
- selection.focus.set(focusKey, focusOffset, focusType);
1602
- }
1603
- return false;
1604
- }, COMMAND_PRIORITY_HIGH));
1605
- }
1606
- //#endregion
1607
- //#region src/plugins/codemirror-block/node/CodeMirrorNode.ts
1608
- init_utils();
1609
- const LANGUAGE_DATA_ATTRIBUTE = "data-language";
1610
- const THEME_DATA_ATTRIBUTE = "data-theme";
1611
- const DEFAULT_OPTIONS = {
1612
- indentWithTabs: false,
1613
- lineNumbers: false,
1614
- tabSize: 2
1615
- };
1616
- function hasChildDOMNodeTag(node, tagName) {
1617
- for (const child of node.childNodes) {
1618
- if (isHTMLElement(child) && child.tagName === tagName) return true;
1619
- hasChildDOMNodeTag(child, tagName);
1620
- }
1621
- return false;
1622
- }
1623
- function isGitHubCodeTable(table) {
1624
- return table.classList.contains("js-file-line-container");
1625
- }
1626
- function isGitHubCodeCell(cell) {
1627
- return cell.classList.contains("js-file-line");
1628
- }
1629
- var CodeMirrorNode = class CodeMirrorNode extends DecoratorNode {
1630
- static getType() {
1631
- return "code";
1632
- }
1633
- static clone(node) {
1634
- return new CodeMirrorNode(node.__lang, node.__code, node.__codeTheme, node.__options, node.__key);
1635
- }
1636
- static importJSON(serializedNode) {
1637
- let code = serializedNode.code;
1638
- if ("children" in serializedNode) code = serializedNode.children?.map((child) => child.text).join("") || "";
1639
- return $createCodeMirrorNode(serializedNode.language, code, serializedNode.codeTheme, serializedNode.options).updateFromJSON(serializedNode);
1640
- }
1641
- static importDOM() {
1642
- return {
1643
- code: (node) => {
1644
- return node.textContent !== null && (/\r?\n/.test(node.textContent) || hasChildDOMNodeTag(node, "BR")) ? {
1645
- conversion: $convertPreElement,
1646
- priority: 1
1647
- } : null;
1648
- },
1649
- div: () => ({
1650
- conversion: $convertDivElement,
1651
- priority: 1
1652
- }),
1653
- pre: () => ({
1654
- conversion: $convertPreElement,
1655
- priority: 0
1656
- }),
1657
- table: (node) => {
1658
- if (isGitHubCodeTable(node)) return {
1659
- conversion: $convertTableElement,
1660
- priority: 3
1661
- };
1662
- return null;
1663
- },
1664
- td: (node) => {
1665
- const td = node;
1666
- const table = td.closest("table");
1667
- if (isGitHubCodeCell(td) || table && isGitHubCodeTable(table)) return {
1668
- conversion: convertCodeNoop,
1669
- priority: 3
1670
- };
1671
- return null;
1672
- },
1673
- tr: (node) => {
1674
- const table = node.closest("table");
1675
- if (table && isGitHubCodeTable(table)) return {
1676
- conversion: convertCodeNoop,
1677
- priority: 3
1678
- };
1679
- return null;
1680
- }
1681
- };
1682
- }
1683
- constructor(lang, code, codeTheme, options, key) {
1684
- super(key);
1685
- this.__lang = lang;
1686
- this.__code = code;
1687
- this.__codeTheme = codeTheme;
1688
- this.__options = options;
1689
- }
1690
- get lang() {
1691
- return this.__lang;
1692
- }
1693
- get code() {
1694
- return this.__code;
1695
- }
1696
- get codeTheme() {
1697
- return this.__codeTheme;
1698
- }
1699
- get options() {
1700
- return this.__options;
1701
- }
1702
- exportDOM(editor) {
1703
- const element = document.createElement("pre");
1704
- addClassNamesToElement(element, editor._config.theme.code);
1705
- element.setAttribute("spellcheck", "false");
1706
- const language = this.__lang;
1707
- if (language) element.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language);
1708
- const theme = this.__codeTheme;
1709
- if (theme) element.setAttribute(THEME_DATA_ATTRIBUTE, theme);
1710
- element.textContent = this.__code;
1711
- return { element };
1712
- }
1713
- exportJSON() {
1714
- return {
1715
- ...super.exportJSON(),
1716
- code: this.code,
1717
- codeTheme: this.codeTheme,
1718
- language: this.lang,
1719
- options: this.options
1720
- };
1721
- }
1722
- setLang(lang) {
1723
- const writer = this.getWritable();
1724
- writer.__lang = lang;
1725
- return this;
1726
- }
1727
- setCode(code) {
1728
- const writer = this.getWritable();
1729
- writer.__code = code;
1730
- return this;
1731
- }
1732
- setCodeTheme(codeTheme) {
1733
- const writer = this.getWritable();
1734
- writer.__codeTheme = codeTheme;
1735
- return this;
1736
- }
1737
- setTabSize(tabSize) {
1738
- const writer = this.getWritable();
1739
- writer.__options.tabSize = tabSize;
1740
- return this;
1741
- }
1742
- setIndentWithTabs(indentWithTabs) {
1743
- const writer = this.getWritable();
1744
- writer.__options.indentWithTabs = indentWithTabs;
1745
- return this;
1746
- }
1747
- setLineNumbers(lineNumbers) {
1748
- const writer = this.getWritable();
1749
- writer.__options.lineNumbers = lineNumbers;
1750
- return this;
1751
- }
1752
- createDOM(config) {
1753
- const element = document.createElement("div");
1754
- addClassNamesToElement(element, config.theme.hr);
1755
- return element;
1756
- }
1757
- getTextContent() {
1758
- return "\n";
1759
- }
1760
- isInline() {
1761
- return false;
1762
- }
1763
- updateDOM() {
1764
- return false;
1765
- }
1766
- decorate(editor) {
1767
- const decorator = getKernelFromEditor(editor)?.getDecorator("codemirror");
1768
- if (!decorator) return null;
1769
- if (typeof decorator === "function") return decorator(this, editor);
1770
- else return decorator.render(this, editor);
1771
- }
1772
- };
1773
- function $createCodeMirrorNode(lang, code = "", codeTheme = "default", options = DEFAULT_OPTIONS) {
1774
- return $applyNodeReplacement(new CodeMirrorNode(lang, code, codeTheme, options));
1775
- }
1776
- function isCodeElement(div) {
1777
- return div.style.fontFamily.match("monospace") !== null;
1778
- }
1779
- function isCodeChildElement(node) {
1780
- let parent = node.parentElement;
1781
- while (parent !== null) {
1782
- if (isCodeElement(parent)) return true;
1783
- parent = parent.parentElement;
1784
- }
1785
- return false;
1786
- }
1787
- function $convertDivElement(domNode) {
1788
- const div = domNode;
1789
- const isCode = isCodeElement(div);
1790
- if (!isCode && !isCodeChildElement(div)) return { node: null };
1791
- return { node: isCode ? $createCodeMirrorNode("plain", domNode.textContent || "", "") : null };
1792
- }
1793
- function $convertTableElement() {
1794
- return { node: $createCodeMirrorNode("plain", "", "") };
1795
- }
1796
- function $convertPreElement(domNode) {
1797
- const language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE);
1798
- const codeTheme = domNode.getAttribute(THEME_DATA_ATTRIBUTE) || "";
1799
- return { node: $createCodeMirrorNode(language || "plain", domNode.textContent || "", codeTheme) };
1800
- }
1801
- function $isCodeMirrorNode(node) {
1802
- return node.getType() === CodeMirrorNode.getType();
1803
- }
1804
- function convertCodeNoop() {
1805
- return { node: null };
1806
- }
1807
- //#endregion
1808
- //#region src/plugins/common/react/style.ts
1809
- const cursorBlink = keyframes`
1810
- to {
1811
- visibility: hidden;
1812
- }
1813
- `;
1814
- const themeStyles = createStaticStyles(({ css, cssVar }) => ({
1815
- quote: "editor_quote",
1816
- textBold_false: css`
1817
- font-weight: unset;
1818
- `,
1819
- textBold_true: css`
1820
- font-weight: bold;
1821
- `,
1822
- textCode: "editor_code",
1823
- textItalic_false: css`
1824
- font-style: unset;
1825
- `,
1826
- textItalic_true: css`
1827
- font-style: italic;
1828
- `,
1829
- textStrikethrough_false: css`
1830
- text-decoration: unset;
1831
- `,
1832
- textStrikethrough_true: css`
1833
- color: ${cssVar.colorTextDescription};
1834
- text-decoration: line-through;
1835
- `,
1836
- textUnderlineStrikethrough_false: css`
1837
- text-decoration: unset;
1838
- `,
1839
- textUnderlineStrikethrough_true: css`
1840
- text-decoration: underline line-through;
1841
- `,
1842
- textUnderline_false: css`
1843
- text-decoration: unset;
1844
- `,
1845
- textUnderline_true: css`
1846
- text-decoration: underline;
1847
- `
1848
- }));
1849
- const styles$1 = createStaticStyles(({ css, cssVar }) => {
1850
- const __root = css`
1851
- --lobe-markdown-font-size: var(--common-font-size, 16px);
1852
- --lobe-markdown-header-multiple: var(--common-header-multiple, 1);
1853
- --lobe-markdown-margin-multiple: var(--common-margin-multiple, 2);
1854
- --lobe-markdown-line-height: var(--common-line-height, 1.6);
1855
- --lobe-markdown-border-radius: ${cssVar.borderRadiusLG};
1856
- --lobe-markdown-border-color: ${cssVar.colorFillQuaternary};
1857
-
1858
- position: relative;
1859
-
1860
- display: flex;
1861
- flex-direction: column;
1862
-
1863
- width: 100%;
1864
- max-width: 100%;
1865
- height: 100%;
1866
-
1867
- font-size: var(--lobe-markdown-font-size);
1868
- line-height: var(--lobe-markdown-line-height);
1869
- word-break: break-word;
1870
-
1871
- [data-placeholder] {
1872
- position: relative;
1873
- }
1874
-
1875
- [data-placeholder]::after {
1876
- pointer-events: none;
1877
- content: attr(data-placeholder);
1878
- user-select: none;
1879
-
1880
- position: absolute;
1881
- inset-block-start: 50%;
1882
- transform: translateY(-50%);
1883
-
1884
- padding-inline-start: 2px;
1885
-
1886
- color: ${cssVar.colorTextDescription};
1887
- white-space: nowrap;
1888
- }
1889
-
1890
- [data-lexical-cursor='true'] {
1891
- pointer-events: none;
1892
- position: absolute;
1893
- display: block;
1894
-
1895
- &::after {
1896
- content: '';
1897
-
1898
- position: absolute;
1899
- inset-block-start: -2px;
1900
-
1901
- display: block;
1902
-
1903
- width: 20px;
1904
- border-block-start: 1px solid ${cssVar.colorText};
1905
-
1906
- animation: ${cursorBlink} 1.1s steps(2, start) infinite;
1907
- }
1908
- }
1909
- `;
1910
- const header = css`
1911
- h1,
1912
- h2,
1913
- h3,
1914
- h4,
1915
- h5,
1916
- h6 {
1917
- margin-block: max(
1918
- calc(var(--lobe-markdown-header-multiple) * var(--lobe-markdown-margin-multiple) * 0.4em),
1919
- var(--lobe-markdown-font-size)
1920
- );
1921
- font-weight: bold;
1922
- line-height: 1.25;
1923
- }
1924
-
1925
- h1 {
1926
- font-size: calc(
1927
- var(--lobe-markdown-font-size) * (1 + 1.5 * var(--lobe-markdown-header-multiple))
1928
- );
1929
- }
1930
-
1931
- h2 {
1932
- font-size: calc(var(--lobe-markdown-font-size) * (1 + var(--lobe-markdown-header-multiple)));
1933
- }
1934
-
1935
- h3 {
1936
- font-size: calc(
1937
- var(--lobe-markdown-font-size) * (1 + 0.5 * var(--lobe-markdown-header-multiple))
1938
- );
1939
- }
1940
-
1941
- h4 {
1942
- font-size: calc(
1943
- var(--lobe-markdown-font-size) * (1 + 0.25 * var(--lobe-markdown-header-multiple))
1944
- );
1945
- }
1946
-
1947
- h5,
1948
- h6 {
1949
- font-size: calc(var(--lobe-markdown-font-size) * 1);
1950
- }
1951
- `;
1952
- const p = css`
1953
- p {
1954
- margin-block: 4px;
1955
- line-height: var(--lobe-markdown-line-height);
1956
- letter-spacing: 0.02em;
1957
-
1958
- &:not(:first-child) {
1959
- margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);
1960
- }
1961
-
1962
- &:not(:last-child) {
1963
- margin-block-end: calc(var(--lobe-markdown-margin-multiple) * 0.5em);
1964
- }
1965
- }
1966
- `;
1967
- const blockquote = css`
1968
- .editor_quote {
1969
- margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);
1970
- margin-inline: 0;
1971
- padding-block: 0;
1972
- padding-inline: 1em;
1973
- border-inline-start: solid 4px ${cssVar.colorBorder};
1974
-
1975
- color: ${cssVar.colorTextSecondary};
1976
- }
1977
- `;
1978
- const code = css`
1979
- .editor_code {
1980
- display: inline;
1981
-
1982
- margin-inline: 0.25em;
1983
- padding-block: 0.2em;
1984
- padding-inline: 0.4em;
1985
- border: 1px solid var(--lobe-markdown-border-color);
1986
- border-radius: 0.25em;
1987
-
1988
- font-family: ${cssVar.fontFamilyCode};
1989
- font-size: 0.875em;
1990
- line-height: 1;
1991
- word-break: break-word;
1992
- white-space: break-spaces;
1993
-
1994
- background: ${cssVar.colorFillSecondary};
1995
- }
1996
- `;
1997
- return {
1998
- blockquote,
1999
- code,
2000
- editorContent: css`
2001
- flex: 1;
2002
- min-height: 0;
2003
- outline: none;
2004
- `,
2005
- header,
2006
- p,
2007
- root: __root,
2008
- variant: cx(header, p, blockquote, code)
2009
- };
2010
- });
2011
- //#endregion
2012
- //#region src/plugins/code/node/code.ts
2013
- var CodeNode = class CodeNode extends CardLikeElementNode {
2014
- static getType() {
2015
- return "codeInline";
2016
- }
2017
- static clone(node) {
2018
- return new CodeNode(node.__key);
2019
- }
2020
- static importJSON(serializedNode) {
2021
- return $createCodeNode().updateFromJSON(serializedNode);
2022
- }
2023
- createDOM(config) {
2024
- const element = document.createElement("span");
2025
- element.setAttribute("data-lexical-key", this.getKey());
2026
- const childContainer = document.createElement("ne-content");
2027
- element.append(childContainer);
2028
- addClassNamesToElement(element, config.theme.codeInline);
2029
- return element;
2030
- }
2031
- getDOMSlot(element) {
2032
- const neContent = element.querySelector("ne-content");
2033
- if (!neContent) throw new Error("CodeNode: ne-content not found");
2034
- return super.getDOMSlot(element).withElement(neContent);
2035
- }
2036
- canBeEmpty() {
2037
- return false;
2038
- }
2039
- isCardLike() {
2040
- return true;
2041
- }
2042
- isInline() {
2043
- return true;
2044
- }
2045
- canIndent() {
2046
- return false;
2047
- }
2048
- canInsertTextBefore() {
2049
- return true;
2050
- }
2051
- canInsertTextAfter() {
2052
- return true;
2053
- }
2054
- updateDOM(prevNode, dom, config) {
2055
- if ((prevNode ? prevNode : null) !== this) addClassNamesToElement(dom, config.theme.codeInline);
2056
- return false;
2057
- }
2058
- };
2059
- function $createCodeNode(textContent) {
2060
- const codeNode = $applyNodeReplacement(new CodeNode());
2061
- const cursorNode = $createCursorNode();
2062
- codeNode.append(cursorNode);
2063
- if (textContent) codeNode.append($createTextNode(textContent));
2064
- return codeNode;
2065
- }
2066
- function $isCodeInlineNode(node) {
2067
- return node instanceof CodeNode;
2068
- }
2069
- function getCodeInlineNode(node) {
2070
- if ($isCursorNode(node)) {
2071
- const parent = node.getParent();
2072
- if ($isCodeInlineNode(parent)) return parent;
2073
- if ($isCodeInlineNode(node.getNextSibling())) return node.getNextSibling();
2074
- if ($isCodeInlineNode(node.getPreviousSibling())) return node.getPreviousSibling();
2075
- return null;
2076
- }
2077
- if ($isCodeInlineNode(node.getParent())) return node.getParent();
2078
- return null;
2079
- }
2080
- function $isSelectionInCodeInline(editor) {
2081
- return editor.getEditorState().read(() => {
2082
- const selection = $getSelection();
2083
- if (!selection) return false;
2084
- if ($isRangeSelection(selection)) {
2085
- const focusNode = selection.focus.getNode();
2086
- const anchorNode = selection.anchor.getNode();
2087
- const code = getCodeInlineNode(focusNode);
2088
- if (code !== getCodeInlineNode(anchorNode)) return false;
2089
- if ($isCodeInlineNode(code)) return true;
2090
- return false;
2091
- } else if ($isNodeSelection(selection)) {
2092
- const nodes = selection.getNodes();
2093
- if (nodes.length === 1 && $isCodeInlineNode(nodes[0])) return true;
2094
- }
2095
- return false;
2096
- });
2097
- }
2098
- //#endregion
2099
- //#region src/plugins/link/node/LinkNode.ts
2100
- init_utils();
2101
- init_debug();
2102
- const logger$1 = createDebugLogger("plugin", "link");
2103
- const SUPPORTED_URL_PROTOCOLS = new Set([
2104
- "http:",
2105
- "https:",
2106
- "mailto:",
2107
- "sms:",
2108
- "tel:"
2109
- ]);
2110
- const HOVER_LINK_COMMAND = createCommand("HOVER_LINK_COMMAND");
2111
- const HOVER_OUT_LINK_COMMAND = createCommand("HOVER_OUT_LINK_COMMAND");
2112
- /** @noInheritDoc */
2113
- var LinkNode = class LinkNode extends ElementNode {
2114
- static getType() {
2115
- return "link";
2116
- }
2117
- static clone(node) {
2118
- return new LinkNode(node.__url, {
2119
- rel: node.__rel,
2120
- target: node.__target,
2121
- title: node.__title
2122
- }, node.__key);
2123
- }
2124
- constructor(url = "", attributes = {}, key) {
2125
- super(key);
2126
- const { target = null, rel = null, title = null } = attributes;
2127
- this.__url = url;
2128
- this.__target = target;
2129
- this.__rel = rel;
2130
- this.__title = title;
2131
- }
2132
- createDOM(config, editor) {
2133
- logger$1.debug("🔍 config", config);
2134
- const element = document.createElement("a");
2135
- this.updateLinkDOM(null, element, config);
2136
- addClassNamesToElement(element, config.theme.link);
2137
- element.addEventListener("mouseenter", (event) => {
2138
- if (event.target instanceof HTMLElement) {
2139
- event.target.classList.add("hover");
2140
- editor.dispatchCommand(HOVER_LINK_COMMAND, {
2141
- event,
2142
- linkNode: this
2143
- });
2144
- }
2145
- });
2146
- element.addEventListener("mouseleave", (event) => {
2147
- if (event.target instanceof HTMLElement) {
2148
- event.target.classList.remove("hover");
2149
- editor.dispatchCommand(HOVER_OUT_LINK_COMMAND, { event });
2150
- }
2151
- });
2152
- return element;
2153
- }
2154
- updateLinkDOM(prevNode, anchor, _config) {
2155
- if (isHTMLAnchorElement(anchor)) {
2156
- if (!prevNode || prevNode.__url !== this.__url) anchor.href = this.sanitizeUrl(this.__url);
2157
- for (const attr of [
2158
- "target",
2159
- "rel",
2160
- "title"
2161
- ]) {
2162
- const key = `__${attr}`;
2163
- const value = this[key];
2164
- if (!prevNode || prevNode[key] !== value) if (value) anchor[attr] = value;
2165
- else anchor.removeAttribute(attr);
2166
- }
2167
- }
2168
- }
2169
- updateDOM(prevNode, anchor, config) {
2170
- this.updateLinkDOM(prevNode, anchor, config);
2171
- return false;
2172
- }
2173
- static importDOM() {
2174
- return { a: () => ({
2175
- conversion: $convertAnchorElement,
2176
- priority: 1
2177
- }) };
2178
- }
2179
- static importJSON(serializedNode) {
2180
- return $createLinkNode().updateFromJSON(serializedNode);
2181
- }
2182
- updateFromJSON(serializedNode) {
2183
- return super.updateFromJSON(serializedNode).setURL(serializedNode.url).setRel(serializedNode.rel || null).setTarget(serializedNode.target || null).setTitle(serializedNode.title || null);
2184
- }
2185
- sanitizeUrl(url) {
2186
- url = formatUrl(url);
2187
- try {
2188
- const parsedUrl = new URL(formatUrl(url));
2189
- if (!SUPPORTED_URL_PROTOCOLS.has(parsedUrl.protocol)) return "about:blank";
2190
- } catch {
2191
- return url;
2192
- }
2193
- return url;
2194
- }
2195
- exportJSON() {
2196
- return {
2197
- ...super.exportJSON(),
2198
- rel: this.getRel(),
2199
- target: this.getTarget(),
2200
- title: this.getTitle(),
2201
- url: this.getURL()
2202
- };
2203
- }
2204
- getURL() {
2205
- return this.getLatest().__url;
2206
- }
2207
- setURL(url) {
2208
- const writable = this.getWritable();
2209
- writable.__url = url;
2210
- return writable;
2211
- }
2212
- getTarget() {
2213
- return this.getLatest().__target;
2214
- }
2215
- setTarget(target) {
2216
- const writable = this.getWritable();
2217
- writable.__target = target;
2218
- return writable;
2219
- }
2220
- getRel() {
2221
- return this.getLatest().__rel;
2222
- }
2223
- setRel(rel) {
2224
- const writable = this.getWritable();
2225
- writable.__rel = rel;
2226
- return writable;
2227
- }
2228
- getTitle() {
2229
- return this.getLatest().__title;
2230
- }
2231
- setTitle(title) {
2232
- const writable = this.getWritable();
2233
- writable.__title = title;
2234
- return writable;
2235
- }
2236
- insertNewAfter(_, restoreSelection = true) {
2237
- const linkNode = $createLinkNode(this.__url, {
2238
- rel: this.__rel,
2239
- target: this.__target,
2240
- title: this.__title
2241
- });
2242
- this.insertAfter(linkNode, restoreSelection);
2243
- return linkNode;
2244
- }
2245
- canInsertTextBefore() {
2246
- return false;
2247
- }
2248
- canInsertTextAfter() {
2249
- return false;
2250
- }
2251
- canBeEmpty() {
2252
- return false;
2253
- }
2254
- isInline() {
2255
- return true;
2256
- }
2257
- extractWithChild(child, selection) {
2258
- if (!$isRangeSelection(selection)) return false;
2259
- const anchorNode = selection.anchor.getNode();
2260
- const focusNode = selection.focus.getNode();
2261
- return this.isParentOf(anchorNode) && this.isParentOf(focusNode) && selection.getTextContent().length > 0;
2262
- }
2263
- isEmailURI() {
2264
- return this.__url.startsWith("mailto:");
2265
- }
2266
- isWebSiteURI() {
2267
- return this.__url.startsWith("https://") || this.__url.startsWith("http://");
2268
- }
2269
- };
2270
- function $convertAnchorElement(domNode) {
2271
- let node = null;
2272
- if (isHTMLAnchorElement(domNode)) {
2273
- const content = domNode.textContent;
2274
- if (content !== null && content !== "" || domNode.children.length > 0) node = $createLinkNode(domNode.getAttribute("href") || "", {
2275
- rel: domNode.getAttribute("rel"),
2276
- target: domNode.getAttribute("target"),
2277
- title: domNode.getAttribute("title")
2278
- });
2279
- }
2280
- return { node };
2281
- }
2282
- /**
2283
- * Takes a URL and creates a LinkNode.
2284
- * @param url - The URL the LinkNode should direct to.
2285
- * @param attributes - Optional HTML a tag attributes \\{ target, rel, title \\}
2286
- * @returns The LinkNode.
2287
- */
2288
- function $createLinkNode(url = "", attributes) {
2289
- return $applyNodeReplacement(new LinkNode(url, attributes));
2290
- }
2291
- /**
2292
- * Determines if node is a LinkNode.
2293
- * @param node - The node to be checked.
2294
- * @returns true if node is a LinkNode, false otherwise.
2295
- */
2296
- function $isLinkNode(node) {
2297
- return node instanceof LinkNode;
2298
- }
2299
- var AutoLinkNode = class AutoLinkNode extends LinkNode {
2300
- constructor(url = "", attributes = {}, key) {
2301
- super(url, attributes, key);
2302
- this.__isUnlinked = attributes.isUnlinked !== void 0 && attributes.isUnlinked !== null ? attributes.isUnlinked : false;
2303
- }
2304
- static getType() {
2305
- return "autolink";
2306
- }
2307
- static clone(node) {
2308
- return new AutoLinkNode(node.__url, {
2309
- isUnlinked: node.__isUnlinked,
2310
- rel: node.__rel,
2311
- target: node.__target,
2312
- title: node.__title
2313
- }, node.__key);
2314
- }
2315
- getIsUnlinked() {
2316
- return this.__isUnlinked;
2317
- }
2318
- setIsUnlinked(value) {
2319
- const self = this.getWritable();
2320
- self.__isUnlinked = value;
2321
- return self;
2322
- }
2323
- createDOM(config, editor) {
2324
- logger$1.debug("🔍 config", config);
2325
- if (this.__isUnlinked) return document.createElement("span");
2326
- else return super.createDOM(config, editor);
2327
- }
2328
- updateDOM(prevNode, anchor, config) {
2329
- return super.updateDOM(prevNode, anchor, config) || prevNode.__isUnlinked !== this.__isUnlinked;
2330
- }
2331
- static importJSON(serializedNode) {
2332
- return $createAutoLinkNode().updateFromJSON(serializedNode);
2333
- }
2334
- updateFromJSON(serializedNode) {
2335
- return super.updateFromJSON(serializedNode).setIsUnlinked(serializedNode.isUnlinked || false);
2336
- }
2337
- static importDOM() {
2338
- return null;
2339
- }
2340
- exportJSON() {
2341
- return {
2342
- ...super.exportJSON(),
2343
- isUnlinked: this.__isUnlinked
2344
- };
2345
- }
2346
- insertNewAfter(selection, restoreSelection = true) {
2347
- const element = this.getParentOrThrow().insertNewAfter(selection, restoreSelection);
2348
- if ($isElementNode(element)) {
2349
- const linkNode = $createAutoLinkNode(this.__url, {
2350
- isUnlinked: this.__isUnlinked,
2351
- rel: this.__rel,
2352
- target: this.__target,
2353
- title: this.__title
2354
- });
2355
- element.append(linkNode);
2356
- return linkNode;
2357
- }
2358
- return null;
2359
- }
2360
- };
2361
- /**
2362
- * Takes a URL and creates an AutoLinkNode. AutoLinkNodes are generally automatically generated
2363
- * during typing, which is especially useful when a button to generate a LinkNode is not practical.
2364
- * @param url - The URL the LinkNode should direct to.
2365
- * @param attributes - Optional HTML a tag attributes. \\{ target, rel, title \\}
2366
- * @returns The LinkNode.
2367
- */
2368
- function $createAutoLinkNode(url = "", attributes) {
2369
- return $applyNodeReplacement(new AutoLinkNode(url, attributes));
2370
- }
2371
- /**
2372
- * Determines if node is an AutoLinkNode.
2373
- * @param node - The node to be checked.
2374
- * @returns true if node is an AutoLinkNode, false otherwise.
2375
- */
2376
- function $isAutoLinkNode(node) {
2377
- return node instanceof AutoLinkNode;
2378
- }
2379
- const TOGGLE_LINK_COMMAND = createCommand("TOGGLE_LINK_COMMAND");
2380
- function $getPointNode(point, offset) {
2381
- if (point.type === "element") {
2382
- const node = point.getNode();
2383
- assert($isElementNode(node), "$getPointNode: element point is not an ElementNode");
2384
- return node.getChildren()[point.offset + offset] || null;
2385
- }
2386
- return null;
2387
- }
2388
- /**
2389
- * Preserve the logical start/end of a RangeSelection in situations where
2390
- * the point is an element that may be reparented in the callback.
2391
- *
2392
- * @param $fn The function to run
2393
- * @returns The result of the callback
2394
- */
2395
- function $withSelectedNodes($fn) {
2396
- const initialSelection = $getSelection();
2397
- if (!$isRangeSelection(initialSelection)) return $fn();
2398
- const normalized = $normalizeSelection__EXPERIMENTAL(initialSelection);
2399
- const isBackwards = normalized.isBackward();
2400
- const anchorNode = $getPointNode(normalized.anchor, isBackwards ? -1 : 0);
2401
- const focusNode = $getPointNode(normalized.focus, isBackwards ? 0 : -1);
2402
- const rval = $fn();
2403
- if (anchorNode || focusNode) {
2404
- const updatedSelection = $getSelection();
2405
- if ($isRangeSelection(updatedSelection)) {
2406
- const finalSelection = updatedSelection.clone();
2407
- if (anchorNode) {
2408
- const anchorParent = anchorNode.getParent();
2409
- if (anchorParent) finalSelection.anchor.set(anchorParent.getKey(), anchorNode.getIndexWithinParent() + (isBackwards ? 1 : 0), "element");
2410
- }
2411
- if (focusNode) {
2412
- const focusParent = focusNode.getParent();
2413
- if (focusParent) finalSelection.focus.set(focusParent.getKey(), focusNode.getIndexWithinParent() + (isBackwards ? 0 : 1), "element");
2414
- }
2415
- $setSelection($normalizeSelection__EXPERIMENTAL(finalSelection));
2416
- }
2417
- }
2418
- return rval;
2419
- }
2420
- /**
2421
- * Generates or updates a LinkNode. It can also delete a LinkNode if the URL is null,
2422
- * but saves any children and brings them up to the parent node.
2423
- * @param url - The URL the link directs to.
2424
- * @param attributes - Optional HTML a tag attributes. \\{ target, rel, title \\}
2425
- */
2426
- function $toggleLink(url, attributes = {}) {
2427
- const { target, title } = attributes;
2428
- const rel = attributes.rel === void 0 ? "noreferrer" : attributes.rel;
2429
- const selection = $getSelection();
2430
- if (selection === null || !$isRangeSelection(selection) && !$isNodeSelection(selection)) return;
2431
- if ($isNodeSelection(selection)) {
2432
- const nodes = selection.getNodes();
2433
- if (nodes.length === 0) return;
2434
- nodes.forEach((node) => {
2435
- if (url === null) {
2436
- const linkParent = $findMatchingParent(node, (parent) => !$isAutoLinkNode(parent) && $isLinkNode(parent));
2437
- if (linkParent) {
2438
- linkParent.insertBefore(node);
2439
- if (linkParent.getChildren().length === 0) linkParent.remove();
2440
- }
2441
- } else {
2442
- const existingLink = $findMatchingParent(node, (parent) => !$isAutoLinkNode(parent) && $isLinkNode(parent));
2443
- if (existingLink) {
2444
- existingLink.setURL(url);
2445
- if (target !== void 0) existingLink.setTarget(target);
2446
- if (rel !== void 0) existingLink.setRel(rel);
2447
- } else {
2448
- const linkNode = $createLinkNode(url, {
2449
- rel,
2450
- target
2451
- });
2452
- node.insertBefore(linkNode);
2453
- linkNode.append(node);
2454
- }
2455
- }
2456
- });
2457
- return;
2458
- }
2459
- const nodes = selection.extract();
2460
- if (url === null) {
2461
- nodes.forEach((node) => {
2462
- const parentLink = $findMatchingParent(node, (parent) => !$isAutoLinkNode(parent) && $isLinkNode(parent));
2463
- if (parentLink) {
2464
- const children = parentLink.getChildren();
2465
- for (const child of children) parentLink.insertBefore(child);
2466
- parentLink.remove();
2467
- }
2468
- });
2469
- return;
2470
- }
2471
- const updatedNodes = /* @__PURE__ */ new Set();
2472
- const updateLinkNode = (linkNode) => {
2473
- if (updatedNodes.has(linkNode.getKey())) return;
2474
- updatedNodes.add(linkNode.getKey());
2475
- linkNode.setURL(url);
2476
- if (target !== void 0) linkNode.setTarget(target);
2477
- if (rel !== void 0) linkNode.setRel(rel);
2478
- if (title !== void 0) linkNode.setTitle(title);
2479
- };
2480
- if (nodes.length === 1) {
2481
- const firstNode = nodes[0];
2482
- const linkNode = $getAncestor(firstNode, $isLinkNode);
2483
- if (linkNode !== null) return updateLinkNode(linkNode);
2484
- }
2485
- $withSelectedNodes(() => {
2486
- let linkNode = null;
2487
- for (const node of nodes) {
2488
- if (!node.isAttached()) continue;
2489
- const parentLinkNode = $getAncestor(node, $isLinkNode);
2490
- if (parentLinkNode) {
2491
- updateLinkNode(parentLinkNode);
2492
- continue;
2493
- }
2494
- if ($isElementNode(node)) {
2495
- if (!node.isInline()) continue;
2496
- if ($isLinkNode(node)) {
2497
- if (!$isAutoLinkNode(node) && (linkNode === null || !linkNode.getParentOrThrow().isParentOf(node))) {
2498
- updateLinkNode(node);
2499
- linkNode = node;
2500
- continue;
2501
- }
2502
- for (const child of node.getChildren()) node.insertBefore(child);
2503
- node.remove();
2504
- continue;
2505
- }
2506
- }
2507
- const prevLinkNode = node.getPreviousSibling();
2508
- if ($isLinkNode(prevLinkNode) && prevLinkNode.is(linkNode)) {
2509
- prevLinkNode.append(node);
2510
- continue;
2511
- }
2512
- linkNode = $createLinkNode(url, {
2513
- rel,
2514
- target,
2515
- title
2516
- });
2517
- node.insertAfter(linkNode);
2518
- linkNode.append(node);
2519
- }
2520
- });
2521
- }
2522
- function $getAncestor(node, predicate) {
2523
- let parent = node;
2524
- while (parent !== null && parent.getParent() !== null && !predicate(parent)) parent = parent.getParentOrThrow();
2525
- return predicate(parent) ? parent : null;
2526
- }
2527
- const PHONE_NUMBER_REGEX = /^\+?[\d\s()-]{5,}$/;
2528
- /**
2529
- * Formats a URL string by adding appropriate protocol if missing
2530
- *
2531
- * @param url - URL to format
2532
- * @returns Formatted URL with appropriate protocol
2533
- */
2534
- function formatUrl(url) {
2535
- if (/^[a-z][\d+.a-z-]*:/i.test(url)) return url;
2536
- else if (/^[#./]/.test(url)) return url;
2537
- else if (url.includes("@")) return `mailto:${url}`;
2538
- else if (PHONE_NUMBER_REGEX.test(url)) return `tel:${url}`;
2539
- return url;
2540
- }
2541
- //#endregion
2542
- //#region src/plugins/link-highlight/node/link-highlight.ts
2543
- init_debug();
2544
- const logger = createDebugLogger("plugin", "link-highlight");
2545
- var LinkHighlightNode = class LinkHighlightNode extends ElementNode {
2546
- static getType() {
2547
- return "linkHighlight";
2548
- }
2549
- static clone(node) {
2550
- return new LinkHighlightNode(node.__key);
2551
- }
2552
- static importJSON(serializedNode) {
2553
- return $createLinkHighlightNode().updateFromJSON(serializedNode);
2554
- }
2555
- createDOM(config) {
2556
- logger.debug("🔍 config", config);
2557
- const element = document.createElement("a");
2558
- const url = this.getURL();
2559
- if (url) element.href = this.formatUrl(url);
2560
- element.setAttribute("target", "_blank");
2561
- element.setAttribute("rel", "noopener noreferrer");
2562
- addClassNamesToElement(element, config.theme.linkHighlight);
2563
- return element;
2564
- }
2565
- /**
2566
- * Format URL to ensure it has proper protocol
2567
- */
2568
- formatUrl(url) {
2569
- if (/^[a-z][\d+.a-z-]*:/i.test(url)) return url;
2570
- if (/^[#./]/.test(url)) return url;
2571
- if (url.includes("@") && !url.startsWith("mailto:")) return `mailto:${url}`;
2572
- if (/^\+?[\d\s()-]{5,}$/.test(url)) return `tel:${url}`;
2573
- if (url.startsWith("www.")) return `https://${url}`;
2574
- if (!url.includes("://")) return `https://${url}`;
2575
- return url;
2576
- }
2577
- canBeEmpty() {
2578
- return false;
2579
- }
2580
- isInline() {
2581
- return true;
2582
- }
2583
- canInsertTextBefore() {
2584
- return false;
2585
- }
2586
- canInsertTextAfter() {
2587
- return false;
2588
- }
2589
- updateDOM(prevNode, dom, config) {
2590
- if ((prevNode ? prevNode : null) !== this) addClassNamesToElement(dom, config.theme.linkHighlight);
2591
- if (dom instanceof HTMLAnchorElement) {
2592
- const url = this.getURL();
2593
- if (url) dom.href = this.formatUrl(url);
2594
- else dom.removeAttribute("href");
2595
- }
2596
- return false;
2597
- }
2598
- /**
2599
- * Get the URL from the text content
2600
- */
2601
- getURL() {
2602
- return this.getTextContent().trim();
2603
- }
2604
- };
2605
- function $createLinkHighlightNode() {
2606
- return $applyNodeReplacement(new LinkHighlightNode());
2607
- }
2608
- function $isLinkHighlightNode(node) {
2609
- return node instanceof LinkHighlightNode;
2610
- }
2611
- function getLinkHighlightNode(node) {
2612
- if ($isLinkHighlightNode(node)) return node;
2613
- const parent = node.getParent();
2614
- if ($isLinkHighlightNode(parent)) return parent;
2615
- return null;
2616
- }
2617
- //#endregion
2618
- //#region src/plugins/math/node/index.ts
2619
- var MathInlineNode = class MathInlineNode extends DecoratorNode {
2620
- static getType() {
2621
- return "math";
2622
- }
2623
- static clone(node) {
2624
- return new MathInlineNode(node.__code, node.__key);
2625
- }
2626
- static importJSON(serializedNode) {
2627
- return $createMathInlineNode().updateFromJSON(serializedNode);
2628
- }
2629
- static importDOM() {
2630
- return { span: (node) => {
2631
- if (node.classList.contains("math-inline")) return {
2632
- conversion: $convertMathInlineElement,
2633
- priority: 0
2634
- };
2635
- return null;
2636
- } };
2637
- }
2638
- constructor(code = "", key) {
2639
- super(key);
2640
- this.__code = code;
2641
- }
2642
- get code() {
2643
- return this.__code;
2644
- }
2645
- updateCode(newCode) {
2646
- const writer = this.getWritable();
2647
- writer.__code = newCode;
2648
- }
2649
- exportDOM() {
2650
- const span = document.createElement("span");
2651
- span.className = "math-inline";
2652
- return { element: span };
2653
- }
2654
- createDOM(config) {
2655
- const element = document.createElement("span");
2656
- addClassNamesToElement(element, config.theme.mathInline);
2657
- return element;
2658
- }
2659
- exportJSON() {
2660
- return {
2661
- ...super.exportJSON(),
2662
- code: this.__code
2663
- };
2664
- }
2665
- updateFromJSON(serializedNode) {
2666
- const node = super.updateFromJSON(serializedNode);
2667
- this.__code = serializedNode.code || "";
2668
- return node;
2669
- }
2670
- getTextContent() {
2671
- return `$${this.code}$`;
2672
- }
2673
- isInline() {
2674
- return true;
2675
- }
2676
- updateDOM() {
2677
- return false;
2678
- }
2679
- decorate(editor) {
2680
- const decorator = getKernelFromEditor(editor)?.getDecorator(MathInlineNode.getType());
2681
- if (!decorator) return null;
2682
- if (typeof decorator === "function") return decorator(this, editor);
2683
- return {
2684
- queryDOM: decorator.queryDOM,
2685
- render: decorator.render(this, editor)
2686
- };
2687
- }
2688
- };
2689
- var MathBlockNode = class MathBlockNode extends DecoratorNode {
2690
- static getType() {
2691
- return "mathBlock";
2692
- }
2693
- static clone(node) {
2694
- return new MathBlockNode(node.__code, node.__key);
2695
- }
2696
- static importJSON(serializedNode) {
2697
- return $createMathBlockNode().updateFromJSON(serializedNode);
2698
- }
2699
- static importDOM() {
2700
- return { div: (node) => {
2701
- if (node.classList.contains("math-block")) return {
2702
- conversion: $convertMathBlockElement,
2703
- priority: 0
2704
- };
2705
- return null;
2706
- } };
2707
- }
2708
- constructor(code = "", key) {
2709
- super(key);
2710
- this.__code = code;
2711
- }
2712
- get code() {
2713
- return this.__code;
2714
- }
2715
- updateCode(newCode) {
2716
- const writer = this.getWritable();
2717
- writer.__code = newCode;
2718
- }
2719
- exportDOM() {
2720
- const div = document.createElement("div");
2721
- div.className = "math-block";
2722
- return { element: div };
2723
- }
2724
- createDOM(config) {
2725
- const element = document.createElement("div");
2726
- addClassNamesToElement(element, config.theme.mathBlock);
2727
- return element;
2728
- }
2729
- exportJSON() {
2730
- return {
2731
- ...super.exportJSON(),
2732
- code: this.__code
2733
- };
2734
- }
2735
- updateFromJSON(serializedNode) {
2736
- const node = super.updateFromJSON(serializedNode);
2737
- this.__code = serializedNode.code || "";
2738
- return node;
2739
- }
2740
- getTextContent() {
2741
- return `$$\n${this.code}\n$$\n`;
2742
- }
2743
- isInline() {
2744
- return false;
2745
- }
2746
- updateDOM() {
2747
- return false;
2748
- }
2749
- decorate(editor) {
2750
- const decorator = getKernelFromEditor(editor)?.getDecorator(MathBlockNode.getType());
2751
- if (!decorator) return null;
2752
- if (typeof decorator === "function") return decorator(this, editor);
2753
- return {
2754
- queryDOM: decorator.queryDOM,
2755
- render: decorator.render(this, editor)
2756
- };
2757
- }
2758
- };
2759
- function $createMathInlineNode(code = "") {
2760
- return $applyNodeReplacement(new MathInlineNode(code));
2761
- }
2762
- function $createMathBlockNode(code = "") {
2763
- return $applyNodeReplacement(new MathBlockNode(code));
2764
- }
2765
- function $convertMathInlineElement() {
2766
- return { node: $createMathInlineNode() };
2767
- }
2768
- function $convertMathBlockElement() {
2769
- return { node: $createMathBlockNode() };
2770
- }
2771
- function $isMathNode(node) {
2772
- return node instanceof MathInlineNode || node instanceof MathBlockNode;
2773
- }
2774
- //#endregion
2775
- //#region src/plugins/mention/node/MentionNode.ts
2776
- init_utils();
2777
- var MentionNode = class MentionNode extends DecoratorNode {
2778
- static getType() {
2779
- return "mention";
2780
- }
2781
- static clone(node) {
2782
- return new MentionNode(node.__label, node.__metadata, node.__key);
2783
- }
2784
- static importJSON(serializedNode) {
2785
- return $createMentionNode().updateFromJSON(serializedNode);
2786
- }
2787
- static importDOM() {
2788
- return { span: (node) => {
2789
- if (node.classList.contains("mention")) return {
2790
- conversion: $convertMentionElement,
2791
- priority: 0
2792
- };
2793
- return null;
2794
- } };
2795
- }
2796
- constructor(label = "", metadata = {}, key) {
2797
- super(key);
2798
- this.__label = label;
2799
- this.__metadata = metadata;
2800
- }
2801
- get label() {
2802
- return this.__label;
2803
- }
2804
- get metadata() {
2805
- return this.__metadata;
2806
- }
2807
- exportDOM() {
2808
- return { element: document.createElement("span") };
2809
- }
2810
- createDOM(config) {
2811
- const element = document.createElement("span");
2812
- addClassNamesToElement(element, config.theme.mention);
2813
- return element;
2814
- }
2815
- getTextContent() {
2816
- return this.label;
2817
- }
2818
- isInline() {
2819
- return true;
2820
- }
2821
- updateDOM() {
2822
- return false;
2823
- }
2824
- exportJSON() {
2825
- return {
2826
- ...super.exportJSON(),
2827
- label: this.label,
2828
- metadata: this.metadata
2829
- };
2830
- }
2831
- updateFromJSON(serializedNode) {
2832
- const node = super.updateFromJSON(serializedNode);
2833
- this.__label = serializedNode.label || "";
2834
- this.__metadata = serializedNode.metadata || {};
2835
- return node;
2836
- }
2837
- decorate(editor) {
2838
- const decorator = getKernelFromEditor(editor)?.getDecorator(MentionNode.getType());
2839
- if (!decorator) return null;
2840
- if (typeof decorator === "function") return decorator(this, editor);
2841
- return {
2842
- queryDOM: decorator.queryDOM,
2843
- render: decorator.render(this, editor)
2844
- };
2845
- }
2846
- };
2847
- function $createMentionNode(label, metadata) {
2848
- return $applyNodeReplacement(new MentionNode(label, metadata));
2849
- }
2850
- function $convertMentionElement() {
2851
- return { node: $createMentionNode() };
2852
- }
2853
- function $isMentionNode(node) {
2854
- return node.getType() === MentionNode.getType();
2855
- }
2856
- //#endregion
2857
- //#region src/plugins/mention/react/style.ts
2858
- const styles = createStaticStyles(({ css, cssVar }) => ({ mention: css`
2859
- user-select: none;
2860
-
2861
- position: relative;
2862
-
2863
- display: inline;
2864
-
2865
- margin-inline: 0.25em;
2866
- padding-block: 0.2em;
2867
- padding-inline: 0.4em;
2868
- border: 1px solid ${cssVar.colorInfoBgHover};
2869
- border-radius: 0.25em;
2870
-
2871
- font-size: 0.875em;
2872
- line-height: 1;
2873
- color: ${cssVar.colorInfo};
2874
- word-break: break-word;
2875
- white-space: break-spaces;
2876
-
2877
- background: ${cssVar.colorInfoBg};
2878
-
2879
- .editor_mention {
2880
- padding: 0;
2881
- }
2882
-
2883
- &.selected {
2884
- color: #000;
2885
- background: ${cssVar.yellow};
2886
- }
2887
- ` }));
2888
- //#endregion
2889
- export { DOM_TEXT_TYPE as $, $createCodeMirrorNode as A, $isCursorInQuote as At, Editor as B, $createCodeNode as C, CONTROL_OR_META as Ct, getCodeInlineNode as D, KeyEnum as Dt, CodeNode as E, HotkeyScopeEnum as Et, $isCursorNode as F, init_utils$1 as Ft, kernel_exports as G, DataSource as H, CardLikeElementNode as I, sampleReader as It, $getNearestNodeFromDOMNode$1 as J, $closest as K, CursorNode as L, INodeHelper as Lt, CodeMirrorNode as M, $isRootTextContentEmpty as Mt, $createCursorNode as N, createBlockNode as Nt, styles$1 as O, init_hotkey$1 as Ot, $isCardLikeElementNode as P, exportNodeToJSON as Pt, DOM_ELEMENT_TYPE as Q, cursorNodeSerialized as R, init_helper as Rt, formatUrl as S, init_registerHotkey as St, $isSelectionInCodeInline as T, HotkeyEnum as Tt, Kernel as U, resetRandomKey$1 as V, init_kernel as W, DOM_DOCUMENT_FRAGMENT_TYPE as X, $getNodeFromDOMNode as Y, DOM_DOCUMENT_TYPE as Z, AutoLinkNode as _, unregisterEditorKernel as _t, $createMathBlockNode as a, generateEditorId as at, LinkNode as b, HOVER_COMMAND as bt, MathBlockNode as c, getNodeKeyFromDOMNode as ct, $isLinkHighlightNode as d, isDOMNode as dt, EDITOR_THEME_KEY as et, LinkHighlightNode as f, isDocumentFragment as ft, $toggleLink as g, registerEditorKernel as gt, $isLinkNode as h, reconcileDecorator as ht, MentionNode as i, genServiceId as it, $isCodeMirrorNode as j, $isCursorInTable as jt, themeStyles as k, $canShowPlaceholderCurry as kt, MathInlineNode as l, getParentElement as lt, $createLinkNode as m, noop as mt, $createMentionNode as n, compareNodeOrder as nt, $createMathInlineNode as o, getKernelFromEditor as ot, getLinkHighlightNode as p, moment as pt, $closestNodeType as q, $isMentionNode as r, createEmptyEditorState as rt, $isMathNode as s, getKernelFromEditorConfig as st, styles as t, assert as tt, $createLinkHighlightNode as u, init_utils as ut, HOVER_LINK_COMMAND as v, KernelPlugin as vt, $isCodeInlineNode as w, init_sys as wt, TOGGLE_LINK_COMMAND as x, getHotkeyById as xt, HOVER_OUT_LINK_COMMAND as y, init_plugin as yt, registerCursorNode as z };