mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
rework saveNow() so html editor saves text properly
This commit is contained in:
parent
92b57fc739
commit
7295bb829d
1 changed files with 8 additions and 6 deletions
|
@ -274,7 +274,6 @@ class Editor(object):
|
||||||
self.stealFocus = True
|
self.stealFocus = True
|
||||||
self.addMode = addMode
|
self.addMode = addMode
|
||||||
self._loaded = False
|
self._loaded = False
|
||||||
self._keepButtons = False
|
|
||||||
self.currentField = 0
|
self.currentField = 0
|
||||||
# current card, for card layout
|
# current card, for card layout
|
||||||
self.card = None
|
self.card = None
|
||||||
|
@ -440,7 +439,6 @@ class Editor(object):
|
||||||
if not self.addMode:
|
if not self.addMode:
|
||||||
self.note.flush()
|
self.note.flush()
|
||||||
if type == "blur":
|
if type == "blur":
|
||||||
if not self._keepButtons:
|
|
||||||
self.disableButtons()
|
self.disableButtons()
|
||||||
# run any filters
|
# run any filters
|
||||||
if runFilter(
|
if runFilter(
|
||||||
|
@ -535,10 +533,14 @@ class Editor(object):
|
||||||
"Must call this before adding cards, closing dialog, etc."
|
"Must call this before adding cards, closing dialog, etc."
|
||||||
if not self.note:
|
if not self.note:
|
||||||
return
|
return
|
||||||
self._keepButtons = True
|
if self.mw.app.focusWidget() != self.web:
|
||||||
self.web.eval("saveField('blur');")
|
# if no fields are focused, there's nothing to save
|
||||||
self._keepButtons = False
|
return
|
||||||
|
# move focus out of fields and save tags
|
||||||
|
self.parentWindow.setFocus()
|
||||||
self.saveTags()
|
self.saveTags()
|
||||||
|
# and process events so any focus-lost hooks fire
|
||||||
|
self.mw.app.processEvents()
|
||||||
|
|
||||||
def checkValid(self):
|
def checkValid(self):
|
||||||
cols = []
|
cols = []
|
||||||
|
|
Loading…
Reference in a new issue