Skip to content

More support or documentation for using clipboard data formats #1729

@jessegrosjean

Description

@jessegrosjean

In most clipboard API's that I'm familiar with (OS X and Javascript clipboard events) there's API for:

  1. List available data formats
  2. Read data for a specific format
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions