It’s not really easy for me to understand the importance of being collapsable, but I know the respective tool implemented for web sites. (It’s funny, however, that in en.wikipedia.org e.g. the clickable
show are positioned in a way making me think they are for hiding/showing the content itself instead of the index. Being funny is human.)
Anyway: The appropriate means to create collapsable text content might be TextFrame objects. Since @ajlittoz already suggested to use macros, I made a demo showing what I would try if I had a related need at all.
The attached document contains two examples of applicable code.
The even simpler Sub named
toggleIsAutomaticHeight can toggle any TextFrame between the states of being reduced to its height set as an absolute value via the Properties, and the state of being expanded to automatic height (showing all content). This macro is assigned to the sensitive area of an included toolbar
myExtraToolbar. It will be called for a frame directly selected or for one containing the current text selection.
The slightly more elaborate Sub named
toggleFrameIsAutomaticHeightRegardingStyleName will also toggle a frame of reduced height to automatic/full. The reverse action depends on the name of the FrameStyle. If the Sub can extract an explicit minimum height from there, it will be applied. Otherwise the frame’s state should remain unchanged. In the example this maccro is callable from the context menu of a selected frame.
Both macros have an unused optional parameter. It is included to hint that an enhancement can implement a diversification of the action depending on modifyer keys pressed in addition when the macro is called by clicking into a toolbar. Menu items dont pass such information.
Both macros can also be called via the menu, of course.
Have a lot of fun.