-
Notifications
You must be signed in to change notification settings - Fork 151
/
types.ts
102 lines (97 loc) · 2.03 KB
/
types.ts
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
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
import type { CSSProperties } from "react"
import type { Token as PrismToken, Grammar } from "prismjs"
import Prism from "prismjs"
export type Language = string
export type PrismGrammar = Grammar
export type PrismLib = typeof Prism
export type Token = {
types: string[]
content: string
empty?: boolean
}
export type EnvConfig = {
code: string
grammar: PrismGrammar
language: Language
tokens: (string | PrismToken)[]
}
export type StyleObj = CSSProperties
export type LineInputProps = {
style?: StyleObj
className?: string
line: Token[]
[key: string]: unknown
}
export type LineOutputProps = {
style?: StyleObj
className: string
[key: string]: unknown
}
export type TokenInputProps = {
style?: StyleObj
className?: string
token: Token
[key: string]: unknown
}
export type TokenOutputProps = {
style?: StyleObj
className: string
children: string
[key: string]: unknown
}
export type InternalHighlightProps = {
prism: PrismLib
theme: PrismTheme
language: Language
code: string
children: (props: RenderProps) => JSX.Element
}
export type HighlightProps = {
prism?: PrismLib
theme?: PrismTheme
language: Language
code: string
children: (props: RenderProps) => JSX.Element
}
export type RenderProps = {
tokens: Token[][]
className: string
style: CSSProperties
getLineProps: (input: LineInputProps) => LineOutputProps
getTokenProps: (input: TokenInputProps) => TokenOutputProps
}
export type PrismThemeEntry = {
color?: string
cursor?: string
background?: string
backgroundImage?: string
backgroundColor?: string
textShadow?: string
fontStyle?: "normal" | "italic"
fontWeight?:
| "normal"
| "bold"
| "100"
| "200"
| "300"
| "400"
| "500"
| "600"
| "700"
| "800"
| "900"
textDecorationLine?:
| "none"
| "underline"
| "line-through"
| "underline line-through"
opacity?: number
}
export type PrismTheme = {
plain: PrismThemeEntry
styles: Array<{
types: string[]
style: PrismThemeEntry
languages?: Language[]
}>
}