markstream-react 0.0.50 → 0.0.53
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 +173 -106
- package/dist/Tooltip-DSM4ImfZ.js +207 -0
- package/dist/codeBlockExtraProps-RaPzFq78.js +3 -0
- package/dist/index-D0DspXy9.js +85 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/markstream-react.css +1 -1
- package/dist/next.d.ts +41 -19
- package/dist/next.js +1 -1
- package/dist/server.d.ts +67 -45
- package/dist/server.js +1 -1
- package/dist/tailwind.cjs +4 -0
- package/dist/tailwind.d.ts +2 -0
- package/dist/tailwind.js +2 -0
- package/dist/types/components/AdmonitionNode/AdmonitionNode.d.ts +2 -1
- package/dist/types/components/BlockquoteNode/BlockquoteNode.d.ts +2 -1
- package/dist/types/components/CheckboxNode/CheckboxNode.d.ts +2 -1
- package/dist/types/components/CodeBlockNode/CodeBlockNode.d.ts +2 -1
- package/dist/types/components/CodeBlockNode/PreCodeNode.d.ts +2 -1
- package/dist/types/components/D2BlockNode/D2BlockNode.d.ts +2 -1
- package/dist/types/components/DefinitionListNode/DefinitionListNode.d.ts +2 -1
- package/dist/types/components/EmojiNode/EmojiNode.d.ts +2 -1
- package/dist/types/components/EmphasisNode/EmphasisNode.d.ts +2 -1
- package/dist/types/components/FootnoteAnchorNode/FootnoteAnchorNode.d.ts +2 -1
- package/dist/types/components/FootnoteNode/FootnoteNode.d.ts +2 -1
- package/dist/types/components/FootnoteReferenceNode/FootnoteReferenceNode.d.ts +2 -1
- package/dist/types/components/HardBreakNode/HardBreakNode.d.ts +2 -1
- package/dist/types/components/HeadingNode/HeadingNode.d.ts +2 -1
- package/dist/types/components/HighlightNode/HighlightNode.d.ts +2 -1
- package/dist/types/components/HtmlBlockNode/HtmlBlockNode.d.ts +1 -1
- package/dist/types/components/HtmlInlineNode/HtmlInlineNode.d.ts +6 -2
- package/dist/types/components/ImageNode/ImageNode.d.ts +1 -1
- package/dist/types/components/InfographicBlockNode/InfographicBlockNode.d.ts +2 -1
- package/dist/types/components/InlineCodeNode/InlineCodeNode.d.ts +2 -1
- package/dist/types/components/InsertNode/InsertNode.d.ts +2 -1
- package/dist/types/components/LinkNode/LinkNode.d.ts +2 -1
- package/dist/types/components/ListItemNode/ListItemNode.d.ts +2 -1
- package/dist/types/components/ListNode/ListNode.d.ts +2 -1
- package/dist/types/components/MarkdownCodeBlockNode/MarkdownCodeBlockNode.d.ts +2 -1
- package/dist/types/components/Math/MathBlockNode.d.ts +1 -1
- package/dist/types/components/Math/MathInlineNode.d.ts +1 -1
- package/dist/types/components/MermaidBlockNode/MermaidBlockNode.d.ts +2 -1
- package/dist/types/components/NodeRenderer/FallbackComponent.d.ts +2 -1
- package/dist/types/components/NodeRenderer.d.ts +2 -1
- package/dist/types/components/ParagraphNode/ParagraphNode.d.ts +2 -1
- package/dist/types/components/ReferenceNode/ReferenceNode.d.ts +1 -1
- package/dist/types/components/StrikethroughNode/StrikethroughNode.d.ts +2 -1
- package/dist/types/components/StrongNode/StrongNode.d.ts +2 -1
- package/dist/types/components/SubscriptNode/SubscriptNode.d.ts +2 -1
- package/dist/types/components/SuperscriptNode/SuperscriptNode.d.ts +2 -1
- package/dist/types/components/TableNode/TableNode.d.ts +2 -1
- package/dist/types/components/TextNode/TextNode.d.ts +2 -1
- package/dist/types/components/ThematicBreakNode/ThematicBreakNode.d.ts +2 -1
- package/dist/types/components/VmrContainerNode/VmrContainerNode.d.ts +2 -1
- package/dist/types/context/viewportPriority.d.ts +1 -1
- package/dist/types/customComponents.d.ts +20 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/next.d.ts +7 -3
- package/dist/types/renderers/renderChildren.d.ts +1 -1
- package/dist/types/renderers/renderNode.d.ts +1 -1
- package/dist/types/server-renderer/index.d.ts +45 -41
- package/dist/types/server.d.ts +2 -2
- package/dist/types/styles.d.ts +1 -0
- package/dist/types/types.d.ts +8 -3
- package/dist/types/utils/customHtmlTag.d.ts +5 -4
- package/dist/types/utils/htmlToReact.d.ts +17 -6
- package/package.json +41 -42
- package/dist/Tooltip-D786qxIk.js +0 -207
- package/dist/codeBlockExtraProps-7n9FWJXk.js +0 -3
- package/dist/index-o_DISWz2.js +0 -85
- package/dist/tailwind.ts +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MathBlockNodeProps } from '../../types/component-props';
|
|
2
|
-
export declare function MathBlockNode({ node }: MathBlockNodeProps): import("react
|
|
2
|
+
export declare function MathBlockNode({ node }: MathBlockNodeProps): import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MathInlineNodeProps } from '../../types/component-props';
|
|
2
|
-
export declare function MathInlineNode({ node }: MathInlineNodeProps): import("react
|
|
2
|
+
export declare function MathInlineNode({ node }: MathInlineNodeProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MermaidBlockEvent, MermaidBlockNodeProps } from '../../types/component-props';
|
|
2
|
+
import { default as React } from 'react';
|
|
2
3
|
export interface MermaidBlockNodeReactEvents {
|
|
3
4
|
onCopy?: (code: string) => void;
|
|
4
5
|
onExport?: (event: MermaidBlockEvent<{
|
|
@@ -12,4 +13,4 @@ export interface MermaidBlockNodeReactEvents {
|
|
|
12
13
|
target: 'preview' | 'source';
|
|
13
14
|
}>) => void;
|
|
14
15
|
}
|
|
15
|
-
export declare function MermaidBlockNode(rawProps: MermaidBlockNodeProps & MermaidBlockNodeReactEvents):
|
|
16
|
+
export declare function MermaidBlockNode(rawProps: MermaidBlockNodeProps & MermaidBlockNodeReactEvents): React.JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { default as React } from 'react';
|
|
2
3
|
export declare function FallbackComponent(props: NodeComponentProps<{
|
|
3
4
|
type: string;
|
|
4
|
-
}>):
|
|
5
|
+
}>): React.JSX.Element;
|
|
5
6
|
export default FallbackComponent;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { HtmlComponentMap, StreamingComponentMap } from '../customComponents';
|
|
1
2
|
import { NodeRendererProps } from '../types';
|
|
2
3
|
import { default as React } from 'react';
|
|
3
|
-
export declare
|
|
4
|
+
export declare function NodeRenderer<TStreamingComponents extends StreamingComponentMap = StreamingComponentMap, THtmlComponents extends Record<string, any> = HtmlComponentMap>(rawProps: NodeRendererProps<TStreamingComponents, THtmlComponents>): React.JSX.Element;
|
|
4
5
|
export default NodeRenderer;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParsedNode } from 'stream-markdown-parser';
|
|
2
2
|
import { NodeComponentProps } from '../../types/node-component';
|
|
3
|
+
import { default as React } from 'react';
|
|
3
4
|
export declare function ParagraphNode(props: NodeComponentProps<{
|
|
4
5
|
type: 'paragraph';
|
|
5
6
|
children?: ParsedNode[];
|
|
6
|
-
}>):
|
|
7
|
+
}>): React.JSX.Element;
|
|
7
8
|
export default ParagraphNode;
|
|
@@ -11,5 +11,5 @@ export declare function ReferenceNode(props: NodeComponentProps<{
|
|
|
11
11
|
}> & {
|
|
12
12
|
messageId?: string;
|
|
13
13
|
threadId?: string;
|
|
14
|
-
} & ReferenceNodeHandlers):
|
|
14
|
+
} & ReferenceNodeHandlers): React.JSX.Element;
|
|
15
15
|
export default ReferenceNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { default as React } from 'react';
|
|
2
3
|
export declare function StrikethroughNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'strikethrough';
|
|
4
|
-
}>):
|
|
5
|
+
}>): React.JSX.Element;
|
|
5
6
|
export default StrikethroughNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { default as React } from 'react';
|
|
2
3
|
export declare function StrongNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'strong';
|
|
4
|
-
}>):
|
|
5
|
+
}>): React.JSX.Element;
|
|
5
6
|
export default StrongNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { default as React } from 'react';
|
|
2
3
|
export declare function SubscriptNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'subscript';
|
|
4
|
-
}>):
|
|
5
|
+
}>): React.JSX.Element;
|
|
5
6
|
export default SubscriptNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { default as React } from 'react';
|
|
2
3
|
export declare function SuperscriptNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'superscript';
|
|
4
|
-
}>):
|
|
5
|
+
}>): React.JSX.Element;
|
|
5
6
|
export default SuperscriptNode;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { TableRowNode } from 'stream-markdown-parser';
|
|
2
2
|
import { NodeComponentProps } from '../../types/node-component';
|
|
3
|
+
import { default as React } from 'react';
|
|
3
4
|
export declare function TableNode(props: NodeComponentProps<{
|
|
4
5
|
type: 'table';
|
|
5
6
|
header?: TableRowNode;
|
|
6
7
|
rows?: TableRowNode[];
|
|
7
8
|
loading?: boolean;
|
|
8
|
-
}>):
|
|
9
|
+
}>): React.JSX.Element;
|
|
9
10
|
export default TableNode;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { default as React } from 'react';
|
|
2
3
|
export declare function TextNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'text';
|
|
4
5
|
content: string;
|
|
5
6
|
center?: boolean;
|
|
6
|
-
}>):
|
|
7
|
+
}>): React.JSX.Element;
|
|
7
8
|
export default TextNode;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ParsedNode } from 'stream-markdown-parser';
|
|
2
2
|
import { NodeComponentProps } from '../../types/node-component';
|
|
3
|
+
import { default as React } from 'react';
|
|
3
4
|
export declare function VmrContainerNode(props: NodeComponentProps<{
|
|
4
5
|
type: 'vmr_container';
|
|
5
6
|
name: string;
|
|
6
7
|
attrs?: Record<string, string> | [string, string | null][] | null;
|
|
7
8
|
children?: ParsedNode[];
|
|
8
|
-
}>):
|
|
9
|
+
}>): React.JSX.Element;
|
|
9
10
|
export default VmrContainerNode;
|
|
@@ -13,5 +13,5 @@ export interface ViewportPriorityProviderProps {
|
|
|
13
13
|
enabled?: boolean;
|
|
14
14
|
children: React.ReactNode;
|
|
15
15
|
}
|
|
16
|
-
export declare function ViewportPriorityProvider({ getRoot, enabled, children }: ViewportPriorityProviderProps):
|
|
16
|
+
export declare function ViewportPriorityProvider({ getRoot, enabled, children }: ViewportPriorityProviderProps): React.JSX.Element;
|
|
17
17
|
export declare function useViewportPriority(): RegisterViewportFn;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
1
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
import { NodeComponentProps } from './types/node-component';
|
|
2
3
|
export type CustomComponentDisplayMode = 'inline' | 'block';
|
|
3
4
|
export type MarkstreamCustomComponent<P = never> = ComponentType<P> & {
|
|
4
5
|
markstreamDisplay?: CustomComponentDisplayMode;
|
|
5
6
|
};
|
|
6
7
|
export type CustomComponentMap = Record<string, MarkstreamCustomComponent>;
|
|
8
|
+
export type StreamingComponent<TNode = any> = ComponentType<NodeComponentProps<TNode>>;
|
|
9
|
+
export type StreamingComponentMap = Record<string, StreamingComponent<any>>;
|
|
10
|
+
export type HtmlComponent<P extends object = any> = ComponentType<PropsWithChildren<P>>;
|
|
11
|
+
export type HtmlComponentMap = Record<string, HtmlComponent<any>>;
|
|
12
|
+
type IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
13
|
+
type ComponentProps<T> = T extends ComponentType<infer P> ? P : T extends (props: infer P) => any ? P : never;
|
|
14
|
+
export type StreamingComponentDefinitions<T extends Record<string, any>> = {
|
|
15
|
+
[K in keyof T]: ComponentProps<T[K]> extends infer P ? IsAny<P> extends true ? T[K] : P extends NodeComponentProps<any> ? NodeComponentProps<any> extends P ? T[K] : never : never : never;
|
|
16
|
+
};
|
|
17
|
+
type ParserComponentOnlyProp = Exclude<keyof NodeComponentProps<any>, 'children' | 'node'>;
|
|
18
|
+
export type HtmlComponentDefinitions<T extends Record<string, any>> = {
|
|
19
|
+
[K in keyof T]: ComponentProps<T[K]> extends infer P ? IsAny<P> extends true ? T[K] : Extract<keyof P, ParserComponentOnlyProp> extends never ? T[K] : never : never;
|
|
20
|
+
};
|
|
7
21
|
export declare function subscribeCustomComponents(listener: () => void): () => void;
|
|
8
22
|
export declare function getCustomComponentsRevision(): number;
|
|
9
23
|
export declare function setCustomComponents(id: string, mapping: CustomComponentMap): void;
|
|
@@ -15,3 +29,8 @@ export declare function getCustomComponentDisplay(component: ComponentType<never
|
|
|
15
29
|
export declare function withMarkstreamComponentDisplay<T extends ComponentType<never>>(component: T, display: CustomComponentDisplayMode): T & {
|
|
16
30
|
markstreamDisplay: CustomComponentDisplayMode;
|
|
17
31
|
};
|
|
32
|
+
export declare function defineStreamingComponents<const T extends Record<string, ComponentType<any>>>(components: T & StreamingComponentDefinitions<T>): T & StreamingComponentDefinitions<T>;
|
|
33
|
+
export declare function defineHtmlComponents<const T extends Record<string, ComponentType<any>>>(components: T & HtmlComponentDefinitions<T>): T & HtmlComponentDefinitions<T>;
|
|
34
|
+
export declare function normalizeComponentMap<T>(mapping?: Record<string, T>): Record<string, T>;
|
|
35
|
+
export declare function warnComponentMapConflicts(streamingComponents: StreamingComponentMap, htmlComponents: HtmlComponentMap, warnedTags: Set<string>): void;
|
|
36
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -51,8 +51,8 @@ export { ThematicBreakNode } from './components/ThematicBreakNode/ThematicBreakN
|
|
|
51
51
|
export { Tooltip } from './components/Tooltip/Tooltip';
|
|
52
52
|
export type { TooltipPlacement, TooltipProps } from './components/Tooltip/Tooltip';
|
|
53
53
|
export { VmrContainerNode } from './components/VmrContainerNode/VmrContainerNode';
|
|
54
|
-
export { clearGlobalCustomComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
55
|
-
export type { CustomComponentDisplayMode, MarkstreamCustomComponent, } from './customComponents';
|
|
54
|
+
export { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
55
|
+
export type { CustomComponentDisplayMode, HtmlComponent, HtmlComponentMap, MarkstreamCustomComponent, StreamingComponent, StreamingComponentMap, } from './customComponents';
|
|
56
56
|
export { useSmoothMarkdownStream } from './hooks/useSmoothMarkdownStream';
|
|
57
57
|
export type { SmoothMarkdownStreamOptions, SmoothMarkdownStreamSnapshot, } from './hooks/useSmoothMarkdownStream';
|
|
58
58
|
export * from './i18n/useSafeI18n';
|
package/dist/types/next.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D2Loader, disableD2, enableD2, isD2Enabled, setD2Loader } from './components/D2BlockNode/d2';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { clearGlobalCustomComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents } from './customComponents';
|
|
3
|
+
import { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents } from './customComponents';
|
|
4
4
|
export declare const AdmonitionNode: {
|
|
5
5
|
(props: import('./types/node-component').NodeComponentProps<{
|
|
6
6
|
type: "admonition";
|
|
@@ -120,6 +120,9 @@ export declare const HtmlInlineNode: {
|
|
|
120
120
|
(props: import('./types/node-component').NodeComponentProps<{
|
|
121
121
|
type: "html_inline";
|
|
122
122
|
content?: string;
|
|
123
|
+
tag?: string;
|
|
124
|
+
attrs?: [string, string | null][] | null;
|
|
125
|
+
children?: import('stream-markdown-parser').ParsedNode[];
|
|
123
126
|
}>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
124
127
|
displayName: string;
|
|
125
128
|
};
|
|
@@ -190,7 +193,7 @@ export declare const MermaidBlockNode: {
|
|
|
190
193
|
displayName: string;
|
|
191
194
|
};
|
|
192
195
|
export declare const NodeRenderer: {
|
|
193
|
-
(props: import('./types').NodeRendererProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
196
|
+
(props: import('./types').NodeRendererProps<import('./customComponents').StreamingComponentMap, Record<string, any>>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
194
197
|
displayName: string;
|
|
195
198
|
};
|
|
196
199
|
export declare const FallbackComponent: {
|
|
@@ -283,13 +286,14 @@ export declare const VmrContainerNode: {
|
|
|
283
286
|
export default NodeRenderer;
|
|
284
287
|
export type { D2Loader };
|
|
285
288
|
export { disableD2, enableD2, isD2Enabled, setD2Loader };
|
|
286
|
-
export { clearGlobalCustomComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents, };
|
|
289
|
+
export { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents, };
|
|
287
290
|
export type { HtmlPreviewFrameProps } from './components/CodeBlockNode/HtmlPreviewFrame';
|
|
288
291
|
export * from './components/D2BlockNode/d2';
|
|
289
292
|
export type { LinkNodeStyleProps } from './components/LinkNode/LinkNode';
|
|
290
293
|
export type { ListItemNodeProps } from './components/ListItemNode/ListItemNode';
|
|
291
294
|
export type { MarkdownCodeBlockNodeProps } from './components/MarkdownCodeBlockNode/MarkdownCodeBlockNode';
|
|
292
295
|
export type { TooltipPlacement, TooltipProps } from './components/Tooltip/Tooltip';
|
|
296
|
+
export type { CustomComponentDisplayMode, HtmlComponent, HtmlComponentMap, MarkstreamCustomComponent, StreamingComponent, StreamingComponentMap, } from './customComponents';
|
|
293
297
|
export * from './i18n/useSafeI18n';
|
|
294
298
|
export * from './renderers/renderNode';
|
|
295
299
|
export type { NodeRendererCodeBlockProps, NodeRendererProps } from './types';
|
|
@@ -4,4 +4,4 @@ import { RenderContext, RenderNodeFn } from '../types';
|
|
|
4
4
|
export declare const BLOCK_LEVEL_TYPES: Set<string>;
|
|
5
5
|
export declare function tokenAttrsToProps(attrs?: [string, string | null][]): Record<string, string | true>;
|
|
6
6
|
export declare function renderNodeChildren(children: ParsedNode[] | undefined, ctx: RenderContext, prefix: string, renderNode: RenderNodeFn): ReactNode[];
|
|
7
|
-
export declare function renderInline(children: ParsedNode[] | undefined, ctx: RenderContext, prefix: string, renderNode: RenderNodeFn): import("react
|
|
7
|
+
export declare function renderInline(children: ParsedNode[] | undefined, ctx: RenderContext, prefix: string, renderNode: RenderNodeFn): import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ParsedNode } from 'stream-markdown-parser';
|
|
2
2
|
import { RenderContext } from '../types';
|
|
3
3
|
import { default as React } from 'react';
|
|
4
|
-
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext):
|
|
4
|
+
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext): any;
|
|
@@ -2,6 +2,7 @@ import { DefinitionItemNode as DefinitionItemNodeType, ListItemNode as ListItemN
|
|
|
2
2
|
import { HtmlPreviewFrameProps } from '../components/CodeBlockNode/HtmlPreviewFrame';
|
|
3
3
|
import { MarkdownCodeBlockNodeProps } from '../components/MarkdownCodeBlockNode/MarkdownCodeBlockNode';
|
|
4
4
|
import { TooltipProps } from '../components/Tooltip/Tooltip';
|
|
5
|
+
import { HtmlComponentMap, StreamingComponentMap } from '../customComponents';
|
|
5
6
|
import { NodeRendererProps, RenderContext } from '../types';
|
|
6
7
|
import { CodeBlockNodeProps, D2BlockNodeProps, ImageNodeProps, InfographicBlockNodeProps, LinkNodeProps, MathBlockNodeProps, MathInlineNodeProps, MermaidBlockNodeProps, PreCodeNodeProps } from '../types/component-props';
|
|
7
8
|
import { NodeComponentProps } from '../types/node-component';
|
|
@@ -10,56 +11,56 @@ export declare function TextNode(props: NodeComponentProps<{
|
|
|
10
11
|
type: 'text';
|
|
11
12
|
content: string;
|
|
12
13
|
center?: boolean;
|
|
13
|
-
}>):
|
|
14
|
+
}>): React.JSX.Element;
|
|
14
15
|
export declare function ParagraphNode(props: NodeComponentProps<{
|
|
15
16
|
type: 'paragraph';
|
|
16
17
|
children?: ParsedNode[];
|
|
17
|
-
}>):
|
|
18
|
+
}>): React.JSX.Element;
|
|
18
19
|
export declare function HeadingNode(props: NodeComponentProps<{
|
|
19
20
|
type: 'heading';
|
|
20
21
|
level?: number;
|
|
21
22
|
children?: ParsedNode[];
|
|
22
23
|
attrs?: Record<string, string | boolean>;
|
|
23
|
-
}>):
|
|
24
|
+
}>): React.JSX.Element;
|
|
24
25
|
export declare function BlockquoteNode(props: NodeComponentProps<{
|
|
25
26
|
type: 'blockquote';
|
|
26
27
|
children?: ParsedNode[];
|
|
27
|
-
}>):
|
|
28
|
+
}>): React.JSX.Element;
|
|
28
29
|
export declare function ListItemNode(props: NodeComponentProps<{
|
|
29
30
|
type: 'list_item';
|
|
30
31
|
children?: ParsedNode[];
|
|
31
32
|
}> & {
|
|
32
33
|
value?: number;
|
|
33
|
-
}):
|
|
34
|
+
}): React.JSX.Element;
|
|
34
35
|
export declare function ListNode(props: NodeComponentProps<{
|
|
35
36
|
type: 'list';
|
|
36
37
|
ordered?: boolean;
|
|
37
38
|
start?: number;
|
|
38
39
|
items?: ListItemNodeType[];
|
|
39
|
-
}>):
|
|
40
|
+
}>): React.JSX.Element;
|
|
40
41
|
export declare function TableNode(props: NodeComponentProps<{
|
|
41
42
|
type: 'table';
|
|
42
43
|
header?: TableRowNodeType;
|
|
43
44
|
rows?: TableRowNodeType[];
|
|
44
45
|
loading?: boolean;
|
|
45
|
-
}>):
|
|
46
|
+
}>): React.JSX.Element;
|
|
46
47
|
export declare function DefinitionListNode(props: NodeComponentProps<{
|
|
47
48
|
type: 'definition_list';
|
|
48
49
|
items?: DefinitionItemNodeType[];
|
|
49
|
-
}>):
|
|
50
|
+
}>): React.JSX.Element;
|
|
50
51
|
export declare function FootnoteNode(props: NodeComponentProps<{
|
|
51
52
|
type: 'footnote';
|
|
52
53
|
id: string;
|
|
53
54
|
children?: ParsedNode[];
|
|
54
|
-
}>):
|
|
55
|
+
}>): React.JSX.Element;
|
|
55
56
|
export declare function FootnoteReferenceNode(props: NodeComponentProps<{
|
|
56
57
|
type: 'footnote_reference';
|
|
57
58
|
id: string;
|
|
58
|
-
}>):
|
|
59
|
+
}>): React.JSX.Element;
|
|
59
60
|
export declare function FootnoteAnchorNode(props: NodeComponentProps<{
|
|
60
61
|
type: 'footnote_anchor';
|
|
61
62
|
id: string;
|
|
62
|
-
}>):
|
|
63
|
+
}>): React.JSX.Element;
|
|
63
64
|
export declare function AdmonitionNode(props: NodeComponentProps<{
|
|
64
65
|
type: 'admonition';
|
|
65
66
|
kind?: string;
|
|
@@ -67,54 +68,54 @@ export declare function AdmonitionNode(props: NodeComponentProps<{
|
|
|
67
68
|
children?: ParsedNode[];
|
|
68
69
|
collapsible?: boolean;
|
|
69
70
|
open?: boolean;
|
|
70
|
-
}>):
|
|
71
|
+
}>): React.JSX.Element;
|
|
71
72
|
export declare function CheckboxNode(props: NodeComponentProps<{
|
|
72
73
|
type: 'checkbox' | 'checkbox_input';
|
|
73
74
|
checked?: boolean;
|
|
74
|
-
}>):
|
|
75
|
+
}>): React.JSX.Element;
|
|
75
76
|
export declare function EmojiNode(props: NodeComponentProps<{
|
|
76
77
|
type: 'emoji';
|
|
77
78
|
name: string;
|
|
78
79
|
markup?: string;
|
|
79
|
-
}>):
|
|
80
|
+
}>): React.JSX.Element;
|
|
80
81
|
export declare function StrongNode(props: NodeComponentProps<{
|
|
81
82
|
type: 'strong';
|
|
82
83
|
children?: ParsedNode[];
|
|
83
|
-
}>):
|
|
84
|
+
}>): React.JSX.Element;
|
|
84
85
|
export declare function EmphasisNode(props: NodeComponentProps<{
|
|
85
86
|
type: 'emphasis';
|
|
86
87
|
children?: ParsedNode[];
|
|
87
|
-
}>):
|
|
88
|
+
}>): React.JSX.Element;
|
|
88
89
|
export declare function StrikethroughNode(props: NodeComponentProps<{
|
|
89
90
|
type: 'strikethrough';
|
|
90
91
|
children?: ParsedNode[];
|
|
91
|
-
}>):
|
|
92
|
+
}>): React.JSX.Element;
|
|
92
93
|
export declare function HighlightNode(props: NodeComponentProps<{
|
|
93
94
|
type: 'highlight';
|
|
94
95
|
children?: ParsedNode[];
|
|
95
|
-
}>):
|
|
96
|
+
}>): React.JSX.Element;
|
|
96
97
|
export declare function InsertNode(props: NodeComponentProps<{
|
|
97
98
|
type: 'insert';
|
|
98
99
|
children?: ParsedNode[];
|
|
99
|
-
}>):
|
|
100
|
+
}>): React.JSX.Element;
|
|
100
101
|
export declare function SubscriptNode(props: NodeComponentProps<{
|
|
101
102
|
type: 'subscript';
|
|
102
103
|
children?: ParsedNode[];
|
|
103
|
-
}>):
|
|
104
|
+
}>): React.JSX.Element;
|
|
104
105
|
export declare function SuperscriptNode(props: NodeComponentProps<{
|
|
105
106
|
type: 'superscript';
|
|
106
107
|
children?: ParsedNode[];
|
|
107
|
-
}>):
|
|
108
|
+
}>): React.JSX.Element;
|
|
108
109
|
export declare function HardBreakNode(_props: NodeComponentProps<{
|
|
109
110
|
type: 'hardbreak';
|
|
110
|
-
}>):
|
|
111
|
+
}>): React.JSX.Element;
|
|
111
112
|
export declare function ThematicBreakNode(_props?: NodeComponentProps<{
|
|
112
113
|
type: 'thematic_break';
|
|
113
|
-
}>):
|
|
114
|
+
}>): React.JSX.Element;
|
|
114
115
|
export declare function InlineCodeNode(props: NodeComponentProps<{
|
|
115
116
|
type: 'inline_code';
|
|
116
117
|
code: string;
|
|
117
|
-
}>):
|
|
118
|
+
}>): React.JSX.Element;
|
|
118
119
|
export declare function LinkNode(props: NodeComponentProps<LinkNodeProps['node']> & {
|
|
119
120
|
showTooltip?: boolean;
|
|
120
121
|
color?: string;
|
|
@@ -124,46 +125,49 @@ export declare function LinkNode(props: NodeComponentProps<LinkNodeProps['node']
|
|
|
124
125
|
animationOpacity?: number;
|
|
125
126
|
animationTiming?: string;
|
|
126
127
|
animationIteration?: string | number;
|
|
127
|
-
}):
|
|
128
|
-
export declare function ImageNode(rawProps: ImageNodeProps):
|
|
129
|
-
export declare function PreCodeNode({ node }: PreCodeNodeProps):
|
|
130
|
-
export declare function CodeBlockNode(props: CodeBlockNodeProps):
|
|
131
|
-
export declare function MarkdownCodeBlockNode(props: MarkdownCodeBlockNodeProps):
|
|
132
|
-
export declare function MermaidBlockNode(props: MermaidBlockNodeProps):
|
|
133
|
-
export declare function D2BlockNode(props: D2BlockNodeProps):
|
|
134
|
-
export declare function InfographicBlockNode(props: InfographicBlockNodeProps):
|
|
135
|
-
export declare function MathBlockNode({ node }: MathBlockNodeProps):
|
|
136
|
-
export declare function MathInlineNode({ node }: MathInlineNodeProps):
|
|
128
|
+
}): React.JSX.Element;
|
|
129
|
+
export declare function ImageNode(rawProps: ImageNodeProps): React.JSX.Element;
|
|
130
|
+
export declare function PreCodeNode({ node }: PreCodeNodeProps): React.JSX.Element;
|
|
131
|
+
export declare function CodeBlockNode(props: CodeBlockNodeProps): React.JSX.Element;
|
|
132
|
+
export declare function MarkdownCodeBlockNode(props: MarkdownCodeBlockNodeProps): React.JSX.Element;
|
|
133
|
+
export declare function MermaidBlockNode(props: MermaidBlockNodeProps): React.JSX.Element;
|
|
134
|
+
export declare function D2BlockNode(props: D2BlockNodeProps): React.JSX.Element;
|
|
135
|
+
export declare function InfographicBlockNode(props: InfographicBlockNodeProps): React.JSX.Element;
|
|
136
|
+
export declare function MathBlockNode({ node }: MathBlockNodeProps): React.JSX.Element;
|
|
137
|
+
export declare function MathInlineNode({ node }: MathInlineNodeProps): React.JSX.Element;
|
|
137
138
|
export declare function ReferenceNode(props: NodeComponentProps<{
|
|
138
139
|
type: 'reference';
|
|
139
140
|
id: string;
|
|
140
141
|
}> & {
|
|
141
142
|
messageId?: string;
|
|
142
143
|
threadId?: string;
|
|
143
|
-
}):
|
|
144
|
+
}): React.JSX.Element;
|
|
144
145
|
export declare function HtmlBlockNode(props: NodeComponentProps<{
|
|
145
146
|
type: 'html_block';
|
|
146
147
|
content?: string;
|
|
147
148
|
tag?: string;
|
|
148
149
|
attrs?: [string, string | null][] | null;
|
|
149
150
|
children?: ParsedNode[];
|
|
150
|
-
}>):
|
|
151
|
+
}>): React.JSX.Element;
|
|
151
152
|
export declare function HtmlInlineNode(props: NodeComponentProps<{
|
|
152
153
|
type: 'html_inline';
|
|
153
154
|
content?: string;
|
|
154
|
-
|
|
155
|
+
tag?: string;
|
|
156
|
+
attrs?: [string, string | null][] | null;
|
|
157
|
+
children?: ParsedNode[];
|
|
158
|
+
}>): React.JSX.Element;
|
|
155
159
|
export declare function VmrContainerNode(props: NodeComponentProps<{
|
|
156
160
|
type: 'vmr_container';
|
|
157
161
|
name: string;
|
|
158
162
|
attrs?: Record<string, string> | [string, string | null][] | null;
|
|
159
163
|
children?: ParsedNode[];
|
|
160
|
-
}>):
|
|
164
|
+
}>): React.JSX.Element;
|
|
161
165
|
export declare function Tooltip(_props: TooltipProps): any;
|
|
162
166
|
export declare function HtmlPreviewFrame(_props: HtmlPreviewFrameProps): any;
|
|
163
167
|
export declare function FallbackComponent(props: NodeComponentProps<{
|
|
164
168
|
type: string;
|
|
165
|
-
}>):
|
|
166
|
-
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext):
|
|
167
|
-
export declare function NodeRenderer(props: NodeRendererProps):
|
|
169
|
+
}>): React.JSX.Element;
|
|
170
|
+
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext): any;
|
|
171
|
+
export declare function NodeRenderer<TStreamingComponents extends StreamingComponentMap = StreamingComponentMap, THtmlComponents extends Record<string, any> = HtmlComponentMap>(props: NodeRendererProps<TStreamingComponents, THtmlComponents>): React.JSX.Element;
|
|
168
172
|
export { CodeBlockNode as ReactCodeBlockNode };
|
|
169
173
|
export default NodeRenderer;
|
package/dist/types/server.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export type { LinkNodeStyleProps } from './components/LinkNode/LinkNode';
|
|
|
3
3
|
export type { ListItemNodeProps } from './components/ListItemNode/ListItemNode';
|
|
4
4
|
export type { MarkdownCodeBlockNodeProps } from './components/MarkdownCodeBlockNode/MarkdownCodeBlockNode';
|
|
5
5
|
export type { TooltipPlacement, TooltipProps } from './components/Tooltip/Tooltip';
|
|
6
|
-
export { clearGlobalCustomComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
7
|
-
export type { CustomComponentDisplayMode, MarkstreamCustomComponent } from './customComponents';
|
|
6
|
+
export { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
7
|
+
export type { CustomComponentDisplayMode, HtmlComponent, HtmlComponentMap, MarkstreamCustomComponent, StreamingComponent, StreamingComponentMap, } from './customComponents';
|
|
8
8
|
export { AdmonitionNode } from './server-renderer';
|
|
9
9
|
export { BlockquoteNode } from './server-renderer';
|
|
10
10
|
export { CheckboxNode } from './server-renderer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
1
|
+
import { default as React, ComponentType } from 'react';
|
|
2
2
|
import { BaseNode, HtmlPolicy, MarkdownIt, ParsedNode, ParseOptions } from 'stream-markdown-parser';
|
|
3
|
-
import { CustomComponentMap } from './customComponents';
|
|
3
|
+
import { CustomComponentMap, HtmlComponentDefinitions, HtmlComponentMap, StreamingComponentDefinitions, StreamingComponentMap } from './customComponents';
|
|
4
4
|
import { SmoothMarkdownStreamOptions } from './hooks/useSmoothMarkdownStream';
|
|
5
5
|
import { CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockNodeProps, CodeBlockPreviewPayload, D2BlockNodeProps, InfographicBlockNodeProps, MermaidBlockNodeProps, ShikiCodeBlockProps } from './types/component-props';
|
|
6
6
|
type NodeRendererCodeBlockThemes = CodeBlockNodeProps['themes'] | ShikiCodeBlockProps['themes'];
|
|
7
7
|
export type NodeRendererCodeBlockProps = Partial<Omit<CodeBlockNodeProps, 'node' | 'themes'>> & Partial<Omit<ShikiCodeBlockProps, 'themes'>> & {
|
|
8
8
|
themes?: NodeRendererCodeBlockThemes;
|
|
9
9
|
} & Record<string, unknown>;
|
|
10
|
-
export interface NodeRendererProps {
|
|
10
|
+
export interface NodeRendererProps<TStreamingComponents extends Record<string, ComponentType<any>> = StreamingComponentMap, THtmlComponents extends Record<string, any> = HtmlComponentMap> {
|
|
11
11
|
content?: string;
|
|
12
12
|
nodes?: readonly BaseNode[] | null;
|
|
13
13
|
/**
|
|
@@ -17,6 +17,8 @@ export interface NodeRendererProps {
|
|
|
17
17
|
final?: boolean;
|
|
18
18
|
parseOptions?: ParseOptions;
|
|
19
19
|
customMarkdownIt?: (md: MarkdownIt) => MarkdownIt;
|
|
20
|
+
streamingComponents?: TStreamingComponents & StreamingComponentDefinitions<TStreamingComponents>;
|
|
21
|
+
htmlComponents?: THtmlComponents & HtmlComponentDefinitions<THtmlComponents>;
|
|
20
22
|
/** Log parse/render timing stats (dev only). */
|
|
21
23
|
debugPerformance?: boolean;
|
|
22
24
|
/**
|
|
@@ -86,6 +88,7 @@ export interface NodeRendererProps {
|
|
|
86
88
|
export interface RenderContext {
|
|
87
89
|
customId?: string;
|
|
88
90
|
isDark?: boolean;
|
|
91
|
+
final?: boolean;
|
|
89
92
|
indexKey?: string;
|
|
90
93
|
typewriter?: boolean;
|
|
91
94
|
/** Enable/disable fade animations. Default: true */
|
|
@@ -93,6 +96,8 @@ export interface RenderContext {
|
|
|
93
96
|
textStreamState?: Map<string, string>;
|
|
94
97
|
streamRenderVersion?: number;
|
|
95
98
|
customComponents?: CustomComponentMap;
|
|
99
|
+
streamingComponents?: StreamingComponentMap;
|
|
100
|
+
htmlComponents?: HtmlComponentMap;
|
|
96
101
|
customHtmlTags?: readonly string[];
|
|
97
102
|
htmlPolicy?: HtmlPolicy;
|
|
98
103
|
codeBlockProps?: NodeRendererCodeBlockProps;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
1
2
|
import { ParsedNode } from 'stream-markdown-parser';
|
|
2
|
-
import { CustomComponentDisplayMode
|
|
3
|
+
import { CustomComponentDisplayMode } from '../customComponents';
|
|
3
4
|
export interface ResolvedCustomHtmlTag {
|
|
4
5
|
tag: string;
|
|
5
6
|
isWhitelisted: boolean;
|
|
6
|
-
component:
|
|
7
|
+
component: ComponentType<any> | null;
|
|
7
8
|
display: CustomComponentDisplayMode | undefined;
|
|
8
9
|
}
|
|
9
10
|
export declare function resolveCustomHtmlTag(node: Pick<ParsedNode, 'type'> & {
|
|
10
11
|
tag?: string | null;
|
|
11
12
|
content?: unknown;
|
|
12
|
-
}, customComponents:
|
|
13
|
+
}, customComponents: Record<string, ComponentType<any>>, customHtmlTags?: readonly string[]): ResolvedCustomHtmlTag | null;
|
|
13
14
|
export declare function isParagraphBreakingCustomHtmlNode(node: Pick<ParsedNode, 'type'> & {
|
|
14
15
|
tag?: string | null;
|
|
15
16
|
content?: unknown;
|
|
16
|
-
}, customComponents:
|
|
17
|
+
}, customComponents: Record<string, ComponentType<any>>, customHtmlTags?: readonly string[]): boolean;
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { HtmlPolicy, sanitizeHtmlAttrs as sanitizeHtmlAttrsBase, tokenizeHtml as tokenizeHtmlBase } from 'stream-markdown-parser';
|
|
3
|
-
import {
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { HtmlPolicy, ParsedNode, sanitizeHtmlAttrs as sanitizeHtmlAttrsBase, tokenizeHtml as tokenizeHtmlBase } from 'stream-markdown-parser';
|
|
3
|
+
import { RenderContext, RenderNodeFn } from '../types';
|
|
4
4
|
export type { HtmlToken } from 'stream-markdown-parser';
|
|
5
|
+
type HtmlReactComponentMap = Record<string, ComponentType<any>>;
|
|
6
|
+
type HtmlReactPropComponentMap = Record<string, ComponentType<any>>;
|
|
7
|
+
type HtmlReactNodeComponentMap = Record<string, ComponentType<any>>;
|
|
8
|
+
interface HtmlToReactOptions {
|
|
9
|
+
ctx?: RenderContext;
|
|
10
|
+
keyPrefix?: string;
|
|
11
|
+
nodeComponents?: HtmlReactNodeComponentMap;
|
|
12
|
+
propComponents?: HtmlReactPropComponentMap;
|
|
13
|
+
renderNode?: RenderNodeFn;
|
|
14
|
+
sourceNode?: ParsedNode;
|
|
15
|
+
}
|
|
5
16
|
export declare function normalizeDomAttrs(attrs: Record<string, string>): Record<string, unknown>;
|
|
6
17
|
export declare const tokenizeHtml: typeof tokenizeHtmlBase;
|
|
7
18
|
export declare const sanitizeHtmlAttrs: typeof sanitizeHtmlAttrsBase;
|
|
8
|
-
export declare function isCustomHtmlComponent(tagName: string, customComponents:
|
|
9
|
-
export declare function hasCustomHtmlComponents(content: string, customComponents:
|
|
10
|
-
export declare function parseHtmlToReactNodes(content: string, customComponents:
|
|
19
|
+
export declare function isCustomHtmlComponent(tagName: string, customComponents: HtmlReactComponentMap): boolean;
|
|
20
|
+
export declare function hasCustomHtmlComponents(content: string, customComponents: HtmlReactComponentMap): boolean;
|
|
21
|
+
export declare function parseHtmlToReactNodes(content: string, customComponents: HtmlReactComponentMap, htmlPolicy?: HtmlPolicy, options?: HtmlToReactOptions): ReactNode[] | null;
|