Browse Source

Auto layout monaco editor on window resize

pull/6/head
Menci 6 years ago
parent
commit
cc01ecc840
  1. 13
      static/self/monaco-editor.js

13
static/self/monaco-editor.js

@ -584,10 +584,16 @@ require(['vs/editor/editor.main'], function () {
}); });
} }
function autoLayout(editor) {
window.addEventListener('resize', function () {
editor.layout();
});
}
$.getScript(window.pathSelfLib + "monaco-editor-tomorrow.js", function () { $.getScript(window.pathSelfLib + "monaco-editor-tomorrow.js", function () {
window.createCodeEditor = function (editorElement, langauge, content) { window.createCodeEditor = function (editorElement, langauge, content) {
editorElement.innerHTML = ''; editorElement.innerHTML = '';
return monaco.editor.create(editorElement, { var editor = monaco.editor.create(editorElement, {
value: content, value: content,
language: langauge, language: langauge,
multicursorModifier: 'ctrlCmd', multicursorModifier: 'ctrlCmd',
@ -608,6 +614,9 @@ require(['vs/editor/editor.main'], function () {
hideCursorInOverviewRuler: true, hideCursorInOverviewRuler: true,
contextmenu: false contextmenu: false
}); });
autoLayout(editor);
return editor;
}; };
window.createMarkdownEditor = function (wrapperElement, content, input) { window.createMarkdownEditor = function (wrapperElement, content, input) {
@ -653,6 +662,8 @@ require(['vs/editor/editor.main'], function () {
input.value = editor.getValue(); input.value = editor.getValue();
}); });
autoLayout(editor);
return editor; return editor;
}; };

Loading…
Cancel
Save