kogmbh/WebODF — pull request #547 by peitschie (2014-04-16 07:49:51+00:00)
Title: Support text composition events that contain line breaks

Dictation programs on OSX (and probably other OSs) enter new data via the same IME mechanism that multi-language support uses. In this particular instance, the dictation program supports the phrase "new paragraph" or "new line", which causes it put a new-line character in the event trap, which the IME handling happily converts directly into an InsertText op. As the inserted character is neither a space or tab element, the new line character is placed directly into the document. This either causes the cursor to move to a strange location if in the middle of a document, or a crash if at the end (because the inserted character is not a proper space or a paragraph split etc.). It also causes OT to fail as the text.length no longer matches the number of inserted characters.

# Patch summary
* Support text composition events that contain line breaks (as can be generated using the OSX 10.9 built-in dictation feature)
* Allow insert text op to gracefully cope with strange whitespace by replacing non-tab non-space whitespace characters with simple ODF space elements
* Optimize paste handling to only create new paragraphs if necessary