all files / document-editor/implementation/track-changes/ track-changes-pane.js

88.84% Statements 653/735
75.51% Branches 330/437
91.23% Functions 52/57
88.83% Lines 652/734
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 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093   576× 576× 576× 576× 576× 576× 576× 576× 576× 576× 576× 576× 576× 576× 576×   576× 13×           563×         576× 576× 576× 576× 576× 576×           833× 833× 833× 833× 833× 833×           8760×     1330× 1330× 1263×     67× 37×   37× 37× 35×       37× 35×     1330× 1330× 1330× 65×           576× 576× 576× 576× 576× 576× 576× 576× 576× 576× 576×               576× 576× 576×                                                               576× 576× 576× 576× 576× 576× 576× 576×           31×     576× 576× 576× 576× 576× 576×               576× 576× 576× 576× 576×           576× 576× 576×   31× 31× 31× 28× 28× 28×           833× 833× 833× 833× 833×     3384×                   816× 816×     816× 806× 806×   10×                     816× 130×     686×     816× 816× 816× 816× 82× 82× 82×     82× 76×                                     82× 77×   82×   816×   24× 24×     167× 167× 167× 167× 134×     33× 33×       167× 37×   167×   97× 97× 48× 48×     1025× 48× 48× 48×   48× 48× 48× 48× 48× 125× 125×     48× 48× 48× 48× 48× 116×   48×   48×         977×     810× 810× 699× 699× 699×   810×   807×     810× 810× 810× 138× 138× 104×   34× 34× 15× 15× 15× 15×   15× 15× 15×     19×     810× 76× 76× 76× 76× 37×     39×           810× 810× 57× 57×     810× 810× 810× 130× 130× 130×             978× 42× 42×   978× 78× 46× 46×       215× 215×     1812× 69×   1812× 1812× 45× 166× 166× 166×   45×                                   1113× 1113× 1113× 1113× 1113× 1113×   574× 41× 248× 248× 248×   41×   574× 574× 574× 574×   574×     574× 574× 574× 574×   574× 574× 574×   574× 574× 574×   574× 574×   574×   574× 574× 574× 81×     574× 574× 574× 574×       574× 574× 574×   574× 574× 574×   574× 574× 574× 574× 574× 574× 574× 574× 574× 574× 574× 574×   19× 19× 19× 18×               19× 19× 19×   19× 19×                   18× 18× 18×   18×                                 383× 383× 383× 383× 383× 383× 383×         334× 334× 334× 334× 334× 334× 334× 334× 334×       334×   334× 334× 334×   334× 334× 213× 213× 213×   121× 121× 121× 121×                           334× 334× 334×       334× 334×     334× 334×     334× 334×     334× 334× 334× 334× 334× 334× 334× 18×   334× 334×     334× 334× 334× 334× 334× 334× 334× 18×   334× 334× 334× 334× 334×   334× 334×   413× 413× 829× 829×           3466× 3466× 3613× 3466×         919× 919×   919× 919× 919× 919× 919× 919× 919× 3466× 3466× 3466× 3210×   3466× 34×   3466× 510×   2956× 50× 49× 49× 15×         50×   2906× 53× 53×     53× 53× 53× 34×       2872×         2872× 170×   2702× 19×   2702× 678×   2024× 19× 19× 19× 19× 19× 19×   19×                                           2005×         2001× 555× 555× 84× 84× 84× 84× 84× 167× 167×   84×     471× 413×       1446× 1444× 375× 375×   1444× 1444×     1444× 1444×     919× 913×   919× 919× 919×   919× 3210×     2757× 2757× 2757× 1444×   2757×               166× 59×   166×     166× 17×   166×   2791× 2518× 3780× 2252×   3780×       414× 141×   414× 141×   414× 141×     166× 166× 166× 166× 59× 59×   166× 59× 59×   166× 59× 59×     59×   166× 59× 59×     59×   166× 10× 10×   10×   166× 59× 59×     59×   166× 59× 59×     59×   166×   248× 248× 248× 82× 82×   248× 82× 82×   248× 82× 82×     82×   248× 82× 82×     82×   248× 22× 22×   22×   248× 82× 82×     82×   248× 82× 82× 82×   82×   248× 248× 248× 248× 248× 248×        
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-navigations", "@syncfusion/ej2-buttons", "@syncfusion/ej2-splitbuttons", "../viewer/page", "../index", "../editor/editor-helper", "../../base/index"], function (require, exports, ej2_base_1, ej2_navigations_1, ej2_buttons_1, ej2_splitbuttons_1, page_1, index_1, editor_helper_1, index_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var TrackChangesPane = (function () {
        function TrackChangesPane(owner, commentReviewPane) {
            this.users = [];
            this.viewTypeitems = [];
            this.sortedRevisions = [];
            this.noChangesVisibleInternal = true;
            this.enableButtons = true;
            this.owner = owner;
            this.commentReviewPane = commentReviewPane;
            this.locale = new ej2_base_1.L10n('documenteditor', this.owner.defaultLocale);
            this.locale.setLocale(this.owner.locale);
            this.selectedUser = this.locale.getConstant('All');
            this.selectedType = this.locale.getConstant('All');
            this.initTrackChangePane();
            this.commentReviewPane.reviewTab.items[1].content = this.trackChangeDiv;
            Eif (!ej2_base_1.Browser.isIE) {
                this.commentReviewPane.reviewTab.refresh();
            }
            if (this.owner.enableRtl) {
                this.closeButton = ej2_base_1.createElement('button', {
                    className: 'e-de-close-icon e-btn e-flat e-icon-btn', id: 'close',
                    attrs: { type: 'button', style: 'position:absolute;top:6px;left:1px' }
                });
            }
            else {
                this.closeButton = ej2_base_1.createElement('button', {
                    className: 'e-de-close-icon e-btn e-flat e-icon-btn', id: 'close',
                    attrs: { type: 'button', style: 'position:absolute;top:6px;right:1px' }
                });
            }
            this.closeButton.title = this.locale.getConstant('Close');
            this.closeButton.setAttribute('aria-label', this.locale.getConstant('Close'));
            var closeSpan = ej2_base_1.createElement('span', { className: 'e-de-op-close-icon e-de-close-icon e-btn-icon e-icons' });
            this.closeButton.appendChild(closeSpan);
            this.commentReviewPane.reviewTab.element.appendChild(this.closeButton);
            this.closeButton.addEventListener('click', this.commentReviewPane.closePane.bind(this.commentReviewPane));
        }
        Object.defineProperty(TrackChangesPane.prototype, "setNoChangesVisibility", {
            get: function () {
                return this.noChangesVisibleInternal;
            },
            set: function (visible) {
                this.isChangesTabVisible = !visible;
                this.noChangeDivElement.style.display = visible ? 'block' : 'none';
                this.noChangesVisibleInternal = visible;
                this.enableDisableToolbarItem(!visible);
                this.commentReviewPane.reviewTab.hideTab(1, visible);
                this.owner.notify('reviewPane', { changes: !visible, comment: this.commentReviewPane.isCommentTabVisible });
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(TrackChangesPane.prototype, "currentSelectedRevision", {
            get: function () {
                return this.currentSelectedRevisionInternal;
            },
            set: function (value) {
                var selectedElement = ej2_base_1.select('.e-de-trckchanges-inner-select', this.changesInfoDiv);
                if (ej2_base_1.isNullOrUndefined(value)) {
                    if (!ej2_base_1.isNullOrUndefined(selectedElement)) {
                        selectedElement.classList.remove('e-de-trckchanges-inner-select');
                    }
                }
                else if (value !== this.currentSelectedRevisionInternal || ej2_base_1.isNullOrUndefined(selectedElement)) {
                    if (selectedElement) {
                        selectedElement.classList.remove('e-de-trckchanges-inner-select');
                    }
                    var currentChangeView = void 0;
                    if (this.changes.length > 0 && this.changes.containsKey(value)) {
                        currentChangeView = this.changes.get(value);
                    }
                    else Iif (this.renderedChanges.containsKey(value)) {
                        currentChangeView = this.renderedChanges.get(value);
                    }
                    if (currentChangeView && !ej2_base_1.isNullOrUndefined(currentChangeView.singleInnerDiv)) {
                        currentChangeView.singleInnerDiv.classList.add('e-de-trckchanges-inner-select');
                    }
                }
                this.currentSelectedRevisionInternal = value;
                selectedElement = ej2_base_1.select('.e-de-trckchanges-inner-select', this.changesInfoDiv);
                if (!ej2_base_1.isNullOrUndefined(selectedElement)) {
                    selectedElement.parentElement.scrollIntoView({ block: 'nearest' });
                }
            },
            enumerable: true,
            configurable: true
        });
        TrackChangesPane.prototype.initTrackChangePane = function () {
            this.changes = new index_2.Dictionary();
            this.owner.revisions.groupedView = new index_2.Dictionary();
            this.renderedChanges = new index_2.Dictionary();
            this.trackChangeDiv = ej2_base_1.createElement('div', { className: 'e-de-tc-pane' });
            this.trackChangeDiv.appendChild(this.initPaneHeader());
            this.changesInfoDiv = ej2_base_1.createElement('div', { id: 'e-de-tc-pane-revision', styles: 'overflow:auto', className: !this.owner.documentEditorSettings.showHiddenMarks ? 'e-de-tc-hide-para-mark' : '' });
            this.trackChangeDiv.appendChild(this.changesInfoDiv);
            this.noChangeDivElement = ej2_base_1.createElement('div', { styles: 'display:none;', className: 'e-de-tc-no-chng' });
            this.noChangeDivElement.textContent = this.locale.getConstant('No changes');
            this.changesInfoDiv.appendChild(this.noChangeDivElement);
            this.updateTrackChanges();
        };
        TrackChangesPane.prototype.showHiddenParaMark = function () {
            if (!this.owner.documentEditorSettings.showHiddenMarks) {
                if (!this.changesInfoDiv.classList.contains('e-de-tc-hide-para-mark')) {
                    this.changesInfoDiv.classList.add('e-de-tc-hide-para-mark');
                }
            }
            else {
                Eif (this.changesInfoDiv.classList.contains('e-de-tc-hide-para-mark')) {
                    this.changesInfoDiv.classList.remove('e-de-tc-hide-para-mark');
                }
            }
        };
        TrackChangesPane.prototype.initPaneHeader = function () {
            var _this = this;
            this.toolbarElement = ej2_base_1.createElement('div', { className: 'e-de-track-toolbar' });
            this.toolbar = new ej2_navigations_1.Toolbar({
                enableRtl: this.owner.enableRtl,
                items: [
                    {
                        text: this.locale.getConstant('User') + ':', cssClass: 'e-de-track-toolbar-overlay', disabled: true
                    },
                    {
                        template: ej2_base_1.createElement('div', { id: 'e-de-user-list', attrs: { 'role': 'button' } })
                    },
                    {
                        type: 'Separator'
                    },
                    {
                        text: this.locale.getConstant('View') + ':', cssClass: 'e-de-track-toolbar-overlay', disabled: true
                    },
                    {
                        template: ej2_base_1.createElement('div', { id: 'e-de-revision-list', attrs: { 'role': 'button' } })
                    },
                    {
                        prefixIcon: 'e-de-nav-left-arrow e-de-tc-tbr', align: 'Right', cssClass: 'e-de-nvgte-left',
                        tooltipText: this.locale.getConstant('Previous Changes'), click: this.navigatePreviousChanges.bind(this)
                    },
                    {
                        prefixIcon: 'e-de-nav-right-arrow e-de-tc-tbr', align: 'Right', cssClass: 'e-de-nvgte-right',
                        tooltipText: this.locale.getConstant('Next Changes'), click: this.navigateNextChanges.bind(this)
                    },
                    {
                        template: ej2_base_1.createElement('div', { id: 'e-de-menu-option', attrs: { 'role': 'button' } }), align: 'Right', cssClass: 'e-de-tc-tbr',
                        tooltipText: this.locale.getConstant('More Options') + '...'
                    }
                ]
            });
            this.toolbar.appendTo(this.toolbarElement);
            var navigateLeftButton = ej2_base_1.select('.e-de-nvgte-left', this.toolbarElement);
            navigateLeftButton.firstChild.classList.add('e-tc-nvgte');
            var navigateRightButton = ej2_base_1.select('.e-de-nvgte-right', this.toolbarElement);
            navigateRightButton.firstChild.classList.add('e-tc-nvgte');
            var userButtonEle = ej2_base_1.select('#e-de-user-list', this.toolbarElement);
            this.userDropDownitems = [{ text: this.locale.getConstant('All') }];
            this.userDropDown = {
                items: this.userDropDownitems,
                cssClass: 'e-de-track-pane-drop-btn e-tc-btn-bg-clr',
                select: this.onUserSelect.bind(this),
                beforeOpen: this.onUserOpen.bind(this),
                beforeItemRender: function (args) {
                    _this.beforeDropDownItemRender(args, _this.selectedUser);
                }
            };
            this.userDropDownButton = new ej2_splitbuttons_1.DropDownButton(this.userDropDown);
            this.userDropDownButton.appendTo(userButtonEle);
            this.userDropDownButton.content = this.getSpanView(this.userDropDown.items[0].text, 0);
            var viewTypeEle = ej2_base_1.select('#e-de-revision-list', this.toolbarElement);
            this.viewTypeitems = [{ text: this.locale.getConstant('All') }, { text: this.locale.getConstant('Inserted') }, { text: this.locale.getConstant('Deleted') }];
            this.viewTypeDropDownButton = new ej2_splitbuttons_1.DropDownButton({
                items: this.viewTypeitems,
                cssClass: 'e-de-track-pane-drop-btn e-tc-btn-bg-clr',
                select: this.onTypeSelect.bind(this),
                beforeItemRender: function (args) {
                    _this.beforeDropDownItemRender(args, _this.selectedType);
                }
            });
            this.viewTypeDropDownButton.content = this.getSpanView(this.viewTypeitems[0].text, 1);
            this.viewTypeDropDownButton.appendTo(viewTypeEle);
            this.menuoptionEle = ej2_base_1.select('#e-de-menu-option', this.toolbarElement);
            var menuOptions = [{ text: this.locale.getConstant('Accept all') }, { text: this.locale.getConstant('Reject all') }];
            var menuDropDown = {
                items: menuOptions,
                select: this.onMenuSelect.bind(this),
                iconCss: 'e-de-menu-icon',
                cssClass: 'e-caret-hide e-tc-btn-bg-clr'
            };
            this.menuDropDownButton = new ej2_splitbuttons_1.DropDownButton(menuDropDown);
            this.menuDropDownButton.appendTo(this.menuoptionEle);
            return this.toolbarElement;
        };
        TrackChangesPane.prototype.beforeDropDownItemRender = function (args, content) {
            args.element.innerHTML = '<span></span>' + args.item.text;
            var span = args.element.children[0];
            if (args.item.text === content) {
                span.style.marginRight = '10px';
                span.style.alignSelf = 'center';
                span.setAttribute('class', 'e-de-selected-item e-icons');
            }
            else {
                args.element.children[0].style.marginRight = '25px';
                args.element.children[0].classList.remove('e-de-selected-item');
            }
        };
        TrackChangesPane.prototype.onUserOpen = function (arg) {
            var ele = arg.element;
            ele.style.maxHeight = '200px';
            ele.style.overflowY = 'auto';
        };
        TrackChangesPane.prototype.enableDisableToolbarItem = function (enable) {
            var elements = this.toolbar.element.querySelectorAll('.e-de-tc-tbr');
            Eif (this.owner && this.owner.viewer) {
                this.toolbar.enableItems(elements[0].parentElement.parentElement, enable);
                this.toolbar.enableItems(elements[1].parentElement.parentElement, enable);
                this.toolbar.enableItems(elements[2], enable);
            }
        };
        TrackChangesPane.prototype.getSpanView = function (value, type) {
            return (type === 0 ? '<span class="e-de-track-span-user">' : '<span class="e-de-track-span-view">') + value + '</span>';
        };
        TrackChangesPane.prototype.onMenuSelect = function (arg) {
            var _this = this;
            var selectedText = arg.item.text;
            if (selectedText.match(this.locale.getConstant('Accept all'))) {
                setTimeout(function () {
                    _this.owner.revisionsInternal.handleRevisionCollection(true, _this.sortedRevisions);
                }, 0);
            }
            else Eif (selectedText.match(this.locale.getConstant('Reject all'))) {
                setTimeout(function () {
                    _this.owner.revisionsInternal.handleRevisionCollection(false, _this.sortedRevisions);
                }, 0);
            }
            this.updateUsers();
        };
        TrackChangesPane.prototype.onSelection = function (revision) {
            this.currentSelectedRevision = revision;
        };
        TrackChangesPane.prototype.onUserSelect = function (arg) {
            var selectedText = arg.item.text;
            this.selectedUser = selectedText;
            this.userDropDownButton.content = this.getSpanView(selectedText, 0);
            this.sortCollectionToDisplay();
        };
        TrackChangesPane.prototype.onTypeSelect = function (arg) {
            var selectedText = arg.item.text;
            this.selectedType = selectedText;
            this.viewTypeDropDownButton.content = this.getSpanView(selectedText, 1);
            this.sortCollectionToDisplay();
        };
        TrackChangesPane.prototype.updateMenuOptions = function () {
            var revisionType;
            if (this.selectedType !== this.locale.getConstant('All')) {
                revisionType = this.selectedType === this.locale.getConstant('Inserted') ? this.locale.getConstant('Insertion')
                    : this.locale.getConstant('Deletion');
            }
            if (this.selectedUser === this.locale.getConstant('All') && this.selectedType === this.locale.getConstant('All')) {
                this.menuDropDownButton.items[0].text = this.locale.getConstant('Accept all') + ' ' + this.locale.getConstant('Changes');
                this.menuDropDownButton.items[1].text = this.locale.getConstant('Reject all') + ' ' + this.locale.getConstant('Changes');
            }
            else if (this.selectedUser === this.locale.getConstant('All') && this.selectedType !== this.locale.getConstant('All')) {
                this.menuDropDownButton.items[0].text = this.locale.getConstant('Accept all') + ' ' + revisionType;
                this.menuDropDownButton.items[1].text = this.locale.getConstant('Reject all') + ' ' + revisionType;
            }
            else Eif (this.selectedUser !== this.locale.getConstant('All') && this.selectedType === this.locale.getConstant('All')) {
                this.menuDropDownButton.items[0].text = this.locale.getConstant('Accept all') + ' ' + this.locale.getConstant('Changes') +
                    ' ' + this.locale.getConstant('By').toLowerCase() + ' ' + this.selectedUser;
                this.menuDropDownButton.items[1].text = this.locale.getConstant('Reject all') + ' ' + this.locale.getConstant('Changes') +
                    ' ' + this.locale.getConstant('By').toLowerCase() + ' ' + this.selectedUser;
            }
            else {
                this.menuDropDownButton.items[0].text = this.locale.getConstant('Accept all') + ' ' + revisionType +
                    ' ' + this.locale.getConstant('By').toLowerCase() + ' ' + this.selectedUser;
                this.menuDropDownButton.items[1].text = this.locale.getConstant('Reject all') + ' ' + revisionType +
                    ' ' + this.locale.getConstant('By').toLowerCase() + ' ' + this.selectedUser;
            }
            if (this.owner.documentHelper.isDocumentProtected || this.owner.isReadOnly) {
                this.menuDropDownButton.disabled = true;
            }
            else {
                this.menuDropDownButton.disabled = false;
            }
        };
        TrackChangesPane.prototype.sortCollectionToDisplay = function () {
            var isRevisionVisible = false;
            this.sortedRevisions.length = 0;
            this.updateMenuOptions();
            for (var i = 0; i < this.owner.revisions.revisions.length; i++) {
                var changes = this.changes.get(this.owner.revisions.revisions[i]);
                var singleChangesDiv = changes.outerSingleDiv;
                Iif (ej2_base_1.isNullOrUndefined(singleChangesDiv)) {
                    continue;
                }
                if (this.selectedUser === this.locale.getConstant('All') && this.selectedType === this.locale.getConstant('All')) {
                    singleChangesDiv.style.display = 'block';
                }
                else if (this.selectedUser === this.locale.getConstant('All') && this.selectedType !== this.locale.getConstant('All')) {
                    if (this.locale.getConstant(changes.revisionType) === this.selectedType) {
                        singleChangesDiv.style.display = 'block';
                    }
                    else {
                        singleChangesDiv.style.display = 'none';
                    }
                }
                else Eif (this.selectedUser !== this.locale.getConstant('All') && this.selectedType === this.locale.getConstant('All')) {
                    Iif (changes.user === this.selectedUser) {
                        singleChangesDiv.style.display = 'block';
                    }
                    else {
                        singleChangesDiv.style.display = 'none';
                    }
                }
                else {
                    if (changes.user === this.selectedUser && this.locale.getConstant(changes.revisionType) === this.selectedType) {
                        singleChangesDiv.style.display = 'block';
                    }
                    else {
                        singleChangesDiv.style.display = 'none';
                    }
                }
                if (singleChangesDiv.style.display === 'block') {
                    this.sortedRevisions.push(this.owner.revisions.revisions[i]);
                }
                isRevisionVisible = true;
            }
            this.setNoChangesVisibility = !isRevisionVisible;
        };
        TrackChangesPane.prototype.enableDisableButton = function (enableButton, isProtection) {
            this.enableButtons = enableButton;
            if (!isProtection || this.owner.showRevisions) {
                this.updateTrackChanges();
            }
        };
        TrackChangesPane.prototype.isUpdateTrackChanges = function (revisionCount) {
            var isUpdate = false;
            var isNoChangeDiv = false;
            Eif (!ej2_base_1.isNullOrUndefined(this.changesInfoDiv)) {
                if (this.changesInfoDiv.childNodes.length === 1 && this.changesInfoDiv.childNodes[0].className == 'e-de-tc-no-chng') {
                    isNoChangeDiv = true;
                }
                else {
                    Eif (revisionCount !== this.changesInfoDiv.childNodes.length) {
                        isUpdate = true;
                    }
                }
            }
            if ((isNoChangeDiv && this.isChangesTabVisible) || revisionCount > 0) {
                isUpdate = true;
            }
            return isUpdate;
        };
        TrackChangesPane.prototype.updatePendingChangesToView = function () {
            var revision = this.owner.revisions.changes.filter(function (item) { return item.hasChanges; });
            for (var i = 0; i < revision.length; i++) {
                this.updateCurrentTrackChanges(revision[i], true);
                revision[i].hasChanges = false;
            }
        };
        TrackChangesPane.prototype.updateCurrentTrackChanges = function (revision, updateChangeView) {
            if (updateChangeView) {
                var currentChangeView = void 0;
                Eif (!ej2_base_1.isNullOrUndefined(revision)) {
                    currentChangeView = this.owner.trackChangesPane.changes.get(revision);
                }
                Eif (!ej2_base_1.isNullOrUndefined(currentChangeView) && revision.getRange().length > 0) {
                    var changesDiv = undefined;
                    Eif (!ej2_base_1.isNullOrUndefined(currentChangeView.singleInnerDiv)) {
                        changesDiv = currentChangeView.singleInnerDiv.querySelector("#textDiv");
                        while (changesDiv.firstChild) {
                            currentChangeView.removeInnerChilds(changesDiv.firstChild);
                            changesDiv.removeChild(changesDiv.firstChild);
                        }
                    }
                    currentChangeView.tableElement = undefined;
                    currentChangeView.tableWidget = undefined;
                    var revisions = this.owner.revisions.groupedView.get(currentChangeView);
                    var ranges = [];
                    for (var i = 0; i < revisions.length; i++) {
                        ranges = ranges.concat(revisions[i].getRange());
                    }
                    currentChangeView.layoutElementText(revision, ranges, changesDiv);
                }
                Iif (!ej2_base_1.isNullOrUndefined(revision) && revision.getRange().length === 0) {
                    this.owner.revisions.remove(revision);
                }
            }
            else {
                revision.hasChanges = true;
            }
        };
        TrackChangesPane.prototype.updateTrackChanges = function (show) {
            Eif (show || ej2_base_1.isNullOrUndefined(show)) {
                if (!this.owner.isUpdateTrackChanges) {
                    this.renderedChanges.clear();
                    this.removeAllChanges();
                    this.owner.revisions.groupedView.clear();
                }
                if (!this.enableButtons && !this.menuoptionEle.classList.contains('e-de-overlay')) {
                    this.menuoptionEle.classList.add('e-de-overlay');
                }
                else Iif (this.menuoptionEle.classList.contains('e-de-overlay') && !this.owner.documentHelper.isDocumentProtected && !this.owner.isReadOnly) {
                    this.menuoptionEle.classList.remove('e-de-overlay');
                }
                this.isChangesTabVisible = true;
                this.owner.notify('reviewPane', { comment: this.commentReviewPane.isCommentTabVisible, changes: this.isChangesTabVisible });
                for (var i = 0; i < this.owner.revisions.changes.length; i++) {
                    var revision = this.owner.revisions.changes[i];
                    if (!ej2_base_1.isNullOrUndefined(this.changes.get(revision))) {
                        continue;
                    }
                    var previousRevision = this.owner.revisions.checkAndGetPreviousRevisionToCombine(revision);
                    if (previousRevision) {
                        var changeSingleView = this.changes.get(previousRevision);
                        var changesDiv = undefined;
                        Eif (!ej2_base_1.isNullOrUndefined(changeSingleView.singleInnerDiv)) {
                            changesDiv = changeSingleView.singleInnerDiv.querySelector("#textDiv");
                        }
                        changeSingleView.layoutElementText(revision, revision.getRange(false), changesDiv);
                        this.owner.revisions.groupedView.get(changeSingleView).push(revision);
                        this.changes.add(revision, changeSingleView);
                    }
                    else {
                        this.addChanges(revision, revision.getRange(false));
                    }
                }
                for (var i = 0; i < this.owner.revisions.revisions.length; i++) {
                    var revision = this.owner.revisions.revisions[i];
                    var currentChangeView = this.changes.get(revision);
                    Eif (!ej2_base_1.isNullOrUndefined(currentChangeView) && !ej2_base_1.isNullOrUndefined(currentChangeView.acceptButtonElement) && !ej2_base_1.isNullOrUndefined(currentChangeView.rejectButtonElement)) {
                        if (!this.enableButtons) {
                            if (!(currentChangeView.acceptButtonElement.classList.contains('e-de-hide-track-btn'))) {
                                currentChangeView.acceptButtonElement.classList.add('e-de-hide-track-btn');
                                currentChangeView.rejectButtonElement.classList.add('e-de-hide-track-btn');
                            }
                        }
                        else Iif (currentChangeView.acceptButtonElement.classList.contains('e-de-hide-track-btn') && !this.owner.documentHelper.isTrackedOnlyMode) {
                            currentChangeView.acceptButtonElement.classList.remove('e-de-hide-track-btn');
                            currentChangeView.rejectButtonElement.classList.remove('e-de-hide-track-btn');
                        }
                    }
                }
                var totalCount = document.getElementsByClassName('e-de-track-chngs-count').length;
                for (var i = 0; i < totalCount; i++) {
                    var div = document.getElementsByClassName('e-de-track-chngs-count')[i];
                    div.innerHTML = this.locale.getConstant('Changes') + ' ' + (i + 1).toString() +
                        ' ' + this.locale.getConstant('of') + ' ' + totalCount.toString();
                }
                this.sortCollectionToDisplay();
                this.updateUsers();
                if (show) {
                    this.currentSelectedRevision = this.currentSelectedRevisionInternal;
                    this.updateHeight();
                    this.owner.resize();
                }
            }
            else {
                this.currentSelectedRevision = undefined;
            }
        };
        TrackChangesPane.prototype.updateUsers = function () {
            if (!ej2_base_1.isNullOrUndefined(this.users) && this.users.length > 0) {
                this.userDropDownButton.removeItems(this.users);
                this.users = [];
            }
            for (var i = 0; i < this.owner.revisions.revisions.length; i++) {
                if (!ej2_base_1.isNullOrUndefined(this.users) && !ej2_base_1.isNullOrUndefined(this.userDropDownButton) && this.users.indexOf(this.owner.revisions.revisions[i].author) === -1) {
                    this.users.push(this.owner.revisions.revisions[i].author);
                    this.userDropDownButton.items.push({ text: this.owner.revisions.revisions[i].author });
                }
            }
        };
        TrackChangesPane.prototype.updateHeight = function () {
            var tabHeaderHeight = this.commentReviewPane.reviewTab.getRootElement().getElementsByClassName('e-tab-header')[0].getBoundingClientRect().height;
            this.changesInfoDiv.style.height = this.commentReviewPane.parentPaneElement.clientHeight - this.toolbarElement.clientHeight
                - tabHeaderHeight - 2 + 'px';
        };
        TrackChangesPane.prototype.removeAllChanges = function () {
            while (this.changesInfoDiv.childNodes.length > 1) {
                this.changesInfoDiv.removeChild(this.changesInfoDiv.lastChild);
            }
            this.owner.revisions.revisions.length = 0;
            if (this.changes && this.changes.length > 0) {
                for (var i = 0; i < this.changes.length; i++) {
                    var revision = this.changes.keys[i];
                    var changesSingleView = this.changes.get(revision);
                    changesSingleView.clear();
                }
                this.changes.clear();
            }
        };
        TrackChangesPane.prototype.setDateInternal = function (revision) {
            var date = revision.date;
            var startTextPosition = new index_1.TextPosition(this.owner);
            var endTextPosition = new index_1.TextPosition(this.owner);
            this.owner.selection.selectRevision(revision, startTextPosition, endTextPosition);
            var endIndex = this.owner.selectionModule.getAbsolutePositionFromRelativePosition(endTextPosition);
            var currentChangeView;
            if (!ej2_base_1.isNullOrUndefined(revision)) {
                currentChangeView = this.owner.trackChangesPane.changes.get(revision);
            }
            if (!ej2_base_1.isNullOrUndefined(currentChangeView)) {
                var dateView = currentChangeView.singleInnerDiv.querySelector('.e-de-track-date');
                dateView.textContent = editor_helper_1.HelperMethods.getModifiedDate(revision.date);
                this.owner.getRevisionData(endIndex, date);
            }
        };
        TrackChangesPane.prototype.clear = function () {
            this.removeAllChanges();
            this.selectedUser = this.locale.getConstant('All');
            this.userDropDownButton.content = this.getSpanView(this.selectedUser, 0);
            this.selectedType = this.locale.getConstant('All');
            this.viewTypeDropDownButton.content = this.getSpanView(this.selectedType, 1);
            this.currentSelectedRevision = undefined;
        };
        TrackChangesPane.prototype.destroy = function () {
            if (this.changes && this.changes.length > 0) {
                for (var i = 0; i < this.changes.length; i++) {
                    var revision = this.changes.keys[i];
                    var changesSingleView = this.changes.get(revision);
                    changesSingleView.destroy();
                }
                this.changes.clear();
            }
            this.changes = undefined;
            Eif (this.toolbar) {
                this.toolbar.destroy();
                this.toolbar = undefined;
            }
            Iif (this.closeButton && this.closeButton.parentElement) {
                this.closeButton.parentElement.removeChild(this.closeButton);
            }
            this.closeButton = undefined;
            Eif (this.userDropDownButton) {
                this.userDropDownButton.destroy();
                this.userDropDownButton = undefined;
            }
            Eif (this.menuDropDownButton) {
                this.menuDropDownButton.destroy();
                this.menuDropDownButton = undefined;
            }
            Eif (this.viewTypeDropDownButton) {
                this.viewTypeDropDownButton.destroy();
                this.viewTypeDropDownButton = undefined;
            }
            Eif (this.userDropDown) {
                this.userDropDown = undefined;
            }
            if (this.users.length > 0) {
                this.users = [];
                this.users = undefined;
            }
            Eif (this.trackChangeDiv) {
                this.trackChangeDiv.innerHTML = '';
                if (this.trackChangeDiv.parentElement) {
                    this.trackChangeDiv.parentElement.removeChild(this.trackChangeDiv);
                }
            }
            this.trackChangeDiv = undefined;
            Eif (this.changesInfoDiv) {
                this.changesInfoDiv.innerHTML = '';
                Iif (this.changesInfoDiv.parentElement) {
                    this.changesInfoDiv.parentElement.removeChild(this.changesInfoDiv);
                }
            }
            this.changesInfoDiv = undefined;
            Eif (this.commentReviewPane) {
                this.commentReviewPane = undefined;
            }
            Eif (this.renderedChanges) {
                this.renderedChanges.destroy();
                this.renderedChanges = undefined;
            }
            this.currentSelectedRevisionInternal = undefined;
            this.selectedUser = undefined;
            this.selectedType = undefined;
            this.sortedRevisions = [];
            this.sortedRevisions = undefined;
            this.viewTypeitems = [];
            this.viewTypeitems = undefined;
            this.userDropDownitems = [];
            this.userDropDownitems = undefined;
            this.owner.revisions.revisions = [];
            this.owner.revisions.revisions = undefined;
            this.owner = undefined;
        };
        TrackChangesPane.prototype.addChanges = function (revision, groupedRange) {
            var currentChangeView = new ChangesSingleView(this.owner, this);
            this.changesInfoDiv.appendChild(currentChangeView.createSingleChangesDiv(revision));
            if (!this.enableButtons) {
                Iif (!(currentChangeView.acceptButtonElement.classList.contains('e-de-hide-track-btn'))) {
                    currentChangeView.acceptButtonElement.classList.add('e-de-hide-track-btn');
                    currentChangeView.rejectButtonElement.classList.add('e-de-hide-track-btn');
                }
            }
            else Iif (currentChangeView.acceptButtonElement.classList.contains('e-de-hide-track-btn') && !this.owner.documentHelper.isTrackedOnlyMode) {
                currentChangeView.acceptButtonElement.classList.remove('e-de-hide-track-btn');
                currentChangeView.rejectButtonElement.classList.remove('e-de-hide-track-btn');
            }
            this.layoutGroupedRange(revision, groupedRange, currentChangeView);
            this.owner.revisions.revisions.push(revision);
            this.changes.add(revision, currentChangeView);
        };
        TrackChangesPane.prototype.layoutGroupedRange = function (revision, groupedRange, currentChangeView) {
            Eif (groupedRange.length > 0) {
                if (groupedRange[0] instanceof index_1.WRowFormat) {
                    var revisions = [];
                    for (var i = 0; i < groupedRange.length; i++) {
                        revisions.push(groupedRange[i].getRevision(groupedRange[i].revisionLength - 1));
                        Eif (i === 0) {
                            var changesDiv = undefined;
                            Eif (!ej2_base_1.isNullOrUndefined(currentChangeView.singleInnerDiv)) {
                                changesDiv = currentChangeView.singleInnerDiv.querySelector("#textDiv");
                            }
                            currentChangeView.layoutElementText(revision, groupedRange, changesDiv);
                        }
                        else {
                            currentChangeView.appendRowToTable(groupedRange[i], i);
                            this.changes.add(groupedRange[i].getRevision(groupedRange[i].revisionLength - 1), currentChangeView);
                        }
                    }
                    this.owner.revisions.groupedView.add(currentChangeView, revisions);
                }
                else {
                    var changesDiv = undefined;
                    Eif (!ej2_base_1.isNullOrUndefined(currentChangeView.singleInnerDiv)) {
                        changesDiv = currentChangeView.singleInnerDiv.querySelector("#textDiv");
                    }
                    currentChangeView.layoutElementText(revision, groupedRange, changesDiv);
                }
            }
        };
        TrackChangesPane.prototype.navigatePreviousChanges = function () {
            this.revisionNavigateInternal(false);
        };
        TrackChangesPane.prototype.navigateNextChanges = function () {
            this.revisionNavigateInternal(true);
        };
        TrackChangesPane.prototype.revisionNavigateInternal = function (next) {
            var changes = this.owner.revisions.revisions;
            Iif (!this.currentSelectedRevisionInternal) {
                if (changes.length === 0) {
                    return;
                }
                this.currentSelectedRevision = changes[0];
            }
            Eif (this.currentSelectedRevision) {
                var revisions = changes;
                var revision = this.currentSelectedRevision;
                var index = revisions.indexOf(revision);
                if (next) {
                    revision = (index === (revisions.length - 1)) ? revisions[0] : revisions[index + 1];
                }
                else {
                    revision = index === 0 ? revisions[revisions.length - 1] : revisions[index - 1];
                }
                this.owner.documentHelper.currentSelectedRevision = revision;
                this.owner.selectionModule.selectRevision(revision);
            }
            this.currentSelectedRevision = this.owner.documentHelper.currentSelectedRevision;
        };
        return TrackChangesPane;
    }());
    exports.TrackChangesPane = TrackChangesPane;
    var ChangesSingleView = (function () {
        function ChangesSingleView(owner, trackChangesPane) {
            this.selectRevisionHandler = this.selectRevision.bind(this);
            this.acceptButtonClickHandler = this.acceptButtonClick.bind(this);
            this.rejectButtonClickHandler = this.rejectButtonClick.bind(this);
            this.owner = owner;
            this.locale = new ej2_base_1.L10n('documenteditor', this.owner.defaultLocale);
            this.locale.setLocale(this.owner.locale);
            this.trackChangesPane = trackChangesPane;
        }
        ChangesSingleView.prototype.updateRevisionIndexAndCount = function (currentIndex, totalCount) {
            this.changesCount.innerHTML = this.locale.getConstant('Changes') + ' ' + currentIndex.toString() +
                ' ' + this.locale.getConstant('of') + ' ' + totalCount.toString();
        };
        ChangesSingleView.prototype.createSingleChangesDiv = function (revision) {
            this.revision = revision;
            this.user = revision.author;
            this.outerSingleDiv = ej2_base_1.createElement('div', { className: 'e-de-tc-outer' });
            this.singleInnerDiv = ej2_base_1.createElement('div', { className: 'e-de-trckchanges-inner' });
            this.singleInnerDiv.addEventListener('click', this.selectRevisionHandler);
            this.outerSingleDiv.appendChild(this.singleInnerDiv);
            var userNameTotalDiv = ej2_base_1.createElement('div', { className: 'e-de-track-usernme-div' });
            var userNameLabel = ej2_base_1.createElement('div', { className: 'e-de-track-user-nme' });
            Iif (!ej2_base_1.isNullOrUndefined(revision.customData) && revision.customData != '' && this.owner.documentEditorSettings.revisionSettings.showCustomDataWithAuthor) {
                userNameLabel.textContent = ej2_base_1.SanitizeHtmlHelper.sanitize(revision.author) + " [" + revision.customData + "]";
            }
            else {
                userNameLabel.textContent = ej2_base_1.SanitizeHtmlHelper.sanitize(revision.author);
            }
            Eif (!ej2_base_1.isNullOrUndefined(revision.author)) {
                userNameTotalDiv.style.display = 'flex';
                this.owner.documentHelper.getAvatar(userNameTotalDiv, userNameLabel, undefined, revision);
            }
            var revisionTypeLabel = ej2_base_1.createElement('div');
            if (revision.revisionType === 'Insertion') {
                this.revisionType = 'Inserted';
                revisionTypeLabel.innerHTML = this.locale.getConstant('Inserted').toUpperCase();
                revisionTypeLabel.classList.add('e-de-track-insert');
            }
            else Eif (revision.revisionType === 'Deletion') {
                this.revisionType = 'Deleted';
                revisionTypeLabel.innerHTML = this.locale.getConstant('Deleted').toUpperCase();
                revisionTypeLabel.classList.add('e-de-track-delete');
            }
            else if (revision.revisionType === 'MoveFrom') {
                this.revisionType = 'MoveFrom';
                revisionTypeLabel.innerHTML = this.locale.getConstant('Move From').toUpperCase();
                revisionTypeLabel.classList.add('e-de-track-delete');
                revisionTypeLabel.style.whiteSpace = 'nowrap';
            }
            else if (revision.revisionType === 'MoveTo') {
                this.revisionType = 'MoveTo';
                revisionTypeLabel.innerHTML = this.locale.getConstant('Move To').toUpperCase();
                revisionTypeLabel.classList.add('e-de-track-insert');
                revisionTypeLabel.style.whiteSpace = 'nowrap';
            }
            userNameTotalDiv.appendChild(revisionTypeLabel);
            this.singleInnerDiv.appendChild(userNameTotalDiv);
            var dateView = ej2_base_1.createElement('div', {
                className: 'e-de-track-date',
                innerHTML: editor_helper_1.HelperMethods.getModifiedDate(revision.date)
            });
            this.singleInnerDiv.appendChild(dateView);
            var changesTextDiv = ej2_base_1.createElement('div', { id: 'textDiv',
                className: 'e-de-track-chngs-text'
            });
            this.singleInnerDiv.appendChild(changesTextDiv);
            var buttonTotalDiv = ej2_base_1.createElement('div', {
                styles: 'display:inline-block;width:100%'
            });
            this.singleInnerDiv.appendChild(buttonTotalDiv);
            var buttonDiv = ej2_base_1.createElement('div', {
                styles: 'float:left;'
            });
            this.acceptButtonElement = ej2_base_1.createElement('button', { className: 'e-de-track-accept-button' });
            this.acceptButton = new ej2_buttons_1.Button({ cssClass: 'e-outline e-success', content: this.locale.getConstant('Accept') });
            this.acceptButtonElement.setAttribute('aria-label', this.locale.getConstant('Accept'));
            buttonDiv.appendChild(this.acceptButtonElement);
            buttonTotalDiv.appendChild(buttonDiv);
            this.acceptButton.appendTo(this.acceptButtonElement);
            if (this.owner.documentHelper.isTrackedOnlyMode) {
                this.acceptButtonElement.classList.add('e-de-hide-track-btn');
            }
            this.acceptButtonElement.addEventListener('click', this.acceptButtonClickHandler);
            buttonDiv = ej2_base_1.createElement('div', {
                styles: 'float:left;'
            });
            this.rejectButtonElement = ej2_base_1.createElement('button', { className: 'e-de-track-reject-button' });
            this.rejectButton = new ej2_buttons_1.Button({ cssClass: 'e-outline e-danger', content: this.locale.getConstant('Reject') });
            this.rejectButtonElement.setAttribute('aria-label', this.locale.getConstant('Reject'));
            buttonDiv.appendChild(this.rejectButtonElement);
            buttonTotalDiv.appendChild(buttonDiv);
            this.rejectButton.appendTo(this.rejectButtonElement);
            if (this.owner.documentHelper.isTrackedOnlyMode) {
                this.rejectButtonElement.classList.add('e-de-hide-track-btn');
            }
            this.rejectButtonElement.addEventListener('click', this.rejectButtonClickHandler);
            this.changesCount = ej2_base_1.createElement('div', { className: 'e-de-track-chngs-count', styles: 'float:right;' });
            var currentCount = this.owner.revisions.changes.indexOf(revision) + 1;
            var totalCount = this.owner.revisions.changes.length;
            this.changesCount.innerHTML = this.locale.getConstant('Changes') + ' ' + currentCount.toString() +
                ' ' + this.locale.getConstant('of') + ' ' + totalCount.toString();
            buttonTotalDiv.appendChild(this.changesCount);
            return this.outerSingleDiv;
        };
        ChangesSingleView.prototype.appendRowToTable = function (rowFormat, insertIndex) {
            this.tableElement.insertRow();
            for (var k = 0; k < rowFormat.ownerBase.childWidgets.length; k++) {
                this.tableElement.rows[insertIndex].insertCell();
                this.tableElement.rows[insertIndex].cells[k].classList.add('e-de-tc-tble-cell');
            }
        };
        ChangesSingleView.prototype.selectRevision = function () {
            this.owner.selectionModule.selectRevision(this.revision);
            this.trackChangesPane.onSelection(this.revision);
        };
        ChangesSingleView.prototype.compareAndGetSameTypeRevision = function (currentRevision, revisionToCompare) {
            var revisionType = currentRevision.revisionType;
            for (var i = 0; i < revisionToCompare.length; i++) {
                if (revisionType === revisionToCompare[i].revisionType) {
                    return revisionToCompare[i];
                }
            }
            return undefined;
        };
        ChangesSingleView.prototype.layoutElementText = function (revision, range, changesText, skipUpdate) {
            Eif (changesText) {
                changesText.style.width = '100%';
            }
            var fragment = document.createDocumentFragment();
            var text = '';
            var toSkip = false;
            var isHyperlinkField = false;
            var revisions = [];
            var tocFieldDepth = 0;
            for (var i = 0; i < range.length; i++) {
                var element = range[i];
                var currentRevision = this.compareAndGetSameTypeRevision(revision, element.getAllRevision());
                if (revisions.length === 0 || revisions.indexOf(currentRevision) === -1) {
                    revisions.push(currentRevision);
                }
                if (!this.trackChangesPane.changes.containsKey(currentRevision)) {
                    this.trackChangesPane.changes.add(currentRevision, this);
                }
                if (!ej2_base_1.isNullOrUndefined(this.tableElement) && (element instanceof page_1.ElementBox || element instanceof index_1.WCharacterFormat)) {
                    continue;
                }
                if (element instanceof page_1.FieldElementBox && element.fieldType === 1) {
                    if (tocFieldDepth > 0) {
                        tocFieldDepth--;
                        if (tocFieldDepth === 0) {
                            toSkip = false;
                        }
                    }
                    else {
                        toSkip = false;
                    }
                    continue;
                }
                if (element instanceof page_1.FieldElementBox && element.fieldType === 0) {
                    var fieldCode = this.owner.selectionModule.getFieldCode(element);
                    Iif (fieldCode.match('HYPERLINK ') && range[range.indexOf(element.fieldEnd) - 1] instanceof page_1.TextElementBox) {
                        isHyperlinkField = true;
                    }
                    Eif (fieldCode.match('TOC ') || fieldCode.match('Toc')) {
                        tocFieldDepth++;
                        if (tocFieldDepth > 1) {
                            continue;
                        }
                    }
                }
                Iif (isHyperlinkField && element instanceof page_1.FieldElementBox && (element.fieldType === 2 || element.fieldType === 1)) {
                    toSkip = false;
                    isHyperlinkField = false;
                    continue;
                }
                if (toSkip || element instanceof page_1.ChartElementBox) {
                    continue;
                }
                if (element instanceof page_1.FieldElementBox && element.fieldType === 0) {
                    toSkip = true;
                }
                if (element instanceof page_1.TextElementBox) {
                    text += element.text;
                }
                else if (element instanceof page_1.FieldElementBox && element.fieldType === 0) {
                    var fieldCode = this.owner.selectionModule.getFieldCode(element);
                    Eif (fieldCode.match('TOC ') || fieldCode.match('Toc')) {
                        Eif (tocFieldDepth === 1) {
                            text += '<Table of Content>';
                            fragment.appendChild(this.addSpan(text));
                            text = '';
                        }
                        continue;
                    }
                    else if ((fieldCode.match('HYPERLINK ') && !isHyperlinkField) || fieldCode.match('MERGEFIELD') || fieldCode.match('FORMTEXT') || fieldCode.match('PAGE ')) {
                        text += this.owner.editorModule.retrieveFieldResultantText(element.fieldEnd);
                    }
                    else if (element.formFieldData) {
                        var emptyChar = this.owner.documentHelper.textHelper.repeatChar(this.owner.documentHelper.textHelper.getEnSpaceCharacter(), 5);
                        if (text !== '') {
                            fragment.appendChild(this.addSpan(text));
                            text = '';
                        }
                        if (element.formFieldData instanceof page_1.TextFormField) {
                            fragment.appendChild(this.addSpan(element.formFieldData.defaultValue === '' ? emptyChar : element.formFieldData.defaultValue, 'e-de-tc-field'));
                        }
                        else if (element.formFieldData instanceof page_1.DropDownFormField) {
                            fragment.appendChild(this.addSpan(element.formFieldData.dropdownItems.length > 0 ? element.formFieldData.dropdownItems[0] : emptyChar, 'e-de-tc-field'));
                        }
                        else {
                            fragment.appendChild(this.addSpan(element.formFieldData.checked ? String.fromCharCode(9745) : String.fromCharCode(9744), 'e-de-tc-field'));
                        }
                    }
                }
                else if (element instanceof page_1.ImageElementBox) {
                    Iif (text !== '') {
                        fragment.appendChild(this.addSpan(text));
                        text = '';
                    }
                    var imageEle = ej2_base_1.createElement('img');
                    imageEle.setAttribute('src', this.owner.documentHelper.getImageString(element));
                    imageEle.classList.add('e-de-tc-shrink-img');
                    fragment.appendChild(imageEle);
                }
                else if (element instanceof index_1.WRowFormat) {
                    var table = element.ownerBase.ownerTable.getSplitWidgets()[0];
                    if (ej2_base_1.isNullOrUndefined(this.tableElement)) {
                        this.tableWidget = table;
                        this.tableElement = ej2_base_1.createElement('table');
                        this.tableElement.classList.add('e-de-track-chng-table');
                        this.tableElement.insertRow();
                        for (var i_1 = 0; i_1 < element.ownerBase.childWidgets.length; i_1++) {
                            this.tableElement.rows[0].insertCell();
                            this.tableElement.rows[0].cells[i_1].classList.add('e-de-tc-tble-cell');
                        }
                        fragment.appendChild(this.tableElement);
                    }
                    else {
                        if (this.tableWidget === table) {
                            this.appendRowToTable(element, this.tableElement.rows.length);
                        }
                    }
                }
                else if (element instanceof index_1.WCharacterFormat) {
                    if (text !== '') {
                        fragment.appendChild(this.addSpan(text));
                        text = '';
                    }
                    var paraMark = '¶';
                    Iif (element.ownerBase instanceof page_1.ParagraphWidget && element.ownerBase.isEndsWithPageBreak) {
                        paraMark = '............Page Break............' + paraMark;
                    }
                    fragment.appendChild(this.addSpan(paraMark, 'e-de-tc-pmark'));
                    fragment.appendChild(ej2_base_1.createElement('br'));
                }
            }
            if (!skipUpdate) {
                this.owner.revisions.groupedView.add(this, revisions);
            }
            fragment.appendChild(this.addSpan(text));
            Eif (changesText) {
                changesText.appendChild(fragment);
            }
            for (var j = 0; j < revisions.length; j++) {
                this.trackChangesPane.renderedChanges.add(revisions[j], this);
            }
        };
        ChangesSingleView.prototype.addSpan = function (text, cssClass) {
            var span = ej2_base_1.createElement('span');
            span.textContent = text;
            if (cssClass) {
                span.classList.add(cssClass);
            }
            return span;
        };
        ChangesSingleView.prototype.acceptButtonClick = function () {
            this.revision.accept();
            Iif (this.owner.enableHeaderAndFooter) {
                this.owner.editorModule.updateHeaderFooterWidget();
            }
        };
        ChangesSingleView.prototype.rejectButtonClick = function () {
            this.revision.reject();
            Iif (this.owner.enableHeaderAndFooter) {
                this.owner.editorModule.updateHeaderFooterWidget();
            }
        };
        ChangesSingleView.prototype.removeFromParentCollec = function () {
            if (!ej2_base_1.isNullOrUndefined(this.revision) && this.trackChangesPane.changes.containsKey(this.revision)) {
                this.trackChangesPane.changes.remove(this.revision);
            }
            Iif (!ej2_base_1.isNullOrUndefined(this.revision) && this.owner.revisions.revisions.indexOf(this.revision) !== -1) {
                this.owner.revisions.revisions.splice(this.owner.revisions.revisions.indexOf(this.revision), 1);
            }
            if (this.trackChangesPane.changes.length === 0) {
                this.trackChangesPane.setNoChangesVisibility = true;
            }
            this.trackChangesPane.updateUsers();
        };
        ChangesSingleView.prototype.removeInnerChilds = function (element) {
            if (element) {
                while (element.firstChild) {
                    if (element.firstChild.childNodes.length > 0) {
                        this.removeInnerChilds(element.firstChild);
                    }
                    element.removeChild(element.firstChild);
                }
            }
        };
        ChangesSingleView.prototype.removeEvents = function () {
            if (this.outerSingleDiv) {
                this.outerSingleDiv.removeEventListener('click', this.selectRevisionHandler);
            }
            if (this.acceptButtonElement) {
                this.acceptButtonElement.removeEventListener('click', this.acceptButtonClickHandler);
            }
            if (this.rejectButtonElement) {
                this.rejectButtonElement.removeEventListener('click', this.rejectButtonClickHandler);
            }
        };
        ChangesSingleView.prototype.clear = function () {
            this.removeFromParentCollec();
            this.removeEvents();
            this.removeInnerChilds(this.outerSingleDiv);
            if (this.acceptButton) {
                this.acceptButton.destroy();
                this.acceptButton = undefined;
            }
            if (this.rejectButton) {
                this.rejectButton.destroy();
                this.rejectButton = undefined;
            }
            if (this.acceptButtonElement) {
                this.acceptButtonElement.innerHTML = '';
                Iif (this.acceptButtonElement.parentElement) {
                    this.acceptButtonElement.parentElement.removeChild(this.acceptButtonElement);
                }
                this.acceptButtonElement = undefined;
            }
            if (this.rejectButtonElement) {
                this.rejectButtonElement.innerHTML = '';
                Iif (this.rejectButtonElement.parentElement) {
                    this.rejectButtonElement.parentElement.removeChild(this.rejectButtonElement);
                }
                this.rejectButtonElement = undefined;
            }
            if (this.tableElement) {
                this.tableElement.innerHTML = '';
                if (this.tableElement.parentElement) {
                    this.tableElement.parentElement.removeChild(this.tableElement);
                }
                this.tableElement = undefined;
            }
            if (this.singleInnerDiv) {
                this.singleInnerDiv.innerHTML = '';
                Iif (this.singleInnerDiv.parentElement) {
                    this.singleInnerDiv.parentElement.removeChild(this.singleInnerDiv);
                }
                this.singleInnerDiv = undefined;
            }
            if (this.outerSingleDiv) {
                this.outerSingleDiv.innerHTML = '';
                Iif (this.outerSingleDiv.parentElement) {
                    this.outerSingleDiv.parentElement.removeChild(this.outerSingleDiv);
                }
                this.outerSingleDiv = undefined;
            }
            this.tableWidget = undefined;
        };
        ChangesSingleView.prototype.destroy = function () {
            this.removeEvents();
            this.removeInnerChilds(this.outerSingleDiv);
            if (this.acceptButton) {
                this.acceptButton.destroy();
                this.acceptButton = undefined;
            }
            if (this.rejectButton) {
                this.rejectButton.destroy();
                this.rejectButton = undefined;
            }
            if (this.acceptButtonElement) {
                this.acceptButtonElement.innerHTML = '';
                Iif (this.acceptButtonElement.parentElement) {
                    this.acceptButtonElement.parentElement.removeChild(this.acceptButtonElement);
                }
                this.acceptButtonElement = undefined;
            }
            if (this.rejectButtonElement) {
                this.rejectButtonElement.innerHTML = '';
                Iif (this.rejectButtonElement.parentElement) {
                    this.rejectButtonElement.parentElement.removeChild(this.rejectButtonElement);
                }
                this.rejectButtonElement = undefined;
            }
            if (this.tableElement) {
                this.tableElement.innerHTML = '';
                if (this.tableElement.parentElement) {
                    this.tableElement.parentElement.removeChild(this.tableElement);
                }
                this.tableElement = undefined;
            }
            if (this.singleInnerDiv) {
                this.singleInnerDiv.innerHTML = '';
                Iif (this.singleInnerDiv.parentElement) {
                    this.singleInnerDiv.parentElement.removeChild(this.singleInnerDiv);
                }
                this.singleInnerDiv = undefined;
            }
            if (this.outerSingleDiv) {
                this.outerSingleDiv.innerHTML = '';
                Eif (this.outerSingleDiv.parentElement) {
                    this.outerSingleDiv.parentElement.removeChild(this.outerSingleDiv);
                }
                this.outerSingleDiv = undefined;
            }
            this.revision = undefined;
            this.user = undefined;
            this.revisionType = undefined;
            this.trackChangesPane = undefined;
            this.owner = undefined;
            this.tableWidget = undefined;
        };
        return ChangesSingleView;
    }());
    exports.ChangesSingleView = ChangesSingleView;
});