Skip to content

Commit

Permalink
feat: add navigation to any settings tab
Browse files Browse the repository at this point in the history
close #29
  • Loading branch information
Vinzent03 committed Nov 1, 2021
1 parent a24012a commit 702f30a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ The `heading` parameter is for `mode=append` and `mode=prepend` supported too.

### Navigation

| / | parameters | explanation |
| --------------- | -------------------------- | -------------------------------------- |
| workspace | workspace | Opens the workspace called `workspace` |
| heading | <identification\>, heading | Opens the `heading` in `filepath` |
| block reference | <identification\>, block | Opens the `block` in `filepath` |
| / | parameters | explanation |
| --------------- | -------------------------- | ----------------------------------------------------- |
| workspace | workspace | Opens the workspace called `workspace` |
| heading | <identification\>, heading | Opens the `heading` in `filepath` |
| block reference | <identification\>, block | Opens the `block` in `filepath` |
| settings tab | settingid | Opens a settings tab by id, all plugins are supported |

### Execute command

Expand Down
10 changes: 10 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface Parameters {
filename?: string;
exists?: string;
viewmode?: "source" | "preview";
settingid?: string;
}

export default class AdvancedURI extends Plugin {
Expand Down Expand Up @@ -160,6 +161,8 @@ export default class AdvancedURI extends Plugin {

} else if (parameters.filepath) {
this.handleOpen(parameters);
} else if (parameters.settingid) {
this.handleOpenSettings(parameters.settingid);
}
});

Expand Down Expand Up @@ -477,6 +480,13 @@ export default class AdvancedURI extends Plugin {
};
}

handleOpenSettings(id: string) {
if ((this.app as any).setting.containerEl.parentElement === null) {
(this.app as any).setting.open();
}
(this.app as any).setting.openTabById(id);
}

async copyURI(parameters: Parameters) {
let uri = `obsidian://advanced-uri?vault=${this.app.vault.getName()}`;
const file = this.app.vault.getAbstractFileByPath(parameters.filepath);
Expand Down

0 comments on commit 702f30a

Please sign in to comment.