// 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) {