mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
fix test complaints
This commit is contained in:
parent
2ef0ab981d
commit
7451ad68b1
2 changed files with 15 additions and 7 deletions
|
@ -863,12 +863,16 @@ $editorToolbar.then(({{ toolbar }}) => toolbar.appendGroup({{
|
||||||
self.web.eval(f"pasteHTML({json.dumps(html)}, {json.dumps(internal)}, {ext});")
|
self.web.eval(f"pasteHTML({json.dumps(html)}, {json.dumps(internal)}, {ext});")
|
||||||
gui_hooks.editor_did_paste(self, html, internal, extended)
|
gui_hooks.editor_did_paste(self, html, internal, extended)
|
||||||
|
|
||||||
def doDrop(self, html: str, internal: bool, extended: bool, cursor_pos: QPoint) -> None:
|
def doDrop(
|
||||||
|
self, html: str, internal: bool, extended: bool, cursor_pos: QPoint
|
||||||
|
) -> None:
|
||||||
def pasteIfField(ret: bool) -> None:
|
def pasteIfField(ret: bool) -> None:
|
||||||
if ret:
|
if ret:
|
||||||
self.doPaste(html, internal, extended)
|
self.doPaste(html, internal, extended)
|
||||||
|
|
||||||
self.web.evalWithCallback(f"focusIfField({cursor_pos.x()}, {cursor_pos.y()});", pasteIfField)
|
self.web.evalWithCallback(
|
||||||
|
f"focusIfField({cursor_pos.x()}, {cursor_pos.y()});", pasteIfField
|
||||||
|
)
|
||||||
|
|
||||||
def onPaste(self) -> None:
|
def onPaste(self) -> None:
|
||||||
self.web.onPaste()
|
self.web.onPaste()
|
||||||
|
@ -1151,7 +1155,9 @@ class EditorWebView(AnkiWebView):
|
||||||
self.editor.doDrop(html, internal, extended, cursor_pos)
|
self.editor.doDrop(html, internal, extended, cursor_pos)
|
||||||
|
|
||||||
# returns (html, isInternal)
|
# returns (html, isInternal)
|
||||||
def _processMime(self, mime: QMimeData, extended: bool = False, drop_event: bool = False) -> Tuple[str, bool]:
|
def _processMime(
|
||||||
|
self, mime: QMimeData, extended: bool = False, drop_event: bool = False
|
||||||
|
) -> Tuple[str, bool]:
|
||||||
# print("html=%s image=%s urls=%s txt=%s" % (
|
# print("html=%s image=%s urls=%s txt=%s" % (
|
||||||
# mime.hasHtml(), mime.hasImage(), mime.hasUrls(), mime.hasText()))
|
# mime.hasHtml(), mime.hasImage(), mime.hasUrls(), mime.hasText()))
|
||||||
# print("html", mime.html())
|
# print("html", mime.html())
|
||||||
|
@ -1160,11 +1166,13 @@ class EditorWebView(AnkiWebView):
|
||||||
|
|
||||||
internal = mime.html().startswith("<!--anki-->")
|
internal = mime.html().startswith("<!--anki-->")
|
||||||
|
|
||||||
mime = gui_hooks.editor_will_process_mime(self, mime, internal, extended, drop_event)
|
mime = gui_hooks.editor_will_process_mime(
|
||||||
|
mime, self, internal, extended, drop_event
|
||||||
|
)
|
||||||
|
|
||||||
# try various content types in turn
|
# try various content types in turn
|
||||||
if mime.hasHtml():
|
if mime.hasHtml():
|
||||||
return mime.html().replace("<!--anki-->", ''), internal
|
return mime.html().replace("<!--anki-->", ""), internal
|
||||||
|
|
||||||
# favour url if it's a local link
|
# favour url if it's a local link
|
||||||
if mime.hasUrls() and mime.urls()[0].toString().startswith("file://"):
|
if mime.hasUrls() and mime.urls()[0].toString().startswith("file://"):
|
||||||
|
|
|
@ -29,7 +29,7 @@ from anki.decks import DeckDict, DeckConfigDict
|
||||||
from anki.hooks import runFilter, runHook
|
from anki.hooks import runFilter, runHook
|
||||||
from anki.models import NotetypeDict
|
from anki.models import NotetypeDict
|
||||||
from anki.collection import OpChangesAfterUndo
|
from anki.collection import OpChangesAfterUndo
|
||||||
from aqt.qt import QDialog, QEvent, QMenu, QModelIndex, QWidget
|
from aqt.qt import QDialog, QEvent, QMenu, QModelIndex, QWidget, QMimeData
|
||||||
from aqt.tagedit import TagEdit
|
from aqt.tagedit import TagEdit
|
||||||
from aqt.undo import UndoActionsInfo
|
from aqt.undo import UndoActionsInfo
|
||||||
"""
|
"""
|
||||||
|
@ -867,8 +867,8 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
|
||||||
Hook(
|
Hook(
|
||||||
name="editor_will_process_mime",
|
name="editor_will_process_mime",
|
||||||
args=[
|
args=[
|
||||||
"editor_web_view: aqt.editor.EditorWebView",
|
|
||||||
"mime: QMimeData",
|
"mime: QMimeData",
|
||||||
|
"editor_web_view: aqt.editor.EditorWebView",
|
||||||
"internal: bool",
|
"internal: bool",
|
||||||
"extended: bool",
|
"extended: bool",
|
||||||
"drop_event: bool",
|
"drop_event: bool",
|
||||||
|
|
Loading…
Reference in a new issue