cleanPastedHTML option to preserve formatting when copy/pasting in editor

The biggest problem I had integrating a contenteditable area into my company's CMS was figuring out how to safely copy and paste documents in a way that 1) preserved formatting like links and italics but 2) created clean HTML. This is a problem even just copy/pasting a paragraph within one editable area on the editor itself. For our staff additionally they often start a document in Google Docs.

Medium's editor is very good at this. You can copy/paste in a google doc full of links and formatting and you will wind up with very tidy text in paragraph tags with the b's and i's and a's all preserved.

This is my solution. It is a combination of regex replacements on the clipboard contents and DOM manipulation once the html has made it into the browser. I've included test cases with clipboard contents from several different sources.