简体   繁体   English

如何在文本区域中显示标签

[英]How to show tags in a textarea

I am trying to show tags in a textarea in my react app like this:我试图在我的反应应用程序的文本区域中显示标签,如下所示: 在此处输入图像描述 The user should be able to add his own tags to the textarea.用户应该能够将他自己的标签添加到文本区域。 I can't figure out how to do it without creating XSS vulnerabilities.如果不创建 XSS 漏洞,我无法弄清楚如何做到这一点。 Does anyone know what the best way to do this is?有谁知道最好的方法是什么?

Your question was not clear to me, however there are 2 different possibilities for the question and here we have the answers.你的问题我不清楚,但是这个问题有两种不同的可能性,在这里我们有答案。

  1. If you want your user to add/update the existing text/content, go with contenteditable如果您希望您的用户添加/更新现有的文本/内容,go with contenteditable

  2. If you want your user to have flexibility of editing not only just content, also able to add, style the content then go with code editors there are plenty of code editors and you can pick one among them based on your use case.如果您希望您的用户不仅可以灵活地编辑内容,还可以添加内容、设置内容样式,那么使用代码编辑器的 go 有很多代码编辑器,您可以根据您的用例选择其中一种。

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM