@@ -11,14 +11,56 @@ 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
+ function MultilineMark ( {
29
+ children,
30
+ data,
31
+ style,
32
+ theme,
33
+ } : {
34
+ data : string
35
+ children : React . ReactNode
36
+ style ?: React . CSSProperties
37
+ theme ?: any
38
+ } ) {
39
+ const className = `ch-code-multiline-mark ` + ( data ?? "" )
40
+ const bg = getColor (
41
+ theme ,
42
+ ColorName . RangeHighlightBackground
43
+ )
44
+ const border = getColor (
45
+ theme ,
46
+ ColorName . EditorInfoForeground
47
+ )
48
+
49
+ return (
50
+ < div
51
+ style = { { ...style , background : bg } }
52
+ className = { className }
53
+ >
54
+ < span
55
+ className = "ch-code-multiline-mark-border"
56
+ style = { { background : border } }
57
+ />
58
+ { children }
59
+ </ div >
60
+ )
61
+ }
62
+
63
+ function InlineMark ( {
22
64
children,
23
65
data,
24
66
theme,
@@ -28,24 +70,15 @@ function Mark({
28
70
theme : any
29
71
} ) {
30
72
const bg =
31
- data && typeof data === "string"
32
- ? data
33
- : tryGuessColor ( children ) ||
34
- transparent (
35
- getColor ( theme , ColorName . CodeForeground ) ,
36
- 0.2
37
- )
73
+ tryGuessColor ( children ) ||
74
+ transparent (
75
+ getColor ( theme , ColorName . CodeForeground ) ,
76
+ 0.2
77
+ )
38
78
79
+ const className = "ch-code-inline-mark " + ( data ?? "" )
39
80
return (
40
- < span
41
- className = "ch-code-mark-annotation"
42
- style = { {
43
- background : bg ,
44
- borderRadius : "0.25rem" ,
45
- padding : "0.2rem 0.15rem 0.1rem" ,
46
- margin : "0 -0.15rem" ,
47
- } }
48
- >
81
+ < span className = { className } style = { { background : bg } } >
49
82
{ children }
50
83
</ span >
51
84
)
@@ -64,7 +97,7 @@ function tryGuessColor(
64
97
grandChild ?. props ?. children || [ ]
65
98
) [ 0 ] as any
66
99
67
- const { color } = grandGrandChild ?. props ?. style
100
+ const { color } = grandGrandChild ?. props ?. style || { }
68
101
69
102
if ( color ) {
70
103
return transparent ( color as string , 0.2 )
@@ -117,49 +150,6 @@ function WithClass({
117
150
)
118
151
}
119
152
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
153
function Label ( {
164
154
children,
165
155
data,
0 commit comments