@@ -5,90 +5,97 @@ import {ComponentType, ReactNode} from 'react';
5
5
import { StyleSheet , View } from 'react-native' ;
6
6
7
7
export function getUniqueID ( ) : string ;
8
+
8
9
export function openUrl ( url : string ) : void ;
9
10
10
11
export function hasParents ( parents : any [ ] , type : string ) : boolean ;
11
12
12
13
export type RenderFunction = (
13
- node : ASTNode ,
14
- children : ReactNode [ ] ,
15
- parentNodes : ASTNode [ ] ,
16
- styles : any ,
17
- styleObj ?: any ,
18
- // must have this so that we can have fixed overrides with more arguments
19
- ...args : any
14
+ node : ASTNode ,
15
+ children : ReactNode [ ] ,
16
+ parentNodes : ASTNode [ ] ,
17
+ styles : any ,
18
+ styleObj ?: any ,
19
+ // must have this so that we can have fixed overrides with more arguments
20
+ ...args : any
20
21
) => ReactNode ;
21
22
22
23
export type RenderLinkFunction = (
23
- node : ASTNode ,
24
- children : ReactNode [ ] ,
25
- parentNodes : ASTNode [ ] ,
26
- styles : any ,
27
- onLinkPress ?: ( url : string ) => boolean ,
24
+ node : ASTNode ,
25
+ children : ReactNode [ ] ,
26
+ parentNodes : ASTNode [ ] ,
27
+ styles : any ,
28
+ onLinkPress ?: ( url : string ) => boolean ,
28
29
) => ReactNode ;
29
30
30
31
export type RenderImageFunction = (
31
- node : ASTNode ,
32
- children : ReactNode [ ] ,
33
- parentNodes : ASTNode [ ] ,
34
- styles : any ,
35
- allowedImageHandlers : string [ ] ,
36
- defaultImageHandler : string ,
32
+ node : ASTNode ,
33
+ children : ReactNode [ ] ,
34
+ parentNodes : ASTNode [ ] ,
35
+ styles : any ,
36
+ allowedImageHandlers : string [ ] ,
37
+ defaultImageHandler : string ,
37
38
) => ReactNode ;
38
39
39
40
export interface RenderRules {
40
- [ name : string ] : RenderFunction | undefined ;
41
- link ?: RenderLinkFunction ;
42
- blocklink ?: RenderLinkFunction ;
43
- image ?: RenderImageFunction ;
41
+ [ name : string ] : RenderFunction | undefined ;
42
+
43
+ link ?: RenderLinkFunction ;
44
+ blocklink ?: RenderLinkFunction ;
45
+ image ?: RenderImageFunction ;
44
46
}
45
47
46
48
export const renderRules : RenderRules ;
47
49
48
50
export interface MarkdownParser {
49
- parse : ( value : string , options : any ) => Token [ ] ;
51
+ parse : ( value : string , options : any ) => Token [ ] ;
50
52
}
51
53
52
54
export interface ASTNode {
53
- type : string ;
54
- sourceType : string ; // original source token name
55
- key : string ;
56
- content : string ;
57
- markup : string ;
58
- tokenIndex : number ;
59
- index : number ;
60
- attributes : Record < string , any > ;
61
- children : ASTNode [ ] ;
55
+ type : string ;
56
+ sourceType : string ; // original source token name
57
+ sourceInfo : string ;
58
+ sourceMeta : any ;
59
+ key : string ;
60
+ content : string ;
61
+ markup : string ;
62
+ tokenIndex : number ;
63
+ index : number ;
64
+ attributes : Record < string , any > ;
65
+ children : ASTNode [ ] ;
62
66
}
63
67
64
68
export class AstRenderer {
65
- constructor ( renderRules : RenderRules , style ?: any ) ;
66
- getRenderFunction ( type : string ) : RenderFunction ;
67
- renderNode ( node : any , parentNodes : ReadonlyArray < any > ) : ReactNode ;
68
- render ( nodes : ReadonlyArray < any > ) : View ;
69
+ constructor ( renderRules : RenderRules , style ?: any ) ;
70
+
71
+ getRenderFunction ( type : string ) : RenderFunction ;
72
+
73
+ renderNode ( node : any , parentNodes : ReadonlyArray < any > ) : ReactNode ;
74
+
75
+ render ( nodes : ReadonlyArray < any > ) : View ;
69
76
}
70
77
71
78
export function parser (
72
- source : string ,
73
- renderer : ( node : ASTNode ) => View ,
74
- parser : MarkdownParser ,
79
+ source : string ,
80
+ renderer : ( node : ASTNode ) => View ,
81
+ parser : MarkdownParser ,
75
82
) : any ;
76
83
77
84
export function stringToTokens (
78
- source : string ,
79
- markdownIt : MarkdownParser ,
85
+ source : string ,
86
+ markdownIt : MarkdownParser ,
80
87
) : Token [ ] ;
81
88
82
89
export function tokensToAST ( tokens : ReadonlyArray < Token > ) : ASTNode [ ] ;
83
90
84
91
export interface MarkdownProps {
85
- rules ?: RenderRules ;
86
- style ?: StyleSheet . NamedStyles < any > ;
87
- renderer ?: AstRenderer ;
88
- markdownit ?: MarkdownIt ;
89
- mergeStyle ?: boolean ;
90
- debugPrintTree ?: boolean ;
91
- onLinkPress ?: ( url : string ) => boolean ;
92
+ rules ?: RenderRules ;
93
+ style ?: StyleSheet . NamedStyles < any > ;
94
+ renderer ?: AstRenderer ;
95
+ markdownit ?: MarkdownIt ;
96
+ mergeStyle ?: boolean ;
97
+ debugPrintTree ?: boolean ;
98
+ onLinkPress ?: ( url : string ) => boolean ;
92
99
}
93
100
94
101
type MarkdownStatic = ComponentType < MarkdownProps > ;
0 commit comments