If you can manipulate the selection, then I think you can manipulate the text of target tiddler (the one from it you open context menu)
For example highlight selection!
If you can manipulate the selection, then I think you can manipulate the text of target tiddler (the one from it you open context menu)
For example highlight selection!
Yes also using freelink plugin as soon as you create the tiddler it will become a highlighted link, but it would be nice to have a operation, like edit-text-operations applied in the text field.
@fastfreddy Can we then insert macros around selected text using this context menu. For example can we add sticky todos (stobot 's plug in) if we select a text and add the todo macro via context menu
I believe this is possible then! So you can have an annotation tool!
Of course dynannoate plugin does some of this already.
If itâs an yes, we could do many operations like that from the view mode itself
absolutely @arunnbabu81, the code I pasted as you will see is quite simple (and only adds the wikitext characters for a link to the selection). You can mangle the selection above you wish as @Mohammad suggested, with the one caveat:
One shortcoming noted so far is if the raw text has a line break that is not visible in view mode (or any other fancy wikitext rendering), the search&replace function will not find the selection in the text. I can probably live with that.
Re: Sticky plugin, I think that would be almost trivial, yes, and a great idea
I also find @saqimtiaz approach to the link context menu to be a bit more modular for these kinds of enhancements, but the : https://context-menu-plugin.tiddlyhost.com plugin isnât bad either if you are comfortable with javascript.
@arunnbabu81 : hereâs a minor update which provides two options (create new tiddler from selection, and make todo from selection).
I have added some error checking, type conversion, and the selected words are TitleCased for the new tiddler (using the [[selection|Selection]]
text replacement).
You will also need the Stickies â lightweight todo system plugin for the new option.
same caveat: the selected text is from the rendered WikiText; the search-replace is done on the raw WikiText; if the two arenât identical, the source tiddler replacement will not work.
@fastfreddy I tried to modify the code.
<<sticky "">>
This is the sticky todo macro.
tm-new-tiddler
because everytime I tried to insert the macro from the context menu, a new tiddler gets created which is not needed.This was the mesage I had typed yesterday night before I slept off (was really busy at work yesterday) âŚwhen I woke up today , I saw that you have updated itâŚwill check and message today when time permits. Thank you for the fast update.
Yes, this is very true, and it gets even worse if the content are produced from transclusion or some computation like a the output of $list widgets, macros, etcâŚ
I just wondering if dynanotate has the same issues (@Mark_S).
True, but if the selection is not found in the raw tiddler, this tells us it is sourced elsewhere.
context menu
the official source tiddler if available, thus enabling search and replace in additional cases other than just when in the underlying raw tiddler.Out of the box, dynannotate seems to be able to highlight (either through annotation or the search result feature) regardless of origin (raw Wikitext or fancy macro/transclusions). It seems to capture the rendered wikitext and adds position-based overlays to the DOM as follows:
It does not seem to make changes/replacements to the underlying tiddler, but instead creates CSS class-based overlays based on relative position within the DOM object !?!
InterestingâŚand surprisingly capable⌠Will continue to investigate, but it may not provide insights if one wishes to change the underlying tiddler with a search/replace functionalityâŚ
Can it be modified to work with macro made by JanJo.
<<ToDo "" "" "">>
Will it by possible to do all basic wiki text formatting using like bold, underline, headings, code blocks with this menu.
yes, all of this is possible and relatively trivial.
yes @arunnbabu81, all of this is relatively trivial, with the one limitation that it works well only when the underlying wikitext is simple text. It will not work when the rendered wikitext stems from macros, transclusions or raw text with line breaks. You should have the building blocks you need in my last json file (or this one with a minor improvements on the wikitext link syntax.)
plugin_fastfreddy_ContextMenuAddin_v0.0.2_20220922.json (9.7 KB)
proof of concept @arunnbabu81
Interestingly, I stumbled another shortcoming. If the word selected appears multiple times, the replacement may or may not occur on the instance you want.
The work around is to substitute all instances which is perhaps what you want, perhaps not.
This json provides will replace all instances of the selection text in the current tiddler for âboldâ, âunderlineâ, and âmake new tiddler from selectionâ. For some reason, I donât think it is appropriate for the sticky todo option, so if multiple matches do exist, only the first one will turn into a todo item.
plugin_fastfreddy_ContextMenuAddin_v0.0.3_20220923.json (11.2 KB)
@fastfreddy I tried to use the version 0.0.3, but seem to be the same as version 0.0.2.
ContextListener.js still has the todo option. Although the bold and underline comes in the context menu, I couldnât find it in the ContextListener.js
How to modify the code to use this macro ?
please try this repackaged (and refresh, because of javascript). I am confident you can modify the $:/plugins/ahanniga/context-menu/ContextListener.js tiddler to suit your specific needs.
plugin_fastfreddy_ContextMenuAddin_v0.0.4_20220923.json (10.8 KB)
This will happen only if the selection is a single word rite. For multi word selections, it will be fine
Tell me what you try that does not work and I will help you troubleshoot.
Look for this portion of $:/plugins/ahanniga/context-menu/ContextListener.js
:
case "tm-todo":
if (selection.trim().length > 0) {
$tw.wiki.setText(targ,"text",null,text.replace(selection,"<<sticky \""+selection+"\">>"));
}
break;