mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 13:55:41 +01:00
Switch themes via a combo box
This commit is contained in:
parent
3d3fea5626
commit
6328b62e22
1 changed files with 10 additions and 27 deletions
|
|
@ -53,7 +53,14 @@ var modesData = {};
|
||||||
monaco.languages.getLanguages().forEach(function(language) {
|
monaco.languages.getLanguages().forEach(function(language) {
|
||||||
modesData[language.id] = updateEditor.bind(this, language.id);
|
modesData[language.id] = updateEditor.bind(this, language.id);
|
||||||
});
|
});
|
||||||
var modesComboBox = new ComboBox ('Mode', modesData);
|
var modesComboBox = new ComboBox('Mode', modesData);
|
||||||
|
|
||||||
|
|
||||||
|
var themesData = {};
|
||||||
|
themesData['vs'] = function() { monaco.editor.setTheme('vs') };
|
||||||
|
themesData['vs-dark'] = function() { monaco.editor.setTheme('vs-dark') };
|
||||||
|
themesData['hc-black'] = function() { monaco.editor.setTheme('hc-black') };
|
||||||
|
var themesComboBox = new ComboBox('Theme', themesData);
|
||||||
|
|
||||||
|
|
||||||
// Do it in a timeout to simplify profiles
|
// Do it in a timeout to simplify profiles
|
||||||
|
|
@ -104,6 +111,8 @@ function createToolbar(editor) {
|
||||||
|
|
||||||
bar.appendChild(modesComboBox.domNode);
|
bar.appendChild(modesComboBox.domNode);
|
||||||
|
|
||||||
|
bar.appendChild(themesComboBox.domNode);
|
||||||
|
|
||||||
bar.appendChild(createButton("Dispose all", function (e) {
|
bar.appendChild(createButton("Dispose all", function (e) {
|
||||||
editor.dispose();
|
editor.dispose();
|
||||||
editor = null;
|
editor = null;
|
||||||
|
|
@ -233,32 +242,6 @@ function createOptions(editor) {
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(
|
|
||||||
editor,
|
|
||||||
'light',
|
|
||||||
function(config) {
|
|
||||||
return false;//config.viewInfo.theme === 'vs-dark';
|
|
||||||
}, function(editor, newValue) {
|
|
||||||
monaco.editor.setTheme('vs');
|
|
||||||
// editor.updateOptions({ theme: newValue ? 'vs-dark' : 'vs' });
|
|
||||||
}
|
|
||||||
));
|
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(editor, 'dark', function(config) {
|
|
||||||
return false;//config.viewInfo.theme === 'vs-dark';
|
|
||||||
}, function(editor, newValue) {
|
|
||||||
monaco.editor.setTheme('vs-dark');
|
|
||||||
// editor.updateOptions({ theme: newValue ? 'vs-dark' : 'vs' });
|
|
||||||
}));
|
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(editor, 'hc-black', function(config) {
|
|
||||||
return false;
|
|
||||||
//return config.viewInfo.theme === 'hc-black';
|
|
||||||
}, function(editor, newValue) {
|
|
||||||
monaco.editor.setTheme('hc-black');
|
|
||||||
editor.updateOptions({ theme: newValue ? 'hc-black' : 'vs' });
|
|
||||||
}));
|
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(
|
options.appendChild(createOptionToggle(
|
||||||
editor,
|
editor,
|
||||||
'readOnly',
|
'readOnly',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue