Add setting to collapse / fold Properties across all notes by default

This feature is very important to me.

I loved @BOT_bkcd css solution! Kudos!

2 Likes

Maybe using this JavaScript snippet with the Templater plugin to automatically toggle fold properties when opening notes:
<%* function toggleFoldProperties(){app.commands.executeCommandById('editor:toggle-fold-properties')} app.workspace.on('file-open',()=>{setTimeout(toggleFoldProperties,300)}); if(app.workspace.getActiveFile()){toggleFoldProperties()} %>
:warning: I am not a developer, This works for me on mobile but it’s not perfect as there’s no method (correct me if I’m wrong) in the Obsidian API to directly check if the properties of a note are folded or unfolded. This ends unfolding the properties when they were already folded when you open any page.

How It Works:Function Definition: toggleFoldProperties runs the command to toggle fold properties.File Open Event: Listens for the file-open event and toggles properties with a delay.Immediate Check: If a file is already open, it toggles properties immediately.Add this to your Templater template to ensure properties are folded/unfolded.

For PC just ended keeping the properties hidden as takes almost a quarter of the available space, even folded. Waiting for a solution since last year.

(+1 to the list of people that created account to request this)

+1 for this feature requset!

I added commands to Note Toolbar to completely hide/unhide and fold/unfold the Properties section.

Closed properties seem to stay maintained if operating within the same tab. Opening a new tab requires the close to be run again.

See the Toggle Properties command.

Give it a try. YMMV!

2 Likes

Thanks you for this css! It works wonderful. :smiley:
It would be nice if this was in native, but this is also a solution!

Has anyone created a plugin for this functionality?

I put together a plugin that adds Fold/Unfold commands to the folder context menu. It loops through all files on the clicked folder, and also loops through children folders.

It allows you to fold (or unfold) the properties section of all the files within the selected folder. I find this beneficial for my monthly notes for example, where now I don’t have to collapse properties per file (a tedious task), I can simply right click, and click “Fold Properties”!

It’s not currently released in the community plugins as I only just spent the last hour developing it.

To install, add a folder inside .obsidian/plugins called fold-properties. Then add the main.js and manifest.json files inside this folder from: Release 0.0.1 · itsonlyjames/obsidian-fold-properties · GitHub.
Enable Fold Properties. Viola!

I will add this plugin to the community plugin list so you can download it easily, however the reviewer is currently away so it may be a few weeks.

Any issues, raise a bug in the repo!

Cheers

1 Like

A few days ago, I was trying to add code to my vault – through JavaScript Init – to auto-fold properties in Source Mode.
I deactivated the script since.

Can you confirm you are able to register the ON and OFF fold states of individual files across multiple sessions (even after quitting and re-starting Obsidian)?

Yeah, it persists through closing/opening, as it’s adding the fold states to local storage. Obsidian uses appId + "-note-fold-" + note in the apps local storage. My plugin saves the fold state using existing methods, and clears the relevant local storage item on unfold.

1 Like

Sounds good.

Source mode editor is twitchy when you have URLs in property values and properties are unfolded, for some reason.

Would you be so kind to compile the main.js file, please so peeps can try?

Edit. My mistake, the main.js is available in releases.