Makes code more readable and ready to future changes.
Check id offset == container.length before enlarge end.
Handle white spaces after element.
Prevent enlarge going outside contenteditable="false".
Export onlyWhiteSpaces to function and call it in both interesting places.
Check 'onlyWhiteSpaces' only if offset != container.getLength().