desc = dir === 'undo' ? gettext('Undo') : gettext('Redo'),
descEmpty = dir === 'undo' ? gettext('There is nothing to undo') : gettext('There is nothing to redo');
if(allowed) {
- desc += ': ' + (_.last(params.document[dir+'Stack']).metadata || gettext('unknown operation'));
+ var metadata = _.last(params.document[dir+'Stack']).metadata;
+ if(metadata) {
+ desc += ': ' + (metadata.description || gettext('unknown operation'));
+ }
}
return {
allowed: allowed,
icon: 'comment',
execute: function(params, editor) {
/* globals Node */
- var node = params.fragment.node;
+ var node = params.fragment.node,
+ action = this;
if(node.nodeType === Node.TEXT_NODE) {
node = node.parent();
}
var metadata = comment.getMetadata();
metadata.add({key: 'creator', value: creator});
metadata.add({key: 'date', value: dt});
+ }, {
+ metadata: {
+ description: action.getState().description
+ }
});
},
},
return _.extend(state, {
allowed: true,
+ description: createParams.description,
execute: function(params) {
params.fragment.document.transaction(function() {
var parent = params.fragment.startNode.parent();
offsetEnd: params.fragment.endOffset,
textNodeIdx: [params.fragment.startNode.getIndex(), params.fragment.endNode.getIndex()]
});
+ }, {
+ metadata: {
+ description: createParams.description
+ }
});
}
});
fields: [
{label: gettext('Link'), name: 'href', type: 'input'}
]
- });
+ }),
+ action = this;
dialog.on('execute', function(event) {
doc.transaction(function() {
span.setAttr('href', event.formData.href);
event.success();
return span;
+ }, {
+ metadata: {
+ description: action.getState().description
+ }
});
});
dialog.show();
fields: [
{label: gettext('Link'), name: 'href', type: 'input', initialValue: link.getAttr('href')}
]
- });
+ }),
+ action = this;
dialog.on('execute', function(event) {
doc.transaction(function() {
link.setAttr('href', event.formData.href);
event.success();
+ }, {
+ metadata: {
+ description: action.getState().description
+ }
});
});
dialog.show();
undoRedoAction('undo'),
undoRedoAction('redo'),
commentAction,
- createWrapTextAction({name: 'emphasis', klass: 'emp'}),
- createWrapTextAction({name: 'cite', klass: 'cite'}),
+ createWrapTextAction({name: 'emphasis', klass: 'emp', description: gettext('Mark as emphasized')}),
+ createWrapTextAction({name: 'cite', klass: 'cite', description: gettext('Mark as citation')}),
linkAction
].concat(plugin.actions, templates.actions, footnote.actions, switchTo.actions, lists.actions);
var execute = {
add: function(params) {
var boundries = getBoundriesForAList(params.fragment),
- listParams = {klass: type === 'Bullet' ? 'list' : 'list.enum'};
+ listParams = {klass: type === 'Bullet' ? 'list' : 'list.enum'},
+ action = this;
+
if(boundries && boundries.node1) {
listParams.node1 = boundries.node1;
listParams.node2 = boundries.node2;
- boundries.node1.document.createList(listParams);
+ boundries.node1.document.transaction(function() {
+ boundries.node1.document.createList(listParams);
+ }, {
+ metadata: {
+ description: action.getState().description
+ }
+ });
} else {
throw new Error('Invalid boundries');
}
},
remove: function(params) {
/* globals Node */
- var current = params.fragment.node;
+ var current = params.fragment.node,
+ action = this;
var toSearch = current.nodeType === Node.ELEMENT_NODE ? [current] : [];
toSearch = toSearch.concat(current.parents());
toSearch.some(function(node) {
if(node.is('list')) {
- node.object.extractListItems();
+ node.document.transaction(function() {
+ node.object.extractListItems();
+ }, {
+ metadata: {
+ description: action.getState().description
+ }
+ });
+
return true; // break
}
- });
+ }.bind(this));
},
changeType: function(params) {
- params.fragment.node.getParent('list').setClass(type === 'Bullet' ? 'list' : 'list.enum');
+ var node = params.fragment.node,
+ action = this;
+ node.document.transaction(function() {
+ node.getParent('list').setClass(type === 'Bullet' ? 'list' : 'list.enum');
+ }, {
+ metadata: {
+ description: action.getState().description
+ }
+ });
}
};
var state = {
label: this.config.label
},
- f = params.fragment;
+ f = params.fragment,
+ description;
if(
toSwitch = toSwitch.getParent(createParams.from);
}
+ description = 'Switch to ' + createParams.to.name;
return _.extend(state, {
allowed: !!toSwitch,
toggled: alreadyInTarget,
- description: 'Switch to ' + createParams.to.name,
+ description: description,
execute: alreadyInTarget ? function() {} : function() {
f.document.transaction(function() {
if(createParams.to.tagName) {
if(!_.isUndefined(createParams.to.klass)) {
toSwitch.setClass(createParams.to.klass);
}
+ }, {
+ metadata: {
+ description: description
+ }
});
}
});
icon: 'core.plus'
},
getState: function(params) {
+ var description;
+
if(!(params.template && params.template.id)) {
return {
allowed: false,
description: gettext('Wrong node selected')
};
}
+
+ description = interpolate(gettext('Insert template %s after %s'), [params.template.name, params.fragment.node.getNearestElementNode().getTagName()]);
return {
allowed: true,
- description: interpolate(gettext('Insert template %s after %s'), [params.template.name, params.fragment.node.getNearestElementNode().getTagName()]),
+ description: description,
execute: function(params) {
var node = params.fragment.node.getNearestElementNode();
- var toAdd = node.document.createDocumentNode(params.template.content);
- node.after(toAdd);
+ node.document.transaction(function() {
+ var toAdd = node.document.createDocumentNode(params.template.content);
+ node.after(toAdd);
+ }, {
+ metadata: {
+ description: description
+ }
+ });
}
};
}