From fea8fda1a2f6a07eac7bb37c3c40a053d398ef92 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 19 Nov 2013 11:29:07 +0100 Subject: [PATCH] integration wip: wrap/unwrap node commands - comment out lists handling as they are not supported yet - handle unwrapping single node --- src/editor/modules/documentCanvas/commands.js | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/editor/modules/documentCanvas/commands.js b/src/editor/modules/documentCanvas/commands.js index 69dd305..1981429 100644 --- a/src/editor/modules/documentCanvas/commands.js +++ b/src/editor/modules/documentCanvas/commands.js @@ -27,27 +27,29 @@ commands.register('unwrap-node', function(canvas) { parent2 = selectionEnd.element.parent() || undefined; if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) { - var selectionAnchor = cursor.getSelectionAnchor(); - canvas.list.extractItems({element1: parent1, element2: parent2}); - canvas.setCurrentElement(selectionAnchor.element, {caretTo: selectionAnchor.offset}); + return; + // TODO + // var selectionAnchor = cursor.getSelectionAnchor(); + // canvas.list.extractItems({element1: parent1, element2: parent2}); + // canvas.setCurrentElement(selectionAnchor.element, {caretTo: selectionAnchor.offset}); } else if(!cursor.isSelecting()) { - var toUnwrap = cursor.getPosition().element, - parent = toUnwrap.unwrap(); - canvas.setCurrentElement(parent); + var nodeToUnwrap = cursor.getPosition().element.data('wlxmlNode'), + parentNode = nodeToUnwrap.unwrap(); + canvas.setCurrentElement(utils.findCanvasElement(parentNode)); } }); -commands.register('wrap-node', function(canvas) { - var cursor = canvas.getCursor(), - selectionStart = cursor.getSelectionStart(), - selectionEnd = cursor.getSelectionEnd(), - parent1 = selectionStart.element.parent() || undefined, - parent2 = selectionEnd.element.parent() || undefined; - - if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) { - canvas.list.create({element1: parent1, element2: parent2}); - } -}); +// commands.register('wrap-node', function(canvas) { +// var cursor = canvas.getCursor(), +// selectionStart = cursor.getSelectionStart(), +// selectionEnd = cursor.getSelectionEnd(), +// parent1 = selectionStart.element.parent() || undefined, +// parent2 = selectionEnd.element.parent() || undefined; + +// if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) { +// canvas.list.create({element1: parent1, element2: parent2}); +// } +// }); commands.register('list', function(canvas, params) { var cursor = canvas.getCursor(), -- 2.20.1