Tiddler Context Menu Plugin

I’ve created a plugin that adds some handy options in an extendable context menu. Hope it’s useful: https://context-menu-plugin.tiddlyhost.com/

12 Likes

WOW
This is amazing! Love it!

2 Likes

Very neat.

I would suggest deriving the menu content from tiddlers with a specific tag, where fields in the tiddlers provide the text (and potentially icon) and the text field of the tiddlers provides the actions to invoke. This makes it easier to customize without overriding plugin tiddlers, and allows users to easily share individual menu items as separate tiddlers.

The Links Context Menu plugin takes this approach for a context menu for tiddler links, so the two plugins could share menu entries.

Other suggestions: don’t trigger the context menu when there is an active selection to allow selecting text and using the default browser context menu, and/or allowing to override the activation of the contextmenu by holding a key (e.g. Ctrl).

2 Likes

Thank you Saq. Good suggestions. Showing the menu when text selected will be a bug … will fix.

2 Likes

Very VERY nice. Kudos.

Saq’s suggestions are certainly worth applying.

Consider yourself “watched”

:eye: :eye:

2 Likes

Both of these context menu plugins are really nice. That right mouse button is significantly underused in TW.

Do you think this could be done entirely in WikiText by using an $eventcatcher?

Have a nice day
Yaisog

1 Like

Still learning - will checkout $eventcatcher. For sure an alternative menu configuration is needed… wikitext/tiddlers would be a better fit than JSON :slight_smile:

1 Like

You should be able to use the same approach as my plugin, which is to set a state tiddler in the context menu handler. The state tiddler is tied to a reveal widget which creates a popup for the menu. This popup transcludes tiddlers with a given tag.

The code is here. If you have any questions please do feel free to ask.

Another eventual improvement might be to look for a parent DOM node with a given CSS selector to which the event listener is added, rather than adding it to the parent DOM node, which might fail with view template customizations.

2 Likes

4 posts were split to a new topic: Implementing a contextmenu with wikitext

Hello @ahanniga,
very nice :+1:

I tried to adapt “$:/plugins/ahanniga/context-menu/options” for my use:

{
	"context-menu": [ 
		  {
			  "name": "bearbeiten",
			  "icon": "$:/core/images/edit-button",
			  "action": "tm-edit-tiddler"
		  },
		  {
			  "name": "Toggle Fold",
			  "icon": "$:/core/images/fold-button",
			  "action": "tm-fold-tiddler"
		  },
		  {
			  "name": "Copy to Clipboard",
			  "icon": "$:/core/images/copy-clipboard",
			  "action": "tm-copy-to-clipboard"
		  },
			{
			  "name": "drucken",
			  "icon": "$:/core/images/print-button",
			  "action": "tm-print"
		  },
		{
			  "name": "schließen",
			  "icon": "$:/core/images/close-button",
			  "action": "tm-close-tiddler"
		  }
	  ]
  }
		

What did I wrong?

Thanks
Stefan

1 Like

Hi Stefan,

This message requires an event object. I have got it working by adding an additional case statement to $:/plugins/ahanniga/context-menu/ContextListener.js

 case "tm-print":
	this.dispatchEvent({ type: "tm-print", event: event });
 break;

This is not ideal. I’m currently working on changing the configuration from JSON to tiddlers, so adding new options will be much more conventional and in-keeping with other plugins.

Thanks - I’m looking forward to the new plugin.

Regards
Stefan

1 Like

To keep this thread focused on the plugin in question, I have moved discussion of alternative implementations with wikitext to a new thread:

2 Likes

Thanks everyone for the feedback! I’ve updated the plugin so that:

  • Configuration is now tiddler-based
  • More menu options
  • Sanitize inputs
  • Optional separators
  • If text is currently selected, thre default context menu is shown

https://context-menu-plugin.tiddlyhost.com/

Cheers, Aidan

6 Likes

Hi Aidan,

I think you context menu is a great idea. I was wondering if it might be possible to add custom commands to the menu such as open a certain tiddler, etc.

Hi HistoryBuff,

The context menu provides access to commands for the current tiddler. To open often-used tiddlers I’d recommend Mohammad’s favourites plugin which does exactly what you need.

1 Like

Thanks. One more question: can this be made to work in edit mode with, say, formatting commands?

Hello Aidan,

thanks for the new plugin - very nice :slight_smile:

I activated the print option and saw, that all open tiddler are in the print-preview and will be printed with icons outside of the tiddler:

I’m using PrintRiver.
grafik
This is a very powerful tool and printing is, how it should be…

What configuration is needed to have this tool by default, when printing with context-menu?

Thanks
Stefan

2 Likes

Hi, will take a look.

1 Like

In edit mode I think this will depend on the editor used and the type of content. There are dedicated buttons depending on whether you’re editing Wikitext or Markdown and these can be configured in the Control Panel (toolbars). There could be a use for a context menu but I can only think of save, delete and cancel being necessary (?)

Aidan