mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-13 08:46:04 +01:00
Added logic for moving the cursor in between markdown tags
This commit is contained in:
@@ -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();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user