Improve contentEditable support

Rebase of #1253 onto current master. From #1253:

> #1246, less the functionality which blurs `contentEditable` elements when `esc` is pressed (by clearing the document selection).

>This is functionally the same as #1247 except
* it detects a wider range of `contentEditable` elements.
* it fixes link hints for `contentEditable` elements.

>This
* fixes #888 
* fixes #1136 
* fixes #1245.