X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/5d2695bd243591aa1697733184d07cdb3e67cf74..88afe908cdc2cd584c551730a98d1b312df48958:/src/editor/modules/documentCanvas/canvas/documentElement.js diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index 859a80b..a1965cd 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -95,6 +95,8 @@ $.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); }; @@ -104,7 +106,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); @@ -146,6 +148,13 @@ $.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)); + }, handle: function(event) { var method = 'on' + event.type[0].toUpperCase() + event.type.substr(1), target; @@ -232,6 +241,9 @@ $.extend(DocumentNodeElement.prototype, { // }) this.dom.css('display', what); this._container().css('display', what); + }, + children: function() { + return []; } }); @@ -293,7 +305,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('