@haklex/rich-editor 0.0.65 → 0.0.66

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 (120) hide show
  1. package/README.md +107 -300
  2. package/dist/AlertQuoteEditNode-AgVEMFEi.js +292 -0
  3. package/dist/KaTeXRenderer-C8jv_5xr.js +214 -0
  4. package/dist/LinkCardRenderer-QmkOlyXb.js +36 -0
  5. package/dist/{LinkFavicon-DpURZdO_.js → LinkFavicon-B9SOaYCR.js} +5 -24
  6. package/dist/MermaidPlugin-CIQbyjXF.js +97 -0
  7. package/dist/RubyRenderer-DbeobSoH.js +13 -0
  8. package/dist/SubmitShortcutPlugin-WQpet-vq.js +1512 -0
  9. package/dist/commands-entry.d.ts +9 -0
  10. package/dist/commands-entry.d.ts.map +1 -0
  11. package/dist/commands-entry.mjs +25 -0
  12. package/dist/components/ContentEditable.d.ts +2 -2
  13. package/dist/components/ContentEditable.d.ts.map +1 -1
  14. package/dist/components/CorePlugins.d.ts +2 -0
  15. package/dist/components/CorePlugins.d.ts.map +1 -0
  16. package/dist/components/LinkFavicon.d.ts.map +1 -1
  17. package/dist/components/RichEditor.d.ts +1 -1
  18. package/dist/components/RichEditor.d.ts.map +1 -1
  19. package/dist/components/RichEditorShell.d.ts +26 -0
  20. package/dist/components/RichEditorShell.d.ts.map +1 -0
  21. package/dist/components/decorators/AlertEditDecorator.d.ts +2 -2
  22. package/dist/components/decorators/AlertEditDecorator.d.ts.map +1 -1
  23. package/dist/components/decorators/BannerEditDecorator.d.ts +1 -1
  24. package/dist/components/decorators/BannerEditDecorator.d.ts.map +1 -1
  25. package/dist/components/decorators/CodeBlockEditDecorator.d.ts +2 -2
  26. package/dist/components/decorators/CodeBlockEditDecorator.d.ts.map +1 -1
  27. package/dist/components/decorators/GridEditDecorator.d.ts +2 -2
  28. package/dist/components/decorators/GridEditDecorator.d.ts.map +1 -1
  29. package/dist/components/renderers/AlertRenderer.d.ts +1 -1
  30. package/dist/components/renderers/AlertRenderer.d.ts.map +1 -1
  31. package/dist/components/renderers/AlertStaticDecorator.d.ts +1 -1
  32. package/dist/components/renderers/AlertStaticDecorator.d.ts.map +1 -1
  33. package/dist/components/renderers/BannerRenderer.d.ts +1 -1
  34. package/dist/components/renderers/BannerRenderer.d.ts.map +1 -1
  35. package/dist/components/renderers/BannerStaticDecorator.d.ts +1 -1
  36. package/dist/components/renderers/BannerStaticDecorator.d.ts.map +1 -1
  37. package/dist/components/renderers/CodeBlockRenderer.d.ts +5 -5
  38. package/dist/components/renderers/CodeBlockRenderer.d.ts.map +1 -1
  39. package/dist/components/renderers/FootnoteRenderer.d.ts.map +1 -1
  40. package/dist/components/renderers/FootnoteSectionEditRenderer.d.ts +1 -1
  41. package/dist/components/renderers/FootnoteSectionEditRenderer.d.ts.map +1 -1
  42. package/dist/components/renderers/FootnoteSectionRenderer.d.ts +1 -1
  43. package/dist/components/renderers/FootnoteSectionRenderer.d.ts.map +1 -1
  44. package/dist/components/renderers/FootnoteStaticRenderer.d.ts +1 -1
  45. package/dist/components/renderers/FootnoteStaticRenderer.d.ts.map +1 -1
  46. package/dist/components/renderers/GridStaticDecorator.d.ts +2 -2
  47. package/dist/components/renderers/GridStaticDecorator.d.ts.map +1 -1
  48. package/dist/components/renderers/ImageRenderer.d.ts +4 -4
  49. package/dist/components/renderers/ImageRenderer.d.ts.map +1 -1
  50. package/dist/components/renderers/KaTeXRenderer.d.ts +1 -1
  51. package/dist/components/renderers/KaTeXRenderer.d.ts.map +1 -1
  52. package/dist/components/renderers/LinkCardRenderer.d.ts +4 -4
  53. package/dist/components/renderers/LinkCardRenderer.d.ts.map +1 -1
  54. package/dist/components/renderers/MentionRenderer.d.ts +2 -2
  55. package/dist/components/renderers/MentionRenderer.d.ts.map +1 -1
  56. package/dist/components/renderers/RubyRenderer.d.ts +1 -1
  57. package/dist/components/renderers/RubyRenderer.d.ts.map +1 -1
  58. package/dist/components/renderers/VideoRenderer.d.ts +3 -3
  59. package/dist/components/renderers/VideoRenderer.d.ts.map +1 -1
  60. package/dist/config-QGdXDSW9.js +1235 -0
  61. package/dist/context/ImageUploadContext.d.ts.map +1 -1
  62. package/dist/context/RendererConfigContext.d.ts +1 -1
  63. package/dist/context/RendererConfigContext.d.ts.map +1 -1
  64. package/dist/favicon-BQgbXF_a.js +43 -0
  65. package/dist/index.d.ts +10 -80
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.mjs +151 -161
  68. package/dist/node-registry-CSRSWJ0q.js +765 -0
  69. package/dist/nodes/CodeBlockEditNode.d.ts +6 -6
  70. package/dist/nodes/DetailsNode.d.ts.map +1 -1
  71. package/dist/nodes/GridContainerNode.d.ts.map +1 -1
  72. package/dist/nodes/GridEditNode.d.ts.map +1 -1
  73. package/dist/nodes/ImageNode.d.ts +4 -4
  74. package/dist/nodes/ImageNode.d.ts.map +1 -1
  75. package/dist/nodes/LinkCardNode.d.ts +4 -4
  76. package/dist/nodes/LinkCardNode.d.ts.map +1 -1
  77. package/dist/nodes/VideoNode.d.ts +2 -2
  78. package/dist/nodes/VideoNode.d.ts.map +1 -1
  79. package/dist/nodes-entry.d.ts +28 -0
  80. package/dist/nodes-entry.d.ts.map +1 -0
  81. package/dist/nodes-entry.mjs +44 -0
  82. package/dist/plugins/AutoLinkPlugin.d.ts.map +1 -1
  83. package/dist/plugins/ImageUploadPlugin.d.ts +2 -2
  84. package/dist/plugins/ImageUploadPlugin.d.ts.map +1 -1
  85. package/dist/plugins/MarkdownPastePlugin.d.ts.map +1 -1
  86. package/dist/plugins/OnChangePlugin.d.ts +1 -1
  87. package/dist/plugins/OnChangePlugin.d.ts.map +1 -1
  88. package/dist/plugins/image-upload-command.d.ts.map +1 -1
  89. package/dist/plugins/image-upload.css.d.ts +1 -4
  90. package/dist/plugins/image-upload.css.d.ts.map +1 -1
  91. package/dist/plugins-entry.d.ts +22 -0
  92. package/dist/plugins-entry.d.ts.map +1 -0
  93. package/dist/plugins-entry.mjs +27 -0
  94. package/dist/renderers-entry.d.ts +23 -0
  95. package/dist/renderers-entry.d.ts.map +1 -0
  96. package/dist/renderers-entry.mjs +60 -0
  97. package/dist/rich-editor.css +1 -1
  98. package/dist/{utils-fpeaZV1R.js → shared.css-DNuMYx6Q.js} +4 -1
  99. package/dist/static-entry.mjs +23 -21
  100. package/dist/styles/article.css.d.ts.map +1 -1
  101. package/dist/styles-entry.mjs +1 -2
  102. package/dist/theme-CRza9nbF.js +924 -0
  103. package/dist/transformers/code-block.d.ts.map +1 -1
  104. package/dist/types/renderer-config.d.ts +6 -6
  105. package/dist/types/renderer-config.d.ts.map +1 -1
  106. package/dist/types/slash-menu.d.ts +6 -6
  107. package/dist/types/slash-menu.d.ts.map +1 -1
  108. package/dist/types.d.ts +18 -13
  109. package/dist/types.d.ts.map +1 -1
  110. package/dist/utils/comment-anchor.d.ts +8 -8
  111. package/dist/utils/comment-anchor.d.ts.map +1 -1
  112. package/package.json +50 -33
  113. package/dist/RichEditor-EI3rR1-9.js +0 -2789
  114. package/dist/components/decorators/nested-doc-dialog.css.d.ts +0 -28
  115. package/dist/components/decorators/nested-doc-dialog.css.d.ts.map +0 -1
  116. package/dist/editor.d.ts +0 -6
  117. package/dist/editor.d.ts.map +0 -1
  118. package/dist/editor.mjs +0 -12
  119. package/dist/favicon-C6Esc0tp.js +0 -2470
  120. package/dist/shared.css-BqX4HjVE.js +0 -5
