Implementing a contextmenu with wikitext

I agree with @Mohammad. This would be a great plugin! I can see some possibilities with my railroad wiki.

2 Likes

Hi @Yaisog

This is very interesting! Is there any demo online to give a try!

Thank you!

I noticed that I still owe you a demo implementation (sorry, have been playing Hard West 2 too much).
Import these tiddlers on tiddlywiki.com:

mwi-context-menu.json (12.6 KB)

Since it’s all wikitext, there is no save/reload needed.
To enable the context menu, select the PageTemplate MWi in $:/ControlPanel → Appearance → Layout.
There should also appear a toggle in the PageControls to switch between custom and browser context menu.

For tiddlywiki.com, I implemented only the ViewToolbar buttons on the whole tiddler frame, but the structure is there for more complex stuff, i.e. by adding the HTML attribute dom-data-contextmenu to any element will give that element its own context menu. The value of that attribute determines the tag that is used to determine which buttons will appear in the menu, e.g. dom-data-contextmenu="Link" will include any button defined in a tiddler tagged with $:/mwi/tags/ContextMenuLink.
The ViewToolbar buttons are defined in $:/mwi/ui/Buttons/view-toolbar-contextmenu-buttons which is tagged $:/mwi/tags/ContextMenuTiddler (standard tag used for the tiddler frame context menu).

While it is purely WikiText, it does require selecting the modified PageTemplate.

Have a nice day
Yaisog

8 Likes

Sounds great. I am looking forward to play with it.

Very nice!
This also has a lot of potentilal for creating other tools.

Thank you for sharing!

@Yaisog Thanks for this!

It doesn’t work if you have Tobi Beer’s appear plugin installed - RSOD. I wasn’t using it and disabling it allowed your context menu to work.

But…

What’s that input-looking box? Tooltip says “Show links”…

Will it only work via the ViewTemplate? I have many tiddlers displayed outside of the ViewTemplate – I truly want it to work there.

This context menu addin by @fastfreddy will work on all pagetemplates and is also very good

Thanks @arunnbabu81 but I think what I’m looking for (a configurable context menu devoid of preconceived ideas about both its location and purpose) is not available. I need it to trigger by HTML node (irrespective of where that node appears) and be populated by actionable items of my choosing. Something like…

<$eventcatcher selector="li" ...>
<ul data-id="my-menu">
  <li>item 1</li>
  ...
  <li>item N</li>
</ul>
</$eventcatcher>

I imagine the trigger that shows the menu would come from another $eventcatcher wrapped over arbitrary tiddler text (blocks of HTML).

I have no idea, currently. When I find the time, I’ll have a look.

A custom PageTemplate is required to include the necessary $eventcatchers at a level high enough so that I can put a context menu on anything, e.g. sidebar, etc. One day the default PageTemplate may be extended to dynamically include widgets via parameterized transclusions. Then it would only be a matter of tagging the corresponding tiddlers correctly. Until then I need to modify the PageTemplate itself.

Yaisog

I know I am a Jonny come lately, I put off researching context menus until now.

Context menus are certainly a fantastic way to “surface options” in tiddlywiki without adding complexity to the User interface. Thanks all for your effort so far.

Here are a few ideas based on my own interest that perhaps we could consider.

  • Different configurable menus for the text editor and the view body
  • Codemirror compatibility inc codemiror 6 (I have not tested)
  • Perhaps we could build additional Control Panel > Appearance > Toolbars to select between buttons on the context menu(s) or behind a more cascade?
  • Perhaps users could select to use the middle button, often also the mouse roller button

I am very interested in;

  • A workaround is using a new page layout
  • @saqimtiaz have you gotten anywhere with this?. I have come up against this limitation quite a few times and it is a weakness in tiddlywikis hackability.
    • I just came up with a possible solution I am doing a quick POC of now

Also for those passing by;

  • Of course this “overriding the link widget via wikitext” is now possible with custom widgets and the genesis widget.
  • The idea of an additional r-click context menu on links is also a possibilitry