X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/dea68129ff763bf38f632ad7373072faf1fda1ba..a6983a6a33c76bc7ae107c604ba73c3571aed7b8:/src/editor/modules/documentCanvas/canvas/canvas.js?ds=inline diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 50c0ae4..d8090c8 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -377,7 +377,7 @@ $.extend(Canvas.prototype, Backbone.Events, { if(textElementToLand) { _markAsCurrent(textElementToLand); - if(params.caretTo || !textElementToLand.sameNode(this.getCursor().getPosition().element)) { + if((params.caretTo || params.caretTo === 0) || !textElementToLand.sameNode(this.getCursor().getPosition().element)) { this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element? } } else { @@ -457,6 +457,9 @@ $.extend(Selection.prototype, { return doc.createFragment(doc.CaretFragment, {node: anchorNode, offset: this.nativeSelection.anchorOffset}); } if(this.type === 'textSelection') { + if(!anchorNode || !focusNode) { + return; + } if(anchorNode.isSiblingOf(focusNode)) { return doc.createFragment(doc.TextRangeFragment, { node1: anchorNode,