X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/1f6c4e3196778b8d0e91988c8c56966f9bb2ef8f..cc4f5cb5ab7df9decf14fbbcbe2736a9d76ef294:/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 9fe3641..7f448ba 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -2,9 +2,8 @@ define([ 'libs/jquery', 'libs/underscore', 'modules/documentCanvas/canvas/utils', -'modules/documentCanvas/canvas/widgets', 'modules/documentCanvas/canvas/wlxmlManagers' -], function($, _, utils, widgets, wlxmlManagers) { +], function($, _, utils, wlxmlManagers) { 'use strict'; /* global Node:false, document:false */ @@ -172,7 +171,7 @@ $.extend(DocumentNodeElement, { element.setWlxml({tag: wlxmlNode.getTagName(), klass: wlxmlNode.getClass()}); wlxmlNode.contents().forEach(function(node) { - container.append(DocumentElement.create(node).dom()); + container.append(DocumentElement.create(node, canvas).dom()); }.bind(this)); return dom; @@ -205,9 +204,6 @@ $.extend(DocumentNodeElement.prototype, { return this; }, append: function(params) { - if(params.tag !== 'span') { - this.data('orig-end', undefined); - } return manipulate(this, params, 'append'); }, prepend: function(params) { @@ -229,19 +225,11 @@ $.extend(DocumentNodeElement.prototype, { var elementContent = this._container().contents(); var element = this; - elementContent.each(function(idx) { + elementContent.each(function() { var childElement = DocumentElement.fromHTMLElement(this, element.canvas); if(childElement === undefined) { return true; } - if(idx === 0 && elementContent.length > 1 && elementContent[1].nodeType === Node.ELEMENT_NODE && (childElement instanceof DocumentTextElement) && $.trim($(this).text()) === '') { - return true; - } - if(idx > 0 && childElement instanceof DocumentTextElement) { - if(toret[toret.length-1] instanceof DocumentNodeElement && $.trim($(this).text()) === '') { - return true; - } - } toret.push(childElement); }); return toret; @@ -339,17 +327,17 @@ var DocumentTextElement = function(htmlElement, canvas) { }; $.extend(DocumentTextElement, { - createDOM: function(wlxmlTextNode) { + createDOM: function(wlxmlTextNode, canvas) { var dom = $('
') .attr('document-text-element', '') .text(wlxmlTextNode.getText() || utils.unicode.ZWS), - element = this.fromHTMLElement(dom[0], this); + element = this.fromHTMLElement(dom[0], canvas); element.data('wlxmlNode', wlxmlTextNode); return dom; }, create: function(wlxmlTextNode, canvas) { - return this.fromHTMLElement(this.createDOM(wlxmlTextNode)[0]); + return this.fromHTMLElement(this.createDOM(wlxmlTextNode, canvas)[0], canvas); }, fromHTMLElement: function(htmlElement, canvas) {