@lobehub/editor 4.15.1 → 4.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (537) 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 +60 -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 +2 -0
  66. package/es/headless.js +782 -20254
  67. package/es/index.d.ts +113 -3059
  68. package/es/index.js +102 -8485
  69. package/es/locale/index.d.ts +63 -0
  70. package/es/locale/index.js +66 -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 +162 -0
  87. package/es/plugins/block/react/ReactBlockPlugin.d.ts +18 -0
  88. package/es/plugins/block/react/ReactBlockPlugin.js +613 -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 +122 -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 +61 -0
  96. package/es/plugins/block/service/i-block-menu-service.js +67 -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 +181 -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 +106 -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 +29 -0
  364. package/es/plugins/table/command/index.js +238 -0
  365. package/es/plugins/table/index.d.ts +4 -0
  366. package/es/plugins/table/node/index.d.ts +2 -0
  367. package/es/plugins/table/node/index.js +146 -0
  368. package/es/plugins/table/plugin/index.d.ts +14 -0
  369. package/es/plugins/table/plugin/index.js +361 -0
  370. package/es/plugins/table/react/TableActionMenu/ActionMenu.js +296 -0
  371. package/es/plugins/table/react/TableActionMenu/index.js +133 -0
  372. package/es/plugins/table/react/TableActionMenu/style.js +20 -0
  373. package/es/plugins/table/react/TableActionMenu/utils.js +34 -0
  374. package/es/plugins/table/react/TableColController.js +354 -0
  375. package/es/plugins/table/react/TableController/hooks.js +201 -0
  376. package/es/plugins/table/react/TableController/style.js +264 -0
  377. package/es/plugins/table/react/TableController/utils.js +25 -0
  378. package/es/plugins/table/react/TableControllerButton.js +81 -0
  379. package/es/plugins/table/react/TableControllerMenu.js +123 -0
  380. package/es/plugins/table/react/TableHoverActions/index.js +147 -0
  381. package/es/plugins/table/react/TableHoverActions/style.js +14 -0
  382. package/es/plugins/table/react/TableHoverActions/utils.js +32 -0
  383. package/es/plugins/table/react/TableInsertButton.js +25 -0
  384. package/es/plugins/table/react/TableResize/index.js +328 -0
  385. package/es/plugins/table/react/TableResize/style.js +16 -0
  386. package/es/plugins/table/react/TableResize/utils.js +9 -0
  387. package/es/plugins/table/react/TableRowController.js +349 -0
  388. package/es/plugins/table/react/hooks.js +77 -0
  389. package/es/plugins/table/react/index.d.ts +7 -0
  390. package/es/plugins/table/react/index.js +172 -0
  391. package/es/plugins/table/react/style.js +144 -0
  392. package/es/plugins/table/react/type.d.ts +10 -0
  393. package/es/plugins/table/react/useAutoFitPastedTable.js +189 -0
  394. package/es/plugins/table/service/i-table-controller-menu-service.d.ts +44 -0
  395. package/es/plugins/table/service/i-table-controller-menu-service.js +31 -0
  396. package/es/plugins/table/service/index.d.ts +1 -0
  397. package/es/plugins/table/utils/autoFitColumnWidth.js +87 -0
  398. package/es/plugins/table/utils/distributeColumnWidth.js +37 -0
  399. package/es/plugins/table/utils/index.js +148 -0
  400. package/es/plugins/toolbar/command/index.d.ts +12 -0
  401. package/es/plugins/toolbar/command/index.js +17 -0
  402. package/es/plugins/toolbar/index.d.ts +2 -0
  403. package/es/plugins/toolbar/react/index.d.ts +7 -0
  404. package/es/plugins/toolbar/react/index.js +109 -0
  405. package/es/plugins/toolbar/react/style.js +55 -0
  406. package/es/plugins/toolbar/react/type.d.ts +9 -0
  407. package/es/plugins/toolbar/utils/getDOMRangeRect.js +20 -0
  408. package/es/plugins/toolbar/utils/setFloatingElemPosition.js +50 -0
  409. package/es/plugins/upload/index.d.ts +2 -0
  410. package/es/plugins/upload/plugin/index.d.ts +6 -0
  411. package/es/plugins/upload/plugin/index.js +47 -0
  412. package/es/plugins/upload/service/i-upload-service.d.ts +13 -0
  413. package/es/plugins/upload/service/i-upload-service.js +30 -0
  414. package/es/plugins/upload/utils/index.js +15 -0
  415. package/es/plugins/virtual-block/index.d.ts +2 -0
  416. package/es/plugins/virtual-block/plugin/index.d.ts +8 -0
  417. package/es/plugins/virtual-block/plugin/index.js +19 -0
  418. package/es/plugins/virtual-block/plugin/register.js +150 -0
  419. package/es/plugins/virtual-block/react/ReactVirtualBlock.d.ts +6 -0
  420. package/es/plugins/virtual-block/react/ReactVirtualBlock.js +15 -0
  421. package/es/plugins/virtual-block/react/index.d.ts +1 -0
  422. package/es/react/ChatInput/ChatInput.d.ts +7 -0
  423. package/es/react/ChatInput/ChatInput.js +91 -0
  424. package/es/react/ChatInput/index.d.ts +2 -0
  425. package/es/react/ChatInput/style.js +115 -0
  426. package/es/react/ChatInput/type.d.ts +32 -0
  427. package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +7 -0
  428. package/es/react/ChatInputActionBar/ChatInputActionBar.js +22 -0
  429. package/es/react/ChatInputActionBar/index.d.ts +2 -0
  430. package/es/react/ChatInputActionBar/style.js +7 -0
  431. package/es/react/ChatInputActionBar/type.d.ts +10 -0
  432. package/es/react/ChatInputActions/ChatInputActions.d.ts +7 -0
  433. package/es/react/ChatInputActions/ChatInputActions.js +65 -0
  434. package/es/react/ChatInputActions/components/ActionItem.js +46 -0
  435. package/es/react/ChatInputActions/components/ActionRender.js +45 -0
  436. package/es/react/ChatInputActions/components/CollapsedActions.js +60 -0
  437. package/es/react/ChatInputActions/components/useDisplayActionCount.js +45 -0
  438. package/es/react/ChatInputActions/index.d.ts +2 -0
  439. package/es/react/ChatInputActions/style.js +20 -0
  440. package/es/react/ChatInputActions/type.d.ts +36 -0
  441. package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +7 -0
  442. package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +67 -0
  443. package/es/react/CodeLanguageSelect/index.d.ts +2 -0
  444. package/es/react/CodeLanguageSelect/style.js +7 -0
  445. package/es/react/CodeLanguageSelect/type.d.ts +6 -0
  446. package/es/react/Editor/Editor.js +108 -0
  447. package/es/react/Editor/index.d.ts +16 -0
  448. package/es/react/Editor/index.js +11 -0
  449. package/es/react/Editor/type.d.ts +64 -0
  450. package/es/react/Editor/utils.d.ts +6 -0
  451. package/es/react/Editor/utils.js +6 -0
  452. package/es/react/EditorProvider/index.d.ts +28 -0
  453. package/es/react/EditorProvider/index.js +18 -0
  454. package/es/react/FloatActions/FloatActions.d.ts +7 -0
  455. package/es/react/FloatActions/FloatActions.js +34 -0
  456. package/es/react/FloatActions/components/ActionItem.js +46 -0
  457. package/es/react/FloatActions/components/ActionRender.js +45 -0
  458. package/es/react/FloatActions/components/CollapsedActions.js +60 -0
  459. package/es/react/FloatActions/index.d.ts +2 -0
  460. package/es/react/FloatActions/style.js +19 -0
  461. package/es/react/FloatActions/type.d.ts +33 -0
  462. package/es/react/FloatMenu/FloatMenu.d.ts +7 -0
  463. package/es/react/FloatMenu/FloatMenu.js +32 -0
  464. package/es/react/FloatMenu/index.d.ts +2 -0
  465. package/es/react/FloatMenu/style.js +28 -0
  466. package/es/react/FloatMenu/type.d.ts +25 -0
  467. package/es/react/SendButton/SendButton.d.ts +7 -0
  468. package/es/react/SendButton/SendButton.js +107 -0
  469. package/es/react/SendButton/components/SendIcon.js +23 -0
  470. package/es/react/SendButton/components/StopIcon.js +56 -0
  471. package/es/react/SendButton/index.d.ts +2 -0
  472. package/es/react/SendButton/style.js +68 -0
  473. package/es/react/SendButton/type.d.ts +12 -0
  474. package/es/react/SlashMenu/SlashMenu.d.ts +7 -0
  475. package/es/react/SlashMenu/SlashMenu.js +40 -0
  476. package/es/react/SlashMenu/index.d.ts +2 -0
  477. package/es/react/SlashMenu/type.d.ts +17 -0
  478. package/es/react/hooks/useEditor.d.ts +5 -0
  479. package/es/react/hooks/useEditor.js +8 -0
  480. package/es/react/hooks/useEditorState/index.d.ts +71 -0
  481. package/es/react/hooks/useEditorState/index.js +347 -0
  482. package/es/react/hooks/useEditorState/utils.js +28 -0
  483. package/es/react/hooks/useSize.js +61 -0
  484. package/es/react.d.ts +22 -334
  485. package/es/react.js +13 -1573
  486. package/es/renderer/LexicalDiff.d.ts +41 -0
  487. package/es/renderer/LexicalDiff.js +96 -0
  488. package/es/renderer/LexicalRenderer.d.ts +16 -0
  489. package/es/renderer/LexicalRenderer.js +48 -0
  490. package/es/renderer/diff/compute.js +396 -0
  491. package/es/renderer/diff/style.d.ts +4 -0
  492. package/es/renderer/diff/style.js +104 -0
  493. package/es/renderer/diff/types.d.ts +32 -0
  494. package/es/renderer/engine/render-builtin-node.js +196 -0
  495. package/es/renderer/engine/render-text-node.js +33 -0
  496. package/es/renderer/engine/render-tree.js +35 -0
  497. package/es/renderer/engine/shiki.d.ts +4 -0
  498. package/es/renderer/engine/shiki.js +24 -0
  499. package/es/renderer/engine/utils.js +16 -0
  500. package/es/renderer/nodes/index.d.ts +6 -0
  501. package/es/renderer/nodes/index.js +44 -0
  502. package/es/renderer/renderers/codeblock.js +21 -0
  503. package/es/renderer/renderers/file.js +29 -0
  504. package/es/renderer/renderers/horizontalrule.js +29 -0
  505. package/es/renderer/renderers/image.js +35 -0
  506. package/es/renderer/renderers/index.d.ts +6 -0
  507. package/es/renderer/renderers/index.js +21 -0
  508. package/es/renderer/renderers/math.js +19 -0
  509. package/es/renderer/renderers/mention.js +15 -0
  510. package/es/renderer/renderers/mermaid.js +17 -0
  511. package/es/renderer/style.js +52 -0
  512. package/es/renderer/types.d.ts +29 -0
  513. package/es/renderer.d.ts +8 -114
  514. package/es/renderer.js +5 -1153
  515. package/es/types/hotkey.d.ts +76 -0
  516. package/es/types/hotkey.js +65 -0
  517. package/es/types/index.d.ts +2 -0
  518. package/es/types/kernel.d.ts +359 -0
  519. package/es/types/locale.d.ts +11 -0
  520. package/es/utils/cx.js +4 -0
  521. package/es/utils/debug.d.ts +425 -0
  522. package/es/{debug-CIvbNHJu.js → utils/debug.js} +3 -35
  523. package/es/utils/hotkey/isHotkeyMatch.js +17 -0
  524. package/es/utils/hotkey/parseHotkeys.js +53 -0
  525. package/es/utils/hotkey/registerHotkey.d.ts +18 -0
  526. package/es/utils/hotkey/registerHotkey.js +35 -0
  527. package/es/utils/scrollIntoView.d.ts +8 -0
  528. package/es/utils/scrollIntoView.js +29 -0
  529. package/es/utils/updatePosition.js +26 -0
  530. package/es/utils/url.d.ts +18 -0
  531. package/es/utils/url.js +34 -0
  532. package/package.json +4 -1
  533. package/es/ReactSlashPlugin-BiVy_Iwf.js +0 -23072
  534. package/es/codemirror-3POv7f__.js +0 -923
  535. package/es/index-DHGp94p0.d.ts +0 -916
  536. package/es/style-DADgHVA1.js +0 -2889
  537. package/es/style-DMdPzCo-.js +0 -999
