X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/f7c97ef38dc00ec9b5358ae0bf959a5e6f99271c..e816ae7584e8b11a1e24efb2f743ac744d80485b:/modules/documentCanvas/canvas.js?ds=inline
diff --git a/modules/documentCanvas/canvas.js b/modules/documentCanvas/canvas.js
index 9ae3a53..be5323a 100644
--- a/modules/documentCanvas/canvas.js
+++ b/modules/documentCanvas/canvas.js
@@ -160,8 +160,20 @@ Canvas.prototype.listCreate = function(options) {
return false;
});
- var list = canvasNode.create({tag: 'div', klass: 'list-items'}).dom; //this._createNode('div', 'list-items');
- element1.before(list);
+ var list = canvasNode.create({tag: 'div', klass: 'list-items' + (options.type === 'enum' ? '-enum' : '')}).dom; //this._createNode('div', 'list-items');
+
+ var parentNode = options.start.parent();
+
+ var toret;
+ if(parentNode && parentNode.isOfClass('list-items')) {
+ list.wrap('
');
+ toret = list.parent();
+ } else {
+ toret = list;
+ }
+
+
+ element1.before(toret);
nodesToWrap.forEach(function(node) {
node.remove();
@@ -172,11 +184,21 @@ Canvas.prototype.listCreate = function(options) {
Canvas.prototype.listRemove = function(options) {
var pointerElement = $(this.content.find('#' + options.pointer.getId()));
var listElement = options.pointer.getClass() === 'list-items' ? pointerElement :
- pointerElement.parent('[wlxml-class="list-items"][wlxml-tag]');
+ pointerElement.parents('[wlxml-class|="list-items"][wlxml-tag]');
- listElement.find('[wlxml-class=item]').each(function() {
- $(this).removeAttr('wlxml-class');
- });
+ var nested = false;
+ if(listElement.length > 1) {
+ listElement = $(listElement[0]);
+ nested = true;
+ }
+
+ if(nested) {
+ listElement.unwrap();
+ } else {
+ listElement.find('[wlxml-class=item]').each(function() {
+ $(this).removeAttr('wlxml-class');
+ });
+ }
listElement.children().unwrap();
};
@@ -190,10 +212,10 @@ Canvas.prototype.getPrecedingNode = function(options) {
Canvas.prototype.nodeInsideList = function(options) {
if(options.node) {
- if(options.node.getClass() === 'list-items' || options.node.getClass() === 'item')
+ if(options.node.isOfClass('list-items') || options.node.isOfClass('item'))
return true;
var pointerElement = $(this.content.find('#' + options.node.getId()));
- return pointerElement.parents('list-items, item').length > 0;
+ return pointerElement.parents('[wlxml-class=list-items], [wlxml-class=item]').length > 0;
}
return false;
};