It has been done already. I forgot who did this.
You can add a button through viewtemplate. Note SE uses temptiddler to expand / collapse a section.
That thread explains the mechanism, but one user has created the button!
You can do it now!
I’m starting to use this plugin and I like it! But how to change the default behaviour so that the “foldstate” is closed for all sections when opening the tiddler? In my case when i open the tiddler which contains several sections, all sections are expanded by default…
@Mohammad can you give some hints about which state tiddler target is to be targeted when craeting a button to hide and reveal all the sections together.
See this post
you could try this: (if you have changed to using state tiddlers)
<$button>
<$list filter="[prefix[$:/state/section-editor/foldstate/changelog/]]">
<$action-setfield text="closed"/>
</$list>
button to set foldstate tiddlers for changelog to closed
</$button>
but only works if the state tiddler already exists, i.e. the section has been closed at least once
<$button>
<$list filter="[prefix[$:/state/section-editor/foldstate/]]">
<$action-setfield text="closed"/>
</$list>
button to set foldstate tiddlers for all tiddlers to closed
</$button>
but only works if the state tiddler already exists, i.e. the section has been closed at least once
code for use in a tiddler tagged with $:/tags/StartupAction
(see https://tiddlywiki.com/#StartupActions for others) that will run when the tiddlywiki is started; but only works if the state tiddler already exists, i.e. the section has been closed at least once:
<$list filter="[prefix[$:/state/section-editor/foldstate/]]">
<$action-setfield text="closed"/>
</$list>
NB this closes all the state tiddlers, even ones you might want left open.
it’s probably possible to add exceptions in the filter e.g. tag a particular foldstate tiddler and filter excluding that tag. though not very practical if you edit your tiddlers often, as the state tiddlers are actually not for particular sections, they are for the sections-in-the-order-in-the-tiddler i.e. if you insert a section between 1 and 2, the new 1.5 section “takes” the state tiddler of the old 2.
@makiaea Thank you. Based on your suggestions, I created two buttons to fold and unfold all sections
<$button class=<<tv-config-toolbar-class>> >
<$list filter="[prefix[$:/temp/section-editor/foldstate/]]">
<$action-setfield text="closed"/>
</$list>
{{$:/images/icon-park/abstract/app-switch-fill}}
</$button>
<$button class=<<tv-config-toolbar-class>> >
<$list filter="[prefix[$:/temp/section-editor/foldstate/]]">
<$action-deletefield $field="text"/>
</$list>
{{$:/images/icon-park/abstract/app-switch-outline}}
</$button>
How to make these buttons appear only in the viewtoolbar of tiddlers with field se-type
Thank you for your code. Your buttons works for me.
Do you know how to create only one button with a toggle function ? (open all / close all sections)
I tried, but didn’t succeed. May be someone else can help regarding this…
<$list filter="[all[current]has[se-type]]" >
<$button class=<<tv-config-toolbar-class>> >
<$list filter="[prefix[$:/state/section-editor/foldstate/]]">
<$action-setfield text="closed"/>
</$list>
{{$:/images/icon-park/abstract/app-switch-fill}}
</$button>
</$list>
I tried this code to make these buttons to appear on the viewtoolbar of tiddlers with field se-type
only, but its not working as intended. Any suggestions ?
If the field se-type
contains a value (not empty) it seems to work but i don’t understand why…
The has[se-type]
filter succeeds only if the se-type
field has a non-blank value.
To test for the existence of the se-type
field, even if blank, you need to add the :field
suffix, like this:
<$list filter="[all[current]has:field[se-type]]">
Thank you Eric for this explanation !
Section editor has got a new update. This is a maintenance release.
Release 1.1.1
- Mar 26th, 2023
- [FIXED] bug in editor toolbar when main editor is used (see Edit Toolbar Configuration button is ignored. · Issue #32 · kookma/TW-Section · GitHub)
- [NEW] updated to Tiddlywiki 5.2.7
Demo: Section Editor — create, edit, fold, manage sections
Code: GitHub - kookma/TW-Section: create, edit and manage big and lengthy tiddlers through sectioning
@Mohammad
Just an Idea that came to my mind today - Is it possible to set the number of levels of headings to be used in each tiddler separately by assigning the that number as fieldvalue
to the fieldname se-type
. By this way we can avoid setting the number of levels globally. Is it possible to do ?
I think it is possible! But not sure as I have not worked on Section Editor for a while.
When you use macro for variable it is simpler to overwrite it,
This is the great idea!
Is it possible to make a section editable with trottle Refresh? On weak computers the difference is quite noticeable: on my 12 year old laptop the time taken is measured using Advanced Performance plugin 1.1.0 - Expanded performance instrumentation equals ~300-400 for one of the heavy filters. On the same filter for a person with modern PCs, it is ~50.
Yes, it is possible. @saqimtiaz has discussed this before, and I have this in my todo list.
I will update as soon as I can.