diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-10-30 17:41:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-30 17:41:52 -0400 |
commit | 327d7b1f26d8553809292e159b97d44bc77b7b8e (patch) | |
tree | 175d18d86fc09e97cef6dba68ed62331467ca934 /ext/bg/js/settings/anki-controller.js | |
parent | cb76848df980b4245e9f5c0dee4eec4280ed645d (diff) |
Anki templates refactor (#970)
* Support menus with multiple sources
* Update anki templates controller
Diffstat (limited to 'ext/bg/js/settings/anki-controller.js')
-rw-r--r-- | ext/bg/js/settings/anki-controller.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/bg/js/settings/anki-controller.js b/ext/bg/js/settings/anki-controller.js index 6988e4b8..c205c160 100644 --- a/ext/bg/js/settings/anki-controller.js +++ b/ext/bg/js/settings/anki-controller.js @@ -214,14 +214,20 @@ class AnkiController { _setupFieldMenus() { const fieldMenuTargets = [ - ['terms', '#anki-card-terms-field-menu-template'], - ['kanji', '#anki-card-kanji-field-menu-template'] + [['terms'], '#anki-card-terms-field-menu-template'], + [['kanji'], '#anki-card-kanji-field-menu-template'], + [['terms', 'kanji'], '#anki-card-all-field-menu-template'] ]; - for (const [type, selector] of fieldMenuTargets) { + for (const [types, selector] of fieldMenuTargets) { const element = document.querySelector(selector); if (element === null) { continue; } - const markers = this.getFieldMarkers(type); + let markers = []; + for (const type of types) { + markers.push(...this.getFieldMarkers(type)); + } + markers = [...new Set(markers)]; + const container = element.content.querySelector('.popup-menu'); if (container === null) { return; } |