Add guiSelectedNotes action (#292)

This commit is contained in:
penginsan 2021-12-06 16:59:10 +00:00 committed by GitHub
parent ca60bf6c61
commit 064fbef413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 0 deletions

View File

@ -1018,6 +1018,27 @@ corresponding to when the API was available for use.
} }
``` ```
* **guiSelectedNotes**
Finds the open instance of the *Card Browser* dialog and returns an array of identifiers of the notes that are
selected. Returns an empty list if the browser is not open.
*Sample request*:
```json
{
"action": "guiSelectedNotes",
"version": 6
}
```
*Sample result*:
```json
{
"result": [1494723142483, 1494703460437, 1494703479525],
"error": null
}
```
* **guiAddCards** * **guiAddCards**
Invokes the *Add Cards* dialog, presets the note using the given deck and model, with the provided field values and tags. Invokes the *Add Cards* dialog, presets the note using the given deck and model, with the provided field values and tags.

View File

@ -1354,6 +1354,12 @@ class AnkiConnect:
return self.findCards(query) return self.findCards(query)
@util.api()
def guiSelectedNotes(self):
(creator, instance) = aqt.dialogs._dialogs['Browser']
if instance is None:
return []
return instance.selectedNotes()
@util.api() @util.api()
def guiAddCards(self, note=None): def guiAddCards(self, note=None):

View File

@ -9,6 +9,9 @@ class TestGui(unittest.TestCase):
# guiBrowse # guiBrowse
util.invoke('guiBrowse', query='deck:Default') util.invoke('guiBrowse', query='deck:Default')
# guiSelectedNotes
util.invoke('guiSelectedNotes')
# guiAddCards # guiAddCards
util.invoke('guiAddCards') util.invoke('guiAddCards')