style: tab according obsidian recommandation for plugins
Easier reading
This commit is contained in:
parent
aa19795ec5
commit
d767bbb31d
6 changed files with 76 additions and 69 deletions
|
|
@ -3,7 +3,8 @@ import FileHider from "../main";
|
|||
// The command used to toggle the visibility.
|
||||
export class VisibilityToggleCommand {
|
||||
constructor(plugin: FileHider) {
|
||||
plugin.addCommand({
|
||||
plugin
|
||||
.addCommand({
|
||||
id: 'oa-fh-toggle-visibility',
|
||||
name: 'Toggle Visibility',
|
||||
callback: () => {
|
||||
|
|
|
|||
17
src/main.ts
17
src/main.ts
|
|
@ -21,18 +21,21 @@ export default class FileHider extends Plugin {
|
|||
async onload() {
|
||||
|
||||
await this.loadSettings();
|
||||
console.log('FileHider loaded');
|
||||
this.registerEvent(
|
||||
this.app.workspace.on(`file-menu`, (menu, file) => {
|
||||
if (file instanceof TFolder) {
|
||||
menu.addItem((i) => {
|
||||
if (this.settings.hiddenList.includes(file.path)) {
|
||||
i.setTitle(`Unhide Folder`)
|
||||
i
|
||||
.setTitle(`Unhide Folder`)
|
||||
.setIcon(`eye`)
|
||||
.onClick(() => {
|
||||
this.unhidePath(file.path);
|
||||
});
|
||||
} else {
|
||||
i.setTitle(`Hide Folder`)
|
||||
i
|
||||
.setTitle(`Hide Folder`)
|
||||
.setIcon(`eye-off`)
|
||||
.onClick(() => {
|
||||
changePathVisibility(file.path, this.settings.hidden);
|
||||
|
|
@ -44,13 +47,15 @@ export default class FileHider extends Plugin {
|
|||
} else {
|
||||
menu.addItem((i) => {
|
||||
if (this.settings.hiddenList.includes(file.path)) {
|
||||
i.setTitle(`Unhide File`)
|
||||
i
|
||||
.setTitle(`Unhide File`)
|
||||
.setIcon(`eye`)
|
||||
.onClick(() => {
|
||||
this.unhidePath(file.path);
|
||||
});
|
||||
} else {
|
||||
i.setTitle(`Hide File`)
|
||||
i
|
||||
.setTitle(`Hide File`)
|
||||
.setIcon(`eye-off`)
|
||||
.onClick(() => {
|
||||
changePathVisibility(file.path, this.settings.hidden);
|
||||
|
|
@ -65,9 +70,9 @@ export default class FileHider extends Plugin {
|
|||
|
||||
|
||||
this.app.workspace.onLayoutReady(async () => {
|
||||
await sleep(50)
|
||||
await sleep(50);
|
||||
for (const path of this.settings.hiddenList) {
|
||||
await changePathVisibility(path, this.settings.hidden);
|
||||
changePathVisibility(path, this.settings.hidden);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ export class HiddenPathsModal extends Modal {
|
|||
new Setting(c)
|
||||
.setName(path)
|
||||
.addButton(btn => {
|
||||
btn.setIcon(`cross`)
|
||||
btn
|
||||
.setIcon(`cross`)
|
||||
.setTooltip(`Remove`)
|
||||
.onClick((e) => {
|
||||
.onClick(() => {
|
||||
this.plugin.unhidePath(path);
|
||||
c.hide();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ export class VisibilityToggleSetting {
|
|||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ export class ManageHiddenPaths {
|
|||
.setName(`Hidden Files and Folders`)
|
||||
.setDesc(`Add or remove files and folders from the list that are being hidden`)
|
||||
.addButton(b => {
|
||||
b.setButtonText(`Manage`)
|
||||
b
|
||||
.setButtonText(`Manage`)
|
||||
.onClick(event => {
|
||||
// sanity check to prevent other code from opening the modal
|
||||
if (!event.isTrusted) { return }
|
||||
|
||||
new HiddenPathsModal(plugin).open()
|
||||
new HiddenPathsModal(plugin).open();
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ export function changePathVisibility(path: string, hide: boolean) {
|
|||
if (!n) {
|
||||
return;
|
||||
}
|
||||
let p = n.parentElement
|
||||
let p = n.parentElement;
|
||||
if (hide) {
|
||||
p.style.display = `none`
|
||||
p.style.display = `none`;
|
||||
} else {
|
||||
p.style.display = ``;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue