Editorjs:Sanitze HTML客户端的最佳方式
我正在使用带有Strapi )。
从可靠地,我用自定义解析器直接在前端中对数据进行消毒。 它工作正常,但是当我从Word粘贴内容时,我遇到了一个问题,它添加了带有一些样式标签的跨度。
块将数据从editorjs转换为段落块的部分
paragraph: function (e) {
return "<p>" + e.data.text + "</p>";
},
//e.data.text = <span style="font-size:11pt;font-family:Arial;>Example</span>
这是我想摆脱所有样式的段落 。最好的方法是什么? 我应该在Strapi中对HTML进行消毒,还是将其保存在前面应用中?
I'm using editorJS with Strapi (back) and NextJS (front).
Acutally, I sanitize the data directly in the frontend with a custom parser.
It's working fine, but I've got an issue when I paste content from Word, it adds a span with some style tag.
This is the part when I transform the data from editorJS to a paragraph block
paragraph: function (e) {
return "<p>" + e.data.text + "</p>";
},
//e.data.text = <span style="font-size:11pt;font-family:Arial;>Example</span>
I want to get rid of all the style. What's the best method ?
Should I sanitize the HTML in the strapi or keep it like this in the front app ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论