This commit is contained in:
lin onetwo 2025-12-04 23:08:25 +08:00 committed by GitHub
commit 5701dfc805
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View file

@ -11,9 +11,13 @@ tags: $:/tags/ViewTemplate
storyview="pop" storyview="pop"
variable="listItem" variable="listItem"
> >
<$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]"> <$let condition={{{ [<listItem>get[condition]] }}}>
<$transclude tiddler=<<listItem>>/> <%if [<condition>!is[blank]] :and[<currentTiddler>subfilter<condition>limit[1]] :else[<condition>is[blank]then[true]] %>
</$set> <$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]">
<$transclude tiddler=<<listItem>>/>
</$set>
<%endif%>
</$let>
</$list> </$list>
</span> </span>
<$set name="tv-wikilinks" value={{$:/config/Tiddlers/TitleLinks}}> <$set name="tv-wikilinks" value={{$:/config/Tiddlers/TitleLinks}}>

View file

@ -0,0 +1,15 @@
title: $:/changenotes/5.4.0/#9466
description: ViewToolbar buttons now support condition field
tags: $:/tags/ChangeNote
release: 5.4.0
change-type: feature
change-category: hackability
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9466
github-contributors: linonetwo
ViewToolbar buttons can now be conditionally displayed based on the currentTiddler using a `condition` field. Similar to how `$:/tags/Exporter` and `$:/tags/EditorTools` already have. An example would be:
```tid
tags: $:/tags/ViewToolbar
condition: [<currentTiddler>type[text/x-markdown]] [<currentTiddler>type[text/markdown]]
```