summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings
diff options
context:
space:
mode:
authorStefanVukovic99 <stefanvukovic44@gmail.com>2024-06-20 19:27:02 +0200
committerGitHub <noreply@github.com>2024-06-20 17:27:02 +0000
commitd2c930a94d6e445053bcb5e5bb629851165425fc (patch)
tree94ff7034e7d3ab36ed663f353aeb5486bd294d1c /ext/js/pages/settings
parent1a866b3997310a04fc146b91eb47a59a3f049589 (diff)
support css file in dictionaries (#1080)
* get styles in db * get styles in settings * use styles * fix test * scope * fix comma separated * escape dict name in css selector * g regex * get styles in anki * fix tests * more specificity * whitespace * test importing * test handlebars * add styles to glossary-first
Diffstat (limited to 'ext/js/pages/settings')
-rw-r--r--ext/js/pages/settings/dictionary-controller.js6
-rw-r--r--ext/js/pages/settings/dictionary-import-controller.js10
2 files changed, 9 insertions, 7 deletions
diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js
index e7a9444f..5c0e49d4 100644
--- a/ext/js/pages/settings/dictionary-controller.js
+++ b/ext/js/pages/settings/dictionary-controller.js
@@ -519,9 +519,10 @@ export class DictionaryController {
/**
* @param {string} name
* @param {boolean} enabled
+ * @param {string} styles
* @returns {import('settings').DictionaryOptions}
*/
- static createDefaultDictionarySettings(name, enabled) {
+ static createDefaultDictionarySettings(name, enabled, styles) {
return {
name,
priority: 0,
@@ -530,6 +531,7 @@ export class DictionaryController {
definitionsCollapsible: 'not-collapsible',
partsOfSpeechFilter: true,
useDeinflections: true,
+ styles: styles ?? '',
};
}
@@ -572,7 +574,7 @@ export class DictionaryController {
}
for (const name of missingDictionaries) {
- const value = DictionaryController.createDefaultDictionarySettings(name, newDictionariesEnabled);
+ const value = DictionaryController.createDefaultDictionarySettings(name, newDictionariesEnabled, '');
dictionaryOptionsArray.push(value);
modified = true;
}
diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js
index c721a9dd..d7bb5d30 100644
--- a/ext/js/pages/settings/dictionary-import-controller.js
+++ b/ext/js/pages/settings/dictionary-import-controller.js
@@ -402,7 +402,7 @@ export class DictionaryImportController {
return errors;
}
- const errors2 = await this._addDictionarySettings(result.sequenced, result.title);
+ const errors2 = await this._addDictionarySettings(result);
await this._settingsController.application.api.triggerDatabaseUpdated('dictionary', 'import');
@@ -415,11 +415,11 @@ export class DictionaryImportController {
}
/**
- * @param {boolean} sequenced
- * @param {string} title
+ * @param {import('dictionary-importer').Summary} summary
* @returns {Promise<Error[]>}
*/
- async _addDictionarySettings(sequenced, title) {
+ async _addDictionarySettings(summary) {
+ const {title, sequenced, styles} = summary;
let optionsFull;
// Workaround Firefox bug sometimes causing getOptionsFull to fail
for (let i = 0, success = false; (i < 10) && (success === false); i++) {
@@ -439,7 +439,7 @@ export class DictionaryImportController {
for (let i = 0; i < profileCount; ++i) {
const {options} = optionsFull.profiles[i];
const enabled = profileIndex === i;
- const value = DictionaryController.createDefaultDictionarySettings(title, enabled);
+ const value = DictionaryController.createDefaultDictionarySettings(title, enabled, styles);
const path1 = `profiles[${i}].options.dictionaries`;
targets.push({action: 'push', path: path1, items: [value]});