From 8a17c686a21178f73ea93a9d7f2c6ee3bf90aa72 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 21 Jan 2014 12:59:04 +0100 Subject: [PATCH] editor: allow for adding new node via toolbar after the current one 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 | 15 +++++++++++---- .../modules/documentToolbar/documentToolbar.js | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/editor/modules/documentCanvas/commands.js b/src/editor/modules/documentCanvas/commands.js index 8ceba63..284c613 100644 --- a/src/editor/modules/documentCanvas/commands.js +++ b/src/editor/modules/documentCanvas/commands.js @@ -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)); - } diff --git a/src/editor/modules/documentToolbar/documentToolbar.js b/src/editor/modules/documentToolbar/documentToolbar.js index 6c58555..33f95a6 100644 --- a/src/editor/modules/documentToolbar/documentToolbar.js +++ b/src/editor/modules/documentToolbar/documentToolbar.js @@ -50,6 +50,8 @@ return function(sandbox) { }; } + _.extend(params, {ctrlKey: e.ctrlKey}); + sandbox.publish('command', command, params); } }); -- 2.20.1