|
| 1 | +// tslint:disable:max-classes-per-file |
| 2 | +import { MarkdownIt, Token } from 'markdown-it'; |
| 3 | +import { ComponentType, ReactNode } from 'react'; |
| 4 | +import { StyleSheet, View } from 'react-native'; |
| 5 | + |
| 6 | +export function getUniqueID(): string; |
| 7 | +export function openUrl(url: string): void; |
| 8 | + |
| 9 | +export function hasParents(parents: any[], type: string): boolean; |
| 10 | + |
| 11 | +export type RenderFunction = ( |
| 12 | + node: any, |
| 13 | + children: ReactNode[], |
| 14 | + parent: ReactNode, |
| 15 | + styles: any, |
| 16 | +) => ReactNode; |
| 17 | + |
| 18 | +export interface RenderRules { |
| 19 | + [name: string]: RenderFunction; |
| 20 | +} |
| 21 | + |
| 22 | +export const renderRules: RenderRules; |
| 23 | + |
| 24 | +export interface MarkdownParser { |
| 25 | + parse: (value: string, options: any) => Token[]; |
| 26 | +} |
| 27 | + |
| 28 | +export interface ASTNode { |
| 29 | + type: string; |
| 30 | + sourceType: string; // original source token name |
| 31 | + key: string; |
| 32 | + content: string; |
| 33 | + tokenIndex: number; |
| 34 | + index: number; |
| 35 | + attributes: Record<string, any>; |
| 36 | + children: ASTNode[]; |
| 37 | +} |
| 38 | + |
| 39 | +export class AstRenderer { |
| 40 | + constructor(renderRules: RenderRules, style?: any); |
| 41 | + getRenderFunction(type: string): RenderFunction; |
| 42 | + renderNode(node: any, parentNodes: ReadonlyArray<any>): ReactNode; |
| 43 | + render(nodes: ReadonlyArray<any>): View; |
| 44 | +} |
| 45 | + |
| 46 | +export function parser( |
| 47 | + source: string, |
| 48 | + renderer: (node: ASTNode) => View, |
| 49 | + parser: MarkdownParser, |
| 50 | +): any; |
| 51 | + |
| 52 | +export function stringToTokens( |
| 53 | + source: string, |
| 54 | + markdownIt: MarkdownParser, |
| 55 | +): Token[]; |
| 56 | + |
| 57 | +export function tokensToAST(tokens: ReadonlyArray<Token>): ASTNode[]; |
| 58 | + |
| 59 | +interface PluginContainerResult<A> extends Array<any> { |
| 60 | + 0: A; |
| 61 | +} |
| 62 | + |
| 63 | +export class PluginContainer<A> { |
| 64 | + constructor(plugin: A, ...options: any[]); |
| 65 | + toArray(): PluginContainerResult<A>; |
| 66 | +} |
| 67 | + |
| 68 | +export function blockPlugin(md: any, name: string, options: object): any; |
| 69 | + |
| 70 | +export const styles: any; |
| 71 | + |
| 72 | +export interface MarkdownProps { |
| 73 | + rules?: RenderRules; |
| 74 | + style?: StyleSheet.NamedStyles<any>; |
| 75 | + renderer?: AstRenderer; |
| 76 | + markdownit?: MarkdownIt; |
| 77 | + plugins?: Array<PluginContainer<any>>; |
| 78 | +} |
| 79 | + |
| 80 | +type MarkdownStatic = React.ComponentType<MarkdownProps>; |
| 81 | +export const Markdown: MarkdownStatic; |
| 82 | +export type Markdown = MarkdownStatic; |
| 83 | + |
| 84 | +export default Markdown; |
0 commit comments