X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/1dcfdcafd9fd0ff3af5dc39619a3a953f4377a11..1d25d2c941f5ffdc6e0824724db9a34960dc5450:/modules/documentCanvas/canvasManager.js?ds=inline diff --git a/modules/documentCanvas/canvasManager.js b/modules/documentCanvas/canvasManager.js index 95e1d91..235c97b 100644 --- a/modules/documentCanvas/canvasManager.js +++ b/modules/documentCanvas/canvasManager.js @@ -228,20 +228,37 @@ Manager.prototype.onBackspaceKey = function(e) { } }; -Manager.prototype.command = function(command, meta) { +Manager.prototype.toggleList = function(toggle) { var selection = window.getSelection(), node1 = $(selection.anchorNode).parent()[0], node2 = $(selection.focusNode).parent()[0], element1 = this.canvas.getDocumentElement(node1), element2 = this.canvas.getDocumentElement(node2); - if(command === 'createList') { + if(toggle) { this.canvas.list.create({element1: element1, element2: element2}); - } else if(command === 'unwrap-node') { + } else { + if(this.canvas.list.areItemsOfTheSameList({element1: element1, element2: element2})) { + this.canvas.list.extractItems({element1: element1, element2: element2, merge: false}); + } + } +}; + +Manager.prototype.command = function(command, meta) { + var selection = window.getSelection(), + node1 = $(selection.anchorNode).parent()[0], + node2 = $(selection.focusNode).parent()[0], + element1 = this.canvas.getDocumentElement(node1), + element2 = this.canvas.getDocumentElement(node2); + if(command === 'unwrap-node') { // this.canvas.nodeUnwrap({node: canvasNode.create(pos.parentNode)}); // this.sandbox.publish('contentChanged'); if(this.canvas.list.areItemsOfTheSameList({element1: element1, element2: element2})) { this.canvas.list.extractItems({element1: element1, element2: element2}); } + } else if(command === 'wrap-node') { + if(this.canvas.list.areItemsOfTheSameList({element1: element1, element2: element2})) { + this.canvas.list.create({element1: element1, element2: element2}); + } } };