From ba9fa339a43a5f494785877018b10f111ccafff5 Mon Sep 17 00:00:00 2001 From: StefanVukovic99 Date: Tue, 21 May 2024 18:55:02 +0200 Subject: add support for overwriting existing card (#859) * frontend * wip * minimum viable * minor simplification * simplify gradients in duplicate svg * simplify add-duplicate svg * colors good * arrows shape * disable overwrite if no valid duplicate IDs * add warning --- ext/js/comm/anki-connect.js | 15 +++++++++++++++ ext/js/comm/api.js | 8 ++++++++ 2 files changed, 23 insertions(+) (limited to 'ext/js/comm') diff --git a/ext/js/comm/anki-connect.js b/ext/js/comm/anki-connect.js index 446b2139..8c5e2c85 100644 --- a/ext/js/comm/anki-connect.js +++ b/ext/js/comm/anki-connect.js @@ -143,6 +143,21 @@ export class AnkiConnect { return result; } + /** + * @param {import('anki').Note} noteWithId + * @returns {Promise} + */ + async updateNoteFields(noteWithId) { + if (!this._enabled) { return null; } + await this._checkVersion(); + const result = await this._invoke('updateNoteFields', {note: noteWithId}); + if (result !== null) { + throw this._createUnexpectedResultError('null', result); + } + return result; + } + + /** * @param {import('anki').Note[]} notes * @returns {Promise} diff --git a/ext/js/comm/api.js b/ext/js/comm/api.js index e8db7846..b044a783 100644 --- a/ext/js/comm/api.js +++ b/ext/js/comm/api.js @@ -95,6 +95,14 @@ export class API { return this._invoke('addAnkiNote', {note}); } + /** + * @param {import('api').ApiParam<'updateAnkiNote', 'noteWithId'>} noteWithId + * @returns {Promise>} + */ + updateAnkiNote(noteWithId) { + return this._invoke('updateAnkiNote', {noteWithId}); + } + /** * @param {import('api').ApiParam<'getAnkiNoteInfo', 'notes'>} notes * @param {import('api').ApiParam<'getAnkiNoteInfo', 'fetchAdditionalInfo'>} fetchAdditionalInfo -- cgit v1.2.3