2022-08-24 16:29:06 +08:00
'use strict' ;
var obsidian = require ( 'obsidian' ) ;
2024-06-12 15:46:38 +08:00
/ * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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 ( ) ) ;
} ) ;
2022-08-24 16:29:06 +08:00
}
2023-07-14 11:06:08 +08:00
class Hider extends obsidian . Plugin {
constructor ( ) {
super ( ... arguments ) ;
2022-08-24 16:29:06 +08:00
// refresh function for when we change settings
2023-07-14 11:06:08 +08:00
this . refresh = ( ) => {
2022-08-24 16:29:06 +08:00
// re-load the style
2023-07-14 11:06:08 +08:00
this . updateStyle ( ) ;
2022-08-24 16:29:06 +08:00
} ;
// update the styles (at the start, or as the result of a settings change)
2023-07-14 11:06:08 +08:00
this . 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 ) ;
2023-09-05 17:29:16 +08:00
document . body . classList . toggle ( 'hider-meta' , this . settings . hidePropertiesReading ) ;
2023-07-14 11:06:08 +08:00
document . body . classList . toggle ( 'hider-vault' , this . settings . hideVault ) ;
2022-08-24 16:29:06 +08:00
} ;
}
2023-07-14 11:06:08 +08:00
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 ( ) ;
2022-08-24 16:29:06 +08:00
}
} ) ;
2023-07-14 11:06:08 +08:00
this . addCommand ( {
id : 'toggle-hider-status' ,
name : 'Toggle status bar' ,
callback : ( ) => {
this . settings . hideStatus = ! this . settings . hideStatus ;
this . saveData ( this . settings ) ;
this . refresh ( ) ;
2022-08-24 16:29:06 +08:00
}
} ) ;
2023-07-14 11:06:08 +08:00
this . refresh ( ) ;
2022-08-24 16:29:06 +08:00
} ) ;
2023-07-14 11:06:08 +08:00
}
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 = {
2022-08-24 16:29:06 +08:00
hideStatus : false ,
2022-10-15 17:08:29 +08:00
hideTabs : false ,
2022-08-24 16:29:06 +08:00
hideScroll : false ,
2022-10-15 17:08:29 +08:00
hideSidebarButtons : false ,
2022-08-24 16:29:06 +08:00
hideTooltips : false ,
2023-07-14 11:06:08 +08:00
hideFileNavButtons : false ,
2022-08-24 16:29:06 +08:00
hideSearchSuggestions : false ,
2022-10-15 17:08:29 +08:00
hideSearchCounts : false ,
2022-08-24 16:29:06 +08:00
hideInstructions : false ,
2023-09-05 17:29:16 +08:00
hidePropertiesReading : false ,
2022-08-24 16:29:06 +08:00
hideVault : false
} ;
2023-07-14 11:06:08 +08:00
class HiderSettingTab extends obsidian . PluginSettingTab {
constructor ( app , plugin ) {
super ( app , plugin ) ;
this . plugin = plugin ;
2022-08-24 16:29:06 +08:00
}
2023-07-14 11:06:08 +08:00
display ( ) {
let { containerEl } = this ;
2022-08-24 16:29:06 +08:00
containerEl . empty ( ) ;
new obsidian . Setting ( containerEl )
2022-10-15 17:08:29 +08:00
. setName ( 'Hide tab bar' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides the tab container at the top of the window.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideTabs )
. onChange ( ( value ) => {
this . plugin . settings . hideTabs = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-08-24 16:29:06 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide status bar' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides word count, character count and backlink count.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideStatus )
. onChange ( ( value ) => {
this . plugin . settings . hideStatus = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-08-24 16:29:06 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide vault name' )
2024-06-12 15:46:38 +08:00
. 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.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideVault )
. onChange ( ( value ) => {
this . plugin . settings . hideVault = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-08-24 16:29:06 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide scroll bars' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides all scroll bars.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideScroll )
. onChange ( ( value ) => {
this . plugin . settings . hideScroll = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-10-15 17:08:29 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide sidebar toggle buttons' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides both sidebar buttons.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideSidebarButtons )
. onChange ( ( value ) => {
this . plugin . settings . hideSidebarButtons = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-08-24 16:29:06 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide tooltips' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides all tooltips.' )
2023-07-14 11:06:08 +08:00
. 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' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides buttons at the top of file explorer (new file, new folder, etc).' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideFileNavButtons )
. onChange ( ( value ) => {
this . plugin . settings . hideFileNavButtons = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-08-24 16:29:06 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide instructions' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides instructional tips in modals.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideInstructions )
. onChange ( ( value ) => {
this . plugin . settings . hideInstructions = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-08-24 16:29:06 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide search suggestions' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides suggestions in search pane.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideSearchSuggestions )
. onChange ( ( value ) => {
this . plugin . settings . hideSearchSuggestions = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-10-15 17:08:29 +08:00
new obsidian . Setting ( containerEl )
. setName ( 'Hide count of search term matches' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides the number of matches within each search result.' )
2023-07-14 11:06:08 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hideSearchCounts )
. onChange ( ( value ) => {
this . plugin . settings . hideSearchCounts = value ;
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
2022-08-24 16:29:06 +08:00
new obsidian . Setting ( containerEl )
2023-09-05 17:29:16 +08:00
. setName ( 'Hide properties in Reading view' )
2024-06-12 15:46:38 +08:00
. setDesc ( 'Hides the properties section in Reading view.' )
2023-09-05 17:29:16 +08:00
. addToggle ( toggle => toggle . setValue ( this . plugin . settings . hidePropertiesReading )
2023-07-14 11:06:08 +08:00
. onChange ( ( value ) => {
2023-09-05 17:29:16 +08:00
this . plugin . settings . hidePropertiesReading = value ;
2023-07-14 11:06:08 +08:00
this . plugin . saveData ( this . plugin . settings ) ;
this . plugin . refresh ( ) ;
} ) ) ;
}
}
2022-08-24 16:29:06 +08:00
module . exports = Hider ;
2024-06-12 15:46:38 +08:00
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZXMiOlsibm9kZV9tb2R1bGVzL3RzbGliL3RzbGliLmVzNi5qcyIsIm1haW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyohICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqXHJcbkNvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLlxyXG5cclxuUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55XHJcbnB1cnBvc2Ugd2l0aCBvciB3aXRob3V0IGZlZSBpcyBoZXJlYnkgZ3JhbnRlZC5cclxuXHJcblRIRSBTT0ZUV0FSRSBJUyBQUk9WSURFRCBc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