X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/600f0113753edfca58e20936e4701a096d2b6d04..75e12ca1b25cdcdb457ee2a159a0bf4287841c63:/src/editor/modules/documentCanvas/canvas/documentElement.js?ds=inline diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index adeaafe..d6d60d3 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -43,6 +43,7 @@ $.extend(DocumentElement.prototype, { this.state[key] = changes[key] = toUpdate[key]; } }.bind(this)); + // console.log(changes); if(_.isFunction(this.onStateChange)) { this.onStateChange(changes); if(_.isBoolean(changes.active)) { @@ -95,6 +96,7 @@ $.extend(DocumentElement.prototype, { var DocumentNodeElement = function(wlxmlNode, canvas) { DocumentElement.call(this, wlxmlNode, canvas); this.containers = []; + this.elementsRegister = canvas.createElementsRegister(); this.contextMenuActions = []; this.init(this.dom); }; @@ -105,7 +107,7 @@ var manipulate = function(e, params, action) { if(params instanceof DocumentElement) { element = params; } else { - element = e.canvas.createElement(params); + element = e.createElement(params); } if(element.dom) { e.dom[action](element.dom); @@ -147,6 +149,10 @@ $.extend(DocumentNodeElement.prototype, { this.containers.splice(idx, 1); } }, + createElement: function(wlxmlNode) { + var parent = this.wlxmlNode.parent() ? utils.getElementForNode(this.wlxmlNode.parent()) : null; + return this.canvas.createElement(wlxmlNode, this.elementsRegister, !parent) || parent.createElement(wlxmlNode); + }, addToContextMenu: function(actionFqName) { this.contextMenuActions.push(this.canvas.createAction(actionFqName)); }, @@ -236,6 +242,9 @@ $.extend(DocumentNodeElement.prototype, { // }) this.dom.css('display', what); this._container().css('display', what); + }, + children: function() { + return []; } }); @@ -270,7 +279,7 @@ $.extend(DocumentTextElement.prototype, { if(text === '') { text = utils.unicode.ZWS; } - if(text !== this.getText()) { + if(text !== this.dom.contents()[0].data) { this.dom.contents()[0].data = text; } }, @@ -297,7 +306,7 @@ $.extend(DocumentTextElement.prototype, { if(params instanceof DocumentNodeElement) { element = params; } else { - element = this.canvas.createElement(params); + element = this.parent().createElement(params); } if(element.dom) { this.dom.wrap('
'); @@ -315,7 +324,7 @@ $.extend(DocumentTextElement.prototype, { if(params instanceof DocumentNodeElement) { element = params; } else { - element = this.canvas.createElement(params); + element = this.createElement(params); } if(element.dom) { this.dom.wrap('
');