问题
I want to be able to copy images and HTML text and past it into my web application.
I am using the clipboard API to do so and my code works fine for images, for which I use: clipboard API read
But for text, I am using this: clipboard API readText And I am only able to paste the raw text, not the HTML formatted text.
Any help appreciated.
回答1:
This should already be possible in Safari and Chrome Canary, by simply calling navigator.clipboard.write
with text/html
, just like you currently do so with images via image/png
.
(This was implemented in Chrome 86, and so will available in Stable Chrome by October 6)
来源:https://stackoverflow.com/questions/62434928/copy-html-text-using-the-clipboard-javascript-api