mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Replace use of window.postMessage in card info (#3646)
* Use anki.updateCard instead of window.onmessage in card-info * Make card-info placeholder text grey --------- Co-authored-by: Abdo <abdo@abdnh.net>
This commit is contained in:
parent
474dbc2812
commit
b061da73d3
3 changed files with 9 additions and 7 deletions
|
@ -73,7 +73,7 @@ class CardInfoDialog(QDialog):
|
|||
card_id = None
|
||||
|
||||
assert self.web is not None
|
||||
self.web.eval(f"window.postMessage('{card_id}');")
|
||||
self.web.eval(f"anki.updateCard('{card_id}');")
|
||||
|
||||
def reject(self) -> None:
|
||||
if self._on_close:
|
||||
|
|
|
@ -15,5 +15,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: grey;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -13,12 +13,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
|
||||
const showRevlog = $page.url.searchParams.get("revlog") !== "0";
|
||||
|
||||
function updateCardId(evt: MessageEvent) {
|
||||
goto(`/card-info/${evt.data}`);
|
||||
}
|
||||
globalThis.anki ||= {};
|
||||
globalThis.anki.updateCard = async (card_id: string): Promise<void> => {
|
||||
const path = `/card-info/${card_id}`;
|
||||
return goto(path).catch(() => {
|
||||
window.location.href = path;
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- used by CardInfoDialog.update_card -->
|
||||
<svelte:window on:message={updateCardId} />
|
||||
|
||||
<CardInfo stats={data.info} {showRevlog} />
|
||||
|
|
Loading…
Reference in a new issue