rework saveNow() so html editor saves text properly

This commit is contained in:
Damien Elmes 2012-04-23 05:43:23 +09:00
parent 92b57fc739
commit 7295bb829d

View file

@ -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 = []