-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.ts
233 lines (205 loc) · 7.97 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import { App, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
export default class Hider extends Plugin {
settings: HiderSettings;
async onload() {
// load settings
await this.loadSettings();
// add the settings tab
this.addSettingTab(new HiderSettingTab(this.app, this));
// add the toggle on/off command
this.addCommand({
id: 'toggle-tab-containers',
name: 'Toggle tab bar',
callback: () => {
this.settings.hideTabs = !this.settings.hideTabs;
this.saveData(this.settings);
this.refresh();
}
});
this.addCommand({
id: 'toggle-hider-status',
name: 'Toggle status bar',
callback: () => {
this.settings.hideStatus = !this.settings.hideStatus;
this.saveData(this.settings);
this.refresh();
}
});
this.refresh()
}
onunload() {
console.log('Unloading Hider plugin');
}
async loadSettings() {
this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData());
}
async saveSettings() {
await this.saveData(this.settings);
}
// refresh function for when we change settings
refresh = () => {
// re-load the style
this.updateStyle()
}
// update the styles (at the start, or as the result of a settings change)
updateStyle = () => {
document.body.classList.toggle('hider-status', this.settings.hideStatus);
document.body.classList.toggle('hider-tabs', this.settings.hideTabs);
document.body.classList.toggle('hider-scroll', this.settings.hideScroll);
document.body.classList.toggle('hider-sidebar-buttons', this.settings.hideSidebarButtons);
document.body.classList.toggle('hider-tooltips', this.settings.hideTooltips);
document.body.classList.toggle('hider-search-suggestions', this.settings.hideSearchSuggestions);
document.body.classList.toggle('hider-file-nav-header', this.settings.hideFileNavButtons);
document.body.classList.toggle('hider-search-counts', this.settings.hideSearchCounts);
document.body.classList.toggle('hider-instructions', this.settings.hideInstructions);
document.body.classList.toggle('hider-meta', this.settings.hidePropertiesReading);
document.body.classList.toggle('hider-vault', this.settings.hideVault);
}
}
interface HiderSettings {
hideStatus: boolean;
hideTabs: boolean;
hideScroll: boolean;
hideSidebarButtons: boolean;
hideTooltips: boolean;
hideFileNavButtons: boolean;
hideSearchSuggestions: boolean;
hideSearchCounts: boolean;
hideInstructions: boolean;
hidePropertiesReading: boolean;
hideVault: boolean;
}
const DEFAULT_SETTINGS: HiderSettings = {
hideStatus: false,
hideTabs: false,
hideScroll: false,
hideSidebarButtons: false,
hideTooltips: false,
hideFileNavButtons: false,
hideSearchSuggestions: false,
hideSearchCounts: false,
hideInstructions: false,
hidePropertiesReading: false,
hideVault: false
}
class HiderSettingTab extends PluginSettingTab {
plugin: Hider;
constructor(app: App, plugin: Hider) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
let {containerEl} = this;
containerEl.empty();
new Setting(containerEl)
.setName('Hide tab bar')
.setDesc('Hides the tab container at the top of the window.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideTabs)
.onChange((value) => {
this.plugin.settings.hideTabs = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide status bar')
.setDesc('Hides word count, character count and backlink count.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideStatus)
.onChange((value) => {
this.plugin.settings.hideStatus = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide vault name')
.setDesc('Hides your vault profile. Warning: this also hides access to the Settings and vault switcher icons. You can use hotkeys or the command palette to open them.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideVault)
.onChange((value) => {
this.plugin.settings.hideVault = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide scroll bars')
.setDesc('Hides all scroll bars.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideScroll)
.onChange((value) => {
this.plugin.settings.hideScroll = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide sidebar toggle buttons')
.setDesc('Hides both sidebar buttons.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideSidebarButtons)
.onChange((value) => {
this.plugin.settings.hideSidebarButtons = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide tooltips')
.setDesc('Hides all tooltips.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideTooltips)
.onChange((value) => {
this.plugin.settings.hideTooltips = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide file explorer buttons')
.setDesc('Hides buttons at the top of file explorer (new file, new folder, etc).')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideFileNavButtons)
.onChange((value) => {
this.plugin.settings.hideFileNavButtons = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide instructions')
.setDesc('Hides instructional tips in modals.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideInstructions)
.onChange((value) => {
this.plugin.settings.hideInstructions = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide search suggestions')
.setDesc('Hides suggestions in search pane.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideSearchSuggestions)
.onChange((value) => {
this.plugin.settings.hideSearchSuggestions = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide count of search term matches')
.setDesc('Hides the number of matches within each search result.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideSearchCounts)
.onChange((value) => {
this.plugin.settings.hideSearchCounts = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
new Setting(containerEl)
.setName('Hide properties in Reading view')
.setDesc('Hides the properties section in Reading view.')
.addToggle(toggle => toggle.setValue(this.plugin.settings.hidePropertiesReading)
.onChange((value) => {
this.plugin.settings.hidePropertiesReading = value;
this.plugin.saveData(this.plugin.settings);
this.plugin.refresh();
})
);
}
}