From 5da192c7c0dcb08208bda9efd30b7f1b435d642c Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 19 Sep 2014 16:05:36 -0700 Subject: [PATCH] Added logic for moving the cursor in between markdown tags --- themes/grav/js/htmleditor.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/grav/js/htmleditor.js b/themes/grav/js/htmleditor.js index a6b65ebb..a8834311 100755 --- a/themes/grav/js/htmleditor.js +++ b/themes/grav/js/htmleditor.js @@ -308,7 +308,8 @@ replaceSelection: function(replace) { - var text = this.editor.getSelection(); + var text = this.editor.getSelection(), + indexOf = -1; if (!text.length) { @@ -325,12 +326,15 @@ if (curWord) { this.editor.setSelection({ line: cur.line, ch: start}, { line: cur.line, ch: end }); text = curWord; + } else { + indexOf = replace.indexOf('$1'); } } var html = replace.replace('$1', text); this.editor.replaceSelection(html, 'end'); + if (indexOf !== -1) this.editor.setCursor({ line: cur.line, ch: start + indexOf }); this.editor.focus(); },