diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 5087e1579..b706c324c 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -493,6 +493,16 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too EditorState(int(new_state_id)), EditorState(int(old_state_id)) ) + elif cmd.startswith("ioImageLoaded"): + (_, path_or_nid_data) = cmd.split(":", 1) + path_or_nid = json.loads(path_or_nid_data) + if self.addMode: + gui_hooks.editor_mask_editor_did_load_image(self, path_or_nid) + else: + gui_hooks.editor_mask_editor_did_load_image( + self, NoteId(int(path_or_nid)) + ) + elif cmd in self._links: return self._links[cmd](self) diff --git a/qt/tools/genhooks_gui.py b/qt/tools/genhooks_gui.py index bb7cf10dc..57c5443cf 100644 --- a/qt/tools/genhooks_gui.py +++ b/qt/tools/genhooks_gui.py @@ -1155,6 +1155,15 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest) doc="""Called when the input state of the editor changes, e.g. when switching to an image occlusion note type.""", ), + Hook( + name="editor_mask_editor_did_load_image", + args=["editor: aqt.editor.Editor", "path_or_nid: str | anki.notes.NoteId"], + doc="""Called when the image occlusion mask editor has completed + loading an image. + + When adding new notes `path_or_nid` will be the path to the image file. + When editing existing notes `path_or_nid` will be the note id.""", + ), # Tag ################### Hook(name="tag_editor_did_process_key", args=["tag_edit: TagEdit", "evt: QEvent"]), diff --git a/ts/editor/NoteEditor.svelte b/ts/editor/NoteEditor.svelte index 7ae589082..da9e1938f 100644 --- a/ts/editor/NoteEditor.svelte +++ b/ts/editor/NoteEditor.svelte @@ -42,7 +42,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html