diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-02-24 21:54:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 21:54:58 -0500 |
commit | ae92e0b3781e27d54cbac2570ba2a1b8a6b11999 (patch) | |
tree | b7d7a7171a6cbc25d5f1fc4b4996024c4f73033e /ext/js/pages | |
parent | 0a76de1b44443cc668882125d73d83d5f7ba8a63 (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/pages')
-rw-r--r-- | ext/js/pages/settings/anki-controller.js | 9 | ||||
-rw-r--r-- | ext/js/pages/settings/anki-templates-controller.js | 2 |
2 files changed, 3 insertions, 8 deletions
diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 26cab68f..509e263c 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -17,7 +17,7 @@ /* global * AnkiConnect - * AnkiNoteBuilder + * AnkiUtil * ObjectPropertyAccessor * SelectorObserver */ @@ -26,7 +26,6 @@ class AnkiController { constructor(settingsController) { this._settingsController = settingsController; this._ankiConnect = new AnkiConnect(); - this._ankiNoteBuilder = new AnkiNoteBuilder(false); this._selectorObserver = new SelectorObserver({ selector: '.anki-card', ignoreSelector: null, @@ -156,10 +155,6 @@ class AnkiController { return this._settingsController.permissionsUtil.getRequiredPermissionsForAnkiFieldValue(fieldValue); } - containsAnyMarker(field) { - return this._ankiNoteBuilder.containsAnyMarker(field); - } - // Private async _onOptionsChanged({options: {anki}}) { @@ -439,7 +434,7 @@ class AnkiCardController { _validateField(node, index) { let valid = (node.dataset.hasPermissions !== 'false'); - if (valid && index === 0 && !this._ankiController.containsAnyMarker(node.value)) { + if (valid && index === 0 && !AnkiUtil.stringContainsAnyFieldMarker(node.value)) { valid = false; } node.dataset.invalid = `${!valid}`; diff --git a/ext/js/pages/settings/anki-templates-controller.js b/ext/js/pages/settings/anki-templates-controller.js index 8e3a1a70..710946be 100644 --- a/ext/js/pages/settings/anki-templates-controller.js +++ b/ext/js/pages/settings/anki-templates-controller.js @@ -32,7 +32,7 @@ class AnkiTemplatesController { this._renderFieldInput = null; this._renderResult = null; this._fieldTemplateResetModal = null; - this._ankiNoteBuilder = new AnkiNoteBuilder(true); + this._ankiNoteBuilder = new AnkiNoteBuilder(); } async prepare() { |