Added logic for moving the cursor in between markdown tags

This commit is contained in:
Djamil Legato
2014-09-19 16:05:36 -07:00
parent 2743c6f614
commit 5da192c7c0

View File

@@ -308,7 +308,8 @@
replaceSelection: function(replace) { replaceSelection: function(replace) {
var text = this.editor.getSelection(); var text = this.editor.getSelection(),
indexOf = -1;
if (!text.length) { if (!text.length) {
@@ -325,12 +326,15 @@
if (curWord) { if (curWord) {
this.editor.setSelection({ line: cur.line, ch: start}, { line: cur.line, ch: end }); this.editor.setSelection({ line: cur.line, ch: start}, { line: cur.line, ch: end });
text = curWord; text = curWord;
} else {
indexOf = replace.indexOf('$1');
} }
} }
var html = replace.replace('$1', text); var html = replace.replace('$1', text);
this.editor.replaceSelection(html, 'end'); this.editor.replaceSelection(html, 'end');
if (indexOf !== -1) this.editor.setCursor({ line: cur.line, ch: start + indexOf });
this.editor.focus(); this.editor.focus();
}, },