diff --git a/.gitignore b/.gitignore index 4798962..4a270dd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,30 @@ reports/ coverage/ ._* bower_components/ + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +.idea + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + diff --git a/bower.json b/bower.json index 8471261..e7b20bd 100644 --- a/bower.json +++ b/bower.json @@ -1,10 +1,10 @@ { - "name": "medium-editor-tables", - "homepage": "http://yabwe.github.io/medium-editor/", + "name": "medium-editor-tables-fork", + "homepage": "https://github.com/lexgorbunov/medium-editor-tables-fork", "authors": [ - "Davi Ferreira " + "Alexanger Gorbunov " ], - "description": "MediumEditor extension to allow tables.", + "description": "MediumEditor extension to allow tables (fork).", "main": [ "dist/js/medium-editor-tables.js", "dist/css/medium-editor-tables.css" @@ -31,10 +31,13 @@ "package.json", "src/js", "README.md", - "CHANGES.md" + "CHANGES.md", + "test", + "tests" ], "dependencies": { "medium-editor": "^5.5.1", "normalize.css": "^3.0.3" - } + }, + "version": "0.5.3" } diff --git a/dist/js/medium-editor-tables.js b/dist/js/medium-editor-tables.js index 0f50fff..527e55b 100644 --- a/dist/js/medium-editor-tables.js +++ b/dist/js/medium-editor-tables.js @@ -323,18 +323,20 @@ Builder.prototype = { addRow: function (before, e) { e.preventDefault(); e.stopPropagation(); - var tbody = this._range.parentNode.parentNode, + var currentTr = this._range.parentNode, + tbody = currentTr.parentNode, tr = this._doc.createElement('tr'), td; - for (var i = 0; i < this._range.parentNode.childNodes.length; i++) { + + for (var i = 0; i < currentTr.querySelectorAll('td').length; i++) { td = this._doc.createElement('td'); td.appendChild(this._doc.createElement('br')); tr.appendChild(td); } - if (before !== true && this._range.parentNode.nextSibling) { - tbody.insertBefore(tr, this._range.parentNode.nextSibling); + if (before !== true && currentTr.nextSibling) { + tbody.insertBefore(tr, currentTr.nextSibling); } else if (before === true) { - tbody.insertBefore(tr, this._range.parentNode); + tbody.insertBefore(tr, currentTr); } else { tbody.appendChild(tr); } @@ -351,19 +353,21 @@ Builder.prototype = { addColumn: function (before, e) { e.preventDefault(); e.stopPropagation(); - var cell = Array.prototype.indexOf.call(this._range.parentNode.childNodes, this._range), - tbody = this._range.parentNode.parentNode, - td; + var currentTr = this._range.parentNode, + cell = Array.prototype.indexOf.call(currentTr.querySelectorAll('td'), this._range), + tbody = currentTr.parentNode, + td, + tableTrs = tbody.querySelectorAll('tr'); - for (var i = 0; i < tbody.childNodes.length; i++) { + for (var i = 0; i < tableTrs.length; i++) { td = this._doc.createElement('td'); td.appendChild(this._doc.createElement('br')); if (before === true) { - tbody.childNodes[i].insertBefore(td, tbody.childNodes[i].childNodes[cell]); - } else if (this._range.parentNode.parentNode.childNodes[i].childNodes[cell].nextSibling) { - tbody.childNodes[i].insertBefore(td, tbody.childNodes[i].childNodes[cell].nextSibling); + tableTrs[i].insertBefore(td, tableTrs[i].querySelectorAll('td')[cell]); + } else if (currentTr.parentNode.querySelectorAll('tr')[i].querySelectorAll('td')[cell].nextSibling) { + tableTrs[i].insertBefore(td, tableTrs[i].querySelectorAll('td')[cell].nextSibling); } else { - tbody.childNodes[i].appendChild(td); + tableTrs[i].appendChild(td); } } @@ -373,12 +377,13 @@ Builder.prototype = { removeColumn: function (e) { e.preventDefault(); e.stopPropagation(); - var cell = Array.prototype.indexOf.call(this._range.parentNode.childNodes, this._range), + var cell = Array.prototype.indexOf.call(this._range.parentNode.querySelectorAll('td'), this._range), tbody = this._range.parentNode.parentNode, - rows = tbody.childNodes.length; + currentTrs = tbody.querySelectorAll('tr'), + rows = currentTrs.length; for (var i = 0; i < rows; i++) { - tbody.childNodes[i].removeChild(tbody.childNodes[i].childNodes[cell]); + currentTrs[i].removeChild(currentTrs[i].querySelectorAll('td')[cell]); } this.options.onClick(0, 0); }, @@ -386,7 +391,7 @@ Builder.prototype = { removeTable: function (e) { e.preventDefault(); e.stopPropagation(); - var cell = Array.prototype.indexOf.call(this._range.parentNode.childNodes, this._range), + var cell = Array.prototype.indexOf.call(this._range.parentNode.querySelectorAll('td'), this._range), table = this._range.parentNode.parentNode.parentNode; table.parentNode.removeChild(table); diff --git a/dist/js/medium-editor-tables.min.js b/dist/js/medium-editor-tables.min.js index bd01eab..43866a2 100644 --- a/dist/js/medium-editor-tables.min.js +++ b/dist/js/medium-editor-tables.min.js @@ -1 +1 @@ -!function(a,b){"use strict";var c="object"==typeof module&&process&&process.versions&&process.versions.electron;c||"object"!=typeof module?"function"==typeof define&&define.amd?define(function(){return b}):a.MediumEditorTable=b:module.exports=b}(this,function(){"use strict";function a(a){return a.getSelection?a.getSelection().toString():a.selection&&"Control"!==a.selection.type?a.selection.createRange().text:""}function b(a){var b=a.getSelection().anchorNode,c=b&&3===b.nodeType?b.parentNode:b;return c}function c(a,b,c){if(void 0!==a.getSelection&&b){var d=a.createRange(),e=a.getSelection();c?d.setStartBefore(b):d.setStartAfter(b),d.collapse(!0),e.removeAllRanges(),e.addRange(d)}}function d(a,b){if(!a)return!1;for(var c=a.parentNode,d=c.tagName.toLowerCase();"body"!==d;){if(d===b)return!0;if(c=c.parentNode,!c||!c.tagName)return!1;d=c.tagName.toLowerCase()}return!1}function e(a,b){var c=!(!a||!a.tagName)&&a.tagName.toLowerCase();if(!c)return!1;for(;c&&"body"!==c;){if(c===b)return a;a=a.parentNode,c=!(!a||!a.tagName)&&a.tagName.toLowerCase()}}function f(a,b,c,d){return this.init(a,b,c,d)}function g(a){return this.init(a)}function h(a){return this.init(a)}f.prototype={init:function(a,b,c,d){return this._root=a,this._callback=b,this.rows=c,this.columns=d,this._render()},setCurrentCell:function(a){this._currentCell=a},markCells:function(){[].forEach.call(this._cellsElements,function(a){var b={column:parseInt(a.dataset.column,10),row:parseInt(a.dataset.row,10)},c=this._currentCell&&b.row<=this._currentCell.row&&b.column<=this._currentCell.column;c===!0?a.classList.add("active"):a.classList.remove("active")}.bind(this))},_generateCells:function(){var a=-1;this._cells=[];for(var b=0;b';return c+=this._cellsHTML(),c+=""},_cellsHTML:function(){var a="";return this._generateCells(),this._cells.map(function(b){a+='',a+=""}),a},_render:function(){this._root.innerHTML=this._html(),this._cellsElements=this._root.querySelectorAll("a"),this._bindEvents()},_bindEvents:function(){[].forEach.call(this._cellsElements,function(a){this._onMouseEnter(a),this._onClick(a)}.bind(this))},_onMouseEnter:function(a){var b,c=this;a.addEventListener("mouseenter",function(){clearTimeout(b);var a=this.dataset;b=setTimeout(function(){c._currentCell={column:parseInt(a.column,10),row:parseInt(a.row,10)},c.markCells()},50)})},_onClick:function(a){var b=this;a.addEventListener("click",function(a){a.preventDefault(),b._callback(this.dataset.row,this.dataset.column)})}},g.prototype={init:function(a){this.options=a,this._doc=a.ownerDocument||document,this._root=this._doc.createElement("div"),this._root.className="medium-editor-table-builder",this.grid=new f(this._root,this.options.onClick,this.options.rows,this.options.columns),this._range=null,this._toolbar=this._doc.createElement("div"),this._toolbar.className="medium-editor-table-builder-toolbar";var b=this._doc.createElement("span");b.innerHTML="Row:",this._toolbar.appendChild(b);var c=this._doc.createElement("button");c.title="Add row before",c.innerHTML='',c.onclick=this.addRow.bind(this,!0),this._toolbar.appendChild(c);var d=this._doc.createElement("button");d.title="Add row after",d.innerHTML='',d.onclick=this.addRow.bind(this,!1),this._toolbar.appendChild(d);var e=this._doc.createElement("button");e.title="Remove row",e.innerHTML='',e.onclick=this.removeRow.bind(this),this._toolbar.appendChild(e);var g=this._doc.createElement("span");g.innerHTML="Column:",this._toolbar.appendChild(g);var h=this._doc.createElement("button");h.title="Add column before",h.innerHTML='',h.onclick=this.addColumn.bind(this,!0),this._toolbar.appendChild(h);var i=this._doc.createElement("button");i.title="Add column after",i.innerHTML='',i.onclick=this.addColumn.bind(this,!1),this._toolbar.appendChild(i);var j=this._doc.createElement("button");j.title="Remove column",j.innerHTML='',j.onclick=this.removeColumn.bind(this),this._toolbar.appendChild(j);var k=this._doc.createElement("button");k.title="Remove table",k.innerHTML='',k.onclick=this.removeTable.bind(this),this._toolbar.appendChild(k);var l=this._root.childNodes[0];this._root.insertBefore(this._toolbar,l)},getElement:function(){return this._root},hide:function(){this._root.style.display="",this.grid.setCurrentCell({column:-1,row:-1}),this.grid.markCells()},show:function(a){this._root.style.display="block",this._root.style.left=a+"px"},setEditor:function(a){this._range=a,this._toolbar.style.display="block"},setBuilder:function(){this._range=null,this._toolbar.style.display="none";for(var a=this._doc.getElementsByClassName("medium-editor-table-builder-grid"),b=0;b'+d+"",{cleanAttrs:[],cleanTags:[]});var e=this._doc.getElementById("medium-editor-table");e.removeAttribute("id"),c(this._doc,e.querySelector("td"),!0),this._editor.checkSelection()},_html:function(b,c){var d,e,f="",g=a(this._doc);for(d=0;d<=b;d++){for(f+="",e=0;e<=c;e++)f+=""+(0===d&&0===e?g:"
")+"";f+=""}return f},_bindTabBehavior:function(){var a=this;[].forEach.call(this._editor.elements,function(b){b.addEventListener("keydown",function(b){a._onKeyDown(b)})})},_onKeyDown:function(a){var f,g=b(this._doc);a.which===i&&d(g,"table")&&(a.preventDefault(),a.stopPropagation(),f=this._getTableElements(g),a.shiftKey?this._tabBackwards(g.previousSibling,f.row):(this._isLastCell(g,f.row,f.root)&&this._insertRow(e(g,"tbody"),f.row.cells.length),c(this._doc,g)))},_getTableElements:function(a){return{cell:e(a,"td"),row:e(a,"tr"),root:e(a,"table")}},_tabBackwards:function(a,b){a=a||this._getPreviousRowLastCell(b),c(this._doc,a,!0)},_insertRow:function(a,b){var c,d=document.createElement("tr"),e="";for(c=0;c
";d.innerHTML=e,a.appendChild(d)},_isLastCell:function(a,b,c){return b.cells.length-1===a.cellIndex&&c.rows.length-1===b.rowIndex},_getPreviousRowLastCell:function(a){if(a=a.previousSibling)return a.cells[a.cells.length-1]}};var j,k=16,l=1;return j=MediumEditor.extensions.form.extend({name:"table",aria:"create table",action:"table",contentDefault:"TBL",contentFA:'',handleClick:function(a){a.preventDefault(),a.stopPropagation(),this[this.isActive()===!0?"hide":"show"]()},hide:function(){this.setInactive(),this.builder.hide()},show:function(){this.setActive();var a=MediumEditor.selection.getSelectionRange(this.document);"td"===a.startContainer.nodeName.toLowerCase()||"td"===a.endContainer.nodeName.toLowerCase()||MediumEditor.util.getClosestTag(MediumEditor.selection.getSelectedParentElement(a),"td")?this.builder.setEditor(MediumEditor.selection.getSelectedParentElement(a)):this.builder.setBuilder(),this.builder.show(this.button.offsetLeft)},getForm:function(){return this.builder||(this.builder=new g({onClick:function(a,b){(a>0||b>0)&&this.table.insert(a,b),this.hide()}.bind(this),ownerDocument:this.document,rows:this.rows||10,columns:this.columns||10}),this.table=new h(this.base)),this.builder.getElement()}})}()); \ No newline at end of file +!function(a,b){"use strict";var c="object"==typeof module&&process&&process.versions&&process.versions.electron;c||"object"!=typeof module?"function"==typeof define&&define.amd?define(function(){return b}):a.MediumEditorTable=b:module.exports=b}(this,function(){"use strict";function a(a){return a.getSelection?a.getSelection().toString():a.selection&&"Control"!==a.selection.type?a.selection.createRange().text:""}function b(a){var b=a.getSelection().anchorNode,c=b&&3===b.nodeType?b.parentNode:b;return c}function c(a,b,c){if(void 0!==a.getSelection&&b){var d=a.createRange(),e=a.getSelection();c?d.setStartBefore(b):d.setStartAfter(b),d.collapse(!0),e.removeAllRanges(),e.addRange(d)}}function d(a,b){if(!a)return!1;for(var c=a.parentNode,d=c.tagName.toLowerCase();"body"!==d;){if(d===b)return!0;if(c=c.parentNode,!c||!c.tagName)return!1;d=c.tagName.toLowerCase()}return!1}function e(a,b){var c=!(!a||!a.tagName)&&a.tagName.toLowerCase();if(!c)return!1;for(;c&&"body"!==c;){if(c===b)return a;a=a.parentNode,c=!(!a||!a.tagName)&&a.tagName.toLowerCase()}}function f(a,b,c,d){return this.init(a,b,c,d)}function g(a){return this.init(a)}function h(a){return this.init(a)}f.prototype={init:function(a,b,c,d){return this._root=a,this._callback=b,this.rows=c,this.columns=d,this._render()},setCurrentCell:function(a){this._currentCell=a},markCells:function(){[].forEach.call(this._cellsElements,function(a){var b={column:parseInt(a.dataset.column,10),row:parseInt(a.dataset.row,10)},c=this._currentCell&&b.row<=this._currentCell.row&&b.column<=this._currentCell.column;c===!0?a.classList.add("active"):a.classList.remove("active")}.bind(this))},_generateCells:function(){var a=-1;this._cells=[];for(var b=0;b';return c+=this._cellsHTML(),c+=""},_cellsHTML:function(){var a="";return this._generateCells(),this._cells.map(function(b){a+='',a+=""}),a},_render:function(){this._root.innerHTML=this._html(),this._cellsElements=this._root.querySelectorAll("a"),this._bindEvents()},_bindEvents:function(){[].forEach.call(this._cellsElements,function(a){this._onMouseEnter(a),this._onClick(a)}.bind(this))},_onMouseEnter:function(a){var b,c=this;a.addEventListener("mouseenter",function(){clearTimeout(b);var a=this.dataset;b=setTimeout(function(){c._currentCell={column:parseInt(a.column,10),row:parseInt(a.row,10)},c.markCells()},50)})},_onClick:function(a){var b=this;a.addEventListener("click",function(a){a.preventDefault(),b._callback(this.dataset.row,this.dataset.column)})}},g.prototype={init:function(a){this.options=a,this._doc=a.ownerDocument||document,this._root=this._doc.createElement("div"),this._root.className="medium-editor-table-builder",this.grid=new f(this._root,this.options.onClick,this.options.rows,this.options.columns),this._range=null,this._toolbar=this._doc.createElement("div"),this._toolbar.className="medium-editor-table-builder-toolbar";var b=this._doc.createElement("span");b.innerHTML="Row:",this._toolbar.appendChild(b);var c=this._doc.createElement("button");c.title="Add row before",c.innerHTML='',c.onclick=this.addRow.bind(this,!0),this._toolbar.appendChild(c);var d=this._doc.createElement("button");d.title="Add row after",d.innerHTML='',d.onclick=this.addRow.bind(this,!1),this._toolbar.appendChild(d);var e=this._doc.createElement("button");e.title="Remove row",e.innerHTML='',e.onclick=this.removeRow.bind(this),this._toolbar.appendChild(e);var g=this._doc.createElement("span");g.innerHTML="Column:",this._toolbar.appendChild(g);var h=this._doc.createElement("button");h.title="Add column before",h.innerHTML='',h.onclick=this.addColumn.bind(this,!0),this._toolbar.appendChild(h);var i=this._doc.createElement("button");i.title="Add column after",i.innerHTML='',i.onclick=this.addColumn.bind(this,!1),this._toolbar.appendChild(i);var j=this._doc.createElement("button");j.title="Remove column",j.innerHTML='',j.onclick=this.removeColumn.bind(this),this._toolbar.appendChild(j);var k=this._doc.createElement("button");k.title="Remove table",k.innerHTML='',k.onclick=this.removeTable.bind(this),this._toolbar.appendChild(k);var l=this._root.childNodes[0];this._root.insertBefore(this._toolbar,l)},getElement:function(){return this._root},hide:function(){this._root.style.display="",this.grid.setCurrentCell({column:-1,row:-1}),this.grid.markCells()},show:function(a){this._root.style.display="block",this._root.style.left=a+"px"},setEditor:function(a){this._range=a,this._toolbar.style.display="block"},setBuilder:function(){this._range=null,this._toolbar.style.display="none";for(var a=this._doc.getElementsByClassName("medium-editor-table-builder-grid"),b=0;b'+d+"",{cleanAttrs:[],cleanTags:[]});var e=this._doc.getElementById("medium-editor-table");e.removeAttribute("id"),c(this._doc,e.querySelector("td"),!0),this._editor.checkSelection()},_html:function(b,c){var d,e,f="",g=a(this._doc);for(d=0;d<=b;d++){for(f+="",e=0;e<=c;e++)f+=""+(0===d&&0===e?g:"
")+"";f+=""}return f},_bindTabBehavior:function(){var a=this;[].forEach.call(this._editor.elements,function(b){b.addEventListener("keydown",function(b){a._onKeyDown(b)})})},_onKeyDown:function(a){var f,g=b(this._doc);a.which===i&&d(g,"table")&&(a.preventDefault(),a.stopPropagation(),f=this._getTableElements(g),a.shiftKey?this._tabBackwards(g.previousSibling,f.row):(this._isLastCell(g,f.row,f.root)&&this._insertRow(e(g,"tbody"),f.row.cells.length),c(this._doc,g)))},_getTableElements:function(a){return{cell:e(a,"td"),row:e(a,"tr"),root:e(a,"table")}},_tabBackwards:function(a,b){a=a||this._getPreviousRowLastCell(b),c(this._doc,a,!0)},_insertRow:function(a,b){var c,d=document.createElement("tr"),e="";for(c=0;c
";d.innerHTML=e,a.appendChild(d)},_isLastCell:function(a,b,c){return b.cells.length-1===a.cellIndex&&c.rows.length-1===b.rowIndex},_getPreviousRowLastCell:function(a){if(a=a.previousSibling)return a.cells[a.cells.length-1]}};var j,k=16,l=1;return j=MediumEditor.extensions.form.extend({name:"table",aria:"create table",action:"table",contentDefault:"TBL",contentFA:'',handleClick:function(a){a.preventDefault(),a.stopPropagation(),this[this.isActive()===!0?"hide":"show"]()},hide:function(){this.setInactive(),this.builder.hide()},show:function(){this.setActive();var a=MediumEditor.selection.getSelectionRange(this.document);"td"===a.startContainer.nodeName.toLowerCase()||"td"===a.endContainer.nodeName.toLowerCase()||MediumEditor.util.getClosestTag(MediumEditor.selection.getSelectedParentElement(a),"td")?this.builder.setEditor(MediumEditor.selection.getSelectedParentElement(a)):this.builder.setBuilder(),this.builder.show(this.button.offsetLeft)},getForm:function(){return this.builder||(this.builder=new g({onClick:function(a,b){(a>0||b>0)&&this.table.insert(a,b),this.hide()}.bind(this),ownerDocument:this.document,rows:this.rows||10,columns:this.columns||10}),this.table=new h(this.base)),this.builder.getElement()}})}()); \ No newline at end of file diff --git a/src/js/builder.js b/src/js/builder.js index e727c05..3f7fc86 100644 --- a/src/js/builder.js +++ b/src/js/builder.js @@ -104,18 +104,20 @@ Builder.prototype = { addRow: function (before, e) { e.preventDefault(); e.stopPropagation(); - var tbody = this._range.parentNode.parentNode, + var currentTr = this._range.parentNode, + tbody = currentTr.parentNode, tr = this._doc.createElement('tr'), td; - for (var i = 0; i < this._range.parentNode.childNodes.length; i++) { + + for (var i = 0; i < currentTr.querySelectorAll('td').length; i++) { td = this._doc.createElement('td'); td.appendChild(this._doc.createElement('br')); tr.appendChild(td); } - if (before !== true && this._range.parentNode.nextSibling) { - tbody.insertBefore(tr, this._range.parentNode.nextSibling); + if (before !== true && currentTr.nextSibling) { + tbody.insertBefore(tr, currentTr.nextSibling); } else if (before === true) { - tbody.insertBefore(tr, this._range.parentNode); + tbody.insertBefore(tr, currentTr); } else { tbody.appendChild(tr); } @@ -132,19 +134,21 @@ Builder.prototype = { addColumn: function (before, e) { e.preventDefault(); e.stopPropagation(); - var cell = Array.prototype.indexOf.call(this._range.parentNode.childNodes, this._range), - tbody = this._range.parentNode.parentNode, - td; + var currentTr = this._range.parentNode, + cell = Array.prototype.indexOf.call(currentTr.querySelectorAll('td'), this._range), + tbody = currentTr.parentNode, + td, + tableTrs = tbody.querySelectorAll('tr'); - for (var i = 0; i < tbody.childNodes.length; i++) { + for (var i = 0; i < tableTrs.length; i++) { td = this._doc.createElement('td'); td.appendChild(this._doc.createElement('br')); if (before === true) { - tbody.childNodes[i].insertBefore(td, tbody.childNodes[i].childNodes[cell]); - } else if (this._range.parentNode.parentNode.childNodes[i].childNodes[cell].nextSibling) { - tbody.childNodes[i].insertBefore(td, tbody.childNodes[i].childNodes[cell].nextSibling); + tableTrs[i].insertBefore(td, tableTrs[i].querySelectorAll('td')[cell]); + } else if (currentTr.parentNode.querySelectorAll('tr')[i].querySelectorAll('td')[cell].nextSibling) { + tableTrs[i].insertBefore(td, tableTrs[i].querySelectorAll('td')[cell].nextSibling); } else { - tbody.childNodes[i].appendChild(td); + tableTrs[i].appendChild(td); } } @@ -154,12 +158,13 @@ Builder.prototype = { removeColumn: function (e) { e.preventDefault(); e.stopPropagation(); - var cell = Array.prototype.indexOf.call(this._range.parentNode.childNodes, this._range), + var cell = Array.prototype.indexOf.call(this._range.parentNode.querySelectorAll('td'), this._range), tbody = this._range.parentNode.parentNode, - rows = tbody.childNodes.length; + currentTrs = tbody.querySelectorAll('tr'), + rows = currentTrs.length; for (var i = 0; i < rows; i++) { - tbody.childNodes[i].removeChild(tbody.childNodes[i].childNodes[cell]); + currentTrs[i].removeChild(currentTrs[i].querySelectorAll('td')[cell]); } this.options.onClick(0, 0); }, @@ -167,7 +172,7 @@ Builder.prototype = { removeTable: function (e) { e.preventDefault(); e.stopPropagation(); - var cell = Array.prototype.indexOf.call(this._range.parentNode.childNodes, this._range), + var cell = Array.prototype.indexOf.call(this._range.parentNode.querySelectorAll('td'), this._range), table = this._range.parentNode.parentNode.parentNode; table.parentNode.removeChild(table);