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 --- types/ext/anki.d.ts | 2 ++ types/ext/api.d.ts | 6 ++++++ types/ext/display-anki.d.ts | 3 +++ types/ext/settings.d.ts | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) (limited to 'types/ext') diff --git a/types/ext/anki.d.ts b/types/ext/anki.d.ts index 4a903c52..8ad0890f 100644 --- a/types/ext/anki.d.ts +++ b/types/ext/anki.d.ts @@ -22,6 +22,8 @@ export type NoteId = number; export type CardId = number; +export type NoteWithId = Note & {id: NoteId}; + export type Note = { fields: NoteFields; tags: string[]; diff --git a/types/ext/api.d.ts b/types/ext/api.d.ts index 9a922fb0..3a2fc0b8 100644 --- a/types/ext/api.d.ts +++ b/types/ext/api.d.ts @@ -169,6 +169,12 @@ type ApiSurface = { }; return: Anki.NoteId | null; }; + updateAnkiNote: { + params: { + noteWithId: Anki.NoteWithId; + }; + return: null; + }; getAnkiNoteInfo: { params: { notes: Anki.Note[]; diff --git a/types/ext/display-anki.d.ts b/types/ext/display-anki.d.ts index 1b0dd4ff..4b6c6e37 100644 --- a/types/ext/display-anki.d.ts +++ b/types/ext/display-anki.d.ts @@ -46,6 +46,9 @@ export type DictionaryEntryModeDetails = { requirements: AnkiNoteBuilder.Requirement[]; canAdd: boolean; valid: boolean; + /** + * Anki IDs of duplicate notes. May contain INVALID_NOTE_ID for notes whose ID could not be found. + */ noteIds: Anki.NoteId[] | null; noteInfos?: (Anki.NoteInfo | null)[]; ankiError: Error | null; diff --git a/types/ext/settings.d.ts b/types/ext/settings.d.ts index 1fce0f59..48a66728 100644 --- a/types/ext/settings.d.ts +++ b/types/ext/settings.d.ts @@ -395,7 +395,7 @@ export type AnkiScreenshotFormat = 'png' | 'jpeg'; export type AnkiDuplicateScope = 'collection' | 'deck' | 'deck-root'; -export type AnkiDuplicateBehavior = 'prevent' | 'new'; +export type AnkiDuplicateBehavior = 'prevent' | 'overwrite' | 'new'; export type AnkiDisplayTags = 'never' | 'always' | 'non-standard'; -- cgit v1.2.3