package/README.md CHANGED
@@ -1,334 +1,141 @@
1
1
  # @haklex/rich-editor
2
2
 
3
- 基于 [Lexical](https://lexical.dev/) 的富文本编辑器核心包。
4
- 负责 `编辑态` 运行时、节点注册、插件装配、Markdown 快捷键与主题系统。
3
+ Core rich text editor based on Lexical. Provides the `RichEditor` component, all builtin and custom nodes, built-in plugins, and editor contexts.
5
4
 
6
- ## 包定位
7
-
8
- - `@haklex/rich-editor`:编辑器核心(`RichEditor`)
9
- - `@haklex/rich-static-renderer`:只读渲染引擎(`RichRenderer`)
10
- - `@haklex/rich-renderers`:静态增强渲染器聚合(codeblock、image、video、mermaid...)
11
- - `@haklex/rich-renderers-edit`:编辑增强渲染器与扩展插件聚合
12
- - `@haklex/rich-kit-shiro`:一站式生产组合(编辑 + 渲染 + 常用扩展)
13
-
14
- ## 安装
5
+ ## Installation
15
6
 
16
7
  ```bash
17
8
  pnpm add @haklex/rich-editor lexical @lexical/react react react-dom
18
9
  ```
19
10
 
20
- 可选依赖(按功能开启):
21
-
22
- - `katex`:数学公式渲染
23
- - `shiki`:代码高亮
24
-
25
- ## 快速开始
11
+ ## Peer Dependencies
12
+
13
+ | Package | Version | Required |
14
+ | --- | --- | --- |
15
+ | `@base-ui/react` | `^1.1.0` | Yes |
16
+ | `@lexical/code` | `^0.41.0` | Yes |
17
+ | `@lexical/extension` | `^0.41.0` | Yes |
18
+ | `@lexical/link` | `^0.41.0` | Yes |
19
+ | `@lexical/list` | `^0.41.0` | Yes |
20
+ | `@lexical/markdown` | `^0.41.0` | Yes |
21
+ | `@lexical/react` | `^0.41.0` | Yes |
22
+ | `@lexical/rich-text` | `^0.41.0` | Yes |
23
+ | `@lexical/table` | `^0.41.0` | Yes |
24
+ | `lexical` | `^0.41.0` | Yes |
25
+ | `lucide-react` | `^0.574.0` | Yes |
26
+ | `react` | `>=19` | Yes |
27
+ | `react-dom` | `>=19` | Yes |
28
+ | `katex` | `>=0.16.0` | Optional |
29
+ | `shiki` | `^3.0.0` | Optional |
30
+
31
+ ## Usage
26
32
 
27
33
  ```tsx
28
34
  import { RichEditor } from '@haklex/rich-editor'
29
- import type { SerializedEditorState } from 'lexical'
30
- import { useState } from 'react'
31
35
  import '@haklex/rich-editor/style.css'
32
36
 
33
- export function DemoEditor() {
34
- const [value, setValue] = useState<SerializedEditorState | undefined>()
35
-
36
- return (
37
- <RichEditor
38
- initialValue={value}
39
- onChange={setValue}
40
- variant="article"
41
- theme="light"
42
- placeholder="Write something..."
43
- onSubmit={() => {
44
- // Cmd/Ctrl + Enter
45
- }}
46
- />
47
- )
48
- }
37
+ <RichEditor
38
+ variant="article"
39
+ initialValue={savedState}
40
+ onChange={(value) => save(value)}
41
+ />
49
42
  ```
50
43
 
51
- 如果要渲染只读内容:
44
+ For read-only rendering, use `@haklex/rich-static-renderer` instead.
52
45
 
53
- ```tsx
54
- import { RichRenderer } from '@haklex/rich-static-renderer'
46
+ ## Exports
55
47
 
56
- <RichRenderer value={value} />
57
- ```
58
-
59
- ## 数据格式
60
-
61
- `onChange` 返回的是 `SerializedEditorState`(Lexical JSON),推荐直接落库。
62
- `initialValue` 直接喂回这个 JSON,可以做到无损回显。
48
+ ### Components
63
49
 
64
- ## 导出入口
65
-
66
- | 入口 | 说明 |
50
+ | Export | Description |
67
51
  | --- | --- |
68
- | `@haklex/rich-editor` | 完整导出(组件、节点、插件命令、上下文、类型) |
69
- | `@haklex/rich-editor/editor` | 轻入口:`RichEditor` + 节点配置 |
70
- | `@haklex/rich-editor/static` | 渲染/SSR 相关静态工具(供 `@haklex/rich-static-renderer` 与扩展包使用) |
71
- | `@haklex/rich-editor/styles` | 仅样式变量/variant class 导出(不含 Lexical theme 对象) |
72
- | `@haklex/rich-editor/style.css` | 打包后的编辑器样式 |
73
-
74
- ## RichEditor API
75
-
76
- ```ts
77
- type RichEditorVariant = 'article' | 'comment' | 'note'
78
-
79
- interface RichEditorProps {
80
- initialValue?: SerializedEditorState
81
- onChange?: (value: SerializedEditorState) => void
82
- variant?: RichEditorVariant
83
- theme?: 'light' | 'dark'
84
- placeholder?: string
85
- onSubmit?: () => void
86
- autoFocus?: boolean
87
- className?: string
88
- contentClassName?: string
89
- style?: React.CSSProperties
90
- actions?: ReactNode
91
- onEditorReady?: (editor: LexicalEditor | null) => void
92
- extraNodes?: Array<Klass<LexicalNode>>
93
- rendererConfig?: RendererConfig
94
- imageUpload?: ImageUploadFn
95
- debounceMs?: number
96
- children?: ReactNode
97
- }
98
- ```
99
-
100
- 关键字段说明:
101
-
102
- - `extraNodes`:注册你自己的 Lexical 节点(扩展节点必配)
103
- - `rendererConfig`:覆写默认渲染器(如 Image/CodeBlock/LinkCard)
104
- - `actions`:插在编辑器底部 actions 区域(常用于 Slash 菜单)
105
- - `children`:插件插槽(如 `EmbedPlugin`、`TldrawPlugin`)
106
- - `imageUpload`:替换默认图片上传逻辑
107
- - `debounceMs`:`onChange` 的防抖间隔(毫秒)
108
-
109
- ## RendererConfig API
110
-
111
- ```ts
112
- interface RendererConfig {
113
- Alert?: ComponentType<AlertRendererProps>
114
- Banner?: ComponentType<BannerRendererProps>
115
- CodeBlock?: ComponentType<CodeBlockRendererProps>
116
- CodeSnippet?: ComponentType<CodeSnippetRendererProps>
117
- Footnote?: ComponentType<FootnoteRendererProps>
118
- FootnoteSection?: ComponentType<FootnoteSectionRendererProps>
119
- Gallery?: ComponentType<GalleryRendererProps>
120
- Image?: ComponentType<ImageRendererProps>
121
- KaTeX?: ComponentType<KaTeXRendererProps>
122
- LinkCard?: ComponentType<LinkCardRendererProps>
123
- Mermaid?: ComponentType<MermaidRendererProps>
124
- Mention?: ComponentType<MentionRendererProps>
125
- Video?: ComponentType<VideoRendererProps>
126
- }
127
- ```
128
-
129
- 示例:覆写图片与代码块渲染器
130
-
131
- ```tsx
132
- import type { RendererConfig } from '@haklex/rich-editor'
133
-
134
- const rendererConfig: RendererConfig = {
135
- Image: MyImageRenderer,
136
- CodeBlock: MyCodeBlockRenderer,
137
- }
138
-
139
- <RichEditor rendererConfig={rendererConfig} />
140
- ```
141
-
142
- ## 内置节点与插件
143
-
144
- 默认内置节点(`config.ts` / `config-edit.ts`):
145
-
146
- - 内置 Lexical 节点:Heading、Quote、List、Link、Table、Code、HorizontalRule...
147
- - 自定义节点:Spoiler、Mention、KaTeXInline、KaTeXBlock、Image、Alert、CodeBlock、Footnote、FootnoteSection、Video、LinkCard、Details、Grid、Banner、Mermaid
148
-
149
- `RichEditor` 默认挂载插件:
150
-
151
- - 历史/列表/链接/表格:`HistoryPlugin`、`ListPlugin`、`LinkPlugin`、`TablePlugin`
152
- - 编辑增强:`MarkdownShortcutsPlugin`、`CheckListPlugin`、`AutoLinkPlugin`
153
- - 内容能力:`ImagePlugin`、`ImageUploadPlugin`、`KaTeXPlugin`、`AlertPlugin`、`MermaidPlugin`、`HorizontalRulePlugin`
154
- - 生命周期:`OnChangePlugin`、`EditorRefPlugin`、`SubmitShortcutPlugin`(Cmd/Ctrl+Enter)、`AutoFocusPlugin`
155
-
156
- ## 常用命令导出
157
-
158
- ```ts
159
- INSERT_ALERT_COMMAND
160
- INSERT_IMAGE_COMMAND
161
- OPEN_IMAGE_UPLOAD_DIALOG_COMMAND
162
- INSERT_KATEX_INLINE_COMMAND
163
- INSERT_KATEX_BLOCK_COMMAND
164
- INSERT_MERMAID_COMMAND
165
- ```
166
-
167
- 可在自定义插件中 `editor.dispatchCommand(...)` 触发。
168
-
169
- ## Markdown Transformer
170
-
171
- 导出:`ALL_TRANSFORMERS`(`src/transformers`)
172
-
173
- 覆盖能力包括:
174
-
175
- - Inline:Spoiler、Mention、Footnote、`++underline++`、上/下标、KaTeX inline
176
- - Block:FootnoteSection、Container(Banner/Details)、Git Alert、KaTeX block、Image/Video/CodeBlock/LinkCard/Mermaid/Grid/Table/HR + Lexical 默认 transformers
177
-
178
- 参考:`docs/export-format-summary.md`
179
-
180
- ## 设计模式
181
-
182
- ### 1) Static / Edit 节点分离
52
+ | `RichEditor` | Main editor component |
53
+ | `ColorSchemeProvider` | Context provider for light/dark theme |
54
+ | `FootnoteDefinitionsProvider` | Context provider for footnote definitions |
55
+ | `NestedContentRendererProvider` | Context provider for nested content rendering |
183
56
 
184
- 对“编辑态很重”的节点采用双类拆分:
57
+ ### Node Registries
185
58
 
186
- - 静态节点:用于只读渲染,依赖轻
187
- - 编辑节点:继承静态节点,覆盖 `decorate()` 挂重 UI(Popover、Dialog、Nested editor 等)
188
-
189
- 典型:`AlertQuoteNode` / `AlertQuoteEditNode`、`CodeBlockNode` / `CodeBlockEditNode`。
190
-
191
- ### 2) RendererWrapper 注入模式
192
-
193
- 节点内部通过 `createRendererDecoration(...)` 把渲染职责交给 `RendererConfig`,实现:
194
-
195
- - 默认渲染器可直接用
196
- - 业务侧可按 key 定向覆写
197
- - 保持节点协议不变
198
-
199
- ### 3) Command + Plugin 模式
200
-
201
- 扩展插入动作统一走 `createCommand` + `registerCommand`,避免 UI 与文档结构硬耦合。
202
-
203
- ## 扩展编写与接入
204
-
205
- 下面是可直接复用的扩展落地流程。
206
-
207
- ### 步骤 1:定义 Node(静态)
208
-
209
- ```tsx
210
- import type {
211
- EditorConfig,
212
- LexicalEditor,
213
- LexicalNode,
214
- NodeKey,
215
- SerializedLexicalNode,
216
- Spread,
217
- } from 'lexical'
218
- import { DecoratorNode } from 'lexical'
219
- import type { ReactElement } from 'react'
220
- import { createElement } from 'react'
221
-
222
- import { PollRenderer } from './PollRenderer'
223
-
224
- type SerializedPollNode = Spread<
225
- { question: string },
226
- SerializedLexicalNode
227
- >
228
-
229
- export class PollNode extends DecoratorNode<ReactElement> {
230
- __question: string
231
-
232
- static getType() {
233
- return 'poll'
234
- }
235
-
236
- static clone(node: PollNode) {
237
- return new PollNode(node.__question, node.__key)
238
- }
239
-
240
- constructor(question: string, key?: NodeKey) {
241
- super(key)
242
- this.__question = question
243
- }
244
-
245
- createDOM(_config: EditorConfig) {
246
- const el = document.createElement('div')
247
- el.className = 'rich-poll-wrapper'
248
- return el
249
- }
250
-
251
- updateDOM() {
252
- return false
253
- }
254
-
255
- isInline() {
256
- return false
257
- }
258
-
259
- static importJSON(json: SerializedPollNode) {
260
- return new PollNode(json.question)
261
- }
262
-
263
- exportJSON(): SerializedPollNode {
264
- return {
265
- ...super.exportJSON(),
266
- type: 'poll',
267
- question: this.__question,
268
- version: 1,
269
- }
270
- }
271
-
272
- decorate(_editor: LexicalEditor, _config: EditorConfig): ReactElement {
273
- return createElement(PollRenderer, {
274
- question: this.__question,
275
- })
276
- }
277
- }
278
-
279
- export function $isPollNode(
280
- node: LexicalNode | null | undefined,
281
- ): node is PollNode {
282
- return node instanceof PollNode
283
- }
284
- ```
285
-
286
- 说明:`RendererConfig` 只能覆写预定义 key。
287
- 像 `Poll` 这种全新节点,一般采用“节点内直接渲染组件”或自定义 context 的方式。
288
-
289
- ### 步骤 2:可选编辑态 Node
290
-
291
- 如果编辑态需要重 UI,可以 `class PollEditNode extends PollNode` 并覆写 `decorate()`。
292
-
293
- 还可以定义 slash 菜单项:
294
-
295
- ```ts
296
- static slashMenuItems = [
297
- {
298
- title: 'Poll',
299
- description: 'Insert a poll block',
300
- section: 'MEDIA',
301
- onSelect: (editor) => { ... },
302
- },
303
- ]
304
- ```
59
+ | Export | Description |
60
+ | --- | --- |
61
+ | `allNodes` | All static nodes (builtin + custom) |
62
+ | `builtinNodes` | Lexical builtin nodes only |
63
+ | `customNodes` | Custom static nodes only |
64
+ | `allEditNodes` | All edit-mode nodes (builtin + custom edit) |
65
+ | `customEditNodes` | Custom edit-mode nodes only |
305
66
 
306
- ### 步骤 3:注册到编辑器与渲染器
67
+ ### Node Classes
307
68
 
308
- ```tsx
309
- import { RichEditor } from '@haklex/rich-editor'
310
- import { RichRenderer } from '@haklex/rich-static-renderer'
69
+ | Export | Description |
70
+ | --- | --- |
71
+ | `MermaidNode`, `$createMermaidNode`, `$isMermaidNode` | Mermaid diagram node |
72
+ | `RubyNode`, `$createRubyNode`, `$isRubyNode` | Ruby annotation node |
73
+ | `GridContainerNode`, `$createGridContainerNode`, `$isGridContainerNode` | Grid layout container |
74
+ | `FootnoteSectionNode`, `$createFootnoteSectionNode`, `$isFootnoteSectionNode` | Footnote section node |
75
+ | `FootnoteSectionEditNode` | Footnote section edit-mode node |
76
+ | `ImageNode`, `$createImageNode`, `$isImageNode` | Image node |
77
+ | `LinkCardNode`, `$createLinkCardNode`, `$isLinkCardNode` | Link card node |
78
+ | `KaTeXBlockNode`, `$isKaTeXBlockNode` | KaTeX block equation node |
79
+ | `KaTeXInlineNode`, `$isKaTeXInlineNode` | KaTeX inline equation node |
80
+ | `MentionNode`, `$createMentionNode`, `$isMentionNode` | Mention node |
81
+
82
+ ### Plugins
83
+
84
+ | Export | Description |
85
+ | --- | --- |
86
+ | `AutoLinkPlugin` | Automatic link detection |
87
+ | `BlockExitPlugin` | Exit block nodes with Enter/arrow keys |
88
+ | `HorizontalRulePlugin` | Horizontal rule insertion |
89
+ | `ImagePlugin` | Image node handling |
90
+ | `ImageUploadPlugin` | Image upload dialog and logic |
91
+ | `KaTeXPlugin` | KaTeX equation insertion |
92
+ | `LinkFaviconPlugin` | Favicon resolution for links |
93
+ | `MarkdownShortcutsPlugin` | Markdown syntax shortcuts |
94
+ | `MermaidPlugin` | Mermaid diagram insertion |
95
+ | `FootnotePlugin` | Footnote insertion and management |
96
+
97
+ ### Commands
98
+
99
+ | Export | Description |
100
+ | --- | --- |
101
+ | `INSERT_ALERT_COMMAND` | Insert an alert/callout block |
102
+ | `INSERT_IMAGE_COMMAND` | Insert an image node |
103
+ | `OPEN_IMAGE_UPLOAD_DIALOG_COMMAND` | Open the image upload dialog |
104
+ | `INSERT_KATEX_BLOCK_COMMAND` | Insert a KaTeX block equation |
105
+ | `INSERT_KATEX_INLINE_COMMAND` | Insert a KaTeX inline equation |
106
+ | `INSERT_MERMAID_COMMAND` | Insert a Mermaid diagram |
311
107
 
312
- <RichEditor extraNodes={[PollEditNode]}>{/* <PollPlugin /> */}</RichEditor>
108
+ ### Utilities
313
109
 
314
- <RichRenderer value={value} extraNodes={[PollNode]} />
315
- ```
110
+ | Export | Description |
111
+ | --- | --- |
112
+ | `extractTextContent` | Extract plain text from editor state |
113
+ | `collectCommandItems` | Collect slash menu / toolbar command items |
114
+ | `computeImageMeta` | Compute thumbhash and dimensions for an image |
115
+ | `decodeThumbHash` | Decode a thumbhash string to a data URL |
116
+ | `createRendererDecoration` | Create a renderer decoration for decorator nodes |
117
+ | `getVariantClass` | Get the CSS class for a variant |
118
+ | `defaultImageUpload` | Default image upload implementation |
119
+ | `buildBlockAnchor`, `buildRangeAnchor` | Comment anchor utilities |
120
+ | `ALL_TRANSFORMERS` | All Markdown transformers (inline + block) |
316
121
 
317
- ### 步骤 4:插件化插入命令(推荐)
122
+ ### Types
318
123
 
319
- ```ts
320
- import { createCommand } from 'lexical'
124
+ `RichEditorProps`, `RichEditorVariant`, `RendererConfig`, `ColorScheme`, `RendererMode`, `ImageUploadFn`, `ImageUploadResult`, `CommandItemConfig`, `SlashMenuItemConfig`, `ToolbarGroup`, `CommandPlacement`, and renderer prop types (`AlertRendererProps`, `ImageRendererProps`, `CodeBlockRendererProps`, etc.).
321
125
 
322
- export const INSERT_POLL_COMMAND = createCommand<{ question: string }>()
323
- ```
126
+ ### Sub-path Exports
324
127
 
325
- 在插件中注册命令,所有 UI(按钮、slash、快捷键)统一 dispatch 该命令。
128
+ | Import Path | Description |
129
+ | --- | --- |
130
+ | `@haklex/rich-editor` | Full export (components, nodes, plugins, commands, contexts, types) |
131
+ | `@haklex/rich-editor/editor` | Editor-specific entry (RichEditor + node configs) |
132
+ | `@haklex/rich-editor/static` | Static/SSR utilities (for renderer and extension packages) |
133
+ | `@haklex/rich-editor/styles` | Style variables and variant class exports |
134
+ | `@haklex/rich-editor/style.css` | Compiled editor stylesheet |
326
135
 
327
- ## 与聚合包配合
136
+ ## Part of Haklex
328
137
 
329
- - 只想增强只读渲染:`@haklex/rich-renderers`
330
- - 要增强编辑态:`@haklex/rich-renderers-edit`
331
- - 想直接开箱即用:`@haklex/rich-kit-shiro`
138
+ This package is part of the [Haklex](../../README.md) rich editor ecosystem.
332
139
 
333
140
  ## License
334
141