editor: canvas fix
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 6 Aug 2014 07:32:53 +0000 (09:32 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 14 Aug 2014 14:26:13 +0000 (16:26 +0200)
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.

src/editor/modules/documentCanvas/canvas/selection.js

index 4de392b..e072050 100644 (file)
@@ -129,7 +129,7 @@ return {
                 params = {
                     type: 'caret',
                     element: element,
                 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);
                 };
             } else if(isText(nativeSelection.focusNode) && isText(nativeSelection.anchorNode)) {
                 anchorElement = canvas.getDocumentElement(nativeSelection.anchorNode);