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

71.29% Statements 216/303
67.55% Branches 127/188
77.14% Functions 27/35
71.29% Lines 216/303
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   504× 504× 504× 504× 504× 504× 504× 504× 504× 504× 504×     24279×       783× 393×     390×             20857×           7026×           3846×                       922×                       331×         14780×   2195×   3660×   1917× 14×   1917× 1917× 1917× 1916×     293× 293× 293×             293×                                                                                                                           2384×     2384× 461× 102×   461×       461× 461×       1923× 1531×   1923× 475×   1923×       1923× 1923×     2384×   2990× 2854×   584×   2854× 797×     2057×   2854×     2624× 2624× 1556×     1556×     1556×       1556×       2624× 360× 360× 360×     2264×     2624×   331× 331× 325×   10×         10× 10×     325×       325×       325× 252× 252×   252× 252×   252×     331× 23×   331× 331× 331× 28×     303× 303× 243×     60×     331× 331× 331× 331×   331× 331× 331× 331×   331× 331× 322×     396× 390× 377×   390× 69× 69×     321×   390×                                                                             22× 22× 22× 22× 22× 22× 22×   22×   22× 22× 22× 22× 22× 22× 22× 22×         22× 22× 22×   467×       461× 461× 461× 461× 461× 461× 461× 461×   402×       398× 398×   398× 398× 398× 398× 398× 398× 398×   1521× 1521× 1521×   1530× 1530×   1530× 464× 1441× 1441× 1441×       3061× 50× 59× 59× 59×            
define(["require", "exports", "../../base/dictionary", "../selection/selection-helper", "../../index", "@syncfusion/ej2-base", "./base-history-info", "./history-helper", "./history-info", "../format/paragraph-format", "../editor/editor-helper"], function (require, exports, dictionary_1, selection_helper_1, index_1, ej2_base_1, base_history_info_1, history_helper_1, history_info_1, paragraph_format_1, editor_helper_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var EditorHistory = (function () {
        function EditorHistory(node) {
            this.undoStackIn = [];
            this.redoStackIn = [];
            this.historyInfoStack = [];
            this.isUndoGroupingEnded = true;
            this.isUndoing = false;
            this.isRedoing = false;
            this.owner = node;
            this.documentHelper = node.documentHelper;
            this.modifiedParaFormats = new dictionary_1.Dictionary();
            this.undoLimitIn = 500;
            this.redoLimitIn = 500;
        }
        Object.defineProperty(EditorHistory.prototype, "currentHistoryInfo", {
            get: function () {
                return this.historyInfoStack && this.historyInfoStack.length > 0 ?
                    this.historyInfoStack[this.historyInfoStack.length - 1] : undefined;
            },
            set: function (value) {
                if (value instanceof history_info_1.HistoryInfo) {
                    this.historyInfoStack.push(value);
                }
                else {
                    this.historyInfoStack.pop();
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(EditorHistory.prototype, "undoStack", {
            get: function () {
                return this.undoStackIn;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(EditorHistory.prototype, "redoStack", {
            get: function () {
                return this.redoStackIn;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(EditorHistory.prototype, "undoLimit", {
            get: function () {
                return ej2_base_1.isNullOrUndefined(this.undoLimitIn) ? 0 : this.undoLimitIn;
            },
            set: function (value) {
                if (value < 0) {
                    throw new Error('The limit should be greater than or equal to zero.');
                }
                this.undoLimitIn = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(EditorHistory.prototype, "redoLimit", {
            get: function () {
                return ej2_base_1.isNullOrUndefined(this.redoLimitIn) ? 0 : this.redoLimitIn;
            },
            set: function (value) {
                if (value < 0) {
                    throw new Error('The limit should be greater than or equal to zero.');
                }
                this.redoLimitIn = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(EditorHistory.prototype, "viewer", {
            get: function () {
                return this.owner.viewer;
            },
            enumerable: true,
            configurable: true
        });
        EditorHistory.prototype.getModuleName = function () {
            return 'EditorHistory';
        };
        EditorHistory.prototype.canUndo = function () {
            return !ej2_base_1.isNullOrUndefined(this.undoStack) && this.undoStack.length > 0;
        };
        EditorHistory.prototype.canRedo = function () {
            return !ej2_base_1.isNullOrUndefined(this.redoStack) && this.redoStack.length > 0;
        };
        EditorHistory.prototype.initializeHistory = function (action) {
            if (!ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo)) {
                this.currentBaseHistoryInfo.destroy();
            }
            this.currentBaseHistoryInfo = new base_history_info_1.BaseHistoryInfo(this.owner);
            this.currentBaseHistoryInfo.action = action;
            if (action !== 'ModifyStyle') {
                this.currentBaseHistoryInfo.updateSelection();
            }
        };
        EditorHistory.prototype.initComplexHistory = function (selection, action) {
            this.currentHistoryInfo = new history_info_1.HistoryInfo(selection.owner, !ej2_base_1.isNullOrUndefined(this.currentHistoryInfo));
            this.currentHistoryInfo.action = action;
            switch (action) {
                case 'PageBreak':
                    this.currentHistoryInfo.insertedText = index_1.CONTROL_CHARACTERS.PageBreak;
                    this.currentHistoryInfo.insertPosition = selection.startOffset;
                    break;
                case 'ColumnBreak':
                    this.currentHistoryInfo.insertedText = index_1.CONTROL_CHARACTERS.ColumnBreak;
                    this.currentHistoryInfo.insertPosition = selection.startOffset;
                    break;
            }
            this.currentHistoryInfo.updateSelection();
        };
        EditorHistory.prototype.initResizingHistory = function (startingPoint, tableResize) {
            if (tableResize.resizeNode === 1) {
                this.initializeHistory('RowResizing');
                if (!ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo)) {
                    tableResize.currentResizingTable = tableResize.currentResizingTable.combineWidget(this.viewer);
                    this.currentBaseHistoryInfo.modifiedProperties.push(new history_helper_1.RowHistoryFormat(tableResize.currentResizingTable, startingPoint, tableResize.currentResizingTable.childWidgets[tableResize.resizerPosition].rowFormat, this.owner));
                    this.documentHelper.layout.reLayoutTable(tableResize.currentResizingTable);
                }
            }
            else {
                this.initializeHistory('CellResizing');
                if (this.currentBaseHistoryInfo) {
                    tableResize.currentResizingTable = tableResize.currentResizingTable.combineWidget(this.viewer);
                    var tableHistoryInfo = new history_helper_1.TableHistoryInfo(tableResize.currentResizingTable, this.owner);
                    tableHistoryInfo.startingPoint = startingPoint;
                    this.currentBaseHistoryInfo.modifiedProperties.push(tableHistoryInfo);
                    this.documentHelper.layout.reLayoutTable(tableResize.currentResizingTable);
                }
            }
        };
        EditorHistory.prototype.beginUndoAction = function () {
            if (this.isUndoGroupingEnded) {
                this.owner.editorModule.initComplexHistory('Grouping');
                this.isUndoGroupingEnded = false;
                this.clearRedoStack();
            }
        };
        EditorHistory.prototype.endUndoAction = function () {
            if (!this.isUndoGroupingEnded) {
                this.updateComplexHistory();
                this.isUndoGroupingEnded = true;
            }
        };
        EditorHistory.prototype.updateResizingHistory = function (point, tableResize) {
            if (tableResize.resizeNode === 1) {
                if (!ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo)) {
                    var rowHistoryFormat = this.currentBaseHistoryInfo.modifiedProperties[0];
                    if (rowHistoryFormat.startingPoint.y === point.y) {
                        this.currentBaseHistoryInfo.modifiedProperties.length = 0;
                    }
                    else {
                        rowHistoryFormat.displacement = editor_helper_1.HelperMethods.convertPixelToPoint(point.y - rowHistoryFormat.startingPoint.y);
                        this.recordChanges(this.currentBaseHistoryInfo);
                        this.owner.fireContentChange();
                        this.currentBaseHistoryInfo = undefined;
                    }
                }
            }
            else {
                if (!ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo)) {
                    var cellHistoryFormat = this.currentBaseHistoryInfo.modifiedProperties[0];
                    if (cellHistoryFormat.startingPoint.x === point.x) {
                        this.currentBaseHistoryInfo.modifiedProperties.length = 0;
                    }
                    else {
                        cellHistoryFormat.displacement = editor_helper_1.HelperMethods.convertPixelToPoint(point.x - cellHistoryFormat.startingPoint.x);
                        cellHistoryFormat.endIndex = tableResize.getCellReSizerPosition(point);
                        this.owner.editorHistoryModule.recordChanges(this.currentBaseHistoryInfo);
                        this.owner.fireContentChange();
                        this.currentBaseHistoryInfo = undefined;
                    }
                }
            }
        };
        EditorHistory.prototype.recordChanges = function (baseHistoryInfo) {
            Iif (!this.owner.enableHistoryMode) {
                return;
            }
            if (this.isUndoing) {
                if (ej2_base_1.isNullOrUndefined(this.redoStack)) {
                    this.redoStackIn = [];
                }
                Iif (this.redoStack.length === this.redoLimit && this.redoLimit > 0) {
                    var count = this.undoLimit > 20 ? 10 : 1;
                    this.redoStackIn.splice(0, count);
                }
                Eif (this.redoStack.length < this.redoLimit) {
                    this.redoStack.push(baseHistoryInfo);
                }
            }
            else {
                if (!this.isRedoing) {
                    this.clearRedoStack();
                }
                if (ej2_base_1.isNullOrUndefined(this.undoStack)) {
                    this.undoStackIn = [];
                }
                Iif (this.undoStack.length === this.undoLimit && this.undoLimit > 0) {
                    var count = this.undoLimit > 20 ? 10 : 1;
                    this.undoStackIn.splice(0, count);
                }
                Eif (this.undoStack.length < this.undoLimit) {
                    this.undoStackIn.push(baseHistoryInfo);
                }
            }
            this.lastOperation = baseHistoryInfo;
        };
        EditorHistory.prototype.updateHistory = function () {
            if (this.documentHelper.owner.enableHistoryMode && !ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo)) {
                if (!ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo)
                    && ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo.endPosition)) {
                    this.currentBaseHistoryInfo.endPosition = this.currentBaseHistoryInfo.insertPosition;
                }
                if (!ej2_base_1.isNullOrUndefined(this.currentHistoryInfo)) {
                    this.currentHistoryInfo.addModifiedAction(this.currentBaseHistoryInfo);
                }
                else {
                    this.recordChanges(this.currentBaseHistoryInfo);
                }
                this.currentBaseHistoryInfo = undefined;
            }
        };
        EditorHistory.prototype.isHandledComplexHistory = function () {
            var isHandledComplexHistory = false;
            if (!(this.isUndoing || this.isRedoing)) {
                if (this.owner.editorModule.removedBookmarkElements.length > 0
                    && this.owner.editorModule.insertRemoveBookMarkElements(isHandledComplexHistory)) {
                    isHandledComplexHistory = true;
                }
                if (this.owner.editorModule.removedEditRangeEndElements.length > 0
                    && this.owner.editorModule.insertRemovedEditRangeEndElements(isHandledComplexHistory)) {
                    isHandledComplexHistory = true;
                }
                Iif (this.owner.editorModule.removedEditRangeStartElements.length > 0
                    && this.owner.editorModule.insertRemovedEditRangeStartElements(isHandledComplexHistory)) {
                    isHandledComplexHistory = true;
                }
                if (this.owner.editorModule.removedContentControlElements.length > 0
                    && this.owner.editorModule.insertRemoveContentControlElements(isHandledComplexHistory)) {
                    isHandledComplexHistory = true;
                }
            }
            if (this.documentHelper.owner.enableHistoryMode && !ej2_base_1.isNullOrUndefined(this.currentHistoryInfo)) {
                Eif (this.currentHistoryInfo.action !== 'Grouping') {
                    this.updateHistory();
                    isHandledComplexHistory = true;
                }
            }
            else Iif (this.owner.editorModule.isHandledComplex) {
                isHandledComplexHistory = true;
            }
            return isHandledComplexHistory;
        };
        EditorHistory.prototype.updateComplexHistory = function () {
            var selection = this.documentHelper.selection;
            if (!ej2_base_1.isNullOrUndefined(this.currentHistoryInfo) && this.currentHistoryInfo.hasAction) {
                if (this.currentHistoryInfo.action === 'AutoFormatHyperlink' || this.currentHistoryInfo.action === 'SkipCommentInline'
                    || this.currentHistoryInfo.action === 'DeleteCommentInline' || this.currentHistoryInfo.action === 'RemoveComment') {
                    Iif (selection.owner.editorHistoryModule.isUndoing) {
                        this.owner.editorModule.setPositionForCurrentIndex(selection.start, this.currentHistoryInfo.selectionStart);
                        this.owner.editorModule.setPositionForCurrentIndex(selection.end, this.currentHistoryInfo.selectionEnd);
                    }
                    else {
                        this.owner.editorModule.setPositionForCurrentIndex(selection.start, this.currentHistoryInfo.endPosition);
                        this.owner.editorModule.setPositionForCurrentIndex(selection.end, this.currentHistoryInfo.endPosition);
                    }
                }
                if (this.currentHistoryInfo.action === 'InsertHyperlink') {
                    var startPosition = new selection_helper_1.TextPosition(selection.owner);
                    if (!ej2_base_1.isNullOrUndefined(this.currentHistoryInfo.insertPosition)) {
                        this.owner.editorModule.setPositionForCurrentIndex(startPosition, this.currentHistoryInfo.insertPosition);
                        var endPosition = new selection_helper_1.TextPosition(selection.owner);
                        this.owner.editorModule.setPositionForCurrentIndex(endPosition, this.currentHistoryInfo.endPosition);
                        this.documentHelper.layout.reLayoutParagraph(startPosition.paragraph, 0, 0);
                        if (endPosition.paragraph !== startPosition.paragraph) {
                            this.documentHelper.layout.reLayoutParagraph(endPosition.paragraph, 0, 0);
                        }
                    }
                }
                Iif (this.currentHistoryInfo.action === 'ReplaceAll') {
                    this.documentHelper.contentControlCollection = [];
                    this.owner.editorModule.layoutWholeDocument();
                }
                else if (selection.owner.isShiftingEnabled) {
                    Eif (!ej2_base_1.isNullOrUndefined(selection.editRegionHighlighters)) {
                        selection.editRegionHighlighters.clear();
                    }
                    this.documentHelper.layout.shiftLayoutedItems(false);
                    if (this.owner.enableHeaderAndFooter) {
                        this.owner.editorModule.updateHeaderFooterWidget();
                    }
                    this.documentHelper.removeEmptyPages();
                }
            }
            if (this.owner.showRevisions && !this.owner.editorModule.restrictLayout) {
                this.owner.trackChangesPane.updateTrackChanges();
            }
            selection.owner.isShiftingEnabled = false;
            selection.owner.isLayoutEnabled = true;
            if (!ej2_base_1.isNullOrUndefined(this.currentHistoryInfo) && this.currentHistoryInfo.action === 'ApplyStyle') {
                this.owner.editorModule.getOffsetValue(selection);
            }
            else {
                selection.start.updatePhysicalPosition(true);
                if (selection.isEmpty) {
                    selection.end.setPositionInternal(selection.start);
                }
                else {
                    selection.end.updatePhysicalPosition(true);
                }
            }
            selection.upDownSelectionLength = selection.end.location.x;
            this.documentHelper.isScrollHandler = true;
            Eif (!this.owner.editorModule.restrictLayout) {
                this.viewer.updateScrollBars();
            }
            selection.fireSelectionChanged(true);
            this.documentHelper.isScrollHandler = false;
            Eif (this.owner.enableAutoFocus) {
                this.documentHelper.updateFocus();
            }
            this.updateComplexHistoryInternal();
            if (!this.owner.editorModule.isInsertingTOC) {
                this.owner.editorModule.fireContentChange();
            }
        };
        EditorHistory.prototype.updateComplexHistoryInternal = function () {
            if (!ej2_base_1.isNullOrUndefined(this.currentHistoryInfo)) {
                if (ej2_base_1.isNullOrUndefined(this.currentHistoryInfo.endPosition)) {
                    this.currentHistoryInfo.endPosition = this.currentHistoryInfo.insertPosition;
                }
                if (this.historyInfoStack.length > 1) {
                    var historyInfo = this.historyInfoStack[this.historyInfoStack.length - 2];
                    historyInfo.addModifiedAction(this.currentHistoryInfo);
                }
                else {
                    this.recordChanges(this.currentHistoryInfo);
                }
                this.currentHistoryInfo = undefined;
            }
        };
        EditorHistory.prototype.updateListChangesInHistory = function (currentAbstractList, list) {
            this.currentBaseHistoryInfo = new base_history_info_1.BaseHistoryInfo(this.documentHelper.owner);
            this.currentBaseHistoryInfo.action = 'List';
            this.currentBaseHistoryInfo.updateSelection();
            var collection = new dictionary_1.Dictionary();
            for (var i = 0; i < currentAbstractList.levels.length; i++) {
                var levels = this.documentHelper.getAbstractListById(list.abstractListId).levels[parseInt(i.toString(), 10)];
                this.currentBaseHistoryInfo.addModifiedPropertiesForList(levels);
                var modifiedLevel = new history_helper_1.ModifiedLevel(levels, currentAbstractList.levels[parseInt(i.toString(), 10)]);
                if (!ej2_base_1.isNullOrUndefined(levels)) {
                    this.documentHelper.owner.editorModule.copyListLevel(levels, currentAbstractList.levels[parseInt(i.toString(), 10)]);
                }
                collection.add(i, modifiedLevel);
            }
            return collection;
        };
        EditorHistory.prototype.applyListChanges = function (selection, modifiedLevelsInternal) {
            if (ej2_base_1.isNullOrUndefined(this.modifiedParaFormats)) {
                this.modifiedParaFormats = new dictionary_1.Dictionary();
            }
            var collection = [];
            for (var i = 0; i < this.documentHelper.listParagraphs.length; i++) {
                var paragraph = this.documentHelper.listParagraphs[parseInt(i.toString(), 10)];
                var paraFormat = paragraph.paragraphFormat;
                var currentList = this.documentHelper.getListById(paraFormat.listFormat.listId);
                var listLevel = this.documentHelper.layout.getListLevel(currentList, paraFormat.listFormat.listLevelNumber);
                if (modifiedLevelsInternal.containsKey(paraFormat.listFormat.listLevelNumber)
                    && modifiedLevelsInternal.get(paraFormat.listFormat.listLevelNumber).ownerListLevel === listLevel) {
                    var modifiedFormat = new paragraph_format_1.WParagraphFormat(null);
                    modifiedFormat.leftIndent = paraFormat.leftIndent;
                    modifiedFormat.firstLineIndent = paraFormat.firstLineIndent;
                    var modified = new history_helper_1.ModifiedParagraphFormat(paraFormat, modifiedFormat);
                    collection.push(modified);
                    this.owner.editorModule.copyFromListLevelParagraphFormat(paraFormat, listLevel.paragraphFormat);
                }
            }
            this.modifiedParaFormats.add(this.currentBaseHistoryInfo, collection);
        };
        EditorHistory.prototype.updateListChanges = function (modifiedCollection) {
            this.documentHelper.owner.isLayoutEnabled = false;
            this.owner.editorModule.updateListParagraphs();
            for (var i = 0; i < modifiedCollection.keys.length; i++) {
                var levelNumber = modifiedCollection.keys[parseInt(i.toString(), 10)];
                var modifiedLevel = modifiedCollection.get(levelNumber);
                Eif (!ej2_base_1.isNullOrUndefined(this.currentBaseHistoryInfo)) {
                    modifiedLevel = this.currentBaseHistoryInfo.addModifiedPropertiesForList(modifiedLevel.ownerListLevel);
                }
                this.owner.editorModule.copyListLevel(modifiedLevel.ownerListLevel, modifiedLevel.modifiedListLevel);
            }
            this.documentHelper.owner.isLayoutEnabled = true;
            this.documentHelper.renderedLists.clear();
            this.documentHelper.renderedLevelOverrides = [];
            this.owner.editorModule.layoutWholeDocument();
            var selection = this.documentHelper.selection;
            selection.start.updatePhysicalPosition(true);
            Eif (selection.isEmpty) {
                selection.end.setPositionInternal(selection.start);
            }
            else {
                selection.end.updatePhysicalPosition(true);
            }
            selection.upDownSelectionLength = selection.end.location.x;
            selection.fireSelectionChanged(false);
            this.updateHistory();
        };
        EditorHistory.prototype.undo = function () {
            if ((this.owner.isReadOnlyMode && !this.owner.documentHelper.isCommentOnlyMode &&
                (this.owner.documentHelper.protectionType !== 'FormFieldsOnly')) ||
                !this.canUndo() || !this.owner.enableHistoryMode) {
                return;
            }
            var historyInfo = this.undoStack.pop();
            this.isUndoing = true;
            historyInfo.revert();
            this.isUndoing = false;
            this.owner.selection.contentControleditRegionHighlighters.clear();
            this.owner.selection.onHighlightContentControl();
            this.owner.selectionModule.checkForCursorVisibility();
            this.owner.editorModule.isBordersAndShadingDialog = false;
        };
        EditorHistory.prototype.redo = function () {
            if ((this.owner.isReadOnlyMode && !this.owner.documentHelper.isCommentOnlyMode &&
                (this.owner.documentHelper.protectionType !== 'FormFieldsOnly'))
                || !this.canRedo() || !this.owner.enableHistoryMode) {
                return;
            }
            var historyInfo = this.redoStack.pop();
            if (historyInfo.action === 'BordersAndShading') {
                this.owner.editorModule.isBordersAndShadingDialog = true;
            }
            this.isRedoing = true;
            historyInfo.revert();
            this.isRedoing = false;
            this.owner.selection.contentControleditRegionHighlighters.clear();
            this.owner.selection.onHighlightContentControl();
            this.owner.selectionModule.checkForCursorVisibility();
            this.owner.editorModule.isBordersAndShadingDialog = false;
        };
        EditorHistory.prototype.destroy = function () {
            this.clearHistory();
            this.undoStackIn = undefined;
            this.redoStackIn = undefined;
        };
        EditorHistory.prototype.clearHistory = function () {
            this.clearUndoStack();
            this.clearRedoStack();
        };
        EditorHistory.prototype.clearUndoStack = function () {
            if (this.canUndo()) {
                while (this.undoStack.length > 0) {
                    var historyInfo = this.undoStack.pop();
                    historyInfo.destroy();
                    historyInfo = undefined;
                }
            }
        };
        EditorHistory.prototype.clearRedoStack = function () {
            if (this.canRedo()) {
                while (this.redoStack.length > 0) {
                    var historyInfo = this.redoStack.pop();
                    historyInfo.destroy();
                    historyInfo = undefined;
                }
            }
        };
        return EditorHistory;
    }());
    exports.EditorHistory = EditorHistory;
});