editor: fix - perform inserting empty footnote operation within one transaction
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 30 Jan 2014 16:12:54 +0000 (17:12 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 30 Jan 2014 16:12:54 +0000 (17:12 +0100)
src/editor/modules/documentCanvas/commands.js

index e0fc3f8..4c52c91 100644 (file)
@@ -212,14 +212,17 @@ commands.register('footnote', function(canvas, params) {
     void(params);
     var cursor = canvas.getCursor(),
         position = cursor.getPosition(),
-        asideNode, asideElement;
+        asideNode, asideElement, node;
         
 
     if(cursor.isSelectingWithinElement()) {
         asideNode = position.element.data('wlxmlNode').wrapWith({tagName: 'aside', attrs:{'class': 'footnote'}, start: cursor.getSelectionStart().offset, end: cursor.getSelectionEnd().offset});
     } else {
-        asideNode = position.element.data('wlxmlNode').divideWithElementNode({tagName: 'aside', attrs:{'class': 'footnote'}}, {offset: position.offset});
-        asideNode.append({text: ''});
+        node = position.element.data('wlxmlNode');
+        node.document.transaction(function() {
+            asideNode = node.divideWithElementNode({tagName: 'aside', attrs:{'class': 'footnote'}}, {offset: position.offset});
+            asideNode.append({text: ''});
+        });
     }
 
     asideElement = utils.findCanvasElement(asideNode);