Add toggle collapse and open pane commands

This commit is contained in:
celeste 2023-03-01 03:22:02 -08:00
parent 99c7835da1
commit 55a2ff456f

21
main.ts
View file

@ -197,6 +197,27 @@ export default class LoomPlugin extends Plugin {
hotkeys: [{ modifiers: ["Alt"], key: "c" }],
});
this.addCommand({
id: "loom-toggle-collapse-current-node",
name: "Toggle whether current node is collapsed",
icon: "folder",
callback: () => {
const file = this.app.workspace.getActiveFile();
if (!file) return;
const state = this.state[file.path];
this.app.workspace.trigger("loom:toggle-collapse", state.current);
},
hotkeys: [{ modifiers: ["Alt"], key: "Enter" }],
});
this.addCommand({
id: "loom-open-pane",
name: "Open Loom pane",
callback: () => this.app.workspace.getRightLeaf(false).setViewState({ type: "loom" }),
});
this.addCommand({
id: "loom-debug-reset-state",
name: "Debug: Reset state",