1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 05:19:57 +00:00

Rewrite more macros.

This commit is contained in:
Leilei332 2024-11-22 19:32:22 +08:00
parent 6b23de81d8
commit 35696e431c
6 changed files with 69 additions and 69 deletions

View File

@ -46,7 +46,7 @@ tags: $:/tags/Macro
--- ---
<$edit-text tiddler="$:/config/ColourPicker/New" tag="input" default="" placeholder="" class="tc-small-gap-right"/> <$edit-text tiddler="$:/config/ColourPicker/New" tag="input" default="" placeholder="" class="tc-tiny-gap-right"/>
<$edit-text tiddler="$:/config/ColourPicker/New" type="color" tag="input"/> <$edit-text tiddler="$:/config/ColourPicker/New" type="color" tag="input"/>
<$set name="colour-picker-value" value={{$:/config/ColourPicker/New}}> <$set name="colour-picker-value" value={{$:/config/ColourPicker/New}}>
<%if [{$:/config/ColourPicker/New}!is[blank]] %> <%if [{$:/config/ColourPicker/New}!is[blank]] %>

View File

@ -1,7 +1,7 @@
title: $:/core/macros/dumpvariables title: $:/core/macros/dumpvariables
tags: $:/tags/Macro tags: $:/tags/Macro
\define dumpvariables() \procedure dumpvariables()
\whitespace trim \whitespace trim
<ul> <ul>
<$list filter="[variables[]]" variable="varname"> <$list filter="[variables[]]" variable="varname">

View File

