Hide Tiddler Body

My take was that Mohammad wanted this to happen automagically, without requiring the user to press a button. Otherwise I’m mystified too :smiley:

I think Mat was talking about “hooks” in code. If there was a “hook” when you closed a tiddler, then things like the hide-body field could be added at the time a tiddler was saved.

There are some hooks, but they are JS only. … BUT there is a discussion going on at GitHub to change that.

The idea is to expose all of the functions that the navigator-widget handles atm, will be “extracted” and should be available with several action-like widgets.

also see: Implement more of TiddlyWiki's black box logic as customisable action strings · Issue #3967 · Jermolene/TiddlyWiki5 · GitHub At the end of the issue, there are a lot of other issues that reference this one. … So there is quite some potential

On a related issue tiddler folding and desired support from navigation

I will just remind us all we already have the fold tiddler button and bar. This is toggled by the existence of a tiddler. This can be automated but requires a trigger. Most people when adding something to the view templates do not include the code to hide the output when the fold tiddler button is used.

This means the fold facility only closes the core output like rendering the body (Tags and Subtitle) which has a similar effect as the hide-body field being set to yes, but can be reversed with the button on the view tool bar, or the foldbar is used to unfold.

It seems to me there is a systematic gap here that if addressed would be easy to solve. Exposing the functions of the navigator widget may help.

@pmario perhaps you could ensure the GitHub discussion considers this but the navigation process is a potential trigger that occurs once each time a tiddler is opened and an appropriate place to test a condition and initiate an action.

A standard work around because its hard to trigger an action in the viewtemplate
If we go back to @Mohammad 's Original question the best work around is to set the hide-text field or fold status toggle at the moment you create or nominate a tiddler for this purpose. I am building a solution not unlike the “edit-section” solution and have simply made the fold button appear;

<$list filter="[all[current]has:field[job]]">
{{||$:/core/ui/Buttons/fold}}
....
how to hide tiddler body?
</$list>

This only demands a one off manual intervention.

Personally I have felt one way we protect users is to not allow us to set an action on open tiddler, one could make an action to close the tiddler on open, or open all tiddlers on open - for example. This could get messy.

However it is stopping us developing a whole class of solutions.

I have worked in building “Standard Operating Environments” (desktop/OS) and application and software distribution in large corporate environments. Both windows itself and the install/ distribution tools typically include a “run once” functionality. Once run It will not run again and this protects it from re-occurring or looping.

Perhaps we can provide a conditional run once on opening a tiddler that can be set in the view template but which the navigation or open tiddler trigger can result in an action. This could conditionally set or fold the tiddler on first navigation, or manual creation.

IMO this would only be a workaround for a very specific usecase. The one described in the OP. …

What we need is a generic solution, similar to the one discussed at github.

As I wrote in the tread there, it would be worth to explore the possibilities. … It may be possible to remove the boundaries between view-mode and edit-mode, which may open up a lot of new possibilities.

Hiding / showing different elements would be 1 of them.

Actually I am asking for the facility to conditionally trigger actions on open tiddler a general facility. There examples may include;

  • Render a large tiddler and take a snapshot, display that snapshot only so that the large tiddler is not re-rendered until requested.

In my view this would be a generic solution, but if it can be satisfied by the other one all the better.

See my comments in the same thread.

Folks - see my recent solution The quickest and easiest ever todolist in tiddlywiki ? Requires 5.2.0 - #2 by TW_Tones for an example of why we could use a way to programaticaly hide the body, in this example I provide a fold button as the work around.

Also @Mohammad see inside quicklist for a method I employed to simply parse the lines similar to Section Editor - Prototype it may prove of use in the future.

Section-Editor respects the core tiddler folding state using the below viewtemplate


<$list filter="[all[current]has:field[se-type]!field:hide-body[yes]]">

<$reveal tag="div" class="xtc-tiddler-body" type="nomatch" stateTitle=<<folded-state>> text="hide" retain="yes" animate="yes">

<$list filter="[all[current]!has[plugin-type]!field:hide-body[yes]]" variable=NULL>

<$vars hn={{{ [[$:/plugins/kookma/section/configs-hn]get[text]else[2]] }}} > <!-- default number of headings 2 -->
<$macrocall $name=section-editor source=<<currentTiddler>> pattern=<<pattern>> />
</$vars>

</$list>

</$reveal>
1 Like

@Mohammad I was looking at how you are hiding the core/ViewTemplate/Body and display the sections viewtemplate. I want to similarly display a table with editor in one column and preview in the other column like shown below.

This table is in a tiddler called Alternate editor

