@@ -11,14 +11,56 @@ 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+ 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 ( {
2264 children,
2365 data,
2466 theme,
@@ -28,24 +70,15 @@ function Mark({
2870 theme : any
2971} ) {
3072 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+ )
3878
79+ const className = "ch-code-inline-mark " + ( data ?? "" )
3980 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 } } >
4982 { children }
5083 </ span >
5184 )
@@ -64,7 +97,7 @@ function tryGuessColor(
6497 grandChild ?. props ?. children || [ ]
6598 ) [ 0 ] as any
6699
67- const { color } = grandGrandChild ?. props ?. style
100+ const { color } = grandGrandChild ?. props ?. style || { }
68101
69102 if ( color ) {
70103 return transparent ( color as string , 0.2 )
@@ -117,49 +150,6 @@ function WithClass({
117150 )
118151}
119152
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-
163153function Label ( {
164154 children,
165155 data,
0 commit comments