X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/68c9d615c3b5f4d6fefcd721f0315fde89fc3328..e6993e4bfe0e5fd38ccf554da489b5af3625c2fb:/src/editor/plugins/core/templates.js diff --git a/src/editor/plugins/core/templates.js b/src/editor/plugins/core/templates.js index 1114258..69e30f9 100644 --- a/src/editor/plugins/core/templates.js +++ b/src/editor/plugins/core/templates.js @@ -16,6 +16,8 @@ var insertTemplateAction = { icon: 'core.plus' }, getState: function(params) { + var description; + if(!(params.template && params.template.id)) { return { allowed: false, @@ -31,13 +33,21 @@ var insertTemplateAction = { 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 + } + }); } }; }