pjeby / pane-relief

Obsidian plugin for per-pane history, pane movement/navigation hotkeys, and more
237 stars 7 forks source link

[HELP] Maximize Active Tab Command + Templater Script #45

Closed FelipeRearden closed 1 year ago

FelipeRearden commented 1 year ago

Hello @pjeby !

I have a question about a workflow that I am trying to create that I would like to share you.

Forgive me if is a dumb question. I am new to Templater and I don't know if what I am trying to create is feasible. → It is about a templater script and the command Maximize Active Tab: Toggle

Idea

I wanna create a Templater script that runs different commands based on the state of the Maximize Pane:

→ If Maximize is ON run cmd_a → If Maximize is OFF run cmd_b

This is an example of the same idea applied to the Workspaces Core Plugin → If the Active Workspace is Books run cmd_a → If the Active Workspace in not Books run cmd_b

<%*
const dir = this.app.internalPlugins.plugins.workspaces.instance.activeWorkspace
if (dir === "Books" ) {
 app.commands.executeCommandById('CMDA');
} else {
app.commands.executeCommandById('CMDB');
}
%>

Question

Would be possible to create a script like that based is the Active Note is Maximized or Not ?

If Yes, would mind helping with the command that I have to add to the templater to evaluate if the Active Note is Maximized or not?


Thanks for reading this !

Have a great day.

pjeby commented 1 year ago

A window is maxmized if there exists an element matching .workspace > .workspace-split.mod-root.has-maximized. So probably this will work:

if (activeDocument.body.find(".workspace > .workspace-split.mod-root.has-maximized")) {
    // active window has maximized pane
} else {
    // active window does not have maximized pane
}
FelipeRearden commented 1 year ago

A window is maxmized if there exists an element matching .workspace > .workspace-split.mod-root.has-maximized. So probably this will work:

Thanks for the reply @pjeby !

It worked PERFECT !!!!

Thank you very much for you help, I really appreciate 🙏