copy HTML text using the clipboard javascript API

允我心安 提交于 2021-01-29 07:11:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!