Switch themes via a combo box

pull/497/head
Alex Dima 2017-07-03 08:56:53 +02:00
parent 3d3fea5626
commit 6328b62e22
1 changed files with 10 additions and 27 deletions

View File

@ -53,7 +53,14 @@ var modesData = {};
monaco.languages.getLanguages().forEach(function(language) {
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
@ -104,6 +111,8 @@ function createToolbar(editor) {
bar.appendChild(modesComboBox.domNode);
bar.appendChild(themesComboBox.domNode);
bar.appendChild(createButton("Dispose all", function (e) {
editor.dispose();
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(
editor,
'readOnly',