Simplify index.js

pull/497/head
Alex Dima 8 years ago
parent 06c48a7281
commit 3d3fea5626

@ -63,4 +63,4 @@
self.METADATA = METADATA; self.METADATA = METADATA;
} }
})(); })();

@ -3,24 +3,12 @@ define(['require', './samples'], function(require, SAMPLES) {
var domutils = require('vs/base/browser/dom'); var domutils = require('vs/base/browser/dom');
var WRAPPING_COLUMN = 300;
var model = monaco.editor.createModel('', 'plaintext'); var model = monaco.editor.createModel('', 'plaintext');
var editor = monaco.editor.create(document.getElementById('container'), { var editor = monaco.editor.create(document.getElementById('container'), {
model: model, model: model,
readOnly: false,
glyphMargin: true, glyphMargin: true,
wrappingColumn: WRAPPING_COLUMN, renderWhitespace: true
outlineMarkers: false,
renderWhitespace: true,
minimap: {
enabled: true
}
// scrollbar: {
// verticalHasArrows: true,
// horizontalHasArrows: true
// }
}); });
editor.addCommand({ editor.addCommand({
@ -42,7 +30,6 @@ editor.addAction({
} }
}); });
var currentSamplePromise = null; var currentSamplePromise = null;
var samplesData = {}; var samplesData = {};
SAMPLES.sort(function(a,b) { SAMPLES.sort(function(a,b) {
@ -170,16 +157,8 @@ function createToolbar(editor) {
} }
}; };
})())); })()));
bar.appendChild(createButton("Colorize", function(e) {
var out = document.getElementById('colorizeOutput');
monaco.editor.colorize(editor.getModel().getValue(), editor.getModel().getMode().getId(), { tabSize: 4 }).then(function(r) {
out.innerHTML = r;
});
}));
} }
function createButton(label, onClick) { function createButton(label, onClick) {
var result = document.createElement("button"); var result = document.createElement("button");
result.innerHTML = label; result.innerHTML = label;
@ -187,117 +166,129 @@ function createButton(label, onClick) {
return result; return result;
} }
function createOptions(editor) { function createOptions(editor) {
var options = document.getElementById('options'); var options = document.getElementById('options');
options.appendChild(createOptionToggle(editor, 'lineNumbers', function(config) { options.appendChild(createOptionToggle(
return config.viewInfo.lineNumbers; editor,
}, function(editor, newValue) { 'lineNumbers',
editor.updateOptions({ lineNumbers: newValue }); function(config) {
})); return config.viewInfo.renderLineNumbers;
},
options.appendChild(createOptionToggle(editor, 'glyphMargin', function(config) { function(editor, newValue) {
return config.viewInfo.glyphMargin; editor.updateOptions({ lineNumbers: newValue ? 'on': 'off' });
}, function(editor, newValue) { }
editor.updateOptions({ glyphMargin: newValue }); ));
}));
options.appendChild(createOptionToggle(
options.appendChild(createOptionToggle(editor, 'roundedSelection', function(config) { editor,
return config.viewInfo.roundedSelection; 'glyphMargin',
}, function(editor, newValue) { function(config) {
editor.updateOptions({ roundedSelection: newValue }); return config.viewInfo.glyphMargin;
})); },
function(editor, newValue) {
editor.updateOptions({ glyphMargin: newValue });
}
));
options.appendChild(createOptionToggle(
editor,
'minimap',
function(config) {
return config.viewInfo.minimap.enabled;
},
function(editor, newValue) {
editor.updateOptions({ minimap: { enabled: newValue } });
}
));
options.appendChild(createOptionToggle(
editor,
'roundedSelection',
function(config) {
return config.viewInfo.roundedSelection;
},
function(editor, newValue) {
editor.updateOptions({ roundedSelection: newValue });
}
));
options.appendChild(createOptionToggle(
editor,
'scrollBeyondLastLine',
function(config) {
return config.viewInfo.scrollBeyondLastLine;
}, function(editor, newValue) {
editor.updateOptions({ scrollBeyondLastLine: newValue });
}
));
options.appendChild(createOptionToggle(
editor,
'renderWhitespace',
function(config) {
return config.viewInfo.renderWhitespace;
}, function(editor, newValue) {
editor.updateOptions({ renderWhitespace: newValue });
}
));
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) { options.appendChild(createOptionToggle(editor, 'dark', function(config) {
return config.viewInfo.theme === 'vs-dark'; return false;//config.viewInfo.theme === 'vs-dark';
}, function(editor, newValue) { }, function(editor, newValue) {
editor.updateOptions({ theme: newValue ? 'vs-dark' : 'vs' }); monaco.editor.setTheme('vs-dark');
// editor.updateOptions({ theme: newValue ? 'vs-dark' : 'vs' });
})); }));
options.appendChild(createOptionToggle(editor, 'hc-black', function(config) { options.appendChild(createOptionToggle(editor, 'hc-black', function(config) {
return config.viewInfo.theme === 'hc-black'; return false;
//return config.viewInfo.theme === 'hc-black';
}, function(editor, newValue) { }, function(editor, newValue) {
monaco.editor.setTheme('hc-black');
editor.updateOptions({ theme: newValue ? 'hc-black' : 'vs' }); editor.updateOptions({ theme: newValue ? 'hc-black' : 'vs' });
})); }));
options.appendChild(createOptionToggle(editor, 'readOnly', function(config) { options.appendChild(createOptionToggle(
return config.readOnly; editor,
}, function(editor, newValue) { 'readOnly',
editor.updateOptions({ readOnly: newValue }); function(config) {
})); return config.readOnly;
},
options.appendChild(createOptionToggle(editor, 'hideCursorInOverviewRuler', function(config) { function(editor, newValue) {
return config.viewInfo.hideCursorInOverviewRuler; editor.updateOptions({ readOnly: newValue });
}, function(editor, newValue) { }
editor.updateOptions({ hideCursorInOverviewRuler: newValue }); ));
}));
options.appendChild(createOptionToggle(
options.appendChild(createOptionToggle(editor, 'scrollBeyondLastLine', function(config) { editor,
return config.viewInfo.scrollBeyondLastLine; 'wordWrap',
}, function(editor, newValue) { function(config) {
editor.updateOptions({ scrollBeyondLastLine: newValue }); return config.wrappingInfo.isViewportWrapping;
})); }, function(editor, newValue) {
editor.updateOptions({ wordWrap: newValue ? 'on' : 'off' });
options.appendChild(createOptionToggle(editor, 'wordWrap', function(config) { }
return config.wrappingInfo.isViewportWrapping; ));
}, function(editor, newValue) {
editor.updateOptions({ wrappingColumn: newValue ? 0 : WRAPPING_COLUMN }); options.appendChild(createOptionToggle(
})); editor,
'folding',
options.appendChild(createOptionToggle(editor, 'quickSuggestions', function(config) { function(config) {
return config.contribInfo.quickSuggestions; return config.contribInfo.folding;
}, function(editor, newValue) { }, function(editor, newValue) {
editor.updateOptions({ quickSuggestions: newValue }); editor.updateOptions({ folding: newValue });
})); }
));
options.appendChild(createOptionToggle(editor, 'iconsInSuggestions', function(config) {
return config.contribInfo.iconsInSuggestions;
}, function(editor, newValue) {
editor.updateOptions({ iconsInSuggestions: newValue });
}));
options.appendChild(createOptionToggle(editor, 'autoClosingBrackets', function(config) {
return config.autoClosingBrackets;
}, function(editor, newValue) {
editor.updateOptions({ autoClosingBrackets: newValue });
}));
options.appendChild(createOptionToggle(editor, 'formatOnType', function(config) {
return config.contribInfo.formatOnType;
}, function(editor, newValue) {
editor.updateOptions({ formatOnType: newValue });
}));
options.appendChild(createOptionToggle(editor, 'suggestOnTriggerCharacters', function(config) {
return config.contribInfo.suggestOnTriggerCharacters;
}, function(editor, newValue) {
editor.updateOptions({ suggestOnTriggerCharacters: newValue });
}));
options.appendChild(createOptionToggle(editor, 'acceptSuggestionOnEnter', function(config) {
return config.contribInfo.acceptSuggestionOnEnter;
}, function(editor, newValue) {
editor.updateOptions({ acceptSuggestionOnEnter: newValue });
}));
options.appendChild(createOptionToggle(editor, 'selectionHighlight', function(config) {
return config.contribInfo.selectionHighlight;
}, function(editor, newValue) {
editor.updateOptions({ selectionHighlight: newValue });
}));
options.appendChild(createOptionToggle(editor, 'folding', function(config) {
return config.contribInfo.folding;
}, function(editor, newValue) {
editor.updateOptions({ folding: newValue });
}));
options.appendChild(createOptionToggle(editor, 'renderWhitespace', function(config) {
return config.viewInfo.renderWhitespace;
}, function(editor, newValue) {
editor.updateOptions({ renderWhitespace: newValue });
}));
} }

Loading…
Cancel
Save