Mercurial > obsidian-remember-file-state
diff src/settings.ts @ 0:7975d7c73f8a 1.0.0
Initial commit
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 08 Feb 2022 21:40:33 -0800 |
parents | |
children | 815b93d13e0f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/settings.ts Tue Feb 08 21:40:33 2022 -0800 @@ -0,0 +1,46 @@ +import { + PluginSettingTab, + Setting +} from 'obsidian'; + +import { + RememberFileStatePlugin +} from './main' + +export interface RememberFileStatePluginSettings { + rememberMaxFiles: number; +} + +export const DEFAULT_SETTINGS: RememberFileStatePluginSettings = { + // Matches the number of files Obsidian remembers the undo/redo + // history for by default (at least as of 0.13.17). + rememberMaxFiles: 20 +} + +export class RememberFileStatePluginSettingTab extends PluginSettingTab { + plugin: RememberFileStatePlugin; + + constructor(app: App, plugin: RememberFileStatePlugin) { + super(app, plugin); + this.plugin = plugin; + } + + display(): void { + const {containerEl} = this; + + containerEl.empty(); + + new Setting(containerEl) + .setName('Remember files') + .setDesc('How many files to remember at most') + .addText(text => text + .setValue(this.plugin.settings.rememberMaxFiles?.toString())) + .onChange(async (value) => { + const intValue = parseInt(value); + if (!isNaN(intValue)) { + this.plugin.settings.rememberMaxFiles = intValue; + await this.plugin.saveSettings(); + } + }); + } +}