From 331a2e62941e04a4d50a21faefed663a92ddc00a Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 29 May 2022 21:24:41 -0400 Subject: Add support for guiEditNote to view notes (#2143) * Add AnkiConnect.guiEditNote * Update _onApiNoteView to first try guiEditNote * Add setting * Update noteView API * Use setting * Return which mode was used * Update DisplayGenerator * Handle errors in DisplayAnki * Update docs * Add isErrorUnsupportedAction function * Add an allowFallback option to noteView * Disambiguate * Simplify now that preferredMode isn't used * Update settings info * Implement test buttons * Update styles * Update status visibility * Wrap layout * Update description * Update date --- ext/css/settings.css | 22 ++++++++++++ ext/data/schemas/options-schema.json | 8 ++++- ext/display-templates.html | 4 +++ ext/js/background/backend.js | 18 ++++++++-- ext/js/comm/anki.js | 24 +++++++++++++ ext/js/comm/api.js | 4 +-- ext/js/data/options-util.js | 12 ++++++- ext/js/display/display-anki.js | 24 ++++++++++--- ext/js/display/display-generator.js | 38 ++++++++++++--------- ext/js/pages/settings/anki-controller.js | 58 ++++++++++++++++++++++++++++++++ ext/settings.html | 33 ++++++++++++++++++ test/test-options-util.js | 5 +-- 12 files changed, 222 insertions(+), 28 deletions(-) diff --git a/ext/css/settings.css b/ext/css/settings.css index 19f587e9..62e979e0 100644 --- a/ext/css/settings.css +++ b/ext/css/settings.css @@ -2147,6 +2147,28 @@ button.hotkey-list-item-enabled-button[data-scope-count='0'] { display: none; } +.test-anki-note-viewer-container { + margin-top: 0.85em; + display: flex; + flex-flow: row wrap; + align-items: flex-start; +} +.test-anki-note-viewer-container>:nth-child(n+2) { + margin-left: 0.5em; +} +.test-anki-note-viewer-button { + flex: 0 0 auto; +} +.test-anki-note-viewer-results { + align-self: center; +} +.test-anki-note-viewer-results[data-success=true] { + color: var(--success-color); +} +.test-anki-note-viewer-results[data-success=false] { + color: var(--danger-color); +} + /* Dictionary settings */ .dictionary-list { diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json index ef86f8c3..46d8a32a 100644 --- a/ext/data/schemas/options-schema.json +++ b/ext/data/schemas/options-schema.json @@ -844,7 +844,8 @@ "checkForDuplicates", "fieldTemplates", "suspendNewCards", - "displayTags" + "displayTags", + "noteGuiMode" ], "properties": { "enable": { @@ -959,6 +960,11 @@ "type": "string", "enum": ["never", "always", "non-standard"], "default": "never" + }, + "noteGuiMode": { + "type": "string", + "enum": ["browse", "edit"], + "default": "browse" } } }, diff --git a/ext/display-templates.html b/ext/display-templates.html index 8b2e4450..8d147253 100644 --- a/ext/display-templates.html +++ b/ext/display-templates.html @@ -179,6 +179,10 @@
Log debug info to console
+