Make tag-macro and tag*-templates human readable for future improvements (#7559)

This commit is contained in:
Mario Pietsch 2023-06-24 15:52:43 +02:00 committed by GitHub
parent a5c258ecac
commit e5566543c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 39 deletions

View File

@ -3,15 +3,14 @@ tags: $:/tags/MoreSideBar
caption: {{$:/language/SideBar/Tags/Caption}} caption: {{$:/language/SideBar/Tags/Caption}}
\whitespace trim \whitespace trim
<$let tv-config-toolbar-icons="yes" tv-config-toolbar-text="yes" tv-config-toolbar-class=""> <$let tv-config-toolbar-icons="yes" tv-config-toolbar-text="yes" tv-config-toolbar-class="">
<div class="tc-tiny-v-gap-bottom"> <div class="tc-tiny-v-gap-bottom">
{{$:/core/ui/Buttons/tag-manager}} {{$:/core/ui/Buttons/tag-manager}}
</div> </div>
</$let> </$let>
<$list filter={{$:/core/Filters/AllTags!!filter}}> <$list filter={{$:/core/Filters/AllTags!!filter}}>
<div class="tc-tiny-v-gap-bottom"> <div class="tc-tiny-v-gap-bottom">
<$transclude tiddler="$:/core/ui/TagTemplate"/> <$transclude tiddler="$:/core/ui/TagTemplate"/>
</div> </div>
</$list> </$list>
<hr class="tc-untagged-separator"> <hr class="tc-untagged-separator">

View File

@ -2,22 +2,29 @@ title: $:/core/ui/TagPickerTagTemplate
\whitespace trim \whitespace trim
<$button class=<<button-classes>> tag="a" tooltip={{$:/language/EditTemplate/Tags/Add/Button/Hint}}> <$button class=<<button-classes>> tag="a" tooltip={{$:/language/EditTemplate/Tags/Add/Button/Hint}}>
<$list filter="[<saveTiddler>minlength[1]]"> <$list filter="[<saveTiddler>minlength[1]]">
<$action-listops $tiddler=<<saveTiddler>> $field=<<tagField>> $subfilter="[<tag>]"/> <$action-listops $tiddler=<<saveTiddler>> $field=<<tagField>> $subfilter="[<tag>]"/>
</$list> </$list>
<$set name="currentTiddlerCSSEscaped" value={{{ [<saveTiddler>escapecss[]] }}}> <$set name="currentTiddlerCSSEscaped" value={{{ [<saveTiddler>escapecss[]] }}}>
<$action-sendmessage $message="tm-focus-selector" $param=<<get-tagpicker-focus-selector>> preventScroll="true"/> <$action-sendmessage $message="tm-focus-selector" $param=<<get-tagpicker-focus-selector>> preventScroll="true"/>
</$set> </$set>
<<delete-tag-state-tiddlers>> <<delete-tag-state-tiddlers>>
<$list filter="[<refreshTitle>minlength[1]]"> <$list filter="[<refreshTitle>minlength[1]]">
<$action-setfield $tiddler=<<refreshTitle>> text="yes"/> <$action-setfield $tiddler=<<refreshTitle>> text="yes"/>
</$list> </$list>
<<actions>> <<actions>>
<$set name="backgroundColor" value={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}}> <$set name="backgroundColor"
<$wikify name="foregroundColor" text="""<$macrocall $name="contrastcolour" target=<<backgroundColor>> fallbackTarget=<<fallbackTarget>> colourA=<<colourA>> colourB=<<colourB>>/>"""> value={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}}
<span class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>> data-tag-title=<<currentTiddler>> > >
{{||$:/core/ui/TiddlerIcon}}<$view field="title" format="text"/> <$wikify name="foregroundColor"
</span> text="""<$macrocall $name="contrastcolour" target=<<backgroundColor>> fallbackTarget=<<fallbackTarget>> colourA=<<colourA>> colourB=<<colourB>>/>"""
</$wikify> >
</$set> <span class="tc-tag-label tc-btn-invisible"
style=<<tag-pill-styles>>
data-tag-title=<<currentTiddler>>
>
{{||$:/core/ui/TiddlerIcon}}<$view field="title" format="text"/>
</span>
</$wikify>
</$set>
</$button> </$button>

View File

