11import debounce from 'lodash.debounce' ;
22import { JSItem , type CSSItem } from 'markmap-common' ;
33import { fillTemplate } from 'markmap-render' ;
4- import type { IMarkmapJSONOptions } from 'markmap-view' ;
4+ import { defaultOptions , type IMarkmapJSONOptions } from 'markmap-view' ;
55import {
66 CancellationToken ,
77 ColorThemeKind ,
@@ -35,7 +35,7 @@ const renderToolbar = () => {
3535} ;
3636
3737class MarkmapEditor implements CustomTextEditorProvider {
38- constructor ( private context : ExtensionContext ) { }
38+ constructor ( private context : ExtensionContext ) { }
3939
4040 private resolveAssetPath ( relPath : string ) {
4141 return Utils . joinPath ( this . context . extensionUri , relPath ) ;
@@ -100,16 +100,16 @@ class MarkmapEditor implements CustomTextEditorProvider {
100100 } ) ;
101101 }
102102 } ;
103- let defaultOptions : IMarkmapJSONOptions ;
103+ let globalOptions : IMarkmapJSONOptions ;
104104 let customCSS : string ;
105105 const updateOptions = ( ) => {
106106 const raw = workspace
107107 . getConfiguration ( 'markmap' )
108108 . get < string > ( 'defaultOptions' ) ;
109109 try {
110- defaultOptions = raw && JSON . parse ( raw ) ;
110+ globalOptions = raw && JSON . parse ( raw ) ;
111111 } catch {
112- defaultOptions = null ;
112+ globalOptions = null ;
113113 }
114114 update ( ) ;
115115 } ;
@@ -123,7 +123,9 @@ class MarkmapEditor implements CustomTextEditorProvider {
123123 } ) ;
124124 } ;
125125 const updateTheme = ( ) => {
126- const dark = [ ColorThemeKind . Dark , ColorThemeKind . HighContrast ] . includes ( vscodeWindow . activeColorTheme . kind ) ;
126+ const dark = [ ColorThemeKind . Dark , ColorThemeKind . HighContrast ] . includes (
127+ vscodeWindow . activeColorTheme . kind ,
128+ ) ;
127129 webviewPanel . webview . postMessage ( {
128130 type : 'setTheme' ,
129131 data : dark ,
@@ -138,6 +140,7 @@ class MarkmapEditor implements CustomTextEditorProvider {
138140 root,
139141 jsonOptions : {
140142 ...defaultOptions ,
143+ ...globalOptions ,
141144 ...( frontmatter as any ) ?. markmap ,
142145 } ,
143146 } ,
@@ -169,7 +172,7 @@ class MarkmapEditor implements CustomTextEditorProvider {
169172 const md = document . getText ( ) ;
170173 const { root, features, frontmatter } = transformerExport . transform ( md ) ;
171174 const jsonOptions = {
172- ...defaultOptions ,
175+ ...globalOptions ,
173176 ...( frontmatter as any ) ?. markmap ,
174177 } ;
175178 const { embedAssets } = jsonOptions as { embedAssets ?: boolean } ;
@@ -180,11 +183,11 @@ class MarkmapEditor implements CustomTextEditorProvider {
180183 styles : [
181184 ...( customCSS
182185 ? [
183- {
184- type : 'style' ,
185- data : customCSS ,
186- } as CSSItem ,
187- ]
186+ {
187+ type : 'style' ,
188+ data : customCSS ,
189+ } as CSSItem ,
190+ ]
188191 : [ ] ) ,
189192 ] ,
190193 scripts : [
0 commit comments