mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
partially fix the broken inserthtml handling on old qt/linux
This commit is contained in:
parent
694fad9f47
commit
be4aa382c3
1 changed files with 11 additions and 2 deletions
|
@ -35,6 +35,8 @@ body { margin: 5px; }
|
||||||
</style><script>
|
</style><script>
|
||||||
%s
|
%s
|
||||||
|
|
||||||
|
insertHTMLOK = %s;
|
||||||
|
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
return this.replace(/\{\d+\}/g, function(m){
|
return this.replace(/\{\d+\}/g, function(m){
|
||||||
|
@ -129,14 +131,20 @@ function wrappedExceptForWhitespace(text, front, back) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function wrap(front, back) {
|
function wrap(front, back) {
|
||||||
setFormat('removeFormat', null, true);
|
|
||||||
var s = window.getSelection();
|
var s = window.getSelection();
|
||||||
var r = s.getRangeAt(0);
|
var r = s.getRangeAt(0);
|
||||||
var content = r.cloneContents();
|
var content = r.cloneContents();
|
||||||
var span = document.createElement("span")
|
var span = document.createElement("span")
|
||||||
span.appendChild(content);
|
span.appendChild(content);
|
||||||
var new_ = wrappedExceptForWhitespace(span.innerHTML, front, back);
|
var new_ = wrappedExceptForWhitespace(span.innerHTML, front, back);
|
||||||
setFormat('inserthtml', new_);
|
if (insertHTMLOK) {
|
||||||
|
setFormat("inserthtml", new_);
|
||||||
|
} else {
|
||||||
|
r.deleteContents();
|
||||||
|
r.collapse(true);
|
||||||
|
r.insertNode(document.createTextNode(new_));
|
||||||
|
saveField('key');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function setFields(fields, focusTo) {
|
function setFields(fields, focusTo) {
|
||||||
|
@ -405,6 +413,7 @@ class Editor(object):
|
||||||
# change timer
|
# change timer
|
||||||
if self.note:
|
if self.note:
|
||||||
self.web.setHtml(_html % (getBase(self.mw.col), anki.js.all,
|
self.web.setHtml(_html % (getBase(self.mw.col), anki.js.all,
|
||||||
|
(isMac or isWin) and 1 or 0,
|
||||||
_("Show Duplicates")),
|
_("Show Duplicates")),
|
||||||
loadCB=self._loadFinished)
|
loadCB=self._loadFinished)
|
||||||
self.updateTagsAndDeck()
|
self.updateTagsAndDeck()
|
||||||
|
|
Loading…
Reference in a new issue