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