Skip to content

feart: Enhances clipboard copying with MIME type selection#17

Open
twofingerrightclick wants to merge 2 commits into
Evercoder:mainfrom
twofingerrightclick:af/CopyAs
Open

feart: Enhances clipboard copying with MIME type selection#17
twofingerrightclick wants to merge 2 commits into
Evercoder:mainfrom
twofingerrightclick:af/CopyAs

Conversation

@twofingerrightclick
Copy link
Copy Markdown

Introduces a new component to allow copying text content to the clipboard with various MIME types (e.g., plain text, HTML, Markdown). Useful when you want to copy a type as another type. Defaults to plain/text.

Utilizes the ClipboardItem API for rich data transfers, falling back to writeText for basic plain text copy if advanced features are unavailable. The UI now includes a dropdown for MIME type selection.

Updates class attributes to className for React consistency.

image image

@twofingerrightclick
Copy link
Copy Markdown
Author

twofingerrightclick commented May 14, 2026

@danburzo This tool was a top hit on google or "What is on my clipboard"! I was about to build something like it because I needed to get html as plain text. Then I needed to get the plain text as html, so I added that in a way that I thought seemed reasonable enough. I often need to copy plain text as svg as well so added that and a few others for experimentation.

Thanks for building this!

Introduces a new component to allow copying text content to the clipboard with various MIME types (e.g., plain text, HTML, Markdown).

Utilizes the `ClipboardItem` API for rich data transfers, falling back to `writeText` for basic plain text copy if advanced features are unavailable. The UI now includes a dropdown for MIME type selection.

Updates class attributes to className for React consistency.
@danburzo
Copy link
Copy Markdown
Collaborator

Thanks for this, @twofingerrightclick, it’s a great addition! I haven’t experimented lately with writing custom MIME types to the clipboard, but IIRC there are some things that complicate this: https://developer.chrome.com/blog/web-custom-formats-for-the-async-clipboard-api/

It warrants some testing around:

  1. Whether there’s any browser that allows writing MIME types besides these three.
  2. Whether text/html gets sanitized (e.g. remove <script> elements), versus web text/html which should be copied verbatim.

@twofingerrightclick
Copy link
Copy Markdown
Author

@danburzo Thanks for pointing this out — I hadn’t fully realized at first that clipboard support is intentionally limited for certain MIME types, both for security reasons and because browser support is still inconsistent. I should have tested more.

The only formats that currently work reliably with the new copy button are plain text and HTML. Interestingly, when copying HTML, the <script> tags are preserved as part of the copied content.

I’ve adjusted it so the dropdown now only includes the two supported/reliable options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants