aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js44
1 files changed, 3 insertions, 41 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 2bb85f1f..70b3895a 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -1047,18 +1047,10 @@ class Display extends EventDispatcher {
try {
this.setSpinnerVisible(true);
- const details = {};
- if (this._noteUsesScreenshot(mode)) {
- try {
- const screenshot = await this._getScreenshot();
- details.screenshot = screenshot;
- } catch (e) {
- // NOP
- }
- }
-
+ const ownerFrameId = this._ownerFrameId;
+ const optionsContext = this.getOptionsContext();
const noteContext = await this._getNoteContext();
- const noteId = await api.definitionAdd(definition, mode, noteContext, details, this.getOptionsContext());
+ const noteId = await api.definitionAdd(definition, mode, noteContext, ownerFrameId, optionsContext);
if (noteId) {
const index = this._definitions.indexOf(definition);
const adderButton = this._adderButtonFind(index, mode);
@@ -1136,36 +1128,6 @@ class Display extends EventDispatcher {
}
}
- _noteUsesScreenshot(mode) {
- const optionsAnki = this._options.anki;
- const fields = (mode === 'kanji' ? optionsAnki.kanji : optionsAnki.terms).fields;
- for (const fieldValue of Object.values(fields)) {
- if (fieldValue.includes('{screenshot}')) {
- return true;
- }
- }
- return false;
- }
-
- async _getScreenshot() {
- const ownerFrameId = this._ownerFrameId;
- let token = null;
- try {
- if (ownerFrameId !== null) {
- token = await api.crossFrame.invoke(ownerFrameId, 'setAllVisibleOverride', {value: false, priority: 0, awaitFrame: true});
- }
-
- const {format, quality} = this._options.anki.screenshot;
- const dataUrl = await api.screenshotGet({format, quality});
-
- return {dataUrl, format};
- } finally {
- if (token !== null) {
- await api.crossFrame.invoke(ownerFrameId, 'clearAllVisibleOverride', {token});
- }
- }
- }
-
_getFirstExpressionIndex() {
return this._options.general.resultOutputMode === 'merge' ? 0 : -1;
}