From b9da1f18b48ac7243e2180b6502afbe3ed5fef24 Mon Sep 17 00:00:00 2001
From: wajnberg <WAJNBERG@il.ibm.com>
Date: Sun, 18 Sep 2016 23:20:50 +0300
Subject: [PATCH] Fixing issue 989 (#997)

* Fixing issue 989

Signed-off-by: Moshe Wajnberg <wajnberg@il.ibm.com>

* Fixing the getRangeAt problem on Chrome

Signed-off-by: Moshe Wajnberg <wajnberg@il.ibm.com>

* Fixing the getRangeAt problem on Chrome

Signed-off-by: Moshe Wajnberg <wajnberg@il.ibm.com>
---
 editor/js/text/format.js | 5 +++--
 editor/sass/editor.scss  | 2 +-
 editor/sass/forms.scss   | 5 +++++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/editor/js/text/format.js b/editor/js/text/format.js
index cfbc92142..937bd6a43 100644
--- a/editor/js/text/format.js
+++ b/editor/js/text/format.js
@@ -1237,11 +1237,12 @@ RED.text.format = (function() {
 
     function displayWithStructure(element) {
         var txt = element.textContent || "";
-        if (txt.length === 0) {
+        var selection = document.getSelection();
+        if (txt.length === 0 || !selection || selection.rangeCount <= 0) {
             element.dispatchEvent(event);
             return;
         }
-        var selection = document.getSelection();
+        
         var range = selection.getRangeAt(0);
         var tempRange = range.cloneRange(), startNode, startOffset;
         startNode = range.startContainer;
diff --git a/editor/sass/editor.scss b/editor/sass/editor.scss
index 8b40403b5..b0f20634f 100644
--- a/editor/sass/editor.scss
+++ b/editor/sass/editor.scss
@@ -196,7 +196,7 @@
     display: inline-block;
     width: 100px;
 }
-.form-row input .form-row div[contenteditable="true"] {
+.form-row input, .form-row div[contenteditable="true"] {
     width:70%;
 }
 
diff --git a/editor/sass/forms.scss b/editor/sass/forms.scss
index c0242a802..6266e156d 100644
--- a/editor/sass/forms.scss
+++ b/editor/sass/forms.scss
@@ -1082,3 +1082,8 @@ legend + .control-group {
 .form-horizontal .form-actions {
   padding-left: 180px;
 }
+
+.form-row div[contenteditable="true"] { 
+   white-space: nowrap;
+   overflow: hidden;
+}