mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Prefer image pastes over HTML in the editor (#2856)
This commit is contained in:
parent
e2e9e37a31
commit
abd8759d50
1 changed files with 18 additions and 10 deletions
|
@ -1490,26 +1490,29 @@ class EditorWebView(AnkiWebView):
|
|||
# print("urls", mime.urls())
|
||||
# print("text", mime.text())
|
||||
|
||||
internal = False
|
||||
|
||||
mime = gui_hooks.editor_will_process_mime(
|
||||
mime, self, internal, extended, drop_event
|
||||
mime, self, False, extended, drop_event
|
||||
)
|
||||
|
||||
# try various content types in turn
|
||||
if mime.hasHtml():
|
||||
html_content = mime.html()[11:] if internal else mime.html()
|
||||
return html_content, internal
|
||||
|
||||
# favour url if it's a local link
|
||||
if (
|
||||
mime.hasUrls()
|
||||
and (urls := mime.urls())
|
||||
and urls[0].toString().startswith("file://")
|
||||
):
|
||||
types = (self._processUrls, self._processImage, self._processText)
|
||||
types = (
|
||||
self._processUrls,
|
||||
self._processImage,
|
||||
self._processHtml,
|
||||
self._processText,
|
||||
)
|
||||
else:
|
||||
types = (self._processImage, self._processUrls, self._processText)
|
||||
types = (
|
||||
self._processImage,
|
||||
self._processHtml,
|
||||
self._processUrls,
|
||||
self._processText,
|
||||
)
|
||||
|
||||
for fn in types:
|
||||
html = fn(mime, extended)
|
||||
|
@ -1531,6 +1534,11 @@ class EditorWebView(AnkiWebView):
|
|||
|
||||
return buf
|
||||
|
||||
def _processHtml(self, mime: QMimeData, extended: bool = False) -> str | None:
|
||||
if mime.hasHtml():
|
||||
return mime.html()
|
||||
return None
|
||||
|
||||
def _processText(self, mime: QMimeData, extended: bool = False) -> str | None:
|
||||
if not mime.hasText():
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue