X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/9831076c8f7385dffb533e0327cc7dd7c9f1ef92..e669605bf75acf5d20b67ce6f9886e9259146615:/src/editor/modules/nodePane/nodePane.js?ds=sidebyside diff --git a/src/editor/modules/nodePane/nodePane.js b/src/editor/modules/nodePane/nodePane.js index f7e6694..25e5ddb 100644 --- a/src/editor/modules/nodePane/nodePane.js +++ b/src/editor/modules/nodePane/nodePane.js @@ -12,13 +12,20 @@ return function(sandbox) { var view = $(_.template(templateSrc)({utils: wlxmlUtils})), listens = false, - currentNode; + currentNode, + msgs = { + Tag: gettext('Tag editing'), + Class: gettext('Class editing') + }; view.on('change', 'select', function(e) { var target = $(e.target); var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'Tag' : 'Class', - value = target.val().replace(/-/g, '.'); - currentNode['set' + attr](value); + value = target.val().replace(/-/g, '.'), + oldValue = attr === 'Tag' ? currentNode.getTagName() : currentNode.getClass(); + currentNode.document.transaction(function() { + currentNode['set' + attr](value); + }, this, msgs[attr] + ': ' + oldValue + ' -> ' + value); }); @@ -35,6 +42,9 @@ return function(sandbox) { var module = this; if(!listens) { wlxmlNodeElement.document.on('change', function(event) { + if(currentNode && !currentNode.isInDocument()) { + module.setNodeElement(null); + } if(event.type === 'nodeAttrChange' && event.meta.node.sameNode(currentNode)) { module.setNodeElement(currentNode); }