I find the YAML field’s to be a little distracting while editing notes ( I have 6 Some fields for almost all notes) .
Is there any chance that we might have a collapsible bar for these fields? Similar to link below
I find the YAML field’s to be a little distracting while editing notes ( I have 6 Some fields for almost all notes) .
Is there any chance that we might have a collapsible bar for these fields? Similar to link below
You can fold/unfold the YAML section using a hotkey. I use Ctrl + Y which is unassigned by default.
<%*
// Get the current cursor location
const cursor = app.workspace.activeLeaf.view.editor.getCursor()
// Move the cursor to the start of the document
app.workspace.activeLeaf.view.editor.setCursor({line: 0, ch: 0})
// Fold/unfold the YAML
app.commands.executeCommandById('editor:toggle-fold')
// Move the cursor back to the original location
app.workspace.activeLeaf.view.editor.setCursor(cursor)
%>
Open the Templater config page and set a hotkey for the new template.
That’s it, you’re done!
You can also make this part of another template, so for example, once you insert your new note template the YAML will be automatically hidden.
If you’re doing that, you will need to put the script in its own Templater “User scripts” file per the User Scripts documentation.
Create a hideYaml.js
file (not a Markdown .md
note file). Place this in the “Script files folder location” which is configured in Templater config.
Paste this into your hideYaml.js
file:
function main() {
setTimeout(() => {
const cursor = app.workspace.activeLeaf.view.editor.getCursor()
app.workspace.activeLeaf.view.editor.setCursor({line: 0, ch: 0})
app.commands.executeCommandById('editor:toggle-fold')
app.workspace.activeLeaf.view.editor.setCursor(cursor)
return ''
}, 100)
}
module.exports = main
<%* tp.user.hideYaml() %>
That way it’s just a single one-liner which you can put in any other template. The reason for the setTimeout
delay is so the new note can be created, and only after that will the YAML be hidden.
I’m attempting to glue everything together; hopefully it works okay.
Thank you!
Let me know if you run into any issues and I’ll update the docs to fill in the gaps.
I’m grateful. I value your assistance.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.