X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7dd937f65ffd6278d02561647dc5f5553debf3e6..f17e9178a91a7df96fd252f66e058e880eac8932:/modules/documentCanvas/canvas/canvas.js diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index 50ca6c0..f80e961 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++) { @@ -216,13 +216,14 @@ $.extend(Canvas.prototype, { if(params.caretTo || !textElementToLand.sameNode(this.getCursor().getPosition().element)) this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element? if(!(textElementToLand.sameNode(currentTextElement))) - this.publisher('currentTextElementSet', element); + this.publisher('currentTextElementSet', textElementToLand); + } else { + document.getSelection().removeAllRanges(); } if(!(currentNodeElement && currentNodeElement.sameNode(nodeElementToLand))) { _markAsCurrent(nodeElementToLand); - if(!textElementToLand) - document.getSelection().removeAllRanges(); + this.publisher('currentNodeElementSet', nodeElementToLand); } }, @@ -418,6 +419,9 @@ $.extend(Cursor.prototype, { anchorElement = this.canvas.getDocumentElement(selection.anchorNode), focusElement = this.canvas.getDocumentElement(selection.focusNode); + if(anchorElement instanceof documentElement.DocumentNodeElement || focusElement instanceof documentElement.DocumentNodeElement) + return {}; + if(which === 'anchor') { return { element: anchorElement,