X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/cf8479951262da902ce027205a48ee420c63d6b8..6ec6461eaba0dfa50a065dac18eb7cc6455cb827:/modules/documentCanvas/canvasManager.js 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}); + } } };