Home > OS >  Copy to clipboard with styles and show the text with styles when pasted
Copy to clipboard with styles and show the text with styles when pasted

Time:01-09

i have a project that needs to copy strikethrough text here is the example site

https://convertcase.net/strikethrough-text-generator/

i want to strikethrough the text and copy it with the styles and when i paste it somewhere it should show the same strikethrough text with styles.

The website above applies styles even in google chrome search bar.

How can i do it with the javascript ?

Thanks

CodePudding user response:

The site you referenced generates a 'modified' version of the string, with a special Unicode character between every letter. I used Babelstone to check the contents of the modified string.

If you enter 'ABC', then convert, the website add a "COMBINING LONG STROKE OVERLAY {strikethrough}" after every character.

The problem here is not 'styles' (I am assuming you are talking about CSS styles), but rather you would have to add the Unicode character above after every character.

TLDR: After every character in 'ABC', add the U 0336 character, then copy it to the clipboard.

You can get the Unicode character here.

  • Related