added enter on caret paragraph start case, refactor