diff --git a/aqt/editor.py b/aqt/editor.py index 8eaa76d8a..1906fb20c 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -723,22 +723,22 @@ class Editor(object): ###################################################################### def toggleBold(self, bool): - self._eval("setFormat('bold');") + self.web.eval("setFormat('bold');") def toggleItalic(self, bool): - self._eval("setFormat('italic');") + self.web.eval("setFormat('italic');") def toggleUnderline(self, bool): - self._eval("setFormat('underline');") + self.web.eval("setFormat('underline');") def toggleSuper(self, bool): - self._eval("setFormat('superscript');") + self.web.eval("setFormat('superscript');") def toggleSub(self, bool): - self._eval("setFormat('subscript');") + self.web.eval("setFormat('subscript');") def removeFormat(self): - self._eval("setFormat('removeFormat');") + self.web.eval("setFormat('removeFormat');") def onCloze(self): # check that the model is set up for cloze deletion @@ -756,13 +756,7 @@ class Editor(object): highest += 1 # must start at 1 highest = max(1, highest) - self._eval("wrap('{{c%d::', '}}');" % highest) - - def _eval(self, str): - # some versions of webkit crash if we try a dom-modifying operation - # before outstanding UI events have been processed - self.mw.app.processEvents() - self.mw.progress.timer(100, lambda: self.web.eval(str), False) + self.web.eval("wrap('{{c%d::', '}}');" % highest) # Foreground colour ###################################################################### @@ -800,7 +794,7 @@ class Editor(object): self.mw.pm.profile['lastColour'] = self.fcolour def _wrapWithColour(self, colour): - self._eval("setFormat('forecolor', '%s')" % colour) + self.web.eval("setFormat('forecolor', '%s')" % colour) # Audio/video/images ###################################################################### @@ -816,7 +810,7 @@ class Editor(object): def addMedia(self, path, canDelete=False): html = self._addMedia(path, canDelete) - self._eval("setFormat('inserthtml', %s);" % json.dumps(html)) + self.web.eval("setFormat('inserthtml', %s);" % json.dumps(html)) def _addMedia(self, path, canDelete=False): "Add to media folder and return basename." @@ -870,13 +864,13 @@ class Editor(object): ###################################################################### def insertLatex(self): - self._eval("wrap('[latex]', '[/latex]');") + self.web.eval("wrap('[latex]', '[/latex]');") def insertLatexEqn(self): - self._eval("wrap('[$]', '[/$]');") + self.web.eval("wrap('[$]', '[/$]');") def insertLatexMathEnv(self): - self._eval("wrap('[$$]', '[/$$]');") + self.web.eval("wrap('[$$]', '[/$$]');") # Keyboard layout ######################################################################