Implementing a contextmenu with wikitext

Turns out, adding the View Toolbar to the context menu is very simple. It is just another “button” with a submenu, just a few lines of code changed from what I posted above:

\import [[$:/core/ui/ViewTemplate]]
<!-- import is needed for the macros defined there -->
<$reveal type="nomatch" text="2" default=<<menuLevel>> tag="button" class="tc-btn-invisible">
	<$tiddler tiddler={{$:/HistoryList!!current-tiddler}} >
		<$let menuLevel="2" >
			{{$:/core/images/options-button}}
			<span class="tc-btn-text">
				Toolbar Buttons
			</span>
			<span class="mwi-hotkey">
				{{$:/core/images/right-arrow}}
			</span>
			<div class="mwi-contextsubmenu">
				<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewToolbar]!has[draft.of]] -[[$:/core/ui/Buttons/more-tiddler-actions]]" variable="listItem">
					<$transclude tiddler=<<listItem>>/>
				</$list>
			</div>
		</$let>
	</$tiddler>
</$reveal>

Mostly, it’s only a change of the $list filter expression that was simply copied from $:/core/ui/Buttons/more-tiddler-actions.


Have a nice day
Yaisog

PS: Not all of it works fully. Because the context menu is defined in the page template and not in the view template, e.g. Info that relies on the variable tiddlerInfoState that is computed via qualify in the view template does not work. If it really has to go into the context menu, I think it would have to be passed via the DOM into the context menu. The rest of the items work as far as I can tell.