This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
common.tsx
77 lines (63 loc) · 1.88 KB
/
common.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
import _ from "lodash";
import React, { useEffect } from "react";
import { StyleProp, StyleSheet, Text, TextStyle, View, ViewProps, ViewStyle } from "react-native";
import { MathToSVGConfig } from "./mathjax/Config";
export type ResizeMode = 'cover' | 'contain';
export interface MathViewCommonProps extends ViewProps {
/**
* set text color
* can be set via `setNativeProps` or passed via `style`
* */
color?: string,
style?: StyleProp<ViewStyle & Pick<TextStyle, 'color'>>
/**
* defaults to 'center'
* */
resizeMode?: ResizeMode,
/**MathJax config object */
config?: Partial<MathToSVGConfig>,
/**Fallback component that will be rendered if a parsing error occurs */
renderError?: React.FC<MathViewErrorProps> | React.ReactElement<MathViewErrorProps>
onError?: (error: Error) => any
/**Verbose option for debugging, disabled in production */
debug?: boolean
}
export interface MathViewProps extends MathViewCommonProps {
/**
* see the list of LaTeX commands:
* http://docs.mathjax.org/en/latest/input/tex/macros/index.html
* */
math: string,
}
export interface ParserResponse {
svg: string,
size: {
width: number,
height: number
}
}
export interface MathViewInjectedProps extends MathViewCommonProps, ParserResponse { }
export enum MathError {
parsing = "MATH_ERROR/PARSING"
}
export interface MathViewErrorProps extends MathViewProps {
error: Error
}
export const getPreserveAspectRatio = (alignment: string, scale: string) => `${alignment} ${scale}`;
export const styles = StyleSheet.create({
container: {
//flexDirection: 'row',
display: 'flex'
},
contain: {
maxWidth: '100%',
maxHeight: '100%'
},
error: {
fontWeight: 'bold'
},
multilineText: {
display: 'flex',
flexDirection: 'column'
}
});