diff --git a/aqt/editor.py b/aqt/editor.py index 86a6f3e34..1ce32edaf 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -787,9 +787,13 @@ class EditorWebView(AnkiWebView): def keyPressEvent(self, evt): self._curKey = True + if evt.matches(QKeySequence.Paste): + self.onPaste() return QWebView.keyPressEvent(self, evt) def contextMenuEvent(self, evt): + # adjust in case the user is going to paste + self.onPaste() QWebView.contextMenuEvent(self, evt) def dropEvent(self, evt): @@ -813,6 +817,12 @@ class EditorWebView(AnkiWebView): evt.accept() QWebView.dropEvent(self, new) + def onPaste(self): + clip = self.editor.mw.app.clipboard() + mime = clip.mimeData() + mime = self._processMime(mime) + clip.setMimeData(mime) + def _processMime(self, mime): print "html=%s image=%s urls=%s txt=%s" % ( mime.hasHtml(), mime.hasImage(), mime.hasUrls(), mime.hasText())