X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/ef3798eb62c7d42315da10c02ce75ba0b9232dd0..f17e9178a91a7df96fd252f66e058e880eac8932:/modules/documentCanvas/canvas/canvas.js?ds=inline diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index a3d24a0..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,7 +216,7 @@ $.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(); } @@ -419,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,