11// tslint:disable:max-classes-per-file
2- import { MarkdownIt , Token } from 'markdown-it' ;
2+ import MarkdownIt from 'markdown-it' ;
3+ import Token from 'markdown-it/lib/token' ;
34import { ComponentType , ReactNode } from 'react' ;
45import { StyleSheet , View } from 'react-native' ;
56
@@ -9,14 +10,37 @@ export function openUrl(url: string): void;
910export function hasParents ( parents : any [ ] , type : string ) : boolean ;
1011
1112export type RenderFunction = (
12- node : any ,
13+ node : ASTNode ,
1314 children : ReactNode [ ] ,
14- parent : ReactNode ,
15+ parentNodes : ASTNode [ ] ,
1516 styles : any ,
17+ styleObj ?: any ,
18+ // must have this so that we can have fixed overrides with more arguments
19+ ...args : any ,
20+ ) => ReactNode ;
21+
22+ export type RenderLinkFunction = (
23+ node : ASTNode ,
24+ children : ReactNode [ ] ,
25+ parentNodes : ASTNode [ ] ,
26+ styles : any ,
27+ onLinkPress : ( url : string ) => boolean ,
28+ ) => ReactNode ;
29+
30+ export type RenderImageFunction = (
31+ node : ASTNode ,
32+ children : ReactNode [ ] ,
33+ parentNodes : ASTNode [ ] ,
34+ styles : any ,
35+ allowedImageHandlers : string [ ] ,
36+ defaultImageHandler : string ,
1637) => ReactNode ;
1738
1839export interface RenderRules {
19- [ name : string ] : RenderFunction ;
40+ [ name : string ] : RenderFunction | undefined ;
41+ link ?: RenderLinkFunction ;
42+ blocklink ?: RenderLinkFunction ;
43+ image ?: RenderImageFunction ;
2044}
2145
2246export const renderRules : RenderRules ;
@@ -30,6 +54,7 @@ export interface ASTNode {
3054 sourceType : string ; // original source token name
3155 key : string ;
3256 content : string ;
57+ markup : string ;
3358 tokenIndex : number ;
3459 index : number ;
3560 attributes : Record < string , any > ;
@@ -56,30 +81,19 @@ export function stringToTokens(
5681
5782export function tokensToAST ( tokens : ReadonlyArray < Token > ) : ASTNode [ ] ;
5883
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-
7084export const styles : any ;
7185
7286export interface MarkdownProps {
7387 rules ?: RenderRules ;
7488 style ?: StyleSheet . NamedStyles < any > ;
7589 renderer ?: AstRenderer ;
7690 markdownit ?: MarkdownIt ;
77- plugins ?: Array < PluginContainer < any > > ;
7891 mergeStyle ?: boolean ;
92+ debugPrintTree ?: boolean ;
7993}
8094
8195type MarkdownStatic = React . ComponentType < MarkdownProps > ;
8296export const Markdown : MarkdownStatic ;
8397export type Markdown = MarkdownStatic ;
84-
98+ export { MarkdownIt } ;
8599export default Markdown ;
0 commit comments