Copy to clipboard on client in Node-Red dashboard

#Copy string to Clipboard on client
I'm trying to build a button that automatically saves a dashboard string to the the clipboard of the client.
That means that the client with an open dashboard should be able, to get the string into his clippoard indipendent of running node-red on his device.

My problem is that all my solutions only write to the clipboard of the device where node-red is running.

What I tried:

01 node-red-contrib-clipboard

Unfortunately, just writes from host and client to my Windows PC where node-red is running.

02 npm module clipboardy

Unfortunately, just writes from host and client to my Windows PC where node-red is running.

const clipboardy = global.get('clipModule');
let id = msg.payload.title.replace('<b>', '').replace('</b>', '');
 
clipboardy.writeSync(id);
 
return msg;

03 html template

msg.payload = '<script>navigator.clipboard.writeText("' + msg.payload +'")</script>';

Unfortunately, just writes from host to my Windows PC where node-red is running.

Does anybody have a solution to this problem?

Thanks in advance!

If you want to copy to the clipboard of the device running the browser that is viewing the dashboard, then you need some code in the ui_template node to do it. This isn't something you can do from the runtime side at all.

There are lots of guides for how to copy text to the clipboard from a webpage - for example: https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.