mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -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 currentField = null;
|
||||||
var changeTimer = null;
|
var changeTimer = null;
|
||||||
var insertHTMLOK = %s;
|
var insertHTMLOK = %s;
|
||||||
var savedSel = null;
|
|
||||||
var dropTarget = null;
|
var dropTarget = null;
|
||||||
|
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
|
@ -185,6 +184,14 @@ function wrap(front, back) {
|
||||||
r.insertNode(document.createTextNode(new_));
|
r.insertNode(document.createTextNode(new_));
|
||||||
saveField('key');
|
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) {
|
function setFields(fields, focusTo) {
|
||||||
|
|
Loading…
Reference in a new issue