Option to sanitize HTML inputs

Copy/paste html text from Dropbox Paper, Google Docs (not talking about MS Word) could be painful. Style works but content is not clean, a lot of spans and horribe invisible useless tags are also pasted.

In text input presentation, after choosing the HTML editor, i would like to enable sanitiziation. Optionally i may choose the stuff i want to be saved: like: tables, spans, iframes, script, css.

My workflow now, from Dropbox Paper: export in markdown, convert markdown in html, copy/paste the clean html.

Would also be nice to turn off the ability to resize things like tables and pictures that add properties that aren’t responsive friendly.

A quick fix is using the shortcuts Ctrl+Shift+V on Windows or Cmd+Opt +Shift+V on Mac to paste sanitized text!

1 Like

We’ve made a plugin for that … https://github.com/SYMBIO/datocms-plugin-sanitize-richtext. It’s private at the moment but feel free to fork it. Maybe we’ll publish it as public plugin some day :slight_smile:

1 Like

nice, yes @dev3 ! If you put it on npm we’ll pick it automatically :slight_smile: would be awesome, thanks!

OK, it’s here https://www.npmjs.com/package/datocms-plugin-sanitize-richtext

1 Like

Hi @dev3 - I haven’t had a close look at the plugin yet but would it be difficult to have this support the newer Structured Text fields?

we don’t yet support plugins for structured text fields, but we would like to allow those soon!

Thanks @mat_jack1 , good to know!

Could the basic Dato HTML editor include a “strip all formatting/tags” button (that can be added just like any other button in the toolbar)?

Not now, but you can have a field-addon plugin to do that: How to build DatoCMS plugins - DatoCMS

Otherwise we are going to publish an example RTE plugin so that you can customize it as you wish, so that we don’t need to add all the possible options to our settings page making it unusable.

Thanks, that would be great!