mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Merge branch 'master' of https://github.com/aaronharsh/ankiqt
This commit is contained in:
commit
90b50ddd6c
1 changed files with 7 additions and 8 deletions
|
@ -123,20 +123,19 @@ function saveField(type) {
|
|||
clearChangeTimer();
|
||||
};
|
||||
|
||||
function wrappedExceptForWhitespace(text, front, back) {
|
||||
var match = text.match(/^(\s*)([^]*?)(\s*)$/);
|
||||
return match[1] + front + match[2] + back + match[3];
|
||||
};
|
||||
|
||||
function wrap(front, back) {
|
||||
setFormat('removeFormat', null, true);
|
||||
var s = window.getSelection();
|
||||
var r = s.getRangeAt(0);
|
||||
var content = r.extractContents();
|
||||
var content = r.cloneContents();
|
||||
var span = document.createElement("span")
|
||||
span.appendChild(content);
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
var new_ = front + span.innerHTML + back;
|
||||
var f = currentField.innerHTML;
|
||||
if (f.length && f[f.length-1] === " ") {
|
||||
new_ = " " + new_;
|
||||
}
|
||||
var new_ = wrappedExceptForWhitespace(span.innerHTML, front, back);
|
||||
setFormat('inserthtml', new_);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue