@@ -11,14 +11,64 @@ export const annotationsMap: Record<
11
11
CodeAnnotation [ "Component" ]
12
12
> = {
13
13
box : Box ,
14
- bg : Background ,
14
+ bg : MultilineMark ,
15
15
label : Label ,
16
16
link : CodeLink ,
17
17
mark : Mark ,
18
18
withClass : WithClass ,
19
19
}
20
20
21
- function Mark ( {
21
+ function Mark ( props : any ) {
22
+ if ( props . isInline ) {
23
+ return < InlineMark { ...props } />
24
+ } else {
25
+ return < MultilineMark { ...props } />
26
+ }
27
+ }
28
+
29
+ function MultilineMark ( {
30
+ children,
31
+ data,
32
+ style,
33
+ theme,
34
+ } : {
35
+ data : string
36
+ children : React . ReactNode
37
+ style ?: React . CSSProperties
38
+ theme ?: any
39
+ } ) {
40
+ const bg =
41
+ data ||
42
+ ( ( ( theme as any ) . colors [
43
+ "editor.lineHighlightBackground"
44
+ ] ||
45
+ ( theme as any ) . colors [
46
+ "editor.selectionHighlightBackground"
47
+ ] ) as string )
48
+ return (
49
+ < div
50
+ style = { {
51
+ ...style ,
52
+ background : bg ,
53
+ } }
54
+ className = "ch-code-bg-annotation"
55
+ >
56
+ < span
57
+ className = "ch-code-bg-annotation-border"
58
+ style = { {
59
+ background : "#00a2d3" ,
60
+ width : "3px" ,
61
+ height : "100%" ,
62
+ position : "absolute" ,
63
+ left : 0 ,
64
+ } }
65
+ />
66
+ { children }
67
+ </ div >
68
+ )
69
+ }
70
+
71
+ function InlineMark ( {
22
72
children,
23
73
data,
24
74
theme,
@@ -64,7 +114,7 @@ function tryGuessColor(
64
114
grandChild ?. props ?. children || [ ]
65
115
) [ 0 ] as any
66
116
67
- const { color } = grandGrandChild ?. props ?. style
117
+ const { color } = grandGrandChild ?. props ?. style || { }
68
118
69
119
if ( color ) {
70
120
return transparent ( color as string , 0.2 )
@@ -117,49 +167,6 @@ function WithClass({
117
167
)
118
168
}
119
169
120
- function Background ( {
121
- children,
122
- data,
123
- style,
124
- theme,
125
- } : {
126
- data : string
127
- children : React . ReactNode
128
- style ?: React . CSSProperties
129
- theme ?: any
130
- } ) {
131
- const bg =
132
- data ||
133
- ( ( ( theme as any ) . colors [
134
- "editor.lineHighlightBackground"
135
- ] ||
136
- ( theme as any ) . colors [
137
- "editor.selectionHighlightBackground"
138
- ] ) as string )
139
- return (
140
- < div
141
- style = { {
142
- ...style ,
143
- background : bg ,
144
- // cursor: "pointer",
145
- } }
146
- className = "ch-code-bg-annotation"
147
- >
148
- < span
149
- className = "ch-code-bg-annotation-border"
150
- style = { {
151
- background : "#00a2d3" ,
152
- width : "3px" ,
153
- height : "100%" ,
154
- position : "absolute" ,
155
- left : 0 ,
156
- } }
157
- />
158
- { children }
159
- </ div >
160
- )
161
- }
162
-
163
170
function Label ( {
164
171
children,
165
172
data,
0 commit comments