Add API for note browsing
This commit is contained in:
parent
9420b66570
commit
654c47ceb6
@ -286,9 +286,19 @@ class AnkiBridge:
|
|||||||
return note
|
return note
|
||||||
|
|
||||||
|
|
||||||
def browseNote(self, noteId):
|
def browseNote(self, deckName, modelName, fields):
|
||||||
|
fields = self.modelFieldNames(modelName)
|
||||||
|
if fields is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
fieldName = fields[0]
|
||||||
|
fieldValue = fields.get(fieldName)
|
||||||
|
|
||||||
|
if fieldValue is None:
|
||||||
|
return
|
||||||
|
|
||||||
browser = aqt.dialogs.open('Browser', self.window())
|
browser = aqt.dialogs.open('Browser', self.window())
|
||||||
browser.form.searchEdit.lineEdit().setText('nid:{0}'.format(noteId))
|
browser.form.searchEdit.lineEdit().setText('deck:{} {}:{}'.format(deckName, fieldName, fieldValue))
|
||||||
browser.onSearch()
|
browser.onSearch()
|
||||||
|
|
||||||
|
|
||||||
@ -396,6 +406,14 @@ class AnkiConnect:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def api_browseNote(self, note):
|
||||||
|
return self.anki.browseNote(
|
||||||
|
note['deckName'],
|
||||||
|
note['modelName'],
|
||||||
|
note['fields']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def api_features(self):
|
def api_features(self):
|
||||||
features = {}
|
features = {}
|
||||||
for name in dir(self):
|
for name in dir(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user