From 486eec15b817d6a87ad98245dea3534545286334 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Sat, 11 May 2024 23:03:27 -0400 Subject: Add option to bulk generate anki cards (#895) * Add option to bulk generate anki cards * Fix tab replacement * Set deckname and modelname in note builder * Add addNotes to ankiconnect api implementation * Add option to send word list to anki directly * Add support for audio and media toggle * Add support for dictionary media * Remove unnecessary assignment * Remove unused css * Remove redundant html * Start of progress bar implementation * Remove redundant type annotation * Remove unused import * Rename words to terms * Print progress to console * Add confirmation to Export to file * Improve progress logs * Add unresponsive and console note * Add progress bars * Make cancel button actually cancel operation * Remove unresponsive warnings * Disable send and export buttons after they are clicked * Remove unneeded Yomichan mention * Mark as experimental * Clarify description * Add documentation on Anki Deck Generation * Add experimental note in docs * Add warning text to settings page * Switch example text based on language * Remove silly cancel function and bind directly * Rename to model * Add link to docs * Make test text less confusing * Rename deck to notes * Clarify what is being sent to anki * Fix incorrect modal header text * Clarify wording * Fix ankiconnect addNotes return types * Add error handling to send to anki * Fix wording and naming in docs * Add option to prevent sending duplicates to anki * Update anki deck and model without a page refresh * Cleanup internal html naming * Cleanup type definition styling * Update example text without a page refresh * Prevent closing the send/export confirm modal from messing up the ui and not allowing the user to see the current progress * Fix cancel getting stuck on true * Consolidate state changes * Support idle download timeout * Capitalize Failed to add cards error * Add separate variable for idleTimeout calculation * Remove redundant _cachedDictionaryEntryValue variable * Use tags option to populate tags * Include deck and tags when exporting to file * Use date down to seconds and zero pad * Remove unnecessary ternary * Limit 'path' finding function to only being able to search for 'path' * Rename _findPathsByKey to _findAllPaths --- ext/js/comm/anki-connect.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ext/js/comm') diff --git a/ext/js/comm/anki-connect.js b/ext/js/comm/anki-connect.js index 23183e79..446b2139 100644 --- a/ext/js/comm/anki-connect.js +++ b/ext/js/comm/anki-connect.js @@ -129,6 +129,19 @@ export class AnkiConnect { return result; } + /** + * @param {import('anki').Note[]} notes + * @returns {Promise} + */ + async addNotes(notes) { + if (!this._enabled) { return null; } + await this._checkVersion(); + const result = await this._invoke('addNotes', {notes}); + if (result !== null && !Array.isArray(result)) { + throw this._createUnexpectedResultError('(number | null)[] | null', result); + } + return result; + } /** * @param {import('anki').Note[]} notes -- cgit v1.2.3