Canvas.getCursor()
[fnpeditor.git] / modules / documentCanvas / canvasManager.js
index b483937..afc3363 100644 (file)
@@ -195,15 +195,15 @@ Manager.prototype.command = function(command, params) {
     var selection  = window.getSelection(),
         element1 = this.canvas.getDocumentElement(selection.anchorNode),
         element2 = this.canvas.getDocumentElement(selection.focusNode),
-        parent1 = element1.parent(),
-        parent2 = element2.parent();
+        parent1 = element1 ? element1.parent() : undefined,
+        parent2 = element2 ? element2.parent() : undefined;
 
     if(command === 'unwrap-node') {
         // this.canvas.nodeUnwrap({node: canvasNode.create(pos.parentNode)});
         // this.sandbox.publish('contentChanged');
         if(this.canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
             this.canvas.list.extractItems({element1: parent1, element2: parent2});
-        } else if (!selection.collapsed) {
+        } else if (selection.isCollapsed) {
             element1.unwrap();
         }
     } else if(command === 'wrap-node') {