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>
This commit is contained in:
wajnberg
2016-09-18 23:20:50 +03:00
committed by Nick O'Leary
parent 55d7420abf
commit b9da1f18b4
3 changed files with 9 additions and 3 deletions

View File

@@ -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;