editor: allow for adding new node via toolbar after the current one
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 21 Jan 2014 11:59:04 +0000 (12:59 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 21 Jan 2014 11:59:04 +0000 (12:59 +0100)
Changed behavior: wrapping current node happened upon clicking toolbar
icon while cursor exists but is not selecting. Now, for that to happen,
also ctrl key must be pressed. The former behavior now adds new node
after the current one.

src/editor/modules/documentCanvas/commands.js
src/editor/modules/documentToolbar/documentToolbar.js

index 8ceba63..284c613 100644 (file)
@@ -191,11 +191,18 @@ commands.register('newNodeRequested', function(canvas, params, user) {
         }
     } else if(canvas.getCurrentNodeElement()) {
         wlxmlNode = canvas.getCurrentNodeElement().data('wlxmlNode');
-        wrapper = insertNode(function() {
-            return wlxmlNode.wrapWith({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}});
-        });
+        if(params.ctrlKey) {
+            wrapper = insertNode(function() {
+                return wlxmlNode.wrapWith({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}});
+            });
+        } else {
+            wrapper = insertNode(function() {
+                var node = wlxmlNode.after({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}});
+                node.append({text:''});
+                return node;
+            });
+        }
         canvas.setCurrentElement(utils.findCanvasElement(wrapper));
-
     }
 
 
index 6c58555..33f95a6 100644 (file)
@@ -50,6 +50,8 @@ return function(sandbox) {
                         };
                     }
 
+                    _.extend(params, {ctrlKey: e.ctrlKey});
+
                     sandbox.publish('command', command, params);
                 }
             });