X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7dd937f65ffd6278d02561647dc5f5553debf3e6..67387c5b199cba829f5f7563ff93020328cbe0ef:/modules/documentCanvas/canvas/canvas.js?ds=sidebyside diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index 50ca6c0..144417a 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -181,7 +181,7 @@ $.extend(Canvas.prototype, { params = _.extend({caretTo: 'end'}, params); var findFirstDirectTextChild = function(e, nodeToLand) { var byBrowser = this.getCursor().getPosition().element; - if(byBrowser.parent().sameNode(nodeToLand)) + if(byBrowser && byBrowser.parent().sameNode(nodeToLand)) return byBrowser; var children = e.children(); for(var i = 0; i < children.length; i++) { @@ -217,12 +217,13 @@ $.extend(Canvas.prototype, { this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element? if(!(textElementToLand.sameNode(currentTextElement))) this.publisher('currentTextElementSet', element); + } else { + document.getSelection().removeAllRanges(); } if(!(currentNodeElement && currentNodeElement.sameNode(nodeElementToLand))) { _markAsCurrent(nodeElementToLand); - if(!textElementToLand) - document.getSelection().removeAllRanges(); + this.publisher('currentNodeElementSet', nodeElementToLand); } },