@ -3,16 +3,23 @@ title: $:/core/ui/TagTemplate
\whitespace trim \whitespace trim
<span class="tc-tag-list-item" data-tag-title=<<currentTiddler>>> <span class="tc-tag-list-item" data-tag-title=<<currentTiddler>>>
<$set name="transclusion" value=<<currentTiddler>>> <$set name="transclusion" value=<<currentTiddler>>>
<$macrocall $name="tag-pill-body" tag=<<currentTiddler>> icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} element-tag="""$button""" element-attributes="""popup=<<qualify "$:/state/popup/tag">> dragFilter='[all[current]tagging[]]' tag='span'"""/> <$macrocall $name="tag-pill-body"
<$reveal state=<<qualify "$:/state/popup/tag">> type="popup" position="below" animate="yes" class="tc-drop-down"> tag=<<currentTiddler>>
<$set name="tv-show-missing-links" value="yes"> icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}}
<$transclude tiddler="$:/core/ui/ListItemTemplate"/> colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}}
</$set> palette={{$:/palette}}
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TagDropdown]!has[draft.of]]" variable="listItem"> element-tag="$button"
<$transclude tiddler=<<listItem>>/> element-attributes="""popup=<<qualify "$:/state/popup/tag">> dragFilter="[all[current]tagging[]]" tag='span'"""
</$list> />
<hr> <$reveal state=<<qualify "$:/state/popup/tag">> type="popup" position="below" animate="yes" class="tc-drop-down">
<$macrocall $name="list-tagged-draggable" tag=<<currentTiddler>>/> <$set name="tv-show-missing-links" value="yes">
</$reveal> <$transclude tiddler="$:/core/ui/ListItemTemplate"/>
</$set>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TagDropdown]!has[draft.of]]" variable="listItem">
<$transclude tiddler=<<listItem>>/>
</$list>
<hr>
<$macrocall $name="list-tagged-draggable" tag=<<currentTiddler>>/>
</$reveal>
</$set> </$set>
</span> </span>

View File

@ -9,26 +9,50 @@ color:$(foregroundColor)$;
<!-- This has no whitespace trim to avoid modifying $actions$. Closing tags omitted for brevity. --> <!-- This has no whitespace trim to avoid modifying $actions$. Closing tags omitted for brevity. -->
\define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions) \define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions)
\whitespace trim
<$vars <$vars
foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">>
backgroundColor="""$colour$""" backgroundColor=<<__colour__>>
><$element-tag$ >
<$element-tag$
$element-attributes$ $element-attributes$
class="tc-tag-label tc-btn-invisible" class="tc-tag-label tc-btn-invisible"
style=<<tag-pill-styles>> style=<<tag-pill-styles>>
>$actions$<$transclude tiddler="""$icon$"""/><$view tiddler=<<__tag__>> field="title" format="text" /></$element-tag$> >
<<__actions__>>
<$transclude tiddler=<<__icon__>>/>
<$view tiddler=<<__tag__>> field="title" format="text" />
</$element-tag$>
\end \end
\define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions) \define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions)
<$macrocall $name="tag-pill-inner" tag=<<__tag__>> icon="""$icon$""" colour="""$colour$""" fallbackTarget={{$palette$##tag-background}} colourA={{$palette$##foreground}} colourB={{$palette$##background}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/> \whitespace trim
<$macrocall $name="tag-pill-inner"
tag=<<__tag__>>
icon=<<__icon__>>
colour=<<__colour__>>
fallbackTarget={{$palette$##tag-background}}
colourA={{$palette$##foreground}}
colourB={{$palette$##background}}
element-tag=<<__element-tag__>>
element-attributes=<<__element-attributes__>>
actions=<<__actions__>>
/>
\end \end
\define tag-pill(tag,element-tag:"span",element-attributes:"",actions:"") \define tag-pill(tag,element-tag:"span",element-attributes:"",actions:"")
\whitespace trim \whitespace trim
<span class="tc-tag-list-item" data-tag-title=<<__tag__>>> <span class="tc-tag-list-item" data-tag-title=<<__tag__>>>
<$let currentTiddler=<<__tag__>>> <$let currentTiddler=<<__tag__>>>
<$macrocall $name="tag-pill-body" tag=<<__tag__>> icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/> <$macrocall $name="tag-pill-body"
</$let> tag=<<__tag__>>
icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}}
colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}}
palette={{$:/palette}}
element-tag=<<__element-tag__>>
element-attributes=<<__element-attributes__>>
actions=<<__actions__>>/>
</$let>
</span> </span>
\end \end