From: Aleksander Ɓukasz Date: Tue, 30 Jul 2013 13:59:41 +0000 (+0200) Subject: internal container wip: Chrome hack - making sure that user can't navigate out of... X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/4f68cdcc12eb61a0061fc1a3b143ea5fa4f77310 internal container wip: Chrome hack - making sure that user can't navigate out of document-text-element --- diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index 83fc504..6179b83 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -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) { diff --git a/modules/documentCanvas/nodes.less b/modules/documentCanvas/nodes.less index cf1df16..3477c3c 100644 --- a/modules/documentCanvas/nodes.less +++ b/modules/documentCanvas/nodes.less @@ -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; @@ -47,11 +51,11 @@ 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; }