Content editable remove unnecessary tags with content and all html tags on paste
Good snippet to control what formatting is retained in a rich text editor on pasting data.
We have been wanting to create a rich-text editor where we can control the tags and attributes that are permitted.
Tags added in a rich text editor (through contenteditable) in multiple ways: - On pasting some rich text - Keyboard shortcuts such as ctrl b, ctrl i - Our own commands executed through document.execCommand
We can use a similar technique of tag replacement by tying the clean-up to oninput event.