Create a EditorToolbar button that copies the full "text" field to the clipboard

I’m on the right track (at least I’m optimistic and I think I am), but I’m still missing something.

I created a tiddler tagged $:/tags/EditorToolbar, with the due fields (caption, icon, description and condition the latter I’m not sure if I filled it with the correct stuff, but I copied the one that had the bold button. But I don’t think there’s actually a problem here).

The problem is in the text field where my best attempt has been:

<$action-sendmessage $message=“tm-copy-to-clipboard” $param={!!text}/>

it clearly doesn’t work, but I’m pretty sure I’m on the right track, and the only thing I’m doing wrong is the $param. Ah right, better clarify, what I’m trying to get is a button in the EditorToolbar that if pressed copies the entire “text” field of the tiddler I’m editing (whose editor contains my custom button) to the clipboard.

-Sam

The use of text outside filters needs 2 curly braces {{!!text}}

Oh, yes. That’s right, I left that error doing some tests, I had initially tried with two and but it still didn’t work. (or rather, it copied to the clipboard the text field of my custom button, i.e <$action-sendmessage $message=“tm-copy-to-clipboard” $param={{!!text}}/>)

I don’t have a lot of time today but here is one I created earlier, use and modify as desired or just learn from it. Its rough and ready :nerd_face:

copy-text-button.json (6.0 KB)

Sorry for the delay in replying, I had gone to bed.
Thanks a lot for the json you provided, but unfortunately I couldn’t get anything useful by dissecting it. Works fine as ViewToolbar button, but not as EditorToolbar buton. There’s something about the buttons in the EditorToolbar that works differently, so unfortunately it’s not translatable

Welcome to the community by the way @SnapSam

  • Sorry I missed that.
  • When you are editing a tiddler there is a draft text field and an original text file
    • What are you thinking?
  • Of course inside the text editor you can ctrl-a and crtl-c to copy all the text.
  • In my above package you add the $:/tags/EditToolbar to $:/PSaT/button/copy-text tiddler it will be visible and you can copy the current (edit mode) text.
    • Not an EditorToolbar button and Edit button (top right of tiddler)
1 Like

Thank you! I’ve already browsed this site often when looking for solutions, but I only recently decided to create an account. Beautiful community btw
While reading old posts, some of the most active users acquired a legendary status for me, including you. I have to admit it’s a little weird talking to you right now. Sorry for the digression but really, it’s like talking to a wise sage :sweat_smile:

Hmm I hadn’t thought of that, the draft would probably be better

The keyboard shortcuts are the ones I currently use, but I’m a bit fixated recently with making mobile use more comfortable.

Yes, thinking about it, it would actually work fine. I’d still prefer to have it in the EditorToolbar, but if it’s a complicated thing to accomplish, I’ll probably do as you suggest.

Just to understand (in case I want to venture into the EditorToolbar again in the future) is working in the EditorToolbar more difficult than I thought? Is it better if possible to look for alternative solutions?

  • Only a little different.
  • I will give it some thought.

Super! I’ll study it and see what I can do

I think it’s not that easy with the current setup used for editor toolbar buttons. It think the content of the toolbar button doesn’t know the tiddler-title of the tiddler that is edited. …

But I’m not sure. I would have to have a closer look. … I think it would make sense for the whole mechanism to be more configurable, if the action-widgets would have access to that info.

I found it. The toolbar buttons know the “targetTiddler” variable so if you use the following action, it should work. At least it did for me.

<$action-sendmessage $message="tm-copy-to-clipboard" $param={{{ [<targetTiddler>get[text]] }}}/>
2 Likes

It works! A big thank you @pmario
:grinning_face_with_smiling_eyes: