internal container wip: Chrome hack - making sure that user can't navigate out of...
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 30 Jul 2013 13:59:41 +0000 (15:59 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 5 Aug 2013 10:20:07 +0000 (12:20 +0200)
modules/documentCanvas/canvas/canvas.js
modules/documentCanvas/nodes.less

index 83fc504..6179b83 100644 (file)
@@ -169,8 +169,23 @@ $.extend(Canvas.prototype, {
             }
 
             this.wrapper.on('keyup', function(e) {
-                if(e.which >= 37 && e.which <= 40)
-                    canvas.setCurrentElement(canvas.getCursor().getPosition().element, {caretTo: false})
+                if(e.which >= 37 && e.which <= 40) {
+                    var element = canvas.getCursor().getPosition().element,
+                        caretTo = false;
+                    if(!element) {
+                        // Chrome hack
+                        var direction;
+                        if(e.which === (KEYS.ARROW_LEFT  || KEYS.ARROW_DOWN)) {
+                            direction = 'above';
+                            caretTo = 'end';
+                        } else {
+                            direction = 'below';
+                            caretTo = 'start';
+                        }
+                        element = canvas.getDocumentElement(utils.nearestInDocumentOrder('[document-text-element]', direction, window.getSelection().focusNode));
+                    }
+                    canvas.setCurrentElement(element, {caretTo: caretTo});
+                }
             });
          
             this.wrapper.on('keydown', function(e) {
index cf1df16..3477c3c 100644 (file)
@@ -1,4 +1,8 @@
+[document-node-element] {
+    font-size: 1px;
+}
 [document-text-element] {
+    font-size: 14px;
     display: inline;
     margin: 0 1px;
     border: 1px solid white;
@@ -20,7 +24,7 @@
     min-width: 10px;
 }
 
-[wlxml-tag=header] {
+[wlxml-tag=header] [document-text-element] {
     font-size: 13px;
     font-weight: bold;
     margin: 10px 0;
     color: blue;
 }
 
-[wlxml-tag=header] [wlxml-class=author] {
+[wlxml-tag=header] [wlxml-class=author] [document-text-element] {
     font-size: 14px;
 }
 
-[wlxml-tag=header] [wlxml-class=title] {
+[wlxml-tag=header] [wlxml-class=title] [document-text-element] {
     font-size:18px;
 }