@@ -118,33 +118,65 @@ export const createCodeMirrorEditor = async ({
118118 onFocus,
119119} ) => {
120120 const runtime = await ensureCodeMirrorRuntime ( )
121+ const editorColors = {
122+ keyword : 'var(--cm-keyword)' ,
123+ name : 'var(--cm-name)' ,
124+ property : 'var(--cm-property)' ,
125+ fn : 'var(--cm-function)' ,
126+ constant : 'var(--cm-constant)' ,
127+ definition : 'var(--cm-definition)' ,
128+ type : 'var(--cm-type)' ,
129+ number : 'var(--cm-number)' ,
130+ operator : 'var(--cm-operator)' ,
131+ string : 'var(--cm-string)' ,
132+ comment : 'var(--cm-comment)' ,
133+ link : 'var(--cm-link)' ,
134+ heading : 'var(--cm-heading)' ,
135+ atom : 'var(--cm-atom)' ,
136+ invalid : 'var(--cm-invalid)' ,
137+ text : 'var(--cm-text)' ,
138+ caret : 'var(--cm-caret)' ,
139+ gutterBg : 'var(--cm-gutter-bg)' ,
140+ gutterBorder : 'var(--cm-gutter-border)' ,
141+ gutterText : 'var(--cm-gutter-text)' ,
142+ selection : 'var(--cm-selection)' ,
143+ activeLine : 'var(--cm-active-line)' ,
144+ focusRing : 'var(--cm-focus-ring)' ,
145+ tooltipBg : 'var(--cm-tooltip-bg)' ,
146+ tooltipText : 'var(--cm-tooltip-text)' ,
147+ tooltipBorder : 'var(--cm-tooltip-border)' ,
148+ tooltipItem : 'var(--cm-tooltip-item)' ,
149+ tooltipItemSelectedBg : 'var(--cm-tooltip-item-selected-bg)' ,
150+ tooltipItemSelectedText : 'var(--cm-tooltip-item-selected-text)' ,
151+ }
152+
121153 const languageCompartment = new runtime . Compartment ( )
122154 const editorHighlightStyle = runtime . HighlightStyle . define ( [
123- { tag : runtime . tags . keyword , color : '#ff7fb3' , fontWeight : '600' } ,
124- { tag : [ runtime . tags . name , runtime . tags . deleted ] , color : '#e7ecf9' } ,
155+ { tag : runtime . tags . keyword , color : editorColors . keyword , fontWeight : '600' } ,
156+ { tag : [ runtime . tags . name , runtime . tags . deleted ] , color : editorColors . name } ,
125157 {
126158 tag : [ runtime . tags . character , runtime . tags . propertyName , runtime . tags . macroName ] ,
127- color : '#3fd6a6' ,
159+ color : editorColors . property ,
128160 } ,
129161 {
130162 tag : [ runtime . tags . function ( runtime . tags . variableName ) , runtime . tags . labelName ] ,
131- color : '#8dc8ff' ,
163+ color : editorColors . fn ,
132164 } ,
133165 {
134166 tag : [
135167 runtime . tags . color ,
136168 runtime . tags . constant ( runtime . tags . name ) ,
137169 runtime . tags . standard ( runtime . tags . name ) ,
138170 ] ,
139- color : '#7fd7ff' ,
171+ color : editorColors . constant ,
140172 } ,
141173 {
142174 tag : [ runtime . tags . definition ( runtime . tags . name ) , runtime . tags . separator ] ,
143- color : '#dce4f6' ,
175+ color : editorColors . definition ,
144176 } ,
145177 {
146178 tag : [ runtime . tags . className , runtime . tags . typeName ] ,
147- color : '#8eb8ff' ,
179+ color : editorColors . type ,
148180 fontWeight : '600' ,
149181 } ,
150182 {
@@ -156,19 +188,19 @@ export const createCodeMirrorEditor = async ({
156188 runtime . tags . self ,
157189 runtime . tags . namespace ,
158190 ] ,
159- color : '#ffcb82' ,
191+ color : editorColors . number ,
160192 } ,
161193 {
162194 tag : [ runtime . tags . operator , runtime . tags . operatorKeyword ] ,
163- color : '#d5def0' ,
195+ color : editorColors . operator ,
164196 } ,
165197 {
166198 tag : [ runtime . tags . string , runtime . tags . special ( runtime . tags . string ) ] ,
167- color : '#ffd38e' ,
199+ color : editorColors . string ,
168200 } ,
169201 {
170202 tag : [ runtime . tags . meta , runtime . tags . comment ] ,
171- color : '#94a2bb' ,
203+ color : editorColors . comment ,
172204 fontStyle : 'italic' ,
173205 } ,
174206 {
@@ -181,12 +213,12 @@ export const createCodeMirrorEditor = async ({
181213 } ,
182214 {
183215 tag : runtime . tags . link ,
184- color : '#88b6ff' ,
216+ color : editorColors . link ,
185217 textDecoration : 'underline' ,
186218 } ,
187219 {
188220 tag : runtime . tags . heading ,
189- color : '#f2f5ff' ,
221+ color : editorColors . heading ,
190222 fontWeight : '700' ,
191223 } ,
192224 {
@@ -195,19 +227,19 @@ export const createCodeMirrorEditor = async ({
195227 runtime . tags . bool ,
196228 runtime . tags . special ( runtime . tags . variableName ) ,
197229 ] ,
198- color : '#b8a8ff' ,
230+ color : editorColors . atom ,
199231 } ,
200232 {
201233 tag : runtime . tags . invalid ,
202- color : '#ff8fa1' ,
203- textDecoration : ' underline wavy #ff8fa1' ,
234+ color : editorColors . invalid ,
235+ textDecoration : ` underline wavy ${ editorColors . invalid } ` ,
204236 } ,
205237 ] )
206238 const editorTheme = runtime . EditorView . theme ( {
207239 '&' : {
208240 height : '100%' ,
209241 backgroundColor : 'transparent' ,
210- color : '#edf2ff' ,
242+ color : editorColors . text ,
211243 fontSize : '0.9rem' ,
212244 fontFamily : "'JetBrains Mono', 'Fira Code', monospace" ,
213245 } ,
@@ -218,39 +250,39 @@ export const createCodeMirrorEditor = async ({
218250 '.cm-content' : {
219251 padding : '16px 18px' ,
220252 minHeight : '100%' ,
221- caretColor : '#f1f5ff' ,
253+ caretColor : editorColors . caret ,
222254 } ,
223255 '.cm-gutters' : {
224- backgroundColor : 'rgba(255, 255, 255, 0.045)' ,
225- borderRight : ' 1px solid rgba(255, 255, 255, 0.13)' ,
226- color : '#98a8c4' ,
256+ backgroundColor : editorColors . gutterBg ,
257+ borderRight : ` 1px solid ${ editorColors . gutterBorder } ` ,
258+ color : editorColors . gutterText ,
227259 } ,
228260 '.cm-lineNumbers .cm-gutterElement' : {
229261 padding : '0 10px 0 14px' ,
230262 } ,
231263 '&.cm-focused .cm-cursor' : {
232- borderLeftColor : '#f1f5ff' ,
264+ borderLeftColor : editorColors . caret ,
233265 } ,
234266 '&.cm-focused .cm-selectionBackground, ::selection' : {
235- backgroundColor : 'rgba(122, 107, 255, 0.36)' ,
267+ backgroundColor : editorColors . selection ,
236268 } ,
237269 '&.cm-focused .cm-activeLine' : {
238- backgroundColor : 'rgba(255, 255, 255, 0.08)' ,
270+ backgroundColor : editorColors . activeLine ,
239271 } ,
240272 '&.cm-focused' : {
241- outline : ' 1px solid rgba(122, 107, 255, 0.62)' ,
273+ outline : ` 1px solid ${ editorColors . focusRing } ` ,
242274 } ,
243275 '.cm-tooltip' : {
244- backgroundColor : '#1b2233' ,
245- color : '#edf2ff' ,
246- border : ' 1px solid rgba(152, 168, 196, 0.32)' ,
276+ backgroundColor : editorColors . tooltipBg ,
277+ color : editorColors . tooltipText ,
278+ border : ` 1px solid ${ editorColors . tooltipBorder } ` ,
247279 } ,
248280 '.cm-tooltip-autocomplete > ul > li' : {
249- color : '#dce6fa' ,
281+ color : editorColors . tooltipItem ,
250282 } ,
251283 '.cm-tooltip-autocomplete > ul > li[aria-selected]' : {
252- backgroundColor : 'rgba(122, 107, 255, 0.34)' ,
253- color : '#f4f7ff' ,
284+ backgroundColor : editorColors . tooltipItemSelectedBg ,
285+ color : editorColors . tooltipItemSelectedText ,
254286 } ,
255287 } )
256288 const updateListener = runtime . EditorView . updateListener . of ( update => {
0 commit comments