From 3dec603fe37bbe234dfefb6070219cb8e5a82cc9 Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Sun, 14 Jan 2024 13:19:10 +1100 Subject: [PATCH 1/8] Partial implementation --- src/gui/Tabs.ts | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ src/settings.ts | 108 +++++++++++++++++++++++++++++-- 2 files changed, 270 insertions(+), 7 deletions(-) create mode 100644 src/gui/Tabs.ts diff --git a/src/gui/Tabs.ts b/src/gui/Tabs.ts new file mode 100644 index 00000000..2747f3b3 --- /dev/null +++ b/src/gui/Tabs.ts @@ -0,0 +1,169 @@ +/* + * 'Shell commands' plugin for Obsidian. + * Copyright (C) 2021 - 2023 Jarkko Linnanvirta + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3.0 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Contact the author (Jarkko Linnanvirta): https://github.com/Taitava/ + */ + +import {setIcon} from "obsidian"; + +export interface Tab { + title: string; + icon: string; + content_generator: (container_element: HTMLElement) => Promise; +} + +export interface TabStructure { + header: HTMLElement, + active_tab_id: string, + buttons: { + [key: string]: HTMLElement, + } + contentContainers: { + [key: string]: HTMLElement, + }, + contentGeneratorPromises: { + [key: string]: Promise, + } +} + +export interface Tabs { + [key: string]: Tab; +} + +interface TabContentContainers { + [key: string]: HTMLElement, +} + +interface TabButtons { + [key: string]: HTMLElement, +} + +export function createTabs(container_element: HTMLElement, tabs: Tabs, activateTabId: string): TabStructure { + const tab_header = container_element.createEl("div", {attr: {class: "SC-tab-header"}}); + const tab_content_containers: TabContentContainers = {}; + const tab_buttons: TabButtons = {}; + const tab_structure: TabStructure = { + header: tab_header, + active_tab_id: Object.keys(tabs)[0] as string, // Indicate that the first tab is active. This does not affect what tab is active in practise, it just reports the active tab. + buttons: tab_buttons, + contentContainers: tab_content_containers, + contentGeneratorPromises: {}, + }; + let first_button: HTMLElement | undefined; + for (const tab_id in tabs) { + const tab = tabs[tab_id]; + + // Create button + const button = tab_header.createEl("button", { + attr: { + class: "SC-tab-header-button", + activateTab: "SC-tab-" + tab_id, + }, + }); + button.onclick = function (event: MouseEvent) { + const tab_button = this as HTMLElement; // Use 'this' instead of event.target because this way we'll always get a button element, not an element inside the button (i.e. an icon). + + // Hide all tab contents and get the max dimensions + let max_width = 0; + let max_height = 0; + const tab_header = tab_button.parentElement; + if (null === tab_header) { + throw new Error("Tab header is missing. Did not get a parent from tab button."); + } + const container_element = tab_header.parentElement; + if (null === container_element) { + throw new Error("Container element is missing. Did not get a parent from tab header."); + } + const tab_contents = container_element.findAll("div.SC-tab-content"); // Do not get all tab contents that exist, because there might be multiple tab systems open at the same time. + const is_main_settings_modal = container_element.hasClass("vertical-tab-content"); + for (const index in tab_contents) { + const tab_content = tab_contents[index]; + + // Get the maximum tab dimensions so that all tabs can have the same dimensions. + // But don't do it if this is the main settings modal + if (!is_main_settings_modal) { + tab_content.addClass("SC-tab-active"); // Need to make the tab visible temporarily in order to get the dimensions. + if (tab_content.offsetHeight > max_height) { + max_height = tab_content.offsetHeight; + } + if (tab_content.offsetWidth > max_width) { + max_width = tab_content.offsetWidth; + } + } + + // Finally hide the tab + tab_content.removeClass("SC-tab-active"); + } + + // Remove active status from all buttons + const adjacent_tab_buttons = tab_header.findAll(".SC-tab-header-button"); // Do not get all tab buttons that exist, because there might be multiple tab systems open at the same time. + for (const index in adjacent_tab_buttons) { + const tab_button = adjacent_tab_buttons[index]; + tab_button.removeClass("SC-tab-active"); + } + + // Activate the clicked tab + tab_button.addClass("SC-tab-active"); + const activateTabAttribute: Attr | null = tab_button.attributes.getNamedItem("activateTab"); + if (null === activateTabAttribute) { + throw new Error("Tab button has no 'activateTab' HTML attribute! Murr!"); + } + const activate_tab_id = activateTabAttribute.value; + const tab_content: HTMLElement | null = document.getElementById(activate_tab_id); + if (null === tab_content) { + throw new Error("No tab content was found with activate_tab_id '"+activate_tab_id+"'! Hmph!"); + } + tab_content.addClass("SC-tab-active"); + + // Mark the clicked tab as active in TabStructure (just to report which tab is currently active) + tab_structure.active_tab_id = activate_tab_id.replace(/^SC-tab-/, ""); // Remove "SC-tab" prefix. + + // Focus an element (if a focusable element is present) + tab_content.find(".SC-focus-element-on-tab-opening")?.focus(); // ? = If not found, do nothing. + + // Apply the max dimensions to this tab + // But don't do it if this is the main settings modal + if (!is_main_settings_modal) { + tab_content.style.width = max_width + "px"; + tab_content.style.height = max_height + "px"; + } + + // Do nothing else (I don't know if this is needed or not) + event.preventDefault(); + }; + setIcon(button, tab.icon); + button.insertAdjacentText("beforeend", " " + tab.title); + tab_buttons[tab_id] = button; + + // Create content container + tab_content_containers[tab_id] = container_element.createEl("div", {attr: {class: "SC-tab-content", id: "SC-tab-" + tab_id}}); + + // Generate content + tab_structure.contentGeneratorPromises[tab_id] = tab.content_generator(tab_content_containers[tab_id]); + + // Memorize the first tab's button + if (undefined === first_button) { + first_button = button; + } + } + + // Open a tab. + tab_buttons[activateTabId].click(); + + // Return the TabStructure + return tab_structure; +} + diff --git a/src/settings.ts b/src/settings.ts index d5bcfe84..4850b50f 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,6 +1,7 @@ import { Notice, PluginSettingTab, Setting, App, Platform } from "obsidian"; import type SRPlugin from "src/main"; import { t } from "src/lang/helpers"; +import { TabStructure, createTabs } from "./gui/Tabs"; export interface SRSettings { // flashcards @@ -115,6 +116,7 @@ function applySettingsUpdate(callback: () => void): void { export class SRSettingTab extends PluginSettingTab { private plugin: SRPlugin; + private tab_structure: TabStructure; constructor(app: App, plugin: SRPlugin) { super(app, plugin); @@ -129,10 +131,62 @@ export class SRSettingTab extends PluginSettingTab { const header = containerEl.createEl("h1", { text: `${t("SETTINGS_HEADER")}` }); header.addClass("sr-centered"); + this.tab_structure = createTabs( + containerEl, + { + "main-main": { + title: "General", + icon: "run-command", + content_generator: (container_element: HTMLElement) => this.tabMain(container_element), + }, + "main-flashcards": { + title: t("FLASHCARDS"), + icon: "stacked-levels", + content_generator: (container_element: HTMLElement) => this.tabFlashcards(container_element), + }, + "main-notes": { + title: t("NOTES"), + icon: "note-glyph", + content_generator: (container_element: HTMLElement) => this.tabNotes(container_element), + }, + "main-ui-preferences": { + title: t("UI_PREFERENCES"), + icon: "lines-of-text", + content_generator: (container_element: HTMLElement) => this.tabUiPreferences(container_element), + }, + "main-developer": { + title: "Developer", + icon: "dice", + content_generator: (container_element: HTMLElement) => this.tabDeveloper(container_element), + }, + }, + this.last_position.tab_name, + ); + + containerEl.createEl("hr"); containerEl.createDiv().innerHTML = t("CHECK_WIKI", { wiki_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", }); + // Documentation link & GitHub links + containerEl.createEl("hr").insertAdjacentHTML("beforeend"); + + // Copyright notice + const copyright_paragraph = containerEl.createEl("p"); + copyright_paragraph.addClass("SC-small-font"); + copyright_paragraph.insertAdjacentHTML("beforeend", ` + Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. + `); + + // KEEP THIS AFTER CREATING ALL ELEMENTS: + // Scroll to the position when the settings modal was last open, but do it after content generating has finished. + // In practise, shell command previews may take some time to appear. + this.tab_structure.contentGeneratorPromises[this.tab_structure.active_tab_id].then(() => { + this.rememberLastPosition(containerEl); + }); + } + + private async tabMain(containerEl: HTMLElement): Promise { new Setting(containerEl) .setName(t("FOLDERS_TO_IGNORE")) .setDesc(t("FOLDERS_TO_IGNORE_DESC")) @@ -149,8 +203,9 @@ export class SRSettingTab extends PluginSettingTab { }); }), ); + } - containerEl.createEl("h3", { text: `${t("FLASHCARDS")}` }); + private async tabFlashcards(containerEl: HTMLElement): Promise { new Setting(containerEl) .setName(t("FLASHCARD_TAGS")) @@ -264,7 +319,7 @@ export class SRSettingTab extends PluginSettingTab { }); }); - new Setting(this.containerEl) + new Setting(containerEl) .setName(t("REVIEW_CARD_ORDER_WITHIN_DECK")) .addDropdown((dropdown) => dropdown @@ -287,7 +342,7 @@ export class SRSettingTab extends PluginSettingTab { const deckOrderEnabled: boolean = this.plugin.data.settings.flashcardCardOrder != "EveryCardRandomDeckAndCard"; - new Setting(this.containerEl).setName(t("REVIEW_DECK_ORDER")).addDropdown((dropdown) => + new Setting(containerEl).setName(t("REVIEW_DECK_ORDER")).addDropdown((dropdown) => dropdown .addOptions( deckOrderEnabled @@ -514,8 +569,9 @@ export class SRSettingTab extends PluginSettingTab { this.display(); }); }); + } - containerEl.createEl("h3", { text: `${t("NOTES")}` }); + private async tabNotes(containerEl: HTMLElement): Promise { new Setting(containerEl).setName(t("REVIEW_PANE_ON_STARTUP")).addToggle((toggle) => toggle @@ -607,8 +663,9 @@ export class SRSettingTab extends PluginSettingTab { this.display(); }); }); + } - containerEl.createEl("h3", { text: `${t("UI_PREFERENCES")}` }); + private async tabUiPreferences(containerEl: HTMLElement): Promise { new Setting(containerEl) .setName(t("INITIALLY_EXPAND_SUBDECKS_IN_TREE")) @@ -621,8 +678,10 @@ export class SRSettingTab extends PluginSettingTab { await this.plugin.savePluginData(); }), ); + } + + private async tabAlgorithm(containerEl: HTMLElement): Promise { - containerEl.createEl("h3", { text: `${t("ALGORITHM")}` }); containerEl.createDiv().innerHTML = t("CHECK_ALGORITHM_WIKI", { algo_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/algorithms/", }); @@ -783,8 +842,10 @@ export class SRSettingTab extends PluginSettingTab { this.display(); }); }); + } + + private async tabDeveloper(containerEl: HTMLElement): Promise { - containerEl.createEl("h3", { text: `${t("LOGGING")}` }); new Setting(containerEl).setName(t("DISPLAY_DEBUG_INFO")).addToggle((toggle) => toggle.setValue(this.plugin.data.settings.showDebugMessages).onChange(async (value) => { this.plugin.data.settings.showDebugMessages = value; @@ -792,4 +853,37 @@ export class SRSettingTab extends PluginSettingTab { }), ); } + + private last_position: { + scroll_position: number; + tab_name: string; + } = { + scroll_position: 0, + tab_name: "main-shell-commands", + }; + private rememberLastPosition(container_element: HTMLElement) { + const last_position = this.last_position; + + // Go to last position now + this.tab_structure.buttons[last_position.tab_name].click(); + // window.setTimeout(() => { // Need to delay the scrolling a bit. Without this, something else would override scrolling and scroll back to 0. + container_element.scrollTo({ + top: this.last_position.scroll_position, + behavior: "auto", + }); + // }, 0); // 'timeout' can be 0 ms, no need to wait any longer. + // I guess there's no need for setTimeout() anymore, as rememberLastPosition() is now called after waiting for asynchronous tab content generating is finished. + // TODO: Remove the commented code after a while. + + // Listen to changes + container_element.addEventListener("scroll", (event) => { + this.last_position.scroll_position = container_element.scrollTop; + }); + for (const tab_name in this.tab_structure.buttons) { + const button = this.tab_structure.buttons[tab_name]; + button.onClickEvent((event: MouseEvent) => { + last_position.tab_name = tab_name; + }); + } + } } From 027f82a1ff8b93081bb5bed4753cb60a96927757 Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Wed, 17 Jan 2024 22:08:07 +1100 Subject: [PATCH 2/8] Progressed implementation --- src/gui/Tabs.ts | 4 +- src/lang/locale/en.ts | 6 + src/settings.ts | 747 ++++++++++++++++++++++-------------------- 3 files changed, 407 insertions(+), 350 deletions(-) diff --git a/src/gui/Tabs.ts b/src/gui/Tabs.ts index 2747f3b3..62829afa 100644 --- a/src/gui/Tabs.ts +++ b/src/gui/Tabs.ts @@ -144,7 +144,9 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT // Do nothing else (I don't know if this is needed or not) event.preventDefault(); }; - setIcon(button, tab.icon); + if (tab.icon) + setIcon(button, tab.icon); + button.insertAdjacentText("beforeend", " " + tab.title); tab_buttons[tab_id] = button; diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 4a5e76ad..0eded17a 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -55,6 +55,12 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition Plugin - Settings", CHECK_WIKI: 'For more information, check the wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Folders to ignore", FOLDERS_TO_IGNORE_DESC: "Enter folder paths separated by newlines i.e. Templates Meta/Scripts", FLASHCARDS: "Flashcards", diff --git a/src/settings.ts b/src/settings.ts index 4850b50f..7223485e 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -134,50 +134,45 @@ export class SRSettingTab extends PluginSettingTab { this.tab_structure = createTabs( containerEl, { - "main-main": { - title: "General", - icon: "run-command", - content_generator: (container_element: HTMLElement) => this.tabMain(container_element), - }, "main-flashcards": { title: t("FLASHCARDS"), - icon: "stacked-levels", + icon: null, // "SpacedRepIcon", content_generator: (container_element: HTMLElement) => this.tabFlashcards(container_element), }, "main-notes": { title: t("NOTES"), - icon: "note-glyph", + icon: null, // "note-glyph", content_generator: (container_element: HTMLElement) => this.tabNotes(container_element), }, + "main-algorithm": { + title: "Algorithm", + icon: null, // "dot-network", + content_generator: (container_element: HTMLElement) => this.tabAlgorithm(container_element), + }, + "main-advanced": { + title: "Advanced", + icon: null, // "vertical-three-dots", + content_generator: (container_element: HTMLElement) => this.tabAdvanced(container_element), + }, "main-ui-preferences": { title: t("UI_PREFERENCES"), - icon: "lines-of-text", + icon: null, // "presentation", content_generator: (container_element: HTMLElement) => this.tabUiPreferences(container_element), }, "main-developer": { title: "Developer", - icon: "dice", + icon: null, // "code-glyph", content_generator: (container_element: HTMLElement) => this.tabDeveloper(container_element), }, + "main-help": { + title: "Help", + icon: null, // "help", + content_generator: (container_element: HTMLElement) => this.tabHelp(container_element), + }, }, this.last_position.tab_name, ); - containerEl.createEl("hr"); - containerEl.createDiv().innerHTML = t("CHECK_WIKI", { - wiki_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", - }); - - // Documentation link & GitHub links - containerEl.createEl("hr").insertAdjacentHTML("beforeend"); - - // Copyright notice - const copyright_paragraph = containerEl.createEl("p"); - copyright_paragraph.addClass("SC-small-font"); - copyright_paragraph.insertAdjacentHTML("beforeend", ` - Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. - `); - // KEEP THIS AFTER CREATING ALL ELEMENTS: // Scroll to the position when the settings modal was last open, but do it after content generating has finished. // In practise, shell command previews may take some time to appear. @@ -186,7 +181,8 @@ export class SRSettingTab extends PluginSettingTab { }); } - private async tabMain(containerEl: HTMLElement): Promise { + private async tabAdvanced(containerEl: HTMLElement): Promise { + containerEl.createEl("br"); new Setting(containerEl) .setName(t("FOLDERS_TO_IGNORE")) .setDesc(t("FOLDERS_TO_IGNORE_DESC")) @@ -207,7 +203,9 @@ export class SRSettingTab extends PluginSettingTab { private async tabFlashcards(containerEl: HTMLElement): Promise { - new Setting(containerEl) + containerEl.createEl("h3", { text: `Tags & Folders` }); + { + new Setting(containerEl) .setName(t("FLASHCARD_TAGS")) .setDesc(t("FLASHCARD_TAGS_DESC")) .addTextArea((text) => @@ -221,358 +219,238 @@ export class SRSettingTab extends PluginSettingTab { }), ); - new Setting(containerEl) - .setName(t("CONVERT_FOLDERS_TO_DECKS")) - .setDesc(t("CONVERT_FOLDERS_TO_DECKS_DESC")) - .addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.convertFoldersToDecks) - .onChange(async (value) => { - this.plugin.data.settings.convertFoldersToDecks = value; - await this.plugin.savePluginData(); - }), + new Setting(containerEl) + .setName(t("CONVERT_FOLDERS_TO_DECKS")) + .setDesc(t("CONVERT_FOLDERS_TO_DECKS_DESC")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.convertFoldersToDecks) + .onChange(async (value) => { + this.plugin.data.settings.convertFoldersToDecks = value; + await this.plugin.savePluginData(); + }), ); + } + + containerEl.createEl("h3", { text: `Flashcard Review` }); + { + new Setting(containerEl) + .setName(t("BURY_SIBLINGS_TILL_NEXT_DAY")) + .setDesc(t("BURY_SIBLINGS_TILL_NEXT_DAY_DESC")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.burySiblingCards) + .onChange(async (value) => { + this.plugin.data.settings.burySiblingCards = value; + await this.plugin.savePluginData(); + }), + ); + + new Setting(containerEl) + .setName(t("REVIEW_CARD_ORDER_WITHIN_DECK")) + .addDropdown((dropdown) => + dropdown + .addOptions({ + NewFirstSequential: t("REVIEW_CARD_ORDER_NEW_FIRST_SEQUENTIAL"), + DueFirstSequential: t("REVIEW_CARD_ORDER_DUE_FIRST_SEQUENTIAL"), + NewFirstRandom: t("REVIEW_CARD_ORDER_NEW_FIRST_RANDOM"), + DueFirstRandom: t("REVIEW_CARD_ORDER_DUE_FIRST_RANDOM"), + EveryCardRandomDeckAndCard: t("REVIEW_CARD_ORDER_RANDOM_DECK_AND_CARD"), + }) + .setValue(this.plugin.data.settings.flashcardCardOrder) + .onChange(async (value) => { + this.plugin.data.settings.flashcardCardOrder = value; + await this.plugin.savePluginData(); - new Setting(containerEl) - .setName(t("INLINE_SCHEDULING_COMMENTS")) - .setDesc(t("INLINE_SCHEDULING_COMMENTS_DESC")) - .addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.cardCommentOnSameLine) - .onChange(async (value) => { - this.plugin.data.settings.cardCommentOnSameLine = value; - await this.plugin.savePluginData(); - }), - ); + // Need to redisplay as changing this setting affects the "deck order" setting + this.display(); + }), + ); - new Setting(containerEl) - .setName(t("BURY_SIBLINGS_TILL_NEXT_DAY")) - .setDesc(t("BURY_SIBLINGS_TILL_NEXT_DAY_DESC")) - .addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.burySiblingCards) + const deckOrderEnabled: boolean = + this.plugin.data.settings.flashcardCardOrder != "EveryCardRandomDeckAndCard"; + new Setting(containerEl).setName(t("REVIEW_DECK_ORDER")).addDropdown((dropdown) => + dropdown + .addOptions( + deckOrderEnabled + ? { + PrevDeckComplete_Sequential: t( + "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_SEQUENTIAL", + ), + PrevDeckComplete_Random: t( + "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_RANDOM", + ), + } + : { + EveryCardRandomDeckAndCard: t( + "REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD", + ), + }, + ) + .setValue( + deckOrderEnabled + ? this.plugin.data.settings.flashcardDeckOrder + : "EveryCardRandomDeckAndCard", + ) + .setDisabled(!deckOrderEnabled) .onChange(async (value) => { - this.plugin.data.settings.burySiblingCards = value; + this.plugin.data.settings.flashcardDeckOrder = value; await this.plugin.savePluginData(); }), ); + } - new Setting(containerEl) - .setName(t("SHOW_CARD_CONTEXT")) - .setDesc(t("SHOW_CARD_CONTEXT_DESC")) - .addToggle((toggle) => + containerEl.createEl("h3", { text: `Flashcard Separators` }); + { + new Setting(containerEl).setName(t("CONVERT_HIGHLIGHTS_TO_CLOZES")).addToggle((toggle) => toggle - .setValue(this.plugin.data.settings.showContextInCards) - .onChange(async (value) => { - this.plugin.data.settings.showContextInCards = value; - await this.plugin.savePluginData(); - }), - ); - - new Setting(containerEl) - .setName(t("CARD_MODAL_HEIGHT_PERCENT")) - .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) - .addSlider((slider) => - slider - .setLimits(10, 100, 5) - .setValue(this.plugin.data.settings.flashcardHeightPercentage) - .setDynamicTooltip() - .onChange(async (value) => { - this.plugin.data.settings.flashcardHeightPercentage = value; - await this.plugin.savePluginData(); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.flashcardHeightPercentage = - DEFAULT_SETTINGS.flashcardHeightPercentage; - await this.plugin.savePluginData(); - this.display(); - }); - }); - - new Setting(containerEl) - .setName(t("CARD_MODAL_WIDTH_PERCENT")) - .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) - .addSlider((slider) => - slider - .setLimits(10, 100, 5) - .setValue(this.plugin.data.settings.flashcardWidthPercentage) - .setDynamicTooltip() - .onChange(async (value) => { - this.plugin.data.settings.flashcardWidthPercentage = value; - await this.plugin.savePluginData(); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.flashcardWidthPercentage = - DEFAULT_SETTINGS.flashcardWidthPercentage; - await this.plugin.savePluginData(); - this.display(); - }); - }); - - new Setting(containerEl) - .setName(t("REVIEW_CARD_ORDER_WITHIN_DECK")) - .addDropdown((dropdown) => - dropdown - .addOptions({ - NewFirstSequential: t("REVIEW_CARD_ORDER_NEW_FIRST_SEQUENTIAL"), - DueFirstSequential: t("REVIEW_CARD_ORDER_DUE_FIRST_SEQUENTIAL"), - NewFirstRandom: t("REVIEW_CARD_ORDER_NEW_FIRST_RANDOM"), - DueFirstRandom: t("REVIEW_CARD_ORDER_DUE_FIRST_RANDOM"), - EveryCardRandomDeckAndCard: t("REVIEW_CARD_ORDER_RANDOM_DECK_AND_CARD"), - }) - .setValue(this.plugin.data.settings.flashcardCardOrder) + .setValue(this.plugin.data.settings.convertHighlightsToClozes) .onChange(async (value) => { - this.plugin.data.settings.flashcardCardOrder = value; + this.plugin.data.settings.convertHighlightsToClozes = value; await this.plugin.savePluginData(); - - // Need to redisplay as changing this setting affects the "deck order" setting - this.display(); }), ); - const deckOrderEnabled: boolean = - this.plugin.data.settings.flashcardCardOrder != "EveryCardRandomDeckAndCard"; - new Setting(containerEl).setName(t("REVIEW_DECK_ORDER")).addDropdown((dropdown) => - dropdown - .addOptions( - deckOrderEnabled - ? { - PrevDeckComplete_Sequential: t( - "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_SEQUENTIAL", - ), - PrevDeckComplete_Random: t( - "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_RANDOM", - ), - } - : { - EveryCardRandomDeckAndCard: t( - "REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD", - ), - }, - ) - .setValue( - deckOrderEnabled - ? this.plugin.data.settings.flashcardDeckOrder - : "EveryCardRandomDeckAndCard", - ) - .setDisabled(!deckOrderEnabled) - .onChange(async (value) => { - this.plugin.data.settings.flashcardDeckOrder = value; - await this.plugin.savePluginData(); - }), - ); - - new Setting(containerEl).setName(t("CONVERT_HIGHLIGHTS_TO_CLOZES")).addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.convertHighlightsToClozes) - .onChange(async (value) => { - this.plugin.data.settings.convertHighlightsToClozes = value; - await this.plugin.savePluginData(); - }), - ); - - new Setting(containerEl).setName(t("CONVERT_BOLD_TEXT_TO_CLOZES")).addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.convertBoldTextToClozes) - .onChange(async (value) => { - this.plugin.data.settings.convertBoldTextToClozes = value; - await this.plugin.savePluginData(); - }), - ); - - new Setting(containerEl) - .setName(t("CONVERT_CURLY_BRACKETS_TO_CLOZES")) - .addToggle((toggle) => + new Setting(containerEl).setName(t("CONVERT_BOLD_TEXT_TO_CLOZES")).addToggle((toggle) => toggle - .setValue(this.plugin.data.settings.convertCurlyBracketsToClozes) + .setValue(this.plugin.data.settings.convertBoldTextToClozes) .onChange(async (value) => { - this.plugin.data.settings.convertCurlyBracketsToClozes = value; + this.plugin.data.settings.convertBoldTextToClozes = value; await this.plugin.savePluginData(); }), ); - new Setting(containerEl) - .setName(t("INLINE_CARDS_SEPARATOR")) - .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) - .addText((text) => - text - .setValue(this.plugin.data.settings.singleLineCardSeparator) - .onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.singleLineCardSeparator = value; + new Setting(containerEl) + .setName(t("CONVERT_CURLY_BRACKETS_TO_CLOZES")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.convertCurlyBracketsToClozes) + .onChange(async (value) => { + this.plugin.data.settings.convertCurlyBracketsToClozes = value; + await this.plugin.savePluginData(); + }), + ); + + new Setting(containerEl) + .setName(t("INLINE_CARDS_SEPARATOR")) + .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) + .addText((text) => + text + .setValue(this.plugin.data.settings.singleLineCardSeparator) + .onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.singleLineCardSeparator = value; + await this.plugin.savePluginData(); + }); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.singleLineCardSeparator = + DEFAULT_SETTINGS.singleLineCardSeparator; await this.plugin.savePluginData(); + this.display(); }); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.singleLineCardSeparator = - DEFAULT_SETTINGS.singleLineCardSeparator; - await this.plugin.savePluginData(); - this.display(); - }); - }); - - new Setting(containerEl) - .setName(t("INLINE_REVERSED_CARDS_SEPARATOR")) - .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) - .addText((text) => - text - .setValue(this.plugin.data.settings.singleLineReversedCardSeparator) - .onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.singleLineReversedCardSeparator = value; + }); + + new Setting(containerEl) + .setName(t("INLINE_REVERSED_CARDS_SEPARATOR")) + .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) + .addText((text) => + text + .setValue(this.plugin.data.settings.singleLineReversedCardSeparator) + .onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.singleLineReversedCardSeparator = value; + await this.plugin.savePluginData(); + }); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.singleLineReversedCardSeparator = + DEFAULT_SETTINGS.singleLineReversedCardSeparator; await this.plugin.savePluginData(); + this.display(); }); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.singleLineReversedCardSeparator = - DEFAULT_SETTINGS.singleLineReversedCardSeparator; - await this.plugin.savePluginData(); - this.display(); - }); - }); - - new Setting(containerEl) - .setName(t("MULTILINE_CARDS_SEPARATOR")) - .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) - .addText((text) => - text - .setValue(this.plugin.data.settings.multilineCardSeparator) - .onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.multilineCardSeparator = value; + }); + + new Setting(containerEl) + .setName(t("MULTILINE_CARDS_SEPARATOR")) + .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) + .addText((text) => + text + .setValue(this.plugin.data.settings.multilineCardSeparator) + .onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.multilineCardSeparator = value; + await this.plugin.savePluginData(); + }); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.multilineCardSeparator = + DEFAULT_SETTINGS.multilineCardSeparator; await this.plugin.savePluginData(); + this.display(); }); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.multilineCardSeparator = - DEFAULT_SETTINGS.multilineCardSeparator; - await this.plugin.savePluginData(); - this.display(); - }); - }); - - new Setting(containerEl) - .setName(t("MULTILINE_REVERSED_CARDS_SEPARATOR")) - .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) - .addText((text) => - text - .setValue(this.plugin.data.settings.multilineReversedCardSeparator) - .onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.multilineReversedCardSeparator = value; + }); + + new Setting(containerEl) + .setName(t("MULTILINE_REVERSED_CARDS_SEPARATOR")) + .setDesc(t("FIX_SEPARATORS_MANUALLY_WARNING")) + .addText((text) => + text + .setValue(this.plugin.data.settings.multilineReversedCardSeparator) + .onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.multilineReversedCardSeparator = value; + await this.plugin.savePluginData(); + }); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.multilineReversedCardSeparator = + DEFAULT_SETTINGS.multilineReversedCardSeparator; await this.plugin.savePluginData(); + this.display(); }); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.multilineReversedCardSeparator = - DEFAULT_SETTINGS.multilineReversedCardSeparator; - await this.plugin.savePluginData(); - this.display(); - }); - }); - - new Setting(containerEl) - .setName(t("FLASHCARD_EASY_LABEL")) - .setDesc(t("FLASHCARD_EASY_DESC")) - .addText((text) => - text.setValue(this.plugin.data.settings.flashcardEasyText).onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.flashcardEasyText = value; - await this.plugin.savePluginData(); - }); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.flashcardEasyText = - DEFAULT_SETTINGS.flashcardEasyText; - await this.plugin.savePluginData(); - this.display(); - }); - }); - - new Setting(containerEl) - .setName(t("FLASHCARD_GOOD_LABEL")) - .setDesc(t("FLASHCARD_GOOD_DESC")) - .addText((text) => - text.setValue(this.plugin.data.settings.flashcardGoodText).onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.flashcardGoodText = value; - await this.plugin.savePluginData(); - }); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.flashcardGoodText = - DEFAULT_SETTINGS.flashcardGoodText; - await this.plugin.savePluginData(); - this.display(); - }); - }); + }); + } - new Setting(containerEl) - .setName(t("FLASHCARD_HARD_LABEL")) - .setDesc(t("FLASHCARD_HARD_DESC")) - .addText((text) => - text.setValue(this.plugin.data.settings.flashcardHardText).onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.flashcardHardText = value; - await this.plugin.savePluginData(); - }); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.flashcardHardText = - DEFAULT_SETTINGS.flashcardHardText; - await this.plugin.savePluginData(); - this.display(); - }); - }); + containerEl.createEl("h3", { text: `Storage of Scheduling Data` }); + { + new Setting(containerEl) + .setName(t("INLINE_SCHEDULING_COMMENTS")) + .setDesc(t("INLINE_SCHEDULING_COMMENTS_DESC")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.cardCommentOnSameLine) + .onChange(async (value) => { + this.plugin.data.settings.cardCommentOnSameLine = value; + await this.plugin.savePluginData(); + }), + ); + } } private async tabNotes(containerEl: HTMLElement): Promise { + containerEl.createEl("br"); new Setting(containerEl).setName(t("REVIEW_PANE_ON_STARTUP")).addToggle((toggle) => toggle .setValue(this.plugin.data.settings.enableNoteReviewPaneOnStartup) @@ -667,6 +545,7 @@ export class SRSettingTab extends PluginSettingTab { private async tabUiPreferences(containerEl: HTMLElement): Promise { + containerEl.createEl("h3", { text: `Flashcards` }); new Setting(containerEl) .setName(t("INITIALLY_EXPAND_SUBDECKS_IN_TREE")) .setDesc(t("INITIALLY_EXPAND_SUBDECKS_IN_TREE_DESC")) @@ -678,13 +557,145 @@ export class SRSettingTab extends PluginSettingTab { await this.plugin.savePluginData(); }), ); + + new Setting(containerEl) + .setName(t("SHOW_CARD_CONTEXT")) + .setDesc(t("SHOW_CARD_CONTEXT_DESC")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.showContextInCards) + .onChange(async (value) => { + this.plugin.data.settings.showContextInCards = value; + await this.plugin.savePluginData(); + }), + ); + + new Setting(containerEl) + .setName(t("CARD_MODAL_HEIGHT_PERCENT")) + .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) + .addSlider((slider) => + slider + .setLimits(10, 100, 5) + .setValue(this.plugin.data.settings.flashcardHeightPercentage) + .setDynamicTooltip() + .onChange(async (value) => { + this.plugin.data.settings.flashcardHeightPercentage = value; + await this.plugin.savePluginData(); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.flashcardHeightPercentage = + DEFAULT_SETTINGS.flashcardHeightPercentage; + await this.plugin.savePluginData(); + this.display(); + }); + }); + + new Setting(containerEl) + .setName(t("CARD_MODAL_WIDTH_PERCENT")) + .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) + .addSlider((slider) => + slider + .setLimits(10, 100, 5) + .setValue(this.plugin.data.settings.flashcardWidthPercentage) + .setDynamicTooltip() + .onChange(async (value) => { + this.plugin.data.settings.flashcardWidthPercentage = value; + await this.plugin.savePluginData(); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.flashcardWidthPercentage = + DEFAULT_SETTINGS.flashcardWidthPercentage; + await this.plugin.savePluginData(); + this.display(); + }); + }); + + containerEl.createEl("h3", { text: `Flashcards & Notes` }); + new Setting(containerEl) + .setName(t("FLASHCARD_EASY_LABEL")) + .setDesc(t("FLASHCARD_EASY_DESC")) + .addText((text) => + text.setValue(this.plugin.data.settings.flashcardEasyText).onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.flashcardEasyText = value; + await this.plugin.savePluginData(); + }); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.flashcardEasyText = + DEFAULT_SETTINGS.flashcardEasyText; + await this.plugin.savePluginData(); + this.display(); + }); + }); + + new Setting(containerEl) + .setName(t("FLASHCARD_GOOD_LABEL")) + .setDesc(t("FLASHCARD_GOOD_DESC")) + .addText((text) => + text.setValue(this.plugin.data.settings.flashcardGoodText).onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.flashcardGoodText = value; + await this.plugin.savePluginData(); + }); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.flashcardGoodText = + DEFAULT_SETTINGS.flashcardGoodText; + await this.plugin.savePluginData(); + this.display(); + }); + }); + + new Setting(containerEl) + .setName(t("FLASHCARD_HARD_LABEL")) + .setDesc(t("FLASHCARD_HARD_DESC")) + .addText((text) => + text.setValue(this.plugin.data.settings.flashcardHardText).onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.flashcardHardText = value; + await this.plugin.savePluginData(); + }); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.flashcardHardText = + DEFAULT_SETTINGS.flashcardHardText; + await this.plugin.savePluginData(); + this.display(); + }); + }); } private async tabAlgorithm(containerEl: HTMLElement): Promise { - containerEl.createDiv().innerHTML = t("CHECK_ALGORITHM_WIKI", { - algo_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/algorithms/", - }); + containerEl.createEl("p").insertAdjacentHTML("beforeend", t("CHECK_ALGORITHM_WIKI", { + algo_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", + })); new Setting(containerEl) .setName(t("BASE_EASE")) @@ -846,12 +857,50 @@ export class SRSettingTab extends PluginSettingTab { private async tabDeveloper(containerEl: HTMLElement): Promise { + containerEl.createEl("h3", { text: `${t("LOGGING")}` }); new Setting(containerEl).setName(t("DISPLAY_DEBUG_INFO")).addToggle((toggle) => toggle.setValue(this.plugin.data.settings.showDebugMessages).onChange(async (value) => { this.plugin.data.settings.showDebugMessages = value; await this.plugin.savePluginData(); }), ); + containerEl.createEl("h3", { text: `Contributing` }); + containerEl.createEl("p").insertAdjacentHTML("beforeend", t("GITHUB_SOURCE_CODE", { + github_project_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition", + })); + containerEl.createEl("p").insertAdjacentHTML("beforeend", t("CODE_CONTRIBUTION_INFO", { + code_contribution_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/contributing/#code", + })); + containerEl.createEl("p").insertAdjacentHTML("beforeend", t("TRANSLATION_CONTRIBUTION_INFO", { + translation_contribution_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/contributing/#translating", + })); + + } + + private async tabHelp(containerEl: HTMLElement): Promise { + + // Documentation link & GitHub links + containerEl.createEl("p").insertAdjacentHTML("beforeend", t("CHECK_WIKI", { + wiki_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", + })); + + containerEl.createEl("p").insertAdjacentHTML("beforeend", t("GITHUB_DISCUSSIONS", { + discussions_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition/discussions/", + })); + + containerEl.createEl("p").insertAdjacentHTML("beforeend", t("GITHUB_ISSUES", { + issues_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition/issues/", + })); +/* + // Documentation link & GitHub links + containerEl.createEl("hr").insertAdjacentHTML("beforeend"); + + // Copyright notice + const copyright_paragraph = containerEl.createEl("p"); + copyright_paragraph.addClass("SC-small-font"); + copyright_paragraph.insertAdjacentHTML("beforeend", ` + Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. + `); */ } private last_position: { @@ -859,7 +908,7 @@ export class SRSettingTab extends PluginSettingTab { tab_name: string; } = { scroll_position: 0, - tab_name: "main-shell-commands", + tab_name: "main-flashcards", }; private rememberLastPosition(container_element: HTMLElement) { const last_position = this.last_position; From 235c9cf0caccea30d05adc54e38e73a1e4786ae8 Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:09:41 +1100 Subject: [PATCH 3/8] Alternative to needing the "Advanced" tab --- src/lang/locale/en.ts | 3 ++- src/settings.ts | 50 +++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 0eded17a..1c0f0d76 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -62,7 +62,8 @@ export default { TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Folders to ignore", - FOLDERS_TO_IGNORE_DESC: "Enter folder paths separated by newlines i.e. Templates Meta/Scripts", + FOLDERS_TO_IGNORE_DESC: `Enter folder paths separated by newlines e.g. Templates Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Flashcards", FLASHCARD_EASY_LABEL: "Easy Button Text", FLASHCARD_GOOD_LABEL: "Good Button Text", diff --git a/src/settings.ts b/src/settings.ts index 7223485e..a86a9732 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -149,11 +149,6 @@ export class SRSettingTab extends PluginSettingTab { icon: null, // "dot-network", content_generator: (container_element: HTMLElement) => this.tabAlgorithm(container_element), }, - "main-advanced": { - title: "Advanced", - icon: null, // "vertical-three-dots", - content_generator: (container_element: HTMLElement) => this.tabAdvanced(container_element), - }, "main-ui-preferences": { title: t("UI_PREFERENCES"), icon: null, // "presentation", @@ -181,27 +176,8 @@ export class SRSettingTab extends PluginSettingTab { }); } - private async tabAdvanced(containerEl: HTMLElement): Promise { - containerEl.createEl("br"); - new Setting(containerEl) - .setName(t("FOLDERS_TO_IGNORE")) - .setDesc(t("FOLDERS_TO_IGNORE_DESC")) - .addTextArea((text) => - text - .setValue(this.plugin.data.settings.noteFoldersToIgnore.join("\n")) - .onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.noteFoldersToIgnore = value - .split(/\n+/) - .map((v) => v.trim()) - .filter((v) => v); - await this.plugin.savePluginData(); - }); - }), - ); - } - private async tabFlashcards(containerEl: HTMLElement): Promise { + console.log(`tabFlashcards`); containerEl.createEl("h3", { text: `Tags & Folders` }); { @@ -230,6 +206,7 @@ export class SRSettingTab extends PluginSettingTab { await this.plugin.savePluginData(); }), ); + this.createSetting_FoldersToIgnore(containerEl); } containerEl.createEl("h3", { text: `Flashcard Review` }); @@ -449,7 +426,7 @@ export class SRSettingTab extends PluginSettingTab { } private async tabNotes(containerEl: HTMLElement): Promise { - +console.log(`tabNotes`); containerEl.createEl("br"); new Setting(containerEl).setName(t("REVIEW_PANE_ON_STARTUP")).addToggle((toggle) => toggle @@ -474,6 +451,8 @@ export class SRSettingTab extends PluginSettingTab { }), ); + this.createSetting_FoldersToIgnore(containerEl); + new Setting(containerEl) .setName(t("OPEN_RANDOM_NOTE")) .setDesc(t("OPEN_RANDOM_NOTE_DESC")) @@ -543,6 +522,25 @@ export class SRSettingTab extends PluginSettingTab { }); } + private async createSetting_FoldersToIgnore(containerEl: HTMLElement): Promise { + new Setting(containerEl) + .setName(t("FOLDERS_TO_IGNORE")) + .setDesc(t("FOLDERS_TO_IGNORE_DESC")) + .addTextArea((text) => + text + .setValue(this.plugin.data.settings.noteFoldersToIgnore.join("\n")) + .onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.noteFoldersToIgnore = value + .split(/\n+/) + .map((v) => v.trim()) + .filter((v) => v); + await this.plugin.savePluginData(); + }); + }), + ); + } + private async tabUiPreferences(containerEl: HTMLElement): Promise { containerEl.createEl("h3", { text: `Flashcards` }); From 965c3943274092d21aba83c2312edfe04e417e0f Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Fri, 19 Jul 2024 12:37:45 +1000 Subject: [PATCH 4/8] Added missing css --- src/gui/Tabs.ts | 26 +++++++++++------------ src/settings.ts | 4 ++-- styles.css | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/gui/Tabs.ts b/src/gui/Tabs.ts index 62829afa..c771ac6d 100644 --- a/src/gui/Tabs.ts +++ b/src/gui/Tabs.ts @@ -52,7 +52,7 @@ interface TabButtons { } export function createTabs(container_element: HTMLElement, tabs: Tabs, activateTabId: string): TabStructure { - const tab_header = container_element.createEl("div", {attr: {class: "SC-tab-header"}}); + const tab_header = container_element.createEl("div", {attr: {class: "sr-tab-header"}}); const tab_content_containers: TabContentContainers = {}; const tab_buttons: TabButtons = {}; const tab_structure: TabStructure = { @@ -69,8 +69,8 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT // Create button const button = tab_header.createEl("button", { attr: { - class: "SC-tab-header-button", - activateTab: "SC-tab-" + tab_id, + class: "sr-tab-header-button", + activateTab: "sr-tab-" + tab_id, }, }); button.onclick = function (event: MouseEvent) { @@ -87,7 +87,7 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT if (null === container_element) { throw new Error("Container element is missing. Did not get a parent from tab header."); } - const tab_contents = container_element.findAll("div.SC-tab-content"); // Do not get all tab contents that exist, because there might be multiple tab systems open at the same time. + const tab_contents = container_element.findAll("div.sr-tab-content"); // Do not get all tab contents that exist, because there might be multiple tab systems open at the same time. const is_main_settings_modal = container_element.hasClass("vertical-tab-content"); for (const index in tab_contents) { const tab_content = tab_contents[index]; @@ -95,7 +95,7 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT // Get the maximum tab dimensions so that all tabs can have the same dimensions. // But don't do it if this is the main settings modal if (!is_main_settings_modal) { - tab_content.addClass("SC-tab-active"); // Need to make the tab visible temporarily in order to get the dimensions. + tab_content.addClass("sr-tab-active"); // Need to make the tab visible temporarily in order to get the dimensions. if (tab_content.offsetHeight > max_height) { max_height = tab_content.offsetHeight; } @@ -105,18 +105,18 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT } // Finally hide the tab - tab_content.removeClass("SC-tab-active"); + tab_content.removeClass("sr-tab-active"); } // Remove active status from all buttons - const adjacent_tab_buttons = tab_header.findAll(".SC-tab-header-button"); // Do not get all tab buttons that exist, because there might be multiple tab systems open at the same time. + const adjacent_tab_buttons = tab_header.findAll(".sr-tab-header-button"); // Do not get all tab buttons that exist, because there might be multiple tab systems open at the same time. for (const index in adjacent_tab_buttons) { const tab_button = adjacent_tab_buttons[index]; - tab_button.removeClass("SC-tab-active"); + tab_button.removeClass("sr-tab-active"); } // Activate the clicked tab - tab_button.addClass("SC-tab-active"); + tab_button.addClass("sr-tab-active"); const activateTabAttribute: Attr | null = tab_button.attributes.getNamedItem("activateTab"); if (null === activateTabAttribute) { throw new Error("Tab button has no 'activateTab' HTML attribute! Murr!"); @@ -126,13 +126,13 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT if (null === tab_content) { throw new Error("No tab content was found with activate_tab_id '"+activate_tab_id+"'! Hmph!"); } - tab_content.addClass("SC-tab-active"); + tab_content.addClass("sr-tab-active"); // Mark the clicked tab as active in TabStructure (just to report which tab is currently active) - tab_structure.active_tab_id = activate_tab_id.replace(/^SC-tab-/, ""); // Remove "SC-tab" prefix. + tab_structure.active_tab_id = activate_tab_id.replace(/^sr-tab-/, ""); // Remove "sr-tab" prefix. // Focus an element (if a focusable element is present) - tab_content.find(".SC-focus-element-on-tab-opening")?.focus(); // ? = If not found, do nothing. + tab_content.find(".sr-focus-element-on-tab-opening")?.focus(); // ? = If not found, do nothing. // Apply the max dimensions to this tab // But don't do it if this is the main settings modal @@ -151,7 +151,7 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT tab_buttons[tab_id] = button; // Create content container - tab_content_containers[tab_id] = container_element.createEl("div", {attr: {class: "SC-tab-content", id: "SC-tab-" + tab_id}}); + tab_content_containers[tab_id] = container_element.createEl("div", {attr: {class: "sr-tab-content", id: "sr-tab-" + tab_id}}); // Generate content tab_structure.contentGeneratorPromises[tab_id] = tab.content_generator(tab_content_containers[tab_id]); diff --git a/src/settings.ts b/src/settings.ts index 893a1d69..46de2002 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -143,7 +143,7 @@ export class SRSettingTab extends PluginSettingTab { containerEl.empty(); - const header = containerEl.createEl("h1", { text: `${t("SETTINGS_HEADER")}` }); + const header = containerEl.createEl("h4", { text: `${t("SETTINGS_HEADER")}` }); header.addClass("sr-centered"); this.tab_structure = createTabs( @@ -910,7 +910,7 @@ console.log(`tabNotes`); // Copyright notice const copyright_paragraph = containerEl.createEl("p"); - copyright_paragraph.addClass("SC-small-font"); + copyright_paragraph.addClass("sr-small-font"); copyright_paragraph.insertAdjacentHTML("beforeend", ` Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0. `); */ diff --git a/styles.css b/styles.css index af8e7a1d..4329ee1d 100644 --- a/styles.css +++ b/styles.css @@ -282,3 +282,58 @@ body:not(.native-scrollbars) #sr-modal .modal-close-button { appearance: menulist; border-right: 8px solid transparent; } + +/* + * Tab elements + * This CSS is copied from https://github.com/Taitava/obsidian-shellcommands + * Jarkko Linnanvirta https://github.com/Taitava comments below... + * - Renamed classes + * + * This CSS is copied 2021-10-21 from https://www.w3schools.com/howto/howto_js_tabs.asp + * Modifications: + * - Renamed classes + * - Added tab icons. + * - Changed colors. + * - Changed/removed borders. + * - Removed button transition. + * - Changed button border-radiuses + * - Added margin-right rule to .sr-tab-header-button . + */ + +/* Style the tab */ +.sr-tab-header { + border-bottom: 6px solid var(--background-modifier-border); +} + +/* Style the buttons that are used to open the tab content */ +button.sr-tab-header-button { + background-color: unset; + border: none; + box-shadow: none; /* Remove a "border" that came via Obsidian 0.16.0. */ + outline: none; + cursor: pointer; + padding: 14px 16px; + margin-right: 6px; /* Reduced margin. Obsidian's default margin-right for button is 12px (0 for other margins). */ + border-radius: 10px 10px 0 0; /* 0 0 = No border-radius at bottom */ +} + +/* Create an active/current tablink class */ +button.sr-tab-header-button.sr-tab-active, +button.sr-tab-header-button:hover { + background-color: var(--background-modifier-border); +} + +.sr-tab-header-button svg { + vertical-align: middle; /* Not middle but close enough. */ +} + +/* Style the tab content */ +.sr-tab-content { + display: none; + padding: 6px 12px; +} + +.sr-tab-content.sr-tab-active { + display: block; +} + From d056c0de462ec3324a4852365a68cccfaed990d0 Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:10:47 +1000 Subject: [PATCH 5/8] Updated messages for non-English languages --- src/lang/locale/ar.ts | 9 ++++++++- src/lang/locale/cz.ts | 11 +++++++++-- src/lang/locale/de.ts | 11 +++++++++-- src/lang/locale/en.ts | 2 +- src/lang/locale/es.ts | 9 ++++++++- src/lang/locale/it.ts | 9 ++++++++- src/lang/locale/ja.ts | 11 +++++++++-- src/lang/locale/ko.ts | 11 +++++++++-- src/lang/locale/pl.ts | 9 ++++++++- src/lang/locale/pt-br.ts | 11 +++++++++-- src/lang/locale/ru.ts | 9 ++++++++- src/lang/locale/zh-cn.ts | 9 ++++++++- src/lang/locale/zh-tw.ts | 9 ++++++++- 13 files changed, 102 insertions(+), 18 deletions(-) diff --git a/src/lang/locale/ar.ts b/src/lang/locale/ar.ts index d4dee92e..990f0d55 100644 --- a/src/lang/locale/ar.ts +++ b/src/lang/locale/ar.ts @@ -52,9 +52,16 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition Plugin - Settings", CHECK_WIKI: '.wiki لمزيد من المعلومات ، تحقق من', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "مجلدات لتجاهلها", FOLDERS_TO_IGNORE_DESC: - "Templates Meta/Scripts : أدخل مسارات المجلد مفصولة بواسطة سطور جديدة,مثال", + `Templates Meta/Scripts. +Note that this setting is common to both Flashcards and Notes. : أدخل مسارات المجلد مفصولة بواسطة سطور جديدة,مثال`, FLASHCARDS: "البطاقات", FLASHCARD_EASY_LABEL: "نص الزر سهل", FLASHCARD_GOOD_LABEL: "نص الزر جيد", diff --git a/src/lang/locale/cz.ts b/src/lang/locale/cz.ts index ebece0a5..354c7997 100644 --- a/src/lang/locale/cz.ts +++ b/src/lang/locale/cz.ts @@ -50,11 +50,18 @@ export default { YEARS_STR_IVL_MOBILE: "${interval}r", // settings.ts - SETTINGS_HEADER: "Spaced Repetition Plugin - Nastavení", + SETTINGS_HEADER: "Spaced Repetition - Nastavení", CHECK_WIKI: 'Pro více informací jděte na wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Ignorované složky", FOLDERS_TO_IGNORE_DESC: - "Zadejte cesty ke složkám oddělené odřádkováním napříkad. Šablony Meta/Scripts", + `Zadejte cesty ke složkám oddělené odřádkováním napříkad. Šablony Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Kartičky", FLASHCARD_EASY_LABEL: "Easy Button Text", FLASHCARD_GOOD_LABEL: "Good Button Text", diff --git a/src/lang/locale/de.ts b/src/lang/locale/de.ts index d4e142d9..0dac438b 100644 --- a/src/lang/locale/de.ts +++ b/src/lang/locale/de.ts @@ -56,11 +56,18 @@ export default { YEARS_STR_IVL_MOBILE: "${interval}j", // settings.ts - SETTINGS_HEADER: "Spaced Repetition Plugin - Einstellungen", + SETTINGS_HEADER: "Spaced Repetition - Einstellungen", CHECK_WIKI: 'Weitere Informationen gibt es im Wiki (english).', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Ausgeschlossene Ordner", FOLDERS_TO_IGNORE_DESC: - "Mehrere Ordner mit Zeilenumbrüchen getrennt angeben. Bsp. OrdnerA[Zeilenumbruch]OrdnerB/Unterordner", + `Mehrere Ordner mit Zeilenumbrüchen getrennt angeben. Bsp. OrdnerA[Zeilenumbruch]OrdnerB/Unterordner. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Lernkarten", FLASHCARD_EASY_LABEL: "Einfach Knopf Text", FLASHCARD_GOOD_LABEL: "Gut Knopf Text", diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index e1380283..42cc4218 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -50,7 +50,7 @@ export default { YEARS_STR_IVL_MOBILE: "${interval}y", // settings.ts - SETTINGS_HEADER: "Spaced Repetition Plugin - Settings", + SETTINGS_HEADER: "Spaced Repetition - Settings", CHECK_WIKI: 'For more information, check the wiki.', GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', diff --git a/src/lang/locale/es.ts b/src/lang/locale/es.ts index 337105ad..b6af1115 100644 --- a/src/lang/locale/es.ts +++ b/src/lang/locale/es.ts @@ -52,9 +52,16 @@ export default { // settings.ts SETTINGS_HEADER: "Extensión de Repetición Espaciada - Ajustes", CHECK_WIKI: 'Para más información revisa la wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Directorios a ignorar", FOLDERS_TO_IGNORE_DESC: - "Escriba las rutas de los directorios separadas por saltos de línea, por ejemplo, Plantillas Extra/Guiones", + `Escriba las rutas de los directorios separadas por saltos de línea, por ejemplo, Plantillas Extra/Guiones. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Tarjetas de Memorización", FLASHCARD_EASY_LABEL: "Texto del botón: Fácil", FLASHCARD_GOOD_LABEL: "Texto del botón: Bien", diff --git a/src/lang/locale/it.ts b/src/lang/locale/it.ts index 33ddff94..54f930b9 100644 --- a/src/lang/locale/it.ts +++ b/src/lang/locale/it.ts @@ -53,9 +53,16 @@ export default { // settings.ts SETTINGS_HEADER: "Plugin per ripetizione spaziata - Impostazioni", CHECK_WIKI: 'Per maggiori informazioni, rivolgersi alla wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Cartelle da ignorare", FOLDERS_TO_IGNORE_DESC: - "Inserisci i percorsi delle cartelle separati da a capo, per esempio, Templates Meta/Scripts", + `Inserisci i percorsi delle cartelle separati da a capo, per esempio, Templates Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Schede", FLASHCARD_EASY_LABEL: "Testo del bottone facile", FLASHCARD_GOOD_LABEL: "Testo del bottone buono", diff --git a/src/lang/locale/ja.ts b/src/lang/locale/ja.ts index 96bbbcfd..f8be4435 100644 --- a/src/lang/locale/ja.ts +++ b/src/lang/locale/ja.ts @@ -51,11 +51,18 @@ export default { YEARS_STR_IVL_MOBILE: "${interval}y", // settings.ts - SETTINGS_HEADER: "Spaced Repetition Plugin - 設定", + SETTINGS_HEADER: "Spaced Repetition - 設定", CHECK_WIKI: '詳細についてはwikiを確認してください。', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "無視するフォルダ", FOLDERS_TO_IGNORE_DESC: - 'フォルダパスを改行で区切って入力してください。"Templates Meta/Scripts" のようなスペースによる区切りでの書き方は無効です。', + `フォルダパスを改行で区切って入力してください。"Templates Meta/Scripts" のようなスペースによる区切りでの書き方は無効です。. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "フラッシュカード", FLASHCARD_EASY_LABEL: "Easy Button Text", FLASHCARD_GOOD_LABEL: "Good Button Text", diff --git a/src/lang/locale/ko.ts b/src/lang/locale/ko.ts index 4f1e6206..2b4efd47 100644 --- a/src/lang/locale/ko.ts +++ b/src/lang/locale/ko.ts @@ -50,11 +50,18 @@ export default { YEARS_STR_IVL_MOBILE: "${interval}y", // settings.ts - SETTINGS_HEADER: "Spaced Repetition Plugin - 설정", + SETTINGS_HEADER: "Spaced Repetition - 설정", CHECK_WIKI: '더 많은 정보를 원하시면, wiki를 확인해주세요.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "무시할 폴더들", FOLDERS_TO_IGNORE_DESC: - "폴더 경로를 빈 줄로 구분해서 입력해주세요. 'Templates Meta/Scripts' 와 같이 입력하는 것은 유효하지 않습니다.", + `폴더 경로를 빈 줄로 구분해서 입력해주세요. 'Templates Meta/Scripts' 와 같이 입력하는 것은 유효하지 않습니다. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "플래시카드", FLASHCARD_EASY_LABEL: "Easy Button Text", FLASHCARD_GOOD_LABEL: "Good Button Text", diff --git a/src/lang/locale/pl.ts b/src/lang/locale/pl.ts index 3d3cf47d..f46a5140 100644 --- a/src/lang/locale/pl.ts +++ b/src/lang/locale/pl.ts @@ -52,9 +52,16 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - Ustawienia", CHECK_WIKI: 'Aby uzyskać więcej informacji, sprawdź wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Foldery do zignorowania", FOLDERS_TO_IGNORE_DESC: - "Wprowadź ścieżki folderów oddzielone nowymi liniami, np. Szablony Meta/Scripts", + `Wprowadź ścieżki folderów oddzielone nowymi liniami, np. Szablony Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Fiszki", FLASHCARD_EASY_LABEL: "Tekst przycisku Łatwe", FLASHCARD_GOOD_LABEL: "Tekst przycisku Średnio trudne", diff --git a/src/lang/locale/pt-br.ts b/src/lang/locale/pt-br.ts index 7656563f..4606a14e 100644 --- a/src/lang/locale/pt-br.ts +++ b/src/lang/locale/pt-br.ts @@ -52,11 +52,18 @@ export default { YEARS_STR_IVL_MOBILE: "${interval}a", // settings.ts - SETTINGS_HEADER: "Plugin Spaced Repetition - Configuração", + SETTINGS_HEADER: "Spaced Repetition - Configuração", CHECK_WIKI: 'Para mais informações, cheque a wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Pastas para ignorar", FOLDERS_TO_IGNORE_DESC: - "Insira o caminho das pastas separado por quebras de linha ex: Templates Meta/Scripts", + `Insira o caminho das pastas separado por quebras de linha ex: Templates Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Flashcards", FLASHCARD_EASY_LABEL: "Texto do Botão de Fácil", FLASHCARD_GOOD_LABEL: "Texto do Botão de OK", diff --git a/src/lang/locale/ru.ts b/src/lang/locale/ru.ts index 6a05f222..de63e69d 100644 --- a/src/lang/locale/ru.ts +++ b/src/lang/locale/ru.ts @@ -61,9 +61,16 @@ export default { // settings.ts SETTINGS_HEADER: "Плагин Spaced Repetition - Настройки", CHECK_WIKI: 'Для дополнительной информации посетите: wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Игнорируемые папки", FOLDERS_TO_IGNORE_DESC: - "Укажите пути папок, каждый на своей строке, например: Templates Meta/Scripts", + `Укажите пути папок, каждый на своей строке, например: Templates Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Карточки", FLASHCARD_EASY_LABEL: 'Текст кнопки "Легко"', FLASHCARD_GOOD_LABEL: 'Текст кнопки "Нормально"', diff --git a/src/lang/locale/zh-cn.ts b/src/lang/locale/zh-cn.ts index d34d01ca..9fa5ef5a 100644 --- a/src/lang/locale/zh-cn.ts +++ b/src/lang/locale/zh-cn.ts @@ -52,8 +52,15 @@ export default { // settings.ts SETTINGS_HEADER: "间隔重复插件 - 设置", CHECK_WIKI: '了解更多, 请点击wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "忽略此文件夹", - FOLDERS_TO_IGNORE_DESC: "输入文件夹路径,用新建行分隔,例如:Templates Meta/Scripts", + FOLDERS_TO_IGNORE_DESC: `输入文件夹路径,用新建行分隔,例如:Templates Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "卡片", FLASHCARD_EASY_LABEL: "“简单”按钮文本", FLASHCARD_GOOD_LABEL: "“记得”按钮文本", diff --git a/src/lang/locale/zh-tw.ts b/src/lang/locale/zh-tw.ts index 6b2dd287..75c80de6 100644 --- a/src/lang/locale/zh-tw.ts +++ b/src/lang/locale/zh-tw.ts @@ -52,8 +52,15 @@ export default { // settings.ts SETTINGS_HEADER: "間隔重複外掛 - 設定", CHECK_WIKI: '瞭解更多, 請點選wiki.', + GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "忽略此資料夾", - FOLDERS_TO_IGNORE_DESC: "輸入資料夾路徑(用換行字元分隔),例如:Templates Meta/Scripts", + FOLDERS_TO_IGNORE_DESC: `輸入資料夾路徑(用換行字元分隔),例如:Templates Meta/Scripts. +Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "卡片", FLASHCARD_EASY_LABEL: "簡單按鈕文字", FLASHCARD_GOOD_LABEL: "記得按鈕文字", From c0119b1b2ef1acce466eac7213835a1390646c43 Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:45:52 +1000 Subject: [PATCH 6/8] Format & lint --- src/gui/Tabs.ts | 55 ++++--- src/lang/locale/ar.ts | 27 +++- src/lang/locale/cz.ts | 27 +++- src/lang/locale/de.ts | 27 +++- src/lang/locale/en.ts | 24 ++- src/lang/locale/es.ts | 27 +++- src/lang/locale/it.ts | 27 +++- src/lang/locale/ja.ts | 27 +++- src/lang/locale/ko.ts | 27 +++- src/lang/locale/pl.ts | 27 +++- src/lang/locale/pt-br.ts | 27 +++- src/lang/locale/ru.ts | 27 +++- src/lang/locale/zh-cn.ts | 24 ++- src/lang/locale/zh-tw.ts | 24 ++- src/settings.ts | 312 +++++++++++++++++++++------------------ styles.css | 1 - 16 files changed, 446 insertions(+), 264 deletions(-) diff --git a/src/gui/Tabs.ts b/src/gui/Tabs.ts index c771ac6d..06fab85b 100644 --- a/src/gui/Tabs.ts +++ b/src/gui/Tabs.ts @@ -17,7 +17,7 @@ * Contact the author (Jarkko Linnanvirta): https://github.com/Taitava/ */ -import {setIcon} from "obsidian"; +import { setIcon } from "obsidian"; export interface Tab { title: string; @@ -26,17 +26,17 @@ export interface Tab { } export interface TabStructure { - header: HTMLElement, - active_tab_id: string, + header: HTMLElement; + active_tab_id: string; buttons: { - [key: string]: HTMLElement, - } + [key: string]: HTMLElement; + }; contentContainers: { - [key: string]: HTMLElement, - }, + [key: string]: HTMLElement; + }; contentGeneratorPromises: { - [key: string]: Promise, - } + [key: string]: Promise; + }; } export interface Tabs { @@ -44,15 +44,19 @@ export interface Tabs { } interface TabContentContainers { - [key: string]: HTMLElement, + [key: string]: HTMLElement; } interface TabButtons { - [key: string]: HTMLElement, + [key: string]: HTMLElement; } -export function createTabs(container_element: HTMLElement, tabs: Tabs, activateTabId: string): TabStructure { - const tab_header = container_element.createEl("div", {attr: {class: "sr-tab-header"}}); +export function createTabs( + container_element: HTMLElement, + tabs: Tabs, + activateTabId: string, +): TabStructure { + const tab_header = container_element.createEl("div", { attr: { class: "sr-tab-header" } }); const tab_content_containers: TabContentContainers = {}; const tab_buttons: TabButtons = {}; const tab_structure: TabStructure = { @@ -85,7 +89,9 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT } const container_element = tab_header.parentElement; if (null === container_element) { - throw new Error("Container element is missing. Did not get a parent from tab header."); + throw new Error( + "Container element is missing. Did not get a parent from tab header.", + ); } const tab_contents = container_element.findAll("div.sr-tab-content"); // Do not get all tab contents that exist, because there might be multiple tab systems open at the same time. const is_main_settings_modal = container_element.hasClass("vertical-tab-content"); @@ -117,14 +123,19 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT // Activate the clicked tab tab_button.addClass("sr-tab-active"); - const activateTabAttribute: Attr | null = tab_button.attributes.getNamedItem("activateTab"); + const activateTabAttribute: Attr | null = + tab_button.attributes.getNamedItem("activateTab"); if (null === activateTabAttribute) { throw new Error("Tab button has no 'activateTab' HTML attribute! Murr!"); } const activate_tab_id = activateTabAttribute.value; const tab_content: HTMLElement | null = document.getElementById(activate_tab_id); if (null === tab_content) { - throw new Error("No tab content was found with activate_tab_id '"+activate_tab_id+"'! Hmph!"); + throw new Error( + "No tab content was found with activate_tab_id '" + + activate_tab_id + + "'! Hmph!", + ); } tab_content.addClass("sr-tab-active"); @@ -144,17 +155,20 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT // Do nothing else (I don't know if this is needed or not) event.preventDefault(); }; - if (tab.icon) - setIcon(button, tab.icon); + if (tab.icon) setIcon(button, tab.icon); button.insertAdjacentText("beforeend", " " + tab.title); tab_buttons[tab_id] = button; // Create content container - tab_content_containers[tab_id] = container_element.createEl("div", {attr: {class: "sr-tab-content", id: "sr-tab-" + tab_id}}); + tab_content_containers[tab_id] = container_element.createEl("div", { + attr: { class: "sr-tab-content", id: "sr-tab-" + tab_id }, + }); // Generate content - tab_structure.contentGeneratorPromises[tab_id] = tab.content_generator(tab_content_containers[tab_id]); + tab_structure.contentGeneratorPromises[tab_id] = tab.content_generator( + tab_content_containers[tab_id], + ); // Memorize the first tab's button if (undefined === first_button) { @@ -168,4 +182,3 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT // Return the TabStructure return tab_structure; } - diff --git a/src/lang/locale/ar.ts b/src/lang/locale/ar.ts index 990f0d55..ca621a78 100644 --- a/src/lang/locale/ar.ts +++ b/src/lang/locale/ar.ts @@ -51,16 +51,27 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition Plugin - Settings", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: '.wiki لمزيد من المعلومات ، تحقق من', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "مجلدات لتجاهلها", - FOLDERS_TO_IGNORE_DESC: - `Templates Meta/Scripts. + FOLDERS_TO_IGNORE_DESC: `Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes. : أدخل مسارات المجلد مفصولة بواسطة سطور جديدة,مثال`, FLASHCARDS: "البطاقات", FLASHCARD_EASY_LABEL: "نص الزر سهل", diff --git a/src/lang/locale/cz.ts b/src/lang/locale/cz.ts index 354c7997..b7256cd7 100644 --- a/src/lang/locale/cz.ts +++ b/src/lang/locale/cz.ts @@ -51,16 +51,27 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - Nastavení", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'Pro více informací jděte na wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Ignorované složky", - FOLDERS_TO_IGNORE_DESC: - `Zadejte cesty ke složkám oddělené odřádkováním napříkad. Šablony Meta/Scripts. + FOLDERS_TO_IGNORE_DESC: `Zadejte cesty ke složkám oddělené odřádkováním napříkad. Šablony Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Kartičky", FLASHCARD_EASY_LABEL: "Easy Button Text", diff --git a/src/lang/locale/de.ts b/src/lang/locale/de.ts index 0dac438b..8173697f 100644 --- a/src/lang/locale/de.ts +++ b/src/lang/locale/de.ts @@ -57,16 +57,27 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - Einstellungen", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'Weitere Informationen gibt es im Wiki (english).', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Ausgeschlossene Ordner", - FOLDERS_TO_IGNORE_DESC: - `Mehrere Ordner mit Zeilenumbrüchen getrennt angeben. Bsp. OrdnerA[Zeilenumbruch]OrdnerB/Unterordner. + FOLDERS_TO_IGNORE_DESC: `Mehrere Ordner mit Zeilenumbrüchen getrennt angeben. Bsp. OrdnerA[Zeilenumbruch]OrdnerB/Unterordner. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Lernkarten", FLASHCARD_EASY_LABEL: "Einfach Knopf Text", diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 42cc4218..6ac84336 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -51,13 +51,25 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - Settings", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'For more information, check the wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Folders to ignore", FOLDERS_TO_IGNORE_DESC: `Enter folder paths separated by newlines e.g. Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, diff --git a/src/lang/locale/es.ts b/src/lang/locale/es.ts index b6af1115..e80b93c7 100644 --- a/src/lang/locale/es.ts +++ b/src/lang/locale/es.ts @@ -51,16 +51,27 @@ export default { // settings.ts SETTINGS_HEADER: "Extensión de Repetición Espaciada - Ajustes", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'Para más información revisa la wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Directorios a ignorar", - FOLDERS_TO_IGNORE_DESC: - `Escriba las rutas de los directorios separadas por saltos de línea, por ejemplo, Plantillas Extra/Guiones. + FOLDERS_TO_IGNORE_DESC: `Escriba las rutas de los directorios separadas por saltos de línea, por ejemplo, Plantillas Extra/Guiones. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Tarjetas de Memorización", FLASHCARD_EASY_LABEL: "Texto del botón: Fácil", diff --git a/src/lang/locale/it.ts b/src/lang/locale/it.ts index 54f930b9..4c256692 100644 --- a/src/lang/locale/it.ts +++ b/src/lang/locale/it.ts @@ -52,16 +52,27 @@ export default { // settings.ts SETTINGS_HEADER: "Plugin per ripetizione spaziata - Impostazioni", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'Per maggiori informazioni, rivolgersi alla wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Cartelle da ignorare", - FOLDERS_TO_IGNORE_DESC: - `Inserisci i percorsi delle cartelle separati da a capo, per esempio, Templates Meta/Scripts. + FOLDERS_TO_IGNORE_DESC: `Inserisci i percorsi delle cartelle separati da a capo, per esempio, Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Schede", FLASHCARD_EASY_LABEL: "Testo del bottone facile", diff --git a/src/lang/locale/ja.ts b/src/lang/locale/ja.ts index f8be4435..9ecac8fb 100644 --- a/src/lang/locale/ja.ts +++ b/src/lang/locale/ja.ts @@ -52,16 +52,27 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - 設定", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: '詳細についてはwikiを確認してください。', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "無視するフォルダ", - FOLDERS_TO_IGNORE_DESC: - `フォルダパスを改行で区切って入力してください。"Templates Meta/Scripts" のようなスペースによる区切りでの書き方は無効です。. + FOLDERS_TO_IGNORE_DESC: `フォルダパスを改行で区切って入力してください。"Templates Meta/Scripts" のようなスペースによる区切りでの書き方は無効です。. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "フラッシュカード", FLASHCARD_EASY_LABEL: "Easy Button Text", diff --git a/src/lang/locale/ko.ts b/src/lang/locale/ko.ts index 2b4efd47..a86fac08 100644 --- a/src/lang/locale/ko.ts +++ b/src/lang/locale/ko.ts @@ -51,16 +51,27 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - 설정", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: '더 많은 정보를 원하시면, wiki를 확인해주세요.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "무시할 폴더들", - FOLDERS_TO_IGNORE_DESC: - `폴더 경로를 빈 줄로 구분해서 입력해주세요. 'Templates Meta/Scripts' 와 같이 입력하는 것은 유효하지 않습니다. + FOLDERS_TO_IGNORE_DESC: `폴더 경로를 빈 줄로 구분해서 입력해주세요. 'Templates Meta/Scripts' 와 같이 입력하는 것은 유효하지 않습니다. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "플래시카드", FLASHCARD_EASY_LABEL: "Easy Button Text", diff --git a/src/lang/locale/pl.ts b/src/lang/locale/pl.ts index f46a5140..735d2bd5 100644 --- a/src/lang/locale/pl.ts +++ b/src/lang/locale/pl.ts @@ -51,16 +51,27 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - Ustawienia", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'Aby uzyskać więcej informacji, sprawdź wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Foldery do zignorowania", - FOLDERS_TO_IGNORE_DESC: - `Wprowadź ścieżki folderów oddzielone nowymi liniami, np. Szablony Meta/Scripts. + FOLDERS_TO_IGNORE_DESC: `Wprowadź ścieżki folderów oddzielone nowymi liniami, np. Szablony Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Fiszki", FLASHCARD_EASY_LABEL: "Tekst przycisku Łatwe", diff --git a/src/lang/locale/pt-br.ts b/src/lang/locale/pt-br.ts index 4606a14e..354e9b46 100644 --- a/src/lang/locale/pt-br.ts +++ b/src/lang/locale/pt-br.ts @@ -53,16 +53,27 @@ export default { // settings.ts SETTINGS_HEADER: "Spaced Repetition - Configuração", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'Para mais informações, cheque a wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Pastas para ignorar", - FOLDERS_TO_IGNORE_DESC: - `Insira o caminho das pastas separado por quebras de linha ex: Templates Meta/Scripts. + FOLDERS_TO_IGNORE_DESC: `Insira o caminho das pastas separado por quebras de linha ex: Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Flashcards", FLASHCARD_EASY_LABEL: "Texto do Botão de Fácil", diff --git a/src/lang/locale/ru.ts b/src/lang/locale/ru.ts index de63e69d..cdfeea1d 100644 --- a/src/lang/locale/ru.ts +++ b/src/lang/locale/ru.ts @@ -60,16 +60,27 @@ export default { // settings.ts SETTINGS_HEADER: "Плагин Spaced Repetition - Настройки", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: 'Для дополнительной информации посетите: wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "Игнорируемые папки", - FOLDERS_TO_IGNORE_DESC: - `Укажите пути папок, каждый на своей строке, например: Templates Meta/Scripts. + FOLDERS_TO_IGNORE_DESC: `Укажите пути папок, каждый на своей строке, например: Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, FLASHCARDS: "Карточки", FLASHCARD_EASY_LABEL: 'Текст кнопки "Легко"', diff --git a/src/lang/locale/zh-cn.ts b/src/lang/locale/zh-cn.ts index 9fa5ef5a..78cbdf19 100644 --- a/src/lang/locale/zh-cn.ts +++ b/src/lang/locale/zh-cn.ts @@ -51,13 +51,25 @@ export default { // settings.ts SETTINGS_HEADER: "间隔重复插件 - 设置", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: '了解更多, 请点击wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "忽略此文件夹", FOLDERS_TO_IGNORE_DESC: `输入文件夹路径,用新建行分隔,例如:Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, diff --git a/src/lang/locale/zh-tw.ts b/src/lang/locale/zh-tw.ts index 75c80de6..dbc4d506 100644 --- a/src/lang/locale/zh-tw.ts +++ b/src/lang/locale/zh-tw.ts @@ -51,13 +51,25 @@ export default { // settings.ts SETTINGS_HEADER: "間隔重複外掛 - 設定", + GROUP_TAGS_FOLDERS: "Tags & Folders", + GROUP_FLASHCARD_REVIEW: "Flashcard Review", + GROUP_FLASHCARD_SEPARATORS: "Flashcard Separators", + GROUP_DATA_STORAGE: "Storage of Scheduling Data", + GROUP_FLASHCARDS_NOTES: "Flashcards & Notes", + GROUP_CONTRIBUTING: "Contributing", CHECK_WIKI: '瞭解更多, 請點選wiki.', - GITHUB_DISCUSSIONS: 'Visit the discussions section for Q&A help, feedback, and general discussion.', - GITHUB_ISSUES: 'Raise an issue here if you have a feature request or a bug-report.', - GITHUB_SOURCE_CODE: 'Project source code available on GitHub', - CODE_CONTRIBUTION_INFO: 'Information on code contributions', - TRANSLATION_CONTRIBUTION_INFO: 'Information on translating the plugin to your language', - PROJECT_CONTRIBUTIONS: 'Raise an issue here if you have a feature request or a bug-report', + GITHUB_DISCUSSIONS: + 'Visit the discussions section for Q&A help, feedback, and general discussion.', + GITHUB_ISSUES: + 'Raise an issue here if you have a feature request or a bug-report.', + GITHUB_SOURCE_CODE: + 'Project source code available on GitHub', + CODE_CONTRIBUTION_INFO: + 'Information on code contributions', + TRANSLATION_CONTRIBUTION_INFO: + 'Information on translating the plugin to your language', + PROJECT_CONTRIBUTIONS: + 'Raise an issue here if you have a feature request or a bug-report', FOLDERS_TO_IGNORE: "忽略此資料夾", FOLDERS_TO_IGNORE_DESC: `輸入資料夾路徑(用換行字元分隔),例如:Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, diff --git a/src/settings.ts b/src/settings.ts index 46de2002..e500ec16 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -152,32 +152,38 @@ export class SRSettingTab extends PluginSettingTab { "main-flashcards": { title: t("FLASHCARDS"), icon: null, // "SpacedRepIcon", - content_generator: (container_element: HTMLElement) => this.tabFlashcards(container_element), + content_generator: (container_element: HTMLElement) => + this.tabFlashcards(container_element), }, "main-notes": { title: t("NOTES"), icon: null, // "note-glyph", - content_generator: (container_element: HTMLElement) => this.tabNotes(container_element), + content_generator: (container_element: HTMLElement) => + this.tabNotes(container_element), }, "main-algorithm": { title: "Algorithm", icon: null, // "dot-network", - content_generator: (container_element: HTMLElement) => this.tabAlgorithm(container_element), + content_generator: (container_element: HTMLElement) => + this.tabAlgorithm(container_element), }, "main-ui-preferences": { title: t("UI_PREFERENCES"), icon: null, // "presentation", - content_generator: (container_element: HTMLElement) => this.tabUiPreferences(container_element), + content_generator: (container_element: HTMLElement) => + this.tabUiPreferences(container_element), }, "main-developer": { title: "Developer", icon: null, // "code-glyph", - content_generator: (container_element: HTMLElement) => this.tabDeveloper(container_element), + content_generator: (container_element: HTMLElement) => + this.tabDeveloper(container_element), }, "main-help": { title: "Help", icon: null, // "help", - content_generator: (container_element: HTMLElement) => this.tabHelp(container_element), + content_generator: (container_element: HTMLElement) => + this.tabHelp(container_element), }, }, this.last_position.tab_name, @@ -192,23 +198,21 @@ export class SRSettingTab extends PluginSettingTab { } private async tabFlashcards(containerEl: HTMLElement): Promise { - console.log(`tabFlashcards`); - - containerEl.createEl("h3", { text: `Tags & Folders` }); + containerEl.createEl("h3", { text: t("GROUP_TAGS_FOLDERS") }); { new Setting(containerEl) - .setName(t("FLASHCARD_TAGS")) - .setDesc(t("FLASHCARD_TAGS_DESC")) - .addTextArea((text) => - text - .setValue(this.plugin.data.settings.flashcardTags.join(" ")) - .onChange((value) => { - applySettingsUpdate(async () => { - this.plugin.data.settings.flashcardTags = value.split(/\s+/); - await this.plugin.savePluginData(); - }); - }), - ); + .setName(t("FLASHCARD_TAGS")) + .setDesc(t("FLASHCARD_TAGS_DESC")) + .addTextArea((text) => + text + .setValue(this.plugin.data.settings.flashcardTags.join(" ")) + .onChange((value) => { + applySettingsUpdate(async () => { + this.plugin.data.settings.flashcardTags = value.split(/\s+/); + await this.plugin.savePluginData(); + }); + }), + ); new Setting(containerEl) .setName(t("CONVERT_FOLDERS_TO_DECKS")) @@ -220,11 +224,11 @@ export class SRSettingTab extends PluginSettingTab { this.plugin.data.settings.convertFoldersToDecks = value; await this.plugin.savePluginData(); }), - ); + ); this.createSetting_FoldersToIgnore(containerEl); } - - containerEl.createEl("h3", { text: `Flashcard Review` }); + + containerEl.createEl("h3", { text: t("GROUP_FLASHCARD_REVIEW") }); { new Setting(containerEl) .setName(t("BURY_SIBLINGS_TILL_NEXT_DAY")) @@ -266,18 +270,18 @@ export class SRSettingTab extends PluginSettingTab { .addOptions( deckOrderEnabled ? { - PrevDeckComplete_Sequential: t( - "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_SEQUENTIAL", - ), - PrevDeckComplete_Random: t( - "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_RANDOM", - ), - } + PrevDeckComplete_Sequential: t( + "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_SEQUENTIAL", + ), + PrevDeckComplete_Random: t( + "REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_RANDOM", + ), + } : { - EveryCardRandomDeckAndCard: t( - "REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD", - ), - }, + EveryCardRandomDeckAndCard: t( + "REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD", + ), + }, ) .setValue( deckOrderEnabled @@ -292,16 +296,18 @@ export class SRSettingTab extends PluginSettingTab { ); } - containerEl.createEl("h3", { text: `Flashcard Separators` }); + containerEl.createEl("h3", { text: t("GROUP_FLASHCARD_SEPARATORS") }); { - new Setting(containerEl).setName(t("CONVERT_HIGHLIGHTS_TO_CLOZES")).addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.convertHighlightsToClozes) - .onChange(async (value) => { - this.plugin.data.settings.convertHighlightsToClozes = value; - await this.plugin.savePluginData(); - }), - ); + new Setting(containerEl) + .setName(t("CONVERT_HIGHLIGHTS_TO_CLOZES")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.convertHighlightsToClozes) + .onChange(async (value) => { + this.plugin.data.settings.convertHighlightsToClozes = value; + await this.plugin.savePluginData(); + }), + ); new Setting(containerEl).setName(t("CONVERT_BOLD_TEXT_TO_CLOZES")).addToggle((toggle) => toggle @@ -424,7 +430,7 @@ export class SRSettingTab extends PluginSettingTab { }); } - containerEl.createEl("h3", { text: `Storage of Scheduling Data` }); + containerEl.createEl("h3", { text: t("GROUP_DATA_STORAGE") }); { new Setting(containerEl) .setName(t("INLINE_SCHEDULING_COMMENTS")) @@ -441,7 +447,6 @@ export class SRSettingTab extends PluginSettingTab { } private async tabNotes(containerEl: HTMLElement): Promise { -console.log(`tabNotes`); containerEl.createEl("br"); new Setting(containerEl).setName(t("REVIEW_PANE_ON_STARTUP")).addToggle((toggle) => toggle @@ -557,8 +562,7 @@ console.log(`tabNotes`); } private async tabUiPreferences(containerEl: HTMLElement): Promise { - - containerEl.createEl("h3", { text: `Flashcards` }); + containerEl.createEl("h3", { text: t("FLASHCARDS") }); new Setting(containerEl) .setName(t("INITIALLY_EXPAND_SUBDECKS_IN_TREE")) .setDesc(t("INITIALLY_EXPAND_SUBDECKS_IN_TREE_DESC")) @@ -571,70 +575,70 @@ console.log(`tabNotes`); }), ); - new Setting(containerEl) - .setName(t("SHOW_CARD_CONTEXT")) - .setDesc(t("SHOW_CARD_CONTEXT_DESC")) - .addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.showContextInCards) - .onChange(async (value) => { - this.plugin.data.settings.showContextInCards = value; - await this.plugin.savePluginData(); - }), - ); + new Setting(containerEl) + .setName(t("SHOW_CARD_CONTEXT")) + .setDesc(t("SHOW_CARD_CONTEXT_DESC")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.showContextInCards) + .onChange(async (value) => { + this.plugin.data.settings.showContextInCards = value; + await this.plugin.savePluginData(); + }), + ); - new Setting(containerEl) - .setName(t("CARD_MODAL_HEIGHT_PERCENT")) - .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) - .addSlider((slider) => - slider - .setLimits(10, 100, 5) - .setValue(this.plugin.data.settings.flashcardHeightPercentage) - .setDynamicTooltip() - .onChange(async (value) => { - this.plugin.data.settings.flashcardHeightPercentage = value; - await this.plugin.savePluginData(); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.flashcardHeightPercentage = - DEFAULT_SETTINGS.flashcardHeightPercentage; - await this.plugin.savePluginData(); - this.display(); - }); - }); + new Setting(containerEl) + .setName(t("CARD_MODAL_HEIGHT_PERCENT")) + .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) + .addSlider((slider) => + slider + .setLimits(10, 100, 5) + .setValue(this.plugin.data.settings.flashcardHeightPercentage) + .setDynamicTooltip() + .onChange(async (value) => { + this.plugin.data.settings.flashcardHeightPercentage = value; + await this.plugin.savePluginData(); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.flashcardHeightPercentage = + DEFAULT_SETTINGS.flashcardHeightPercentage; + await this.plugin.savePluginData(); + this.display(); + }); + }); - new Setting(containerEl) - .setName(t("CARD_MODAL_WIDTH_PERCENT")) - .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) - .addSlider((slider) => - slider - .setLimits(10, 100, 5) - .setValue(this.plugin.data.settings.flashcardWidthPercentage) - .setDynamicTooltip() - .onChange(async (value) => { - this.plugin.data.settings.flashcardWidthPercentage = value; - await this.plugin.savePluginData(); - }), - ) - .addExtraButton((button) => { - button - .setIcon("reset") - .setTooltip(t("RESET_DEFAULT")) - .onClick(async () => { - this.plugin.data.settings.flashcardWidthPercentage = - DEFAULT_SETTINGS.flashcardWidthPercentage; - await this.plugin.savePluginData(); - this.display(); - }); - }); + new Setting(containerEl) + .setName(t("CARD_MODAL_WIDTH_PERCENT")) + .setDesc(t("CARD_MODAL_SIZE_PERCENT_DESC")) + .addSlider((slider) => + slider + .setLimits(10, 100, 5) + .setValue(this.plugin.data.settings.flashcardWidthPercentage) + .setDynamicTooltip() + .onChange(async (value) => { + this.plugin.data.settings.flashcardWidthPercentage = value; + await this.plugin.savePluginData(); + }), + ) + .addExtraButton((button) => { + button + .setIcon("reset") + .setTooltip(t("RESET_DEFAULT")) + .onClick(async () => { + this.plugin.data.settings.flashcardWidthPercentage = + DEFAULT_SETTINGS.flashcardWidthPercentage; + await this.plugin.savePluginData(); + this.display(); + }); + }); - containerEl.createEl("h3", { text: `Flashcards & Notes` }); - new Setting(containerEl) + containerEl.createEl("h3", { text: t("GROUP_FLASHCARDS_NOTES") }); + new Setting(containerEl) .setName(t("FLASHCARD_EASY_LABEL")) .setDesc(t("FLASHCARD_EASY_DESC")) .addText((text) => @@ -705,10 +709,12 @@ console.log(`tabNotes`); } private async tabAlgorithm(containerEl: HTMLElement): Promise { - - containerEl.createEl("p").insertAdjacentHTML("beforeend", t("CHECK_ALGORITHM_WIKI", { - algo_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", - })); + containerEl.createEl("p").insertAdjacentHTML( + "beforeend", + t("CHECK_ALGORITHM_WIKI", { + algo_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", + }), + ); new Setting(containerEl) .setName(t("BASE_EASE")) @@ -869,7 +875,6 @@ console.log(`tabNotes`); } private async tabDeveloper(containerEl: HTMLElement): Promise { - containerEl.createEl("h3", { text: `${t("LOGGING")}` }); new Setting(containerEl).setName(t("DISPLAY_DEBUG_INFO")).addToggle((toggle) => toggle.setValue(this.plugin.data.settings.showDebugMessages).onChange(async (value) => { @@ -877,34 +882,53 @@ console.log(`tabNotes`); await this.plugin.savePluginData(); }), ); - containerEl.createEl("h3", { text: `Contributing` }); - containerEl.createEl("p").insertAdjacentHTML("beforeend", t("GITHUB_SOURCE_CODE", { - github_project_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition", - })); - containerEl.createEl("p").insertAdjacentHTML("beforeend", t("CODE_CONTRIBUTION_INFO", { - code_contribution_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/contributing/#code", - })); - containerEl.createEl("p").insertAdjacentHTML("beforeend", t("TRANSLATION_CONTRIBUTION_INFO", { - translation_contribution_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/contributing/#translating", - })); - + containerEl.createEl("h3", { text: t("GROUP_CONTRIBUTING") }); + containerEl.createEl("p").insertAdjacentHTML( + "beforeend", + t("GITHUB_SOURCE_CODE", { + github_project_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition", + }), + ); + containerEl.createEl("p").insertAdjacentHTML( + "beforeend", + t("CODE_CONTRIBUTION_INFO", { + code_contribution_url: + "https://www.stephenmwangi.com/obsidian-spaced-repetition/contributing/#code", + }), + ); + containerEl.createEl("p").insertAdjacentHTML( + "beforeend", + t("TRANSLATION_CONTRIBUTION_INFO", { + translation_contribution_url: + "https://www.stephenmwangi.com/obsidian-spaced-repetition/contributing/#translating", + }), + ); } private async tabHelp(containerEl: HTMLElement): Promise { - // Documentation link & GitHub links - containerEl.createEl("p").insertAdjacentHTML("beforeend", t("CHECK_WIKI", { - wiki_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", - })); - - containerEl.createEl("p").insertAdjacentHTML("beforeend", t("GITHUB_DISCUSSIONS", { - discussions_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition/discussions/", - })); - - containerEl.createEl("p").insertAdjacentHTML("beforeend", t("GITHUB_ISSUES", { - issues_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition/issues/", - })); -/* + containerEl.createEl("p").insertAdjacentHTML( + "beforeend", + t("CHECK_WIKI", { + wiki_url: "https://www.stephenmwangi.com/obsidian-spaced-repetition/", + }), + ); + + containerEl.createEl("p").insertAdjacentHTML( + "beforeend", + t("GITHUB_DISCUSSIONS", { + discussions_url: + "https://github.com/st3v3nmw/obsidian-spaced-repetition/discussions/", + }), + ); + + containerEl.createEl("p").insertAdjacentHTML( + "beforeend", + t("GITHUB_ISSUES", { + issues_url: "https://github.com/st3v3nmw/obsidian-spaced-repetition/issues/", + }), + ); + /* // Documentation link & GitHub links containerEl.createEl("hr").insertAdjacentHTML("beforeend"); @@ -929,21 +953,21 @@ console.log(`tabNotes`); // Go to last position now this.tab_structure.buttons[last_position.tab_name].click(); // window.setTimeout(() => { // Need to delay the scrolling a bit. Without this, something else would override scrolling and scroll back to 0. - container_element.scrollTo({ - top: this.last_position.scroll_position, - behavior: "auto", - }); + container_element.scrollTo({ + top: this.last_position.scroll_position, + behavior: "auto", + }); // }, 0); // 'timeout' can be 0 ms, no need to wait any longer. // I guess there's no need for setTimeout() anymore, as rememberLastPosition() is now called after waiting for asynchronous tab content generating is finished. // TODO: Remove the commented code after a while. // Listen to changes - container_element.addEventListener("scroll", (event) => { + container_element.addEventListener("scroll", (_) => { this.last_position.scroll_position = container_element.scrollTop; }); for (const tab_name in this.tab_structure.buttons) { const button = this.tab_structure.buttons[tab_name]; - button.onClickEvent((event: MouseEvent) => { + button.onClickEvent((_: MouseEvent) => { last_position.tab_name = tab_name; }); } diff --git a/styles.css b/styles.css index 4329ee1d..6646f08a 100644 --- a/styles.css +++ b/styles.css @@ -336,4 +336,3 @@ button.sr-tab-header-button:hover { .sr-tab-content.sr-tab-active { display: block; } - From 70b06c3bb1afb66da671166834a8d3652835fed3 Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:30:12 +1000 Subject: [PATCH 7/8] changelog update --- docs/changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index a740e670..da0447c8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [Unreleased] +- [FEAT] Split the long list of options into categories within a tab control https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1021 + #### [1.12.4](https://github.com/st3v3nmw/obsidian-spaced-repetition/compare/1.12.3...1.12.4) - chore: fix package manager issue in CI [`#939`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/939) From d56c41f6bc403afc51d09a781f79510d77fb51e9 Mon Sep 17 00:00:00 2001 From: ronzulu <75528127+ronzulu@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:32:05 +1000 Subject: [PATCH 8/8] changelog.md --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index da0447c8..b5c7237b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### [Unreleased] + - [FEAT] Split the long list of options into categories within a tab control https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/1021 #### [1.12.4](https://github.com/st3v3nmw/obsidian-spaced-repetition/compare/1.12.3...1.12.4)