all files / document-editor/implementation/editor-history/ history-info.js

27.3% Statements 101/370
24.32% Branches 54/222
100% Functions 14/14
26.7% Lines 98/367
11 statements, 6 functions, 9 branches Ignored     
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 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573          268× 268× 268× 268× 268× 268×     303×         822× 616× 267×   616×     10× 10× 10×                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               10×   99× 99×   99× 99× 54× 54× 110× 110× 110×       45× 45× 97× 97× 97×       99×                         99× 73×     26×     254× 253× 581× 581× 581×   253×   254×        
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "@syncfusion/ej2-base", "./base-history-info", "../viewer/page", "../../base/types"], function (require, exports, ej2_base_1, base_history_info_1, page_1, types_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var HistoryInfo = (function (_super) {
        __extends(HistoryInfo, _super);
        function HistoryInfo(node, isChild) {
            var _this = _super.call(this, node) || this;
            _this.isChildHistoryInfo = false;
            _this.editRangeStart = undefined;
            _this.documentHelper = node.documentHelper;
            _this.isChildHistoryInfo = isChild;
            return _this;
        }
        Object.defineProperty(HistoryInfo.prototype, "hasAction", {
            get: function () {
                return !ej2_base_1.isNullOrUndefined(this.modifiedActions);
            },
            enumerable: true,
            configurable: true
        });
        HistoryInfo.prototype.addModifiedAction = function (baseHistoryInfo) {
            if (!(this.editorHistory.isUndoing || this.editorHistory.isRedoing)) {
                if (ej2_base_1.isNullOrUndefined(this.modifiedActions)) {
                    this.modifiedActions = [];
                }
                this.modifiedActions.push(baseHistoryInfo);
            }
        };
        HistoryInfo.prototype.getActionInfo = function (isInvertOperation) {
            var action = this.action;
            var operations = [];
            switch (action) {
                case 'InsertBookmark':
                case 'RestrictEditing':
                    Iif (this.editorHistory.isUndoing) {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            if (action === 'RestrictEditing') {
                                this.modifiedActions[parseInt(i.toString(), 10)].markerData.push(this.owner.editorModule.getMarkerData(this.modifiedActions[parseInt(i.toString(), 10)].removedNodes[0]));
                            }
                            operations.push(this.modifiedActions[parseInt(i.toString(), 10)].getDeleteOperation('DeleteBookmark', i === 0 ? true : undefined));
                            this.modifiedActions[parseInt(i.toString(), 10)].markerData.shift();
                        }
                    }
                    else {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            Iif (currentHistory.action === 'DeleteBookmark') {
                                operations.push(currentHistory.getDeleteOperation('DeleteBookmark'));
                                operations.push(currentHistory.getDeleteOperation('DeleteBookmark', true));
                                continue;
                            }
                            operations.push(currentHistory.getInsertOperation(action));
                        }
                    }
                    break;
                case 'BackSpace':
                case 'Delete':
                case 'RemoveEditRange':
                    if (this.editorHistory.isUndoing) {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            if (currentHistory.action === 'InsertInline') {
                                var operation = currentHistory.getDeleteOperation('DeleteBookmark', true);
                                operations.push(operation);
                            }
                            else {
                                var operationCollection = currentHistory.getActionInfo();
                                operations = operations.concat(operationCollection);
                                if (currentHistory.action === 'RemoveEditRange') {
                                    operations.push(currentHistory.getDeleteOperation(action, true));
                                }
                            }
                        }
                        operations.reverse();
                    }
                    else {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            if (currentHistory.action === 'InsertInline') {
                                var operation = currentHistory.getInsertOperation('InsertBookmark');
                                operations.push(operation);
                            }
                            else {
                                operations.push(currentHistory.getDeleteOperation(action));
                                if (currentHistory.action === 'RemoveEditRange') {
                                    operations.push(currentHistory.getDeleteOperation(action, true));
                                }
                            }
                        }
                    }
                    break;
                case 'PageBreak':
                case 'ColumnBreak':
                    if (this.owner.enableTrackChanges) {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            if (currentHistory.removedNodes.length > 0) {
                                operations = operations.concat(currentHistory.getDeleteOperationsForTrackChanges());
                            }
                            var markerData = currentHistory.markerData[currentHistory.markerData.length - 1];
                            var operation = currentHistory.getInsertOperation('Enter');
                            var breakOperation = this.getInsertOperation(action);
                            operation.markerData = markerData;
                            breakOperation.markerData =
                                this.owner.editorModule.getMarkerData(undefined, undefined, this.owner.editorModule.getRevision(markerData.revisionId));
                            operations.push(operation);
                            operations.push(breakOperation);
                            operations.push(operation);
                            operation.markerData.skipOperation = true;
                        }
                    }
                    else {
                        if (this.editorHistory.isUndoing) {
                            for (var i = 0; i < this.modifiedActions.length; i++) {
                                var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                                currentHistory.endIndex = currentHistory.startIndex;
                                operations.push(currentHistory.getDeleteOperation('Delete'));
                                operations.push(currentHistory.getDeleteOperation('Delete'));
                                operations.push(currentHistory.getDeleteOperation('Delete'));
                                if (currentHistory.isRemovedNodes) {
                                    var operationCollection = currentHistory.getDeleteContent('BackSpace');
                                    operations = operations.concat(operationCollection);
                                }
                            }
                        }
                        else {
                            for (var i = 0; i < this.modifiedActions.length; i++) {
                                var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                                if (currentHistory.removedNodes.length > 0) {
                                    operations.push(currentHistory.getDeleteOperation(action));
                                }
                            }
                            var operation = this.getInsertOperation('Enter');
                            operation.markerData = { skipOperation: true };
                            operations.push(operation);
                            operations.push(operation);
                            operations.push(this.getInsertOperation(action));
                            operations.push(operation);
                        }
                    }
                    break;
                case 'InsertHyperlink':
                case 'AutoFormatHyperlink':
                case 'RemoveHyperlink':
                    Iif (this.editorHistory.isUndoing && action === 'RemoveHyperlink') {
                        var length_1 = 0;
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            if (currentHistory.action === 'FontColor' || currentHistory.action === 'Underline') {
                                length_1 = currentHistory.endIndex - currentHistory.startIndex;
                            }
                        }
                        if (!ej2_base_1.isNullOrUndefined(this.modifiedActions[parseInt((this.modifiedActions.length - 1).toString(), 10)].fieldBegin)) {
                            this.modifiedActions[parseInt((this.modifiedActions.length - 1).toString(), 10)].endIndex =
                                this.modifiedActions[parseInt((this.modifiedActions.length - 1).toString(), 10)].startIndex + length_1;
                            var operation = this.modifiedActions[parseInt((this.modifiedActions.length - 1).toString(), 10)].getDeleteOperation('Delete');
                            operation.markerData = undefined;
                            operations.push(operation);
                            var operationCollection = this.modifiedActions[parseInt((this.modifiedActions.length - 1).toString(), 10)].getFieldOperation();
                            operations = operations.concat(operationCollection);
                        }
                    }
                    else {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            Iif (currentHistory.action === 'InsertHyperlink') {
                                operations.push.apply(operations, currentHistory.getActionInfo());
                            }
                            else Iif (currentHistory.action === 'InsertInline') {
                                if (currentHistory.insertedText === types_1.CONTROL_CHARACTERS.Marker_Start ||
                                    currentHistory.insertedText === types_1.CONTROL_CHARACTERS.Marker_End) {
                                    if (this.editorHistory.isUndoing) {
                                        operations.push(currentHistory.getDeleteOperation(currentHistory.action));
                                    }
                                    else {
                                        operations.push(currentHistory.getInsertOperation('InsertHyperlink'));
                                    }
                                }
                                else {
                                    if (this.editorHistory.isUndoing) {
                                        operations.push(currentHistory.getDeleteOperation(currentHistory.action));
                                    }
                                    else {
                                        operations.push(currentHistory.getInsertOperation('Insert'));
                                    }
                                }
                            }
                            else if (currentHistory.action === 'Delete') {
                                operations.push(currentHistory.getDeleteOperation(currentHistory.action));
                            }
                            else if (currentHistory.action === 'Underline') {
                                operations = operations.concat(currentHistory.getActionInfo());
                            }
                            else Eif (currentHistory.action === 'FontColor') {
                                operations = operations.concat(currentHistory.getActionInfo());
                            }
                        }
                        Iif (this.editorHistory.isUndoing) {
                            operations.reverse();
                        }
                    }
                    break;
                case 'InsertComment':
                    Iif (this.editorHistory.isUndoing) {
                        this.getDeleteCommentOperation(this.modifiedActions, operations);
                    }
                    else {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            var operation = currentHistory.getInsertOperation(currentHistory.action);
                            if ((currentHistory.insertedElement instanceof page_1.CommentCharacterElementBox && currentHistory.action === 'InsertInline')) {
                                operations.push(currentHistory.getCommentOperation(operation, currentHistory.action));
                            }
                            else Eif (currentHistory.action === 'InsertCommentWidget') {
                                operation = this.getUpdateOperation();
                                operations.push(currentHistory.getCommentOperation(operation, currentHistory.action));
                            }
                        }
                    }
                    break;
                case 'RemoveComment':
                    if (this.editorHistory.isUndoing) {
                        for (var i = this.modifiedActions.length - 1; i >= 0; i--) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            var operation = undefined;
                            var operationCollection = [];
                            if (currentHistory.action === 'InsertInline' && currentHistory.insertedElement instanceof page_1.CommentCharacterElementBox) {
                                operation = currentHistory.getDeleteOperation(currentHistory.action);
                                operationCollection.push(currentHistory.getCommentOperation(operation, 'InsertInline'));
                            }
                            else if (currentHistory.action === 'RemoveInline') {
                                operation = currentHistory.getDeleteOperation(currentHistory.action);
                                operationCollection.push(currentHistory.getCommentOperation(operation, 'InsertInline'));
                                operation = currentHistory.getInsertOperation(currentHistory.action);
                                operationCollection.push(currentHistory.getCommentOperation(operation, 'InsertInline'));
                            }
                            else if (currentHistory.action === 'DeleteComment') {
                                operationCollection = currentHistory.getActionInfo();
                            }
                            else {
                                this.owner.sfdtExportModule.iscontentInsert = false;
                                operationCollection = currentHistory.getActionInfo();
                                this.owner.sfdtExportModule.iscontentInsert = true;
                            }
                            operations = operations.concat(operationCollection);
                        }
                    }
                    else {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            var operation = undefined;
                            var operationCollection = [];
                            if (currentHistory.action === 'RemoveInline' && currentHistory.removedNodes[0] instanceof page_1.CommentCharacterElementBox) {
                                operation = currentHistory.getDeleteOperation(currentHistory.action);
                                operationCollection.push(currentHistory.getCommentOperation(operation, currentHistory.action));
                            }
                            else if (currentHistory.action === 'InsertInline' && currentHistory.insertedElement instanceof page_1.CommentCharacterElementBox) {
                                operation = currentHistory.getInsertOperation(currentHistory.action);
                                operationCollection.push(currentHistory.getCommentOperation(operation, currentHistory.action));
                            }
                            else {
                                operationCollection = currentHistory.getActionInfo();
                            }
                            operations = operations.concat(operationCollection);
                        }
                    }
                    break;
                case 'DeleteComment':
                    Iif (this.editorHistory.isUndoing) {
                        for (var j = this.modifiedActions.length - 1; j >= 0; j--) {
                            var history_1 = this.modifiedActions[parseInt(j.toString(), 10)];
                            var operation = history_1.getInsertOperation(history_1.action);
                            if ((history_1.insertedElement instanceof page_1.CommentCharacterElementBox && history_1.action === 'RemoveInline')) {
                                operations.push(history_1.getCommentOperation(operation, 'InsertInline'));
                            }
                            else if (history_1.action === 'DeleteCommentWidget') {
                                operation = this.getUpdateOperation();
                                operations.push(history_1.getCommentOperation(operation, 'InsertCommentWidget'));
                            }
                            else if (history_1.action === 'DeleteComment') {
                                history_1.getActionInfo();
                            }
                        }
                    }
                    else {
                        this.getDeleteCommentOperation(this.modifiedActions, operations);
                    }
                    break;
                case 'FormField': {
                    var currentHistory = this.modifiedActions.pop();
                    operations = currentHistory.getFieldOperation();
                    break;
                }
                case 'IMEInput':
                    if (isInvertOperation && (!(this.editorHistory.isUndoing || this.editorHistory.isRedoing))) {
                        if (this.modifiedActions[0].removedNodes.length > 0) {
                            var removeOperation = this.modifiedActions[0].getDeleteOperation('Delete');
                            removeOperation.length = removeOperation.text.length;
                            operations.push(removeOperation);
                        }
                        var insertOperation = this.modifiedActions[this.modifiedActions.length - 1].getInsertOperation('Insert');
                        insertOperation.length = insertOperation.text.length;
                        operations.push(insertOperation);
                        operations.reverse();
                        for (var i = 0; i < operations.length; i++) {
                            var operation = operations[parseInt(i.toString(), 10)];
                            if (operation.action === 'Insert') {
                                operation.action = 'Delete';
                            }
                            else if (operation.action === 'Delete') {
                                operation.action = 'Insert';
                            }
                        }
                    }
                    else {
                        var currentHistory = this.modifiedActions[this.modifiedActions.length - 1];
                        if (this.editorHistory.isUndoing || this.editorHistory.isRedoing) {
                            for (var i = 0; i < this.modifiedActions.length; i++) {
                                currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                                if (currentHistory.removedNodes.length > 0) {
                                    operations.push(currentHistory.getDeleteOperation(action));
                                }
                                if (currentHistory.isRemovedNodes) {
                                    var operationCollection = currentHistory.getDeleteContent('BackSpace');
                                    operations = operations.concat(operationCollection);
                                }
                                currentHistory.isRemovedNodes = false;
                            }
                        }
                        else {
                            if (currentHistory.removedNodes.length > 0) {
                                operations.push(currentHistory.getDeleteOperation(action));
                            }
                            operations.push(currentHistory.getInsertOperation(this.action));
                        }
                        currentHistory.isRemovedNodes = false;
                    }
                    break;
                case 'Accept All':
                case 'ReplaceAll':
                case 'Reject All': {
                    var isSkip = false;
                    if (this.editorHistory.isUndoing) {
                        for (var i = this.modifiedActions.length - 1; i >= 0; i--) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            if (!ej2_base_1.isNullOrUndefined(currentHistory.cellOperation) && currentHistory.cellOperation.length > 0) {
                                operations.push(currentHistory.cellOperation[0]);
                                isSkip = true;
                                currentHistory.cellOperation = [];
                            }
                            else {
                                var operationsCollection = currentHistory.getActionInfo();
                                operations.push.apply(operations, operationsCollection);
                            }
                        }
                    }
                    else {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                            if (!ej2_base_1.isNullOrUndefined(currentHistory.cellOperation) && currentHistory.cellOperation.length > 0) {
                                operations.push(currentHistory.cellOperation[0]);
                                isSkip = true;
                                currentHistory.cellOperation = [];
                            }
                            else {
                                var operationsCollection = currentHistory.getActionInfo();
                                operations.push.apply(operations, operationsCollection);
                            }
                        }
                    }
                    break;
                }
                case 'Paste':
                    for (var i = 0; i < this.modifiedActions.length; i++) {
                        var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                        currentHistory.type = this.type === 'PasteToc' ? this.type : 'Paste';
                        var pasteOperations = currentHistory.getActionInfo();
                        operations.push.apply(operations, pasteOperations);
                    }
                    break;
                case 'TOC':
                    if (this.modifiedActions) {
                        if (this.editorHistory.isUndoing) {
                            for (var i = this.modifiedActions.length - 1; i >= 0; i--) {
                                var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                                currentHistory.type = currentHistory.action === 'Paste' ? 'PasteToc' : undefined;
                                var tocOperations = currentHistory.getActionInfo();
                                operations.push.apply(operations, tocOperations);
                            }
                        }
                        else {
                            for (var i = 0; i < this.modifiedActions.length; i++) {
                                var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                                currentHistory.type = currentHistory.action === 'Paste' ? 'PasteToc' : undefined;
                                var tocOperations = currentHistory.getActionInfo();
                                operations.push.apply(operations, tocOperations);
                            }
                        }
                    }
                    break;
                case 'DragAndDropContent':
                    for (var i = 0; i < this.modifiedActions.length; i++) {
                        var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                        currentHistory.type = currentHistory.action === 'Paste' ? 'Paste' : undefined;
                        var ddcOperations = currentHistory.getActionInfo();
                        operations.push.apply(operations, ddcOperations);
                    }
                    break;
                case 'ClearFormat':
                    if (this.editorHistory.isUndoing) {
                        for (var i = 0; i < this.modifiedActions.length; i++) {
                            operations.push.apply(operations, this.modifiedActions[parseInt(i.toString(), 10)].modifiedFormatOperation);
                            this.modifiedActions[parseInt(i.toString(), 10)].modifiedFormatOperation = [];
                        }
                    }
                    else {
                        var clearHistory = this.modifiedActions[this.modifiedActions.length - 1];
                        var formatOperation = clearHistory.buildFormatOperation('ClearFormat', true);
                        operations = formatOperation.slice();
                    }
                    break;
                case 'ApplyStyle': {
                    var styleHistory = void 0;
                    var formatstyleOperation = [];
                    if (this.modifiedActions[0] instanceof HistoryInfo) {
                        var historyInfo = this.modifiedActions[0];
                        styleHistory = historyInfo.modifiedActions[0];
                        formatstyleOperation = styleHistory.buildFormatOperation('ClearFormat', true);
                        operations = formatstyleOperation.slice();
                    }
                    if (!(this.modifiedActions[this.modifiedActions.length - 1] instanceof HistoryInfo)) {
                        formatstyleOperation = this.modifiedActions[this.modifiedActions.length - 1].buildFormatOperation(action, true);
                        for (var i = 0; i < formatstyleOperation.length; i++) {
                            operations.push(formatstyleOperation[parseInt(i.toString(), 10)]);
                        }
                    }
                    break;
                }
                case 'TableMarginsSelection':
                    this.modifiedActions[this.modifiedActions.length - 1].createTableFormat(this.modifiedActions[this.modifiedActions.length - 1].action);
                    this.modifiedActions[this.modifiedActions.length - 1].type = 'TableFormat';
                    operations.push(this.modifiedActions[this.modifiedActions.length - 1].getFormatOperation());
                    break;
                case 'BordersAndShading':
                    if (this.modifiedActions[0].action === 'TableFormat') {
                        this.modifiedActions[0].type = 'TableFormat';
                        this.modifiedActions[0].createTableFormat('BordersAndShading');
                        operations.push(this.modifiedActions[0].getFormatOperation());
                    }
                    else {
                        this.modifiedActions[0].createCellFormat('BordersAndShading');
                        this.modifiedActions[0].type = 'CellFormat';
                        operations = this.modifiedActions[0].getSelectedCellOperation('BordersAndShading', undefined, true, true, true);
                    }
                    break;
                case 'AutoList':
                    for (var i = 0; i < this.modifiedActions.length; i++) {
                        var currentHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                        var autoListOperations = currentHistory.getActionInfo();
                        operations.push.apply(operations, autoListOperations);
                    }
                    break;
                case 'TableProperties':
                    for (var i = 0; i < this.modifiedActions.length; i++) {
                        var tablePropHistory = this.modifiedActions[parseInt(i.toString(), 10)];
                        if (tablePropHistory.action === 'TableFormat') {
                            tablePropHistory.createTableFormat(tablePropHistory.action);
                            tablePropHistory.type = 'TableFormat';
                            operations.push(tablePropHistory.getFormatOperation());
                        }
                        else if (tablePropHistory.action === 'RowFormat') {
                            if (this.editorHistory.isUndoing || this.editorHistory.isRedoing &&
                                tablePropHistory.modifiedProperties.length > 1) {
                                operations = tablePropHistory.modifiedFormatOperation;
                                tablePropHistory.modifiedFormatOperation = [];
                            }
                            else {
                                tablePropHistory.createRowFormat(tablePropHistory.action);
                                tablePropHistory.type = 'RowFormat';
                                operations.push(tablePropHistory.getFormatOperation());
                            }
                        }
                        else if (tablePropHistory.action === 'CellFormat') {
                            tablePropHistory.createCellFormat(tablePropHistory.action);
                            tablePropHistory.type = 'CellFormat';
                            var cellProp = tablePropHistory.getSelectedCellOperation(tablePropHistory.action, false, false, false, true);
                            for (var i_1 = 0; i_1 < cellProp.length; i_1++) {
                                operations.push(cellProp[parseInt(i_1.toString(), 10)]);
                            }
                        }
                    }
                    break;
                case 'CellMarginsSelection':
                    this.modifiedActions[this.modifiedActions.length - 1].createCellFormat('CellOptions');
                    this.modifiedActions[this.modifiedActions.length - 1].type = 'CellFormat';
                    operations = this.modifiedActions[this.modifiedActions.length - 1].getSelectedCellOperation('CellOptions', false, false, false, true).slice();
                    break;
            }
            return operations;
        };
        HistoryInfo.prototype.revert = function () {
            this.editorHistory.currentHistoryInfo = this;
            if (this.action === 'BordersAndShading') {
                this.owner.editorModule.isBordersAndShadingDialog = true;
            }
            Eif (!ej2_base_1.isNullOrUndefined(this.modifiedActions)) {
                if (this.editorHistory.isUndoing) {
                    var i = this.modifiedActions.length;
                    while (i > 0) {
                        var baseHistoryInfo = this.modifiedActions[i - 1];
                        baseHistoryInfo.revert();
                        i = i - 1;
                    }
                }
                else {
                    var i = 0;
                    while (i < this.modifiedActions.length) {
                        var baseHistoryInfo = this.modifiedActions[parseInt(i.toString(), 10)];
                        baseHistoryInfo.revert();
                        i = i + 1;
                    }
                }
            }
            Iif (this.action === 'RestrictEditing') {
                var user = this.editRangeStart.user !== '' ? this.editRangeStart.user : this.editRangeStart.group;
                if (this.editorHistory.isUndoing) {
                    var index = this.owner.documentHelper.editRanges.get(user).indexOf(this.editRangeStart);
                    if (index !== -1) {
                        this.owner.documentHelper.editRanges.get(user).splice(index, 1);
                    }
                }
                else {
                    this.owner.editorModule.updateRangeCollection(this.editRangeStart, user);
                }
                this.owner.selectionModule.updateEditRangeCollection();
            }
            if (!this.isChildHistoryInfo) {
                this.editorHistory.updateComplexHistory();
            }
            else {
                this.editorHistory.updateComplexHistoryInternal();
            }
        };
        HistoryInfo.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.modifiedActions)) {
                while (this.modifiedActions.length > 0) {
                    var baseHistoryInfo = this.modifiedActions[this.modifiedActions.length - 1];
                    baseHistoryInfo.destroy();
                    this.modifiedActions.splice(this.modifiedActions.indexOf(baseHistoryInfo), 1);
                }
                this.modifiedActions = undefined;
            }
            _super.prototype.destroy.call(this);
        };
        return HistoryInfo;
    }(base_history_info_1.BaseHistoryInfo));
    exports.HistoryInfo = HistoryInfo;
});