1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-11 18:50:28 +00:00

rename toc-captionField to toc-defaultItemTemplate and lists call toc-itemTemplate which is a new proc

This commit is contained in:
pmario 2024-02-07 11:30:10 +01:00
parent a2afdc8c96
commit 9b53df00a1

View File

@ -3,11 +3,11 @@ tags: $:/tags/Macro
\whitespace trim
\procedure toc-captionField()
\procedure toc-defaultItemTemplate()
<span class="tc-toc-caption tc-tiny-gap-left" title={{!!tooltip}}>
<$let tv-wikilinks="no">
<$transclude $tiddler={{{ [<captionFieldTemplate>!is[blank]then<captionFieldTemplate>else<currentTiddler>] }}}
$field={{{ [<captionFieldTemplate>!is[blank]then[text]] :else[<captionField>!is[blank]then<captionField>else[caption]] }}}
<$transclude $tiddler={{{ [<itemTemplate>!is[blank]then<itemTemplate>else<currentTiddler>] }}}
$field={{{ [<itemTemplate>!is[blank]then[text]] :else[<captionField>!is[blank]then<captionField>else[caption]] }}}
>
<$view field="title"/>
</$transclude>
@ -15,6 +15,15 @@ tags: $:/tags/Macro
</span>
\end
<!-- returns the title of an itemTemplate tiddler -->
\function tf.toc-getItemTemplate() [<itemTemplate>!is[blank]then<itemTemplate>] :else[<currentTiddler>get[toc-itemTemplate]]
\procedure toc-itemTemplate()
<$transclude $tiddler=<<tf.toc-getItemTemplate>> >
<<toc-defaultItemTemplate>>
</$transclude>
\end
<!-- v5.2.4 add "Custom Icons" -->
\procedure toc-open-icon() $:/core/images/down-arrow
\procedure toc-closed-icon() $:/core/images/right-arrow
@ -67,11 +76,11 @@ tags: $:/tags/Macro
<$set name="_excluded" filter="[subfilter<exclude>] [<tag>] [subfilter<tf.toc-hide>]">
<li class=<<tf.toc-itemClass>>>
<% if [all[current]toc-link[no]] %>
<<toc-captionField>>
<<toc-itemTemplate>>
<% else %>
<!-- v5.1.23 use target-field if present in tiddler -->
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
<<toc-captionField>>
<<toc-itemTemplate>>
</$link>
<% endif %>
<$macrocall
@ -94,28 +103,28 @@ Simple toc macro which alwayse shows the full tree
This macro is _not_ used by other toc-macros
v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter
================================================================== -->
\procedure toc(tag, sort:"", itemClassFilter, exclude, tagField, parentField, captionField, captionFieldTemplate)
\procedure toc(tag, sort:"", itemClassFilter, exclude, tagField, parentField, captionField, itemTemplate)
<$macrocall $name="toc-body" tag=<<tag>> sort=<<sort>> exclude=<<exclude>>/>
\end
<!--
If a toc-itme shows a link. Clicking the caption will open the tiddler
If toc-item is linked, the toc-captionField is managed in the parent procedure
If a toc-item should not show a link, the toc-captionField is part of the button. So it can be clicked to open / close the branch
If toc-item is linked, the toc-itemTemplate is managed in the parent procedure
If a toc-item should not show a link, the toc-itemTemplate is part of the button. So it can be clicked to open / close the branch
-->
\procedure toc-item(isUnlinked:"")
<% if [<toc-state>get[text]else[close]match[close]] %>
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep" tooltip=<<toc-state>>>
<$transclude tiddler=<<toc-closed-icon>> />
<% if [<isUnlinked>match[yes]] %>
<<toc-captionField>>
<<toc-itemTemplate>>
<% endif %>
</$button>
<% elseif [<toc-state>get[text]match[open]] %>
<$button setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep" tooltip=<<toc-state>>>
<$transclude tiddler=<<toc-open-icon>> />
<% if [<isUnlinked>match[yes]] %>
<<toc-captionField>>
<<toc-itemTemplate>>
<% endif %>
</$button>
<% endif %>
@ -123,27 +132,27 @@ v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter
\function tf.toc-stateTitle() [[$:/state/toc]] [<path>] "/" [<currentTiddler>] +[join[]]
\procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,captionFieldTemplate)
\procedure toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,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>>
<<toc-captionField>>
<<toc-itemTemplate>>
</$link>
<!-- TODO auto expand -->
<% if [<toc-state>get[text]match[open]] %>
<$macrocall
$name="toc-expandable"
tag=<<currentTiddler>> sort=<<sort>> exclude=<<exclude>> path=<<path>>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
</$qualify>
\end
\procedure toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,captionFieldTemplate)
\procedure toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,itemTemplate)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>>>
<li class=<<tf.toc-itemClass>>>
<<toc-item isUnlinked:"yes">>
@ -152,7 +161,7 @@ v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter
<$macrocall
$name="toc-expandable"
tag=<<currentTiddler>> sort=<<sort>> exclude=<<exclude>> path=<<path>>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
@ -162,7 +171,7 @@ v5.3.4 itemClassFilter has been replaced by tf.toc-itemClassFilter
<!-- ==========================================================
Shows an expandable toc. Item always have an open/close chevron
=============================================================== -->
\procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path, captionField, captionFieldTemplate)
\procedure toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path, captionField, itemTemplate)
<ol class="tc-toc toc-expandable">
<!-- text substitution is needed for backwards compatibility -->
<$list filter=` [subfilter<tf.toc-filter>]
@ -175,13 +184,13 @@ Shows an expandable toc. Item always have an open/close chevron
<$macrocall
$name="toc-unlinked-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% else %>
<$macrocall
$name="toc-linked-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% endif %>
</$set>
@ -193,7 +202,7 @@ Shows an expandable toc. Item always have an open/close chevron
\function tf.toc-curTidInclude() [<currentTiddler>get<toc-include-field>]
\procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,captionFieldTemplate)
\procedure toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,itemTemplate)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>>>
<li class=<<tf.toc-itemClass>>>
<!-- v5.1.23 use target-field if present in tiddler -->
@ -206,21 +215,21 @@ Shows an expandable toc. Item always have an open/close chevron
{{$:/core/images/blank}}
</$button>
<% endif %>
<<toc-captionField>>
<<toc-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>>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
</$qualify>
\end
\procedure toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,captionFieldTemplate)
\procedure toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path,captionField,itemTemplate)
<$qualify name="toc-state" title=<<tf.toc-stateTitle>> >
<li class=<<tf.toc-itemClass>>>
<% if [all[current]tagging[]] [subfilter<tf.toc-curTidInclude>] -[subfilter<exclude>] +[limit[1]] %>
@ -230,7 +239,7 @@ Shows an expandable toc. Item always have an open/close chevron
{{$:/core/images/blank}}
</$button>
<span class="toc-item-muted">
<<toc-captionField>>
<<toc-itemTemplate>>
</span>
<% endif %>
<!-- TODO auto expand -->
@ -238,7 +247,7 @@ Shows an expandable toc. Item always have an open/close chevron
<$macrocall
$name="toc-selective-expandable"
tag=<<currentTiddler>> sort=<<sort>> exclude=<<exclude>> path=<<path>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% endif %>
</li>
@ -249,7 +258,7 @@ Shows an expandable toc. Item always have an open/close chevron
Shows a selctive expandable toc.
If an item has no children, there is no open/close chevron
========================================================== -->
\procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path,captionField,captionFieldTemplate)
\procedure toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path,captionField,itemTemplate)
<ol class="tc-toc toc-selective-expandable">
<!-- text substitution is needed for backwards compatibility -->
<$list filter=` [subfilter<tf.toc-filter>]
@ -262,13 +271,13 @@ If an item has no children, there is no open/close chevron
<$macrocall
$name="toc-unlinked-selective-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% else %>
<$macrocall
$name="toc-linked-selective-expandable-body"
tag=<<tag>> sort=<<sort>> exclude=<<_excluded>> path=<<_path>>
captionField=<<captionField>> captionFieldTemplate=<<captionFieldTemplate>>
captionField=<<captionField>> itemTemplate=<<itemTemplate>>
/>
<% endif %>
</$set>
@ -282,7 +291,7 @@ If an item has no children, there is no open/close chevron
Shows a tabbed toc.
If a toc-item link is clicked it will open the tiddler in the story
=================================================================== -->
\procedure toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude, captionField, captionFieldTemplate)
\procedure toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude, captionField, itemTemplate)
<$tiddler tiddler={{{ [<selectedTiddler>get[text]] }}}>
<div class="tc-tabbed-table-of-contents">
<$linkcatcher to=<<selectedTiddler>>>
@ -294,14 +303,14 @@ If a toc-item link is clicked it will open the tiddler in the story
sort=<<sort>>
exclude=<<exclude>>
captionField=<<captionField>>
captionFieldTemplate=<<captionFieldTemplate>>
itemTemplate=<<itemTemplate>>
/>
</div>
</$linkcatcher>
<div class="tc-tabbed-table-of-contents-content">
<$reveal stateTitle=<<selectedTiddler>> type="nomatch" text="">
<$transclude mode="block" tiddler=<<template>>>
<h1><<toc-captionField>></h1>
<h1><<toc-itemTemplate>></h1>
<$transclude mode="block">$missingText$</$transclude>
</$transclude>
</$reveal>
@ -317,7 +326,7 @@ If a toc-item link is clicked it will open the tiddler in the story
Shows a tabbed toc. If a toc-item link is clicked
it will open the tiddler in the view area of the same tiddler
============================================================= -->
\procedure toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude,captionField,captionFieldTemplate)
\procedure toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude,captionField,itemTemplate)
<$linkcatcher to=<<selectedTiddler>>>
<$macrocall
$name="toc-tabbed-external-nav"
@ -329,7 +338,7 @@ it will open the tiddler in the view area of the same tiddler
template=<<template>>
exclude=<<exclude>>
captionField=<<captionField>>
captionFieldTemplate=<<captionFieldTemplate>>
itemTemplate=<<itemTemplate>>
/>
</$linkcatcher>
\end