Skip to content

Conversation

@jkleinsc
Copy link
Member

@jkleinsc jkleinsc commented Aug 7, 2025

This RFC outlines a rearchitecturing of the clipboard module in Electron to improve alignment with the Clipboard API as specified by the W3C.

📄 Read rendered document

coauthored with @codebytere.

@jkleinsc jkleinsc requested a review from a team as a code owner August 7, 2025 19:20
@erickzhao erickzhao added the pending-review Waiting for reviewers to give feedback on the PR specifications label Aug 14, 2025
Comment on lines +87 to +89
* Custom MIME types e.g. `electron application/filepath` will be used to allow support of non-standard clipboard formats. This follows
the W3C proposal for supporting [Web Custom formats for Async Clipboard API](https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md#custom-formats).
The exception here is that instead of using the `web` prefix, we will use the `electron` prefix to prevent possible collisions with custom web formats.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me whether electron can access arbitrary clipboard formats outside of a subset of whitelisted platform specific types. This uncertainty exists both for the current electron version (v37), as reported in electron/electron#39853 (comment), and in the proposed changes in this RFC.

AFAIU the W3C Async Clipboard API supports access to only a subset of possible formats as specified in well-known mime types and the clipboard API working draft which notes support of those with a web prefix (and this RFC adapts for an electron prefix).

Is access to arbitrary clipboard formats:

  • intended to work in the current electron clipboard API
  • intended to work in the proposed rearchitected clipboard API

This is a critical feature for my use case and I was encouraged to see this RFC in case there is any relation.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Electron 38 on Windows, clipboard.read and clipboard.readBuffer can access arbitrary clipboard formats. So I think we can conclude that prior to this re-architecture, the Electron intends to be able to read/write any clipboard format. And that this rearchitecture should preserve and refine this ability. By refine, I mean enhancements like making clipboard.availableFormats actually detect all available formats.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhimmel the intention would be that we wouldn’t lose any current functionality, so if a format is readable now it should be so after this change goes through. The problem right now is that you have to know these weird platform specific formats exist and then use stuff like readBuffer to get the data.

I think we might end up missing some formats on the initial implementation but I’d expect that we’d add them through follow up PRs. If there are particular formats you are interested in, feel free to mention them here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good with the clarifications in e642a54. Thanks for you work.

The current functionality to read raw formats will be maintained with the electron application/osclipboard;format="OS CLIPBOARD NAME HERE" syntax. Note the space in the format name. Supporting spaces is important for our use case.

clipboard.read will be able to list all available formats. Hopefully this includes the electron application/osclipboard formats.

If there are particular formats you are interested in, feel free to mention them here

The RTF functionality. clipboard.readRTF function is going away but using the MIME type application/rtf is an adequate substitute and will work across platforms.

Copy link
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC LGTM

Copy link
Member

@reitowo reitowo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC LGTM

Copy link
Member

@itsananderson itsananderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC LGTM

@erickzhao erickzhao added final-comment-period pending-review Waiting for reviewers to give feedback on the PR specifications and removed pending-review Waiting for reviewers to give feedback on the PR specifications final-comment-period labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-review Waiting for reviewers to give feedback on the PR specifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants