fix some lints
This commit is contained in:
parent
ac6397ae9e
commit
e80b3eeeef
@ -2866,20 +2866,20 @@ def mytest(web: AnkiWebView):
|
||||
gui_hooks.webview_did_inject_style_into_page.append(mytest)
|
||||
'''
|
||||
|
||||
_hooks: List[Callable[[AnkiWebView], None]] = []
|
||||
_hooks: List[Callable[["aqt.webview.AnkiWebView"], None]] = []
|
||||
|
||||
def append(self, cb: Callable[[AnkiWebView], None]) -> None:
|
||||
"""(webview: AnkiWebView)"""
|
||||
def append(self, cb: Callable[["aqt.webview.AnkiWebView"], None]) -> None:
|
||||
"""(webview: aqt.webview.AnkiWebView)"""
|
||||
self._hooks.append(cb)
|
||||
|
||||
def remove(self, cb: Callable[[AnkiWebView], None]) -> None:
|
||||
def remove(self, cb: Callable[["aqt.webview.AnkiWebView"], None]) -> None:
|
||||
if cb in self._hooks:
|
||||
self._hooks.remove(cb)
|
||||
|
||||
def count(self) -> int:
|
||||
return len(self._hooks)
|
||||
|
||||
def __call__(self, webview: AnkiWebView) -> None:
|
||||
def __call__(self, webview: aqt.webview.AnkiWebView) -> None:
|
||||
for hook in self._hooks:
|
||||
try:
|
||||
hook(webview)
|
||||
|
@ -10,9 +10,7 @@ from typing import Optional
|
||||
import aqt
|
||||
from anki.lang import _
|
||||
from aqt import gui_hooks
|
||||
from aqt.qt import QUrl
|
||||
from aqt.sound import av_player
|
||||
from aqt.theme import theme_manager
|
||||
from aqt.toolbar import BottomBar
|
||||
from aqt.utils import askUserDialog, openLink, shortcut, tooltip
|
||||
|
||||
|
@ -598,15 +598,19 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }}
|
||||
def inject_dynamic_style_and_show(self):
|
||||
"Add dynamic styling, and reveal."
|
||||
css = self.standard_css()
|
||||
|
||||
def after_style(arg):
|
||||
gui_hooks.webview_did_inject_style_into_page(self)
|
||||
self.show()
|
||||
|
||||
self.evalWithCallback(
|
||||
f"""
|
||||
const style = document.createElement('style');
|
||||
style.innerHTML = `{css}`;
|
||||
document.head.appendChild(style);
|
||||
""", after_style)
|
||||
""",
|
||||
after_style,
|
||||
)
|
||||
|
||||
def load_ts_page(self, name: str) -> None:
|
||||
from aqt import mw
|
||||
|
@ -454,7 +454,7 @@ hooks = [
|
||||
),
|
||||
Hook(
|
||||
name="webview_did_inject_style_into_page",
|
||||
args=["webview: AnkiWebView"],
|
||||
args=["webview: aqt.webview.AnkiWebView"],
|
||||
doc='''Called after standard styling is injected into an external
|
||||
html file, such as when loading the new graphs. You can use this hook to
|
||||
mutate the DOM before the page is revealed.
|
||||
@ -474,7 +474,8 @@ def mytest(web: AnkiWebView):
|
||||
)
|
||||
|
||||
gui_hooks.webview_did_inject_style_into_page.append(mytest)
|
||||
'''),
|
||||
''',
|
||||
),
|
||||
# Main
|
||||
###################
|
||||
Hook(
|
||||
|
Loading…
Reference in New Issue
Block a user