@lobehub/editor 1.0.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 (392) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +635 -0
  3. package/es/common/canUseDOM.d.ts +8 -0
  4. package/es/common/canUseDOM.js +9 -0
  5. package/es/common/sys.d.ts +17 -0
  6. package/es/common/sys.js +30 -0
  7. package/es/editor-kernel/data-source.d.ts +8 -0
  8. package/es/editor-kernel/data-source.js +30 -0
  9. package/es/editor-kernel/event.d.ts +3 -0
  10. package/es/editor-kernel/event.js +11 -0
  11. package/es/editor-kernel/index.d.ts +11 -0
  12. package/es/editor-kernel/index.js +14 -0
  13. package/es/editor-kernel/inode/helper.d.ts +11 -0
  14. package/es/editor-kernel/inode/helper.js +48 -0
  15. package/es/editor-kernel/inode/i-element-node.d.ts +5 -0
  16. package/es/editor-kernel/inode/i-element-node.js +1 -0
  17. package/es/editor-kernel/inode/i-node.d.ts +6 -0
  18. package/es/editor-kernel/inode/i-node.js +1 -0
  19. package/es/editor-kernel/inode/index.d.ts +5 -0
  20. package/es/editor-kernel/inode/index.js +5 -0
  21. package/es/editor-kernel/inode/paragraph-node.d.ts +6 -0
  22. package/es/editor-kernel/inode/paragraph-node.js +1 -0
  23. package/es/editor-kernel/inode/root-node.d.ts +7 -0
  24. package/es/editor-kernel/inode/root-node.js +1 -0
  25. package/es/editor-kernel/inode/text-node.d.ts +12 -0
  26. package/es/editor-kernel/inode/text-node.js +1 -0
  27. package/es/editor-kernel/kernel.d.ts +46 -0
  28. package/es/editor-kernel/kernel.js +273 -0
  29. package/es/editor-kernel/plugin.d.ts +7 -0
  30. package/es/editor-kernel/plugin.js +54 -0
  31. package/es/editor-kernel/react/LexicalErrorBoundary.d.ts +13 -0
  32. package/es/editor-kernel/react/LexicalErrorBoundary.js +26 -0
  33. package/es/editor-kernel/react/index.d.ts +5 -0
  34. package/es/editor-kernel/react/index.js +5 -0
  35. package/es/editor-kernel/react/react-context.d.ts +10 -0
  36. package/es/editor-kernel/react/react-context.js +25 -0
  37. package/es/editor-kernel/react/react-editor.d.ts +12 -0
  38. package/es/editor-kernel/react/react-editor.js +57 -0
  39. package/es/editor-kernel/react/useDecorators.d.ts +9 -0
  40. package/es/editor-kernel/react/useDecorators.js +69 -0
  41. package/es/editor-kernel/react/useLexicalEditor.d.ts +2 -0
  42. package/es/editor-kernel/react/useLexicalEditor.js +31 -0
  43. package/es/editor-kernel/react/useLexicalNodeSelection.d.ts +17 -0
  44. package/es/editor-kernel/react/useLexicalNodeSelection.js +99 -0
  45. package/es/editor-kernel/react/useToolbarState.d.ts +31 -0
  46. package/es/editor-kernel/react/useToolbarState.js +302 -0
  47. package/es/editor-kernel/react/useTranslation.d.ts +3 -0
  48. package/es/editor-kernel/react/useTranslation.js +19 -0
  49. package/es/editor-kernel/types.d.ts +189 -0
  50. package/es/editor-kernel/types.js +1 -0
  51. package/es/editor-kernel/utils.d.ts +25 -0
  52. package/es/editor-kernel/utils.js +69 -0
  53. package/es/index.d.ts +14 -0
  54. package/es/index.js +14 -0
  55. package/es/locale/index.d.ts +25 -0
  56. package/es/locale/index.js +24 -0
  57. package/es/plugins/codeblock/command/index.d.ts +20 -0
  58. package/es/plugins/codeblock/command/index.js +84 -0
  59. package/es/plugins/codeblock/index.d.ts +4 -0
  60. package/es/plugins/codeblock/index.js +4 -0
  61. package/es/plugins/codeblock/plugin/CodeHighlighterShiki.d.ts +24 -0
  62. package/es/plugins/codeblock/plugin/CodeHighlighterShiki.js +680 -0
  63. package/es/plugins/codeblock/plugin/FacadeShiki.d.ts +51 -0
  64. package/es/plugins/codeblock/plugin/FacadeShiki.js +348 -0
  65. package/es/plugins/codeblock/plugin/index.d.ts +18 -0
  66. package/es/plugins/codeblock/plugin/index.js +90 -0
  67. package/es/plugins/codeblock/plugin/invariant.d.ts +8 -0
  68. package/es/plugins/codeblock/plugin/invariant.js +17 -0
  69. package/es/plugins/codeblock/react/ReactCodeblockPlugin.d.ts +4 -0
  70. package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +51 -0
  71. package/es/plugins/codeblock/react/index.d.ts +2 -0
  72. package/es/plugins/codeblock/react/index.js +1 -0
  73. package/es/plugins/codeblock/react/style.d.ts +6 -0
  74. package/es/plugins/codeblock/react/style.js +38 -0
  75. package/es/plugins/codeblock/react/type.d.ts +5 -0
  76. package/es/plugins/codeblock/react/type.js +1 -0
  77. package/es/plugins/codeblock/utils/language.d.ts +1 -0
  78. package/es/plugins/codeblock/utils/language.js +12 -0
  79. package/es/plugins/common/command/index.d.ts +7 -0
  80. package/es/plugins/common/command/index.js +31 -0
  81. package/es/plugins/common/data-source/json-data-source.d.ts +7 -0
  82. package/es/plugins/common/data-source/json-data-source.js +39 -0
  83. package/es/plugins/common/data-source/text-data-source.d.ts +6 -0
  84. package/es/plugins/common/data-source/text-data-source.js +54 -0
  85. package/es/plugins/common/index.d.ts +3 -0
  86. package/es/plugins/common/index.js +3 -0
  87. package/es/plugins/common/node/ElementDOMSlot.d.ts +5 -0
  88. package/es/plugins/common/node/ElementDOMSlot.js +59 -0
  89. package/es/plugins/common/node/LexicalLineBreakNode.d.ts +31 -0
  90. package/es/plugins/common/node/LexicalLineBreakNode.js +140 -0
  91. package/es/plugins/common/node/ParagraphNode.d.ts +7 -0
  92. package/es/plugins/common/node/ParagraphNode.js +47 -0
  93. package/es/plugins/common/plugin/index.d.ts +16 -0
  94. package/es/plugins/common/plugin/index.js +245 -0
  95. package/es/plugins/common/plugin/register.d.ts +4 -0
  96. package/es/plugins/common/plugin/register.js +230 -0
  97. package/es/plugins/common/react/Placeholder/index.d.ts +7 -0
  98. package/es/plugins/common/react/Placeholder/index.js +53 -0
  99. package/es/plugins/common/react/Placeholder/style.d.ts +4 -0
  100. package/es/plugins/common/react/Placeholder/style.js +12 -0
  101. package/es/plugins/common/react/ReactEditorContent.d.ts +4 -0
  102. package/es/plugins/common/react/ReactEditorContent.js +7 -0
  103. package/es/plugins/common/react/ReactPlainText.d.ts +4 -0
  104. package/es/plugins/common/react/ReactPlainText.js +100 -0
  105. package/es/plugins/common/react/index.d.ts +3 -0
  106. package/es/plugins/common/react/index.js +3 -0
  107. package/es/plugins/common/react/style.d.ts +18 -0
  108. package/es/plugins/common/react/style.js +38 -0
  109. package/es/plugins/common/react/type.d.ts +21 -0
  110. package/es/plugins/common/react/type.js +1 -0
  111. package/es/plugins/common/utils/index.d.ts +28 -0
  112. package/es/plugins/common/utils/index.js +96 -0
  113. package/es/plugins/file/command/index.d.ts +7 -0
  114. package/es/plugins/file/command/index.js +28 -0
  115. package/es/plugins/file/index.d.ts +3 -0
  116. package/es/plugins/file/index.js +3 -0
  117. package/es/plugins/file/node/FileNode.d.ts +36 -0
  118. package/es/plugins/file/node/FileNode.js +177 -0
  119. package/es/plugins/file/plugin/index.d.ts +14 -0
  120. package/es/plugins/file/plugin/index.js +116 -0
  121. package/es/plugins/file/react/ReactFilePlugin.d.ts +4 -0
  122. package/es/plugins/file/react/ReactFilePlugin.js +74 -0
  123. package/es/plugins/file/react/components/ReactFile.d.ts +10 -0
  124. package/es/plugins/file/react/components/ReactFile.js +65 -0
  125. package/es/plugins/file/react/index.d.ts +2 -0
  126. package/es/plugins/file/react/index.js +1 -0
  127. package/es/plugins/file/react/style.d.ts +3 -0
  128. package/es/plugins/file/react/style.js +11 -0
  129. package/es/plugins/file/react/type.d.ts +13 -0
  130. package/es/plugins/file/react/type.js +1 -0
  131. package/es/plugins/file/utils/index.d.ts +2 -0
  132. package/es/plugins/file/utils/index.js +45 -0
  133. package/es/plugins/hr/command/index.d.ts +3 -0
  134. package/es/plugins/hr/command/index.js +13 -0
  135. package/es/plugins/hr/index.d.ts +3 -0
  136. package/es/plugins/hr/index.js +3 -0
  137. package/es/plugins/hr/node/HorizontalRuleNode.d.ts +16 -0
  138. package/es/plugins/hr/node/HorizontalRuleNode.js +100 -0
  139. package/es/plugins/hr/plugin/index.d.ts +8 -0
  140. package/es/plugins/hr/plugin/index.js +70 -0
  141. package/es/plugins/hr/react/ReactHRPlugin.d.ts +4 -0
  142. package/es/plugins/hr/react/ReactHRPlugin.js +36 -0
  143. package/es/plugins/hr/react/components/HRNode.d.ts +10 -0
  144. package/es/plugins/hr/react/components/HRNode.js +45 -0
  145. package/es/plugins/hr/react/index.d.ts +2 -0
  146. package/es/plugins/hr/react/index.js +1 -0
  147. package/es/plugins/hr/react/style.d.ts +1 -0
  148. package/es/plugins/hr/react/style.js +8 -0
  149. package/es/plugins/hr/react/type.d.ts +3 -0
  150. package/es/plugins/hr/react/type.js +1 -0
  151. package/es/plugins/image/command/index.d.ts +8 -0
  152. package/es/plugins/image/command/index.js +46 -0
  153. package/es/plugins/image/index.d.ts +3 -0
  154. package/es/plugins/image/index.js +3 -0
  155. package/es/plugins/image/node/basie-image-node.d.ts +44 -0
  156. package/es/plugins/image/node/basie-image-node.js +151 -0
  157. package/es/plugins/image/node/image-node.d.ts +26 -0
  158. package/es/plugins/image/node/image-node.js +176 -0
  159. package/es/plugins/image/plugin/index.d.ts +13 -0
  160. package/es/plugins/image/plugin/index.js +74 -0
  161. package/es/plugins/image/react/ReactImagePlugin.d.ts +4 -0
  162. package/es/plugins/image/react/ReactImagePlugin.js +48 -0
  163. package/es/plugins/image/react/components/BrokenImage.d.ts +3 -0
  164. package/es/plugins/image/react/components/BrokenImage.js +18 -0
  165. package/es/plugins/image/react/components/Image.d.ts +7 -0
  166. package/es/plugins/image/react/components/Image.js +71 -0
  167. package/es/plugins/image/react/components/LazyImage.d.ts +8 -0
  168. package/es/plugins/image/react/components/LazyImage.js +99 -0
  169. package/es/plugins/image/react/components/useSupenseImage.d.ts +2 -0
  170. package/es/plugins/image/react/components/useSupenseImage.js +24 -0
  171. package/es/plugins/image/react/index.d.ts +2 -0
  172. package/es/plugins/image/react/index.js +1 -0
  173. package/es/plugins/image/react/style.d.ts +12 -0
  174. package/es/plugins/image/react/style.js +17 -0
  175. package/es/plugins/image/react/type.d.ts +6 -0
  176. package/es/plugins/image/react/type.js +1 -0
  177. package/es/plugins/link/command/index.d.ts +6 -0
  178. package/es/plugins/link/command/index.js +20 -0
  179. package/es/plugins/link/index.d.ts +3 -0
  180. package/es/plugins/link/index.js +3 -0
  181. package/es/plugins/link/node/LinkNode.d.ts +126 -0
  182. package/es/plugins/link/node/LinkNode.js +721 -0
  183. package/es/plugins/link/plugin/index.d.ts +8 -0
  184. package/es/plugins/link/plugin/index.js +94 -0
  185. package/es/plugins/link/react/ReactLinkPlugin.d.ts +4 -0
  186. package/es/plugins/link/react/ReactLinkPlugin.js +168 -0
  187. package/es/plugins/link/react/components/LinkEdit.d.ts +7 -0
  188. package/es/plugins/link/react/components/LinkEdit.js +138 -0
  189. package/es/plugins/link/react/components/Toolbar.d.ts +7 -0
  190. package/es/plugins/link/react/components/Toolbar.js +63 -0
  191. package/es/plugins/link/react/index.d.ts +2 -0
  192. package/es/plugins/link/react/index.js +1 -0
  193. package/es/plugins/link/react/style.d.ts +5 -0
  194. package/es/plugins/link/react/style.js +12 -0
  195. package/es/plugins/link/react/type.d.ts +9 -0
  196. package/es/plugins/link/react/type.js +1 -0
  197. package/es/plugins/link/utils/index.d.ts +4 -0
  198. package/es/plugins/link/utils/index.js +37 -0
  199. package/es/plugins/list/command/index.d.ts +1 -0
  200. package/es/plugins/list/command/index.js +1 -0
  201. package/es/plugins/list/index.d.ts +3 -0
  202. package/es/plugins/list/index.js +3 -0
  203. package/es/plugins/list/plugin/index.d.ts +5 -0
  204. package/es/plugins/list/plugin/index.js +193 -0
  205. package/es/plugins/list/react/ReactListPlugin.d.ts +4 -0
  206. package/es/plugins/list/react/ReactListPlugin.js +29 -0
  207. package/es/plugins/list/react/index.d.ts +2 -0
  208. package/es/plugins/list/react/index.js +1 -0
  209. package/es/plugins/list/react/style.d.ts +1 -0
  210. package/es/plugins/list/react/style.js +7 -0
  211. package/es/plugins/list/react/type.d.ts +3 -0
  212. package/es/plugins/list/react/type.js +1 -0
  213. package/es/plugins/list/utils/index.d.ts +5 -0
  214. package/es/plugins/list/utils/index.js +88 -0
  215. package/es/plugins/markdown/data-source/markdown-data-source.d.ts +10 -0
  216. package/es/plugins/markdown/data-source/markdown-data-source.js +64 -0
  217. package/es/plugins/markdown/data-source/markdown-writer-context.d.ts +12 -0
  218. package/es/plugins/markdown/data-source/markdown-writer-context.js +51 -0
  219. package/es/plugins/markdown/index.d.ts +2 -0
  220. package/es/plugins/markdown/index.js +2 -0
  221. package/es/plugins/markdown/plugin/index.d.ts +4 -0
  222. package/es/plugins/markdown/plugin/index.js +122 -0
  223. package/es/plugins/markdown/service/shortcut.d.ts +139 -0
  224. package/es/plugins/markdown/service/shortcut.js +401 -0
  225. package/es/plugins/markdown/utils/index.d.ts +12 -0
  226. package/es/plugins/markdown/utils/index.js +61 -0
  227. package/es/plugins/mention/command/index.d.ts +6 -0
  228. package/es/plugins/mention/command/index.js +19 -0
  229. package/es/plugins/mention/index.d.ts +3 -0
  230. package/es/plugins/mention/index.js +3 -0
  231. package/es/plugins/mention/node/MentionNode.d.ts +26 -0
  232. package/es/plugins/mention/node/MentionNode.js +143 -0
  233. package/es/plugins/mention/plugin/index.d.ts +11 -0
  234. package/es/plugins/mention/plugin/index.js +61 -0
  235. package/es/plugins/mention/plugin/register.d.ts +2 -0
  236. package/es/plugins/mention/plugin/register.js +46 -0
  237. package/es/plugins/mention/react/ReactMentionPlugin.d.ts +4 -0
  238. package/es/plugins/mention/react/ReactMentionPlugin.js +42 -0
  239. package/es/plugins/mention/react/components/Mention.d.ts +9 -0
  240. package/es/plugins/mention/react/components/Mention.js +39 -0
  241. package/es/plugins/mention/react/index.d.ts +2 -0
  242. package/es/plugins/mention/react/index.js +1 -0
  243. package/es/plugins/mention/react/style.d.ts +3 -0
  244. package/es/plugins/mention/react/style.js +11 -0
  245. package/es/plugins/mention/react/type.d.ts +8 -0
  246. package/es/plugins/mention/react/type.js +1 -0
  247. package/es/plugins/slash/index.d.ts +3 -0
  248. package/es/plugins/slash/index.js +3 -0
  249. package/es/plugins/slash/plugin/index.d.ts +23 -0
  250. package/es/plugins/slash/plugin/index.js +132 -0
  251. package/es/plugins/slash/react/ReactSlashOption.d.ts +4 -0
  252. package/es/plugins/slash/react/ReactSlashOption.js +7 -0
  253. package/es/plugins/slash/react/ReactSlashPlugin.d.ts +4 -0
  254. package/es/plugins/slash/react/ReactSlashPlugin.js +228 -0
  255. package/es/plugins/slash/react/components/SlashMenu.d.ts +8 -0
  256. package/es/plugins/slash/react/components/SlashMenu.js +72 -0
  257. package/es/plugins/slash/react/index.d.ts +4 -0
  258. package/es/plugins/slash/react/index.js +3 -0
  259. package/es/plugins/slash/react/style.d.ts +1 -0
  260. package/es/plugins/slash/react/style.js +9 -0
  261. package/es/plugins/slash/react/type.d.ts +82 -0
  262. package/es/plugins/slash/react/type.js +1 -0
  263. package/es/plugins/slash/react/utils.d.ts +5 -0
  264. package/es/plugins/slash/react/utils.js +20 -0
  265. package/es/plugins/slash/service/i-slash-service.d.ts +38 -0
  266. package/es/plugins/slash/service/i-slash-service.js +64 -0
  267. package/es/plugins/slash/utils/utils.d.ts +38 -0
  268. package/es/plugins/slash/utils/utils.js +192 -0
  269. package/es/plugins/table/command/index.d.ts +13 -0
  270. package/es/plugins/table/command/index.js +73 -0
  271. package/es/plugins/table/index.d.ts +3 -0
  272. package/es/plugins/table/index.js +3 -0
  273. package/es/plugins/table/node/index.d.ts +2 -0
  274. package/es/plugins/table/node/index.js +16 -0
  275. package/es/plugins/table/plugin/index.d.ts +5 -0
  276. package/es/plugins/table/plugin/index.js +85 -0
  277. package/es/plugins/table/react/TableActionMenu/index.d.ts +8 -0
  278. package/es/plugins/table/react/TableActionMenu/index.js +481 -0
  279. package/es/plugins/table/react/TableActionMenu/style.d.ts +1 -0
  280. package/es/plugins/table/react/TableActionMenu/style.js +7 -0
  281. package/es/plugins/table/react/TableActionMenu/utils.d.ts +9 -0
  282. package/es/plugins/table/react/TableActionMenu/utils.js +49 -0
  283. package/es/plugins/table/react/TableHoverActions/index.d.ts +7 -0
  284. package/es/plugins/table/react/TableHoverActions/index.js +268 -0
  285. package/es/plugins/table/react/TableHoverActions/style.d.ts +5 -0
  286. package/es/plugins/table/react/TableHoverActions/style.js +11 -0
  287. package/es/plugins/table/react/TableHoverActions/utils.d.ts +8 -0
  288. package/es/plugins/table/react/TableHoverActions/utils.js +43 -0
  289. package/es/plugins/table/react/TableResize/index.d.ts +10 -0
  290. package/es/plugins/table/react/TableResize/index.js +378 -0
  291. package/es/plugins/table/react/TableResize/style.d.ts +3 -0
  292. package/es/plugins/table/react/TableResize/style.js +10 -0
  293. package/es/plugins/table/react/TableResize/utils.d.ts +4 -0
  294. package/es/plugins/table/react/TableResize/utils.js +40 -0
  295. package/es/plugins/table/react/hooks.d.ts +1 -0
  296. package/es/plugins/table/react/hooks.js +22 -0
  297. package/es/plugins/table/react/index.d.ts +3 -0
  298. package/es/plugins/table/react/index.js +77 -0
  299. package/es/plugins/table/react/style.d.ts +1 -0
  300. package/es/plugins/table/react/style.js +8 -0
  301. package/es/plugins/table/react/type.d.ts +5 -0
  302. package/es/plugins/table/react/type.js +1 -0
  303. package/es/plugins/table/utils/index.d.ts +8 -0
  304. package/es/plugins/table/utils/index.js +83 -0
  305. package/es/plugins/upload/index.d.ts +3 -0
  306. package/es/plugins/upload/index.js +3 -0
  307. package/es/plugins/upload/plugin/index.d.ts +4 -0
  308. package/es/plugins/upload/plugin/index.js +82 -0
  309. package/es/plugins/upload/service/i-upload-service.d.ts +15 -0
  310. package/es/plugins/upload/service/i-upload-service.js +115 -0
  311. package/es/plugins/upload/utils/index.d.ts +1 -0
  312. package/es/plugins/upload/utils/index.js +20 -0
  313. package/es/react/ChatInput/ChatInput.d.ts +4 -0
  314. package/es/react/ChatInput/ChatInput.js +41 -0
  315. package/es/react/ChatInput/index.d.ts +2 -0
  316. package/es/react/ChatInput/index.js +2 -0
  317. package/es/react/ChatInput/style.d.ts +4 -0
  318. package/es/react/ChatInput/style.js +11 -0
  319. package/es/react/ChatInput/type.d.ts +10 -0
  320. package/es/react/ChatInput/type.js +1 -0
  321. package/es/react/ChatInputActionBar/ChatInputActionBar.d.ts +4 -0
  322. package/es/react/ChatInputActionBar/ChatInputActionBar.js +27 -0
  323. package/es/react/ChatInputActionBar/index.d.ts +2 -0
  324. package/es/react/ChatInputActionBar/index.js +2 -0
  325. package/es/react/ChatInputActionBar/style.d.ts +3 -0
  326. package/es/react/ChatInputActionBar/style.js +9 -0
  327. package/es/react/ChatInputActionBar/type.d.ts +7 -0
  328. package/es/react/ChatInputActionBar/type.js +1 -0
  329. package/es/react/ChatInputActions/ChatInputActions.d.ts +4 -0
  330. package/es/react/ChatInputActions/ChatInputActions.js +187 -0
  331. package/es/react/ChatInputActions/components/ChatInputActionsCollapse.d.ts +4 -0
  332. package/es/react/ChatInputActions/components/ChatInputActionsCollapse.js +97 -0
  333. package/es/react/ChatInputActions/index.d.ts +2 -0
  334. package/es/react/ChatInputActions/index.js +1 -0
  335. package/es/react/ChatInputActions/style.d.ts +4 -0
  336. package/es/react/ChatInputActions/style.js +10 -0
  337. package/es/react/ChatInputActions/type.d.ts +38 -0
  338. package/es/react/ChatInputActions/type.js +1 -0
  339. package/es/react/CodeLanguageSelect/CodeLanguageSelect.d.ts +4 -0
  340. package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +96 -0
  341. package/es/react/CodeLanguageSelect/index.d.ts +2 -0
  342. package/es/react/CodeLanguageSelect/index.js +2 -0
  343. package/es/react/CodeLanguageSelect/style.d.ts +3 -0
  344. package/es/react/CodeLanguageSelect/style.js +9 -0
  345. package/es/react/CodeLanguageSelect/type.d.ts +2 -0
  346. package/es/react/CodeLanguageSelect/type.js +1 -0
  347. package/es/react/Editor/Editor.d.ts +4 -0
  348. package/es/react/Editor/Editor.js +78 -0
  349. package/es/react/Editor/index.d.ts +14 -0
  350. package/es/react/Editor/index.js +10 -0
  351. package/es/react/Editor/type.d.ts +24 -0
  352. package/es/react/Editor/type.js +1 -0
  353. package/es/react/Editor/useEditor.d.ts +3 -0
  354. package/es/react/Editor/useEditor.js +4 -0
  355. package/es/react/Editor/utils.d.ts +2 -0
  356. package/es/react/Editor/utils.js +3 -0
  357. package/es/react/EditorProvider/index.d.ts +20 -0
  358. package/es/react/EditorProvider/index.js +25 -0
  359. package/es/react/SendButton/SendButton.d.ts +4 -0
  360. package/es/react/SendButton/SendButton.js +77 -0
  361. package/es/react/SendButton/components/SendIcon.d.ts +6 -0
  362. package/es/react/SendButton/components/SendIcon.js +32 -0
  363. package/es/react/SendButton/components/StopIcon.d.ts +6 -0
  364. package/es/react/SendButton/components/StopIcon.js +61 -0
  365. package/es/react/SendButton/index.d.ts +2 -0
  366. package/es/react/SendButton/index.js +2 -0
  367. package/es/react/SendButton/style.d.ts +6 -0
  368. package/es/react/SendButton/style.js +15 -0
  369. package/es/react/SendButton/type.d.ts +6 -0
  370. package/es/react/SendButton/type.js +1 -0
  371. package/es/react/SlashMenu/SlashMenu.d.ts +4 -0
  372. package/es/react/SlashMenu/SlashMenu.js +68 -0
  373. package/es/react/SlashMenu/index.d.ts +2 -0
  374. package/es/react/SlashMenu/index.js +2 -0
  375. package/es/react/SlashMenu/style.d.ts +4 -0
  376. package/es/react/SlashMenu/style.js +11 -0
  377. package/es/react/SlashMenu/type.d.ts +8 -0
  378. package/es/react/SlashMenu/type.js +1 -0
  379. package/es/react/index.d.ts +8 -0
  380. package/es/react/index.js +8 -0
  381. package/es/types/global.d.ts +20 -0
  382. package/es/types/index.d.ts +2 -0
  383. package/es/types/index.js +2 -0
  384. package/es/types/kernel.d.ts +180 -0
  385. package/es/types/kernel.js +1 -0
  386. package/es/types/locale.d.ts +10 -0
  387. package/es/types/locale.js +1 -0
  388. package/package.json +66 -0
  389. package/patches/lexical+0.33.1.patch +88 -0
  390. package/react.d.ts +1 -0
  391. package/react.js +1 -0
  392. package/scripts/patch-lexical-package-json.js +20 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Alec Larson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,635 @@
