@@ -11,14 +11,64 @@ export const annotationsMap: Record<
1111 CodeAnnotation [ "Component" ]
1212> = {
1313 box : Box ,
14- bg : Background ,
14+ bg : MultilineMark ,
1515 label : Label ,
1616 link : CodeLink ,
1717 mark : Mark ,
1818 withClass : WithClass ,
1919}
2020
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 ( {
2272 children,
2373 data,
2474 theme,
@@ -64,7 +114,7 @@ function tryGuessColor(
64114 grandChild ?. props ?. children || [ ]
65115 ) [ 0 ] as any
66116
67- const { color } = grandGrandChild ?. props ?. style
117+ const { color } = grandGrandChild ?. props ?. style || { }
68118
69119 if ( color ) {
70120 return transparent ( color as string , 0.2 )
@@ -117,49 +167,6 @@ function WithClass({
117167 )
118168}
119169
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-
163170function Label ( {
164171 children,
165172 data,
0 commit comments