Implementation of smart cursor. Partially working.

Need to fix -
1) selection range is outside currentInputBox
2) selection contains image nodes
3) recover caret position