Visual editor: hitting enter moves to a new tag - copy of current one (Chrome, FF)
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 19 Apr 2013 14:49:19 +0000 (16:49 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 19 Apr 2013 14:49:19 +0000 (16:49 +0200)
editor.css
modules/visualEditor.js

index cf1abc2..5d3eae2 100644 (file)
@@ -177,6 +177,11 @@ body {
     min-height:20px;\r
 }\r
 \r
+span[wlxml-tag] {\r
+    display:inline-block;\r
+    min-width: 10px;\r
+}\r
+\r
 [wlxml-tag=header] {\r
     font-size: 13px;\r
     font-weight: bold;\r
index f3c0a5c..702c812 100644 (file)
@@ -31,6 +31,18 @@ rng.modules.visualEditor = function(sandbox) {
                 view._markSelected(anchor);\r
             });\r
             \r
+            this.node.on('keydown', '#rng-visualEditor-contentWrapper', function(e) {\r
+                if(e.which === 13) { \r
+                    e.preventDefault();\r
+                    var anchor = $(window.getSelection().anchorNode);\r
+                    if(anchor[0].nodeType === Node.TEXT_NODE)\r
+                        anchor = anchor.parent();\r
+                    var newNode = anchor.clone().empty();\r
+                    anchor.after(newNode);\r
+                    view.selectNode(newNode);\r
+                }\r
+            });\r
+            \r
             \r
             var metaTable = this.metaTable = this.node.find('#rng-visualEditor-meta table');\r
             \r