From: Aleksander Ɓukasz Date: Mon, 15 Jul 2013 21:17:33 +0000 (+0200) Subject: Fixing text to land algorithm - handling case when no child text element exist better X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/ef3798eb62c7d42315da10c02ce75ba0b9232dd0 Fixing text to land algorithm - handling case when no child text element exist better --- diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index 50ca6c0..a3d24a0 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -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); } },