0

I want to copy the <span data-dcvarid=261>{GENDER-261-234}</span> element and paste only like dom element. Now it's past like plain text. How can I fix that?

import { CopyToClipboard } from 'react-copy-to-clipboard';

const copiedValue = `<span data-dcvarid=261>{GENDER-261-234}</span>`;
... 

<CopyToClipboard text={copiedValue} onCopy={() => message.success(`${name} was copied`)}>
  Click to copy
</CopyToClipboard>
isherwood
  • 58,414
  • 16
  • 114
  • 157
someone
  • 681
  • 4
  • 18
  • Please revise to provide some context. Why copy/paste? Why not clone the element? We need to understand the whole picture. It may not be appropriate to even use the clipboard. – isherwood Sep 09 '22 at 14:24
  • I need to understand the right way of doing that ... if it's possible to do with clone then please advise me how can I archive that ... btw I am trying to copy that span element and paste into texteditor and send to backend. – someone Sep 09 '22 at 14:28
  • After paste user should see `{GENDER-261-234}` but actually behind that it should be `{GENDER-261-234}` – someone Sep 09 '22 at 14:32
  • You can do this by dynamic content ```dangerouslySetInnerHTML={{ __html: copiedValue }}``` – Romik Makavana Sep 09 '22 at 14:40
  • @RomikMakavana can you please provide the whole code ? – someone Sep 09 '22 at 14:51
  • @someone Actually, you had not detailed, how and where you paste the copied value. – Romik Makavana Sep 10 '22 at 15:17
  • @RomikMakavana, I am using `tiny editor` , and I want to past there. – someone Sep 10 '22 at 15:31

0 Answers0