将文本复制到剪贴板,并在粘贴时显示带样式的文本。

huangapple go评论76阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年1月9日 04:29:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75051052.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定