react-native-marked 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/components/MDImage.js +1 -1
- package/dist/commonjs/components/MDImage.js.map +1 -1
- package/dist/commonjs/lib/Markdown.js.map +1 -1
- package/dist/commonjs/lib/Parser.js +27 -24
- package/dist/commonjs/lib/Parser.js.map +1 -1
- package/dist/commonjs/lib/Renderer.js.map +1 -1
- package/dist/commonjs/theme/colors.js +10 -10
- package/dist/commonjs/theme/colors.js.map +1 -1
- package/dist/commonjs/theme/spacing.js.map +1 -1
- package/dist/commonjs/theme/styles.js +12 -12
- package/dist/commonjs/theme/styles.js.map +1 -1
- package/dist/commonjs/utils/handlers.js.map +1 -1
- package/dist/commonjs/utils/string.js.map +1 -1
- package/dist/commonjs/utils/url.js +3 -3
- package/dist/commonjs/utils/url.js.map +1 -1
- package/dist/module/components/MDImage.js +4 -4
- package/dist/module/components/MDImage.js.map +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/lib/Markdown.js +5 -5
- package/dist/module/lib/Markdown.js.map +1 -1
- package/dist/module/lib/Parser.js +29 -26
- package/dist/module/lib/Parser.js.map +1 -1
- package/dist/module/lib/Renderer.js +8 -8
- package/dist/module/lib/Renderer.js.map +1 -1
- package/dist/module/theme/colors.js +10 -10
- package/dist/module/theme/colors.js.map +1 -1
- package/dist/module/theme/spacing.js.map +1 -1
- package/dist/module/theme/styles.js +15 -15
- package/dist/module/theme/styles.js.map +1 -1
- package/dist/module/utils/handlers.js +1 -1
- package/dist/module/utils/handlers.js.map +1 -1
- package/dist/module/utils/string.js.map +1 -1
- package/dist/module/utils/url.js +3 -3
- package/dist/module/utils/url.js.map +1 -1
- package/dist/typescript/components/MDImage.d.ts +2 -2
- package/dist/typescript/components/MDImage.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +1 -1
- package/dist/typescript/lib/Markdown.d.ts +2 -2
- package/dist/typescript/lib/Parser.d.ts +4 -4
- package/dist/typescript/lib/Parser.d.ts.map +1 -1
- package/dist/typescript/lib/Renderer.d.ts +2 -2
- package/dist/typescript/lib/Renderer.d.ts.map +1 -1
- package/dist/typescript/lib/types.d.ts +4 -4
- package/dist/typescript/lib/types.d.ts.map +1 -1
- package/dist/typescript/theme/colors.d.ts +2 -2
- package/dist/typescript/theme/spacing.d.ts +1 -1
- package/dist/typescript/theme/styles.d.ts +2 -2
- package/dist/typescript/theme/styles.d.ts.map +1 -1
- package/dist/typescript/theme/types.d.ts +3 -3
- package/dist/typescript/theme/types.d.ts.map +1 -1
- package/package.json +7 -57
- package/src/components/MDImage.tsx +19 -19
- package/src/index.ts +1 -1
- package/src/lib/Markdown.tsx +40 -40
- package/src/lib/Parser.tsx +241 -240
- package/src/lib/Renderer.tsx +108 -108
- package/src/lib/types.ts +11 -11
- package/src/theme/colors.ts +16 -16
- package/src/theme/spacing.ts +5 -5
- package/src/theme/styles.ts +126 -126
- package/src/theme/types.ts +25 -25
- package/src/utils/handlers.ts +6 -6
- package/src/utils/string.ts +1 -1
- package/src/utils/url.ts +14 -14
package/src/lib/Renderer.tsx
CHANGED
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
import React, { ReactNode } from
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from
|
|
11
|
-
import MarkedList from
|
|
12
|
-
import Disc from
|
|
13
|
-
import Decimal from
|
|
14
|
-
import MDImage from
|
|
15
|
-
import { generateRandomString } from
|
|
16
|
-
import { onLinkPress } from
|
|
3
|
+
ScrollView,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
TouchableHighlight,
|
|
7
|
+
TextStyle,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
ImageStyle,
|
|
10
|
+
} from "react-native";
|
|
11
|
+
import MarkedList from "@jsamr/react-native-li";
|
|
12
|
+
import Disc from "@jsamr/counter-style/presets/disc";
|
|
13
|
+
import Decimal from "@jsamr/counter-style/presets/decimal";
|
|
14
|
+
import MDImage from "./../components/MDImage";
|
|
15
|
+
import { generateRandomString } from "../utils/string";
|
|
16
|
+
import { onLinkPress } from "../utils/handlers";
|
|
17
17
|
|
|
18
18
|
class Renderer {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
getTextNode = (children: string | ReactNode[], styles?: TextStyle) => {
|
|
20
|
+
return (
|
|
21
|
+
<Text key={generateRandomString()} style={styles}>
|
|
22
|
+
{children}
|
|
23
|
+
</Text>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
getTextLinkNode = (
|
|
28
|
+
children: string | ReactNode[],
|
|
29
|
+
href: string,
|
|
30
|
+
styles?: TextStyle,
|
|
31
|
+
) => {
|
|
32
|
+
return (
|
|
33
|
+
<Text
|
|
34
|
+
accessibilityRole="link"
|
|
35
|
+
accessibilityHint="Opens in a new window"
|
|
36
|
+
key={generateRandomString()}
|
|
37
|
+
onPress={onLinkPress(href)}
|
|
38
|
+
style={styles}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</Text>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
getImageLinkNode = (
|
|
46
|
+
href: string,
|
|
47
|
+
imageUrl: string,
|
|
48
|
+
alt?: string,
|
|
49
|
+
style?: ImageStyle,
|
|
50
|
+
) => {
|
|
51
|
+
const imageNode = this.getImageNode(imageUrl, alt, style);
|
|
52
|
+
return (
|
|
53
|
+
<TouchableHighlight
|
|
54
|
+
accessibilityRole="link"
|
|
55
|
+
accessibilityHint="Opens in a new window"
|
|
56
|
+
onPress={onLinkPress(href)}
|
|
57
|
+
key={generateRandomString()}
|
|
58
|
+
>
|
|
59
|
+
{imageNode}
|
|
60
|
+
</TouchableHighlight>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
getViewNode(children: ReactNode[] | null, styles?: ViewStyle) {
|
|
65
|
+
return (
|
|
66
|
+
<View key={generateRandomString()} style={styles}>
|
|
67
|
+
{children}
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
getCodeBlockNode(
|
|
73
|
+
text: string,
|
|
74
|
+
containerStyle?: ViewStyle,
|
|
75
|
+
textStyle?: TextStyle,
|
|
76
|
+
) {
|
|
77
|
+
return (
|
|
78
|
+
<ScrollView
|
|
79
|
+
key={generateRandomString()}
|
|
80
|
+
contentContainerStyle={containerStyle}
|
|
81
|
+
horizontal={true}
|
|
82
|
+
>
|
|
83
|
+
<Text style={textStyle}>{text}</Text>
|
|
84
|
+
</ScrollView>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
getBlockquoteNode(children: ReactNode[], styles?: ViewStyle) {
|
|
89
|
+
return (
|
|
90
|
+
<View key={generateRandomString()} style={styles}>
|
|
91
|
+
{children}
|
|
92
|
+
</View>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
getImageNode(uri: string, alt?: string, style?: ImageStyle) {
|
|
97
|
+
return (
|
|
98
|
+
<MDImage key={generateRandomString()} uri={uri} alt={alt} style={style} />
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
getListNode(
|
|
103
|
+
ordered: boolean,
|
|
104
|
+
li: ReactNode[],
|
|
105
|
+
listStyle?: ViewStyle,
|
|
106
|
+
textStyle?: TextStyle,
|
|
107
|
+
) {
|
|
108
|
+
return (
|
|
109
|
+
<MarkedList
|
|
110
|
+
counterRenderer={ordered ? Decimal : Disc}
|
|
111
|
+
markerTextStyle={textStyle}
|
|
112
|
+
markerBoxStyle={listStyle}
|
|
113
|
+
key={generateRandomString()}
|
|
114
|
+
>
|
|
115
|
+
{li.map((node) => node)}
|
|
116
|
+
</MarkedList>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export default Renderer;
|
package/src/lib/types.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { ReactNode } from
|
|
2
|
-
import type { FlatListProps } from
|
|
3
|
-
import type { MarkedStyles, UserTheme } from
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { FlatListProps } from "react-native";
|
|
3
|
+
import type { MarkedStyles, UserTheme } from "./../theme/types";
|
|
4
4
|
|
|
5
5
|
export interface ParserOptions {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
styles?: MarkedStyles;
|
|
7
|
+
baseUrl?: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface MarkdownProps extends ParserOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
value: string;
|
|
12
|
+
flatListProps?: Omit<
|
|
13
|
+
FlatListProps<ReactNode>,
|
|
14
|
+
"data" | "renderItem" | "horizontal"
|
|
15
|
+
>;
|
|
16
|
+
theme?: UserTheme;
|
|
17
17
|
}
|
package/src/theme/colors.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export type ColorKeysType =
|
|
1
|
+
export type ColorKeysType = "background" | "code" | "link" | "text" | "border";
|
|
2
2
|
export type ColorsPropType = Record<ColorKeysType, string>;
|
|
3
3
|
|
|
4
|
-
const colors: Record<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const colors: Record<"light" | "dark", ColorsPropType> = {
|
|
5
|
+
light: {
|
|
6
|
+
background: "#ffffff",
|
|
7
|
+
code: "#f6f8fa",
|
|
8
|
+
link: "#58a6ff",
|
|
9
|
+
text: "#333333",
|
|
10
|
+
border: "#d0d7de",
|
|
11
|
+
},
|
|
12
|
+
dark: {
|
|
13
|
+
background: "#000000",
|
|
14
|
+
code: "#161b22",
|
|
15
|
+
link: "#58a6ff",
|
|
16
|
+
text: "#ffffff",
|
|
17
|
+
border: "#30363d",
|
|
18
|
+
},
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export default colors;
|
package/src/theme/spacing.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type SpacingKeysType =
|
|
1
|
+
export type SpacingKeysType = "xs" | "s" | "m" | "l";
|
|
2
2
|
|
|
3
3
|
const padding: Record<SpacingKeysType, number> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
xs: 2,
|
|
5
|
+
s: 4,
|
|
6
|
+
m: 8,
|
|
7
|
+
l: 16,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export default padding;
|
package/src/theme/styles.ts
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import { ColorSchemeName, StyleSheet } from
|
|
2
|
-
import spacing from
|
|
3
|
-
import colors, { type ColorsPropType } from
|
|
4
|
-
import type { MarkedStyles, UserTheme } from
|
|
1
|
+
import { ColorSchemeName, StyleSheet } from "react-native";
|
|
2
|
+
import spacing from "./spacing";
|
|
3
|
+
import colors, { type ColorsPropType } from "./colors";
|
|
4
|
+
import type { MarkedStyles, UserTheme } from "./types";
|
|
5
5
|
|
|
6
6
|
const getFontStyles = (mdColors: ColorsPropType) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
return StyleSheet.create({
|
|
8
|
+
regular: {
|
|
9
|
+
fontSize: 16,
|
|
10
|
+
lineHeight: 24,
|
|
11
|
+
color: mdColors.text,
|
|
12
|
+
},
|
|
13
|
+
heading: {
|
|
14
|
+
fontWeight: "500",
|
|
15
|
+
color: mdColors.text,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const getStyles = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
userStyles?: MarkedStyles,
|
|
22
|
+
colorScheme?: ColorSchemeName,
|
|
23
|
+
userTheme?: UserTheme,
|
|
24
24
|
): MarkedStyles => {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const mdColors = { ...colors[colorScheme || "light"], ...userTheme?.colors };
|
|
26
|
+
const mdSpacing = { ...spacing, ...userTheme?.spacing };
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
28
|
+
const fontStyle = getFontStyles(mdColors);
|
|
29
|
+
const defaultStyles = StyleSheet.create<MarkedStyles>({
|
|
30
|
+
container: {
|
|
31
|
+
backgroundColor: mdColors.background,
|
|
32
|
+
},
|
|
33
|
+
em: {
|
|
34
|
+
...fontStyle.regular,
|
|
35
|
+
fontStyle: "italic",
|
|
36
|
+
},
|
|
37
|
+
strong: {
|
|
38
|
+
...fontStyle.regular,
|
|
39
|
+
fontWeight: "bold",
|
|
40
|
+
},
|
|
41
|
+
strikethrough: {
|
|
42
|
+
...fontStyle.regular,
|
|
43
|
+
textDecorationLine: "line-through",
|
|
44
|
+
textDecorationStyle: "solid",
|
|
45
|
+
},
|
|
46
|
+
text: {
|
|
47
|
+
...fontStyle.regular,
|
|
48
|
+
},
|
|
49
|
+
paragraph: {
|
|
50
|
+
...fontStyle.regular,
|
|
51
|
+
paddingVertical: mdSpacing.m,
|
|
52
|
+
},
|
|
53
|
+
link: {
|
|
54
|
+
...fontStyle.regular,
|
|
55
|
+
fontStyle: "italic",
|
|
56
|
+
color: mdColors.link,
|
|
57
|
+
},
|
|
58
|
+
blockquote: {
|
|
59
|
+
borderLeftColor: mdColors.border,
|
|
60
|
+
paddingLeft: mdSpacing.l,
|
|
61
|
+
borderLeftWidth: mdSpacing.s,
|
|
62
|
+
opacity: 0.8,
|
|
63
|
+
},
|
|
64
|
+
h1: {
|
|
65
|
+
fontSize: 32,
|
|
66
|
+
lineHeight: 40,
|
|
67
|
+
fontWeight: "bold",
|
|
68
|
+
marginVertical: mdSpacing.m,
|
|
69
|
+
letterSpacing: 0,
|
|
70
|
+
paddingBottom: mdSpacing.s,
|
|
71
|
+
borderBottomColor: mdColors.border,
|
|
72
|
+
borderBottomWidth: 1,
|
|
73
|
+
},
|
|
74
|
+
h2: {
|
|
75
|
+
...fontStyle.heading,
|
|
76
|
+
fontSize: 28,
|
|
77
|
+
lineHeight: 36,
|
|
78
|
+
marginVertical: mdSpacing.m,
|
|
79
|
+
paddingBottom: mdSpacing.s,
|
|
80
|
+
borderBottomColor: mdColors.border,
|
|
81
|
+
borderBottomWidth: 1,
|
|
82
|
+
},
|
|
83
|
+
h3: {
|
|
84
|
+
...fontStyle.heading,
|
|
85
|
+
fontSize: 24,
|
|
86
|
+
lineHeight: 32,
|
|
87
|
+
marginVertical: mdSpacing.s,
|
|
88
|
+
},
|
|
89
|
+
h4: {
|
|
90
|
+
...fontStyle.heading,
|
|
91
|
+
fontSize: 22,
|
|
92
|
+
lineHeight: 28,
|
|
93
|
+
marginVertical: mdSpacing.s,
|
|
94
|
+
},
|
|
95
|
+
h5: {
|
|
96
|
+
...fontStyle.regular,
|
|
97
|
+
...fontStyle.heading,
|
|
98
|
+
marginVertical: mdSpacing.xs,
|
|
99
|
+
},
|
|
100
|
+
h6: {
|
|
101
|
+
...fontStyle.heading,
|
|
102
|
+
fontSize: 14,
|
|
103
|
+
lineHeight: 20,
|
|
104
|
+
marginVertical: mdSpacing.xs,
|
|
105
|
+
},
|
|
106
|
+
codespan: {
|
|
107
|
+
...fontStyle.regular,
|
|
108
|
+
fontStyle: "italic",
|
|
109
|
+
backgroundColor: mdColors.code,
|
|
110
|
+
fontWeight: "300",
|
|
111
|
+
},
|
|
112
|
+
code: {
|
|
113
|
+
padding: mdSpacing.l,
|
|
114
|
+
backgroundColor: mdColors.code,
|
|
115
|
+
minWidth: "100%",
|
|
116
|
+
},
|
|
117
|
+
hr: {
|
|
118
|
+
borderBottomWidth: 1,
|
|
119
|
+
borderBottomColor: mdColors.border,
|
|
120
|
+
marginVertical: mdSpacing.s,
|
|
121
|
+
},
|
|
122
|
+
li: {
|
|
123
|
+
...fontStyle.regular,
|
|
124
|
+
flexShrink: 1,
|
|
125
|
+
},
|
|
126
|
+
image: {
|
|
127
|
+
resizeMode: "cover",
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
return {
|
|
132
|
+
...defaultStyles,
|
|
133
|
+
...userStyles,
|
|
134
|
+
};
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
export default getStyles;
|
package/src/theme/types.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type { ImageStyle, TextStyle, ViewStyle } from
|
|
2
|
-
import type { ColorKeysType } from
|
|
3
|
-
import type { SpacingKeysType } from
|
|
1
|
+
import type { ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
import type { ColorKeysType } from "./colors";
|
|
3
|
+
import type { SpacingKeysType } from "./spacing";
|
|
4
4
|
|
|
5
5
|
export interface MarkedStyles {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
container?: ViewStyle;
|
|
7
|
+
em?: TextStyle;
|
|
8
|
+
strong?: TextStyle;
|
|
9
|
+
strikethrough?: TextStyle;
|
|
10
|
+
text?: TextStyle;
|
|
11
|
+
paragraph?: ViewStyle;
|
|
12
|
+
link?: TextStyle;
|
|
13
|
+
blockquote?: ViewStyle;
|
|
14
|
+
h1?: TextStyle;
|
|
15
|
+
h2?: TextStyle;
|
|
16
|
+
h3?: TextStyle;
|
|
17
|
+
h4?: TextStyle;
|
|
18
|
+
h5?: TextStyle;
|
|
19
|
+
h6?: TextStyle;
|
|
20
|
+
codespan?: TextStyle;
|
|
21
|
+
code?: ViewStyle;
|
|
22
|
+
hr?: ViewStyle;
|
|
23
|
+
list?: ViewStyle;
|
|
24
|
+
li?: TextStyle;
|
|
25
|
+
image?: ImageStyle;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface UserTheme {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
colors?: Record<ColorKeysType, string>;
|
|
30
|
+
spacing?: Record<SpacingKeysType, number>;
|
|
31
31
|
}
|
package/src/utils/handlers.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Linking } from
|
|
1
|
+
import { Linking } from "react-native";
|
|
2
2
|
|
|
3
3
|
export const onLinkPress = (url: string) => () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
Linking.openURL(url)
|
|
5
|
+
.then(() => null)
|
|
6
|
+
.catch((e) => {
|
|
7
|
+
console.warn("URL can't be opened", e);
|
|
8
|
+
});
|
|
9
9
|
};
|
package/src/utils/string.ts
CHANGED