@ -1,14 +1,14 @@
title: $:/core/macros/list title: $:/core/macros/list
tags: $:/tags/Macro tags: $:/tags/Macro
\define list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage,field:"caption") \procedure list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage,field:"caption")
\whitespace trim \whitespace trim
<$genesis $type=<<__type__>> class=<<__class__>>> <$genesis $type=<<type>> class=<<class>>>
<$list filter=<<__filter__>> emptyMessage=<<__emptyMessage__>>> <$list filter=<<filter>> emptyMessage=<<emptyMessage>>>
<$genesis $type=<<__subtype__>>> <$genesis $type=<<subtype>>>
<$link to={{!!title}}> <$link to={{!!title}}>
<$let tv-wikilinks="no"> <$let tv-wikilinks="no">
<$transclude field=<<__field__>>> <$transclude field=<<field>>>
<$view field="title"/> <$view field="title"/>
</$transclude> </$transclude>
</$let> </$let>
@ -18,24 +18,24 @@ tags: $:/tags/Macro
</$genesis> </$genesis>
\end \end
\define list-links-draggable-drop-actions() \procedure list-links-draggable-drop-actions()
<$action-listops $tiddler=<<targetTiddler>> $field=<<targetField>> $subfilter="+[insertbefore<actionTiddler>,<currentTiddler>]"/> <$action-listops $tiddler=<<targetTiddler>> $field=<<targetField>> $subfilter="+[insertbefore<actionTiddler>,<currentTiddler>]"/>
\end \end
\define list-links-draggable(tiddler,field:"list",emptyMessage,type:"ul",subtype:"li",class:"",itemTemplate) \procedure list-links-draggable(tiddler,field:"list",emptyMessage,type:"ul",subtype:"li",class:"",itemTemplate)
\whitespace trim \whitespace trim
<span class="tc-links-draggable-list"> <span class="tc-links-draggable-list">
<$vars targetTiddler="""$tiddler$""" targetField="""$field$"""> <$vars targetTiddler=<<tiddler>> targetField=<<field>>>
<$genesis $type=<<__type__>> class="$class$"> <$genesis $type=<<type>> class=<<class>>>
<$list filter="[list[$tiddler$!!$field$]]" emptyMessage=<<__emptyMessage__>>> <$list filter="[<tiddler>get<field>enlist-input[]]" emptyMessage=<<emptyMessage>>>
<$droppable <$droppable
actions=<<list-links-draggable-drop-actions>> actions=<<list-links-draggable-drop-actions>>
tag="""$subtype$""" tag=<<subtype>>
enable=<<tv-enable-drag-and-drop>> enable=<<tv-enable-drag-and-drop>>
> >
<div class="tc-droppable-placeholder"/> <div class="tc-droppable-placeholder"/>
<div> <div>
<$transclude tiddler="""$itemTemplate$"""> <$transclude tiddler=<<itemTemplate>>>
<$link to={{!!title}}> <$link to={{!!title}}>
<$let tv-wikilinks="no"> <$let tv-wikilinks="no">
<$transclude field="caption"> <$transclude field="caption">
@ -64,46 +64,46 @@ tags: $:/tags/Macro
</span> </span>
\end \end
\define list-tagged-draggable-drop-actions(tag) \procedure list-tagged-draggable-drop-actions(tag)
\whitespace trim \whitespace trim
<!-- Save the current ordering of the tiddlers with this tag --> <!-- Save the current ordering of the tiddlers with this tag -->
<$set name="order" filter="[<__tag__>tagging[]]"> <$set name="order" filter="[<tag>tagging[]]">
<!-- Remove any list-after or list-before fields from the tiddlers with this tag --> <!-- Remove any list-after or list-before fields from the tiddlers with this tag -->
<$list filter="[<__tag__>tagging[]]"> <$list filter="[<tag>tagging[]]">
<$action-deletefield $field="list-before"/> <$action-deletefield $field="list-before"/>
<$action-deletefield $field="list-after"/> <$action-deletefield $field="list-after"/>
</$list> </$list>
<!-- Save the new order to the Tag Tiddler --> <!-- Save the new order to the Tag Tiddler -->
<$action-listops $tiddler=<<__tag__>> $field="list" $filter="+[enlist<order>] +[insertbefore<actionTiddler>,<currentTiddler>]"/> <$action-listops $tiddler=<<tag>> $field="list" $filter="+[enlist<order>] +[insertbefore<actionTiddler>,<currentTiddler>]"/>
<!-- Make sure the newly added item has the right tag --> <!-- Make sure the newly added item has the right tag -->
<!-- Removing this line makes dragging tags within the dropdown work as intended --> <!-- Removing this line makes dragging tags within the dropdown work as intended -->
<!--<$action-listops $tiddler=<<actionTiddler>> $tags=<<__tag__>>/>--> <!--<$action-listops $tiddler=<<actionTiddler>> $tags=<<__tag__>>/>-->
<!-- Using the following 5 lines as replacement makes dragging titles from outside into the dropdown apply the tag --> <!-- Using the following 5 lines as replacement makes dragging titles from outside into the dropdown apply the tag -->
<$list filter="[<actionTiddler>!contains:tags<__tag__>]"> <$list filter="[<actionTiddler>!contains:tags<tag>]">
<$fieldmangler tiddler=<<actionTiddler>>> <$fieldmangler tiddler=<<actionTiddler>>>
<$action-sendmessage $message="tm-add-tag" $param=<<__tag__>>/> <$action-sendmessage $message="tm-add-tag" $param=<<tag>>/>
</$fieldmangler> </$fieldmangler>
</$list> </$list>
</$set> </$set>
\end \end
\define list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div",storyview:"") \procedure list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div",storyview:"")
\whitespace trim \whitespace trim
<span class="tc-tagged-draggable-list"> <span class="tc-tagged-draggable-list">
<$set name="tag" value=<<__tag__>>> <$set name="tag" value=<<tag>>>
<$list <$list
filter="[<__tag__>tagging[]$subFilter$]" filter=`[<tag>tagging[]$(subFilter)$]`
emptyMessage=<<__emptyMessage__>> emptyMessage=<<emptyMessage>>
storyview=<<__storyview__>> storyview=<<storyview>>
> >
<$genesis $type=<<__elementTag__>> class="tc-menu-list-item"> <$genesis $type=<<elementTag>> class="tc-menu-list-item">
<$droppable <$droppable
actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""" actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<tag>>/>"""
enable=<<tv-enable-drag-and-drop>> enable=<<tv-enable-drag-and-drop>>
> >
<$genesis $type=<<__elementTag__>> class="tc-droppable-placeholder"/> <$genesis $type=<<elementTag>> class="tc-droppable-placeholder"/>
<$genesis $type=<<__elementTag__>>> <$genesis $type=<<elementTag>>>
<$transclude tiddler="""$itemTemplate$"""> <$transclude tiddler=<<itemTemplate>>>
<$link to={{!!title}}> <$link to={{!!title}}>
<$view field="title"/> <$view field="title"/>
</$link> </$link>
@ -114,11 +114,11 @@ tags: $:/tags/Macro
</$list> </$list>
<$tiddler tiddler=""> <$tiddler tiddler="">
<$droppable <$droppable
actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""" actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<tag>>/>"""
enable=<<tv-enable-drag-and-drop>> enable=<<tv-enable-drag-and-drop>>
> >
<$genesis $type=<<__elementTag__>> class="tc-droppable-placeholder"/> <$genesis $type=<<elementTag>> class="tc-droppable-placeholder"/>
<$genesis $type=<<__elementTag__>> style="height:0.5em;"/> <$genesis $type=<<elementTag>> style="height:0.5em;"/>
</$droppable> </$droppable>
</$tiddler> </$tiddler>
</$set> </$set>

