javascript copy rich text contents to clipboard

后端 未结 5 1975
[愿得一人]
[愿得一人] 2020-11-28 09:11

Premise

I need help copying rich text to the clipboard using JavaScript. I have searched around and haven\'t found anything to suit my specific needs.

Cod

5条回答
  •  无人及你
    2020-11-28 09:49

    This tiny JS plugin copies richtext without using Flash: https://www.npmjs.com/package/clipboard-js

    It's based on https://clipboardjs.com/ - but it's an upgrade in my opinion, because the original only supports plain text.

    The code is simple:

    clipboard.copy({
        "text/html": "Markup text. Paste me into a rich text editor."
    });
    

提交回复
热议问题