markstream-react 0.0.47 → 0.0.48
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/dist/{Tooltip-DQ6sUeEf.js → Tooltip-3iGNq_AM.js} +116 -116
- package/dist/{index-DOjYeelM.js → index-DI8pPos8.js} +20 -20
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -1
- 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 +49 -34
- package/dist/next.js +1 -1
- package/dist/server.d.ts +38 -28
- package/dist/server.js +1 -1
- package/dist/tailwind.ts +1 -1
- package/dist/types/components/CodeBlockNode/HtmlPreviewFrame.d.ts +2 -0
- package/dist/types/components/D2BlockNode/d2.d.ts +13 -2
- package/dist/types/components/DefinitionListNode/DefinitionListNode.d.ts +2 -1
- package/dist/types/components/HtmlBlockNode/HtmlBlockNode.d.ts +4 -3
- package/dist/types/components/ListNode/ListNode.d.ts +2 -1
- package/dist/types/components/MermaidBlockNode/mermaid.d.ts +22 -1
- package/dist/types/components/TableNode/TableNode.d.ts +3 -2
- package/dist/types/customComponents.d.ts +4 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/next.d.ts +7 -13
- package/dist/types/server-renderer/index.d.ts +5 -5
- package/dist/types/types/component-props.d.ts +12 -4
- package/dist/types/types.d.ts +5 -4
- package/dist/types/utils/customHtmlTag.d.ts +1 -1
- package/dist/types/utils/htmlToReact.d.ts +6 -5
- package/package.json +2 -2
package/dist/tailwind.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const safeList = `use client react string cannot delete global call clearGlobalCustomComponents note is-dark data-index-key headerId admonition-header admonition-icon admonition-title admonition-toggle aria-expanded aria-controls collapsed admonition-content aria-labelledby stream-markdown-parser
|
|
1
|
+
export const safeList = `use client react string cannot delete global call clearGlobalCustomComponents dependency is not install it to enable checkbox-node checkbox checkbox-input note is-dark data-index-key headerId admonition-header admonition-icon admonition-title admonition-toggle aria-expanded aria-controls collapsed admonition-content aria-labelledby stream-markdown-parser typeof window.requestIdleCallback [data-node-index] node-spacer dark virtualized data-custom-id code_block node-slot data-node-index data-node-type typewriter-node node-placeholder performance [markstream-react][perf] mermaid theme object name markdown-renderer boolean safe clsx href xlink:href markstream-d2-root-svg number window.requestAnimationFrame instance.render instance missing render returned empty top d2-block my-4 rounded-lg border overflow-hidden shadow-sm border-gray-700/30 bg-gray-900 text-gray-100 border-gray-200 bg-white text-gray-900 d2-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5 gap-x-2 text-sm font-medium font-mono gap-x-1 rounded-md p-0.5 bg-gray-700 bg-gray-100 mode-btn px-2 py-1 text-xs rounded !showSource is-active showSource d2-action-btn p-2 transition-colors hover:bg-[var(--vscode-editor-selectionBackground)] copying w-3 h-3 none currentColor round aria-pressed m9 bodyRef d2-block-body bodyStyle !hasPreview d2-source py-4 d2-code d2-error mt-2 d2-render d2-svg pb-3 line-info diffUnchangedRegionStyle line-info-basic metadata legacy off never background auto night moon black dracula mocha frappe macchiato palenight ocean poimandres monokai laserwave tokyo slack-dark rose-pine github-dark material-theme one-dark catppuccin-mocha catppuccin-frappe catppuccin-macchiato light latte dawn lotus plaintext diff visible view.getModifiedEditor ?? explicit on same helpers.cleanupEditor canonicalLanguage single window.cancelAnimationFrame clientX navigator.clipboard navigator.clipboard.writeText code-block-container is-rendering is-diff is-plain-text code-block-header space-x-2 flex-1 icon-slot h-4 w-4 flex-shrink-0 truncate code-action-btn copied m14 evenodd code-block-body--collapsed code-block-body--expanded code-editor-layer code-height-placeholder hidden aria-hidden code-editor-fallback-surface code-fallback-plain m-0 aria-busy aria-label no code-loading-placeholder loading-skeleton skeleton-line short sr-only polite status emoji-node emphasis-node smooth footnote-reference handleScroll footnote-link cursor-pointer footnote-node leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2 insert-node mark highlight-node blockquote-node heading-node font-semibold inline-code inline text-[85%] px-1 py-0.5 bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full text-node-stream-delta text-node-stream-delta--a text-node-stream-delta--b dl definition-list indexKey mb-4 dt definition-term ctx renderNode definition dd definition-desc ml-4 hard-break footnote-anchor hover:underline ↩︎ react-dom library failed text-red-500 p-4">Failed instanceof error.message error keydown transform ease center fullscreen touches text-gray-400 hover:bg-gray-700 hover:text-gray-200 text-gray-600 hover:bg-gray-200 hover:text-gray-700 source hasPreview preview pending bg-gray-800 bg-gray-50 px-2.5 bg-gray-600 text-gray-200 text-gray-700 text-gray-500 m16 isCollapsed opacity-50 cursor-not-allowed m7 whitespace-pre-wrap text-gray-300 baseCode relative absolute top-2 right-2 z-10 gap-2 backdrop-blur infographic-preview min-h-[360px] transition-all duration-100 block inset-0 cursor-grab isDragging containerRef w-full text-center justify-center min-h-full fixed z-50 bg-black/70 p-4 closeModal dialog h-full max-h-full shadow-lg top-6 right-6 !isDragging cursor-grabbing list-item pl-1.5 my-2 valueAttr children is-loaded lazy eager async image image-node__placeholder image-node__spinner image-node__placeholder-text image… placeholder image-node__error load ease-in-out infinite node.title link-loading inline-flex items-baseline gap-1.5 link-text-wrapper leading-[normal] link-text text link-loading-indicator link-node noopener noreferrer html-block-node escape html-block html-block-node__placeholder html-block-node__placeholder-bar w-4/5 w-2/3 setHostEl shouldRender useDynamic reactNodes list-node my-5 pl-[calc(13/8*1em)] list-decimal list-disc max-lg:my-[calc(4/3*1em)] max-lg:pl-[calc(14/9*1em)] list vitesse-dark vitesse-light shiki shiki-fallback stream-markdown code-block-content rendererTargetRef code-block-render paragraph-node paragraph strong-node reference-node bg-[hsl(var(--muted))] px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))] event.key unknown-node italic node strikethrough-node subscript-node superscript-node in out zoom hr-node thematic-break containerClass vmr-container javascript typescript python ruby shell d2 plain cpp markdown right text-right text-left pointermove pointerup pointercancel table-node-wrapper my-8 table-node table-node--loading colgroup border-[var(--table-border,#cbd5e1)] p-[calc(4/7*1em)] table-node__resize-handle table-node__loading table-node__spinner window.matchMedia ms-tooltip z-[9999] inline-block text-base py-2 px-3 shadow-md whitespace-nowrap pointer-events-none tooltip-element text-white border-gray-700 tooltip text-node text-node-center afterbegin viewBox loose strict gantt open-modal [data-mermaid-wrapper] mermaid-action-btn toggle-mode common.zoomIn common.zoomOut common.resetZoom transition-[height] duration-150 ease-out data-mermaid-wrapper mermaid-loading mermaid-spinner diagram… mermaid-block-header space-x-1 common.preview common.source common.export mermaid-error hasRenderedOnce mermaid-block modeContainerRef mermaid-modal-overlay mermaid-modal-panel mermaid-modal-header mermaid-modal-title mermaid-modal-close mermaid-modal-body modalContentRef mermaid-modal-content available default abort timed [mermaidWorkerClient] messageerror cleared worker inject via busy canParse findPrefix infographic language d2lang html_block node.type html_inline text_special node.content heading list_item definition_list footnote footnote_reference footnote_anchor admonition hardbreak inline_code emphasis strikethrough highlight insert subscript superscript checkbox_input emoji thematic_break math_inline math_block reference vmr_container label_open label_close stream-monaco document data-language thinking htmlFor class className role aria-describedby self_closing tag_open tag_close parse dynamic template html-inline-node html-inline-node--loading [markstream-react] htmlPreviewSandbox contains both allow-scripts and this only fully trusted content served an isolated en utf-8 viewport content="width=device-width initial-scale=1 html-preview-frame__backdrop--dark html-preview-frame--dark html-preview-frame__header html-preview-frame__title html-preview-frame__dot html-preview-frame__label html-preview-frame__close--dark html-preview-frame__iframe no-referrer about:blank data-ssr-fallback normalizedLanguage renderNodeProp classAttr node.cite value void rowIdx bodyRows.length isOpen thematic-break-node cssVars image-node__img code-block-node code-block markdown-code-block-node markdown-code-block mermaid-block-node d2-block-node infographic-block-node math-block overflow-x-auto min-h-[40px] $$ math-inline-wrapper math-inline data-reference-id customComponents server-renderer node-content mathRef math-inline--hidden math-inline__loading math-inline__spinner rendering math-rendering normalizedType globalThis.requestAnimationFrame globalThis.cancelAnimationFrame sequencediagram classdiagram kind statediagram erdiagram flowchart graph module did expected [katexWorkerClient] init cache-hit timeout waiting slot existingEnv.getWorkerUrl °C process katex`
|
|
2
2
|
module.exports = safeList;
|
|
3
3
|
export default safeList;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface D2Instance {
|
|
2
|
+
D2?: D2Constructor;
|
|
3
|
+
compile?: (source: string, options?: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
4
|
+
render?: (input: unknown, options?: Record<string, unknown>) => Promise<unknown> | unknown;
|
|
5
|
+
}
|
|
6
|
+
export interface D2Constructor {
|
|
7
|
+
new (): D2Instance;
|
|
8
|
+
D2?: D2Constructor;
|
|
9
|
+
compile?: D2Instance['compile'];
|
|
10
|
+
}
|
|
11
|
+
export type D2Module = D2Constructor | D2Instance;
|
|
12
|
+
export type D2Loader = () => Promise<unknown> | unknown;
|
|
2
13
|
export declare function setD2Loader(loader: D2Loader | null): void;
|
|
3
14
|
export declare function enableD2(loader?: D2Loader): void;
|
|
4
15
|
export declare function disableD2(): void;
|
|
5
16
|
export declare function isD2Enabled(): boolean;
|
|
6
|
-
export declare function getD2(): Promise<
|
|
17
|
+
export declare function getD2(): Promise<D2Module | null>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { DefinitionItemNode } from 'stream-markdown-parser';
|
|
2
3
|
export declare function DefinitionListNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'definition_list';
|
|
4
|
-
items?:
|
|
5
|
+
items?: DefinitionItemNode[];
|
|
5
6
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export default DefinitionListNode;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { HtmlPolicy } from 'stream-markdown-parser';
|
|
1
|
+
import { HtmlPolicy, ParsedNode } from 'stream-markdown-parser';
|
|
2
|
+
import { CustomComponentMap } from '../../customComponents';
|
|
2
3
|
import { NodeComponentProps } from '../../types/node-component';
|
|
3
4
|
import { default as React } from 'react';
|
|
4
5
|
export declare function HtmlBlockNode(props: NodeComponentProps<{
|
|
@@ -7,10 +8,10 @@ export declare function HtmlBlockNode(props: NodeComponentProps<{
|
|
|
7
8
|
raw?: string;
|
|
8
9
|
tag?: string;
|
|
9
10
|
attrs?: [string, string | null][] | null;
|
|
10
|
-
children?:
|
|
11
|
+
children?: ParsedNode[];
|
|
11
12
|
loading?: boolean;
|
|
12
13
|
}> & {
|
|
13
|
-
customComponents?:
|
|
14
|
+
customComponents?: CustomComponentMap;
|
|
14
15
|
htmlPolicy?: HtmlPolicy;
|
|
15
16
|
placeholder?: React.ReactNode;
|
|
16
17
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { ListItemNode as ParsedListItemNode } from 'stream-markdown-parser';
|
|
2
3
|
export declare function ListNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'list';
|
|
4
5
|
ordered?: boolean;
|
|
5
6
|
start?: number;
|
|
6
|
-
items?:
|
|
7
|
+
items?: ParsedListItemNode[];
|
|
7
8
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export default ListNode;
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface MermaidModule {
|
|
2
|
+
render: (id: string, source: string) => Promise<MermaidRenderResult> | MermaidRenderResult;
|
|
3
|
+
parse?: (source: string) => Promise<unknown> | unknown;
|
|
4
|
+
initialize?: (config?: Record<string, unknown>) => unknown;
|
|
5
|
+
mermaidAPI?: {
|
|
6
|
+
render?: MermaidModule['render'];
|
|
7
|
+
parse?: MermaidModule['parse'];
|
|
8
|
+
initialize?: MermaidModule['initialize'];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export type MermaidRenderResult = string | {
|
|
12
|
+
svg?: string;
|
|
13
|
+
bindFunctions?: (element: Element) => unknown;
|
|
14
|
+
};
|
|
15
|
+
interface MermaidInitConfig extends Record<string, unknown> {
|
|
16
|
+
securityLevel?: unknown;
|
|
17
|
+
flowchart?: {
|
|
18
|
+
htmlLabels?: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare function getMermaid(initConfig?: MermaidInitConfig): Promise<MermaidModule | null>;
|
|
22
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NodeComponentProps } from '../../types/node-component';
|
|
2
|
+
import { TableRowNode } from 'stream-markdown-parser';
|
|
2
3
|
export declare function TableNode(props: NodeComponentProps<{
|
|
3
4
|
type: 'table';
|
|
4
|
-
header?:
|
|
5
|
-
rows?:
|
|
5
|
+
header?: TableRowNode;
|
|
6
|
+
rows?: TableRowNode[];
|
|
6
7
|
loading?: boolean;
|
|
7
8
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export default TableNode;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
export type CustomComponentDisplayMode = 'inline' | 'block';
|
|
3
|
-
export type MarkstreamCustomComponent<P =
|
|
3
|
+
export type MarkstreamCustomComponent<P = never> = ComponentType<P> & {
|
|
4
4
|
markstreamDisplay?: CustomComponentDisplayMode;
|
|
5
5
|
};
|
|
6
|
-
export type CustomComponentMap = Record<string, MarkstreamCustomComponent
|
|
6
|
+
export type CustomComponentMap = Record<string, MarkstreamCustomComponent>;
|
|
7
7
|
export declare function subscribeCustomComponents(listener: () => void): () => void;
|
|
8
8
|
export declare function getCustomComponentsRevision(): number;
|
|
9
9
|
export declare function setCustomComponents(id: string, mapping: CustomComponentMap): void;
|
|
@@ -11,7 +11,7 @@ export declare function setCustomComponents(mapping: CustomComponentMap): void;
|
|
|
11
11
|
export declare function getCustomNodeComponents(customId?: string): CustomComponentMap;
|
|
12
12
|
export declare function removeCustomComponents(id: string): void;
|
|
13
13
|
export declare function clearGlobalCustomComponents(): void;
|
|
14
|
-
export declare function getCustomComponentDisplay(component: ComponentType<
|
|
15
|
-
export declare function withMarkstreamComponentDisplay<T extends ComponentType<
|
|
14
|
+
export declare function getCustomComponentDisplay(component: ComponentType<never> | null | undefined): CustomComponentDisplayMode | undefined;
|
|
15
|
+
export declare function withMarkstreamComponentDisplay<T extends ComponentType<never>>(component: T, display: CustomComponentDisplayMode): T & {
|
|
16
16
|
markstreamDisplay: CustomComponentDisplayMode;
|
|
17
17
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export type { CustomComponentDisplayMode, MarkstreamCustomComponent, } from './c
|
|
|
56
56
|
export * from './i18n/useSafeI18n';
|
|
57
57
|
export * from './renderers/renderNode';
|
|
58
58
|
export type { NodeRendererCodeBlockProps, NodeRendererProps } from './types';
|
|
59
|
-
export type { CodeBlockDiffAppearance, CodeBlockDiffHideUnchangedRegions, CodeBlockDiffHideUnchangedRegionsOptions, CodeBlockDiffHunkActionContext, CodeBlockDiffHunkActionKind, CodeBlockDiffHunkSide, CodeBlockDiffLineStyle, CodeBlockDiffUnchangedRegionStyle, CodeBlockMonacoLanguage, CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockMonacoThemeObject, CodeBlockNodeProps, D2BlockNodeProps, ImageNodeProps, InfographicBlockNodeProps, LinkNodeProps, MathBlockNodeProps, MathInlineNodeProps, MermaidBlockEvent, MermaidBlockNodeProps, PreCodeNodeProps, } from './types/component-props';
|
|
59
|
+
export type { CodeBlockDiffAppearance, CodeBlockDiffHideUnchangedRegions, CodeBlockDiffHideUnchangedRegionsOptions, CodeBlockDiffHunkActionContext, CodeBlockDiffHunkActionKind, CodeBlockDiffHunkSide, CodeBlockDiffLineStyle, CodeBlockDiffUnchangedRegionStyle, CodeBlockMonacoLanguage, CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockMonacoThemeObject, CodeBlockNodeProps, CodeBlockPreviewPayload, D2BlockNodeProps, ImageNodeProps, InfographicBlockNodeProps, LinkNodeProps, MathBlockNodeProps, MathInlineNodeProps, MermaidBlockEvent, MermaidBlockNodeProps, PreCodeNodeProps, } from './types/component-props';
|
|
60
60
|
export type { NodeComponentProps } from './types/node-component';
|
|
61
61
|
export * from './utils/languageIcon';
|
|
62
62
|
export * from './workers/katexWorkerClient';
|
package/dist/types/next.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const D2BlockNode: {
|
|
|
45
45
|
export declare const DefinitionListNode: {
|
|
46
46
|
(props: import('./types/node-component').NodeComponentProps<{
|
|
47
47
|
type: "definition_list";
|
|
48
|
-
items?:
|
|
48
|
+
items?: import('stream-markdown-parser').DefinitionItemNode[];
|
|
49
49
|
}>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
50
50
|
displayName: string;
|
|
51
51
|
};
|
|
@@ -109,17 +109,11 @@ export declare const HighlightNode: {
|
|
|
109
109
|
export declare const HtmlBlockNode: {
|
|
110
110
|
(props: import('./types/node-component').NodeComponentProps<{
|
|
111
111
|
type: "html_block";
|
|
112
|
-
content
|
|
113
|
-
raw?: string;
|
|
112
|
+
content?: string;
|
|
114
113
|
tag?: string;
|
|
115
114
|
attrs?: [string, string | null][] | null;
|
|
116
|
-
children?:
|
|
117
|
-
|
|
118
|
-
}> & {
|
|
119
|
-
customComponents?: Record<string, React.ComponentType<any>>;
|
|
120
|
-
htmlPolicy?: import('stream-markdown-parser').HtmlPolicy;
|
|
121
|
-
placeholder?: React.ReactNode;
|
|
122
|
-
}): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
115
|
+
children?: import('stream-markdown-parser').ParsedNode[];
|
|
116
|
+
}>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
123
117
|
displayName: string;
|
|
124
118
|
};
|
|
125
119
|
export declare const HtmlInlineNode: {
|
|
@@ -175,7 +169,7 @@ export declare const ListNode: {
|
|
|
175
169
|
type: "list";
|
|
176
170
|
ordered?: boolean;
|
|
177
171
|
start?: number;
|
|
178
|
-
items?:
|
|
172
|
+
items?: import('stream-markdown-parser').ListItemNode[];
|
|
179
173
|
}>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
180
174
|
displayName: string;
|
|
181
175
|
};
|
|
@@ -253,8 +247,8 @@ export declare const SuperscriptNode: {
|
|
|
253
247
|
export declare const TableNode: {
|
|
254
248
|
(props: import('./types/node-component').NodeComponentProps<{
|
|
255
249
|
type: "table";
|
|
256
|
-
header?:
|
|
257
|
-
rows?:
|
|
250
|
+
header?: import('stream-markdown-parser').TableRowNode;
|
|
251
|
+
rows?: import('stream-markdown-parser').TableRowNode[];
|
|
258
252
|
loading?: boolean;
|
|
259
253
|
}>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
260
254
|
displayName: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParsedNode } from 'stream-markdown-parser';
|
|
1
|
+
import { DefinitionItemNode as DefinitionItemNodeType, ListItemNode as ListItemNodeType, ParsedNode, TableRowNode as TableRowNodeType } from 'stream-markdown-parser';
|
|
2
2
|
import { HtmlPreviewFrameProps } from '../components/CodeBlockNode/HtmlPreviewFrame';
|
|
3
3
|
import { MarkdownCodeBlockNodeProps } from '../components/MarkdownCodeBlockNode/MarkdownCodeBlockNode';
|
|
4
4
|
import { TooltipProps } from '../components/Tooltip/Tooltip';
|
|
@@ -35,17 +35,17 @@ export declare function ListNode(props: NodeComponentProps<{
|
|
|
35
35
|
type: 'list';
|
|
36
36
|
ordered?: boolean;
|
|
37
37
|
start?: number;
|
|
38
|
-
items?:
|
|
38
|
+
items?: ListItemNodeType[];
|
|
39
39
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
40
40
|
export declare function TableNode(props: NodeComponentProps<{
|
|
41
41
|
type: 'table';
|
|
42
|
-
header?:
|
|
43
|
-
rows?:
|
|
42
|
+
header?: TableRowNodeType;
|
|
43
|
+
rows?: TableRowNodeType[];
|
|
44
44
|
loading?: boolean;
|
|
45
45
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
46
46
|
export declare function DefinitionListNode(props: NodeComponentProps<{
|
|
47
47
|
type: 'definition_list';
|
|
48
|
-
items?:
|
|
48
|
+
items?: DefinitionItemNodeType[];
|
|
49
49
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
50
50
|
export declare function FootnoteNode(props: NodeComponentProps<{
|
|
51
51
|
type: 'footnote';
|
|
@@ -8,7 +8,7 @@ export interface CodeBlockMonacoThemeObject {
|
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
}
|
|
10
10
|
export type CodeBlockMonacoTheme = string | CodeBlockMonacoThemeObject;
|
|
11
|
-
export type CodeBlockMonacoLanguage = string | ((...args:
|
|
11
|
+
export type CodeBlockMonacoLanguage = string | ((...args: unknown[]) => unknown);
|
|
12
12
|
export interface CodeBlockDiffHideUnchangedRegionsOptions {
|
|
13
13
|
enabled?: boolean;
|
|
14
14
|
contextLineCount?: number;
|
|
@@ -61,8 +61,8 @@ export interface CodeBlockMonacoOptions {
|
|
|
61
61
|
diffHunkActionsOnHover?: boolean;
|
|
62
62
|
diffHunkHoverHideDelayMs?: number;
|
|
63
63
|
onDiffHunkAction?: (context: CodeBlockDiffHunkActionContext) => void | boolean | Promise<void | boolean>;
|
|
64
|
-
scrollbar?: Record<string,
|
|
65
|
-
[key: string]:
|
|
64
|
+
scrollbar?: Record<string, unknown>;
|
|
65
|
+
[key: string]: unknown;
|
|
66
66
|
}
|
|
67
67
|
export interface CodeBlockNodeProps {
|
|
68
68
|
node: CodeBlockNode;
|
|
@@ -84,6 +84,8 @@ export interface CodeBlockNodeProps {
|
|
|
84
84
|
showCollapseButton?: boolean;
|
|
85
85
|
showFontSizeButtons?: boolean;
|
|
86
86
|
showTooltips?: boolean;
|
|
87
|
+
htmlPreviewAllowScripts?: boolean;
|
|
88
|
+
htmlPreviewSandbox?: string;
|
|
87
89
|
customId?: string;
|
|
88
90
|
}
|
|
89
91
|
export interface ImageNodeProps {
|
|
@@ -154,7 +156,13 @@ export interface MermaidBlockNodeProps {
|
|
|
154
156
|
showTooltips?: boolean;
|
|
155
157
|
onRenderError?: (error: unknown, code: string, container: HTMLElement) => boolean | void;
|
|
156
158
|
}
|
|
157
|
-
export interface
|
|
159
|
+
export interface CodeBlockPreviewPayload {
|
|
160
|
+
node: CodeBlockNode;
|
|
161
|
+
artifactType: 'text/html' | 'image/svg+xml';
|
|
162
|
+
artifactTitle: string;
|
|
163
|
+
id: string;
|
|
164
|
+
}
|
|
165
|
+
export interface MermaidBlockEvent<TPayload = unknown> {
|
|
158
166
|
payload?: TPayload;
|
|
159
167
|
defaultPrevented: boolean;
|
|
160
168
|
preventDefault: () => void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { BaseNode, HtmlPolicy, MarkdownIt, ParsedNode, ParseOptions } from 'stream-markdown-parser';
|
|
3
|
-
import {
|
|
3
|
+
import { CustomComponentMap } from './customComponents';
|
|
4
|
+
import { CodeBlockPreviewPayload, CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockNodeProps, D2BlockNodeProps, InfographicBlockNodeProps, MermaidBlockNodeProps } from './types/component-props';
|
|
4
5
|
export type NodeRendererCodeBlockProps = Partial<Omit<CodeBlockNodeProps, 'node'>> & Record<string, unknown>;
|
|
5
6
|
export interface NodeRendererProps {
|
|
6
7
|
content?: string;
|
|
@@ -48,7 +49,7 @@ export interface NodeRendererProps {
|
|
|
48
49
|
maxLiveNodes?: number;
|
|
49
50
|
liveNodeBuffer?: number;
|
|
50
51
|
onCopy?: (code: string) => void;
|
|
51
|
-
onHandleArtifactClick?: (payload:
|
|
52
|
+
onHandleArtifactClick?: (payload: CodeBlockPreviewPayload) => void;
|
|
52
53
|
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
53
54
|
onMouseOver?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
54
55
|
onMouseOut?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
@@ -60,7 +61,7 @@ export interface RenderContext {
|
|
|
60
61
|
typewriter?: boolean;
|
|
61
62
|
textStreamState?: Map<string, string>;
|
|
62
63
|
streamRenderVersion?: number;
|
|
63
|
-
customComponents?:
|
|
64
|
+
customComponents?: CustomComponentMap;
|
|
64
65
|
customHtmlTags?: readonly string[];
|
|
65
66
|
htmlPolicy?: HtmlPolicy;
|
|
66
67
|
codeBlockProps?: NodeRendererCodeBlockProps;
|
|
@@ -80,7 +81,7 @@ export interface RenderContext {
|
|
|
80
81
|
};
|
|
81
82
|
events: {
|
|
82
83
|
onCopy?: (code: string) => void;
|
|
83
|
-
onHandleArtifactClick?: (payload:
|
|
84
|
+
onHandleArtifactClick?: (payload: CodeBlockPreviewPayload) => void;
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
export type RenderNodeFn = (node: ParsedNode, key: React.Key, ctx: RenderContext) => React.ReactNode;
|
|
@@ -3,7 +3,7 @@ import { CustomComponentDisplayMode, CustomComponentMap, MarkstreamCustomCompone
|
|
|
3
3
|
export interface ResolvedCustomHtmlTag {
|
|
4
4
|
tag: string;
|
|
5
5
|
isWhitelisted: boolean;
|
|
6
|
-
component: MarkstreamCustomComponent
|
|
6
|
+
component: MarkstreamCustomComponent | null;
|
|
7
7
|
display: CustomComponentDisplayMode | undefined;
|
|
8
8
|
}
|
|
9
9
|
export declare function resolveCustomHtmlTag(node: Pick<ParsedNode, 'type'> & {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { HtmlPolicy, sanitizeHtmlAttrs as sanitizeHtmlAttrsBase, tokenizeHtml as tokenizeHtmlBase } from 'stream-markdown-parser';
|
|
3
|
+
import { CustomComponentMap } from '../customComponents';
|
|
3
4
|
export type { HtmlToken } from 'stream-markdown-parser';
|
|
4
|
-
export declare function normalizeDomAttrs(attrs: Record<string, string>): Record<string,
|
|
5
|
+
export declare function normalizeDomAttrs(attrs: Record<string, string>): Record<string, unknown>;
|
|
5
6
|
export declare const tokenizeHtml: typeof tokenizeHtmlBase;
|
|
6
7
|
export declare const sanitizeHtmlAttrs: typeof sanitizeHtmlAttrsBase;
|
|
7
|
-
export declare function isCustomHtmlComponent(tagName: string, customComponents:
|
|
8
|
-
export declare function hasCustomHtmlComponents(content: string, customComponents:
|
|
9
|
-
export declare function parseHtmlToReactNodes(content: string, customComponents:
|
|
8
|
+
export declare function isCustomHtmlComponent(tagName: string, customComponents: CustomComponentMap): boolean;
|
|
9
|
+
export declare function hasCustomHtmlComponents(content: string, customComponents: CustomComponentMap): boolean;
|
|
10
|
+
export declare function parseHtmlToReactNodes(content: string, customComponents: CustomComponentMap, htmlPolicy?: HtmlPolicy): ReactNode[] | null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markstream-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.48",
|
|
5
5
|
"description": "React Markdown renderer optimized for large documents with progressive Mermaid rendering, streaming diff code blocks, and fast real-time preview. Built on stream-markdown AST for consistent rendering across frameworks. Perfect for documentation sites, AI chat interfaces, and content management systems.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"dependencies": {
|
|
117
117
|
"@floating-ui/dom": "^1.7.6",
|
|
118
118
|
"clsx": "^2.1.1",
|
|
119
|
-
"stream-markdown-parser": "0.0.
|
|
119
|
+
"stream-markdown-parser": "0.0.93"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@types/react": "^18.3.28",
|