- var added = element.after({tag: element.getWlxmlTag() || 'div', klass: element.getWlxmlClass() || 'p'});
- added.append({text:''});
- canvas.setCurrentElement(added, {caretTo: 'start'});
+ if(element instanceof documentElement.DocumentTextElement) {
+ element = element.parent();
+ }
+
+ canvas.wlxmlDocument.startTransaction();
+ added = element.data('wlxmlNode').after(
+ {tagName: element.getWlxmlTag() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}}
+ );
+ added.append({text: ''});
+ canvas.wlxmlDocument.endTransaction();
+ canvas.setCurrentElement(utils.findCanvasElement(added), {caretTo: 'start'});