From 38cbe0746d1690d5fcbd4c074e5fec2aa006bf51 Mon Sep 17 00:00:00 2001 From: Philip Peitsch Date: Wed, 16 Apr 2014 17:27:24 +1000 Subject: [PATCH] Support text composition events that contain line breaks Using the paste-handler for text that contains new lines allows the inserted text to correctly create new paragraphs as necessary. --- webodf/lib/gui/SessionController.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webodf/lib/gui/SessionController.js b/webodf/lib/gui/SessionController.js index 84b65398..9547b7d8 100644 --- a/webodf/lib/gui/SessionController.js +++ b/webodf/lib/gui/SessionController.js @@ -729,7 +729,13 @@ gui.SessionControllerOptions = function () { // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-compositionend var input = e.data; if (input) { - textController.insertText(input); + if (input.indexOf("\n") === -1) { + textController.insertText(input); + } else { + // Multi-line input should be handled as if it was pasted, rather than inserted as one giant + // single string. + session.enqueue(pasteHandler.createPasteOps(input)); + } } }