aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-09-26 13:45:48 -0400
committerGitHub <noreply@github.com>2020-09-26 13:45:48 -0400
commitcab5daa22e986fdf0c71a370ebd459efa0a13a61 (patch)
tree1c6b4cbeb783e528e3190bcd4d52b5b6b2e9be72 /ext/bg/js/backend.js
parentd27349207dc493e6d1e035c2c5606943c990f02f (diff)
Add clipboard-text Anki field (#863)
* Add clipboard-text anki field * Add markers * Update clipboard injection
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) {