How to copy (almost) anything to the Clipboard with 5.2.0

Perhaps this post fits the category “Fun with 5.2.0”

How can you copy almost anything to the clipboard with a simple macro?

Copy the following to a tiddler tagged $:/tags/Macro

\define copy-input(input label class:"tc-btn-invisible" style:"")
<$wikify name=wikified-input text="""$input$""">
<$set name=label value="$label$" emptyValue=<<wikified-input>> >
<$button tooltip="Copy result of $input$ to clipboard" message="tm-copy-to-clipboard" param=<<wikified-input>> class="$class$" style="$style$"><<label>> {{$:/core/images/copy-clipboard}}</$button>
</$set>
</$wikify>
\end

Then use the macro copy-input to use the new

" More Flexible Parsing of Macros"

<<copy-input "<<now YYYY-0MM-0DD>>" "Todays date" class:" " style:"color: red;">> 

<<copy-input "{{!!description}}">>

<<copy-input "<$text text={{!!text}}/>" "Source Text">>

Snag_20a1f3d1

In the macro definition you can see if you provide a label parameter it replaces the result, if you use a class or style to can change the result. Try class=" " (space) for a standard button.

How far can you extend this?

Like if you think its cool, I do!

10 Likes

Briljant!
Especially the first example that takes a macro result as input is the one that does not work with the standard <<copy-to-clipboard>> macro.

[Edited] to wrap the macro in the code (TW_Tones)

1 Like

Please, know someone plugin to add button to tiddlers toolbar to copy tiddler content to clipboard?

Situation: I am blind and I often want to copy content of tiddler (drawed in HHTML) but this simple task is absolutelly terrible with screenreader, macro button is usefull.

I’m afraid what you want is not possible, as (after I tested building what you want) tiddlywiki copies the html, but it copies it as text, so you will end up having in your clipboard text like <ul><li> first item </li><li> second item </li></ul>

And I assume that’s not what you want…

Do you mean that after the tiddler is rendered in the browser you want its html to be copied?

  • Use a browser tool that allows you to copy any thing but retain it in html
  • Have a custom button I made (it uses wikify with html as the output format)
  • Install the internals plugin, use the HTML preview select and copy the html result.
1 Like

Many thanks for replies, but i was described not understable.

My situation is really, I want to copy tiddler content to clipboard and for example paste it to Word as HTML riched object and manually I cannot select only tiddler´s content with screenreader. Now I have workaround with exporting to MD and with Pandoc generating DOCX file or open tiddler in new window and copy its contents to clipborard, but this is frustrating method :slight_smile:

it sounds great, but I cannot find your meaned button, can you please give me link to it?

I will try and find the button but first;

  • See tiddlywiki.com first, it already has the internals plugin
  • To install In your wiki go to Control Panel/Settings > Plugins > Get More Plugins > Open Plugin Library, search for internals > install the internals plugin > Save a reload

Using internals preview as html

  • In a tiddler with content select Edit > Preview Button, From the preview Dropdown > select raw HTML > see now the HTML version
  • You can select that html and save it in a file?

Also you may want to export tiddler > as Static HTML for a whole html file.

  • The template can be changed for different output.

Have a go then ask for more help.

I wrote a proof of concept:

  • import the file below to your tiddlywiki
  • reload (browser refresh) your tiddlywiki, since it includes javascript code

that will add a button to each tiddler; when clicking that button, it will put the HTML content of the tiddler, in the clipboard.

tiddlers.json (3.5 KB)

Please let me know if that is what you needed, because if that’s the case, then that code needs some improvements, especially regarding quoting especial characters.

3 Likes

Great, i mean that this plugin will be usefull for others too.

I have two ideas for improving this:

  1. Name of the tiddler as H1 at beginning of copied contents
  2. Renaming button to Copy contents, because Copy HHTML invokes copying HTML source.

How can I render the label so it looks like rendering foo (with the ticks) will look like? Or the input will look like the above without using a label.

I suggest a new topic referencing this one and spelling out what you want.

  • I think I know the answer but the effort involved to give you an answer is too high.
    • the chance is you wont be happy with any answer based on your question.
  • If possible give us a package of tiddlers we can install in tiddlywiki and it should be easy to answer.
    • often doing this people find their own answer.
1 Like

Thanks for the great tool. I wanted to use it to copy multiple fields ({{!!title}}, {{!!text}} etc.) of a tiddler in a formatted style (new line; within quotes, everything under { } bracket). How can I do that?
I tried putting them together in multiple ways (between triple quotes, one after another); doesn’t work.

Any help?

@rahulkashyap.phy, Did you see my reply over on your other thread? Since your question there looks bibtex-specific, I thought it might be better to point to a bibtex-specific tool for getting the info in json format. But please follow up if you need more help getting what you need onto the clipboard.