X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/52f3927cfc1af1e9eaa469b73a33c9575ef710d8..7b4405539ac7c11a11b5259b4f968e1289f0b2a7:/modules/documentCanvas/canvas.js?ds=sidebyside diff --git a/modules/documentCanvas/canvas.js b/modules/documentCanvas/canvas.js index 5de60f4..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() { @@ -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; }