From: Aleksander Ɓukasz Date: Wed, 6 Aug 2014 07:32:53 +0000 (+0200) Subject: editor: canvas fix X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/83f83c6ba32734d4d6b53125d2eb4adb039ea3de editor: canvas fix In Chrome in some scenarios native Selection indicates that focusOffset is 1 even if a range that was just set in Cavnas._moveCaretToTextElement had an offset of 0. Range returned by Selection indicates a correct value. --- diff --git a/src/editor/modules/documentCanvas/canvas/selection.js b/src/editor/modules/documentCanvas/canvas/selection.js index 4de392b..e072050 100644 --- a/src/editor/modules/documentCanvas/canvas/selection.js +++ b/src/editor/modules/documentCanvas/canvas/selection.js @@ -129,7 +129,7 @@ return { params = { type: 'caret', element: element, - offset: element.isEmpty() ? 0 : nativeSelection.focusOffset + offset: element.isEmpty() ? 0 : nativeSelection.getRangeAt(0).startOffset }; } else if(isText(nativeSelection.focusNode) && isText(nativeSelection.anchorNode)) { anchorElement = canvas.getDocumentElement(nativeSelection.anchorNode);