X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/739242f6208f3e58570194fb1000086bafd527ef..2d37cb23154783cc89f2ff286405d02e594e0e46:/modules/documentCanvas/commands.js?ds=inline diff --git a/modules/documentCanvas/commands.js b/modules/documentCanvas/commands.js index 8152ccd..955ba48 100644 --- a/modules/documentCanvas/commands.js +++ b/modules/documentCanvas/commands.js @@ -48,7 +48,7 @@ commands.register('wrap-node', function(canvas) { } }); -commands.register('toggle-list', function(canvas, params) { +commands.register('list', function(canvas, params) { var cursor = canvas.getCursor(), selectionStart = cursor.getSelectionStart(), selectionEnd = cursor.getSelectionEnd(), @@ -56,13 +56,13 @@ commands.register('toggle-list', function(canvas, params) { parent2 = selectionEnd.element.parent() || undefined; var selectionFocus = cursor.getSelectionFocus(); - if(params.toggle) { - canvas.list.create({element1: parent1, element2: parent2}); - } else { - if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) { - canvas.list.extractItems({element1: parent1, element2: parent2, merge: false}); - } + + if(selectionStart.element.isInsideList() || selectionEnd.element.isInsideList()) { + return; } + + canvas.list.create({element1: parent1, element2: parent2}); + canvas.setCurrentElement(selectionFocus.element, {caretTo: selectionFocus.offset}); }); @@ -107,6 +107,9 @@ commands.register('newNodeRequested', function(canvas, params) { }); } } + } else if(canvas.getCurrentNodeElement()) { + var el = canvas.getCurrentNodeElement().wrapWithNodeElement({tag: params.wlxmlTag, klass: params.wlxmlClass}); + canvas.setCurrentElement(el); }