X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4bd7ae43a9d3cd78105f174d1f92c1bc92d35f02..5713cbab555401cab4cb69012bf1d5ec47153982:/src/editor/modules/documentCanvas/canvas/documentElement.js?ds=sidebyside diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index 4378e73..cd6b3d8 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -52,6 +52,13 @@ $.extend(DocumentElement.prototype, { dom: function() { return this.$element; }, + data: function() { + var dom = this.dom(), + args = Array.prototype.slice.call(arguments, 0); + if(args.length === 2 && args[1] === undefined) + return dom.removeData(args[0]); + return dom.data.apply(dom, arguments); + }, parent: function() { var parents = this.$element.parents('[document-node-element]'); if(parents.length) @@ -162,6 +169,9 @@ $.extend(DocumentNodeElement, { var element = this.fromHTMLElement(dom[0], canvas); + element.data('wlxmlNode', wlxmlNode); + wlxmlNode.setData('canvasElement', element); + element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()}); _.keys(wlxmlNode.getMetaAttributes()).forEach(function(key) { @@ -257,13 +267,6 @@ $.extend(DocumentNodeElement.prototype, { element2: parent.children()[myIdx + childrenLength-1 + (moveRightRange ? 1 : 0)] }; }, - data: function() { - var dom = this.dom(), - args = Array.prototype.slice.call(arguments, 0); - if(args.length === 2 && args[1] === undefined) - return dom.removeData(args[0]); - return dom.data.apply(dom, arguments); - }, toXML: function(level) { var node = $('<' + this.getWlxmlTag() + '>'); @@ -477,9 +480,12 @@ var DocumentTextElement = function(htmlElement, canvas) { $.extend(DocumentTextElement, { createDOM: function(wlxmlTextNode) { - return $('
') + var dom = $('
') .attr('document-text-element', '') - .text(wlxmlTextNode.getText() || utils.unicode.ZWS); + .text(wlxmlTextNode.getText() || utils.unicode.ZWS), + element = this.fromHTMLElement(dom[0], this); + element.data('wlxmlNode', wlxmlTextNode); + return dom; }, create: function(wlxmlTextNode, canvas) {