diff --git a/README.md b/README.md index 06d9d7d..8fac95f 100644 --- a/README.md +++ b/README.md @@ -1059,6 +1059,34 @@ corresponding to when the API was available for use. } ``` +* **guiEditNote** + + Opens the *Edit* dialog with a note corresponding to given note ID. + The dialog is similar to the *Edit Current* dialog, but: + * has a Preview button to preview the cards for the note + * has a Browse button to open the browser with these cards + * has Previous/Back buttons to navigate the history of the dialog + * has no bar with the Close button + + *Sample request*: + ```json + { + "action": "guiEditNote", + "version": 6, + "params": { + "note": 1649198355435 + } + } + ``` + + *Sample result*: + ```json + { + "result": null, + "error": null + } + ``` + * **guiCurrentCard** Returns information about the current card or `null` if not in review mode. diff --git a/plugin/__init__.py b/plugin/__init__.py index a192839..8e15035 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -41,6 +41,8 @@ from anki.exporting import AnkiPackageExporter from anki.importing import AnkiPackageImporter from anki.notes import Note +from .edit import Edit + try: from anki.rsbackend import NotFoundError except: @@ -1366,6 +1368,12 @@ class AnkiConnect: return self.findCards(query) + + @util.api() + def guiEditNote(self, note): + Edit.open_dialog_and_show_note_with_id(note) + + @util.api() def guiSelectedNotes(self): (creator, instance) = aqt.dialogs._dialogs['Browser'] @@ -1706,6 +1714,8 @@ class AnkiConnect: # when run inside Anki, `__name__` would be either numeric, # or, if installed via `link.sh`, `AnkiConnectDev` if __name__ != "plugin": + Edit.register_with_dialog_manager() + ac = AnkiConnect() ac.initLogging() ac.startWebServer()