mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
when wrap called with empty selection, postion caret in middle
This commit is contained in:
parent
e7911652ef
commit
ff28fdd189
1 changed files with 8 additions and 1 deletions
|
@ -48,7 +48,6 @@ body { margin: 5px; }
|
|||
var currentField = null;
|
||||
var changeTimer = null;
|
||||
var insertHTMLOK = %s;
|
||||
var savedSel = null;
|
||||
var dropTarget = null;
|
||||
|
||||
String.prototype.format = function() {
|
||||
|
@ -185,6 +184,14 @@ function wrap(front, back) {
|
|||
r.insertNode(document.createTextNode(new_));
|
||||
saveField('key');
|
||||
}
|
||||
if (!span.innerHTML) {
|
||||
// run with an empty selection; move cursor back past postfix
|
||||
r = s.getRangeAt(0);
|
||||
r.setStart(r.startContainer, r.startOffset - back.length);
|
||||
r.collapse(true);
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
}
|
||||
};
|
||||
|
||||
function setFields(fields, focusTo) {
|
||||
|
|
Loading…
Reference in a new issue