Fixes microsoft/monaco-editor#1832: Accept theme to be passed in to updateOptions

This commit is contained in:
Alex Dima
2020-02-17 21:01:26 +01:00
parent b308a365d7
commit 37f2127173
2 changed files with 25 additions and 1 deletions
@@ -124,6 +124,13 @@ export interface IGlobalEditorOptions {
* Defaults to 20000.
*/
maxTokenizationLineLength?: number;
/**
* Theme to be used for rendering.
* The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
* You can create custom themes via `monaco.editor.defineTheme`.
* To switch a theme, use `monaco.editor.setTheme`
*/
theme?: string;
}
/**
@@ -334,6 +341,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
private readonly _contextViewService: ContextViewService;
private readonly _configurationService: IConfigurationService;
private readonly _standaloneThemeService: IStandaloneThemeService;
private _ownsModel: boolean;
constructor(
@@ -363,6 +371,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
this._contextViewService = <ContextViewService>contextViewService;
this._configurationService = configurationService;
this._standaloneThemeService = themeService;
this._register(toDispose);
this._register(themeDomRegistration);
@@ -391,6 +400,9 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
public updateOptions(newOptions: IEditorOptions & IGlobalEditorOptions): void {
applyConfigurationValues(this._configurationService, newOptions, false);
if (typeof newOptions.theme === 'string') {
this._standaloneThemeService.setTheme(newOptions.theme);
}
super.updateOptions(newOptions);
}
@@ -414,6 +426,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
private readonly _contextViewService: ContextViewService;
private readonly _configurationService: IConfigurationService;
private readonly _standaloneThemeService: IStandaloneThemeService;
constructor(
domElement: HTMLElement,
@@ -443,6 +456,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
this._contextViewService = <ContextViewService>contextViewService;
this._configurationService = configurationService;
this._standaloneThemeService = themeService;
this._register(toDispose);
this._register(themeDomRegistration);
@@ -454,8 +468,11 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
super.dispose();
}
public updateOptions(newOptions: IDiffEditorOptions): void {
public updateOptions(newOptions: IDiffEditorOptions & IGlobalEditorOptions): void {
applyConfigurationValues(this._configurationService, newOptions, true);
if (typeof newOptions.theme === 'string') {
this._standaloneThemeService.setTheme(newOptions.theme);
}
super.updateOptions(newOptions);
}
+7
View File
@@ -1108,6 +1108,13 @@ declare namespace monaco.editor {
* Defaults to 20000.
*/
maxTokenizationLineLength?: number;
/**
* Theme to be used for rendering.
* The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
* You can create custom themes via `monaco.editor.defineTheme`.
* To switch a theme, use `monaco.editor.setTheme`
*/
theme?: string;
}
/**