1
+ <div align="center"><a name="readme-top"></a>
2
+
3
+ <img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
4
+ <img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
5
+ <img height="120" src="https://registry.npmmirror.com/@lobehub/fluent-emoji-3d/latest/files/assets/2712-fe0f.webp">
6
+
7
+ <h1>LobeHub Editor</h1>
8
+
9
+ A modern, extensible rich text editor built on Meta's Lexical framework with dual-architecture design, featuring both a powerful kernel and React integration. Optimized for AI applications and chat interfaces.
10
+
11
+ [![][npm-release-shield]][npm-release-link]
12
+ [![][github-releasedate-shield]][github-releasedate-link]
13
+ [![][github-action-test-shield]][github-action-test-link]
14
+ [![][github-action-release-shield]][github-action-release-link]<br/>
15
+ [![][github-contributors-shield]][github-contributors-link]
16
+ [![][github-forks-shield]][github-forks-link]
17
+ [![][github-stars-shield]][github-stars-link]
18
+ [![][github-issues-shield]][github-issues-link]
19
+ [![][github-license-shield]][github-license-link]
20
+
21
+ [Changelog](./CHANGELOG.md) Β· [Report Bug][github-issues-link] Β· [Request Feature][github-issues-link]
22
+
23
+ ![](https://github.com/user-attachments/assets/98c9a810-1c7d-4c33-acd7-ae9d4c0695da)
24
+
25
+ </div>
26
+
27
+ <details>
28
+ <summary><kbd>Table of contents</kbd></summary>
29
+
30
+ #### TOC
31
+
32
+ - [✨ Features](#-features)
33
+ - [πŸ“¦ Installation](#-installation)
34
+ - [πŸš€ Quick Start](#-quick-start)
35
+ - [Basic Editor](#basic-editor)
36
+ - [Advanced Usage with Plugins](#advanced-usage-with-plugins)
37
+ - [Chat Input Component](#chat-input-component)
38
+ - [Editor Kernel API](#editor-kernel-api)
39
+ - [πŸ”Œ Available Plugins](#-available-plugins)
40
+ - [Core Plugins](#core-plugins)
41
+ - [Content Plugins](#content-plugins)
42
+ - [Plugin Architecture](#plugin-architecture)
43
+ - [Plugin Features](#plugin-features)
44
+ - [πŸ“– API Reference](#-api-reference)
45
+ - [Editor Kernel](#editor-kernel)
46
+ - [Plugin System](#plugin-system)
47
+ - [πŸ› οΈ Development](#️-development)
48
+ - [Setup](#setup)
49
+ - [Available Scripts](#available-scripts)
50
+ - [Project Architecture](#project-architecture)
51
+ - [🀝 Contributing](#-contributing)
52
+ - [πŸ”— Links](#-links)
53
+ - [More Products](#more-products)
54
+ - [Design Resources](#design-resources)
55
+ - [Development Resources](#development-resources)
56
+
57
+ ####
58
+
59
+ </details>
60
+
61
+ ## ✨ Features
62
+
63
+ - 🎯 **Dual Architecture** - Both kernel-based API and React components for maximum flexibility
64
+ - βš›οΈ **React-First** - Built for React 19+ with modern hooks and patterns
65
+ - πŸ”Œ **Rich Plugin Ecosystem** - 10+ built-in plugins for comprehensive content editing
66
+ - πŸ’¬ **Chat Interface Ready** - Pre-built chat input components with mention support
67
+ - ⌨️ **Slash Commands** - Intuitive `/` and `@` triggered menus for quick content insertion
68
+ - πŸ“ **Multiple Export Formats** - JSON, Markdown, and plain text export capabilities
69
+ - 🎨 **Customizable UI** - Antd-styled components with flexible theming
70
+ - πŸ”— **File & Media Support** - Native support for images, files, tables, and more
71
+ - 🎯 **TypeScript Native** - Built with TypeScript for excellent developer experience
72
+ - πŸ“± **Modern Build System** - Optimized with Vite, Dumi docs, and comprehensive testing
73
+
74
+ ## πŸ“¦ Installation
75
+
76
+ To install `@lobehub/editor`, run the following command:
77
+
78
+ [![][bun-shield]][bun-link]
79
+
80
+ ```bash
81
+ $ bun add @lobehub/editor
82
+ ```
83
+
84
+ ```bash
85
+ $ pnpm add @lobehub/editor
86
+ ```
87
+
88
+ <div align="right">
89
+
90
+ [![][back-to-top]](#readme-top)
91
+
92
+ </div>
93
+
94
+ ## πŸš€ Quick Start
95
+
96
+ ### Basic Editor
97
+
98
+ The simplest way to get started with a fully-featured editor:
99
+
100
+ ```tsx
101
+ import {
102
+ ReactCodeblockPlugin,
103
+ ReactImagePlugin,
104
+ ReactLinkPlugin,
105
+ ReactListPlugin,
106
+ } from '@lobehub/editor';
107
+ import { Editor } from '@lobehub/editor/react';
108
+
109
+ export default function MyEditor() {
110
+ const editorRef = Editor.useEditor();
111
+
112
+ return (
113
+ <Editor
114
+ placeholder="Start typing..."
115
+ editorRef={editorRef}
116
+ plugins={[ReactListPlugin, ReactLinkPlugin, ReactImagePlugin, ReactCodeblockPlugin]}
117
+ slashOption={{
118
+ items: [
119
+ {
120
+ key: 'h1',
121
+ label: 'Heading 1',
122
+ onSelect: (editor) => {
123
+ editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h1' });
124
+ },
125
+ },
126
+ // More slash commands...
127
+ ],
128
+ }}
129
+ onChange={(editor) => {
130
+ // Handle content changes
131
+ const markdown = editor.getDocument('markdown');
132
+ const json = editor.getDocument('json');
133
+ }}
134
+ />
135
+ );
136
+ }
137
+ ```
138
+
139
+ ### Advanced Usage with Plugins
140
+
141
+ Add more functionality with built-in plugins:
142
+
143
+ ```tsx
144
+ import {
145
+ INSERT_FILE_COMMAND,
146
+ INSERT_TABLE_COMMAND,
147
+ ReactFilePlugin,
148
+ ReactHRPlugin,
149
+ ReactTablePlugin,
150
+ } from '@lobehub/editor';
151
+ import { Editor } from '@lobehub/editor/react';
152
+
153
+ export default function AdvancedEditor() {
154
+ const editorRef = Editor.useEditor();
155
+
156
+ return (
157
+ <Editor
158
+ editorRef={editorRef}
159
+ plugins={[
160
+ ReactTablePlugin,
161
+ ReactHRPlugin,
162
+ Editor.withProps(ReactFilePlugin, {
163
+ handleUpload: async (file) => {
164
+ // Handle file upload
165
+ return { url: await uploadFile(file) };
166
+ },
167
+ }),
168
+ ]}
169
+ mentionOption={{
170
+ items: async (search) => [
171
+ {
172
+ key: 'user1',
173
+ label: 'John Doe',
174
+ onSelect: (editor) => {
175
+ editor.dispatchCommand(INSERT_MENTION_COMMAND, {
176
+ label: 'John Doe',
177
+ extra: { userId: 1 },
178
+ });
179
+ },
180
+ },
181
+ ],
182
+ }}
183
+ />
184
+ );
185
+ }
186
+ ```
187
+
188
+ ### Chat Input Component
189
+
190
+ Pre-built component optimized for chat interfaces:
191
+
192
+ ```tsx
193
+ import { ChatInput } from '@lobehub/editor/react';
194
+
195
+ export default function ChatApp() {
196
+ return (
197
+ <ChatInput
198
+ placeholder="Type a message..."
199
+ onSend={(content) => {
200
+ // Handle message send
201
+ console.log('Message:', content);
202
+ }}
203
+ enabledFeatures={['mention', 'upload', 'codeblock']}
204
+ />
205
+ );
206
+ }
207
+ ```
208
+
209
+ ### Editor Kernel API
210
+
211
+ For advanced use cases, access the underlying kernel directly:
212
+
213
+ ```typescript
214
+ import { IEditor, createEditor } from '@lobehub/editor';
215
+
216
+ // Create editor instance
217
+ const editor: IEditor = createEditor();
218
+
219
+ // Register plugins
220
+ editor.registerPlugin(SomePlugin, { config: 'value' });
221
+
222
+ // Interact with content
223
+ editor.setDocument('text', 'Hello world');
224
+ const content = editor.getDocument('json');
225
+
226
+ // Listen to events
227
+ editor.on('content-changed', (newContent) => {
228
+ console.log('Content updated:', newContent);
229
+ });
230
+
231
+ // Execute commands
232
+ editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h2' });
233
+ ```
234
+
235
+ <div align="right">
236
+
237
+ [![][back-to-top]](#readme-top)
238
+
239
+ </div>
240
+
241
+ ## πŸ”Œ Available Plugins
242
+
243
+ ### Core Plugins
244
+
245
+ | Plugin | Description | Features |
246
+ | ------------------ | ----------------------------- | --------------------------------------------------------------- |
247
+ | **CommonPlugin** | Foundation editor components | ReactEditor, ReactEditorContent, ReactPlainText, base utilities |
248
+ | **MarkdownPlugin** | Markdown processing engine | Shortcuts, transformers, serialization, custom writers |
249
+ | **UploadPlugin** | File upload management system | Priority handlers, drag-drop, multi-source uploads |
250
+
251
+ ### Content Plugins
252
+
253
+ | Plugin | Description | Features |
254
+ | ------------------------ | ------------------------- | --------------------------------------------------------------- |
255
+ | **ReactSlashPlugin** | Slash command menu system | `/` and `@` triggered menus, customizable items, async search |
256
+ | **ReactMentionPlugin** | User mention support | `@username` mentions, custom markdown output, async user search |
257
+ | **ReactImagePlugin** | Image handling | Upload, display, drag & drop, captions, resizing |
258
+ | **ReactCodeblockPlugin** | Code syntax highlighting | Shiki-powered, 100+ languages, custom themes, color schemes |
259
+ | **ReactListPlugin** | List management | Ordered/unordered lists, nested lists, keyboard shortcuts |
260
+ | **ReactLinkPlugin** | Link management | Auto-detection, validation, previews, custom styling |
261
+ | **ReactTablePlugin** | Table support | Insert tables, edit cells, add/remove rows/columns, i18n |
262
+ | **ReactHRPlugin** | Horizontal rules | Divider insertion, custom styling, markdown shortcuts |
263
+ | **ReactFilePlugin** | File attachments | File upload, status tracking, validation, drag-drop |
264
+
265
+ ### Plugin Architecture
266
+
267
+ All plugins follow a **dual-architecture design**:
268
+
269
+ #### 🧠 **Kernel Layer** (Framework-agnostic)
270
+
271
+ - **Plugin Interface**: Standardized plugin system with lifecycle management
272
+ - **Service Container**: Centralized service registration and dependency injection
273
+ - **Command System**: Event-driven command pattern for editor operations
274
+ - **Node System**: Custom node types with serialization and transformation
275
+ - **Data Sources**: Content management and format conversion (JSON, Markdown, Text)
276
+
277
+ #### βš›οΈ **React Layer** (React-specific)
278
+
279
+ - **React Components**: High-level components for easy integration
280
+ - **Hook Integration**: Custom hooks for editor state and functionality
281
+ - **Event Handling**: React-friendly event system and callbacks
282
+ - **UI Components**: Pre-built UI elements with theming support
283
+
284
+ ### Plugin Features
285
+
286
+ - βœ… **Fully configurable** with TypeScript-typed options
287
+ - βœ… **Composable** - use any combination together
288
+ - βœ… **Extensible** - create custom plugins using the same API
289
+ - βœ… **Event-driven** - react to user interactions and content changes
290
+ - βœ… **Service-oriented** - modular architecture with dependency injection
291
+ - βœ… **Internationalization** - Built-in i18n support where applicable
292
+ - βœ… **Markdown integration** - Shortcuts, import/export, custom transformers
293
+ - βœ… **Theme system** - Customizable styling and appearance
294
+ - βœ… **Command pattern** - Programmatic control and automation
295
+
296
+ ## πŸ“– API Reference
297
+
298
+ #### Utility Hooks
299
+
300
+ ```tsx
301
+ // Get editor reference
302
+ const editorRef = Editor.useEditor();
303
+
304
+ // Helper for plugin configuration
305
+ const PluginWithConfig = Editor.withProps(ReactFilePlugin, {
306
+ handleUpload: async (file) => ({ url: 'uploaded-url' }),
307
+ });
308
+ ```
309
+
310
+ ### Editor Kernel
311
+
312
+ #### `createEditor(): IEditor`
313
+
314
+ Create a new editor kernel instance:
315
+
316
+ ```typescript
317
+ const editor = createEditor();
318
+ ```
319
+
320
+ #### `IEditor` Interface
321
+
322
+ Core editor methods:
323
+
324
+ ```typescript
325
+ interface IEditor {
326
+ // Content management
327
+ setDocument(type: string, content: any): void;
328
+ getDocument(type: string): any;
329
+
330
+ // Plugin system
331
+ registerPlugin<T>(plugin: Constructor<T>, config?: T): IEditor;
332
+ registerPlugins(plugins: Plugin[]): IEditor;
333
+
334
+ // Commands
335
+ dispatchCommand<T>(command: LexicalCommand<T>, payload: T): boolean;
336
+
337
+ // Events
338
+ on<T>(event: string, listener: (data: T) => void): this;
339
+ off<T>(event: string, listener: (data: T) => void): this;
340
+
341
+ // Lifecycle
342
+ focus(): void;
343
+ blur(): void;
344
+ destroy(): void;
345
+
346
+ // Access
347
+ getLexicalEditor(): LexicalEditor | null;
348
+ getRootElement(): HTMLElement | null;
349
+ requireService<T>(serviceId: ServiceID<T>): T | null;
350
+ }
351
+ ```
352
+
353
+ ### Plugin System
354
+
355
+ #### Creating Custom Plugins
356
+
357
+ ```typescript
358
+ import { IEditorKernel, IEditorPlugin } from '@lobehub/editor';
359
+
360
+ class MyCustomPlugin implements IEditorPlugin {
361
+ constructor(private config: MyPluginConfig) {}
362
+
363
+ initialize(kernel: IEditorKernel) {
364
+ // Register nodes, commands, transforms, etc.
365
+ kernel.registerNode(MyCustomNode);
366
+ kernel.registerCommand(MY_COMMAND, this.handleCommand);
367
+ }
368
+
369
+ destroy() {
370
+ // Cleanup
371
+ }
372
+ }
373
+ ```
374
+
375
+ #### Available Commands
376
+
377
+ Common commands you can dispatch:
378
+
379
+ ```typescript
380
+ // Content insertion
381
+ INSERT_HEADING_COMMAND; // { tag: 'h1' | 'h2' | 'h3' }
382
+ INSERT_LINK_COMMAND; // { url: string, text?: string }
383
+ INSERT_IMAGE_COMMAND; // { src: string, alt?: string }
384
+ INSERT_TABLE_COMMAND; // { rows: number, columns: number }
385
+ INSERT_MENTION_COMMAND; // { label: string, extra?: any }
386
+ INSERT_FILE_COMMAND; // { file: File }
387
+ INSERT_HORIZONTAL_RULE_COMMAND;
388
+
389
+ // Text formatting
390
+ FORMAT_TEXT_COMMAND; // { format: 'bold' | 'italic' | 'underline' }
391
+ CLEAR_FORMAT_COMMAND;
392
+ ```
393
+
394
+ <div align="right">
395
+
396
+ [![][back-to-top]](#readme-top)
397
+
398
+ </div>
399
+
400
+ ## πŸ› οΈ Development
401
+
402
+ ### Setup
403
+
404
+ You can use Github Codespaces for online development:
405
+
406
+ [![][github-codespace-shield]][github-codespace-link]
407
+
408
+ Or clone it for local development:
409
+
410
+ [![][bun-shield]][bun-link]
411
+
412
+ ```bash
413
+ $ git clone https://github.com/lobehub/lobe-editor.git
414
+ $ cd lobe-editor
415
+ $ pnpm install
416
+ $ pnpm run dev
417
+ ```
418
+
419
+ This will start the Dumi documentation server with live playground at `http://localhost:8000`.
420
+
421
+ ### Available Scripts
422
+
423
+ | Script | Description |
424
+ | -------------------- | --------------------------------------------- |
425
+ | `pnpm dev` | Start Dumi development server with playground |
426
+ | `pnpm build` | Build library and generate type definitions |
427
+ | `pnpm test` | Run tests with Vitest |
428
+ | `pnpm test:coverage` | Run tests with coverage report |
429
+ | `pnpm lint` | Lint and fix code with ESLint |
430
+ | `pnpm type-check` | Type check with TypeScript |
431
+ | `pnpm ci` | Run all CI checks (lint, type-check, test) |
432
+ | `pnpm docs:build` | Build documentation for production |
433
+ | `pnpm release` | Publish new version with semantic-release |
434
+
435
+ ### Project Architecture
436
+
437
+ ```
438
+ lobe-editor/
439
+ β”œβ”€β”€ src/
440
+ β”‚ β”œβ”€β”€ editor-kernel/ # 🧠 Core editor logic
441
+ β”‚ β”‚ β”œβ”€β”€ kernel.ts # Main editor class with plugin system
442
+ β”‚ β”‚ β”œβ”€β”€ data-source.ts # Content management (JSON/Markdown/Text)
443
+ β”‚ β”‚ β”œβ”€β”€ service.ts # Service container and dependency injection
444
+ β”‚ β”‚ β”œβ”€β”€ plugin/ # Plugin base classes and interfaces
445
+ β”‚ β”‚ β”œβ”€β”€ react/ # React integration layer
446
+ β”‚ β”‚ └── types.ts # TypeScript interfaces
447
+ β”‚ β”‚
448
+ β”‚ β”œβ”€β”€ plugins/ # πŸ”Œ Feature plugins
449
+ β”‚ β”‚ β”œβ”€β”€ common/ # πŸ—οΈ Foundation components
450
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Base editor plugin
451
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactEditor, ReactEditorContent, ReactPlainText
452
+ β”‚ β”‚ β”‚ β”œβ”€β”€ data-source/ # Content data sources
453
+ β”‚ β”‚ β”‚ └── utils/ # Common utilities
454
+ β”‚ β”‚ β”‚
455
+ β”‚ β”‚ β”œβ”€β”€ markdown/ # πŸ“ Markdown processing engine
456
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Markdown transformation plugin
457
+ β”‚ β”‚ β”‚ β”œβ”€β”€ service/ # Markdown shortcut service
458
+ β”‚ β”‚ β”‚ β”œβ”€β”€ data-source/ # Markdown serialization
459
+ β”‚ β”‚ β”‚ └── utils/ # Transformer utilities
460
+ β”‚ β”‚ β”‚
461
+ β”‚ β”‚ β”œβ”€β”€ upload/ # πŸ“€ Upload management system
462
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Upload handling plugin
463
+ β”‚ β”‚ β”‚ β”œβ”€β”€ service/ # Upload service with priority system
464
+ β”‚ β”‚ β”‚ └── utils/ # Upload utilities
465
+ β”‚ β”‚ β”‚
466
+ β”‚ β”‚ β”œβ”€β”€ slash/ # ⚑ Slash commands (/, @)
467
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Slash detection plugin
468
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactSlashPlugin, ReactSlashOption
469
+ β”‚ β”‚ β”‚ β”œβ”€β”€ service/ # Slash service with fuzzy search
470
+ β”‚ β”‚ β”‚ └── utils/ # Search and trigger utilities
471
+ β”‚ β”‚ β”‚
472
+ β”‚ β”‚ β”œβ”€β”€ mention/ # πŸ‘€ @mention system
473
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Mention plugin with decorators
474
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactMentionPlugin
475
+ β”‚ β”‚ β”‚ β”œβ”€β”€ command/ # INSERT_MENTION_COMMAND
476
+ β”‚ β”‚ β”‚ └── node/ # MentionNode with serialization
477
+ β”‚ β”‚ β”‚
478
+ β”‚ β”‚ β”œβ”€β”€ codeblock/ # 🎨 Syntax highlighting
479
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Codeblock plugin with Shiki
480
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactCodeblockPlugin
481
+ β”‚ β”‚ β”‚ β”œβ”€β”€ command/ # Language and color commands
482
+ β”‚ β”‚ β”‚ └── utils/ # Language detection
483
+ β”‚ β”‚ β”‚
484
+ β”‚ β”‚ β”œβ”€β”€ image/ # πŸ–ΌοΈ Image upload & display
485
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Image plugin with captions
486
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactImagePlugin
487
+ β”‚ β”‚ β”‚ β”œβ”€β”€ command/ # INSERT_IMAGE_COMMAND
488
+ β”‚ β”‚ β”‚ └── node/ # BaseImageNode, ImageNode
489
+ β”‚ β”‚ β”‚
490
+ β”‚ β”‚ β”œβ”€β”€ table/ # πŸ“Š Table support
491
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Table plugin with i18n
492
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactTablePlugin
493
+ β”‚ β”‚ β”‚ β”œβ”€β”€ command/ # Table manipulation commands
494
+ β”‚ β”‚ β”‚ β”œβ”€β”€ node/ # Enhanced TableNode
495
+ β”‚ β”‚ β”‚ └── utils/ # Table operations
496
+ β”‚ β”‚ β”‚
497
+ β”‚ β”‚ β”œβ”€β”€ file/ # πŸ“Ž File attachments
498
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # File plugin with status tracking
499
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactFilePlugin
500
+ β”‚ β”‚ β”‚ β”œβ”€β”€ command/ # INSERT_FILE_COMMAND
501
+ β”‚ β”‚ β”‚ β”œβ”€β”€ node/ # FileNode with metadata
502
+ β”‚ β”‚ β”‚ └── utils/ # File operations
503
+ β”‚ β”‚ β”‚
504
+ β”‚ β”‚ β”œβ”€β”€ link/ # πŸ”— Link management
505
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # Link plugin with validation
506
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactLinkPlugin
507
+ β”‚ β”‚ β”‚ β”œβ”€β”€ command/ # Link commands
508
+ β”‚ β”‚ β”‚ └── utils/ # URL validation and detection
509
+ β”‚ β”‚ β”‚
510
+ β”‚ β”‚ β”œβ”€β”€ list/ # πŸ“‹ Lists (ordered/unordered)
511
+ β”‚ β”‚ β”‚ β”œβ”€β”€ plugin/ # List plugin with nesting
512
+ β”‚ β”‚ β”‚ β”œβ”€β”€ react/ # ReactListPlugin
513
+ β”‚ β”‚ β”‚ β”œβ”€β”€ command/ # List manipulation commands
514
+ β”‚ β”‚ β”‚ └── utils/ # List operations
515
+ β”‚ β”‚ β”‚
516
+ β”‚ β”‚ └── hr/ # βž– Horizontal rules
517
+ β”‚ β”‚ β”œβ”€β”€ plugin/ # HR plugin with styling
518
+ β”‚ β”‚ β”œβ”€β”€ react/ # ReactHRPlugin
519
+ β”‚ β”‚ β”œβ”€β”€ command/ # HR insertion commands
520
+ β”‚ β”‚ └── node/ # HorizontalRuleNode
521
+ β”‚ β”‚
522
+ β”‚ β”œβ”€β”€ react/ # βš›οΈ High-level React components
523
+ β”‚ β”‚ β”œβ”€β”€ Editor/ # Main Editor component with plugins
524
+ β”‚ β”‚ β”œβ”€β”€ ChatInput/ # Chat interface component
525
+ β”‚ β”‚ β”œβ”€β”€ ChatInputActions/ # Chat action buttons
526
+ β”‚ β”‚ β”œβ”€β”€ ChatInputActionBar/ # Action bar layout
527
+ β”‚ β”‚ β”œβ”€β”€ SendButton/ # Send button with states
528
+ β”‚ β”‚ └── CodeLanguageSelect/ # Code language selector
529
+ β”‚ β”‚
530
+ β”‚ └── index.ts # Public API exports
531
+ β”‚
532
+ β”œβ”€β”€ docs/ # πŸ“š Documentation source
533
+ β”œβ”€β”€ tests/ # πŸ§ͺ Test files
534
+ β”œβ”€β”€ vitest.config.ts # Test configuration
535
+ └── .dumi/ # Dumi doc build cache
536
+ ```
537
+
538
+ The architecture follows a **dual-layer design**:
539
+
540
+ 1. **Kernel Layer** (`editor-kernel/`) - Framework-agnostic core with plugin system
541
+ 2. **React Layer** (`react/` + `plugins/*/react/`) - React-specific implementations
542
+
543
+ Each plugin follows a consistent structure:
544
+
545
+ - **`plugin/`** - Core plugin logic and node definitions
546
+ - **`react/`** - React components and hooks (if applicable)
547
+ - **`command/`** - Editor commands and handlers
548
+ - **`service/`** - Services and business logic
549
+ - **`node/`** - Custom Lexical nodes
550
+ - **`utils/`** - Utility functions and helpers
551
+
552
+ This allows for maximum flexibility - you can use just the kernel for custom integrations, or the React components for rapid development.
553
+
554
+ <div align="right">
555
+
556
+ [![][back-to-top]](#readme-top)
557
+
558
+ </div>
559
+
560
+ ## 🀝 Contributing
561
+
562
+ Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub [Issues][github-issues-link] to get stuck in to show us what you're made of.
563
+
564
+ [![][pr-welcome-shield]][pr-welcome-link]
565
+
566
+ [![][github-contrib-shield]][github-contrib-link]
567
+
568
+ <div align="right">
569
+
570
+ [![][back-to-top]](#readme-top)
571
+
572
+ </div>
573
+
574
+ ## πŸ”— Links
575
+
576
+ ### More Products
577
+
578
+ - **[🀯 Lobe Chat](https://github.com/lobehub/lobe-chat)** - An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application.
579
+ - **[πŸ…°οΈ Lobe Theme](https://github.com/lobehub/sd-webui-lobe-theme)** - The modern theme for stable diffusion webui, exquisite interface design, highly customizable UI, and efficiency boosting features.
580
+ - **[🧸 Lobe Vidol](https://github.com/lobehub/lobe-vidol)** - Experience the magic of virtual idol creation with Lobe Vidol, enjoy the elegance of our Exquisite UI Design, dance along using MMD Dance Support, and engage in Smooth Conversations.
581
+
582
+ ### Design Resources
583
+
584
+ - **[🍭 Lobe UI](https://ui.lobehub.com)** - An open-source UI component library for building AIGC web apps.
585
+ - **[πŸ₯¨ Lobe Icons](https://lobehub.com/icons)** - Popular AI / LLM Model Brand SVG Logo and Icon Collection.
586
+ - **[πŸ“Š Lobe Charts](https://charts.lobehub.com)** - React modern charts components built on recharts
587
+
588
+ ### Development Resources
589
+
590
+ - **[🎀 Lobe TTS](https://tts.lobehub.com)** - A high-quality & reliable TTS/STT library for Server and Browser
591
+ - **[🌏 Lobe i18n](https://github.com/lobehub/lobe-cli-toolbox/blob/master/packages/lobe-i18n)** - Automation ai tool for the i18n (internationalization) translation process.
592
+
593
+ [More Resources](https://lobehub.com/resources)
594
+
595
+ <div align="right">
596
+
597
+ [![][back-to-top]](#readme-top)
598
+
599
+ </div>
600
+
601
+ ---
602
+
603
+ #### πŸ“ License
604
+
605
+ Copyright Β© 2025 [LobeHub][profile-link]. <br />
606
+ This project is [MIT](./LICENSE) licensed.
607
+
608
+ [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-black?style=flat-square
609
+ [bun-link]: https://bun.sh
610
+ [bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
611
+ [github-action-release-link]: https://github.com/lobehub/lobe-editor/actions/workflows/release.yml
612
+ [github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-editor/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
613
+ [github-action-test-link]: https://github.com/lobehub/lobe-editor/actions/workflows/test.yml
614
+ [github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-editor/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
615
+ [github-codespace-link]: https://codespaces.new/lobehub/lobe-editor
616
+ [github-codespace-shield]: https://github.com/codespaces/badge.svg
617
+ [github-contrib-link]: https://github.com/lobehub/lobe-editor/graphs/contributors
618
+ [github-contrib-shield]: https://contrib.rocks/image?repo=lobehub%2Flobe-editor
619
+ [github-contributors-link]: https://github.com/lobehub/lobe-editor/graphs/contributors
620
+ [github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-editor?color=c4f042&labelColor=black&style=flat-square
621
+ [github-forks-link]: https://github.com/lobehub/lobe-editor/network/members
622
+ [github-forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-editor?color=8ae8ff&labelColor=black&style=flat-square
623
+ [github-issues-link]: https://github.com/lobehub/lobe-editor/issues
624
+ [github-issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-editor?color=ff80eb&labelColor=black&style=flat-square
625
+ [github-license-link]: https://github.com/lobehub/lobe-editor/blob/master/LICENSE
626
+ [github-license-shield]: https://img.shields.io/github/license/lobehub/lobe-editor?color=white&labelColor=black&style=flat-square
627
+ [github-releasedate-link]: https://github.com/lobehub/lobe-editor/releases
628
+ [github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/lobe-editor?labelColor=black&style=flat-square
629
+ [github-stars-link]: https://github.com/lobehub/lobe-editor/network/stargazers
630
+ [github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-editor?color=ffcb47&labelColor=black&style=flat-square
631
+ [npm-release-link]: https://www.npmjs.com/package/@lobehub/editor
632
+ [npm-release-shield]: https://img.shields.io/npm/v/@lobehub/editor?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
633
+ [pr-welcome-link]: https://github.com/lobehub/lobe-editor/pulls
634
+ [pr-welcome-shield]: https://img.shields.io/badge/%F0%9F%A4%AF%20PR%20WELCOME-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
635
+ [profile-link]: https://github.com/lobehub
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare const CAN_USE_DOM: boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ export var CAN_USE_DOM = typeof window !== 'undefined' && window.document !== undefined && window.document.createElement !== undefined;
@@ -0,0 +1,17 @@
1
+ export declare const nodeDetect: () => boolean;
2
+ export declare const browserDetect: () => boolean;
3
+ export declare const isNode: boolean;
4
+ export declare const isBrowser: boolean;
5
+ export declare const macOSDetect: () => boolean;
6
+ export declare const isMac: boolean;
7
+ export declare const CONTROL_OR_META: {
8
+ ctrlKey: boolean;
9
+ metaKey: boolean;
10
+ };
11
+ export declare const CONTROL_OR_META_AND_SHIFT: {
12
+ ctrlKey: boolean;
13
+ metaKey: boolean;
14
+ shiftKey: boolean;
15
+ };
16
+ export { IS_FIREFOX, IS_APPLE as isApple } from '@lexical/utils';
17
+ export declare const isOnServerSide: boolean;