From: Aleksander Ɓukasz Date: Thu, 30 Jan 2014 16:12:54 +0000 (+0100) Subject: editor: fix - perform inserting empty footnote operation within one transaction X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/a132113f20073907fd2907a93c75c9d699516ee6?ds=sidebyside;hp=226e74a984c6e5652bc7c6f7cb97f2f27eaba6b1 editor: fix - perform inserting empty footnote operation within one transaction --- diff --git a/src/editor/modules/documentCanvas/commands.js b/src/editor/modules/documentCanvas/commands.js index e0fc3f8..4c52c91 100644 --- a/src/editor/modules/documentCanvas/commands.js +++ b/src/editor/modules/documentCanvas/commands.js @@ -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);