You can test this pretty easily by editing $:/core/ui/TagTemplate
. The part of the template responsible for generating the list of links is <$macrocall $name="list-tagged-draggable" tag=<<currentTiddler>>/>
, which you can replace with your preferred TOC macro. I tested it with toc-selective-expandable
:
\whitespace trim
<style>
.tc-drop-down li.toc-item button { display: inline-block; width: fit-content; padding: 0; }
</style>
<span class="tc-tag-list-item" data-tag-title=<<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'"""
/>
<$reveal state=<<qualify "$:/state/popup/tag">> type="popup" position="below" animate="yes" class="tc-drop-down">
<$set name="tv-show-missing-links" value="yes">
<$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="toc-selective-expandable" tag=<<currentTiddler>>/>
</$reveal>
</$set>
</span>
Here’s a JSON of the above code if you’d like to test it: $ _core_ui_TagTemplate.json (1.4 KB). I started from the prerelease, but it seems to work with 5.3.3 as well.
In addition to the macrocall I changed, I also added a line of CSS to prevent the TOC carets from appearing on a separate line (as all buttons do by default in the tag dropdown). You may want to make some further CSS tweaks to get it looking the way you want—and ideally, you’ll move the CSS from the <style>
tags I added into a separate tiddler with the $:/tags/Stylesheet
tag.
You’ll notice that in replacing the list-tagged-draggable
macro, we lost the ability to reorder the tagged tiddlers through drag-and-drop. I imagine you could keep list-tagged-draggable
and use its itemTemplate
attribute to render each list item as the head of a TOC, but it’s probably easier just to use one of Eric’s alternate TOC macros as discussed in this recent thread, since he already has drag-and-drop functionality built in.
I hope this is enough to get you started!