From 5051dcedb684a3ba8d855169d9fdce8fdc2a0198 Mon Sep 17 00:00:00 2001 From: Simone Gaiarin Date: Fri, 6 Jan 2017 15:54:55 +0100 Subject: [PATCH] Add anki buttons using the new method The html of each anki button is stored in a list that is joined in a string at the end. This make it easier to run the filter. Drawback: Only buttons on the right side of the editor can be added using the filter. --- aqt/editor.py | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index ecb7e77bb..b6a48439d 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -438,26 +438,35 @@ class Editor(object): self.outerLayout.addWidget(self.web, 1) self.web.onLoadFinished = self._loadFinished + righttopbtns = list() + righttopbtns.append(self._addButton('text_bold', 'bold', "Bold text (Ctrl+B)")) + righttopbtns.append(self._addButton('text_italic', 'italic', "Italic text (Ctrl+I)")) + righttopbtns.append(self._addButton('text_under', 'underline', "Underline text (Ctrl+U)")) + righttopbtns.append(self._addButton('text_super', 'super', "Superscript (Ctrl+Shift+=)")) + righttopbtns.append(self._addButton('text_sub', 'sub', "Subscript (Ctrl+=)")) + righttopbtns.append(self._addButton('text_clear', 'clear', "Remove formatting (Ctrl+R)")) + # The color selection buttons do not use an icon so the HTML must be specified manually + righttopbtns.append('''''') + righttopbtns.append('''''') + righttopbtns.append(self._addButton('text_cloze', 'cloze', "Cloze deletion (Ctrl+Shift+C)")) + righttopbtns.append(self._addButton('paperclip', 'attach', "Attach pictures/audio/video (F3)")) + righttopbtns.append(self._addButton('media-record', 'record', "Record audio (F5)")) + righttopbtns.append(self._addButton('more', 'more')) topbuts = """ -
- - -
-
- - - - - - - - - - - - -
- """ % dict(flds=_("Fields"), cards=_("Cards")) +
+ + +
+
+ %(rightbts)s +
+ """ % dict(flds=_("Fields"), cards=_("Cards"), rightbts="".join(righttopbtns)) topbuts = runFilter("setupEditorButtons", topbuts) self.web.stdHtml(_html % ( self.mw.baseHTML(), anki.js.jquery,