react-native-marked 8.2.0 → 8.3.1
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/LICENSE +20 -20
- package/README.md +374 -354
- package/dist/commonjs/components/MDImage.js +3 -3
- package/dist/commonjs/components/MDImage.js.map +1 -1
- package/dist/commonjs/components/MDList.js.map +1 -1
- package/dist/commonjs/components/MDSvg.js.map +1 -1
- package/dist/commonjs/components/MDTable.js.map +1 -1
- package/dist/commonjs/hooks/useMarkdown.js +4 -2
- package/dist/commonjs/hooks/useMarkdown.js.map +1 -1
- package/dist/commonjs/hooks/useMarkdownWithComponents.js +7 -1
- package/dist/commonjs/hooks/useMarkdownWithComponents.js.map +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/lib/Markdown.js +4 -2
- package/dist/commonjs/lib/Markdown.js.map +1 -1
- package/dist/commonjs/lib/Parser.js +7 -7
- package/dist/commonjs/lib/Parser.js.map +1 -1
- package/dist/commonjs/lib/ReactComponentRegistry.js.map +1 -1
- package/dist/commonjs/lib/ReactComponentTokenizer.js.map +1 -1
- package/dist/commonjs/lib/Renderer.js +7 -5
- package/dist/commonjs/lib/Renderer.js.map +1 -1
- package/dist/commonjs/lib/types.js.map +1 -1
- package/dist/commonjs/theme/colors.js.map +1 -1
- package/dist/commonjs/theme/spacing.js.map +1 -1
- package/dist/commonjs/theme/styles.js +4 -0
- package/dist/commonjs/theme/styles.js.map +1 -1
- package/dist/commonjs/theme/types.js.map +1 -1
- package/dist/commonjs/utils/handlers.js.map +1 -1
- package/dist/commonjs/utils/svg.js.map +1 -1
- package/dist/commonjs/utils/table.js.map +1 -1
- package/dist/commonjs/utils/url.js.map +1 -1
- package/dist/module/components/MDImage.js +3 -3
- package/dist/module/components/MDImage.js.map +1 -1
- package/dist/module/components/MDList.js.map +1 -1
- package/dist/module/components/MDSvg.js.map +1 -1
- package/dist/module/components/MDTable.js.map +1 -1
- package/dist/module/hooks/useMarkdown.js +4 -2
- package/dist/module/hooks/useMarkdown.js.map +1 -1
- package/dist/module/hooks/useMarkdownWithComponents.js +7 -1
- package/dist/module/hooks/useMarkdownWithComponents.js.map +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/Markdown.js +4 -2
- package/dist/module/lib/Markdown.js.map +1 -1
- package/dist/module/lib/Parser.js +7 -7
- package/dist/module/lib/Parser.js.map +1 -1
- package/dist/module/lib/ReactComponentRegistry.js.map +1 -1
- package/dist/module/lib/ReactComponentTokenizer.js.map +1 -1
- package/dist/module/lib/Renderer.js +7 -5
- package/dist/module/lib/Renderer.js.map +1 -1
- package/dist/module/lib/types.js.map +1 -1
- package/dist/module/theme/colors.js.map +1 -1
- package/dist/module/theme/spacing.js.map +1 -1
- package/dist/module/theme/styles.js +4 -0
- package/dist/module/theme/styles.js.map +1 -1
- package/dist/module/theme/types.js.map +1 -1
- package/dist/module/utils/handlers.js.map +1 -1
- package/dist/module/utils/svg.js.map +1 -1
- package/dist/module/utils/table.js.map +1 -1
- package/dist/module/utils/url.js.map +1 -1
- package/dist/typescript/hooks/useMarkdown.d.ts +3 -0
- package/dist/typescript/hooks/useMarkdown.d.ts.map +1 -1
- package/dist/typescript/hooks/useMarkdownWithComponents.d.ts.map +1 -1
- package/dist/typescript/index.d.ts +2 -2
- package/dist/typescript/index.d.ts.map +1 -1
- package/dist/typescript/lib/Markdown.d.ts +1 -1
- package/dist/typescript/lib/Markdown.d.ts.map +1 -1
- package/dist/typescript/lib/Renderer.d.ts +8 -1
- package/dist/typescript/lib/Renderer.d.ts.map +1 -1
- package/dist/typescript/lib/types.d.ts +6 -0
- package/dist/typescript/lib/types.d.ts.map +1 -1
- package/dist/typescript/theme/styles.d.ts.map +1 -1
- package/dist/typescript/theme/types.d.ts +1 -0
- package/dist/typescript/theme/types.d.ts.map +1 -1
- package/package.json +178 -175
- package/src/components/MDImage.tsx +90 -90
- package/src/components/MDList.tsx +46 -46
- package/src/components/MDSvg.tsx +108 -108
- package/src/components/MDTable.tsx +60 -60
- package/src/hooks/useMarkdown.ts +56 -51
- package/src/hooks/useMarkdownWithComponents.tsx +94 -89
- package/src/index.ts +44 -43
- package/src/lib/Markdown.tsx +55 -53
- package/src/lib/Parser.tsx +316 -316
- package/src/lib/ReactComponentRegistry.tsx +52 -52
- package/src/lib/ReactComponentTokenizer.ts +149 -149
- package/src/lib/Renderer.tsx +247 -238
- package/src/lib/types.ts +93 -87
- package/src/theme/colors.ts +31 -31
- package/src/theme/spacing.ts +10 -10
- package/src/theme/styles.ts +206 -198
- package/src/theme/types.ts +34 -33
- package/src/utils/handlers.ts +9 -9
- package/src/utils/svg.ts +14 -14
- package/src/utils/table.ts +29 -29
- package/src/utils/url.ts +22 -22
package/src/theme/colors.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type { ColorValue } from "react-native";
|
|
2
|
-
|
|
3
|
-
export interface ColorsPropType {
|
|
4
|
-
code: ColorValue;
|
|
5
|
-
link: ColorValue;
|
|
6
|
-
text: ColorValue;
|
|
7
|
-
border: ColorValue;
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use flatlist containerStyle or style prop for setting background color
|
|
10
|
-
*/
|
|
11
|
-
background?: ColorValue;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const colors: Record<"light" | "dark", ColorsPropType> = {
|
|
15
|
-
light: {
|
|
16
|
-
background: "#ffffff",
|
|
17
|
-
code: "#f6f8fa",
|
|
18
|
-
link: "#58a6ff",
|
|
19
|
-
text: "#333333",
|
|
20
|
-
border: "#d0d7de",
|
|
21
|
-
},
|
|
22
|
-
dark: {
|
|
23
|
-
background: "#000000",
|
|
24
|
-
code: "#161b22",
|
|
25
|
-
link: "#58a6ff",
|
|
26
|
-
text: "#ffffff",
|
|
27
|
-
border: "#30363d",
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default colors;
|
|
1
|
+
import type { ColorValue } from "react-native";
|
|
2
|
+
|
|
3
|
+
export interface ColorsPropType {
|
|
4
|
+
code: ColorValue;
|
|
5
|
+
link: ColorValue;
|
|
6
|
+
text: ColorValue;
|
|
7
|
+
border: ColorValue;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use flatlist containerStyle or style prop for setting background color
|
|
10
|
+
*/
|
|
11
|
+
background?: ColorValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const colors: Record<"light" | "dark", ColorsPropType> = {
|
|
15
|
+
light: {
|
|
16
|
+
background: "#ffffff",
|
|
17
|
+
code: "#f6f8fa",
|
|
18
|
+
link: "#58a6ff",
|
|
19
|
+
text: "#333333",
|
|
20
|
+
border: "#d0d7de",
|
|
21
|
+
},
|
|
22
|
+
dark: {
|
|
23
|
+
background: "#000000",
|
|
24
|
+
code: "#161b22",
|
|
25
|
+
link: "#58a6ff",
|
|
26
|
+
text: "#ffffff",
|
|
27
|
+
border: "#30363d",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default colors;
|
package/src/theme/spacing.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type SpacingKeysType = "xs" | "s" | "m" | "l";
|
|
2
|
-
|
|
3
|
-
const padding: Record<SpacingKeysType, number> = {
|
|
4
|
-
xs: 2,
|
|
5
|
-
s: 4,
|
|
6
|
-
m: 8,
|
|
7
|
-
l: 16,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default padding;
|
|
1
|
+
export type SpacingKeysType = "xs" | "s" | "m" | "l";
|
|
2
|
+
|
|
3
|
+
const padding: Record<SpacingKeysType, number> = {
|
|
4
|
+
xs: 2,
|
|
5
|
+
s: 4,
|
|
6
|
+
m: 8,
|
|
7
|
+
l: 16,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default padding;
|
package/src/theme/styles.ts
CHANGED
|
@@ -1,198 +1,206 @@
|
|
|
1
|
-
import { type ColorSchemeName, StyleSheet } from "react-native";
|
|
2
|
-
import colors, { type ColorsPropType } from "./colors";
|
|
3
|
-
import spacing from "./spacing";
|
|
4
|
-
import type { MarkedStyles, UserTheme } from "./types";
|
|
5
|
-
|
|
6
|
-
const getFontStyles = (mdColors: ColorsPropType) => {
|
|
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
|
-
};
|
|
19
|
-
|
|
20
|
-
const getStyles = (
|
|
21
|
-
userStyles?: MarkedStyles,
|
|
22
|
-
colorScheme?: ColorSchemeName,
|
|
23
|
-
userTheme?: UserTheme,
|
|
24
|
-
): MarkedStyles => {
|
|
25
|
-
const mdColors = { ...colors[colorScheme || "light"], ...userTheme?.colors };
|
|
26
|
-
const mdSpacing = { ...spacing, ...userTheme?.spacing };
|
|
27
|
-
|
|
28
|
-
const fontStyle = getFontStyles(mdColors);
|
|
29
|
-
return StyleSheet.create<MarkedStyles>({
|
|
30
|
-
em: StyleSheet.flatten([
|
|
31
|
-
fontStyle.regular,
|
|
32
|
-
{
|
|
33
|
-
fontStyle: "italic",
|
|
34
|
-
},
|
|
35
|
-
userStyles?.em,
|
|
36
|
-
]),
|
|
37
|
-
strong: StyleSheet.flatten([
|
|
38
|
-
fontStyle.regular,
|
|
39
|
-
{
|
|
40
|
-
fontWeight: "bold",
|
|
41
|
-
},
|
|
42
|
-
userStyles?.strong,
|
|
43
|
-
]),
|
|
44
|
-
strikethrough: StyleSheet.flatten([
|
|
45
|
-
fontStyle.regular,
|
|
46
|
-
{
|
|
47
|
-
textDecorationLine: "line-through",
|
|
48
|
-
textDecorationStyle: "solid",
|
|
49
|
-
},
|
|
50
|
-
userStyles?.strikethrough,
|
|
51
|
-
]),
|
|
52
|
-
text: StyleSheet.flatten([fontStyle.regular, userStyles?.text]),
|
|
53
|
-
paragraph: StyleSheet.flatten([
|
|
54
|
-
{
|
|
55
|
-
paddingVertical: mdSpacing.m,
|
|
56
|
-
},
|
|
57
|
-
userStyles?.paragraph,
|
|
58
|
-
]),
|
|
59
|
-
link: StyleSheet.flatten([
|
|
60
|
-
fontStyle.regular,
|
|
61
|
-
{
|
|
62
|
-
fontStyle: "italic",
|
|
63
|
-
color: mdColors.link,
|
|
64
|
-
},
|
|
65
|
-
userStyles?.link,
|
|
66
|
-
]),
|
|
67
|
-
blockquote: StyleSheet.flatten([
|
|
68
|
-
{
|
|
69
|
-
borderLeftColor: mdColors.border,
|
|
70
|
-
paddingLeft: mdSpacing.l,
|
|
71
|
-
borderLeftWidth: mdSpacing.s,
|
|
72
|
-
opacity: 0.8,
|
|
73
|
-
},
|
|
74
|
-
userStyles?.blockquote,
|
|
75
|
-
]),
|
|
76
|
-
h1: StyleSheet.flatten([
|
|
77
|
-
fontStyle.heading,
|
|
78
|
-
{
|
|
79
|
-
fontSize: 32,
|
|
80
|
-
lineHeight: 40,
|
|
81
|
-
fontWeight: "bold",
|
|
82
|
-
marginVertical: mdSpacing.m,
|
|
83
|
-
letterSpacing: 0,
|
|
84
|
-
paddingBottom: mdSpacing.s,
|
|
85
|
-
borderBottomColor: mdColors.border,
|
|
86
|
-
borderBottomWidth: 1,
|
|
87
|
-
},
|
|
88
|
-
userStyles?.h1,
|
|
89
|
-
]),
|
|
90
|
-
h2: StyleSheet.flatten([
|
|
91
|
-
fontStyle.heading,
|
|
92
|
-
{
|
|
93
|
-
fontSize: 28,
|
|
94
|
-
lineHeight: 36,
|
|
95
|
-
marginVertical: mdSpacing.m,
|
|
96
|
-
paddingBottom: mdSpacing.s,
|
|
97
|
-
borderBottomColor: mdColors.border,
|
|
98
|
-
borderBottomWidth: 1,
|
|
99
|
-
},
|
|
100
|
-
userStyles?.h2,
|
|
101
|
-
]),
|
|
102
|
-
h3: StyleSheet.flatten([
|
|
103
|
-
fontStyle.heading,
|
|
104
|
-
{
|
|
105
|
-
fontSize: 24,
|
|
106
|
-
lineHeight: 32,
|
|
107
|
-
marginVertical: mdSpacing.s,
|
|
108
|
-
},
|
|
109
|
-
userStyles?.h3,
|
|
110
|
-
]),
|
|
111
|
-
h4: StyleSheet.flatten([
|
|
112
|
-
fontStyle.heading,
|
|
113
|
-
{
|
|
114
|
-
fontSize: 22,
|
|
115
|
-
lineHeight: 28,
|
|
116
|
-
marginVertical: mdSpacing.s,
|
|
117
|
-
},
|
|
118
|
-
userStyles?.h4,
|
|
119
|
-
]),
|
|
120
|
-
h5: StyleSheet.flatten([
|
|
121
|
-
fontStyle.regular,
|
|
122
|
-
fontStyle.heading,
|
|
123
|
-
{
|
|
124
|
-
marginVertical: mdSpacing.xs,
|
|
125
|
-
},
|
|
126
|
-
userStyles?.h5,
|
|
127
|
-
]),
|
|
128
|
-
h6: StyleSheet.flatten([
|
|
129
|
-
fontStyle.heading,
|
|
130
|
-
{
|
|
131
|
-
fontSize: 14,
|
|
132
|
-
lineHeight: 20,
|
|
133
|
-
marginVertical: mdSpacing.xs,
|
|
134
|
-
},
|
|
135
|
-
userStyles?.h6,
|
|
136
|
-
]),
|
|
137
|
-
codespan: StyleSheet.flatten([
|
|
138
|
-
fontStyle.regular,
|
|
139
|
-
{
|
|
140
|
-
fontStyle: "italic",
|
|
141
|
-
backgroundColor: mdColors.code,
|
|
142
|
-
fontWeight: "300",
|
|
143
|
-
},
|
|
144
|
-
userStyles?.codespan,
|
|
145
|
-
]),
|
|
146
|
-
code: StyleSheet.flatten([
|
|
147
|
-
{
|
|
148
|
-
padding: mdSpacing.l,
|
|
149
|
-
backgroundColor: mdColors.code,
|
|
150
|
-
minWidth: "100%",
|
|
151
|
-
},
|
|
152
|
-
userStyles?.code,
|
|
153
|
-
]),
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
userStyles?.
|
|
161
|
-
]),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
userStyles?.
|
|
169
|
-
]),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
1
|
+
import { type ColorSchemeName, StyleSheet } from "react-native";
|
|
2
|
+
import colors, { type ColorsPropType } from "./colors";
|
|
3
|
+
import spacing from "./spacing";
|
|
4
|
+
import type { MarkedStyles, UserTheme } from "./types";
|
|
5
|
+
|
|
6
|
+
const getFontStyles = (mdColors: ColorsPropType) => {
|
|
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
|
+
};
|
|
19
|
+
|
|
20
|
+
const getStyles = (
|
|
21
|
+
userStyles?: MarkedStyles,
|
|
22
|
+
colorScheme?: ColorSchemeName,
|
|
23
|
+
userTheme?: UserTheme,
|
|
24
|
+
): MarkedStyles => {
|
|
25
|
+
const mdColors = { ...colors[colorScheme || "light"], ...userTheme?.colors };
|
|
26
|
+
const mdSpacing = { ...spacing, ...userTheme?.spacing };
|
|
27
|
+
|
|
28
|
+
const fontStyle = getFontStyles(mdColors);
|
|
29
|
+
return StyleSheet.create<MarkedStyles>({
|
|
30
|
+
em: StyleSheet.flatten([
|
|
31
|
+
fontStyle.regular,
|
|
32
|
+
{
|
|
33
|
+
fontStyle: "italic",
|
|
34
|
+
},
|
|
35
|
+
userStyles?.em,
|
|
36
|
+
]),
|
|
37
|
+
strong: StyleSheet.flatten([
|
|
38
|
+
fontStyle.regular,
|
|
39
|
+
{
|
|
40
|
+
fontWeight: "bold",
|
|
41
|
+
},
|
|
42
|
+
userStyles?.strong,
|
|
43
|
+
]),
|
|
44
|
+
strikethrough: StyleSheet.flatten([
|
|
45
|
+
fontStyle.regular,
|
|
46
|
+
{
|
|
47
|
+
textDecorationLine: "line-through",
|
|
48
|
+
textDecorationStyle: "solid",
|
|
49
|
+
},
|
|
50
|
+
userStyles?.strikethrough,
|
|
51
|
+
]),
|
|
52
|
+
text: StyleSheet.flatten([fontStyle.regular, userStyles?.text]),
|
|
53
|
+
paragraph: StyleSheet.flatten([
|
|
54
|
+
{
|
|
55
|
+
paddingVertical: mdSpacing.m,
|
|
56
|
+
},
|
|
57
|
+
userStyles?.paragraph,
|
|
58
|
+
]),
|
|
59
|
+
link: StyleSheet.flatten([
|
|
60
|
+
fontStyle.regular,
|
|
61
|
+
{
|
|
62
|
+
fontStyle: "italic",
|
|
63
|
+
color: mdColors.link,
|
|
64
|
+
},
|
|
65
|
+
userStyles?.link,
|
|
66
|
+
]),
|
|
67
|
+
blockquote: StyleSheet.flatten([
|
|
68
|
+
{
|
|
69
|
+
borderLeftColor: mdColors.border,
|
|
70
|
+
paddingLeft: mdSpacing.l,
|
|
71
|
+
borderLeftWidth: mdSpacing.s,
|
|
72
|
+
opacity: 0.8,
|
|
73
|
+
},
|
|
74
|
+
userStyles?.blockquote,
|
|
75
|
+
]),
|
|
76
|
+
h1: StyleSheet.flatten([
|
|
77
|
+
fontStyle.heading,
|
|
78
|
+
{
|
|
79
|
+
fontSize: 32,
|
|
80
|
+
lineHeight: 40,
|
|
81
|
+
fontWeight: "bold",
|
|
82
|
+
marginVertical: mdSpacing.m,
|
|
83
|
+
letterSpacing: 0,
|
|
84
|
+
paddingBottom: mdSpacing.s,
|
|
85
|
+
borderBottomColor: mdColors.border,
|
|
86
|
+
borderBottomWidth: 1,
|
|
87
|
+
},
|
|
88
|
+
userStyles?.h1,
|
|
89
|
+
]),
|
|
90
|
+
h2: StyleSheet.flatten([
|
|
91
|
+
fontStyle.heading,
|
|
92
|
+
{
|
|
93
|
+
fontSize: 28,
|
|
94
|
+
lineHeight: 36,
|
|
95
|
+
marginVertical: mdSpacing.m,
|
|
96
|
+
paddingBottom: mdSpacing.s,
|
|
97
|
+
borderBottomColor: mdColors.border,
|
|
98
|
+
borderBottomWidth: 1,
|
|
99
|
+
},
|
|
100
|
+
userStyles?.h2,
|
|
101
|
+
]),
|
|
102
|
+
h3: StyleSheet.flatten([
|
|
103
|
+
fontStyle.heading,
|
|
104
|
+
{
|
|
105
|
+
fontSize: 24,
|
|
106
|
+
lineHeight: 32,
|
|
107
|
+
marginVertical: mdSpacing.s,
|
|
108
|
+
},
|
|
109
|
+
userStyles?.h3,
|
|
110
|
+
]),
|
|
111
|
+
h4: StyleSheet.flatten([
|
|
112
|
+
fontStyle.heading,
|
|
113
|
+
{
|
|
114
|
+
fontSize: 22,
|
|
115
|
+
lineHeight: 28,
|
|
116
|
+
marginVertical: mdSpacing.s,
|
|
117
|
+
},
|
|
118
|
+
userStyles?.h4,
|
|
119
|
+
]),
|
|
120
|
+
h5: StyleSheet.flatten([
|
|
121
|
+
fontStyle.regular,
|
|
122
|
+
fontStyle.heading,
|
|
123
|
+
{
|
|
124
|
+
marginVertical: mdSpacing.xs,
|
|
125
|
+
},
|
|
126
|
+
userStyles?.h5,
|
|
127
|
+
]),
|
|
128
|
+
h6: StyleSheet.flatten([
|
|
129
|
+
fontStyle.heading,
|
|
130
|
+
{
|
|
131
|
+
fontSize: 14,
|
|
132
|
+
lineHeight: 20,
|
|
133
|
+
marginVertical: mdSpacing.xs,
|
|
134
|
+
},
|
|
135
|
+
userStyles?.h6,
|
|
136
|
+
]),
|
|
137
|
+
codespan: StyleSheet.flatten([
|
|
138
|
+
fontStyle.regular,
|
|
139
|
+
{
|
|
140
|
+
fontStyle: "italic",
|
|
141
|
+
backgroundColor: mdColors.code,
|
|
142
|
+
fontWeight: "300",
|
|
143
|
+
},
|
|
144
|
+
userStyles?.codespan,
|
|
145
|
+
]),
|
|
146
|
+
code: StyleSheet.flatten([
|
|
147
|
+
{
|
|
148
|
+
padding: mdSpacing.l,
|
|
149
|
+
backgroundColor: mdColors.code,
|
|
150
|
+
minWidth: "100%",
|
|
151
|
+
},
|
|
152
|
+
userStyles?.code,
|
|
153
|
+
]),
|
|
154
|
+
codeText: StyleSheet.flatten([
|
|
155
|
+
fontStyle.regular,
|
|
156
|
+
{
|
|
157
|
+
fontStyle: "normal",
|
|
158
|
+
fontWeight: "400",
|
|
159
|
+
},
|
|
160
|
+
userStyles?.codeText,
|
|
161
|
+
]),
|
|
162
|
+
hr: StyleSheet.flatten([
|
|
163
|
+
{
|
|
164
|
+
borderBottomWidth: 1,
|
|
165
|
+
borderBottomColor: mdColors.border,
|
|
166
|
+
marginVertical: mdSpacing.s,
|
|
167
|
+
},
|
|
168
|
+
userStyles?.hr,
|
|
169
|
+
]),
|
|
170
|
+
list: StyleSheet.flatten([userStyles?.list]),
|
|
171
|
+
li: StyleSheet.flatten([
|
|
172
|
+
fontStyle.regular,
|
|
173
|
+
{
|
|
174
|
+
flexShrink: 1,
|
|
175
|
+
},
|
|
176
|
+
userStyles?.li,
|
|
177
|
+
]),
|
|
178
|
+
image: StyleSheet.flatten([
|
|
179
|
+
{
|
|
180
|
+
resizeMode: "cover",
|
|
181
|
+
},
|
|
182
|
+
userStyles?.image,
|
|
183
|
+
]),
|
|
184
|
+
table: StyleSheet.flatten([
|
|
185
|
+
{
|
|
186
|
+
borderWidth: 1,
|
|
187
|
+
borderColor: mdColors.border,
|
|
188
|
+
},
|
|
189
|
+
userStyles?.table,
|
|
190
|
+
]),
|
|
191
|
+
tableRow: StyleSheet.flatten([
|
|
192
|
+
{
|
|
193
|
+
flexDirection: "row",
|
|
194
|
+
},
|
|
195
|
+
userStyles?.tableRow,
|
|
196
|
+
]),
|
|
197
|
+
tableCell: StyleSheet.flatten([
|
|
198
|
+
{
|
|
199
|
+
padding: mdSpacing.s,
|
|
200
|
+
},
|
|
201
|
+
userStyles?.tableCell,
|
|
202
|
+
]),
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export default getStyles;
|
package/src/theme/types.ts
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import type { ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
2
|
-
import type { ColorsPropType } from "./colors";
|
|
3
|
-
import type { SpacingKeysType } from "./spacing";
|
|
4
|
-
|
|
5
|
-
export interface MarkedStyles {
|
|
6
|
-
em?: TextStyle;
|
|
7
|
-
strong?: TextStyle;
|
|
8
|
-
strikethrough?: TextStyle;
|
|
9
|
-
text?: TextStyle;
|
|
10
|
-
paragraph?: ViewStyle;
|
|
11
|
-
link?: TextStyle;
|
|
12
|
-
blockquote?: ViewStyle;
|
|
13
|
-
h1?: TextStyle;
|
|
14
|
-
h2?: TextStyle;
|
|
15
|
-
h3?: TextStyle;
|
|
16
|
-
h4?: TextStyle;
|
|
17
|
-
h5?: TextStyle;
|
|
18
|
-
h6?: TextStyle;
|
|
19
|
-
codespan?: TextStyle;
|
|
20
|
-
code?: ViewStyle;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import type { ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
import type { ColorsPropType } from "./colors";
|
|
3
|
+
import type { SpacingKeysType } from "./spacing";
|
|
4
|
+
|
|
5
|
+
export interface MarkedStyles {
|
|
6
|
+
em?: TextStyle;
|
|
7
|
+
strong?: TextStyle;
|
|
8
|
+
strikethrough?: TextStyle;
|
|
9
|
+
text?: TextStyle;
|
|
10
|
+
paragraph?: ViewStyle;
|
|
11
|
+
link?: TextStyle;
|
|
12
|
+
blockquote?: ViewStyle;
|
|
13
|
+
h1?: TextStyle;
|
|
14
|
+
h2?: TextStyle;
|
|
15
|
+
h3?: TextStyle;
|
|
16
|
+
h4?: TextStyle;
|
|
17
|
+
h5?: TextStyle;
|
|
18
|
+
h6?: TextStyle;
|
|
19
|
+
codespan?: TextStyle;
|
|
20
|
+
code?: ViewStyle;
|
|
21
|
+
codeText?: TextStyle;
|
|
22
|
+
hr?: ViewStyle;
|
|
23
|
+
list?: ViewStyle;
|
|
24
|
+
li?: TextStyle;
|
|
25
|
+
image?: ImageStyle;
|
|
26
|
+
table?: ViewStyle;
|
|
27
|
+
tableRow?: ViewStyle;
|
|
28
|
+
tableCell?: ViewStyle;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface UserTheme {
|
|
32
|
+
colors?: ColorsPropType;
|
|
33
|
+
spacing?: Record<SpacingKeysType, number>;
|
|
34
|
+
}
|
package/src/utils/handlers.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Linking } from "react-native";
|
|
2
|
-
|
|
3
|
-
export const onLinkPress = (url: string) => () => {
|
|
4
|
-
Linking.openURL(url)
|
|
5
|
-
.then(() => null)
|
|
6
|
-
.catch((e) => {
|
|
7
|
-
console.warn("URL can't be opened", e);
|
|
8
|
-
});
|
|
9
|
-
};
|
|
1
|
+
import { Linking } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const onLinkPress = (url: string) => () => {
|
|
4
|
+
Linking.openURL(url)
|
|
5
|
+
.then(() => null)
|
|
6
|
+
.catch((e) => {
|
|
7
|
+
console.warn("URL can't be opened", e);
|
|
8
|
+
});
|
|
9
|
+
};
|
package/src/utils/svg.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { ElementNode } from "svg-parser";
|
|
2
|
-
import { parse } from "svg-parser";
|
|
3
|
-
|
|
4
|
-
export const getSvgDimensions = (svg: string) => {
|
|
5
|
-
const parsed = parse(svg);
|
|
6
|
-
|
|
7
|
-
const rootChild = parsed.children[0] as ElementNode;
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
width: Number.parseInt(String(rootChild.properties?.width ?? "0"), 10),
|
|
11
|
-
height: Number.parseInt(String(rootChild.properties?.height ?? "0"), 10),
|
|
12
|
-
viewBox: String(rootChild.properties?.viewBox ?? ""),
|
|
13
|
-
};
|
|
14
|
-
};
|
|
1
|
+
import type { ElementNode } from "svg-parser";
|
|
2
|
+
import { parse } from "svg-parser";
|
|
3
|
+
|
|
4
|
+
export const getSvgDimensions = (svg: string) => {
|
|
5
|
+
const parsed = parse(svg);
|
|
6
|
+
|
|
7
|
+
const rootChild = parsed.children[0] as ElementNode;
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
width: Number.parseInt(String(rootChild.properties?.width ?? "0"), 10),
|
|
11
|
+
height: Number.parseInt(String(rootChild.properties?.height ?? "0"), 10),
|
|
12
|
+
viewBox: String(rootChild.properties?.viewBox ?? ""),
|
|
13
|
+
};
|
|
14
|
+
};
|
package/src/utils/table.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type { TextStyle } from "react-native";
|
|
2
|
-
import type { TableColAlignment } from "../lib/types";
|
|
3
|
-
|
|
4
|
-
export const getTableWidthArr = (totalCols: number, windowWidth: number) => {
|
|
5
|
-
if (totalCols < 1) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return Array(totalCols)
|
|
10
|
-
.fill(0)
|
|
11
|
-
.map(() => {
|
|
12
|
-
return Math.floor(windowWidth * (1.3 / 3));
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const getTableColAlignmentStyle = (
|
|
17
|
-
alignment?: TableColAlignment,
|
|
18
|
-
): TextStyle => {
|
|
19
|
-
switch (alignment) {
|
|
20
|
-
case "center":
|
|
21
|
-
return { textAlign: "center" };
|
|
22
|
-
case "left":
|
|
23
|
-
return { textAlign: "left" };
|
|
24
|
-
case "right":
|
|
25
|
-
return { textAlign: "right" };
|
|
26
|
-
default:
|
|
27
|
-
return { textAlign: "left" };
|
|
28
|
-
}
|
|
29
|
-
};
|
|
1
|
+
import type { TextStyle } from "react-native";
|
|
2
|
+
import type { TableColAlignment } from "../lib/types";
|
|
3
|
+
|
|
4
|
+
export const getTableWidthArr = (totalCols: number, windowWidth: number) => {
|
|
5
|
+
if (totalCols < 1) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return Array(totalCols)
|
|
10
|
+
.fill(0)
|
|
11
|
+
.map(() => {
|
|
12
|
+
return Math.floor(windowWidth * (1.3 / 3));
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getTableColAlignmentStyle = (
|
|
17
|
+
alignment?: TableColAlignment,
|
|
18
|
+
): TextStyle => {
|
|
19
|
+
switch (alignment) {
|
|
20
|
+
case "center":
|
|
21
|
+
return { textAlign: "center" };
|
|
22
|
+
case "left":
|
|
23
|
+
return { textAlign: "left" };
|
|
24
|
+
case "right":
|
|
25
|
+
return { textAlign: "right" };
|
|
26
|
+
default:
|
|
27
|
+
return { textAlign: "left" };
|
|
28
|
+
}
|
|
29
|
+
};
|