1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-27 18:40:28 +00:00
TiddlyWiki5/core/wiki/macros/tree.tid
Leilei332 2801eee905
Migrate some old macros to new syntax (#8768)
* Migrate some old macros to new syntax

* Rewrite more macros.

* Update image-picker

* Rewrite tabs macro

* Use more new syntax

* Revert thumbnail macro

* Avoid duplicated whitespace pragma

* Revert tabs macro
2024-12-05 12:40:13 +00:00

59 lines
2.2 KiB
Plaintext

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