X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/b7d40f4f02e71505150c8b33ad3ad7d7acde0ae2..b7266f76b76a0a67000144d2780a8f64967fafb4:/modules/documentCanvas/documentCanvas.js diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index df11ea0..51acbf3 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -6,7 +6,7 @@ define([ './wlxmlNode', 'libs/text!./template.html'], function(_, transformations, wlxmlNode, template) { - +'use strict'; return function(sandbox) { @@ -50,23 +50,6 @@ return function(sandbox) { view.insertNewNode(null, null); } }); - - - var observer = new MutationObserver(function(mutations) { - mutations.forEach(function(mutation) { - _.each(mutation.addedNodes, function(node) { - node = $(node); - node.parent().find('[wlxml-tag]').each(function() { - tag = $(this); - if(!tag.attr('id')) - tag.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);})); - }); - }); - }); - }); - var config = { attributes: true, childList: true, characterData: true, subtree: true }; - observer.observe(this.node.find('#rng-module-documentCanvas-contentWrapper')[0], config); - this.gridToggled = false; }, _createNode: function(wlxmlTag, wlxmlClass) { @@ -76,6 +59,7 @@ return function(sandbox) { toret.attr('wlxml-tag', wlxmlTag); if(wlxmlClass) toret.attr('wlxml-class', wlxmlClass); + toret.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);})); return toret; }, insertNewNode: function(wlxmlTag, wlxmlClass) { @@ -100,7 +84,7 @@ return function(sandbox) { anchor.before(newNode) else anchor.after(newNode); - this.selectNode(newNode); + this.selectNode(new wlxmlNode.Node(newNode), {moveCarret: true}); //isDirty = true; sandbox.publish('contentChanged'); }, @@ -124,7 +108,7 @@ return function(sandbox) { newNode.before(prefix); newNode.after(suffix); - this.selectNode(newNode); + this.selectNode(new wlxmlNode.Node(newNode), {moveCarret: true}); //isDirty = true; sandbox.publish('contentChanged'); } @@ -151,7 +135,7 @@ return function(sandbox) { newNode.before(prefixNode); newNode.after(suffixNode); - this.selectNode(newNode); + this.selectNode(new wlxmlNode.Node(newNode), {moveCarret: true}); //isDirty = true; sandbox.publish('contentChanged'); } @@ -239,8 +223,8 @@ return function(sandbox) { }, modifyCurrentNode: function(attr, value) { if(view.currentNode) { - view.currentNode.attr('wlxml-'+attr, value); - sandbox.publish('contentEdited'); + view.getNodeElement(view.currentNode).attr('wlxml-'+attr, value); + sandbox.publish('contentChanged'); } }, highlightNode: function(wlxmlNode) {