diff --git a/src/codeFilesSettingsTab.ts b/src/codeFilesSettingsTab.ts index c61a322..4a8ed5d 100644 --- a/src/codeFilesSettingsTab.ts +++ b/src/codeFilesSettingsTab.ts @@ -1,5 +1,6 @@ import { App, PluginSettingTab, Setting } from "obsidian"; import CodeFilesPlugin from "./codeFilesPlugin"; +import { themes } from "./themes"; export class CodeFilesSettingsTab extends PluginSettingTab { plugin: CodeFilesPlugin; @@ -15,6 +16,44 @@ export class CodeFilesSettingsTab extends PluginSettingTab { containerEl.empty(); containerEl.createEl("h2", { text: "Code Files Settings" }); + containerEl.createEl("p", { + text: "If you change any settings, you need to reopen already opened files for the changes to take effect.", + }); + + new Setting(containerEl) + .setName("Theme") + .setDesc( + "Theme of the editor, defaults to dark or light based on the current editor theme." + ) + .addDropdown((dropdown) => { + dropdown.addOption("default", "Default"); + for (const theme of themes) { + dropdown.addOption(theme, theme); + } + + return dropdown + .setValue(this.plugin.settings.theme) + .onChange(async (value) => { + this.plugin.settings.theme = value; + await this.plugin.saveSettings(); + }); + }); + + new Setting(containerEl) + .setName("Overwrite background with Obsidian background") + .setDesc( + "Always use the background of Obsidian as background, instead of the theme default background." + + " It's recommended to turn this off if you are using" + + " custom themes. Disable this if the text colors are illegible on Obsidians background." + ) + .addToggle((toggle) => + toggle + .setValue(this.plugin.settings.overwriteBg) + .onChange((v) => { + this.plugin.settings.overwriteBg = v; + this.plugin.saveSettings(); + }) + ); new Setting(containerEl) .setName("File Extensions")