|
|
@ -738,29 +738,27 @@ MessageComposer.prototype.onEmojiSelected = function (code, autocomplete) { |
|
|
|
if (window.getSelection) { |
|
|
|
if (window.getSelection) { |
|
|
|
var sel = window.getSelection(); |
|
|
|
var sel = window.getSelection(); |
|
|
|
if (sel.getRangeAt && sel.rangeCount) { |
|
|
|
if (sel.getRangeAt && sel.rangeCount) { |
|
|
|
var range = sel.getRangeAt(0); |
|
|
|
|
|
|
|
range.deleteContents(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var el = document.createElement('div'); |
|
|
|
var el = document.createElement('div'); |
|
|
|
el.innerHTML = html; |
|
|
|
el.innerHTML = html; |
|
|
|
var frag = document.createDocumentFragment(), node, lastNode; |
|
|
|
var node = el.firstChild; |
|
|
|
while ( (node = el.firstChild) ) { |
|
|
|
var range = sel.getRangeAt(0); |
|
|
|
lastNode = frag.appendChild(node); |
|
|
|
range.deleteContents(); |
|
|
|
} |
|
|
|
range.insertNode(document.createTextNode(' ')); |
|
|
|
range.insertNode(frag); |
|
|
|
range.insertNode(node); |
|
|
|
|
|
|
|
range.setStart(node, 0); |
|
|
|
|
|
|
|
|
|
|
|
if (lastNode) { |
|
|
|
setTimeout(function() { |
|
|
|
range = range.cloneRange(); |
|
|
|
range = document.createRange(); |
|
|
|
range.setStartAfter(lastNode); |
|
|
|
range.setStartAfter(node); |
|
|
|
range.collapse(true); |
|
|
|
range.collapse(true); |
|
|
|
sel.removeAllRanges(); |
|
|
|
sel.removeAllRanges(); |
|
|
|
sel.addRange(range); |
|
|
|
sel.addRange(range); |
|
|
|
} |
|
|
|
}, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (document.selection && document.selection.type != 'Control') { |
|
|
|
} else if (document.selection && document.selection.type != 'Control') { |
|
|
|
document.selection.createRange().pasteHTML(html); |
|
|
|
document.selection.createRange().pasteHTML(html); |
|
|
|
} |
|
|
|
} |
|
|
|
// document.execCommand('insertHTML', false, html);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|