mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-10 09:20:26 +00:00
249 lines
8.3 KiB
Plaintext
249 lines
8.3 KiB
Plaintext
title: $:/core/macros/toc
|
|
tags: $:/tags/Macro
|
|
|
|
\whitespace trim
|
|
|
|
<!-- v5.2.4 add "Custom Icons" -->
|
|
\procedure toc-open-icon() $:/core/images/down-arrow
|
|
\procedure toc-closed-icon() $:/core/images/right-arrow
|
|
|
|
<!-- v5.3.4 complrete rewrite -->
|
|
\function tf.toc-stateTitle() [[$:/state/toc]addsuffix<path>addsuffix[/]addsuffix<currentTiddler>]
|
|
|
|
\procedure toc-caption()
|
|
<span class="tc-toc-caption tc-tiny-gap-left">
|
|
<$set name="tv-wikilinks" value="no">
|
|
<$transclude field="caption">
|
|
<$view field="title"/>
|
|
</$transclude>
|
|
</$set>
|
|
</span>
|
|
\end
|
|
|
|
<!-- v5.3.4 rewrite -->
|
|
\function tf.toc-newPath() [<path>addsuffix[/]addsuffix<tag>]
|
|
|
|
\procedure toc-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<ol class="tc-toc">
|
|
<!-- text substitution is needed for backwards compatibility -->
|
|
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
|
|
<$let item=<<currentTiddler>> path=<<tf.toc-newPath>> >
|
|
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]">
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<% if [all[current]toc-link[no]] %>
|
|
<<toc-caption>>
|
|
<% else %>
|
|
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
|
|
<<toc-caption>>
|
|
</$link>
|
|
<% endif %>
|
|
<$macrocall
|
|
$name="toc-body"
|
|
tag=<<item>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>
|
|
/>
|
|
</li>
|
|
</$set>
|
|
</$let>
|
|
</$list>
|
|
</ol>
|
|
\end
|
|
|
|
\procedure toc(tag,sort:"",itemClassFilter:"",exclude)
|
|
<$macrocall $name="toc-body" tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>>/>
|
|
\end
|
|
|
|
<!--
|
|
If a toc-itme shows a link. Clicking the caption will open the tiddler
|
|
If toc-item is linked, the toc-caption is managed in the parent procedure
|
|
If a toc-item should not show a link, the toc-caption is part of the button. So it can be clicked to open / close the branch
|
|
-->
|
|
\procedure toc-item(isUnlinked:"")
|
|
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
|
|
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
|
|
<$transclude tiddler=<<toc-closed-icon>> />
|
|
<% if [<isUnlinked>match[yes]] %>
|
|
<<toc-caption>>
|
|
<% endif %>
|
|
</$button>
|
|
</$reveal>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$button setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep">
|
|
<$transclude tiddler=<<toc-open-icon>> />
|
|
<% if [<isUnlinked>match[yes]] %>
|
|
<<toc-caption>>
|
|
<% endif %>
|
|
</$button>
|
|
</$reveal>
|
|
\end
|
|
|
|
\procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
|
|
<<toc-item>>
|
|
<<toc-caption>>
|
|
</$link>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall
|
|
$name="toc-expandable"
|
|
tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>
|
|
/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
\procedure toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$qualify name="toc-state" title=<<tf.toc-stateTitle>>>
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<<toc-item isUnlinked:"yes">>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall
|
|
$name="toc-expandable"
|
|
tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>
|
|
/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
\procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path)
|
|
<$let path=<<tf.toc-newPath>>>
|
|
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]">
|
|
<ol class="tc-toc toc-expandable">
|
|
<!-- text substitution is needed for backwards compatibility -->
|
|
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
|
|
<% if [all[current]toc-link[no]] %>
|
|
<$macrocall
|
|
$name="toc-unlinked-expandable-body"
|
|
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>
|
|
/>
|
|
<% else %>
|
|
<$macrocall
|
|
$name="toc-linked-expandable-body"
|
|
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>
|
|
/>
|
|
<% endif %>
|
|
</$list>
|
|
</ol>
|
|
</$set>
|
|
</$let>
|
|
\end
|
|
|
|
\procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$qualify name="toc-state" title=<<tf.toc-stateTitle>>>
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
|
|
<% if [all[current]tagging[]] -[subfilter<exclude>] +[limit[1]] %>
|
|
<<toc-item>>
|
|
<% else %>
|
|
<$button class='tc-btn-invisible'>
|
|
{{$:/core/images/blank}}
|
|
</$button>
|
|
<% endif %>
|
|
<<toc-caption>>
|
|
</$link>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall
|
|
$name="toc-selective-expandable"
|
|
tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>
|
|
/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
<!-- At the moment the following function is only used by "tabbed" tocs -->
|
|
\function tf.toc-getItemClass() [<selectedTiddler>get[text]match<currentTiddler>then[toc-item-selected]else[toc-item]]
|
|
|
|
\procedure toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
|
|
<li class=<<tf.toc-getItemClass>>>
|
|
<% if [all[current]tagging[]] -[subfilter<exclude>] +[limit[1]] %>
|
|
<<toc-item isUnlinked:"yes">>
|
|
<% else %>
|
|
<$button class="tc-btn-invisible">
|
|
{{$:/core/images/blank}}
|
|
</$button>
|
|
<span class="toc-item-muted">
|
|
<<toc-caption>>
|
|
</span>
|
|
<% endif %>
|
|
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
|
<$macrocall
|
|
$name="toc-selective-expandable"
|
|
tag=<<currentTiddler>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<exclude>> path=<<path>>
|
|
/>
|
|
</$reveal>
|
|
</li>
|
|
</$qualify>
|
|
\end
|
|
|
|
\procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path)
|
|
<$let tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> path=<<tf.toc-newPath>>>
|
|
<$set name="excluded" filter="[subfilter<exclude>] [<tag>]">
|
|
<ol class="tc-toc toc-selective-expandable">
|
|
<!-- text substitution is needed for backwards compatibility -->
|
|
<$list filter=`[all[shadows+tiddlers]tag<tag>!has[draft.of]$(sort)$] -[<tag>] -[subfilter<exclude>]`>
|
|
<% if [all[current]toc-link[no]] %>
|
|
<$macrocall
|
|
$name="toc-unlinked-selective-expandable-body"
|
|
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>
|
|
/>
|
|
<% else %>
|
|
<$macrocall
|
|
$name="toc-linked-selective-expandable-body"
|
|
tag=<<tag>> sort=<<sort>> itemClassFilter=<<itemClassFilter>> exclude=<<excluded>> path=<<path>>
|
|
/>
|
|
<% endif %>
|
|
</$list>
|
|
</ol>
|
|
</$set>
|
|
</$let>
|
|
\end
|
|
|
|
\procedure toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude)
|
|
<$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-getItemClass -->
|
|
<$macrocall
|
|
$name="toc-selective-expandable"
|
|
tag=<<tag>>
|
|
sort=<<sort>>
|
|
itemClassFilter="[all[current]] -[<selectedTiddler>get[text]]"
|
|
exclude=<<exclude>>
|
|
/>
|
|
</div>
|
|
</$linkcatcher>
|
|
<div class="tc-tabbed-table-of-contents-content">
|
|
<$reveal stateTitle=<<selectedTiddler>> type="nomatch" text="">
|
|
<$transclude mode="block" tiddler=<<template>>>
|
|
<h1><<toc-caption>></h1>
|
|
<$transclude mode="block">$missingText$</$transclude>
|
|
</$transclude>
|
|
</$reveal>
|
|
<$reveal stateTitle=<<selectedTiddler>> type="match" text="">
|
|
<<unselectedText>>
|
|
</$reveal>
|
|
</div>
|
|
</div>
|
|
</$tiddler>
|
|
\end
|
|
|
|
\procedure toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude)
|
|
<$linkcatcher to=<<selectedTiddler>>>
|
|
<$macrocall
|
|
$name="toc-tabbed-external-nav"
|
|
tag=<<tag>>
|
|
sort=<<sort>>
|
|
selectedTiddler=<<selectedTiddler>>
|
|
unselectedText=<<unselectedText>>
|
|
missingText=<<missingText>>
|
|
template=<<template>>
|
|
exclude=<<exclude>>
|
|
/>
|
|
</$linkcatcher>
|
|
\end
|