X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7234259fa025569d6a7682aa6c74fdcfb3ca7e17..7b4405539ac7c11a11b5259b4f968e1289f0b2a7:/modules/documentCanvas/canvas.js diff --git a/modules/documentCanvas/canvas.js b/modules/documentCanvas/canvas.js index eb0fd0b..80d3915 100644 --- a/modules/documentCanvas/canvas.js +++ b/modules/documentCanvas/canvas.js @@ -15,8 +15,8 @@ var Canvas = function(xml) { } Canvas.prototype.setXML = function(xml) { - this.xml = xml; - this.content.html(transformations.fromXML.getHTMLTree(xml)); + this.xml = $.trim(xml); + this.content.html(transformations.fromXML.getHTMLTree(this.xml)); } Canvas.prototype.toXML = function() { @@ -147,23 +147,42 @@ Canvas.prototype.createList = function(options) { else { $node = $(node); } - $node.attr('wlxml-class', 'list.item'); + $node.attr('wlxml-class', 'item'); nodesToWrap.push($node); } if(node.isSameNode(element2.get(0))) - return; + return false; }); - var list = this._createNode('div', 'list'); + var list = this._createNode('div', 'list-items'); element1.before(list); nodesToWrap.forEach(function(node) { node.remove(); list.append(node); }); +} + +Canvas.prototype.removeList = function(options) { + var pointerElement = $(this.content.find('#' + options.pointer.id)); + var listElement = options.pointer.klass === 'list-items' ? pointerElement : + pointerElement.parent('[wlxml-class="list-items"][wlxml-tag]'); + listElement.find('[wlxml-class=item]').each(function() { + $(this).attr('wlxml-class', ''); + });; + listElement.children().unwrap(); - +} + +Canvas.prototype.insideList = function(options) { + if(options.pointer) { + if(options.pointer.klass === 'list-items' || options.pointer.klass === 'item') + return true; + var pointerElement = $(this.content.find('#' + options.pointer.id)); + return pointerElement.parents('list-items').length > 0; + } + return false; }