I’ve made a little inline editor with some clean up logic. So if you paste from a word file it deletes all the formatting.
My problem is, that if you select e.g. one sentence and paste, it doesn’t get replaced. This is duo to the cleanUp logic. Now I need to know, how I can delete a range with rangy, so I can delete this range before I paste.
You can delete a range using its
deleteContents()method.Rangy also deals with a lot of the cross-browser issues you’re attempting to fix in your jsFiddle. It provides a
createContextualFragment()implementation and a selection object withgetRangeAt(). Also, you should use thectrlKeyproperty of thekeydownevent. Here’s an updated jsFiddle:http://jsfiddle.net/timdown/eJNKy/6/
The crucial function is