mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 13:55:41 +01:00
Simplify index.js
This commit is contained in:
parent
06c48a7281
commit
3d3fea5626
2 changed files with 108 additions and 117 deletions
223
test/index.js
223
test/index.js
|
|
@ -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;
|
||||||
|
},
|
||||||
|
function(editor, newValue) {
|
||||||
|
editor.updateOptions({ lineNumbers: newValue ? 'on': 'off' });
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(editor, 'glyphMargin', function(config) {
|
options.appendChild(createOptionToggle(
|
||||||
return config.viewInfo.glyphMargin;
|
editor,
|
||||||
}, function(editor, newValue) {
|
'glyphMargin',
|
||||||
editor.updateOptions({ glyphMargin: newValue });
|
function(config) {
|
||||||
}));
|
return config.viewInfo.glyphMargin;
|
||||||
|
},
|
||||||
|
function(editor, newValue) {
|
||||||
|
editor.updateOptions({ glyphMargin: newValue });
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(editor, 'roundedSelection', function(config) {
|
options.appendChild(createOptionToggle(
|
||||||
return config.viewInfo.roundedSelection;
|
editor,
|
||||||
}, function(editor, newValue) {
|
'minimap',
|
||||||
editor.updateOptions({ roundedSelection: newValue });
|
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;
|
||||||
|
},
|
||||||
|
function(editor, newValue) {
|
||||||
|
editor.updateOptions({ readOnly: newValue });
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(editor, 'hideCursorInOverviewRuler', function(config) {
|
options.appendChild(createOptionToggle(
|
||||||
return config.viewInfo.hideCursorInOverviewRuler;
|
editor,
|
||||||
}, function(editor, newValue) {
|
'wordWrap',
|
||||||
editor.updateOptions({ hideCursorInOverviewRuler: newValue });
|
function(config) {
|
||||||
}));
|
return config.wrappingInfo.isViewportWrapping;
|
||||||
|
}, function(editor, newValue) {
|
||||||
|
editor.updateOptions({ wordWrap: newValue ? 'on' : 'off' });
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(editor, 'scrollBeyondLastLine', function(config) {
|
options.appendChild(createOptionToggle(
|
||||||
return config.viewInfo.scrollBeyondLastLine;
|
editor,
|
||||||
}, function(editor, newValue) {
|
'folding',
|
||||||
editor.updateOptions({ scrollBeyondLastLine: newValue });
|
function(config) {
|
||||||
}));
|
return config.contribInfo.folding;
|
||||||
|
}, function(editor, newValue) {
|
||||||
options.appendChild(createOptionToggle(editor, 'wordWrap', function(config) {
|
editor.updateOptions({ folding: newValue });
|
||||||
return config.wrappingInfo.isViewportWrapping;
|
}
|
||||||
}, function(editor, newValue) {
|
));
|
||||||
editor.updateOptions({ wrappingColumn: newValue ? 0 : WRAPPING_COLUMN });
|
|
||||||
}));
|
|
||||||
|
|
||||||
options.appendChild(createOptionToggle(editor, 'quickSuggestions', function(config) {
|
|
||||||
return config.contribInfo.quickSuggestions;
|
|
||||||
}, function(editor, newValue) {
|
|
||||||
editor.updateOptions({ quickSuggestions: 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…
Add table
Add a link
Reference in a new issue