View File

@ -2,33 +2,34 @@ title: $:/core/macros/thumbnails
tags: $:/tags/Macro tags: $:/tags/Macro
<!-- This macro does not use \whitespace trim because it could affect the caption --> <!-- This macro does not use \whitespace trim because it could affect the caption -->
\define thumbnail(link,icon,color,background-color,image,caption,width:"280",height:"157") \procedure thumbnail(link,icon,color,background-color,image,caption,width:"280",height:"157")
<$link to="""$link$"""><div class="tc-thumbnail-wrapper" <$link to=<<link>>><div class="tc-thumbnail-wrapper"
><div ><div
class="tc-thumbnail-image" class="tc-thumbnail-image"
style="width:$width$px;height:$height$px;"><$reveal style.width={{{ [<width>addsuffix[px]] }}} style.height={{{ [<height>addsuffix[px]] }}}>
<$reveal
type="nomatch" type="nomatch"
text="" text=""
default="""$image$""" default=<<image>>
tag="div" tag="div"
style="width:$width$px;height:$height$px;" style=`width:$(width)$px;height:$(height)$px;`
>[img[$image$]]</$reveal><$reveal ><$image source=<<image>>/></$reveal><$reveal
type="match" type="match"
text="" text=""
default="""$image$""" default=<<image>>
tag="div" tag="div"
class="tc-thumbnail-background" class="tc-thumbnail-background"
style="width:$width$px;height:$height$px;background-color:$background-color$;" style=`width:$(width)$px;height:$(height)$px;background-color:$(background-color)$;`
></$reveal></div><div ></$reveal></div><div
class="tc-thumbnail-icon" class="tc-thumbnail-icon"
style="fill:$color$;color:$color$;" style.fill=<<color>> style.color=<<color>>
>$icon$</div><div class="tc-thumbnail-caption">$caption$</div></div></$link> ><<icon>></div><div class="tc-thumbnail-caption"><<caption>></div></div></$link>
\end \end
\define thumbnail-right(link,icon,color,background-color,image,caption,width:"280",height:"157") \procedure thumbnail-right(link,icon,color,background-color,image,caption,width:"280",height:"157")
<div class="tc-thumbnail-right-wrapper"><<thumbnail """$link$""" """$icon$""" """$color$""" """$background-color$""" """$image$""" """$caption$""" """$width$""" """$height$""">></div> <div class="tc-thumbnail-right-wrapper"><$transclude $variable="thumbnail" link=<<link>> icon=<<icon>> color=<<color>> background-color=<<background-color>> image=<<image>> caption=<<caption>> width=<<width>> height=<<height>>/></div>
\end \end
\define list-thumbnails(filter,width:"280",height:"157") \procedure list-thumbnails(filter,width:"280",height:"157")
<$list filter="""$filter$"""><$macrocall $name="thumbnail" link={{!!link}} icon={{!!icon}} color={{!!color}} background-color={{!!background-color}} image={{!!image}} caption={{!!caption}} width="""$width$""" height="""$height$"""/></$list> <$list filter=<<filter>>><$transclude $variable="thumbnail" link={{!!link}} icon={{!!icon}} color={{!!color}} background-color={{!!background-color}} image={{!!image}} caption={{!!caption}} width=<<width>> height=<<height>>/></$list>
\end \end

View File

