240 lines
49 KiB
JavaScript
240 lines
49 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
var obsidian = require('obsidian');
|
||
|
|
||
|
/*! *****************************************************************************
|
||
|
Copyright (c) Microsoft Corporation.
|
||
|
|
||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||
|
purpose with or without fee is hereby granted.
|
||
|
|
||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||
|
PERFORMANCE OF THIS SOFTWARE.
|
||
|
***************************************************************************** */
|
||
|
|
||
|
function __awaiter(thisArg, _arguments, P, generator) {
|
||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
}
|
||
|
|
||
|
class Hider extends obsidian.Plugin {
|
||
|
constructor() {
|
||
|
super(...arguments);
|
||
|
// refresh function for when we change settings
|
||
|
this.refresh = () => {
|
||
|
// re-load the style
|
||
|
this.updateStyle();
|
||
|
};
|
||
|
// update the styles (at the start, or as the result of a settings change)
|
||
|
this.updateStyle = () => {
|
||
|
document.body.classList.toggle('hider-ribbon', this.settings.hideRibbon);
|
||
|
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);
|
||
|
};
|
||
|
}
|
||
|
onload() {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
// load settings
|
||
|
yield 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-app-ribbon',
|
||
|
name: 'Toggle app ribbon',
|
||
|
callback: () => {
|
||
|
this.settings.hideRibbon = !this.settings.hideRibbon;
|
||
|
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');
|
||
|
}
|
||
|
loadSettings() {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
this.settings = Object.assign(DEFAULT_SETTINGS, yield this.loadData());
|
||
|
});
|
||
|
}
|
||
|
saveSettings() {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
yield this.saveData(this.settings);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
const DEFAULT_SETTINGS = {
|
||
|
hideRibbon: false,
|
||
|
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 obsidian.PluginSettingTab {
|
||
|
constructor(app, plugin) {
|
||
|
super(app, plugin);
|
||
|
this.plugin = plugin;
|
||
|
}
|
||
|
display() {
|
||
|
let { containerEl } = this;
|
||
|
containerEl.empty();
|
||
|
new obsidian.Setting(containerEl)
|
||
|
.setName('Hide app ribbon')
|
||
|
.setDesc('Hides the Obsidian menu. Warning: to open Settings you will need use the hotkey (default is CMD + ,)')
|
||
|
.addToggle(toggle => toggle.setValue(this.plugin.settings.hideRibbon)
|
||
|
.onChange((value) => {
|
||
|
this.plugin.settings.hideRibbon = value;
|
||
|
this.plugin.saveData(this.plugin.settings);
|
||
|
this.plugin.refresh();
|
||
|
}));
|
||
|
new obsidian.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 obsidian.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 obsidian.Setting(containerEl)
|
||
|
.setName('Hide vault name')
|
||
|
.setDesc('Hides the root folder name')
|
||
|
.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 obsidian.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 obsidian.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 obsidian.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 obsidian.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 obsidian.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 obsidian.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 obsidian.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 obsidian.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();
|
||
|
}));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = Hider;
|
||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZXMiOlsibm9kZV9tb2R1bGVzL3RzbGliL3RzbGliLmVzNi5qcyIsIm1haW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyohICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqXHJcbkNvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLlxyXG5cclxuUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55XHJcbnB1cnBvc2Ugd2l0aCBvciB3aXRob3V0IGZlZSBpcyBoZXJlYnkgZ3JhbnRlZC5cclxuXHJcblRIRSBTT0ZUV0FSRSBJUyBQUk9WSURFRCBcIkFTIElTXCIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEhcclxuUkVHQVJEIFRPIFRISVMgU09GVFdBUkUgSU5DTFVESU5HIEFMTCBJTVBMSUVEIFdBUlJBTlRJRVMgT0YgTUVSQ0hBTlRBQklMSVRZXHJcbkFORCBGSVRORVNTLiBJTiBOTyBFVkVOVCBTSEFMTCBUSEUgQVVUSE9SIEJFIExJQUJMRSBGT1IgQU5ZIFNQRUNJQUwsIERJUkVDVCxcclxuSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NXHJcbkxPU1MgT0YgVVNFLCBEQVRBIE9SIFBST0ZJVFMsIF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