mirror of
https://github.com/ankitects/anki.git
synced 2025-11-08 13:47:13 -05:00
delayed eval no longer seems necessary
This commit is contained in:
parent
ae33ed2623
commit
f8c7f130a6
1 changed files with 12 additions and 18 deletions
|
|
@ -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
|
||||
######################################################################
|
||||
|
|
|
|||
Loading…
Reference in a new issue