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