aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-24 21:54:58 -0500
committerGitHub <noreply@github.com>2021-02-24 21:54:58 -0500
commitae92e0b3781e27d54cbac2570ba2a1b8a6b11999 (patch)
treeb7d7a7171a6cbc25d5f1fc4b4996024c4f73033e /ext/js/display/display.js
parent0a76de1b44443cc668882125d73d83d5f7ba8a63 (diff)
AnkiUtil (#1439)
* Add AnkiUtil * Update AnkiConnect to use AnkiUtil * Use AnkiUtil in AnkiNoteBuilder * Replace containsAnyMarker with AnkiUtil.stringContainsAnyFieldMarker * Add AnkiUtil.getFieldMarkers * Add fieldsObjectContainsMarker to AnkiUtil * Remove unused global * Remove unused parameter: enabled * Add cloneFieldMarkerPattern
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r--ext/js/display/display.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 517b391d..0e029748 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -17,6 +17,7 @@
/* global
* AnkiNoteBuilder
+ * AnkiUtil
* DisplayAudio
* DisplayGenerator
* DisplayHistory
@@ -85,7 +86,7 @@ class Display extends EventDispatcher {
});
this._ankiFieldTemplates = null;
this._ankiFieldTemplatesDefault = null;
- this._ankiNoteBuilder = new AnkiNoteBuilder(true);
+ this._ankiNoteBuilder = new AnkiNoteBuilder();
this._updateAdderButtonsPromise = Promise.resolve();
this._contentScrollElement = document.querySelector('#content-scroll');
this._contentScrollBodyElement = document.querySelector('#content-body');
@@ -1493,7 +1494,7 @@ class Display extends EventDispatcher {
const definitionDetails = this._getDefinitionDetailsForNote(definition);
let audioDetails = null;
- if (definitionDetails.type !== 'kanji' && this._ankiNoteBuilder.containsMarker(fields, 'audio')) {
+ if (definitionDetails.type !== 'kanji' && AnkiUtil.fieldsObjectContainsMarker(fields, 'audio')) {
const primaryCardAudio = this._displayAudio.getPrimaryCardAudio(definitionDetails.expression, definitionDetails.reading);
let preferredAudioIndex = null;
let sources2 = sources;
@@ -1504,11 +1505,11 @@ class Display extends EventDispatcher {
audioDetails = {sources: sources2, preferredAudioIndex, customSourceUrl, customSourceType};
}
- const screenshotDetails = (this._ankiNoteBuilder.containsMarker(fields, 'screenshot') ? {tabId: this._contentOriginTabId, frameId: this._contentOriginFrameId, format, quality} : null);
+ const screenshotDetails = (AnkiUtil.fieldsObjectContainsMarker(fields, 'screenshot') ? {tabId: this._contentOriginTabId, frameId: this._contentOriginFrameId, format, quality} : null);
const clipboardDetails = {
- image: this._ankiNoteBuilder.containsMarker(fields, 'clipboard-image'),
- text: this._ankiNoteBuilder.containsMarker(fields, 'clipboard-text')
+ image: AnkiUtil.fieldsObjectContainsMarker(fields, 'clipboard-image'),
+ text: AnkiUtil.fieldsObjectContainsMarker(fields, 'clipboard-text')
};
return await yomichan.api.injectAnkiNoteMedia(