Code coverage report for src/js/base/editing/Table.js

# all files / src/js/base/editing/ Table.js

90.14% Statements 256/284
78.48% Branches 124/158
95.83% Functions 23/24
90.11% Lines 255/283

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    5511×
    1×
    1×
    1×
    1×
    1×

    1×
    24×
    24×
    24×

    2×
    24×

    24×
    24×

    24×

    2×
    112×

    112×
    52×

    112×

    2×
    42×

    2×
    102×
    42×

    60×
    45×

    15×
    15×
    16×
    16×
    15×

    2×
    94×
    94×
    94×
    94×
    94×

    94×
    94×
    9×
    10×
    10×
    10×

    94×
    94×
    7×
    8×
    8×
    8×

    2×
    18×
    4×

    2×
    24×
    24×
    52×
    52×
    94×

    2×
    22×

    17×
    3×

    14×

    5×
    1×

    4×
    1×

    3×

    17×

    2×
    20×

    8×
    1×

    7×
    1×

    6×

    12×
    3×

    9×
    1×

    8×

    14×

    2×
    24×
    24×

    24×
    24×
    24×
    24×
    24×
    24×
    66×
    66×
    66×
    66×
    13×
    13×

    53×
    53×
    11×
    11×

    42×
    42×

    20×
    20×

    22×
    22×

    42×
    42×

    24×

    1×

    1×

    1×

    1×
    2×

    1×

    1×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    12×
    12×
    12×

    8×
    8×

    3×
    1×
    1×
    1×
    1×
    1×
    1×

    2×
    2×
    2×
    2×

    8×
    3×

    5×
    5×
    1×
    1×
    1×

    4×

    1×
    5×
    5×
    5×
    5×
    5×
    5×
    5×
    8×
    8×
    8×

    6×
    5×

    1×

    6×

    1×
    1×
    1×
    1×

    1×

    1×
    28×
    28×

    28×
    28×
    26×
    18×

    8×
    8×

    28×

    1×
    3×
    3×
    3×
    3×
    3×
    3×
    3×
    5×

    5×
    5×
    5×
    5×
    5×

    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×

    1×

    1×
    1×
    1×
    1×
    1×

    1×

    3×

    3×

    1×
    8×
    8×
    8×
    8×
    8×
    8×
    17×

    17×

    3×
    3×
    3×
    3×
    3×
    1×
    1×
    1×

    2×
    2×
    2×
    1×

    3×

    14×
    14×

    1×
    2×
    2×
    2×
    3×

    2×
    2×
    2×
    2×
    3×

    2×
    2×
    2×
    1×

    2×

    1×
    1×
    1×

    1×

    1×

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/src/js/base/editing/Table.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    var jquery_1 = require("jquery");
    var dom_1 = require("../core/dom");
    var range_1 = require("../core/range");
    var lists_1 = require("../core/lists");
    /**
     * @class Create a virtual table to create what actions to do in change.
     * @param {object} startPoint Cell selected to apply change.
     * @param {enum} where  Where change will be applied Row or Col. Use enum: TableResultAction.where
     * @param {enum} action Action to be applied. Use enum: TableResultAction.requestAction
     * @param {object} domTable Dom element of table to make changes.
     */
    var TableResultAction = function (startPoint, where, action, domTable) {
        var _startPoint = { 'colPos': 0, 'rowPos': 0 };
        var _virtualTable = [];
        var _actionCellList = [];
        /// ///////////////////////////////////////////
        // Private functions
        /// ///////////////////////////////////////////
        /**
         * Set the startPoint of action.
         */
        function setStartPoint() {
            Iif (!startPoint || !startPoint.tagName || (startPoint.tagName.toLowerCase() !== 'td' && startPoint.tagName.toLowerCase() !== 'th')) {
                console.error('Impossible to identify start Cell point.', startPoint);
                return;
            }
            _startPoint.colPos = startPoint.cellIndex;
            Iif (!startPoint.parentElement || !startPoint.parentElement.tagName || startPoint.parentElement.tagName.toLowerCase() !== 'tr') {
                console.error('Impossible to identify start Row point.', startPoint);
                return;
            }
            _startPoint.rowPos = startPoint.parentElement.rowIndex;
        }
        /**
         * Define virtual table position info object.
         *
         * @param {int} rowIndex Index position in line of virtual table.
         * @param {int} cellIndex Index position in column of virtual table.
         * @param {object} baseRow Row affected by this position.
         * @param {object} baseCell Cell affected by this position.
         * @param {bool} isSpan Inform if it is an span cell/row.
         */
        function setVirtualTablePosition(rowIndex, cellIndex, baseRow, baseCell, isRowSpan, isColSpan, isVirtualCell) {
            var objPosition = {
                'baseRow': baseRow,
                'baseCell': baseCell,
                'isRowSpan': isRowSpan,
                'isColSpan': isColSpan,
                'isVirtual': isVirtualCell
            };
            if (!_virtualTable[rowIndex]) {
                _virtualTable[rowIndex] = [];
            }
            _virtualTable[rowIndex][cellIndex] = objPosition;
        }
        /**
         * Create action cell object.
         *
         * @param {object} virtualTableCellObj Object of specific position on virtual table.
         * @param {enum} resultAction Action to be applied in that item.
         */
        function getActionCell(virtualTableCellObj, resultAction, virtualRowPosition, virtualColPosition) {
            return {
                'baseCell': virtualTableCellObj.baseCell,
                'action': resultAction,
                'virtualTable': {
                    'rowIndex': virtualRowPosition,
                    'cellIndex': virtualColPosition
                }
            };
        }
        /**
         * Recover free index of row to append Cell.
         *
         * @param {int} rowIndex Index of row to find free space.
         * @param {int} cellIndex Index of cell to find free space in table.
         */
        function recoverCellIndex(rowIndex, cellIndex) {
            if (!_virtualTable[rowIndex]) {
                return cellIndex;
            }
            if (!_virtualTable[rowIndex][cellIndex]) {
                return cellIndex;
            }
            var newCellIndex = cellIndex;
            while (_virtualTable[rowIndex][newCellIndex]) {
                newCellIndex++;
                if (!_virtualTable[rowIndex][newCellIndex]) {
                    return newCellIndex;
                }
            }
        }
        /**
         * Recover info about row and cell and add information to virtual table.
         *
         * @param {object} row Row to recover information.
         * @param {object} cell Cell to recover information.
         */
        function addCellInfoToVirtual(row, cell) {
            var cellIndex = recoverCellIndex(row.rowIndex, cell.cellIndex);
            var cellHasColspan = (cell.colSpan > 1);
            var cellHasRowspan = (cell.rowSpan > 1);
            var isThisSelectedCell = (row.rowIndex === _startPoint.rowPos && cell.cellIndex === _startPoint.colPos);
            setVirtualTablePosition(row.rowIndex, cellIndex, row, cell, cellHasRowspan, cellHasColspan, false);
            // Add span rows to virtual Table.
            var rowspanNumber = cell.attributes.rowSpan ? parseInt(cell.attributes.rowSpan.value, 10) : 0;
            if (rowspanNumber > 1) {
                for (var rp = 1; rp < rowspanNumber; rp++) {
                    var rowspanIndex = row.rowIndex + rp;
                    adjustStartPoint(rowspanIndex, cellIndex, cell, isThisSelectedCell);
                    setVirtualTablePosition(rowspanIndex, cellIndex, row, cell, true, cellHasColspan, true);
                }
            }
            // Add span cols to virtual table.
            var colspanNumber = cell.attributes.colSpan ? parseInt(cell.attributes.colSpan.value, 10) : 0;
            if (colspanNumber > 1) {
                for (var cp = 1; cp < colspanNumber; cp++) {
                    var cellspanIndex = recoverCellIndex(row.rowIndex, (cellIndex + cp));
                    adjustStartPoint(row.rowIndex, cellspanIndex, cell, isThisSelectedCell);
                    setVirtualTablePosition(row.rowIndex, cellspanIndex, row, cell, cellHasRowspan, true, true);
                }
            }
        }
        /**
         * Process validation and adjust of start point if needed
         *
         * @param {int} rowIndex
         * @param {int} cellIndex
         * @param {object} cell
         * @param {bool} isSelectedCell
         */
        function adjustStartPoint(rowIndex, cellIndex, cell, isSelectedCell) {
            if (rowIndex === _startPoint.rowPos && _startPoint.colPos >= cell.cellIndex && cell.cellIndex <= cellIndex && !isSelectedCell) {
                _startPoint.colPos++;
            }
        }
        /**
         * Create virtual table of cells with all cells, including span cells.
         */
        function createVirtualTable() {
            var rows = domTable.rows;
            for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) {
                var cells = rows[rowIndex].cells;
                for (var cellIndex = 0; cellIndex < cells.length; cellIndex++) {
                    addCellInfoToVirtual(rows[rowIndex], cells[cellIndex]);
                }
            }
        }
        /**
         * Get action to be applied on the cell.
         *
         * @param {object} cell virtual table cell to apply action
         */
        function getDeleteResultActionToCell(cell) {
            switch (where) {
                case TableResultAction.where.Column:
                    if (cell.isColSpan) {
                        return TableResultAction.resultAction.SubtractSpanCount;
                    }
                    break;
                case TableResultAction.where.Row:
                    if (!cell.isVirtual && cell.isRowSpan) {
                        return TableResultAction.resultAction.AddCell;
                    }
                    else if (cell.isRowSpan) {
                        return TableResultAction.resultAction.SubtractSpanCount;
                    }
                    break;
            }
            return TableResultAction.resultAction.RemoveCell;
        }
        /**
         * Get action to be applied on the cell.
         *
         * @param {object} cell virtual table cell to apply action
         */
        function getAddResultActionToCell(cell) {
            switch (where) {
                case TableResultAction.where.Column:
                    if (cell.isColSpan) {
                        return TableResultAction.resultAction.SumSpanCount;
                    }
                    else if (cell.isRowSpan && cell.isVirtual) {
                        return TableResultAction.resultAction.Ignore;
                    }
                    break;
                case TableResultAction.where.Row:
                    if (cell.isRowSpan) {
                        return TableResultAction.resultAction.SumSpanCount;
                    }
                    else if (cell.isColSpan && cell.isVirtual) {
                        return TableResultAction.resultAction.Ignore;
                    }
                    break;
            }
            return TableResultAction.resultAction.AddCell;
        }
        function init() {
            setStartPoint();
            createVirtualTable();
        }
        /// ///////////////////////////////////////////
        // Public functions
        /// ///////////////////////////////////////////
        /**
         * Recover array os what to do in table.
         */
        this.getActionList = function () {
            var fixedRow = (where === TableResultAction.where.Row) ? _startPoint.rowPos : -1;
            var fixedCol = (where === TableResultAction.where.Column) ? _startPoint.colPos : -1;
            var actualPosition = 0;
            var canContinue = true;
            while (canContinue) {
                var rowPosition = (fixedRow >= 0) ? fixedRow : actualPosition;
                var colPosition = (fixedCol >= 0) ? fixedCol : actualPosition;
                var row = _virtualTable[rowPosition];
                if (!row) {
                    canContinue = false;
                    return _actionCellList;
                }
                var cell = row[colPosition];
                if (!cell) {
                    canContinue = false;
                    return _actionCellList;
                }
                // Define action to be applied in this cell
                var resultAction = TableResultAction.resultAction.Ignore;
                switch (action) {
                    case TableResultAction.requestAction.Add:
                        resultAction = getAddResultActionToCell(cell);
                        break;
                    case TableResultAction.requestAction.Delete:
                        resultAction = getDeleteResultActionToCell(cell);
                        break;
                }
                _actionCellList.push(getActionCell(cell, resultAction, rowPosition, colPosition));
                actualPosition++;
            }
            return _actionCellList;
        };
        init();
    };
    /**
    *
    * Where action occours enum.
    */
    TableResultAction.where = { 'Row': 0, 'Column': 1 };
    /**
    *
    * Requested action to apply enum.
    */
    TableResultAction.requestAction = { 'Add': 0, 'Delete': 1 };
    /**
    *
    * Result action to be executed enum.
    */
    TableResultAction.resultAction = { 'Ignore': 0, 'SubtractSpanCount': 1, 'RemoveCell': 2, 'AddCell': 3, 'SumSpanCount': 4 };
    /**
     *
     * @class editing.Table
     *
     * Table
     *
     */
    var Table = /** @class */ (function () {
        function Table() {
        }
        /**
         * handle tab key
         *
         * @param {WrappedRange} rng
         * @param {Boolean} isShift
         */
        Table.prototype.tab = function (rng, isShift) {
            var cell = dom_1["default"].ancestor(rng.commonAncestor(), dom_1["default"].isCell);
            var table = dom_1["default"].ancestor(cell, dom_1["default"].isTable);
            var cells = dom_1["default"].listDescendant(table, dom_1["default"].isCell);
            var nextCell = lists_1["default"][isShift ? 'prev' : 'next'](cells, cell);
            if (nextCell) {
                range_1["default"].create(nextCell, 0).select();
            }
        };
        /**
         * Add a new row
         *
         * @param {WrappedRange} rng
         * @param {String} position (top/bottom)
         * @return {Node}
         */
        Table.prototype.addRow = function (rng, position) {
            var cell = dom_1["default"].ancestor(rng.commonAncestor(), dom_1["default"].isCell);
            var currentTr = jquery_1["default"](cell).closest('tr');
            var trAttributes = this.recoverAttributes(currentTr);
            var html = jquery_1["default"]('<tr' + trAttributes + '></tr>');
            var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Add, jquery_1["default"](currentTr).closest('table')[0]);
            var actions = vTable.getActionList();
            for (var idCell = 0; idCell < actions.length; idCell++) {
                var currentCell = actions[idCell];
                var tdAttributes = this.recoverAttributes(currentCell.baseCell);
                switch (currentCell.action) {
                    case TableResultAction.resultAction.AddCell:
                        html.append('<td' + tdAttributes + '>' + dom_1["default"].blank + '</td>');
                        break;
                    case TableResultAction.resultAction.SumSpanCount:
                        if (position === 'top') {
                            var baseCellTr = currentCell.baseCell.parent;
                            var isTopFromRowSpan = (!baseCellTr ? 0 : currentCell.baseCell.closest('tr').rowIndex) <= currentTr[0].rowIndex;
                            Eif (isTopFromRowSpan) {
                                var newTd = jquery_1["default"]('<div></div>').append(jquery_1["default"]('<td' + tdAttributes + '>' + dom_1["default"].blank + '</td>').removeAttr('rowspan')).html();
                                html.append(newTd);
                                break;
                            }
                        }
                        var rowspanNumber = parseInt(currentCell.baseCell.rowSpan, 10);
                        rowspanNumber++;
                        currentCell.baseCell.setAttribute('rowSpan', rowspanNumber);
                        break;
                }
            }
            if (position === 'top') {
                currentTr.before(html);
            }
            else {
                var cellHasRowspan = (cell.rowSpan > 1);
                if (cellHasRowspan) {
                    var lastTrIndex = currentTr[0].rowIndex + (cell.rowSpan - 2);
                    jquery_1["default"](jquery_1["default"](currentTr).parent().find('tr')[lastTrIndex]).after(jquery_1["default"](html));
                    return;
                }
                currentTr.after(html);
            }
        };
        /**
         * Add a new col
         *
         * @param {WrappedRange} rng
         * @param {String} position (left/right)
         * @return {Node}
         */
        Table.prototype.addCol = function (rng, position) {
            var cell = dom_1["default"].ancestor(rng.commonAncestor(), dom_1["default"].isCell);
            var row = jquery_1["default"](cell).closest('tr');
            var rowsGroup = jquery_1["default"](row).siblings();
            rowsGroup.push(row);
            var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Add, jquery_1["default"](row).closest('table')[0]);
            var actions = vTable.getActionList();
            for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {
                var currentCell = actions[actionIndex];
                var tdAttributes = this.recoverAttributes(currentCell.baseCell);
                switch (currentCell.action) {
                    case TableResultAction.resultAction.AddCell:
                        if (position === 'right') {
                            jquery_1["default"](currentCell.baseCell).after('<td' + tdAttributes + '>' + dom_1["default"].blank + '</td>');
                        }
                        else {
                            jquery_1["default"](currentCell.baseCell).before('<td' + tdAttributes + '>' + dom_1["default"].blank + '</td>');
                        }
                        break;
                    case TableResultAction.resultAction.SumSpanCount:
                        Eif (position === 'right') {
                            var colspanNumber = parseInt(currentCell.baseCell.colSpan, 10);
                            colspanNumber++;
                            currentCell.baseCell.setAttribute('colSpan', colspanNumber);
                        }
                        else {
                            jquery_1["default"](currentCell.baseCell).before('<td' + tdAttributes + '>' + dom_1["default"].blank + '</td>');
                        }
                        break;
                }
            }
        };
        /*
        * Copy attributes from element.
        *
        * @param {object} Element to recover attributes.
        * @return {string} Copied string elements.
        */
        Table.prototype.recoverAttributes = function (el) {
            var resultStr = '';
            Iif (!el) {
                return resultStr;
            }
            var attrList = el.attributes || [];
            for (var i = 0; i < attrList.length; i++) {
                if (attrList[i].name.toLowerCase() === 'id') {
                    continue;
                }
                Eif (attrList[i].specified) {
                    resultStr += ' ' + attrList[i].name + '=\'' + attrList[i].value + '\'';
                }
            }
            return resultStr;
        };
        /**
         * Delete current row
         *
         * @param {WrappedRange} rng
         * @return {Node}
         */
        Table.prototype.deleteRow = function (rng) {
            var cell = dom_1["default"].ancestor(rng.commonAncestor(), dom_1["default"].isCell);
            var row = jquery_1["default"](cell).closest('tr');
            var cellPos = row.children('td, th').index(jquery_1["default"](cell));
            var rowPos = row[0].rowIndex;
            var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Delete, jquery_1["default"](row).closest('table')[0]);
            var actions = vTable.getActionList();
            for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {
                Iif (!actions[actionIndex]) {
                    continue;
                }
                var baseCell = actions[actionIndex].baseCell;
                var virtualPosition = actions[actionIndex].virtualTable;
                var hasRowspan = (baseCell.rowSpan && baseCell.rowSpan > 1);
                var rowspanNumber = (hasRowspan) ? parseInt(baseCell.rowSpan, 10) : 0;
                switch (actions[actionIndex].action) {
                    case TableResultAction.resultAction.Ignore:
                        continue;
                    case TableResultAction.resultAction.AddCell:
                        var nextRow = row.next('tr')[0];
                        Iif (!nextRow) {
                            continue;
                        }
                        var cloneRow = row[0].cells[cellPos];
                        Eif (hasRowspan) {
                            Iif (rowspanNumber > 2) {
                                rowspanNumber--;
                                nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]);
                                nextRow.cells[cellPos].setAttribute('rowSpan', rowspanNumber);
                                nextRow.cells[cellPos].innerHTML = '';
                            }
                            else Eif (rowspanNumber === 2) {
                                nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]);
                                nextRow.cells[cellPos].removeAttribute('rowSpan');
                                nextRow.cells[cellPos].innerHTML = '';
                            }
                        }
                        continue;
                    case TableResultAction.resultAction.SubtractSpanCount:
                        Eif (hasRowspan) {
                            Eif (rowspanNumber > 2) {
                                rowspanNumber--;
                                baseCell.setAttribute('rowSpan', rowspanNumber);
                                Iif (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) {
                                    baseCell.innerHTML = '';
                                }
                            }
                            else if (rowspanNumber === 2) {
                                baseCell.removeAttribute('rowSpan');
                                if (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) {
                                    baseCell.innerHTML = '';
                                }
                            }
                        }
                        continue;
                    case TableResultAction.resultAction.RemoveCell:
                        // Do not need remove cell because row will be deleted.
                        continue;
                }
            }
            row.remove();
        };
        /**
         * Delete current col
         *
         * @param {WrappedRange} rng
         * @return {Node}
         */
        Table.prototype.deleteCol = function (rng) {
            var cell = dom_1["default"].ancestor(rng.commonAncestor(), dom_1["default"].isCell);
            var row = jquery_1["default"](cell).closest('tr');
            var cellPos = row.children('td, th').index(jquery_1["default"](cell));
            var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Delete, jquery_1["default"](row).closest('table')[0]);
            var actions = vTable.getActionList();
            for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {
                Iif (!actions[actionIndex]) {
                    continue;
                }
                switch (actions[actionIndex].action) {
                    case TableResultAction.resultAction.Ignore:
                        continue;
                    case TableResultAction.resultAction.SubtractSpanCount:
                        var baseCell = actions[actionIndex].baseCell;
                        var hasColspan = (baseCell.colSpan && baseCell.colSpan > 1);
                        Eif (hasColspan) {
                            var colspanNumber = (baseCell.colSpan) ? parseInt(baseCell.colSpan, 10) : 0;
                            if (colspanNumber > 2) {
                                colspanNumber--;
                                baseCell.setAttribute('colSpan', colspanNumber);
                                Iif (baseCell.cellIndex === cellPos) {
                                    baseCell.innerHTML = '';
                                }
                            }
                            else Eif (colspanNumber === 2) {
                                baseCell.removeAttribute('colSpan');
                                if (baseCell.cellIndex === cellPos) {
                                    baseCell.innerHTML = '';
                                }
                            }
                        }
                        continue;
                    case TableResultAction.resultAction.RemoveCell:
                        dom_1["default"].remove(actions[actionIndex].baseCell, true);
                        continue;
                }
            }
        };
        /**
         * create empty table element
         *
         * @param {Number} rowCount
         * @param {Number} colCount
         * @return {Node}
         */
        Table.prototype.createTable = function (colCount, rowCount, options) {
            var tds = [];
            var tdHTML;
            for (var idxCol = 0; idxCol < colCount; idxCol++) {
                tds.push('<td>' + dom_1["default"].blank + '</td>');
            }
            tdHTML = tds.join('');
            var trs = [];
            var trHTML;
            for (var idxRow = 0; idxRow < rowCount; idxRow++) {
                trs.push('<tr>' + tdHTML + '</tr>');
            }
            trHTML = trs.join('');
            var $table = jquery_1["default"]('<table>' + trHTML + '</table>');
            if (options && options.tableClassName) {
                $table.addClass(options.tableClassName);
            }
            return $table[0];
        };
        /**
         * Delete current table
         *
         * @param {WrappedRange} rng
         * @return {Node}
         */
        Table.prototype.deleteTable = function (rng) {
            var cell = dom_1["default"].ancestor(rng.commonAncestor(), dom_1["default"].isCell);
            jquery_1["default"](cell).closest('table').remove();
        };
        return Table;
    }());
    exports["default"] = Table;

    },'src/js/base/editing/Table.js',{"jquery":"/Users/lqez/Dev/summernote/node_modules/jquery/dist/jquery.js","../core/dom":"/Users/lqez/Dev/summernote/src/js/base/core/dom.js","../core/range":"/Users/lqez/Dev/summernote/src/js/base/core/range.js","../core/lists":"/Users/lqez/Dev/summernote/src/js/base/core/lists.js"}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 48508 characters]