X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/cca351c564d1bc9eabf6aca2bc13d41218443703..ed7551a2490c5a62e87cc316e614e5c211f57dbb:/modules/documentCanvas/canvasManager.js?ds=sidebyside diff --git a/modules/documentCanvas/canvasManager.js b/modules/documentCanvas/canvasManager.js index 7e34e29..5edd4be 100644 --- a/modules/documentCanvas/canvasManager.js +++ b/modules/documentCanvas/canvasManager.js @@ -159,6 +159,8 @@ Manager.prototype.selectFirstNode = function() { }; Manager.prototype.movecaretToNode = function(nodeElement, where) { + if(!nodeElement.length) + return; var range = document.createRange(); range.selectNodeContents(nodeElement[0]); @@ -184,7 +186,7 @@ Manager.prototype.onEnterKey = function(e) { if(pos.isAtEnd) { newNode = canvasNode.create({tag: pos.parentNode.attr('wlxml-tag'), klass: pos.parentNode.attr('wlxml-class')}); - this.canvas.nodeInsertAfter({node: newNode, after: canvas.getNodeById(pos.parentNode.attr('id'))}); + this.canvas.nodeInsertAfter({node: newNode, after: this.canvas.getNodeById(pos.parentNode.attr('id'))}); } else { newNode = this.canvas.nodeSplit({node: contextNode, textNodeIdx: pos.textNodeIndex, offset: pos.textNodeOffset}); } @@ -215,17 +217,17 @@ Manager.prototype.command = function(command, meta) { if(command === 'createList') { var node = canvasNode.create(pos.parentNode); - if(window.getSelection().getRangeAt().collapsed && this.canvas.nodeInsideList({node: node})) { + if(window.getSelection().getRangeAt(0).collapsed && this.canvas.nodeInsideList({node: node})) { this.canvas.listRemove({pointer: node}); this.selectNode(node, {movecaret: 'end'}); this.sandbox.publish('contentChanged'); } else { - if(!this.canvas.nodeInsideList({node: node})) { + //if(!this.canvas.nodeInsideList({node: node})) { this.canvas.listCreate({start: node, end: canvasNode.create(pos.focusNode), type: meta}); this.selectNode(node, {movecaret: 'end'}); this.sandbox.publish('contentChanged'); - } + //} } }