Change drag and drop from sidebar into edit field of current tiddler action from linking to transposing

Hello everyone,

I am quite new to TiddlyWiki using TW version 5.2.2.

Currently, when I drag and drop from the sidebar into the edit field of a tiddler, TiddlyWiki is adding [[square brackets]]. I would like TW to add {{curly brackets}} instead.

Where can I change the code, so that TW is {{transposing}} rather than [[linking]] the dragged element?

Thank you for your help and suggestions

I am not sure, but will give it some thought.

Do you want any title, open, recent etc… to be “dropped” as a transclusion, or only tiddlers dragged from a custom sidebar tab / list?

Drop zone is mentioned in the editor tiddler $:/core/ui/EditTemplate/body/default but I can’t see how to modify it. It has recently been improved to allow images to be dropped into the editor.

Perfect, thank you for looking into this.

Behaviour can be added for all tabs in the sidebar so:
Open, Recent, + 1 custom Contents tab

Following this discussion: https://groups.google.com/g/tiddlywiki/c/Qa0hG-_NN9A
it seems that the square brackets have been included in 2017 but I can’t seem to find the specific commit on the github repo to see the diff in the code.

I wonder if an alt+drag and drop resulted in {{tiddlername}} and perhaps even ctrl+drag {{||tiddlername}} as default behaviours?

Dragging a link, the data that is made available is always the tiddler title in title list format:
https://tiddlywiki.com/#Title%20List

Thus titles with spaces in them are wrapped in double square brackets. This is required by the drag and drop related widgets.

Currently there is no affordance to override this behaviour. What would be needed is an extension of the drag and drop and paste handling in the editor, likely in the form of a plugin.

See these related issues:

3 Likes

Thanks for the request @chris. I’ve just added a GitHub ticket that proposes supporting the requested behaviour, and fixing the inconsistency that brackets are not currently applied to titles that do not contain whitespace.

1 Like

As I mentioned at GitHub [IDEA] Option to make drag and dropping tiddler titles (shown as a link) always make a link · Issue #6317 · Jermolene/TiddlyWiki5 · GitHub I still think checking for keyboard control characters to select between different modes makes sense

It may be best to explore the possibilities with plugins first. …

Thank you for your answers.

It would be great, if Ctrl + Drag&Drop would transclude rather than link the dragged tiddler.
As it doesn’t work that way yet, I will be interested in what the result of the ticket will be, thank you @jeremyruston for adding it.

I searched available plugins, but did not find one, that could alter the dragging behaviour. So I might try to write a plugin.

While we’re waiting for an official fix, an easier solution might be to hack the transclusion tool in the toolbar so that it not only puts curly braces around text, but strips out any square brackets. That would make it easy to quickly convert a link to a transclusion.

To make the button mentioned in my previous post, modify $:/core/ui/EditorToolbar/transcludify :

<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="save-selection"
	tiddler="tempSelection"
   field="text"
/>
<$vars lsb="[[" rsb="]]" lcb="{{" rcb="}}" >
<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="insert-text"
	text={{{ [{tempSelection}trim[]trim<lsb>trim<rsb>addprefix<lcb>addsuffix<rcb>] }}}
	
/>
</$vars>

This uses a temporary tiddler to save the selected text value, since we don’t have access to the value inside the button.

2 Likes

Thank you @Mark_S for your post. This works really nicely.

Searching further, I found that Charlie_Veniot has built a nice plugin called Transclude Assistant for transposing existing tiddlers. Instead of searching the sidebar and then drag from the search results, searching could be done in the Transclude Assistant directly then.
I will give it a try as well.