From d5ea5697dbac4887ff2ecbcdc77d0a483a59911b Mon Sep 17 00:00:00 2001 From: Yoonchae Lee Date: Mon, 27 Jun 2022 18:41:32 +0900 Subject: [PATCH] serve card at the end --- src/addon/reviewer.py | 9 ++++++--- src/addon/web/global_card.js | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/addon/reviewer.py b/src/addon/reviewer.py index a266894..a5782b1 100644 --- a/src/addon/reviewer.py +++ b/src/addon/reviewer.py @@ -6,6 +6,7 @@ from anki.buildinfo import version as ankiversion from anki.template import TemplateRenderContext from anki.notes import Note +from anki.cards import Card import aqt from aqt import mw, gui_hooks from aqt.editor import Editor @@ -62,10 +63,13 @@ def edit_filter(txt: str, field: str, filt: str, ctx: TemplateRenderContext) -> txt, conf["tag"], ) - txt += "".format(field) return txt +def serve_card(txt: str, card: Card, kind: str) -> str: + return txt + "" + + def saveField(note: Note, fld: str, val: str) -> None: if fld == "Tags": # aqt.editor.Editor.saveTags @@ -210,6 +214,5 @@ def on_webview(web_content: aqt.webview.WebContent, context: Optional[Any]) -> N mw.addonManager.setWebExports(__name__, r"web/.*") gui_hooks.webview_will_set_content.append(on_webview) gui_hooks.webview_did_receive_js_message.append(handle_pycmd_message) +gui_hooks.card_will_show.append(serve_card) anki.hooks.field_filter.append(edit_filter) - -# gui_hooks.card_will_show.append(lambda t, c, k: print(t)) diff --git a/src/addon/web/global_card.js b/src/addon/web/global_card.js index 872b127..f695d8f 100644 --- a/src/addon/web/global_card.js +++ b/src/addon/web/global_card.js @@ -253,8 +253,8 @@ ['onkeypress', 'handleKeyPress'] ] - EFDRC.serveCard = function (fld) { // fld: string - const els = document.querySelectorAll("[data-EFDRCfield='" + fld + "']") + EFDRC.serveCard = function () { // fld: string + const els = document.querySelectorAll('[data-EFDRCfield]') for (const el of els) { if (EFDRC.CONF.ctrl_click) { const fldName = b64DecodeUnicode(el.getAttribute('data-EFDRCfield'))