X-Git-Url: http://git.ipfire.org/?p=ipfire.org.git;a=blobdiff_plain;f=src%2Fstatic%2Fjs%2Feditor.js;fp=src%2Fstatic%2Fjs%2Feditor.js;h=39fac6b214c0b91e4986cf6da60c4c0d3289c245;hp=7639ae2eaa09bd13f436f6b17967cf0cd9f1e453;hb=6eb53879591bd0b1573da7ce7d001523a1b25ff2;hpb=18c363578bdf14415519d68a16707ac08e4781dd diff --git a/src/static/js/editor.js b/src/static/js/editor.js index 7639ae2e..39fac6b2 100644 --- a/src/static/js/editor.js +++ b/src/static/js/editor.js @@ -45,12 +45,12 @@ class Editor { // Functions to modify the text replaceSelection(replacement) { - var text = this.textarea.val(); + // Get the DOM element + var textarea = this.textarea.get(0); - text = text.slice(0, this.selection.start) + replacement + text.slice(this.selection.end); - - // Write text to textarea - this.textarea.val(text); + // Write text to textarea and move the cursor to the end + textarea.setRangeText(replacement, + this.selection.start, this.selection.end, "end"); } insertAtCursor(insertion) {