-
Notifications
You must be signed in to change notification settings - Fork 9
Add custom component overrides #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Great! This new feature I was looking for real personalization. |
|
My final recommendation to have a consistency and extensible nodes renders is merging PROPOSE 1: import type { Content, RootContentMap } from 'mdast';
/**
* Props for the main StreamdownRN component
*/
export interface StreamdownRNProps {
components?: {
[Key in keyof RootContentMap]?: (props: {
node: Content;
theme: ThemeConfig;
isStreaming: boolean;
key?: string | number;
}) => React.ReactNode;
component?: {
[name as string]: ComponentDefinition & {
validator?: (props: Record<string, unknown>) => ValidationResult;
}
}
};
...
}PROPOSE 2: import type { Content, RootContentMap } from "mdast";
/**
* Props for the main StreamdownRN component
*/
export interface StreamdownRNProps {
nodes?: {
[Key in keyof RootContentMap]?: (props: {
node: Content;
theme: ThemeConfig;
isStreaming: boolean;
key?: string | number;
}) => React.ReactNode;
};
components?: {
[name as string]: ComponentDefinition & {
validator?: (props: Record<string, unknown>) => ValidationResult;
};
};
...
} |
|
Other recommendation is allow to override all the nodes/elements types and expose all the props as possible, because it will allow to cover all 100% including the outliers situations. Exposing only |
|
Here is a situation in our application that our default Are you considering introducing that props for higher customization in |
Custom Block-Level Renderers for StreamdownRN
This PR adds a powerful new extensibility feature to streamdown-rn: fully customizable block-level renderers. You can now override how any block element is rendered while preserving all the streaming, memoization, and performance benefits of the library.
The Problem
Previously, if you wanted custom rendering for code blocks (e.g., with a copy button), images (e.g., lazy loading with FastImage), or links (e.g., in-app navigation), you had to fork the library or post-process the output.
The Solution
Pass a renderers prop to override any block-level element:
Supported Elements
Key Design Decisions
Changes
Core (streamdown-rn)
Testing
CI
Documentation
Test Plan
This makes streamdown-rn much more extensible for production apps that need custom UI for markdown elements.