Skip to content

Commit

Permalink
feat: update plugins, open theme/plugin browser
Browse files Browse the repository at this point in the history
close #32
  • Loading branch information
Vinzent03 committed Nov 16, 2021
1 parent 717fcfe commit a310d80
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ The `heading` parameter is for `mode=append` and `mode=prepend` supported too.

### Navigation

| / | parameters | explanation |
| ---------------------- | -------------------------- | -------------------------------------------------------------------------------------------------- |
| workspace | workspace | Opens the workspace called `workspace` |
| save current workspace | saveworkspace | Saves the current workspace. (Can be combined with `workspace` to open a new workspace afterwards) |
| 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 |
| / | parameters | explanation |
| ---------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| workspace | workspace | Opens the workspace called `workspace` |
| save current workspace | saveworkspace | Saves the current workspace. (Can be combined with `workspace` to open a new workspace afterwards) |
| 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 (e.g. `editor`, `community-plugins`, `plugin-browser`, `theme-browser`...) |

### Execute command

Expand Down
23 changes: 21 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface Parameters {
"x-success"?: string;
"x-error"?: string;
saveworkspace?: string;
updateplugins?: string;
}

export default class AdvancedURI extends Plugin {
Expand Down Expand Up @@ -167,6 +168,8 @@ export default class AdvancedURI extends Plugin {
this.handleOpen(parameters);
} else if (parameters.settingid) {
this.handleOpenSettings(parameters);
} else if (parameters.updateplugins) {
this.handleUpdatePlugins(parameters);
}
});

Expand Down Expand Up @@ -515,7 +518,23 @@ export default class AdvancedURI extends Plugin {
if ((this.app as any).setting.containerEl.parentElement === null) {
(this.app as any).setting.open();
}
(this.app as any).setting.openTabById(parameters.settingid);
if (parameters.settingid == "plugin-browser") {
(this.app as any).setting.openTabById("community-plugins");
(this.app as any).setting.activeTab.containerEl.find(".mod-cta").click();
} else if (parameters.settingid == "theme-browser") {
(this.app as any).setting.openTabById("appearance");
(this.app as any).setting.activeTab.containerEl.find(".mod-cta").click();
} else {
(this.app as any).setting.openTabById(parameters.settingid);
}
this.success(parameters);
}

handleUpdatePlugins(parameters: Parameters) {
parameters.settingid = "community-plugins";
this.handleOpenSettings(parameters);
(this.app as any).setting.activeTab.containerEl.findAll(".mod-cta").last().click();

this.success(parameters);
}

Expand Down Expand Up @@ -561,7 +580,7 @@ export default class AdvancedURI extends Plugin {
const newFileContent = splitContent.join("\n");
await this.app.vault.modify(file, newFileContent);
return uid;
}
};

getViewStateFromMode(parameters: Parameters) {
return { state: { mode: parameters.viewmode } };
Expand Down

0 comments on commit a310d80

Please sign in to comment.