X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/b381ca66b7a9766aa4f408f6d0add75d486ef3d5..7b4405539ac7c11a11b5259b4f968e1289f0b2a7:/modules/documentCanvas/canvas.js?ds=sidebyside diff --git a/modules/documentCanvas/canvas.js b/modules/documentCanvas/canvas.js index 848dc48..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() { @@ -151,7 +151,7 @@ Canvas.prototype.createList = function(options) { nodesToWrap.push($node); } if(node.isSameNode(element2.get(0))) - return; + return false; }); var list = this._createNode('div', 'list-items'); @@ -161,9 +161,28 @@ Canvas.prototype.createList = function(options) { 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; }