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