英文:
Copy to clipboard with styles and show the text with styles when pasted
问题
我有一个项目需要复制删除线文本,以下是示例网站:
https://convertcase.net/strikethrough-text-generator/
我想要将文本加上删除线并复制它的样式,当我粘贴到其他地方时,它应该显示相同的带有样式的删除线文本。
上述网站甚至在Google Chrome搜索栏中应用样式。
我应该如何使用JavaScript来实现这个?
谢谢
英文:
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
答案1
得分: 0
你提到的网站生成了一个**'修改过的'**字符串版本,其中在每个字母之间添加了一个特殊的Unicode字符。我使用了Babelstone来检查修改后的字符串的内容。
如果你输入'ABC',然后进行转换,该网站会在每个字符后面添加一个**"COMBINING LONG STROKE OVERLAY {strikethrough}"**。
这里的问题不是*'样式'*(我假设你是在谈论CSS样式),而是你需要在每个字符后面添加Unicode字符。
TLDR:
在'ABC'的每个字符后面添加U+0336字符,然后将其复制到剪贴板上。
你可以在这里获取Unicode字符。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论