@@ -0,0 +1,251 @@
1
+ //#region src/plugins/markdown/utils/detectLanguage.ts
2
+ const LANGUAGE_PATTERNS = {
3
+ bash: {
4
+ optional: [
5
+ /\|\||&&/,
6
+ /echo\s+/,
7
+ /if\s+\[/
8
+ ],
9
+ required: [/^#!\/bin\/(ba)?sh/, /\${?\w+}?/],
10
+ weight: 7
11
+ },
12
+ csharp: {
13
+ optional: [
14
+ /\[.*]/,
15
+ /async\s+Task/,
16
+ /var\s+\w+\s*=/
17
+ ],
18
+ required: [/(public|private|protected)\s+(class|interface|namespace)/, /using\s+\w+/],
19
+ weight: 8
20
+ },
21
+ css: {
22
+ optional: [/@media|@import|@keyframes/, /!important/],
23
+ required: [/[#.]?[\w-]+\s*{/, /:\s*[\w#%-]+;/],
24
+ weight: 8
25
+ },
26
+ dockerfile: {
27
+ required: [/^FROM\s+/, /^(RUN|CMD|COPY|ADD|WORKDIR|ENV|EXPOSE)\s+/m],
28
+ weight: 10
29
+ },
30
+ go: {
31
+ optional: [
32
+ /import\s+\(/,
33
+ /:=/,
34
+ /defer|goroutine/
35
+ ],
36
+ required: [/package\s+\w+/, /func\s+\w+/],
37
+ weight: 8
38
+ },
39
+ graphql: {
40
+ optional: [/fragment\s+/, /on\s+\w+/],
41
+ required: [/(query|mutation|subscription)\s+/, /{[\S\s]*}/],
42
+ weight: 8
43
+ },
44
+ html: {
45
+ optional: [/<\/\w+>/, /class=|id=/],
46
+ required: [/<(html|head|body|div|span|p|a|img|script|style|link|meta)/i],
47
+ weight: 9
48
+ },
49
+ ini: {
50
+ exclude: [/^\s*</, /{.*}/],
51
+ required: [/^\[.*]$/m, /\w+\s*=\s*/],
52
+ weight: 6
53
+ },
54
+ java: {
55
+ optional: [
56
+ /@Override|@Autowired/,
57
+ /extends|implements/,
58
+ /System\.out/
59
+ ],
60
+ required: [/(public|private|protected)\s+(class|interface|static)/, /\w+\s+\w+\s*\([^)]*\)\s*{/],
61
+ weight: 8
62
+ },
63
+ javascript: {
64
+ exclude: [
65
+ /^\s*</,
66
+ /interface\s+\w+/,
67
+ /:\s*\w+\s*[;=]/
68
+ ],
69
+ optional: [
70
+ /=>\s*{/,
71
+ /console\.(log|error|warn)/,
72
+ /\.then\(/,
73
+ /require\(/
74
+ ],
75
+ required: [/(function|const|let|var|class|import|export|async|await)\s/],
76
+ weight: 7
77
+ },
78
+ json: {
79
+ optional: [/"[^"]*"\s*:/, /:\s*["'[{]/],
80
+ required: [/^\s*[[{]/, /[\]}]\s*$/],
81
+ weight: 10
82
+ },
83
+ jsx: {
84
+ exclude: [/^\s*<!DOCTYPE/, /^\s*<html/],
85
+ optional: [
86
+ /className=/,
87
+ /{.*}/,
88
+ /import.*from/
89
+ ],
90
+ required: [/<\w+[^>]*>/, /(const|function|class)\s+\w+/],
91
+ weight: 8
92
+ },
93
+ makefile: {
94
+ optional: [/\$\(.*\)/, /\.PHONY/],
95
+ required: [/^[\w-]+:\s*/, /^\t/m],
96
+ weight: 7
97
+ },
98
+ markdown: {
99
+ optional: [
100
+ /```/,
101
+ /\*\*.*\*\*/,
102
+ /^\s*[*+-]\s+/m
103
+ ],
104
+ required: [/^#{1,6}\s+/, /\[.*]\(.*\)/],
105
+ weight: 6
106
+ },
107
+ php: {
108
+ optional: [
109
+ /function\s+\w+/,
110
+ /class\s+\w+/,
111
+ /echo|print/
112
+ ],
113
+ required: [/<\?php/, /\$\w+/],
114
+ weight: 10
115
+ },
116
+ powershell: {
117
+ optional: [
118
+ /\|\s*Where/,
119
+ /\|\s*Select/,
120
+ /param\(/
121
+ ],
122
+ required: [/\$\w+/, /(Get|Set|New|Remove)-\w+/],
123
+ weight: 8
124
+ },
125
+ python: {
126
+ optional: [
127
+ /if __name__|print\(/,
128
+ /self\.|lambda/,
129
+ /@\w+\s*$/m
130
+ ],
131
+ required: [/(def|class|import|from)\s+\w+/, /:\s*$/m],
132
+ weight: 8
133
+ },
134
+ ruby: {
135
+ optional: [
136
+ /do\s*\|.*\|/,
137
+ /puts|require/,
138
+ /:\w+\s*=>/
139
+ ],
140
+ required: [/(def|class|module|end)\s/, /@\w+/],
141
+ weight: 7
142
+ },
143
+ rust: {
144
+ optional: [
145
+ /::\w+/,
146
+ /&mut|&str/,
147
+ /#\[derive\(/
148
+ ],
149
+ required: [/(fn|struct|impl|trait|use)\s+/, /let\s+(mut\s+)?\w+/],
150
+ weight: 8
151
+ },
152
+ scss: {
153
+ optional: [/@mixin|@include|@extend/, /#{.*}/],
154
+ required: [/\$[\w-]+\s*:/, /[&@]\w+/],
155
+ weight: 8
156
+ },
157
+ sql: {
158
+ optional: [/from|where|join|group by|order by/i, /\*/],
159
+ required: [/(select|insert|update|delete|create|alter|drop)\s+/i],
160
+ weight: 9
161
+ },
162
+ toml: {
163
+ optional: [/\[\[.*]]/, /"""[\S\s]*"""/],
164
+ required: [/^\[.*]$/m, /\w+\s*=\s*[\w"']/],
165
+ weight: 8
166
+ },
167
+ tsx: {
168
+ optional: [
169
+ /:\s*React\./,
170
+ /:\s*FC</,
171
+ /useState|useEffect/
172
+ ],
173
+ required: [/<\w+[^>]*>/, /interface|type\s+\w+/],
174
+ weight: 9
175
+ },
176
+ typescript: {
177
+ optional: [
178
+ /<\w+>/,
179
+ /as\s+\w+/,
180
+ /implements|extends/
181
+ ],
182
+ required: [/(interface|type|enum)\s+\w+/, /:\s*\w+(\[]|<.+>)?\s*[);=]/],
183
+ weight: 8
184
+ },
185
+ xml: {
186
+ optional: [/<\/\w+>/, /xmlns/],
187
+ required: [/<\?xml|<\w+[^>]*>/],
188
+ weight: 9
189
+ },
190
+ yaml: {
191
+ exclude: [/^\s*[[\]{]/],
192
+ required: [/^[\s-]*\w+:\s*/, /^[\s-]*-\s+/m],
193
+ weight: 8
194
+ }
195
+ };
196
+ /**
197
+ * Detect the programming language of a code snippet
198
+ * @param code - The code snippet to analyze
199
+ * @returns Language detection result with confidence score
200
+ */
201
+ function detectLanguage(code) {
202
+ if (!code || code.trim().length === 0) return null;
203
+ const trimmed = code.trim();
204
+ const scores = {};
205
+ for (const [language, pattern] of Object.entries(LANGUAGE_PATTERNS)) {
206
+ let score = 0;
207
+ const baseWeight = pattern.weight || 5;
208
+ if (pattern.exclude) {
209
+ if (pattern.exclude.some((regex) => regex.test(trimmed))) continue;
210
+ }
211
+ if (pattern.required) {
212
+ if (!pattern.required.every((regex) => regex.test(trimmed))) continue;
213
+ score += baseWeight * 2;
214
+ }
215
+ if (pattern.optional) {
216
+ const matchedOptional = pattern.optional.filter((regex) => regex.test(trimmed)).length;
217
+ score += matchedOptional * baseWeight;
218
+ }
219
+ if (score > 0) scores[language] = score;
220
+ }
221
+ const entries = Object.entries(scores);
222
+ if (entries.length === 0) return null;
223
+ entries.sort((a, b) => b[1] - a[1]);
224
+ const [topLanguage, topScore] = entries[0];
225
+ const maxPossibleScore = (LANGUAGE_PATTERNS[topLanguage].weight || 5) * 5;
226
+ const confidence = Math.min(100, Math.round(topScore / maxPossibleScore * 100));
227
+ if (confidence < 30) return null;
228
+ return {
229
+ confidence,
230
+ language: topLanguage
231
+ };
232
+ }
233
+ /**
234
+ * Simple detection for common formats with high confidence
235
+ * Falls back to detectLanguage for more complex detection
236
+ */
237
+ function detectCodeLanguage(code) {
238
+ const trimmed = code.trim();
239
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) try {
240
+ JSON.parse(trimmed);
241
+ return "json";
242
+ } catch {}
243
+ if (/^\s*(select|insert|update|delete|create|alter|drop)\s+/i.test(code)) return "sql";
244
+ if (/^<\?xml/i.test(code)) return "xml";
245
+ if (/^FROM\s+|^RUN\s+|^CMD\s+/m.test(code)) return "dockerfile";
246
+ if (/<\?php/.test(code)) return "php";
247
+ const result = detectLanguage(code);
248
+ return result && result.confidence > 50 ? result.language : null;
249
+ }
250
+ //#endregion
251
+ export { detectCodeLanguage, detectLanguage };
@@ -0,0 +1,11 @@
1
+ import { BaseSelection, LexicalEditor, LexicalNode, TextNode } from "lexical";
2
+
3
+ //#region src/plugins/markdown/utils/index.d.ts
4
+ /**
5
+ * Checks if a character is a punctuation character.
6
+ * @param char The character to check.
7
+ * @returns True if the character is a punctuation character, false otherwise.
8
+ */
9
+ declare function isPunctuationChar(char: string): boolean;
10
+ //#endregion
11
+ export { isPunctuationChar };
@@ -0,0 +1,143 @@
1
+ import { $caretFromPoint, $getCaretRange, $getChildCaret, $getRoot, $isElementNode, $isRangeSelection, $isTextNode, $isTextPointCaret, $parseSerializedNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND } from "lexical";
2
+ //#region src/plugins/markdown/utils/index.ts
3
+ /**
4
+ * Returns true if the node can contain transformable markdown.
5
+ * Code nodes cannot contain transformable markdown.
6
+ * For example, `code **bold**` should not be transformed to
7
+ * <code>code <strong>bold</strong></code>.
8
+ */
9
+ function canContainTransformableMarkdown(node) {
10
+ return $isTextNode(node) && !node.hasFormat("code");
11
+ }
12
+ function isEqualSubString(stringA, aStart, stringB, bStart, length) {
13
+ for (let i = 0; i < length; i++) if (stringA[aStart + i] !== stringB[bStart + i]) return false;
14
+ return true;
15
+ }
16
+ const PUNCTUATION_OR_SPACE = /[!-/:-@[-`{-~\s]/;
17
+ function getOpenTagStartIndex(string, maxIndex, tag) {
18
+ const tagLength = tag.length;
19
+ for (let i = maxIndex; i >= tagLength; i--) {
20
+ const startIndex = i - tagLength;
21
+ if (isEqualSubString(string, startIndex, tag, 0, tagLength) && string[startIndex + tagLength] !== " ") return startIndex;
22
+ }
23
+ return -1;
24
+ }
25
+ function indexBy(list, callback) {
26
+ const index = {};
27
+ for (const item of list) {
28
+ const key = callback(item);
29
+ if (!key) continue;
30
+ if (index[key]) index[key].push(item);
31
+ else index[key] = [item];
32
+ }
33
+ return index;
34
+ }
35
+ let Punctuation = /[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~\u00A1\u2010-\u2027-]/;
36
+ try {
37
+ Punctuation = /* @__PURE__ */ new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]", "u");
38
+ } catch {}
39
+ /**
40
+ * Checks if a character is a punctuation character.
41
+ * @param char The character to check.
42
+ * @returns True if the character is a punctuation character, false otherwise.
43
+ */
44
+ function isPunctuationChar(char) {
45
+ return Punctuation.test(char);
46
+ }
47
+ function $updateSelectionOnInsert(selection) {
48
+ if ($isRangeSelection(selection) && selection.isCollapsed()) {
49
+ const anchor = selection.anchor;
50
+ let nodeToInspect = null;
51
+ const anchorCaret = $caretFromPoint(anchor, "previous");
52
+ if (anchorCaret) if ($isTextPointCaret(anchorCaret)) nodeToInspect = anchorCaret.origin;
53
+ else {
54
+ const range = $getCaretRange(anchorCaret, $getChildCaret($getRoot(), "next").getFlipped());
55
+ for (const caret of range) if ($isTextNode(caret.origin)) {
56
+ nodeToInspect = caret.origin;
57
+ break;
58
+ } else if ($isElementNode(caret.origin) && !caret.origin.isInline()) break;
59
+ }
60
+ if (nodeToInspect && $isTextNode(nodeToInspect)) {
61
+ const newFormat = nodeToInspect.getFormat();
62
+ const newStyle = nodeToInspect.getStyle();
63
+ if (selection.format !== newFormat || selection.style !== newStyle) {
64
+ selection.format = newFormat;
65
+ selection.style = newStyle;
66
+ selection.dirty = true;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ /**
72
+ * Inserts Lexical nodes into the editor using different strategies depending on
73
+ * some simple selection-based heuristics. If you're looking for a generic way to
74
+ * to insert nodes into the editor at a specific selection point, you probably want
75
+ * {@link lexical.$insertNodes}
76
+ *
77
+ * @param editor LexicalEditor instance to insert the nodes into.
78
+ * @param nodes The nodes to insert.
79
+ * @param selection The selection to insert the nodes into.
80
+ */
81
+ function $insertGeneratedNodes(editor, nodes, selection) {
82
+ if (!editor.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, {
83
+ nodes,
84
+ selection
85
+ })) {
86
+ selection.insertNodes(nodes);
87
+ $updateSelectionOnInsert(selection);
88
+ }
89
+ }
90
+ /**
91
+ * Creates an object containing all the styles and their values provided in the CSS string.
92
+ * @param css - The CSS string of styles and their values.
93
+ * @returns The styleObject containing all the styles and their values.
94
+ */
95
+ function getStyleObjectFromRawCSS(css) {
96
+ const styleObject = {};
97
+ if (!css) return styleObject;
98
+ const styles = css.split(";");
99
+ for (const style of styles) if (style !== "") {
100
+ const [key, value] = style.split(/:([^]+)/);
101
+ if (key && value) styleObject[key.trim()] = value.trim();
102
+ }
103
+ return styleObject;
104
+ }
105
+ /**
106
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
107
+ *
108
+ * This source code is licensed under the MIT license found in the
109
+ * LICENSE file in the root directory of this source tree.
110
+ *
111
+ */
112
+ const CSS_TO_STYLES = /* @__PURE__ */ new Map();
113
+ /**
114
+ * Gets the TextNode's style object and adds the styles to the CSS.
115
+ * @param node - The TextNode to add styles to.
116
+ */
117
+ function $addNodeStyle(node) {
118
+ const CSSText = node.getStyle();
119
+ const styles = getStyleObjectFromRawCSS(CSSText);
120
+ CSS_TO_STYLES.set(CSSText, styles);
121
+ }
122
+ /**
123
+ * This method takes an array of objects conforming to the BaseSerializedNode interface and returns
124
+ * an Array containing instances of the corresponding LexicalNode classes registered on the editor.
125
+ * Normally, you'd get an Array of BaseSerialized nodes from {@link $generateJSONFromSelectedNodes}
126
+ *
127
+ * @param serializedNodes an Array of objects conforming to the BaseSerializedNode interface.
128
+ * @returns an Array of Lexical Node objects.
129
+ */
130
+ function $generateNodesFromSerializedNodes(serializedNodes) {
131
+ const nodes = [];
132
+ for (const serializedNode of serializedNodes) {
133
+ const node = $parseSerializedNode(serializedNode);
134
+ if ($isTextNode(node)) $addNodeStyle(node);
135
+ nodes.push(node);
136
+ }
137
+ return nodes;
138
+ }
139
+ function insertIRootNode(editor, root, selection) {
140
+ $insertGeneratedNodes(editor, $generateNodesFromSerializedNodes(root.children), selection);
141
+ }
142
+ //#endregion
143
+ export { $generateNodesFromSerializedNodes, $insertGeneratedNodes, PUNCTUATION_OR_SPACE, canContainTransformableMarkdown, getOpenTagStartIndex, indexBy, insertIRootNode, isEqualSubString, isPunctuationChar };
@@ -0,0 +1,6 @@
1
+ import { createDebugLogger, init_debug } from "../../../utils/debug.js";
2
+ //#region src/plugins/markdown/utils/logger.ts
3
+ init_debug();
4
+ const logger = createDebugLogger("plugin", "markdown");
5
+ //#endregion
6
+ export { logger };
@@ -0,0 +1,9 @@
1
+ import * as _$lexical from "lexical";
2
+ import { LexicalEditor } from "lexical";
3
+
4
+ //#region src/plugins/math/command/index.d.ts
5
+ declare const INSERT_MATH_COMMAND: _$lexical.LexicalCommand<{
6
+ code: string;
7
+ }>;
8
+ //#endregion
9
+ export { INSERT_MATH_COMMAND };
@@ -0,0 +1,38 @@
1
+ import { $createMathInlineNode } from "../node/index.js";
2
+ import { $createParagraphNode, $getNodeByKey, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_HIGH, createCommand } from "lexical";
3
+ import { $wrapNodeInElement, mergeRegister } from "@lexical/utils";
4
+ //#region src/plugins/math/command/index.ts
5
+ const INSERT_MATH_COMMAND = createCommand("INSERT_MATH_COMMAND");
6
+ const UPDATE_MATH_COMMAND = createCommand("UPDATE_MATH_COMMAND");
7
+ const SELECT_MATH_SIDE_COMMAND = createCommand("SELECT_MATH_SIDE_COMMAND");
8
+ function registerMathCommand(editor) {
9
+ return mergeRegister(editor.registerCommand(INSERT_MATH_COMMAND, (payload) => {
10
+ const { code } = payload;
11
+ editor.update(() => {
12
+ const mathNode = $createMathInlineNode(code);
13
+ $insertNodes([mathNode]);
14
+ if ($isRootOrShadowRoot(mathNode.getParentOrThrow())) $wrapNodeInElement(mathNode, $createParagraphNode).selectEnd();
15
+ });
16
+ return true;
17
+ }, COMMAND_PRIORITY_HIGH), editor.registerCommand(UPDATE_MATH_COMMAND, (payload) => {
18
+ const { code, key } = payload;
19
+ editor.update(() => {
20
+ const mathCode = $getNodeByKey(key);
21
+ if (mathCode) {
22
+ mathCode.updateCode(code);
23
+ mathCode.selectNext();
24
+ }
25
+ });
26
+ return true;
27
+ }, COMMAND_PRIORITY_HIGH), editor.registerCommand(SELECT_MATH_SIDE_COMMAND, (payload) => {
28
+ const { key, prev } = payload;
29
+ editor.update(() => {
30
+ const mathNode = $getNodeByKey(key);
31
+ if (mathNode) if (prev) mathNode.selectPrevious();
32
+ else mathNode.selectNext();
33
+ });
34
+ return true;
35
+ }, COMMAND_PRIORITY_HIGH));
36
+ }
37
+ //#endregion
38
+ export { INSERT_MATH_COMMAND, SELECT_MATH_SIDE_COMMAND, UPDATE_MATH_COMMAND, registerMathCommand };
@@ -0,0 +1,3 @@
1
+ import { INSERT_MATH_COMMAND } from "./command/index.js";
2
+ import { MathPlugin } from "./plugin/index.js";
3
+ import { ReactMathPlugin } from "./react/index.js";
@@ -0,0 +1,44 @@
1
+ import { DOMConversionMap, DOMExportOutput, DecoratorNode, EditorConfig, LexicalEditor, LexicalNode, LexicalUpdateJSON, SerializedLexicalNode, Spread } from "lexical";
2
+
3
+ //#region src/plugins/math/node/index.d.ts
4
+ type SerializedMathInlineNode = Spread<{
5
+ code: string;
6
+ }, SerializedLexicalNode>;
7
+ declare class MathInlineNode extends DecoratorNode<unknown> {
8
+ static getType(): string;
9
+ static clone(node: MathInlineNode): MathInlineNode;
10
+ static importJSON(serializedNode: SerializedMathInlineNode): MathInlineNode;
11
+ static importDOM(): DOMConversionMap | null;
12
+ __code: string;
13
+ constructor(code?: string, key?: string);
14
+ get code(): string;
15
+ updateCode(newCode: string): void;
16
+ exportDOM(): DOMExportOutput;
17
+ createDOM(config: EditorConfig): HTMLElement;
18
+ exportJSON(): SerializedMathInlineNode;
19
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedMathInlineNode>): this;
20
+ getTextContent(): string;
21
+ isInline(): boolean;
22
+ updateDOM(): boolean;
23
+ decorate(editor: LexicalEditor): unknown;
24
+ }
25
+ declare class MathBlockNode extends DecoratorNode<unknown> {
26
+ static getType(): string;
27
+ static clone(node: MathBlockNode): MathBlockNode;
28
+ static importJSON(serializedNode: SerializedMathInlineNode): MathBlockNode;
29
+ static importDOM(): DOMConversionMap | null;
30
+ __code: string;
31
+ constructor(code?: string, key?: string);
32
+ get code(): string;
33
+ updateCode(newCode: string): void;
34
+ exportDOM(): DOMExportOutput;
35
+ createDOM(config: EditorConfig): HTMLElement;
36
+ exportJSON(): SerializedMathInlineNode;
37
+ updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedMathInlineNode>): this;
38
+ getTextContent(): string;
39
+ isInline(): boolean;
40
+ updateDOM(): boolean;
41
+ decorate(editor: LexicalEditor): unknown;
42
+ }
43
+ //#endregion
44
+ export { MathBlockNode, MathInlineNode };
@@ -0,0 +1,161 @@
1
+ import { getKernelFromEditor } from "../../../editor-kernel/utils.js";
2
+ import { $applyNodeReplacement, DecoratorNode } from "lexical";
3
+ import { addClassNamesToElement } from "@lexical/utils";
4
+ //#region src/plugins/math/node/index.ts
5
+ var MathInlineNode = class MathInlineNode extends DecoratorNode {
6
+ static getType() {
7
+ return "math";
8
+ }
9
+ static clone(node) {
10
+ return new MathInlineNode(node.__code, node.__key);
11
+ }
12
+ static importJSON(serializedNode) {
13
+ return $createMathInlineNode().updateFromJSON(serializedNode);
14
+ }
15
+ static importDOM() {
16
+ return { span: (node) => {
17
+ if (node.classList.contains("math-inline")) return {
18
+ conversion: $convertMathInlineElement,
19
+ priority: 0
20
+ };
21
+ return null;
22
+ } };
23
+ }
24
+ constructor(code = "", key) {
25
+ super(key);
26
+ this.__code = code;
27
+ }
28
+ get code() {
29
+ return this.__code;
30
+ }
31
+ updateCode(newCode) {
32
+ const writer = this.getWritable();
33
+ writer.__code = newCode;
34
+ }
35
+ exportDOM() {
36
+ const span = document.createElement("span");
37
+ span.className = "math-inline";
38
+ return { element: span };
39
+ }
40
+ createDOM(config) {
41
+ const element = document.createElement("span");
42
+ addClassNamesToElement(element, config.theme.mathInline);
43
+ return element;
44
+ }
45
+ exportJSON() {
46
+ return {
47
+ ...super.exportJSON(),
48
+ code: this.__code
49
+ };
50
+ }
51
+ updateFromJSON(serializedNode) {
52
+ const node = super.updateFromJSON(serializedNode);
53
+ this.__code = serializedNode.code || "";
54
+ return node;
55
+ }
56
+ getTextContent() {
57
+ return `$${this.code}$`;
58
+ }
59
+ isInline() {
60
+ return true;
61
+ }
62
+ updateDOM() {
63
+ return false;
64
+ }
65
+ decorate(editor) {
66
+ const decorator = getKernelFromEditor(editor)?.getDecorator(MathInlineNode.getType());
67
+ if (!decorator) return null;
68
+ if (typeof decorator === "function") return decorator(this, editor);
69
+ return {
70
+ queryDOM: decorator.queryDOM,
71
+ render: decorator.render(this, editor)
72
+ };
73
+ }
74
+ };
75
+ var MathBlockNode = class MathBlockNode extends DecoratorNode {
76
+ static getType() {
77
+ return "mathBlock";
78
+ }
79
+ static clone(node) {
80
+ return new MathBlockNode(node.__code, node.__key);
81
+ }
82
+ static importJSON(serializedNode) {
83
+ return $createMathBlockNode().updateFromJSON(serializedNode);
84
+ }
85
+ static importDOM() {
86
+ return { div: (node) => {
87
+ if (node.classList.contains("math-block")) return {
88
+ conversion: $convertMathBlockElement,
89
+ priority: 0
90
+ };
91
+ return null;
92
+ } };
93
+ }
94
+ constructor(code = "", key) {
95
+ super(key);
96
+ this.__code = code;
97
+ }
98
+ get code() {
99
+ return this.__code;
100
+ }
101
+ updateCode(newCode) {
102
+ const writer = this.getWritable();
103
+ writer.__code = newCode;
104
+ }
105
+ exportDOM() {
106
+ const div = document.createElement("div");
107
+ div.className = "math-block";
108
+ return { element: div };
109
+ }
110
+ createDOM(config) {
111
+ const element = document.createElement("div");
112
+ addClassNamesToElement(element, config.theme.mathBlock);
113
+ return element;
114
+ }
115
+ exportJSON() {
116
+ return {
117
+ ...super.exportJSON(),
118
+ code: this.__code
119
+ };
120
+ }
121
+ updateFromJSON(serializedNode) {
122
+ const node = super.updateFromJSON(serializedNode);
123
+ this.__code = serializedNode.code || "";
124
+ return node;
125
+ }
126
+ getTextContent() {
127
+ return `$$\n${this.code}\n$$\n`;
128
+ }
129
+ isInline() {
130
+ return false;
131
+ }
132
+ updateDOM() {
133
+ return false;
134
+ }
135
+ decorate(editor) {
136
+ const decorator = getKernelFromEditor(editor)?.getDecorator(MathBlockNode.getType());
137
+ if (!decorator) return null;
138
+ if (typeof decorator === "function") return decorator(this, editor);
139
+ return {
140
+ queryDOM: decorator.queryDOM,
141
+ render: decorator.render(this, editor)
142
+ };
143
+ }
144
+ };
145
+ function $createMathInlineNode(code = "") {
146
+ return $applyNodeReplacement(new MathInlineNode(code));
147
+ }
148
+ function $createMathBlockNode(code = "") {
149
+ return $applyNodeReplacement(new MathBlockNode(code));
150
+ }
151
+ function $convertMathInlineElement() {
152
+ return { node: $createMathInlineNode() };
153
+ }
154
+ function $convertMathBlockElement() {
155
+ return { node: $createMathBlockNode() };
156
+ }
157
+ function $isMathNode(node) {
158
+ return node instanceof MathInlineNode || node instanceof MathBlockNode;
159
+ }
160
+ //#endregion
161
+ export { $createMathBlockNode, $createMathInlineNode, $isMathNode, MathBlockNode, MathInlineNode };
@@ -0,0 +1,15 @@
1
+ import { IEditorPluginConstructor } from "../../../types/kernel.js";
2
+ import { MathBlockNode, MathInlineNode } from "../node/index.js";
3
+ import { LexicalEditor } from "lexical";
4
+
5
+ //#region src/plugins/math/plugin/index.d.ts
6
+ interface MathPluginOptions {
7
+ decorator: (node: MathInlineNode | MathBlockNode, editor: LexicalEditor) => unknown;
8
+ theme?: {
9
+ mathBlock?: string;
10
+ mathInline?: string;
11
+ };
12
+ }
13
+ declare const MathPlugin: IEditorPluginConstructor<MathPluginOptions>;
14
+ //#endregion
15
+ export { MathPlugin };