mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-17 23:31:22 +00:00
Create the new "tree" global macro (#2925)
* Create the "tree" global macro file (tree.tid) * Added styles for the new "tree" global macro * Update Explorer tab * Cleaning the macro of unneeded code I have chosen to keep the slash suffix in the branch node titles to go along with the rest (e.g. root node), so the "clean-chunk" macro isn't needed anymore. * Minor fix
This commit is contained in:
committed by
Jeremy Ruston
parent
d5b50e0854
commit
f75e97f308
@@ -0,0 +1,53 @@
|
||||
title: $:/core/macros/tree
|
||||
tags: $:/tags/Macro
|
||||
|
||||
\define leaf-node(prefix)
|
||||
<li>
|
||||
<$list filter="""[[$prefix$$(chunk)$]is[shadow]] [[$prefix$$(chunk)$]is[tiddler]] +[removeprefix[$prefix$]] +[limit[1]]"""
|
||||
emptyMessage="""<$text text="$prefix$$(chunk)$"/>""">
|
||||
<span>{{$:/core/images/file}}</span> <$link to="""$prefix$$(chunk)$""">
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</$list>
|
||||
</li>
|
||||
\end
|
||||
|
||||
\define branch-node(prefix)
|
||||
<$reveal type="nomatch" text="" default="""$(chunk)$""">
|
||||
<li>
|
||||
<$list filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]] +[limit[1]]""">
|
||||
<$reveal type="nomatch" state="""$:/state/tree/$prefix$$(chunk)$""" text="show">
|
||||
<$button set="""$:/state/tree/$prefix$$(chunk)$""" setTo="show" class="tc-btn-invisible">{{$:/core/images/folder}} """$(chunk)$"""</$button>
|
||||
</$reveal>
|
||||
<$reveal type="match" state="""$:/state/tree/$prefix$$(chunk)$""" text="show">
|
||||
<$button set="""$:/state/tree/$prefix$$(chunk)$""" setTo="hide" class="tc-btn-invisible">{{$:/core/images/folder}} """$(chunk)$"""</$button>
|
||||
</$reveal>
|
||||
</$list>
|
||||
<$list filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]] +[limit[1]]"""><span>(<$count filter="""[all[shadows+tiddlers]prefix[$prefix$$(chunk)$]] -[[$prefix$$(chunk)$]]"""/>)</span>
|
||||
<$reveal type="match" state="""$:/state/tree/$prefix$$(chunk)$""" text="show">
|
||||
<$macrocall $name="tree-node" prefix="""$prefix$$(chunk)$"""/>
|
||||
</$reveal>
|
||||
</$list>
|
||||
</li>
|
||||
</$reveal>
|
||||
\end
|
||||
|
||||
\define tree-node(prefix)
|
||||
<ol>
|
||||
<$list filter="[all[shadows+tiddlers]removeprefix[$prefix$]splitbefore[/]sort[title]] +[!suffix[/]]" variable="chunk">
|
||||
<<leaf-node """$prefix$""">>
|
||||
</$list>
|
||||
<$list filter="[all[shadows+tiddlers]removeprefix[$prefix$]splitbefore[/]sort[title]] +[suffix[/]]" variable="chunk">
|
||||
<<branch-node """$prefix$""">>
|
||||
</$list>
|
||||
</ol>
|
||||
\end
|
||||
|
||||
\define tree(prefix)
|
||||
<div class="tc-tree">
|
||||
<span><$text text="""$prefix$"""/></span>
|
||||
<div>
|
||||
<$macrocall $name="tree-node" prefix="""$prefix$"""/>
|
||||
</div>
|
||||
</div>
|
||||
\end
|
||||
Reference in New Issue
Block a user