mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
catch attempts to save field contents to wrong note
This commit is contained in:
parent
1b20dc3311
commit
38178e5281
2 changed files with 14 additions and 4 deletions
|
@ -242,8 +242,12 @@ class Editor:
|
||||||
return
|
return
|
||||||
# focus lost or key/button pressed?
|
# focus lost or key/button pressed?
|
||||||
if cmd.startswith("blur") or cmd.startswith("key"):
|
if cmd.startswith("blur") or cmd.startswith("key"):
|
||||||
(type, ord, txt) = cmd.split(":", 2)
|
(type, ord, nid, txt) = cmd.split(":", 3)
|
||||||
ord = int(ord)
|
ord = int(ord)
|
||||||
|
nid = int(nid)
|
||||||
|
if nid != self.note.id:
|
||||||
|
print("ignored late blur")
|
||||||
|
return
|
||||||
txt = urllib.parse.unquote(txt)
|
txt = urllib.parse.unquote(txt)
|
||||||
txt = unicodedata.normalize("NFC", txt)
|
txt = unicodedata.normalize("NFC", txt)
|
||||||
txt = self.mungeHTML(txt)
|
txt = self.mungeHTML(txt)
|
||||||
|
@ -318,9 +322,10 @@ class Editor:
|
||||||
self.web.setFocus()
|
self.web.setFocus()
|
||||||
runHook("loadNote", self)
|
runHook("loadNote", self)
|
||||||
|
|
||||||
self.web.evalWithCallback("setFields(%s); setFonts(%s); focusField(%s)" % (
|
self.web.evalWithCallback("setFields(%s); setFonts(%s); focusField(%s); setNoteId(%s)" % (
|
||||||
json.dumps(data),
|
json.dumps(data),
|
||||||
json.dumps(self.fonts()), json.dumps(focusTo)),
|
json.dumps(self.fonts()), json.dumps(focusTo),
|
||||||
|
json.dumps(self.note.id)),
|
||||||
oncallback)
|
oncallback)
|
||||||
|
|
||||||
def fonts(self):
|
def fonts(self):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
var currentField = null;
|
var currentField = null;
|
||||||
var changeTimer = null;
|
var changeTimer = null;
|
||||||
var dropTarget = null;
|
var dropTarget = null;
|
||||||
|
var currentNoteId = null;
|
||||||
|
|
||||||
String.prototype.format = function () {
|
String.prototype.format = function () {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
|
@ -203,7 +204,7 @@ function saveField(type) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// type is either 'blur' or 'key'
|
// type is either 'blur' or 'key'
|
||||||
pycmd(type + ":" + currentFieldOrdinal() + ":" + currentField.innerHTML);
|
pycmd(type + ":" + currentFieldOrdinal() + ":" + currentNoteId + ":" + currentField.innerHTML);
|
||||||
clearChangeTimer();
|
clearChangeTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +296,10 @@ function setFonts(fonts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setNoteId(id) {
|
||||||
|
currentNoteId = id;
|
||||||
|
}
|
||||||
|
|
||||||
function showDupes() {
|
function showDupes() {
|
||||||
$("#dupes").show();
|
$("#dupes").show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue