Context menu plugin - selection add-in

@fastfreddy Thanks for taking a look at this issue.
I have installed streams plug-in in the demo wiki. - https://mcl-context-menu-bug.tiddlyhost.com/

The error message occurs only when I select a text inside regular tiddler body. No error is seen on selecting text in streams and right clicking.

Wonderful, thanks @arunnbabu81. That is a very helpful bit. I believe it confirms my suspicion that identifying the target targ is problematic under MCL. I will see what I can dig up; but I reserve the right of calling a friend (@BurningTreeC or @saqimtiaz ) for help…

        //Streams node compatibility 
        //nearest DOM element that contains this attribute [data-node-title]
        const node = event.target.closest("[data-node-title]"); 
        const nodeTitle = node && node.dataset["nodeTitle"];


        //regular logic if the event was not on a Streams node
        targ = nodeTitle || event.currentTarget.getAttribute("data-tiddler-title"); //based on the div attribute in view template that contains currentTiddler		
        const tiddlerText=$tw.wiki.getTiddlerText(targ);
1 Like

Hi @fastfreddy,

I suspect that the problem with MCL is, that the View- and Edittemplates are a bit different

I’ve changed the lines you posted here to the following and that works:

        //Streams node compatibility 
        //nearest DOM element that contains this attribute [data-node-title]
        const node = event.target.closest("[data-node-title]"); 
        const nodeTitle = node && node.dataset["nodeTitle"];

const closestTarget = event.currentTarget.closest("[data-tiddler-title]");

        //regular logic if the event was not on a Streams node
        targ = nodeTitle || closestTarget.getAttribute("data-tiddler-title"); //based on the div attribute in view template that contains currentTiddler		
        const tiddlerText=$tw.wiki.getTiddlerText(targ);
2 Likes

You’re a wizard @BurningTreeC !
I will integrate this into a new release later today!

2 Likes

Thanks, @fastfreddy , Is it possible to hide separator lines too?

Despite of this, I tried it on Tiddloid, it is much better now!

To use it on TidGi

FYI GitHub - WebReflection/html-escaper: A module to escape/unescape common problematic entities done the right way.

Seems you are overwriting

$:/plugins/ahanniga/context-menu/ContextListener.js

What if I want to also add some JS to add JS based menu item? I think this context menu plugin can only support one add-on? @ahanniga

Hi @linonetwo, you can already change, add or hide the separators in the configuration screen:

Agreed, it is somewhat limiting and the reason I ended up having to modify the original function.
It is not super clean; a full restructure might be optimal, and one that relies on wikitext more so than the javascript (it may be possible, but I don’t believe the “mouse selection” values are available in wikitext - at least they were not, maybe that has changed…

version 0.3.0 released, which should address MCL compatibility thanks to @BurningTreeC’s mods…

2 Likes

Thank you @fastfreddy now it works with MCL