aboutsummaryrefslogtreecommitdiff
path: root/ext/js/comm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/comm')
-rw-r--r--ext/js/comm/anki.js24
-rw-r--r--ext/js/comm/api.js4
2 files changed, 26 insertions, 2 deletions
diff --git a/ext/js/comm/anki.js b/ext/js/comm/anki.js
index 7ffb747b..f5dc62f2 100644
--- a/ext/js/comm/anki.js
+++ b/ext/js/comm/anki.js
@@ -106,6 +106,15 @@ class AnkiConnect {
}
/**
+ * Opens the note editor GUI.
+ * @param {number} noteId The ID of the note.
+ * @returns {Promise<null>} Nothing is returned.
+ */
+ async guiEditNote(noteId) {
+ return await this._invoke('guiEditNote', {note: noteId});
+ }
+
+ /**
* Stores a file with the specified base64-encoded content inside Anki's media folder.
* @param {string} fileName The name of the file.
* @param {string} content The base64-encoded content of the file.
@@ -187,6 +196,21 @@ class AnkiConnect {
return actions.includes(action);
}
+ /**
+ * Checks if a specific error object corresponds to an unsupported action.
+ * @param {Error} error An error object generated by an API call.
+ * @returns {boolean} Whether or not the error indicates the action is not supported.
+ */
+ isErrorUnsupportedAction(error) {
+ if (error instanceof Error) {
+ const {data} = error;
+ if (isObject(data) && data.apiError === 'unsupported action') {
+ return true;
+ }
+ }
+ return false;
+ }
+
// Private
async _checkVersion() {
diff --git a/ext/js/comm/api.js b/ext/js/comm/api.js
index 75a01dd5..2ffe2d8c 100644
--- a/ext/js/comm/api.js
+++ b/ext/js/comm/api.js
@@ -60,8 +60,8 @@ class API {
return this._invoke('injectAnkiNoteMedia', {timestamp, definitionDetails, audioDetails, screenshotDetails, clipboardDetails, dictionaryMediaDetails});
}
- noteView(noteId) {
- return this._invoke('noteView', {noteId});
+ noteView(noteId, mode, allowFallback) {
+ return this._invoke('noteView', {noteId, mode, allowFallback});
}
suspendAnkiCardsForNote(noteId) {