@haklex/rich-editor 0.5.0 → 0.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.
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ import '@haklex/rich-editor/style.css';
|
|
|
38
38
|
<RichEditor variant="article" initialValue={savedState} onChange={(value) => save(value)} />;
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
For read-only rendering, use `@haklex/rich-
|
|
41
|
+
For read-only rendering, use `@haklex/rich-compose` (exports `RichRenderer` and the modular composition API).
|
|
42
42
|
|
|
43
43
|
## Exports
|
|
44
44
|
|
|
@@ -116,9 +116,54 @@ For read-only rendering, use `@haklex/rich-static-renderer` instead.
|
|
|
116
116
|
| `buildBlockAnchor`, `buildRangeAnchor` | Comment anchor utilities |
|
|
117
117
|
| `ALL_TRANSFORMERS` | All Markdown transformers (inline + block) |
|
|
118
118
|
|
|
119
|
+
### Slot Keys
|
|
120
|
+
|
|
121
|
+
`RendererConfig` keys are exposed as `as const` constants for safer call sites. Use them in `createRendererDecoration` and module override maps instead of bare string literals:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import {
|
|
125
|
+
ALERT_NODE_KEY,
|
|
126
|
+
BANNER_NODE_KEY,
|
|
127
|
+
CODE_BLOCK_NODE_KEY,
|
|
128
|
+
FOOTNOTE_NODE_KEY,
|
|
129
|
+
FOOTNOTE_SECTION_NODE_KEY,
|
|
130
|
+
IMAGE_NODE_KEY,
|
|
131
|
+
KATEX_NODE_KEY,
|
|
132
|
+
LINK_CARD_NODE_KEY,
|
|
133
|
+
MENTION_NODE_KEY,
|
|
134
|
+
MERMAID_NODE_KEY,
|
|
135
|
+
RUBY_NODE_KEY,
|
|
136
|
+
TAG_NODE_KEY,
|
|
137
|
+
VIDEO_NODE_KEY,
|
|
138
|
+
} from '@haklex/rich-editor';
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Extension packages (`@haklex/rich-ext-*`) expose their own slot keys (e.g. `POLL_NODE_KEY`, `CHAT_NODE_KEY`).
|
|
142
|
+
|
|
143
|
+
### Extending `RendererConfig`
|
|
144
|
+
|
|
145
|
+
`@haklex/rich-editor` ships only the built-in slots. Extension and downstream packages add their own slots via TypeScript module augmentation:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import type { ComponentType } from 'react';
|
|
149
|
+
import type { MyChartProps } from './MyChart';
|
|
150
|
+
// Force the augmentation target to resolve as an external module.
|
|
151
|
+
import type {} from '@haklex/rich-editor';
|
|
152
|
+
|
|
153
|
+
declare module '@haklex/rich-editor' {
|
|
154
|
+
interface RendererConfig {
|
|
155
|
+
MyChart?: ComponentType<MyChartProps>;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export {};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Re-export the augmentation file as a side-effect from every public entry (`/node`, `/renderer`, `/edit`, `/static`, `/index`) so consumers see the slot regardless of which sub-path they import.
|
|
163
|
+
|
|
119
164
|
### Types
|
|
120
165
|
|
|
121
|
-
`RichEditorProps`, `RichEditorVariant`, `RendererConfig`, `ColorScheme`, `RendererMode`, `ImageUploadFn`, `ImageUploadResult`, `CommandItemConfig`, `SlashMenuItemConfig`, `ToolbarGroup`, `CommandPlacement`, and renderer prop types (`AlertRendererProps`, `ImageRendererProps`, `CodeBlockRendererProps`, etc.).
|
|
166
|
+
`RichEditorProps`, `RichEditorVariant`, `RendererConfig`, `ColorScheme`, `RendererMode`, `ImageUploadFn`, `ImageUploadResult`, `CommandItemConfig`, `SlashMenuItemConfig`, `ToolbarGroup`, `CommandPlacement`, and **built-in** renderer prop types (`AlertRendererProps`, `ImageRendererProps`, `CodeBlockRendererProps`, etc.). Extension renderer props (`PollRendererProps`, `ChatRendererProps`, `CodeFile`, `GalleryRendererProps`, …) live in their owning packages — import from `@haklex/rich-ext-<name>/node`.
|
|
122
167
|
|
|
123
168
|
### Sub-path Exports
|
|
124
169
|
|
|
@@ -126,6 +171,10 @@ For read-only rendering, use `@haklex/rich-static-renderer` instead.
|
|
|
126
171
|
| ------------------------------- | ------------------------------------------------------------------- |
|
|
127
172
|
| `@haklex/rich-editor` | Full export (components, nodes, plugins, commands, contexts, types) |
|
|
128
173
|
| `@haklex/rich-editor/editor` | Editor-specific entry (RichEditor + node configs) |
|
|
174
|
+
| `@haklex/rich-editor/nodes` | Node classes + edit-mode node classes |
|
|
175
|
+
| `@haklex/rich-editor/plugins` | Built-in plugins |
|
|
176
|
+
| `@haklex/rich-editor/commands` | Insert / open commands + `CommandItemConfig` |
|
|
177
|
+
| `@haklex/rich-editor/renderers` | Built-in renderer components, prop types, and slot key constants |
|
|
129
178
|
| `@haklex/rich-editor/static` | Static/SSR utilities (for renderer and extension packages) |
|
|
130
179
|
| `@haklex/rich-editor/styles` | Style variables and variant class exports |
|
|
131
180
|
| `@haklex/rich-editor/style.css` | Compiled editor stylesheet |
|
|
@@ -26,7 +26,7 @@ export type RendererWrapperProps = {
|
|
|
26
26
|
* Wrapper component that allows overriding default renderers with custom ones.
|
|
27
27
|
* Uses RendererConfig from context to determine which renderer to use.
|
|
28
28
|
*/
|
|
29
|
-
export declare function RendererWrapper({ rendererKey, defaultRenderer, props
|
|
29
|
+
export declare function RendererWrapper({ rendererKey, defaultRenderer, props }: RendererWrapperProps): import("react").JSX.Element | null;
|
|
30
30
|
/**
|
|
31
31
|
* Type-safe helper for creating RendererWrapper elements from .ts node files.
|
|
32
32
|
* Avoids the createElement + discriminated-union typing limitation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RendererWrapper.d.ts","sourceRoot":"","sources":["../../src/components/RendererWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"RendererWrapper.d.ts","sourceRoot":"","sources":["../../src/components/RendererWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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ts","sourceRoot":"","sources":["../../src/nodes/CodeBlockNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"CodeBlockNode.d.ts","sourceRoot":"","sources":["../../src/nodes/CodeBlockNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAgB,aAAa,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAM1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C;IACE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,EACD,qBAAqB,CACtB,CAAC;AAEF,qBAAa,aAAc,SAAQ,aAAa,CAAC,YAAY,CAAC;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE,CAetC;IAEF,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa;gBAIpC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO;IAMzD,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW;IAM7C,SAAS,IAAI,OAAO;IAIpB,QAAQ,IAAI,OAAO;IAInB,oBAAoB,IAAI,OAAO;IAI/B,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,uBAAuB,GAAG,aAAa;IAIzE,UAAU,IAAI,uBAAuB;IAUrC,OAAO,IAAI,MAAM;IAIjB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK3B,WAAW,IAAI,MAAM;IAIrB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKnC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAMtE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,CAElF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,aAAa,CAE5F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionNode.d.ts","sourceRoot":"","sources":["../../src/nodes/MentionNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"MentionNode.d.ts","sourceRoot":"","sources":["../../src/nodes/MentionNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAoC,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAM1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,EACD,qBAAqB,CACtB,CAAC;AAEF,qBAAa,WAAY,SAAQ,aAAa,CAAC,YAAY,CAAC;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,MAAM,CAAC,cAAc,EAAE,mBAAmB,EAAE,CAgB1C;IAEF,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;gBAIhC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO;IAOjF,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW;IAQ7C,SAAS,IAAI,OAAO;IAIpB,QAAQ,IAAI,OAAO;IAInB,WAAW,IAAI,MAAM;IAIrB,SAAS,IAAI,MAAM;IAInB,cAAc,IAAI,MAAM,GAAG,SAAS;IAIpC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,qBAAqB,GAAG,WAAW;IAQrE,UAAU,IAAI,qBAAqB;IAWnC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY;CAOtE;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GACnB,WAAW,CAEb;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,WAAW,CAExF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MermaidNode.d.ts","sourceRoot":"","sources":["../../src/nodes/MermaidNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"MermaidNode.d.ts","sourceRoot":"","sources":["../../src/nodes/MermaidNode.ts"],"names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|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Core rich text editor based on Lexical",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@lexical/code-core": "^0.44.0",
|
|
49
49
|
"nanoid": "^5.1.9",
|
|
50
50
|
"thumbhash": "^0.1.1",
|
|
51
|
-
"@haklex/rich-editor-ui": "0.
|
|
52
|
-
"@haklex/rich-style-token": "0.
|
|
53
|
-
"@haklex/rich-headless": "0.
|
|
51
|
+
"@haklex/rich-editor-ui": "0.6.0",
|
|
52
|
+
"@haklex/rich-style-token": "0.6.0",
|
|
53
|
+
"@haklex/rich-headless": "0.6.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@lexical/extension": "^0.44.0",
|