Editorjs:Sanitze HTML客户端的最佳方式

发布于 2025-02-03 16:17:42 字数 528 浏览 2 评论 0原文

我正在使用带有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文