I created a config tiddler called $:/config/ViewTemplateBodyFilters/Alternate editor with tag $:/tags/ViewTemplateBodyFilter and its content as

[has:field[ae-type]!field:hide-body[yes]then[$:/plugins/arsheth/editor/viewtemplates/alternate editor]]

Now I created a tiddler called $:/plugins/arsheth/editor/viewtemplates/alternate editor
How should I modify your code in the the tiddler $:/plugins/kookma/section/viewtemplates/sections so that my table in the tiddler Alternate editor is shown in tiddler with field ae-type instead of the tiddler body.

\import $:/plugins/kookma/section/macros/main
\define filterpattern() ^\[.*\]$

<$list filter="[all[current]has:field[se-type]]"> 
<$reveal tag="div" class="se-tc-tiddler-body" type="nomatch" stateTitle=<<folded-state>> text="hide" retain="yes" animate="yes">
<$list filter="[all[current]] :filter[<currentTiddler>get[se-type]regexp<filterpattern>]" variable=patchworkTid
       emptyMessage="""<$macrocall $name=sectionizeSingleTiddler sourceTiddler=<<currentTiddler>> /> """ >
  <$macrocall $name=sectionizePatchworkTiddler sourceTiddler=<<patchworkTid>> />
</$list>
</$reveal>
</$list>

<!-- generate sections only by heading levels (h1, h2, h3, ...)

Note: this view template works with cascade new filter operator and uses $:/config/ViewTemplateBodyFilters/Sections
-->

I tried adding a list filter and transclude the Alternate editor tiddler with table in it , but that was not working. Any suggestions ?

I plan to create a button to add the field ae-type to tiddlers as I need (Similar to the JanJo section editor viewtoolbar button)

Theoretically, what you put in $:/plugins/arsheth/editor/viewtemplates/alternate editor will be displayed.

This code is little out of date, there is no need to check again if the tiddler has se-type field as the cascade already has done this!

This is to honor the fold state!

This is what it display instead of body

Is it needed in my case?

Can I just transclude the table tiddler here instead of the macrocall

No, it uses two states, you have one!

Sure, you can!

I use these four tiddlers, still nothing happens on adding the field ae-type to a tiddler by clicking the viewtoolbar button. @Mohammad Can you take at look this when free ?

<$list filter="[all[current]has:field[ae-type]]"> 
{{Alternate toggle editor}}
</$list>


[has:field[ae-type]!field:hide-body[yes]then[$:/plugins/arsheth/editor/viewtemplates/alternateeditor]]

This is the alternate editor table -

Here is a demo wiki - https://demowiki.tiddlyhost.com/

I have put all relevant tiddlers in the home page.

@arunnbabu81
As I understand, you like to show a tiddler as a table using viewtemplates (here cascades) and hide its content, am I right?

You are right. That table has editor on left side and preview on right side

Okay then lets first go through cascades

  1. you need to have a conditional viewtemplate, I see you have one My TiddlyWiki — a non-linear personal web notebook

add a list-before to it with value $:/config/ViewTemplateBodyFilters/default

I have added the list-before field now with value $:/config/ViewTemplateBodyFilters/default- My TiddlyWiki — a non-linear personal web notebook

Now the alternate editor viewtemplate is getting activated once I add the ae-type field using the viewtoolbar button. But I need to modify my filters somewhere I guess beacuse on all tiddlers the same alternate editor table is being seen. I have to go for work now. I will revisit once I am back home.

Okay. now it works, you can start with adding gradually the style and content you want. This will help you to debug the current code!

After a lot of tinkering, finally I was able to make it work.
Now there are three editor modes which are activated by viewtoolbar buttons.

  1. Alternative editor without preview - This is a simple editor created using edit text widget.

  1. Alternative editor selective - This is an editor with three modes - simple editor, preview, editor with preview modes which can be selected using radio buttons.

  1. Alternative editor selective for modals - Same as the second one except that the editor is loaded in a modal.

Click on these three viewtoolbar buttons to see the editors working. image

Check out the editors in this link - My TiddlyWiki — a non-linear personal web notebook

Given below is a link of ensemble tiddler showing ensembles for each editor modes and their related tiddlers.
https://demowiki.tiddlyhost.com/#%24%3A%2Fplugins%2FBTC%2Ftiddlywiki-multi-columns%2Fui%2FSideBarTabs%2FEnsemble

Thank you @Mohammad for the helps.

2 Likes

Great work!
Thank you for sharing!

Sidenote: TW Icons is a comprehensive collections of icons, you can find good icons there with same size and line thickness ( stroke-width) as TW core icons!