Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting mime when using useClipboard for copying #3450

Closed
4 tasks done
DanSnow opened this issue Oct 3, 2023 · 0 comments · Fixed by #3477
Closed
4 tasks done

Support setting mime when using useClipboard for copying #3450

DanSnow opened this issue Oct 3, 2023 · 0 comments · Fixed by #3477
Labels
enhancement New feature or request

Comments

@DanSnow
Copy link

DanSnow commented Oct 3, 2023

Clear and concise description of the problem

According to MDN https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write, when using the write API, you can specify a MIME type. This allows you to copy HTML content, so when users paste it into supported editors like Google Docs, the formatted text will be displayed.

Suggested solution

For the copy returned by useClipboard, provide a second options parameter as { mime?: string }, and use it like this:

const { mime = 'text/plain' } = options ?? {}
clipboard.write([new ClipboardItem({ [mime]: new Blob([text], { type: mime }) })])

Alternative

No response

Additional context

No response

Validations

@DanSnow DanSnow added the enhancement New feature or request label Oct 3, 2023
Doctor-wu added a commit to Doctor-wu/vueuse that referenced this issue Oct 16, 2023
support to pass a parameter |transform2ClipboardItems| to customize clipboardItems

fix vueuse#3450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant