@ant-design/x-markdown
Version:
placeholder for @ant-design/x-markdown
27 lines (26 loc) • 897 B
TypeScript
import type { Config as DOMPurifyConfig } from 'dompurify';
import React, { ReactNode } from 'react';
import type { XMarkdownProps } from '../interface';
interface RendererOptions {
components?: XMarkdownProps['components'];
dompurifyConfig?: DOMPurifyConfig;
streaming?: XMarkdownProps['streaming'];
}
declare class Renderer {
private readonly options;
private static readonly NON_WHITESPACE_REGEX;
constructor(options: RendererOptions);
/**
* Detect unclosed tags using regular expressions
*/
private detectUnclosedTags;
/**
* Configure DOMPurify to preserve components and target attributes, filter everything else
*/
private configureDOMPurify;
private createReplaceElement;
private processChildren;
processHtml(htmlString: string): React.ReactNode;
render(html: string): ReactNode | null;
}
export default Renderer;