Rollback selection calculation
This commit is contained in:
parent
edfd8a1603
commit
65d2c6c455
@ -252,14 +252,20 @@ define([
|
||||
var selectionRange = selection.getRangeAt(0);
|
||||
var node = selectionRange.startContainer;
|
||||
if((contentElt.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_CONTAINED_BY) || contentElt === node) {
|
||||
var range = self.createRange({
|
||||
container: contentElt,
|
||||
offsetInContainer: 0
|
||||
}, {
|
||||
container: node,
|
||||
offsetInContainer: selectionRange.startOffset
|
||||
});
|
||||
var offset = range.toString().length;
|
||||
var offset = selectionRange.startOffset;
|
||||
if(node.hasChildNodes() && offset > 0) {
|
||||
node = node.childNodes[offset - 1];
|
||||
offset = node.textContent.length;
|
||||
}
|
||||
var container = node;
|
||||
while(node != contentElt) {
|
||||
while(node = node.previousSibling) {
|
||||
if(node.textContent) {
|
||||
offset += node.textContent.length;
|
||||
}
|
||||
}
|
||||
node = container = container.parentNode;
|
||||
}
|
||||
|
||||
if(selection.isBackwards()) {
|
||||
selectionStart = offset + selectionRange.toString().length;
|
||||
|
Loading…
Reference in New Issue
Block a user