generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.ts
44 lines (36 loc) · 1.41 KB
/
settings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { App, PluginSettingTab, Setting } from 'obsidian';
import UrlExpanderPlugin from './main';
export interface UrlExpanderPluginSettings {
mySetting: string;
contextMenu: boolean;
}
export const DEFAULT_SETTINGS: UrlExpanderPluginSettings = {
mySetting: 'default',
contextMenu: true
};
export class UrlExpanderSettingsTab extends PluginSettingTab {
plugin: UrlExpanderPlugin;
constructor(app: App, plugin: UrlExpanderPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl('h2', { text: 'Obsidian URL Expander' });
new Setting(containerEl)
.setName('File Context Menu')
.setDesc("Turn this option off if you don't want single file commands to appear within the file context menu")
.addToggle((toggle) => {
toggle.setValue(this.plugin.settings.contextMenu).onChange((newVal) => {
this.plugin.settings.contextMenu = newVal;
this.plugin.saveSettings();
if (newVal) {
this.plugin.app.workspace.on('file-menu', this.plugin.addFileMenuItems);
} else {
this.plugin.app.workspace.off('file-menu', this.plugin.addFileMenuItems);
}
});
});
}
}