1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-22 06:56:52 +00:00
TiddlyWiki5/core/wiki/macros/toc.tid

486 lines
22 KiB
Plaintext
Raw Normal View History

title: $:/core/macros/toc
tags: $:/tags/Macro
2024-02-07 13:32:22 +00:00
<!--
Naming rules
- functions eg: tf.toc-variableName, "tf." ... function prefix reservered for TW, "toc-" ... global macro prefix, "variableName"
2024-02-07 13:32:22 +00:00
- procedures eg: toc-procedureName,
- macro parameters: path, itemTemplate
- derived macro parameters: _path, _itemTemplate ... derived variables start with an underscore
- some \function definitions are near their first use in the middle of the code, to find them easily
2024-02-09 11:23:24 +00:00
The toc-macro code is heavily reused from top to bottom.
toc-tabbed-internal-nav calls toc-tabbed-external-nav, which calls toc-selective-expandable, which calls toc-expandable
2024-02-09 11:23:24 +00:00
The very first toc macro is _not_ reused. So it can be used as a simple reference implementation, because it is relatively easy to debug.
2024-02-07 13:32:22 +00:00
-->
\whitespace trim
<!-- The field to show depends on the following cascade - default: title -->
\procedure _hasItemTemplate() [<itemTemplate>!is[blank]then[text]]
\procedure _hasCaptionField() [get<captionField>!is[blank]then<captionField>]
\procedure _hasCaption() [has[caption]then[caption]]
2024-05-14 01:19:26 +00:00
\function tf.toc-getTooltip() [<currentTiddler>get[toc-tooltip]!is[blank]] :else[<currentTiddler>]
<!-- Use this item template as a default -->
\procedure toc-defaultItemTemplate()
<$let tv-wikilinks="no"
field={{{ [<currentTiddler>] :cascade[<_hasItemTemplate>append<_hasCaptionField>append<_hasCaption>append[title]] }}}
>
<span class=""
data-fieldClass=`field-$(field)$`
2024-05-14 01:19:26 +00:00
title=<<tf.toc-getTooltip>>
>
<$transclude $field=<<field>>/>
</span>
<<toc-newChildButton>>
2024-07-23 10:49:08 +00:00
<!-- Do not remove next line it's needed for debugging -->
<!-- <sup class="tc-small-gap-left"><<_mode>></sup> -->
</$let>
\end
\procedure toc-newChildButton()
\procedure _newChild(field:"parent")
<$button tooltip=`New Child -> "$(field)$: $(currentTiddler)$"`
aria-label="new child here" class="tc-btn-invisible"
>
<% if [<_mode>match[tocpMode]] %>
<$action-sendmessage $message="tm-new-tiddler" $name=<<field>> $value=<<currentTiddler>>/>
{{$:/wikilabs/images/new-child-alone}}
<% else %>
<$action-sendmessage $message="tm-new-tiddler" $name=<<field>> $value={{{[<currentTiddler>format:titlelist[]]}}}/>
{{$:/core/images/new-here-button}}
<% endif %>
</$button>
\end _newChild
<% if [<tv-toc-show-new-child>match[yes]] %>
<% if [<_mode>match[tagMode]] %>
<span class="tc-small-gap-left"><$macrocall $name="_newChild" field="tags"/></span>
<!-- <span class="tc-small-gap-left">{{||$:/core/ui/Buttons/new-here}}</span> -->
<% elseif [<_mode>match[tocpMode]] %>
<span class="tc-small-gap-left"><$macrocall $name="_newChild" field=<<parentField>>/></span>
<% elseif [<_mode>match[tagLikeMode]] %>
<span class="tc-small-gap-left"><$macrocall $name="_newChild" field=<<tagField>>/></span>
<% endif %>
<% endif %>
\end
<!--
Check if a user defined item template should be used.
It can be a macro parameter: itemTemplate or a tiddler field: toc-itemTemplate. Tiddler field takes precedence
If the macro parameter is empty - Use the toc-defaultItemTemplate
-->
\function tf.toc-getItemTemplateTitle() [<currentTiddler>get[toc-itemTemplate]] :filter[has[text]] :else[<itemTemplate>has[text]then<itemTemplate>]
\procedure _itemTemplate()
2024-05-04 13:28:11 +00:00
<$transclude $tiddler=<<tf.toc-getItemTemplateTitle>> >
<<toc-defaultItemTemplate>>
</$transclude>
\end
<!-- Next 2 allow custom icons (TW v5.2.4). Keep names for backwards compatibility -->
\procedure toc-open-icon() $:/core/images/down-arrow
\procedure toc-closed-icon() $:/core/images/right-arrow
<!-- Default field names -->
\procedure toc-hideField() toc-hide
\procedure toc-includeField() toc-include
\procedure toc-filterField() toc-filter
2024-02-05 20:14:44 +00:00
2024-05-04 13:28:11 +00:00
<!-- Helper functions for LI class definitions on the branch level -->
\function tf.toc-itemClassFilter() [<selectedTiddler>get[text]match<currentTiddler>then[toc-item-selected]else[toc-item]]
\function tf.toc-includeClass() [subfilter<tf.toc-include>match<currentTiddler>then[tc-toc-include]]
\function tf.toc-filterClass() [subfilter<tf.toc-filter>match<currentTiddler>then[tc-toc-filter]]
\function tf.toc-hideClass() [<tf.toc-hide>!is[blank]then[tc-toc-hide]]
<!-- join the CSS definitions from above -->
\function tf.toc-itemClass() [<tf.toc-itemClassFilter>] [<tf.toc-includeClass>] [<tf.toc-filterClass>] [<tf.toc-hideClass>] +[join[ ]]
<!-- Special case: if toc-hide field is "yes", we need a currentTiddler *titlelist* - otherwise return the content as text -->
2024-05-04 13:28:11 +00:00
<!-- The following functions need to use <currentTiddler> -->
\function tf.toc-getHideText() [<currentTiddler>get<toc-hideField>]
\function tf.toc-hideIsYes() [<currentTiddler>format:titlelist[]]
\function tf.toc-hide() [<tf.toc-getHideText>match[yes]then<tf.toc-hideIsYes>] :else[<tf.toc-getHideText>]
2024-05-04 13:28:11 +00:00
<!-- Read tf.toc-include and tf.toc-filter from fields. Need to use the <tag> variable -->
2024-02-07 13:32:22 +00:00
\function tf.toc-include() [<tag>get<toc-includeField>]
\function tf.toc-filter() [<tag>get<toc-filterField>]
2024-02-09 11:23:24 +00:00
<!-- Define default filter strings for different usecases: tag (default), parentField or tagField for using a tag-like field -->
\procedure toc-filterDefault() [all[shadows+tiddlers]tag<tag>!has[draft.of]]
\procedure toc-filterParent() [has<parentField>!has[draft.of]] :filter[get<parentField>match<tag>]
\procedure toc-filterTagLike() [<tag>get<tagField>enlist-input[]!has[draft.of]]
2024-07-23 10:49:08 +00:00
\procedure toc-filterTagLike() [has<tagField>!has[draft.of]] :filter[get<tagField>enlist-input[]match<tag>]
2024-02-09 11:23:24 +00:00
<!-- TODO tiddlers with parentField MAY need caching -->
2024-05-04 13:28:11 +00:00
<!-- Activate the filterString depending on tagField, parentField or default. tagField takes precedence -->
\function tf.toc-filterString() [<tagField>!is[blank]then<toc-filterTagLike>] :else[<parentField>!is[blank]then<toc-filterParent>else<toc-filterDefault>]
<!-- The main filter string defines the current _mode variable. tagLikeMode, tocpMode or tagMode -->
\function tf.toc-mode() [<tf.toc-filterString>match<toc-filterTagLike>then[tagLikeMode]] :else[<tf.toc-filterString>match<toc-filterParent>then[tocpMode]else[tagMode]]
2024-05-04 13:28:11 +00:00
<!-- Define unique path based state title -->
\function tf.toc-newPath() [<path>addsuffix[/]addsuffix<tag>]
2024-02-09 11:23:24 +00:00
<!-- ====================================================================================
Simple toc macro which shows the full tree
This macro is _not_ used by other toc-macros
v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter see: tf.toc-itemClass()
========================================================================================== -->
\procedure toc(tag,sort:"",itemClassFilter,exclude,captionField,tagField,parentField,itemTemplate)
<$macrocall $name="toc-body" tag=<<tag>> sort=<<sort>> exclude=<<exclude>>/>
\end
2024-05-04 13:28:11 +00:00
<!-- Simple toc helper body -->
\procedure toc-body(tag,sort:"",itemClassFilter,exclude,path)
<!-- Be aware: if parentField is set, the "tag" parameter contains the currentTiddler -->
<$set name=currentTiddler filter="[<parentField>!is[blank]then<tag>else<currentTiddler>]">
2014-08-31 13:05:43 +00:00
<ol class="tc-toc">
2024-02-09 11:23:24 +00:00
<!-- text substitution for $(sort)$ parameter backwards compatibility -->
2024-02-05 19:07:10 +00:00
<$list filter=` [subfilter<tf.toc-filter>]
:else[subfilter<tf.toc-filterString>$(sort)$]
[subfilter<tf.toc-include>] -[<tag>] -[subfilter<exclude>]`>
<%if [<currentTiddler>] -[subfilter<tf.toc-hide>] %>
<$let _path=<<tf.toc-newPath>> _mode=<<tf.toc-mode>> >
<!-- adding tf.toc-hide, excludes blocked elements from all visible sub-nodes -->
<$set name="_excluded" filter="[subfilter<exclude>] [<tag>] [subfilter<tf.toc-hide>]">
<li class=<<tf.toc-itemClass>>>
<% if [all[current]toc-link[no]] %>
<<_itemTemplate>>
<% else %>
2024-05-04 13:28:11 +00:00
<!-- Since v5.1.23 use target-field if present in tiddler -->
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
<<_itemTemplate>>
</$link>
<% endif %>
<!-- toc-body only calls itself, so only modified variables have to be passed on. -->
2024-02-07 13:32:22 +00:00
<!-- The rest can be reused from toc parameters -->
<$macrocall $name="toc-body" tag=<<currentTiddler>> exclude=<<_excluded>> path=<<_path>>
/>
</li>
</$set>
</$let>
<% endif %>
</$list>
</ol>
</$set>
\end
<!-- -->
2024-07-23 10:49:08 +00:00
<!-- <$log $$filter="tag currentTiddler _excluded _path" /> -->
<!-- <$log $$filter="tag parentField toc-filter currentTiddler captionField /> -->
<!-- -->
2024-02-09 11:23:24 +00:00
<!-- Helper functions for toc-openBranch and toc-closeBranch procedures -->
\procedure toc-tagLikeChildFilter() [<currentTiddler>get<tagField>enlist-input[]] -[toc-hide[yes]]
2024-07-23 10:49:08 +00:00
\procedure toc-tagLikeChildFilter() [has<tagField>] :filter[get<tagField>enlist-input[]match<..currentTiddler>] -[toc-hide[yes]]
\procedure toc-parentChildFilter() [has<parentField>] :filter[get<parentField>match<..currentTiddler>] -[toc-hide[yes]]
\procedure toc-tagChildFilter() [tag<currentTiddler>] -[toc-hide[yes]]
<!-- this function uses the variables NOT the tiddler fields -->
\function tf.toc-hasChildren()
[<tagField>!is[blank]then<toc-tagLikeChildFilter>]
:else[<parentField>!is[blank]then<toc-parentChildFilter>]
:else[<toc-tagChildFilter>]
\end
\function tf.toc-stateTitle() [[$:/state/toc]] [<path>] "/" [<currentTiddler>] +[join[]]
2024-02-09 11:23:24 +00:00
<!-- toc-openBranch internally uses a recursiveOpen() procedure -->
\procedure toc-openBranch(path,currentTiddler,manual:"no")
2024-05-04 13:28:11 +00:00
\procedure recursiveOpen(exclude, path)
<!-- tf.toc-stateTitle needs the path variable! -->
<$let path={{{ [<path>] "/" [<currentTiddler>] +[join[]] }}}>
<!-- It's common that users tag the <currentTiddler> with itself, so avoid redundant state tiddlers with -[<currentTiddler>] -->
<$list filter="[subfilter<tf.toc-hasChildren>] [subfilter<tf.toc-curTidInclude>] -[<currentTiddler>] -[subfilter<exclude>]" >
<% if [subfilter<tf.toc-hasChildren>] [subfilter<tf.toc-curTidInclude>] -[<currentTiddler>] -[subfilter<exclude>] %>
<$set name="_excluded" filter="[subfilter<exclude>] [<currentTiddler>]">
<!-- tf.toc-stateTitle needs the path variable! -->
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
<$action-setfield $tiddler=<<toc-state>> text="open"/>
<$macrocall $name="recursiveOpen" exclude=<<_excluded>> path=<<path>> />
</$qualify>
</$set>
<% endif %>
</$list>
</$let>
\end recursiveOpen
2024-02-09 11:23:24 +00:00
<% if [<manual>match[yes]] %>
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
<$action-setfield $tiddler=<<toc-state>> text="open"/>
<$macrocall $name="recursiveOpen" exclude=<<exclude>> path=<<path>> />
</$qualify>
<% elseif [<modifier>match[ctrl]] %>
<$macrocall $name="recursiveOpen" exclude=<<exclude>> path=<<path>> />
<% endif %>
\end
<!-- <$action-log/> -->
<!-- <$action-log ct=<<currentTiddler>> hasChildren=<<tf.toc-hasChildren>> path=<<path>> exclude=<<exclude>>/> -->
<!-- <$action-log toc-state=<<toc-state>> path=<<path>> exclude=<<exclude>> ct=<<currentTiddler>> /> -->
<!-- <$action-log ct=<<currentTiddler>> prefix=<<prefix>> toc-state=<<toc-state>>/> -->
\procedure toc-closeBranch(path,currentTiddler,manual:"no")
<% if [<modifier>match[ctrl]] :else[<manual>match[yes]] %>
<$let prefix={{{ [<tf.toc-stateTitle>] }}} >
<$action-deletetiddler $filter="[prefix<prefix>]"/>
</$let>
<% endif %>
\end
<!--
2024-02-07 13:32:22 +00:00
If a toc-item shows a link. Clicking the caption will open the tiddler
If toc-item is linked, the _itemTemplate is managed in the parent procedure
2024-05-04 13:28:11 +00:00
If a toc-item should not show a link, the _itemTemplate is part of the button. So it can be clicked to open or close one branch
The buttons also call toc-stateOpen and toc-stateClose, which by default allow us to CTRL-click to expand or fold the whole branch
-->
\procedure toc-item(isUnlinked:"")
<% if [<toc-state>get[text]else[close]match[close]] %>
<!-- <$button actions=<<toc-openBranch>> setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible" tooltip=<<toc-state>>> -->
<$button actions=<<toc-openBranch>> setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-tiny-gap-right">
<$transclude tiddler=<<toc-closed-icon>> />
<% if [<isUnlinked>match[yes]] %>
2024-07-23 10:49:08 +00:00
<span class="tc-toc-unlinked tc-tiny-gap-left"><<_itemTemplate>></span>
<% endif %>
</$button>
<% elseif [<toc-state>get[text]match[open]] %>
<!-- <$button actions=<<toc-closeBranch>> setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible" tooltip=<<toc-state>>> -->
<$button actions=<<toc-closeBranch>> setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-tiny-gap-right">
<$transclude tiddler=<<toc-open-icon>> />
<% if [<isUnlinked>match[yes]] %>
2024-07-23 10:49:08 +00:00
<span class="tc-toc-unlinked tc-tiny-gap-left"><<_itemTemplate>></span>
<% endif %>
</$button>
<% endif %>
\end
2024-02-07 12:17:38 +00:00
\procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,tagField,parentField,itemTemplate)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
<li class=<<tf.toc-itemClass>>>
<!-- v5.1.23 use target-field if present in tiddler -->
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
<<toc-item>>
<<_itemTemplate>>
</$link>
<!-- TODO auto expand -->
<% if [<toc-state>get[text]match[open]] %>
<$macrocall $name="toc-expandable"
tag=<<currentTiddler>> sort=<<sort>> exclude=<<exclude>> path=<<path>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
</$qualify>
\end
2024-02-07 12:17:38 +00:00
\procedure toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,tagField,parentField,itemTemplate)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>>>
<li class=<<tf.toc-itemClass>>>
<<toc-item isUnlinked:"yes">>
<!-- TODO auto expand -->
<% if [<toc-state>get[text]match[open]] %>
<$macrocall $name="toc-expandable"
tag=<<currentTiddler>> sort=<<sort>> exclude=<<exclude>> path=<<path>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
</$qualify>
\end
<!-- ==========================================================
Shows an expandable toc. Item always have an open/close chevron
=============================================================== -->
2024-02-07 12:17:38 +00:00
\procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path,captionField,tagField,parentField,itemTemplate)
<$set name=currentTiddler filter="[<parentField>!is[blank]then<tag>else<currentTiddler>]">
<ol class="tc-toc toc-expandable">
2024-05-04 13:28:11 +00:00
<!-- Text substitution is needed for backwards compatibility -->
2024-02-05 19:07:10 +00:00
<$list filter=` [subfilter<tf.toc-filter>]
:else[subfilter<tf.toc-filterString>$(sort)$]
[subfilter<tf.toc-include>] -[<tag>] -[subfilter<exclude>]`>
<%if [<currentTiddler>] -[subfilter<tf.toc-hide>] %>
<$let _path=<<tf.toc-newPath>> _mode=<<tf.toc-mode>> >
<$set name="_excluded" filter="[subfilter<exclude>] [<tag>] [subfilter<tf.toc-hide>]">
<% if [all[current]toc-link[no]] %>
<$macrocall $name="toc-unlinked-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% else %>
<$macrocall $name="toc-linked-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% endif %>
</$set>
</$let>
<% endif %>
</$list>
</ol>
</$set>
\end
\function tf.toc-curTidInclude() [<currentTiddler>get<toc-includeField>] [<currentTiddler>get<toc-filterField>]
2024-02-07 12:17:38 +00:00
\procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,tagField,parentField,itemTemplate)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>>>
<li class=<<tf.toc-itemClass>>>
<!-- v5.1.23 use target-field if present in tiddler -->
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
2024-05-04 13:28:11 +00:00
<!-- The subfilter<exclude> must to be the last filter run -->
<% if [subfilter<tf.toc-hasChildren>] [subfilter<tf.toc-curTidInclude>] -[<currentTiddler>] -[subfilter<exclude>] +[limit[1]] %>
<<toc-item>>
<% else %>
<$button class='tc-btn-invisible tc-tiny-gap-right' tabindex="-1">
{{$:/core/images/blank}}
</$button>
<% endif %>
<<_itemTemplate>>
</$link>
<!-- TODO auto expand -->
<% if [<toc-state>get[text]match[open]] %>
<$macrocall $name="toc-selective-expandable"
tag=<<currentTiddler>> sort=<<sort>> exclude=<<exclude>> path=<<path>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
</$qualify>
\end
2024-05-04 13:28:11 +00:00
<!-- Keep them for now -->
<!-- <$log
ct=<<currentTiddler>>
tf.toc-hasChildren=<<tf.toc-hasChildren>>
2024-07-23 10:49:08 +00:00
tf.toc-hasChildren-f= {{{ [subfilter<tf.toc-hasChildren>] +[join[, ]] }}}
2024-05-04 13:28:11 +00:00
filter={{{ [subfilter<tf.toc-hasChildren>] [subfilter<tf.toc-curTidInclude>] -[<currentTiddler>] -[subfilter<exclude>] }}}
2024-07-23 10:49:08 +00:00
exclude=<<exclude>>
tag=<<tag>>
hasTagField={{{ [has<tagField>join[, ]] }}}
2024-05-04 13:28:11 +00:00
/> -->
2024-07-23 10:49:08 +00:00
<!-- <$log ct=<<currentTiddler>>
includeList={{{ [subfilter<tf.toc-hasChildren>] [subfilter<tf.toc-curTidInclude>] -[subfilter<exclude>] +[limit[1]] }}}
hasChildren={{{ [subfilter<tf.toc-hasChildren>] }}} path=<<path>> exclude=<<exclude>>/>
-->
2024-02-07 12:17:38 +00:00
\procedure toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,tagField,parentField,itemTemplate)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
<li class=<<tf.toc-itemClass>>>
<% if [subfilter<tf.toc-hasChildren>] [subfilter<tf.toc-curTidInclude>] -[<currentTiddler>] -[subfilter<exclude>] +[limit[1]] %>
<<toc-item isUnlinked:"yes">>
<% else %>
2024-07-23 10:49:08 +00:00
<$button class="tc-btn-invisible tc-tiny-gap">
{{$:/core/images/blank}}
</$button>
<span class="toc-item-muted">
<<_itemTemplate>>
</span>
<% endif %>
<!-- TODO auto expand -->
<% if [<toc-state>get[text]match[open]] %>
<$macrocall $name="toc-selective-expandable"
tag=<<currentTiddler>> sort=<<sort>> exclude=<<exclude>> path=<<path>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
</$qualify>
\end
<!-- =====================================================
2024-05-04 13:28:11 +00:00
Shows a selctive expandable toc.
If an item has no children, there is no open/close chevron
========================================================== -->
2024-02-07 12:17:38 +00:00
\procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path,captionField,tagField,parentField,itemTemplate)
<$set name=currentTiddler filter="[<parentField>!is[blank]then<tag>else<currentTiddler>]">
<ol class="tc-toc toc-selective-expandable">
<!-- text substitution is needed for backwards compatibility -->
2024-02-05 19:07:10 +00:00
<$list filter=` [subfilter<tf.toc-filter>]
:else[subfilter<tf.toc-filterString>$(sort)$]
[subfilter<tf.toc-include>] -[<tag>] -[subfilter<exclude>]`>
<%if [<currentTiddler>] -[subfilter<tf.toc-hide>] %>
<$let _path=<<tf.toc-newPath>> _mode=<<tf.toc-mode>> >
<$set name="_excluded" filter="[subfilter<exclude>] [<tag>] [subfilter<tf.toc-hide>]">
<% if [all[current]toc-link[no]] %>
<$macrocall $name="toc-unlinked-selective-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% else %>
<$macrocall $name="toc-linked-selective-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
<% endif %>
</$set>
</$let>
<% endif %>
</$list>
</ol>
</$set>
\end
2014-11-13 21:39:28 +00:00
2024-05-04 13:28:11 +00:00
<!-- ====================================================================
Shows a tabbed toc.
2024-05-04 13:28:11 +00:00
If a toc-item link is clicked it will open the tiddler in the story river
========================================================================= -->
2024-02-07 12:17:38 +00:00
\procedure toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude,captionField,tagField,parentField,itemTemplate)
<$tiddler tiddler={{{ [<selectedTiddler>get[text]] }}}>
<div class="tc-tabbed-table-of-contents">
<$linkcatcher to=<<selectedTiddler>>>
<div class="tc-table-of-contents">
<!-- v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter -->
<$macrocall $name="toc-selective-expandable"
tag=<<tag>> sort=<<sort>> exclude=<<exclude>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>> tagField=<<tagField>> parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
</div>
</$linkcatcher>
<div class="tc-tabbed-table-of-contents-content">
<$reveal stateTitle=<<selectedTiddler>> type="nomatch" text="">
<$transclude mode="block" tiddler=<<template>>>
<h1><<_itemTemplate>></h1>
<$transclude mode="block">$missingText$</$transclude>
</$transclude>
</$reveal>
<$reveal stateTitle=<<selectedTiddler>> type="match" text="">
<<unselectedText>>
</$reveal>
</div>
</div>
2014-11-13 21:39:28 +00:00
</$tiddler>
\end
<!-- ========================================================
2024-05-04 13:28:11 +00:00
Shows a tabbed toc. If a toc-item link is clicked
it will open the tiddler in the view area of the same tiddler
============================================================= -->
2024-02-07 12:17:38 +00:00
\procedure toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude,captionField,tagField,parentField,itemTemplate)
<$linkcatcher to=<<selectedTiddler>>>
<$macrocall $name="toc-tabbed-external-nav"
tag=<<tag>>
sort=<<sort>>
selectedTiddler=<<selectedTiddler>>
unselectedText=<<unselectedText>>
missingText=<<missingText>>
template=<<template>>
exclude=<<exclude>>
2024-02-07 12:17:38 +00:00
captionField=<<captionField>>
tagField=<<tagField>>
parentField=<<parentField>>
itemTemplate=<<itemTemplate>>
/>
2014-11-13 21:39:28 +00:00
</$linkcatcher>
\end