Hi @ambert, this plugin will be very useful regardless of not remembering state when switching to another note and back.
At the minute I can see the arrows by the headers to collapse them, and on mouse-over it changes the mouse pointer to a hand, but on click the headings don't collapse.
Thanks for your other plugin work too, particularly Embed Search
Update:
v1.2.0 persists folding. As for now, it automatically adds dot (".") at the end of header to mark it as to be fold on load of note, and removes it when unfolded.
Dot is arbitrary choice, mostly because it occupies little of the visible part of a heading.
@ambrt, plugin (1.2.0) working flawlessly here, including remembering state.
In case this information might be useful to you: my previous issue was tracked down to an adjustment I'd made to userchrome.css to limit the width of lines in CodeMirror. Commenting it out allowed the plugin to function as expected.
/*LIMIT NOTE WIDTH WRAP AT 580PX AND CENTRE:::::::::::*/
.CodeMirror-sizer {
margin-right: auto !important;
margin-left: auto !important;
max-width: 580px !important;
}
There are few things on left side of header line that have to be aligned for plugin to know that folding click was made.
So anything that modifies with left margin or left padding might render plugin not usable.
What do you think of creating a keyboard shortcut or menu icon to expand/restore all collapsed sections for the selected note?
I guess, it also would be nice to have a config option to only temporarily collapse sections in the manner of navigating through a longer note. And when you leave the note, no collapse is persisted.
For me (without any custom css I believe) when I open a note that I have folded headings, the arrows in the left gutter all point down. The first time I click on one to unfold it, that one stays pointing down, but the others suddenly point to the right. I am using the CodeMirror Line Numbers v1.0.0 plugin. Joplin 1.7.11 (prod, win32)
Unrelated (I assume) I got the following error joplynCrash.txt (3.0 KB)
I was in the middle of solving a different problem so I can't be 100% sure, but I believe it happended when I was trying to fold a heading. Also, I was running in safe mode at the time.
Thanks for the plugin!! It's great. Should be a core feature if you ask me.
@ambrt you can use defineExtension in your content script to create a function that will fold all. Then inside index.ts you will register a command that uses editor.execCommand to call the CodeMirror function to collapse all.
This command can be assigned a hotkey and will be available in the command palette.
(in case if other developers might wonder how to implement this too)
So just pushed new (1.2.4) version to repository with bug fixed (hopefully) and keyboard shortcuts:
Ctrl(or Cmd) + Alt + F to fold all
Ctrl(or Cmd) + Alt + U to unfold all
The problem i see with those un/fold all is that i will remove existing structure.
I'm not sure how it will work if someone would want to go back after un/folding.
Thanks. I got it to be bigger by using 2.5em and functionally it's fine. But visually, it looks a bit odd because the triangle is on top of the "#". Is it possible to make the triangle not overlap at all with the "#"?
Also, can you show me what needs to be written so that the triangle is yellow? Thanks.