@stream-mdx/react 0.2.0 → 0.4.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 +4 -3
- package/dist/components/index.cjs +8 -4
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.mjs +8 -4
- package/dist/{index-D0akq48G.d.cts → index-D2MYusAM.d.cts} +4 -1
- package/dist/{index-D0akq48G.d.ts → index-D2MYusAM.d.ts} +4 -1
- package/dist/index.cjs +2543 -2522
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +2757 -2736
- package/dist/renderer/node-views.cjs +4 -0
- package/dist/renderer/node-views.d.cts +1 -1
- package/dist/renderer/node-views.d.ts +1 -1
- package/dist/renderer/node-views.mjs +4 -0
- package/dist/renderer.cjs +2740 -2719
- package/dist/renderer.d.cts +13 -12
- package/dist/renderer.d.ts +13 -12
- package/dist/renderer.mjs +2749 -2728
- package/dist/server.cjs +4244 -0
- package/dist/server.d.cts +249 -0
- package/dist/server.d.ts +249 -0
- package/dist/server.mjs +4226 -0
- package/dist/{streaming-markdown-Ch6PwjAa.d.cts → streaming-markdown-D-JcByd9.d.cts} +4 -1
- package/dist/{streaming-markdown-tca-Mf8D.d.ts → streaming-markdown-DOc2uLiP.d.ts} +4 -1
- package/dist/streaming-markdown.cjs +2793 -2772
- package/dist/streaming-markdown.d.cts +2 -2
- package/dist/streaming-markdown.d.ts +2 -2
- package/dist/streaming-markdown.mjs +2759 -2738
- package/dist/utils/inline-html.d.cts +1 -1
- package/dist/utils/inline-html.d.ts +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { InlineNode, TokenLineV1, CompiledMdxModule, InlineHtmlDescriptor, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode, Block, Patch, CoalescingMetrics } from '@stream-mdx/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
type GenericComponent = React.ComponentType<any>;
|
|
5
|
+
interface TableElements {
|
|
6
|
+
Table: GenericComponent;
|
|
7
|
+
Thead: GenericComponent;
|
|
8
|
+
Tbody: GenericComponent;
|
|
9
|
+
Tr: GenericComponent;
|
|
10
|
+
Th: GenericComponent;
|
|
11
|
+
Td: GenericComponent;
|
|
12
|
+
}
|
|
13
|
+
type HtmlElements = Record<string, GenericComponent>;
|
|
14
|
+
type InlineHtmlRenderer = (descriptor: InlineHtmlDescriptor, context: {
|
|
15
|
+
key?: React.Key;
|
|
16
|
+
defaultRender: () => React.ReactElement | null;
|
|
17
|
+
}) => React.ReactElement | null;
|
|
18
|
+
type InlineHtmlRendererMap = Record<string, InlineHtmlRenderer>;
|
|
19
|
+
interface BlockComponents {
|
|
20
|
+
paragraph: React.FC<{
|
|
21
|
+
inlines: InlineNode[];
|
|
22
|
+
raw?: string;
|
|
23
|
+
meta?: Record<string, unknown>;
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
}>;
|
|
26
|
+
heading: React.FC<{
|
|
27
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
28
|
+
inlines: InlineNode[];
|
|
29
|
+
text?: string;
|
|
30
|
+
meta?: Record<string, unknown>;
|
|
31
|
+
}>;
|
|
32
|
+
code: React.FC<{
|
|
33
|
+
html: string;
|
|
34
|
+
meta?: Record<string, unknown>;
|
|
35
|
+
lines?: ReadonlyArray<{
|
|
36
|
+
id: string;
|
|
37
|
+
index: number;
|
|
38
|
+
text: string;
|
|
39
|
+
html?: string | null;
|
|
40
|
+
tokens?: TokenLineV1 | null;
|
|
41
|
+
}>;
|
|
42
|
+
lang?: string;
|
|
43
|
+
preAttrs?: Record<string, string>;
|
|
44
|
+
codeAttrs?: Record<string, string>;
|
|
45
|
+
}>;
|
|
46
|
+
blockquote: React.FC<{
|
|
47
|
+
inlines: InlineNode[];
|
|
48
|
+
renderedContent?: React.ReactNode;
|
|
49
|
+
}>;
|
|
50
|
+
list: React.FC<{
|
|
51
|
+
ordered: boolean;
|
|
52
|
+
items: InlineNode[][];
|
|
53
|
+
}>;
|
|
54
|
+
html: React.FC<{
|
|
55
|
+
__trustedHtml: TrustedHTML | string;
|
|
56
|
+
elements?: Record<string, GenericComponent>;
|
|
57
|
+
}>;
|
|
58
|
+
mdx: React.FC<{
|
|
59
|
+
compiledRef?: {
|
|
60
|
+
id: string;
|
|
61
|
+
};
|
|
62
|
+
compiledModule?: CompiledMdxModule | null;
|
|
63
|
+
status?: "pending" | "compiled" | "error";
|
|
64
|
+
errorMessage?: string;
|
|
65
|
+
raw?: string;
|
|
66
|
+
}>;
|
|
67
|
+
hr: React.FC<React.HTMLAttributes<HTMLHRElement>>;
|
|
68
|
+
table: React.FC<{
|
|
69
|
+
header?: InlineNode[][];
|
|
70
|
+
rows: InlineNode[][][];
|
|
71
|
+
align?: Array<"left" | "center" | "right" | null>;
|
|
72
|
+
elements?: Partial<TableElements>;
|
|
73
|
+
}>;
|
|
74
|
+
[k: string]: GenericComponent;
|
|
75
|
+
}
|
|
76
|
+
type InlineComponents = Record<string, GenericComponent> & {
|
|
77
|
+
text: React.FC<{
|
|
78
|
+
text: string;
|
|
79
|
+
}>;
|
|
80
|
+
strong: React.FC<{
|
|
81
|
+
children: React.ReactNode;
|
|
82
|
+
}>;
|
|
83
|
+
em: React.FC<{
|
|
84
|
+
children: React.ReactNode;
|
|
85
|
+
}>;
|
|
86
|
+
strike?: React.FC<{
|
|
87
|
+
children: React.ReactNode;
|
|
88
|
+
}>;
|
|
89
|
+
code: React.FC<{
|
|
90
|
+
text: string;
|
|
91
|
+
}>;
|
|
92
|
+
link: React.FC<{
|
|
93
|
+
href?: string;
|
|
94
|
+
title?: string;
|
|
95
|
+
children: React.ReactNode;
|
|
96
|
+
}>;
|
|
97
|
+
image: React.FC<{
|
|
98
|
+
src: string;
|
|
99
|
+
alt?: string;
|
|
100
|
+
title?: string;
|
|
101
|
+
}>;
|
|
102
|
+
br: React.FC<Record<string, never>>;
|
|
103
|
+
};
|
|
104
|
+
interface RendererConfig {
|
|
105
|
+
themes?: {
|
|
106
|
+
light: string;
|
|
107
|
+
dark: string;
|
|
108
|
+
};
|
|
109
|
+
highlight?: {
|
|
110
|
+
browserEngine?: "js" | "wasm";
|
|
111
|
+
serverEngine?: "wasm";
|
|
112
|
+
langs?: string[];
|
|
113
|
+
};
|
|
114
|
+
sanitization?: {
|
|
115
|
+
schemaId?: string;
|
|
116
|
+
};
|
|
117
|
+
mdx?: {
|
|
118
|
+
enabled?: boolean;
|
|
119
|
+
compileEndpoint?: string;
|
|
120
|
+
compileStrategy?: "server" | "worker";
|
|
121
|
+
components?: Record<string, GenericComponent>;
|
|
122
|
+
};
|
|
123
|
+
plugins?: {
|
|
124
|
+
footnotes?: boolean;
|
|
125
|
+
html?: boolean;
|
|
126
|
+
mdx?: boolean;
|
|
127
|
+
tables?: boolean;
|
|
128
|
+
callouts?: boolean;
|
|
129
|
+
math?: boolean;
|
|
130
|
+
formatAnticipation?: FormatAnticipationConfig;
|
|
131
|
+
codeHighlighting?: CodeHighlightingMode;
|
|
132
|
+
outputMode?: CodeHighlightOutputMode;
|
|
133
|
+
liveCodeHighlighting?: boolean;
|
|
134
|
+
liveTokenization?: boolean;
|
|
135
|
+
emitHighlightTokens?: boolean;
|
|
136
|
+
emitDiffBlocks?: boolean;
|
|
137
|
+
};
|
|
138
|
+
performance?: {
|
|
139
|
+
frameBudgetMs?: number;
|
|
140
|
+
flushTimeoutMs?: number;
|
|
141
|
+
maxBatchesPerFlush?: number;
|
|
142
|
+
maxLowPriorityBatchesPerFlush?: number;
|
|
143
|
+
lowPriorityFrameBudgetMs?: number;
|
|
144
|
+
urgentQueueThreshold?: number;
|
|
145
|
+
batch?: "rAF" | "microtask" | "timeout";
|
|
146
|
+
historyLimit?: number;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Component registry that allows customization
|
|
152
|
+
*/
|
|
153
|
+
declare class ComponentRegistry {
|
|
154
|
+
private blockComponents;
|
|
155
|
+
private inlineComponents;
|
|
156
|
+
private htmlElements;
|
|
157
|
+
private tableElements;
|
|
158
|
+
private blockComponentMapCache;
|
|
159
|
+
private inlineComponentMapCache;
|
|
160
|
+
constructor(blockComponents?: Partial<BlockComponents>, inlineComponents?: Partial<InlineComponents>);
|
|
161
|
+
/**
|
|
162
|
+
* Update block components
|
|
163
|
+
*/
|
|
164
|
+
setBlockComponents(components: Partial<BlockComponents>): void;
|
|
165
|
+
/**
|
|
166
|
+
* Update inline components
|
|
167
|
+
*/
|
|
168
|
+
setInlineComponents(components: Partial<InlineComponents>): void;
|
|
169
|
+
/** Update HTML element mapping for html blocks */
|
|
170
|
+
setHtmlElements(map: Partial<HtmlElements>): void;
|
|
171
|
+
/** Update table element mapping for table blocks */
|
|
172
|
+
setTableElements(map: Partial<TableElements>): void;
|
|
173
|
+
/**
|
|
174
|
+
* Get block component
|
|
175
|
+
*/
|
|
176
|
+
getBlockComponent(type: string): React.ComponentType<Record<string, unknown>>;
|
|
177
|
+
/**
|
|
178
|
+
* Get inline components
|
|
179
|
+
*/
|
|
180
|
+
getInlineComponents(): InlineComponents;
|
|
181
|
+
getBlockComponentMap(): BlockComponents;
|
|
182
|
+
getInlineComponentMap(): InlineComponents;
|
|
183
|
+
getTableElements(): TableElements;
|
|
184
|
+
/**
|
|
185
|
+
* Render a block
|
|
186
|
+
*/
|
|
187
|
+
renderBlock(block: Block): React.ReactElement;
|
|
188
|
+
/**
|
|
189
|
+
* Get props for a block based on its type
|
|
190
|
+
*/
|
|
191
|
+
private getBlockProps;
|
|
192
|
+
/**
|
|
193
|
+
* Extract heading level from raw markdown
|
|
194
|
+
*/
|
|
195
|
+
private extractHeadingLevel;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface NodeRecord {
|
|
199
|
+
id: string;
|
|
200
|
+
type: string;
|
|
201
|
+
parentId: string | null;
|
|
202
|
+
children: string[];
|
|
203
|
+
props: Record<string, unknown>;
|
|
204
|
+
meta?: Record<string, unknown>;
|
|
205
|
+
range?: {
|
|
206
|
+
from: number;
|
|
207
|
+
to: number;
|
|
208
|
+
};
|
|
209
|
+
version: number;
|
|
210
|
+
block?: Block;
|
|
211
|
+
}
|
|
212
|
+
interface ApplyPatchesOptions {
|
|
213
|
+
coalesced?: boolean;
|
|
214
|
+
metrics?: CoalescingMetrics | null;
|
|
215
|
+
captureMetrics?: boolean;
|
|
216
|
+
allowEmpty?: boolean;
|
|
217
|
+
}
|
|
218
|
+
interface RendererStore {
|
|
219
|
+
reset(blocks: Block[]): void;
|
|
220
|
+
applyPatches(patches: Patch[], options?: ApplyPatchesOptions): Set<string>;
|
|
221
|
+
getBlocks(): ReadonlyArray<Block>;
|
|
222
|
+
getVersion(): number;
|
|
223
|
+
getNode(id: string): NodeRecord | undefined;
|
|
224
|
+
getNodeWithVersion(id: string): {
|
|
225
|
+
version: number;
|
|
226
|
+
node?: NodeRecord;
|
|
227
|
+
};
|
|
228
|
+
getChildren(id: string): ReadonlyArray<string>;
|
|
229
|
+
getChildrenWithVersion(id: string): {
|
|
230
|
+
version: number;
|
|
231
|
+
children: ReadonlyArray<string>;
|
|
232
|
+
};
|
|
233
|
+
subscribe(listener: () => void): () => void;
|
|
234
|
+
getLastCoalescingMetrics(): CoalescingMetrics | null;
|
|
235
|
+
}
|
|
236
|
+
declare function createRendererStore(initialBlocks?: Block[]): RendererStore;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* React component for rendering markdown blocks
|
|
240
|
+
*/
|
|
241
|
+
declare const MarkdownBlocksRenderer: React.NamedExoticComponent<{
|
|
242
|
+
blocks: ReadonlyArray<Block>;
|
|
243
|
+
componentRegistry: ComponentRegistry;
|
|
244
|
+
className?: string;
|
|
245
|
+
style?: React.CSSProperties;
|
|
246
|
+
store?: ReturnType<typeof createRendererStore>;
|
|
247
|
+
}>;
|
|
248
|
+
|
|
249
|
+
export { type BlockComponents, ComponentRegistry, type HtmlElements, type InlineComponents, type InlineHtmlRenderer, type InlineHtmlRendererMap, MarkdownBlocksRenderer, type RendererConfig, type TableElements, createRendererStore };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { InlineNode, TokenLineV1, CompiledMdxModule, InlineHtmlDescriptor, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode, Block, Patch, CoalescingMetrics } from '@stream-mdx/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
type GenericComponent = React.ComponentType<any>;
|
|
5
|
+
interface TableElements {
|
|
6
|
+
Table: GenericComponent;
|
|
7
|
+
Thead: GenericComponent;
|
|
8
|
+
Tbody: GenericComponent;
|
|
9
|
+
Tr: GenericComponent;
|
|
10
|
+
Th: GenericComponent;
|
|
11
|
+
Td: GenericComponent;
|
|
12
|
+
}
|
|
13
|
+
type HtmlElements = Record<string, GenericComponent>;
|
|
14
|
+
type InlineHtmlRenderer = (descriptor: InlineHtmlDescriptor, context: {
|
|
15
|
+
key?: React.Key;
|
|
16
|
+
defaultRender: () => React.ReactElement | null;
|
|
17
|
+
}) => React.ReactElement | null;
|
|
18
|
+
type InlineHtmlRendererMap = Record<string, InlineHtmlRenderer>;
|
|
19
|
+
interface BlockComponents {
|
|
20
|
+
paragraph: React.FC<{
|
|
21
|
+
inlines: InlineNode[];
|
|
22
|
+
raw?: string;
|
|
23
|
+
meta?: Record<string, unknown>;
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
}>;
|
|
26
|
+
heading: React.FC<{
|
|
27
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
28
|
+
inlines: InlineNode[];
|
|
29
|
+
text?: string;
|
|
30
|
+
meta?: Record<string, unknown>;
|
|
31
|
+
}>;
|
|
32
|
+
code: React.FC<{
|
|
33
|
+
html: string;
|
|
34
|
+
meta?: Record<string, unknown>;
|
|
35
|
+
lines?: ReadonlyArray<{
|
|
36
|
+
id: string;
|
|
37
|
+
index: number;
|
|
38
|
+
text: string;
|
|
39
|
+
html?: string | null;
|
|
40
|
+
tokens?: TokenLineV1 | null;
|
|
41
|
+
}>;
|
|
42
|
+
lang?: string;
|
|
43
|
+
preAttrs?: Record<string, string>;
|
|
44
|
+
codeAttrs?: Record<string, string>;
|
|
45
|
+
}>;
|
|
46
|
+
blockquote: React.FC<{
|
|
47
|
+
inlines: InlineNode[];
|
|
48
|
+
renderedContent?: React.ReactNode;
|
|
49
|
+
}>;
|
|
50
|
+
list: React.FC<{
|
|
51
|
+
ordered: boolean;
|
|
52
|
+
items: InlineNode[][];
|
|
53
|
+
}>;
|
|
54
|
+
html: React.FC<{
|
|
55
|
+
__trustedHtml: TrustedHTML | string;
|
|
56
|
+
elements?: Record<string, GenericComponent>;
|
|
57
|
+
}>;
|
|
58
|
+
mdx: React.FC<{
|
|
59
|
+
compiledRef?: {
|
|
60
|
+
id: string;
|
|
61
|
+
};
|
|
62
|
+
compiledModule?: CompiledMdxModule | null;
|
|
63
|
+
status?: "pending" | "compiled" | "error";
|
|
64
|
+
errorMessage?: string;
|
|
65
|
+
raw?: string;
|
|
66
|
+
}>;
|
|
67
|
+
hr: React.FC<React.HTMLAttributes<HTMLHRElement>>;
|
|
68
|
+
table: React.FC<{
|
|
69
|
+
header?: InlineNode[][];
|
|
70
|
+
rows: InlineNode[][][];
|
|
71
|
+
align?: Array<"left" | "center" | "right" | null>;
|
|
72
|
+
elements?: Partial<TableElements>;
|
|
73
|
+
}>;
|
|
74
|
+
[k: string]: GenericComponent;
|
|
75
|
+
}
|
|
76
|
+
type InlineComponents = Record<string, GenericComponent> & {
|
|
77
|
+
text: React.FC<{
|
|
78
|
+
text: string;
|
|
79
|
+
}>;
|
|
80
|
+
strong: React.FC<{
|
|
81
|
+
children: React.ReactNode;
|
|
82
|
+
}>;
|
|
83
|
+
em: React.FC<{
|
|
84
|
+
children: React.ReactNode;
|
|
85
|
+
}>;
|
|
86
|
+
strike?: React.FC<{
|
|
87
|
+
children: React.ReactNode;
|
|
88
|
+
}>;
|
|
89
|
+
code: React.FC<{
|
|
90
|
+
text: string;
|
|
91
|
+
}>;
|
|
92
|
+
link: React.FC<{
|
|
93
|
+
href?: string;
|
|
94
|
+
title?: string;
|
|
95
|
+
children: React.ReactNode;
|
|
96
|
+
}>;
|
|
97
|
+
image: React.FC<{
|
|
98
|
+
src: string;
|
|
99
|
+
alt?: string;
|
|
100
|
+
title?: string;
|
|
101
|
+
}>;
|
|
102
|
+
br: React.FC<Record<string, never>>;
|
|
103
|
+
};
|
|
104
|
+
interface RendererConfig {
|
|
105
|
+
themes?: {
|
|
106
|
+
light: string;
|
|
107
|
+
dark: string;
|
|
108
|
+
};
|
|
109
|
+
highlight?: {
|
|
110
|
+
browserEngine?: "js" | "wasm";
|
|
111
|
+
serverEngine?: "wasm";
|
|
112
|
+
langs?: string[];
|
|
113
|
+
};
|
|
114
|
+
sanitization?: {
|
|
115
|
+
schemaId?: string;
|
|
116
|
+
};
|
|
117
|
+
mdx?: {
|
|
118
|
+
enabled?: boolean;
|
|
119
|
+
compileEndpoint?: string;
|
|
120
|
+
compileStrategy?: "server" | "worker";
|
|
121
|
+
components?: Record<string, GenericComponent>;
|
|
122
|
+
};
|
|
123
|
+
plugins?: {
|
|
124
|
+
footnotes?: boolean;
|
|
125
|
+
html?: boolean;
|
|
126
|
+
mdx?: boolean;
|
|
127
|
+
tables?: boolean;
|
|
128
|
+
callouts?: boolean;
|
|
129
|
+
math?: boolean;
|
|
130
|
+
formatAnticipation?: FormatAnticipationConfig;
|
|
131
|
+
codeHighlighting?: CodeHighlightingMode;
|
|
132
|
+
outputMode?: CodeHighlightOutputMode;
|
|
133
|
+
liveCodeHighlighting?: boolean;
|
|
134
|
+
liveTokenization?: boolean;
|
|
135
|
+
emitHighlightTokens?: boolean;
|
|
136
|
+
emitDiffBlocks?: boolean;
|
|
137
|
+
};
|
|
138
|
+
performance?: {
|
|
139
|
+
frameBudgetMs?: number;
|
|
140
|
+
flushTimeoutMs?: number;
|
|
141
|
+
maxBatchesPerFlush?: number;
|
|
142
|
+
maxLowPriorityBatchesPerFlush?: number;
|
|
143
|
+
lowPriorityFrameBudgetMs?: number;
|
|
144
|
+
urgentQueueThreshold?: number;
|
|
145
|
+
batch?: "rAF" | "microtask" | "timeout";
|
|
146
|
+
historyLimit?: number;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Component registry that allows customization
|
|
152
|
+
*/
|
|
153
|
+
declare class ComponentRegistry {
|
|
154
|
+
private blockComponents;
|
|
155
|
+
private inlineComponents;
|
|
156
|
+
private htmlElements;
|
|
157
|
+
private tableElements;
|
|
158
|
+
private blockComponentMapCache;
|
|
159
|
+
private inlineComponentMapCache;
|
|
160
|
+
constructor(blockComponents?: Partial<BlockComponents>, inlineComponents?: Partial<InlineComponents>);
|
|
161
|
+
/**
|
|
162
|
+
* Update block components
|
|
163
|
+
*/
|
|
164
|
+
setBlockComponents(components: Partial<BlockComponents>): void;
|
|
165
|
+
/**
|
|
166
|
+
* Update inline components
|
|
167
|
+
*/
|
|
168
|
+
setInlineComponents(components: Partial<InlineComponents>): void;
|
|
169
|
+
/** Update HTML element mapping for html blocks */
|
|
170
|
+
setHtmlElements(map: Partial<HtmlElements>): void;
|
|
171
|
+
/** Update table element mapping for table blocks */
|
|
172
|
+
setTableElements(map: Partial<TableElements>): void;
|
|
173
|
+
/**
|
|
174
|
+
* Get block component
|
|
175
|
+
*/
|
|
176
|
+
getBlockComponent(type: string): React.ComponentType<Record<string, unknown>>;
|
|
177
|
+
/**
|
|
178
|
+
* Get inline components
|
|
179
|
+
*/
|
|
180
|
+
getInlineComponents(): InlineComponents;
|
|
181
|
+
getBlockComponentMap(): BlockComponents;
|
|
182
|
+
getInlineComponentMap(): InlineComponents;
|
|
183
|
+
getTableElements(): TableElements;
|
|
184
|
+
/**
|
|
185
|
+
* Render a block
|
|
186
|
+
*/
|
|
187
|
+
renderBlock(block: Block): React.ReactElement;
|
|
188
|
+
/**
|
|
189
|
+
* Get props for a block based on its type
|
|
190
|
+
*/
|
|
191
|
+
private getBlockProps;
|
|
192
|
+
/**
|
|
193
|
+
* Extract heading level from raw markdown
|
|
194
|
+
*/
|
|
195
|
+
private extractHeadingLevel;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface NodeRecord {
|
|
199
|
+
id: string;
|
|
200
|
+
type: string;
|
|
201
|
+
parentId: string | null;
|
|
202
|
+
children: string[];
|
|
203
|
+
props: Record<string, unknown>;
|
|
204
|
+
meta?: Record<string, unknown>;
|
|
205
|
+
range?: {
|
|
206
|
+
from: number;
|
|
207
|
+
to: number;
|
|
208
|
+
};
|
|
209
|
+
version: number;
|
|
210
|
+
block?: Block;
|
|
211
|
+
}
|
|
212
|
+
interface ApplyPatchesOptions {
|
|
213
|
+
coalesced?: boolean;
|
|
214
|
+
metrics?: CoalescingMetrics | null;
|
|
215
|
+
captureMetrics?: boolean;
|
|
216
|
+
allowEmpty?: boolean;
|
|
217
|
+
}
|
|
218
|
+
interface RendererStore {
|
|
219
|
+
reset(blocks: Block[]): void;
|
|
220
|
+
applyPatches(patches: Patch[], options?: ApplyPatchesOptions): Set<string>;
|
|
221
|
+
getBlocks(): ReadonlyArray<Block>;
|
|
222
|
+
getVersion(): number;
|
|
223
|
+
getNode(id: string): NodeRecord | undefined;
|
|
224
|
+
getNodeWithVersion(id: string): {
|
|
225
|
+
version: number;
|
|
226
|
+
node?: NodeRecord;
|
|
227
|
+
};
|
|
228
|
+
getChildren(id: string): ReadonlyArray<string>;
|
|
229
|
+
getChildrenWithVersion(id: string): {
|
|
230
|
+
version: number;
|
|
231
|
+
children: ReadonlyArray<string>;
|
|
232
|
+
};
|
|
233
|
+
subscribe(listener: () => void): () => void;
|
|
234
|
+
getLastCoalescingMetrics(): CoalescingMetrics | null;
|
|
235
|
+
}
|
|
236
|
+
declare function createRendererStore(initialBlocks?: Block[]): RendererStore;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* React component for rendering markdown blocks
|
|
240
|
+
*/
|
|
241
|
+
declare const MarkdownBlocksRenderer: React.NamedExoticComponent<{
|
|
242
|
+
blocks: ReadonlyArray<Block>;
|
|
243
|
+
componentRegistry: ComponentRegistry;
|
|
244
|
+
className?: string;
|
|
245
|
+
style?: React.CSSProperties;
|
|
246
|
+
store?: ReturnType<typeof createRendererStore>;
|
|
247
|
+
}>;
|
|
248
|
+
|
|
249
|
+
export { type BlockComponents, ComponentRegistry, type HtmlElements, type InlineComponents, type InlineHtmlRenderer, type InlineHtmlRendererMap, MarkdownBlocksRenderer, type RendererConfig, type TableElements, createRendererStore };
|