From ffa31a965e2121d7dd0eb7a582d2b82bd1204c7a Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 30 Sep 2015 21:11:52 +0200 Subject: Do not override user options in codeq.makeEditor Also clean up remains of previous CodeMirror panel support. --- js/codeq/editor.js | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/js/codeq/editor.js b/js/codeq/editor.js index f84bd05..d0b365e 100644 --- a/js/codeq/editor.js +++ b/js/codeq/editor.js @@ -1,28 +1,23 @@ codeq.makeEditor = function (elt, options) { - var statusBar = document.createElement("div"), + var statusBar = $(elt).siblings(".block-statusbar")[0], updateStatusBar = function (pos) { statusBar.innerHTML = 'line ' + (pos.line+1) + ', column ' + (pos.ch+1); }, - editor; + allOptions = $.extend({ + cursorHeight: 0.85, + lineNumbers: true, + matchBrackets: true, + extraKeys: { + // replace tabs with spaces + Tab: function (cm) { + var spaces = Array(cm.getOption("indentUnit") + 1).join(" "); + cm.replaceSelection(spaces); + } + } + }, options), + editor = CodeMirror(elt, allOptions); - options.cursorHeight = 0.85; - options.lineNumbers = true; - options.matchBrackets = true; - options.extraKeys = { - // replace tabs with spaces - Tab: function (cm) { - var spaces = Array(cm.getOption("indentUnit") + 1).join(" "); - cm.replaceSelection(spaces); - } - }; - editor = CodeMirror(elt, options), - - //since addPanel brakes CodeMirrot responsiveness no mather what, we manually added block-statusbar located at the bottom of editor block - //statusBar.className = 'editor-statusbar'; - statusBar = statusBar = $(elt).siblings(".block-statusbar")[0]; updateStatusBar({line: 0, ch: 0}); - - //editor.addPanel(statusBar, {position: 'bottom'}); editor.on('cursorActivity', function (instance) { var pos = instance.getDoc().getCursor(); updateStatusBar(pos); -- cgit v1.2.1