@@ -105,13 +105,13 @@ function createTheme(colors, options) {
105105 tagStyles . push ( { tag : highlight . tags . quote , color : highlightColors ?. quote } ) ;
106106 }
107107 if ( highlightColors ?. link ) {
108- tagStyles . push ( { tag : highlight . tags . link , color : highlightColors ?. link } ) ;
108+ tagStyles . push ( { tag : [ highlight . tags . url , highlight . tags . link ] , color : highlightColors ?. link } ) ;
109109 }
110110 if ( highlightColors ?. separator ) {
111111 tagStyles . push ( { tag : [ highlight . tags . definition ( highlight . tags . name ) , highlight . tags . separator , highlight . tags . contentSeparator ] , color : highlightColors ?. separator } ) ;
112112 }
113113 if ( highlightColors ?. comment ) {
114- tagStyles . push ( { tag : [ highlight . tags . meta , highlight . tags . comment ] , color : highlightColors ?. comment } ) ;
114+ tagStyles . push ( { tag : highlight . tags . comment , color : highlightColors ?. comment } ) ;
115115 }
116116 if ( highlightColors ?. meta ) {
117117 tagStyles . push ( { tag : highlight . tags . meta , color : highlightColors ?. meta } ) ;
@@ -120,7 +120,7 @@ function createTheme(colors, options) {
120120 tagStyles . push ( { tag : highlight . tags . keyword , color : highlightColors ?. keyword } ) ;
121121 }
122122 if ( highlightColors ?. atom ) {
123- tagStyles . push ( { tag : [ highlight . tags . atom , highlight . tags . bool , highlight . tags . url , highlight . tags . contentSeparator , highlight . tags . labelName ] , color : highlightColors ?. atom } ) ;
123+ tagStyles . push ( { tag : [ highlight . tags . atom , highlight . tags . bool ] , color : highlightColors ?. atom } ) ;
124124 }
125125 if ( highlightColors ?. literal ) {
126126 tagStyles . push ( { tag : [ highlight . tags . literal , highlight . tags . inserted ] , color : highlightColors ?. literal } ) ;
@@ -239,20 +239,14 @@ function lighterColor(textColor) {
239239 const [ red , green , blue ] = components . slice ( 1 , 4 ) . map ( Number ) ;
240240 return `rgba(${ red } , ${ green } , ${ blue } , 0.6)` ;
241241}
242- function flattenThemes ( root ) {
243- const result = [ ] ;
244- const stack = [ root ] ;
245- while ( stack . length > 0 ) {
246- const node = stack . pop ( ) ;
247- if ( Array . isArray ( node ) ) {
248- node . forEach ( ( o ) => stack . push ( o ) ) ;
249- } else if ( "extension" in node ) {
250- stack . push ( node . extension ) ;
251- } else {
252- result . push ( node ) ;
253- }
242+ function flattenThemes ( node ) {
243+ if ( Array . isArray ( node ) ) {
244+ return node . flatMap ( flattenThemes ) ;
245+ } else if ( "extension" in node ) {
246+ return flattenThemes ( node . extension ) ;
247+ } else {
248+ return [ node ] ;
254249 }
255- return result ;
256250}
257251function parseCssRules ( cssText2 ) {
258252 const result = { } ;
@@ -337,16 +331,16 @@ function overrideStyles(editor, isDark, isDisabled, cssStyles, tagStyles, colors
337331 const matchingBracket = findBackground ( cssStyles , selectors . matchingBracket ) ;
338332 const primaryColor = getComputedStyle ( editor . contentDOM ) . color ;
339333 const secondaryColor = colors ?. visibleSpace ?? lighterColor ( primaryColor ) ;
340- const useCustomHeader = extractTaggedColor ( tagStyles , highlight . tags . heading ) !== void 0 ;
334+ const headingTagColor = extractTaggedColor ( tagStyles , highlight . tags . heading ) ;
341335 const instructionTagColor = extractTaggedColor ( tagStyles , highlight . tags . processingInstruction ) ;
342336 const propertyUpdates = [
343337 [ selectors . activeIndicator , activeLine , "background" ] ,
344338 [ selectors . matchingBracket , matchingBracket , "background" ] ,
345339 [ selectors . lineGutter , primaryColor , "color" ] ,
346340 [ selectors . foldGutter , secondaryColor , "color" ] ,
347341 [ selectors . visibleSpace , secondaryColor , "color" ] ,
348- [ selectors . accentColor , colors ?. accentColor , "color" ] ,
349- [ selectors . syntaxMarker , instructionTagColor ?? colors ?. syntaxMarker , "color" ]
342+ [ selectors . accentColor , colors ?. accentColor ?? headingTagColor , "color" ] ,
343+ [ selectors . syntaxMarker , colors ?. syntaxMarker ?? instructionTagColor , "color" ]
350344 ] ;
351345 const styles = Array . from ( document . querySelectorAll ( "style" ) ) ;
352346 const originalRules = isDark ? $context ( ) . darkOriginalRules : $context ( ) . lightOriginalRules ;
@@ -366,7 +360,7 @@ function overrideStyles(editor, isDark, isDisabled, cssStyles, tagStyles, colors
366360 rule . style . setProperty ( "background" , selectionBackground , "important" ) ;
367361 }
368362 }
369- if ( useCustomHeader && ( selector === ".cm-md-header" || selector === ".cm-md-header:not(.cm-md-quote)" ) ) {
363+ if ( headingTagColor !== void 0 && ( selector === ".cm-md-header" || selector === ".cm-md-header:not(.cm-md-quote)" ) ) {
370364 originalRules . markdownHeader ??= rule . cssText ;
371365 if ( isDisabled ) {
372366 rule . cssText = originalRules . markdownHeader ;
@@ -381,7 +375,8 @@ function overrideStyles(editor, isDark, isDisabled, cssStyles, tagStyles, colors
381375 if ( color === void 0 ) {
382376 rule . style . removeProperty ( property ) ;
383377 } else {
384- rule . style . setProperty ( property , color , "important" ) ;
378+ const priority = [ selectors . accentColor , selectors . syntaxMarker ] . includes ( selector ) ? void 0 : "important" ;
379+ rule . style . setProperty ( property , color , priority ) ;
385380 if ( selector === selectors . matchingBracket || selector === selectors . activeIndicator ) {
386381 rule . style . setProperty ( "box-shadow" , "unset" , "important" ) ;
387382 }
0 commit comments