3 ms·
When pasting from Word, the contentEditable will gladly accept any formatting that came with the paste (e.g whatever strongs, bolds, italics, links, headings, t
by askonomm 5y ago
When pasting from Word, the contentEditable will gladly accept any formatting that came with the paste (e.g whatever strongs, bolds, italics, links, headings, tables, what-not you may have in your clipboard), and so the sanitize-html NPM library essentially strips out the elements I do not want for UX consistency. Since I'm building this contentEditable just for a singular paragraph as part of a larger block-based editor, I only want it to contain what a regular paragraph would (e.g bold, italic, link), but nothing else.
So, all-in-all, the clipboard contains still everything, the sanitize-html library would strip things from it that you wouldn't want, so that you're left with only the formatting you do want. As for images, since I'm stripping them out as well, there will not be any images. By default I'm not sure if they end up as base-64 (I'm leaning to believe that rather they would get local URL's like file://...).