From: Aleksander Ɓukasz Date: Tue, 21 Jan 2014 11:59:04 +0000 (+0100) Subject: editor: allow for adding new node via toolbar after the current one X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/8a17c686a21178f73ea93a9d7f2c6ee3bf90aa72?ds=inline 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. --- 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); } });