});
commands.register('toggle-grid', function(canvas, params) {
- canvas.doc().dom().find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', params.toggle);
+ canvas.doc().dom().parent().toggleClass('grid-on', params.toggle);
gridToggled = params.toggle;
});
}
} else if(canvas.getCurrentNodeElement()) {
wlxmlNode = canvas.getCurrentNodeElement().data('wlxmlNode');
- wrapper = insertNode(function() {
- return wlxmlNode.wrapWith({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}});
- });
+ if(params.ctrlKey) {
+ wrapper = insertNode(function() {
+ return wlxmlNode.wrapWith({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}});
+ });
+ } else {
+ wrapper = insertNode(function() {
+ var node = wlxmlNode.after({tagName: params.wlxmlTag, attrs: {'class': params.wlxmlClass}});
+ node.append({text:''});
+ return node;
+ });
+ }
canvas.setCurrentElement(utils.findCanvasElement(wrapper));
-
}
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);