mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Possible fix for error when copying text in editor
https://forums.ankiweb.net/t/error-copying-data-when-editing-a-note-field-anki-2-1-54/23147 https://forums.ankiweb.net/t/error-during-performing-an-ahk-script/23070
This commit is contained in:
parent
8142176f84
commit
39d59caa48
1 changed files with 13 additions and 3 deletions
|
@ -1374,9 +1374,19 @@ class EditorWebView(AnkiWebView):
|
|||
mime = clip.mimeData()
|
||||
if not mime.hasHtml():
|
||||
return
|
||||
html = mime.html()
|
||||
mime.setHtml(f"<!--anki-->{html}")
|
||||
aqt.mw.progress.timer(10, lambda: clip.setMimeData(mime), False, parent=self)
|
||||
html = f"<!--anki-->{mime.html()}"
|
||||
|
||||
def after_delay() -> None:
|
||||
# utilities that modify the clipboard can invalidate our existing
|
||||
# mime handle in the time it takes for the timer to fire, so we need
|
||||
# to fetch the data again
|
||||
mime = clip.mimeData()
|
||||
mime.setHtml(html)
|
||||
clip.setMimeData(mime)
|
||||
|
||||
# Mutter bugs out if the clipboard data is mutated in the clipboard change
|
||||
# hook, so we need to do it after a small delay
|
||||
aqt.mw.progress.timer(10, after_delay, False, parent=self)
|
||||
|
||||
def contextMenuEvent(self, evt: QContextMenuEvent) -> None:
|
||||
m = QMenu(self)
|
||||
|
|
Loading…
Reference in a new issue