Templater icon indicating copy to clipboard operation
Templater copied to clipboard

Using Create New Note From Template in the File Explorer created the note in the left pane

Open Randy-Astle opened this issue 2 years ago • 6 comments

Plugin information (please complete the following information):

  • OS: Windows 10
  • Templater version: 1.12.0
  • Obsidian version: 0.15.2
  • Templater settings:
    • Template folder location: "Templates/",
    • Syntax highlighting: enabled
    • Automtic jump to cursor: disabled
    • Trigger Templater on New File Creation: disabled

Describe the bug I have template to create a note to store account information.

When I used it via the Create New Note From Template context menu in the File Explorer, the note was created in the left panel.

Expected behavior Expected the new note to be placed in the active editor pane.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Randy-Astle avatar Jun 22 '22 21:06 Randy-Astle

Please see #670. The code snippet below seemed to work if added at the end of your template:

<%*
if (this.app.workspace.activeLeaf.getViewState()?.type =="file-explorer") {
this.app.workspace.setActiveLeaf(this.app.workspace.getMostRecentLeaf())
}
%>
Demo and explanation demo

If the current active leaf == the left file explorer pane, switch the focus to the most recent leaf.

Hope that helps.

~welp

welpdx avatar Jun 22 '22 22:06 welpdx

I have the same problem!

The script doesent work for me and it keeps opening on top of the File explorer

diale13 avatar Jul 13 '22 17:07 diale13

@diale13 can you tell me exactly what steps you took that ended up with this problem? Is it the same steps as the op? (i.e., focus is on the file explorer, and then Templater: create new note is executed) And what os are you using?

Also, what is the template you are using? Can you try adding the above script at the start of your template and see what happens? Thanks

welpdx avatar Jul 14 '22 03:07 welpdx

Yes sure, sorry i took a while to respond.

OS: Windows 10 Templater version: 1.12.0 Obsidian version: 0.15.8

Templater settings: Template folder location: "📜Templates/", Syntax highlighting: disabled Automtic jump to cursor: disabled Trigger Templater on New File Creation: disabled

Describe the bug

Process: imagen

After template gets created home bar gets replaced by the template. Only way to restore home side bar is to close Obsidian. imagen

When I used it via the Create New Note From Template context menu in the File Explorer, the note was created in the left panel.

Expected behavior Expected the new note to be placed in the active editor pane.

Thanks

diale13 avatar Jul 24 '22 18:07 diale13

Is #691 related?

AB1908 avatar Jul 25 '22 11:07 AB1908

@diale13 until this issue is resolved, please just add this script to the end of your template

<%*
if (this.app.workspace.activeLeaf.getViewState()?.type =="file-explorer") {
this.app.workspace.setActiveLeaf(this.app.workspace.getMostRecentLeaf())
}
%>

img

The alternative to completely closing obsidian is to just Reload from command palate or F5 from console.

welpdx avatar Jul 25 '22 18:07 welpdx