diff --git a/aqt/editor.py b/aqt/editor.py index b14825079..f54740fbe 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -646,6 +646,9 @@ to a cloze type first, via Edit>Change Note Type.""")) def onPaste(self): self.web.onPaste() + def onCutOrCopy(self): + self.web.flagAnkiText() + # Advanced menu ###################################################################### @@ -693,6 +696,7 @@ to a cloze type first, via Edit>Change Note Type.""")) more=onAdvanced, dupes=showDupes, paste=onPaste, + cutOrCopy=onCutOrCopy, ) # Pasting, drag & drop, and keyboard layouts @@ -715,11 +719,9 @@ class EditorWebView(AnkiWebView): self._flagAnkiText() def onCut(self): - self._markInternal = True self.triggerPageAction(QWebEnginePage.Cut) def onCopy(self): - self._markInternal = True self.triggerPageAction(QWebEnginePage.Copy) def onPaste(self): @@ -819,6 +821,10 @@ class EditorWebView(AnkiWebView): # add to media and return resulting html link return self.editor._addMedia(newpath) + def flagAnkiText(self): + # be ready to adjust when clipboard event fires + self._markInternal = True + def _flagAnkiText(self): # add a comment in the clipboard html so we can tell text is copied # from us and doesn't need to be stripped diff --git a/web/editor.js b/web/editor.js index 14df3bdcc..8bed7ae9d 100644 --- a/web/editor.js +++ b/web/editor.js @@ -258,6 +258,11 @@ function wrap(front, back) { } } +function onCutOrCopy() { + pycmd("cutOrCopy"); + return true; +} + function setFields(fields, prewrap) { var txt = ""; for (var i = 0; i < fields.length; i++) { @@ -270,6 +275,7 @@ function setFields(fields, prewrap) { txt += "