Context menu plugin - selection add-in

fixed in 0.2.8 @arunnbabu81

@HistoryBuff all of what you propose should be doable. That last one is very similar in concept to “create new here”. I tried a tagging option quickly with tm-add-tag, but that didn’t quite work. I may try a few other things and see…

I had already changed the js tiddler as you had told.

Is this similar to the clone viewtoolbar button functionality?

Another custom function I added to my context menu is adding links [[]]. But since this add in uses search and replace, there might be multiple instances of the selected word, which might limit the usefulness.

I have also used this add in for adding strex macro by telmiger and also my experimental cloze macro.

Thanks @fastfreddy for the work on this addin.

1 Like

What I am looking for is similar to the clone button, but what I would like is to be able to create a new tiddler with the tag preset to Railroads and a couple of other fields prepopulated with fixed values. These would not be dependent on the tiddler I was right clicking in. I could create a toolbar button to do this, but thought it might be convenient to have it available from a right click. Upon reflection, it might be good to also be able to have the title of that new railroad tiddler be whatever text I currently have highlighted.

@fastfreddy

So is it basically possible to almost add any button to the context menu that I could add to either the page toolbar or view toolbar? That would be enormously convenient.

I think this prevents Selecting texts on the mobile. Or maybe this is the bug in the main Plugin… @ahanniga Where is the Github repository of your plug in? I can try pr for it.


found it ahanniga/tiddlywiki-context-menu-plugin: Configurable context menus for tiddlers

1 Like

@fastfreddy Can you hide the items when they are unusable? Because it makes the list too long for a view in a small screen.

Yes the menu items can be shown or hidden in the configuration. Did that not work?

I mean hide the gray items in view template, as long as they can’t be clicked. And only show them when they can be clicked. Maybe this has to be done in the main context menu plugin?


Wait, but in your screenshow, seems we could use them, even in view mode


I see, the text is {{$:/plugins/phiv/context-menu-selection-addin/readme}} so it doesn’t work. This is very confusing for a new user come to the demo.

Oh I see, I think it can be done.
In the current implementation, I wanted to signal to the user when options were not available because of transclusions.
I can just as easily hide the options which will be friendlier to mobile users…

I think you can hide them, because if user doesn’t read the doc, they will confuse as I did. If read the doc, then don’t need this signal…

You should be able to simply redefine “context-menu > form > ul > li.item-disabled”

in my plugin’s $:/plugins/ahanniga/context-menu/styles.css tiddler.

I am on a plane about to take off, I can’t try it, but “display:none” on the element should hide it…

There are probably a few more similar styles to redefine, I remember needing a few variants…

1 Like

@fastfreddy

After upgrading to 5.3.0 or 5.3.1, the context menu is showing a bug.
The icons are not displayed, instead /parameter (size"22pt") is seen. Check the below image and wiki - https://context-menu-bug.tiddlyhost.com/

I think there was some change related to images or icon with 5.3.0 which might be causing this. Also it must be corrected in the main context menu plug in mostly. Since @ahanniga has not been active in this forum for some time, @fastfreddy can you take a look at this ?

The appearance of the /parameter (size"22pt" is similar to a problem in my splash screen I raised here and there is discussion there that may help Minor error in 5.3.0 splash screen \parameters text - #2 by TW_Tones

1 Like

Thanks Tones, that will help. I am still struggling to get the original https://context-menu-plugin.tiddlyhost.com/ plugin to work in latest.

this line in my overrriden $:/plugins/ahanniga/context-menu/ContextListener.js probably needs to be adjusted. I’ll see if I can figure it out with Tones’ pointer.

icon = $tw.wiki.getTiddlerText(tid.getFieldString("icon", "$:/core/images/blank"));
1 Like

maybe use core function getValueAsHtmlWikified()

thanks @buggyj ; didn’t manage to make your proposal work (it still may very well be valid)…

@arunnbabu81 : this modification to $:/plugins/ahanniga/context-menu/ContextListener.js fixes the icon issues; not sure if there is a better way yet; will try to release a new version before too long; I’d like to test if this change is backwards compatible…

            //icon = $tw.wiki.getTiddlerText(tid.getFieldString("icon", "$:/core/images/blank"));
            icon = $tw.wiki.renderText("text/html","text/vnd.tiddlywiki",$tw.wiki.getTiddlerText(tid.getFieldString("icon", "$:/core/images/blank")),{
            		parseAsInline: mode !== "block"
            	});
1 Like

@fastfreddy
Do you know why this error is happening when context menu plug in is used with multicolumn layout

I have released 0.2.9 which addresses compatibility with 5.3.0/5.3.1 at @arunnbabu81’s request, as well as a new configuration option to hide disabled menu items completely (best for small screens) at @linonetwo’s request.

https://fastfreddy.gitlab.io/context-menu-selection-add-in/

I rushed the release (had to rebuild my dev environment); hopefully all is well.

2 Likes

Thank you @fastfreddy for the quick fix.

I need your help for another bug I have come acros when using context menu plug in with multicolumn plug in.

Internal javascript error is seen when I right click to access the context menu if the multicolumn layout is activated (no issues while using the context menu plug in with multicolumn plug in installed but multicolumn layout not activated)

https://mcl-context-menu-bug.tiddlyhost.com/ check this demo wiki

I’ll try to take a look in the next few days; there seems to be an issue with this function:

	//used when storing text values from tiddler in context menu HTML
    var sanitize = function (string) {
        const map = {
            '&': '&',
            '<': '&lt;',
            '>': '&gt;',
            '"': '&quot;',
            "'": '&#x27;',
            "/": '&#x2F;',
        };
        const reg = /[&<>"'/]/ig;
        return string.replace(reg, (match) => (map[match]));
    };

I am guessing from the call at the end of this sequence:


        //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);

		const sTarg = sanitize(targ);

It may be struggling to find a target for the context menu… which could very well be the case in this MCL layout.

Can you try and install Streams on your demo wiki (and populating a few Stream nodes instead of/in addition to the tiddler’s main body)? It would be interesting to see if the logic to find a target works in MCL when Stream nodes are present.

Cheers,