summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 2a90e8e1..d071a857 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -452,7 +452,7 @@ class Backend {
return results;
}
- async _onApiInjectAnkiNoteMedia({expression, reading, timestamp, audioDetails, screenshotDetails, clipboardImage}, sender) {
+ async _onApiInjectAnkiNoteMedia({expression, reading, timestamp, audioDetails, screenshotDetails, clipboardDetails}, sender) {
if (isObject(screenshotDetails)) {
const {id: tabId, windowId} = (sender && sender.tab ? sender.tab : {});
screenshotDetails = Object.assign({}, screenshotDetails, {tabId, windowId});
@@ -464,7 +464,7 @@ class Backend {
timestamp,
audioDetails,
screenshotDetails,
- clipboardImage
+ clipboardDetails
);
}
@@ -1512,23 +1512,31 @@ class Backend {
return await this._audioDownloader.downloadAudio(sources, expression, reading, details);
}
- async _injectAnkNoteMedia(ankiConnect, expression, reading, timestamp, audioDetails, screenshotDetails, clipboardImage) {
+ async _injectAnkNoteMedia(ankiConnect, expression, reading, timestamp, audioDetails, screenshotDetails, clipboardDetails) {
const screenshotFileName = (
screenshotDetails !== null ?
await this._injectAnkNoteScreenshot(ankiConnect, expression, reading, timestamp, screenshotDetails) :
null
);
const clipboardImageFileName = (
- clipboardImage ?
+ clipboardDetails !== null && clipboardDetails.image ?
await this._injectAnkNoteClipboardImage(ankiConnect, expression, reading, timestamp) :
null
);
+ let clipboardText = null;
+ try {
+ if (clipboardDetails !== null && clipboardDetails.text) {
+ clipboardText = await this._clipboardReader.getText();
+ }
+ } catch (e) {
+ // NOP
+ }
const audioFileName = (
audioDetails !== null ?
await this._injectAnkNoteAudio(ankiConnect, expression, reading, timestamp, audioDetails) :
null
);
- return {screenshotFileName, clipboardImageFileName, audioFileName};
+ return {screenshotFileName, clipboardImageFileName, clipboardText, audioFileName};
}
async _injectAnkNoteAudio(ankiConnect, expression, reading, timestamp, details) {