@ -17,7 +17,7 @@ tags: $:/tags/Macro
<%endif%> <%endif%>
<%if [<mode>match[inline]] %> <%if [<mode>match[inline]] %>
<span class="tc-translink"> <span class="tc-translink">
<$link to=<<title>> class="tc-small-gap-right"> <$link to=<<title>> class="tc-tiny-gap-right">
<$text text=<<title>>/> <$text text=<<title>>/>
</$link> </$link>
(<$transclude tiddler=<<title>> mode="inline"> (<$transclude tiddler=<<title>> mode="inline">

View File

@ -1,62 +1,61 @@
title: $:/core/macros/tree title: $:/core/macros/tree
tags: $:/tags/Macro tags: $:/tags/Macro
\define leaf-link(full-title,chunk,separator: "/") \procedure leaf-link(full-title,chunk,separator: "/")
<$link to=<<__full-title__>>><$text text=<<__chunk__>>/></$link> <$link to=<<full-title>>><$text text=<<chunk>>/></$link>
\end \end
\define leaf-node(prefix,chunk) \procedure leaf-node(prefix,chunk)
\whitespace trim \whitespace trim
<li> <li>
<$list filter="[<__prefix__>addsuffix<__chunk__>is[shadow]] [<__prefix__>addsuffix<__chunk__>is[tiddler]]" variable="full-title"> <$list filter="[<prefix>addsuffix<chunk>is[shadow]] [<prefix>addsuffix<chunk>is[tiddler]]" variable="full-title">
<$list filter="[<full-title>removeprefix<__prefix__>]" variable="chunk"> <$list filter="[<full-title>removeprefix<prefix>]" variable="chunk">
<span>{{$:/core/images/file}}</span>&#32;<$macrocall $name="leaf-link" full-title=<<full-title>> chunk=<<chunk>>/> <span class="tc-tiny-gap-right">{{$:/core/images/file}}</span><$transclude $variable="leaf-link" full-title=<<full-title>> chunk=<<chunk>>/>
</$list> </$list>
</$list> </$list>
</li> </li>
\end \end
\define branch-node(prefix,chunk,separator: "/") \procedure branch-node(prefix,chunk,separator: "/")
\whitespace trim \whitespace trim
<li> <li>
<$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<__prefix__>addsuffix<__chunk__>] }}}> <$set name="reveal-state" value={{{ [[$:/state/tree/]addsuffix<prefix>addsuffix<chunk>] }}}>
<$reveal type="nomatch" stateTitle=<<reveal-state>> text="show"> <$reveal type="nomatch" stateTitle=<<reveal-state>> text="show">
<$button setTitle=<<reveal-state>> setTo="show" class="tc-btn-invisible"> <$button setTitle=<<reveal-state>> setTo="show" class="tc-btn-invisible">
{{$:/core/images/folder}}&#32;<$text text=<<__chunk__>>/> {{$:/core/images/folder}}&#32;<$text text=<<chunk>>/>
</$button> </$button>
</$reveal> </$reveal>
<$reveal type="match" stateTitle=<<reveal-state>> text="show"> <$reveal type="match" stateTitle=<<reveal-state>> text="show">
<$button setTitle=<<reveal-state>> setTo="hide" class="tc-btn-invisible"> <$button setTitle=<<reveal-state>> setTo="hide" class="tc-btn-invisible">
{{$:/core/images/folder}}&#32;<$text text=<<__chunk__>>/> {{$:/core/images/folder}}&#32;<$text text=<<chunk>>/>
</$button> </$button>
</$reveal> </$reveal>
&#32; <span class="tc-tiny-gap-left">(<$count filter="[all[shadows+tiddlers]removeprefix<prefix>removeprefix<chunk>] -[<prefix>addsuffix<chunk>]"/>)</span>
<span>(<$count filter="[all[shadows+tiddlers]removeprefix<__prefix__>removeprefix<__chunk__>] -[<__prefix__>addsuffix<__chunk__>]"/>)</span>
<$reveal type="match" stateTitle=<<reveal-state>> text="show"> <$reveal type="match" stateTitle=<<reveal-state>> text="show">
<$macrocall $name="tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}} separator=<<__separator__>>/> <$transclude $variable="tree-node" prefix={{{ [<prefix>addsuffix<chunk>] }}} separator=<<separator>>/>
</$reveal> </$reveal>
</$set> </$set>
</li> </li>
\end \end
\define tree-node(prefix,separator: "/") \procedure tree-node(prefix,separator: "/")
\whitespace trim \whitespace trim
<ol> <ol>
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore<__separator__>sort[]!suffix<__separator__>]" variable="chunk"> <$list filter="[all[shadows+tiddlers]removeprefix<prefix>splitbefore<separator>sort[]!suffix<separator>]" variable="chunk">
<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/> <$transclude $variable="leaf-node" prefix=<<prefix>> chunk=<<chunk>> separator=<<separator>>/>
</$list> </$list>
<$list filter="[all[shadows+tiddlers]removeprefix<__prefix__>splitbefore<__separator__>sort[]suffix<__separator__>]" variable="chunk"> <$list filter="[all[shadows+tiddlers]removeprefix<prefix>splitbefore<separator>sort[]suffix<__separator__>]" variable="chunk">
<$macrocall $name="branch-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/> <$transclude $variable="branch-node" prefix=<<prefix>> chunk=<<chunk>> separator=<<separator>>/>
</$list> </$list>
</ol> </ol>
\end \end
\define tree(prefix: "$:/",separator: "/") \procedure tree(prefix: "$:/",separator: "/")
\whitespace trim \whitespace trim
<div class="tc-tree"> <div class="tc-tree">
<span><$text text=<<__prefix__>>/></span> <span><$text text=<<prefix>>/></span>
<div> <div>
<$macrocall $name="tree-node" prefix=<<__prefix__>> separator=<<__separator__>>/> <$transclude $variable="tree-node" prefix=<<prefix>> separator=<<separator>>/>
</div> </div>
</div> </div>
\end \end