Mercurial > obsidian-remember-file-state
annotate src/settings.ts @ 35:42ff65e35f4f
More standardized logging.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 14 Aug 2023 10:42:04 -0700 |
parents | 815b93d13e0f |
children | 7e981d54a055 |
rev | line source |
---|---|
0 | 1 import { |
21
815b93d13e0f
Improve typescript compliance
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
2 App, |
0 | 3 PluginSettingTab, |
4 Setting | |
5 } from 'obsidian'; | |
6 | |
21
815b93d13e0f
Improve typescript compliance
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
7 import RememberFileStatePlugin from './main'; |
0 | 8 |
9 export interface RememberFileStatePluginSettings { | |
10 rememberMaxFiles: number; | |
11 } | |
12 | |
13 export const DEFAULT_SETTINGS: RememberFileStatePluginSettings = { | |
14 // Matches the number of files Obsidian remembers the undo/redo | |
15 // history for by default (at least as of 0.13.17). | |
16 rememberMaxFiles: 20 | |
17 } | |
18 | |
19 export class RememberFileStatePluginSettingTab extends PluginSettingTab { | |
20 plugin: RememberFileStatePlugin; | |
21 | |
22 constructor(app: App, plugin: RememberFileStatePlugin) { | |
23 super(app, plugin); | |
24 this.plugin = plugin; | |
25 } | |
26 | |
27 display(): void { | |
28 const {containerEl} = this; | |
29 | |
30 containerEl.empty(); | |
31 | |
32 new Setting(containerEl) | |
33 .setName('Remember files') | |
34 .setDesc('How many files to remember at most') | |
35 .addText(text => text | |
21
815b93d13e0f
Improve typescript compliance
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
36 .setValue(this.plugin.settings.rememberMaxFiles?.toString()) |
815b93d13e0f
Improve typescript compliance
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
37 .onChange(async (value: string) => { |
0 | 38 const intValue = parseInt(value); |
39 if (!isNaN(intValue)) { | |
40 this.plugin.settings.rememberMaxFiles = intValue; | |
41 await this.plugin.saveSettings(); | |
42 } | |
21
815b93d13e0f
Improve typescript compliance
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
43 })); |
0 | 44 } |
45 } |