-
Notifications
You must be signed in to change notification settings - Fork 17.1k
Description
In most clipboard API's that I'm familiar with (OS X and Javascript clipboard events) there's API for:
- List available data formats
- Read data for a specific format
- Write data for a specific format
I think Electron's clipboard should have the same capabilities, but I'm not sure if it does or not. My goal is to write some text in both "text/plain" format to the clipboard and also in a richer "text/html" format. And when reading from the clipboard I'd like to first check if the clipboard has "text/html" data and read that if possible, and if not fallback and read "text/plain"
I'm having trouble trying to do this with Electrons clipboard.
First I don't see anyway to write text in a specified format. There is clipboard.writeText(text[, type]), but type seems to refer to the clipboard name (i.e. standard/selection) not to data type.
The API does have methods to test for the existence of clipboard.has(format[, type]) a format, and read a specific format clipboard.read(format[, type]), but I don't see any examples of these methods being used, and I don't know what values to use for the "format" parameter. I've tried "text/plain" and "text/html" but they don't seem to work.
Is there anyway currently to do what I'm trying to do?