Setting caret after moving list elements up one level
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 17 Jul 2013 11:58:10 +0000 (13:58 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 17 Jul 2013 11:58:10 +0000 (13:58 +0200)
modules/documentCanvas/commands.js

index 52f03d8..0c9fef0 100644 (file)
@@ -26,7 +26,9 @@ commands.register('unwrap-node', function(canvas) {
         parent2 = selectionEnd.element.parent() || undefined;
 
     if(canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
         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.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();
     } else if(!cursor.isSelecting()) {
         var toUnwrap = cursor.getPosition().element,
             parent = toUnwrap.unwrap();