1

I would paste HTML to Apple Mail. I would copy text programmatically. But at pasting I see raw HTML text, not the formatted one.

<a
  className="facebook"
  onClick={(_) => {
    navigator.clipboard.writeText(
      "<div style={{ width: '284px', }} className={'cnt-box boxed'} > <img src={'https://themekit.dev/shared/thumbs/wide.png'} width=\"284\" height=\"166\" /> <div className=\"caption\"> <h2>Jelentkezz vagy oszd meg és nyerj 250$-t</h2> <p> Segíts megtalálni a megfelelő jelöltet az XY nyitott pozícióiba. </p> </div> </div>"
    );
  }}
>
  <i className="icon-facebook"></i>
</a>

Now I see following after pressing CMD + V:

enter image description here

I would use not use external package, and also no deprecated method I would call.

János
  • 32,867
  • 38
  • 193
  • 353
  • Because you called writeText(), your data is treated as text. Does this answer your question? https://stackoverflow.com/questions/23934656/how-can-i-copy-rich-text-contents-to-the-clipboard-with-javascript See also https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write – KC Wong Aug 18 '22 at 06:44
  • You mean https://stackoverflow.com/a/39497923/239219 or https://jsfiddle.net/jdhenckel/km7prgv4/3/? Because first use an external package second has a deprecated method call. – János Aug 18 '22 at 06:55
  • 1
    See the answer (https://stackoverflow.com/a/71850835/2205845) by antoineMoPa that demonstrates using Clipboard API to store HTML data. As well as the Mozilla link I shared. – KC Wong Aug 18 '22 at 06:59
  • Yes, it works, funny, nobody give any vote or it was not accepted as good answer – János Aug 18 '22 at 07:13
  • 1
    Because IT is a fast-changing field... the Clipboard API is a latter addition, as Jungle Editor answered in https://stackoverflow.com/a/64281196/2205845. What's correct and proper today may no longer be a few years down the road. – KC Wong Aug 18 '22 at 07:17

0 Answers0