0
|
1 import {
|
|
2 PluginSettingTab,
|
|
3 Setting
|
|
4 } from 'obsidian';
|
|
5
|
|
6 import {
|
|
7 RememberFileStatePlugin
|
|
8 } from './main'
|
|
9
|
|
10 export interface RememberFileStatePluginSettings {
|
|
11 rememberMaxFiles: number;
|
|
12 }
|
|
13
|
|
14 export const DEFAULT_SETTINGS: RememberFileStatePluginSettings = {
|
|
15 // Matches the number of files Obsidian remembers the undo/redo
|
|
16 // history for by default (at least as of 0.13.17).
|
|
17 rememberMaxFiles: 20
|
|
18 }
|
|
19
|
|
20 export class RememberFileStatePluginSettingTab extends PluginSettingTab {
|
|
21 plugin: RememberFileStatePlugin;
|
|
22
|
|
23 constructor(app: App, plugin: RememberFileStatePlugin) {
|
|
24 super(app, plugin);
|
|
25 this.plugin = plugin;
|
|
26 }
|
|
27
|
|
28 display(): void {
|
|
29 const {containerEl} = this;
|
|
30
|
|
31 containerEl.empty();
|
|
32
|
|
33 new Setting(containerEl)
|
|
34 .setName('Remember files')
|
|
35 .setDesc('How many files to remember at most')
|
|
36 .addText(text => text
|
|
37 .setValue(this.plugin.settings.rememberMaxFiles?.toString()))
|
|
38 .onChange(async (value) => {
|
|
39 const intValue = parseInt(value);
|
|
40 if (!isNaN(intValue)) {
|
|
41 this.plugin.settings.rememberMaxFiles = intValue;
|
|
42 await this.plugin.saveSettings();
|
|
43 }
|
|
44 });
|
|
45 }
|
|
46 }
|