add support to modify fields of exist note.
This commit is contained in:
parent
aabfc8596b
commit
7de12f7d4b
@ -424,6 +424,18 @@ class AnkiBridge:
|
||||
if not note.dupeOrEmpty():
|
||||
return note
|
||||
|
||||
def updateNoteFields(self, params):
|
||||
collection = self.collection()
|
||||
if collection is None:
|
||||
return
|
||||
|
||||
note = collection.getNote(params['id'])
|
||||
if note is None:
|
||||
raise Exception("Failed to get note:{}".format(params['id']))
|
||||
for name, value in params['fields'].items():
|
||||
if name in note:
|
||||
note[name] = value
|
||||
note.flush()
|
||||
|
||||
def addTags(self, notes, tags, add=True):
|
||||
self.startEditing()
|
||||
@ -1023,6 +1035,9 @@ class AnkiConnect:
|
||||
|
||||
return results
|
||||
|
||||
@webApi()
|
||||
def updateNoteFields(self, note):
|
||||
return self.anki.updateNoteFields(note)
|
||||
|
||||
@webApi()
|
||||
def canAddNotes(self, notes):
|
||||
|
32
README.md
32
README.md
@ -763,6 +763,38 @@ guarantee that your application continues to function properly in the future.
|
||||
}
|
||||
```
|
||||
|
||||
#### Note Modification ####
|
||||
|
||||
* **updateNoteFields**
|
||||
|
||||
Modify the fields of an exist note.
|
||||
|
||||
*Sample request*:
|
||||
```json
|
||||
{
|
||||
"action": "updateNoteFields",
|
||||
"version": 5,
|
||||
"params": {
|
||||
"note": {
|
||||
"id": 1514547547030,
|
||||
"fields": {
|
||||
"Front": "new front content",
|
||||
"Back": "new back content"
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Sample result*:
|
||||
```json
|
||||
{
|
||||
"result": null,
|
||||
"error": null
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Note Tags ####
|
||||
|
||||
* **addTags**
|
||||
|
Loading…
Reference in New Issue
Block a user