editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

What's the best way to sanitize HTML ?

Open Kaherdin opened this issue 3 years ago • 0 comments

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 ?

Kaherdin avatar May 31 '22 10:05 Kaherdin