all files / document-editor-container/properties-pane/ text-properties.js

67.14% Statements 382/569
30.11% Branches 81/269
43.86% Functions 25/57
67.08% Lines 381/568
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   60× 60× 60× 60× 60×                         60×         60×     60×       60× 60× 60×   60×                                                                     60× 60×     1594×         60× 60× 60× 60× 60× 60× 60× 60×   60× 60×     60× 60× 60× 60× 60× 60×   60×     60× 60× 60× 60×     60×   60× 60×     60× 60× 60× 60× 60× 60× 60×   60× 60× 60× 60× 60×     60×   60× 60×   60× 60× 60× 60× 60× 60× 60× 60× 60× 60×     60×   60× 60× 60×   60× 60× 60× 60×         60× 60×     60× 60× 60× 60×           60×       60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60× 60×   900× 900× 900× 900×             65× 65× 65×                                                                                               65× 65× 65× 65× 65× 65× 65× 65× 65× 65× 65× 65× 65× 65× 65×                                                                                         240× 240× 60×     180×   240× 240×   420× 420× 420×     420× 420× 420× 420× 420×   60× 60×   60× 60×   60× 60×   60× 60×   60× 60×   60× 60×   60×   420×   60× 60× 60× 60× 60× 60× 60× 60× 60×   60× 60× 60×               60×       60× 60× 60× 60×   60× 60× 60× 60× 60× 978× 60×   60×                     60× 60× 60× 60× 960× 960× 960×   60×       60×   60× 60× 20×   60×     60×       60×       60×       60×       60×       60×       60×       60×       60×         59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59×                                                                                                                                       20× 20× 20×                                         65× 65× 65× 65× 65×   54×     11×   65× 65× 65×           65× 65× 65× 65×         65×             65×         65×             65×         65×               65×         65×               65×         65×               65×         65×               65×         65× 65× 65× 58×   65×   65× 65× 65×       59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59× 59×     59× 59× 59× 472×   59× 59×   59× 59× 59× 59× 59×   59× 59× 59× 59× 59×   59× 59× 59× 59× 59×   59×   59× 59× 59× 59× 59×   59×   59× 59× 59×   59× 59× 59×   59× 59× 59×   59× 59× 59×   59× 59× 59×   59× 59× 59×   59× 59× 59×   59× 59× 59×   59×        
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-dropdowns", "@syncfusion/ej2-buttons", "@syncfusion/ej2-splitbuttons", "@syncfusion/ej2-inputs", "@syncfusion/ej2-data", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_dropdowns_1, ej2_buttons_1, ej2_splitbuttons_1, ej2_inputs_1, ej2_data_1, ej2_base_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Text = (function () {
        function Text(container, isRtl) {
            var _this = this;
            this.isRetrieving = false;
            this.appliedHighlightColor = 'rgb(255, 255, 0)';
            this.createChangecase = function (container) {
                var items = [
                    {
                        text: _this.localObj.getConstant('SentenceCase'), id: 'sentencecase'
                    }, {
                        text: _this.localObj.getConstant('UPPERCASE'), id: 'uppercase'
                    }, {
                        text: _this.localObj.getConstant('Lowercase'), id: 'lowercase'
                    }, {
                        text: _this.localObj.getConstant('CapitalizeEachWord'), id: 'capitalizeEachWord'
                    }, {
                        text: _this.localObj.getConstant('ToggleCase'), id: 'togglecase'
                    }
                ];
                _this.changeCaseDropdown = new ej2_splitbuttons_1.DropDownButton({
                    items: items,
                    iconCss: 'e-icons e-de-ctnr-change-case',
                    enableRtl: _this.isRtl
                });
                var changeCaseContainer = ej2_base_1.createElement('div', {
                    id: container.id + '_changeCase', className: 'e-de-ctnr-group-btn'
                });
                var buttonElement = ej2_base_1.createElement('button', {
                    id: changeCaseContainer.id + '_dropdownBtn',
                    attrs: { type: 'button' }
                });
                changeCaseContainer.appendChild(buttonElement);
                container.appendChild(changeCaseContainer);
                _this.changeCaseDropdown.appendTo(buttonElement);
            };
            this.changeCase = function (args) {
                if (_this.isRetrieving) {
                    return;
                }
                var text = args.item.id;
                switch (text) {
                    case 'sentencecase':
                        if (!_this.documentEditor.isReadOnly && _this.documentEditor.editorModule) {
                            _this.documentEditor.editorModule.changeCase('SentenceCase');
                        }
                        break;
                    case 'uppercase':
                        if (!_this.documentEditor.isReadOnly && _this.documentEditor.editorModule) {
                            _this.documentEditor.editorModule.changeCase('Uppercase');
                        }
                        break;
                    case 'lowercase':
                        if (!_this.documentEditor.isReadOnly && _this.documentEditor.editorModule) {
                            _this.documentEditor.editorModule.changeCase('Lowercase');
                        }
                        break;
                    case 'capitalizeEachWord':
                        if (!_this.documentEditor.isReadOnly && _this.documentEditor.editorModule) {
                            _this.documentEditor.editorModule.changeCase('CapitalizeEachWord');
                        }
                        break;
                    case 'togglecase':
                        if (!_this.documentEditor.isReadOnly && _this.documentEditor.editorModule) {
                            _this.documentEditor.editorModule.changeCase('ToggleCase');
                        }
                        break;
                    default:
                        break;
                }
            };
            this.container = container;
            this.isRtl = isRtl;
        }
        Object.defineProperty(Text.prototype, "documentEditor", {
            get: function () {
                return this.container.documentEditor;
            },
            enumerable: true,
            configurable: true
        });
        Text.prototype.initializeTextPropertiesDiv = function (wholeDiv, isRtl) {
            this.localObj = new ej2_base_1.L10n('documenteditorcontainer', this.container.defaultLocale, this.container.locale);
            this.textProperties = wholeDiv;
            var element = this.documentEditor.element.id + '_font_properties';
            var textDiv = this.createDiv(element + '_text', wholeDiv);
            ej2_base_1.classList(textDiv, ['e-de-cntr-pane-padding', 'e-de-prop-separator-line'], []);
            var fontDiv = this.createDiv(element + '_sizeStyle', textDiv, 'display:inline-flex;');
            ej2_base_1.classList(fontDiv, ['e-de-ctnr-segment'], []);
            if (isRtl) {
                ej2_base_1.classList(fontDiv, ['e-de-ctnr-segment-rtl'], []);
            }
            var fontFamilyDiv = this.createDiv(element + '_fontFamilyDiv', fontDiv);
            var fontFamily = ej2_base_1.createElement('input', {
                id: element + '_fontFamily', className: 'e-prop-font-style'
            });
            fontFamilyDiv.appendChild(fontFamily);
            ej2_base_1.classList(fontFamilyDiv, ['e-de-panel-left-width'], []);
            this.createDropDownListForFamily(fontFamily);
            var fontSizeDiv = this.createDiv(element + '_fontSizeDiv', fontDiv);
            var divClassName = 'e-de-ctnr-group-btn e-de-char-fmt-btn-left e-btn-group';
            if (isRtl) {
                divClassName = 'e-rtl ' + divClassName;
            }
            var fontSize = ej2_base_1.createElement('input', {
                id: element + '_fontSize', innerHTML: 'type:number', className: 'e-prop-font-style'
            });
            fontSizeDiv.appendChild(fontSize);
            ej2_base_1.classList(fontSizeDiv, ['e-de-panel-right-width'], []);
            this.createDropDownListForSize(fontSize);
            var propertiesDiv = ej2_base_1.createElement('div', {
                id: element + '_properties', styles: 'display:inline-flex;', className: 'e-de-ctnr-segment'
            });
            if (isRtl) {
                ej2_base_1.classList(propertiesDiv, ['e-de-ctnr-segment-rtl'], []);
            }
            textDiv.appendChild(propertiesDiv);
            var leftDiv = ej2_base_1.createElement('div', {
                id: element + '_leftDiv', className: divClassName, styles: 'display:inline-flex;'
            });
            propertiesDiv.appendChild(leftDiv);
            this.bold = this.createButtonTemplate(element + '_bold', 'e-de-ctnr-bold e-icons', leftDiv, 'e-de-prop-font-button', '40.5', 'Bold Tooltip');
            this.italic = this.createButtonTemplate(element + '_italic', 'e-de-ctnr-italic e-icons', leftDiv, 'e-de-prop-font-button', '40.5', 'Italic Tooltip');
            this.underline = this.createButtonTemplate(element + '_underline', 'e-de-ctnr-underline e-icons', leftDiv, 'e-de-prop-font-button', '40.5', 'Underline Tooltip');
            this.strikethrough = this.createButtonTemplate(element + '_strikethrough', 'e-de-ctnr-strikethrough e-icons', leftDiv, 'e-de-prop-font-last-button', '40.5', 'Strikethrough');
            divClassName = 'e-de-ctnr-group-btn e-de-char-fmt-btn-right e-btn-group';
            if (isRtl) {
                divClassName = 'e-rtl ' + divClassName;
            }
            var rightDiv = ej2_base_1.createElement('div', { id: element + '_rightDiv', className: divClassName, styles: 'display:inline-flex;' });
            propertiesDiv.appendChild(rightDiv);
            this.superscript = this.createButtonTemplate(element + '_superscript', 'e-de-ctnr-superscript e-icons', rightDiv, 'e-de-prop-font-button', '38.5', 'Superscript Tooltip');
            this.subscript = this.createButtonTemplate(element + '_subscript', 'e-de-ctnr-subscript e-icons', rightDiv, 'e-de-prop-font-last-button', '38.5', 'Subscript Tooltip');
            var colorDiv = ej2_base_1.createElement('div', {
                id: element + '_colorDiv', styles: 'display:inline-flex;', className: 'e-de-ctnr-segment'
            });
            if (isRtl) {
                ej2_base_1.classList(propertiesDiv, ['e-de-ctnr-segment-rtl'], []);
            }
            var leftDiv2 = ej2_base_1.createElement('div', { id: element + '_color', className: 'e-de-font-clr-picker e-de-ctnr-group-btn', styles: 'display:inline-flex;' });
            if (isRtl) {
                ej2_base_1.classList(leftDiv2, ['e-rtl'], []);
            }
            colorDiv.appendChild(leftDiv2);
            textDiv.appendChild(colorDiv);
            this.fontColor = this.createFontColorPicker(element + '_textColor', 40.5, leftDiv2, this.localObj.getConstant('Font color'));
            ej2_base_1.classList(leftDiv2.firstElementChild.lastElementChild.lastElementChild.firstChild, ['e-de-ctnr-fontcolor', 'e-icons'], ['e-caret']);
            this.initializeHighlightColorElement();
            this.highlightColor = this.createHighlightColorSplitButton(element + '_highlightColor', 34.5, leftDiv2, this.localObj.getConstant('Text highlight color'));
            ej2_base_1.classList(this.highlightColor.element.nextElementSibling.firstElementChild, ['e-de-ctnr-highlight', 'e-icons'], ['e-caret']);
            this.highlightColorInputElement = this.highlightColor.element.firstChild;
            this.clearFormat = this.createButtonTemplate(element + '_clearFormat', 'e-de-ctnr-clearall e-icons', leftDiv2, 'e-de-prop-font-last-button', '40.5', 'Clear all formatting');
            var rightDiv2 = ej2_base_1.createElement('div', {
                id: element + '_rightDiv2', className: divClassName.replace('e-btn-group', ''), styles: 'display:inline-flex;'
            });
            if (isRtl) {
                ej2_base_1.classList(rightDiv2, ['e-rtl'], []);
            }
            rightDiv2.setAttribute('title', this.container.localObj.getConstant('Change case Tooltip'));
            textDiv.appendChild(rightDiv2);
            this.createChangecase(rightDiv2);
        };
        Text.prototype.createHighlightColorSplitButton = function (id, width, divElement, toolTipText) {
            var _this = this;
            var buttonElement = ej2_base_1.createElement('button', { id: id, attrs: { type: 'button' } });
            divElement.appendChild(buttonElement);
            var hgltSplitObj = new ej2_splitbuttons_1.SplitButton({
                cssClass: 'e-de-btn-hghlclr',
                iconCss: 'e-de-ctnr-hglt-color',
                target: this.highlightColorElement, close: this.closePopup.bind(this), beforeOpen: this.openPopup.bind(this), enableRtl: this.isRtl
            });
            hgltSplitObj.appendTo(buttonElement);
            hgltSplitObj.click = function () {
                _this.applyHighlightColor(_this.highlightColorInputElement.style.backgroundColor);
            };
            hgltSplitObj.element.firstChild.style.backgroundColor = 'rgb(255, 255, 0)';
            hgltSplitObj.element.parentElement.setAttribute('title', toolTipText);
            hgltSplitObj.element.parentElement.setAttribute('aria-label', toolTipText);
            return hgltSplitObj;
        };
        Text.prototype.openPopup = function () {
            this.highlightColorElement.style.display = 'block';
        };
        Text.prototype.closePopup = function () {
            this.highlightColorElement.style.display = 'none';
        };
        Text.prototype.initializeHighlightColorElement = function () {
            this.highlightColorElement = ej2_base_1.createElement('div', {
                styles: 'display:none;width:157px',
                className: 'e-de-cntr-highlight-pane'
            });
            var yellowDiv = this.createHightlighColorPickerDiv('#ffff00', 'yellowDiv');
            var brightGreenDiv = this.createHightlighColorPickerDiv('#00ff00', 'brightGreenDiv');
            var turquoiseDiv = this.createHightlighColorPickerDiv('#00ffff', 'turquoiseDiv');
            var hotPinkDiv = this.createHightlighColorPickerDiv('#ff00ff', 'hotPinkDiv');
            var blueDiv = this.createHightlighColorPickerDiv('#0000ff', 'blueDiv');
            var redDiv = this.createHightlighColorPickerDiv('#ff0000', 'redDiv');
            var darkBlueDiv = this.createHightlighColorPickerDiv('#000080', 'darkBlueDiv');
            var tealDiv = this.createHightlighColorPickerDiv('#008080', 'tealDiv');
            var greenDiv = this.createHightlighColorPickerDiv('#008000', 'greenDiv');
            var violetDiv = this.createHightlighColorPickerDiv('#800080', 'violetDiv');
            var darkRedDiv = this.createHightlighColorPickerDiv('#800000', 'darkRedDiv');
            var darkYellowDiv = this.createHightlighColorPickerDiv('#808000', 'darkYellowDiv');
            var gray50Div = this.createHightlighColorPickerDiv('#808080', 'gray50Div');
            var gray25Div = this.createHightlighColorPickerDiv('#c0c0c0', 'gray25Div');
            var blackDiv = this.createHightlighColorPickerDiv('#000000', 'blackDiv');
            var nocolor = ej2_base_1.createElement('div', { className: 'e-hglt-no-color' });
            this.highlightColorElement.appendChild(nocolor);
            var nocolorDiv = ej2_base_1.createElement('div', { styles: 'width:24px;height:24px;background-color:#ffffff;margin:3px;', id: 'noColorDiv' });
            nocolor.appendChild(nocolorDiv);
            var nocolorDivValue = ej2_base_1.createElement('div', { innerHTML: this.localObj.getConstant('No color'), className: 'e-de-ctnr-hglt-no-color' });
            nocolorDiv.appendChild(nocolorDivValue);
            yellowDiv.addEventListener('click', this.onHighLightColor.bind(this));
            brightGreenDiv.addEventListener('click', this.onHighLightColor.bind(this));
            turquoiseDiv.addEventListener('click', this.onHighLightColor.bind(this));
            hotPinkDiv.addEventListener('click', this.onHighLightColor.bind(this));
            blueDiv.addEventListener('click', this.onHighLightColor.bind(this));
            redDiv.addEventListener('click', this.onHighLightColor.bind(this));
            darkBlueDiv.addEventListener('click', this.onHighLightColor.bind(this));
            tealDiv.addEventListener('click', this.onHighLightColor.bind(this));
            greenDiv.addEventListener('click', this.onHighLightColor.bind(this));
            violetDiv.addEventListener('click', this.onHighLightColor.bind(this));
            darkRedDiv.addEventListener('click', this.onHighLightColor.bind(this));
            darkYellowDiv.addEventListener('click', this.onHighLightColor.bind(this));
            gray50Div.addEventListener('click', this.onHighLightColor.bind(this));
            gray25Div.addEventListener('click', this.onHighLightColor.bind(this));
            blackDiv.addEventListener('click', this.onHighLightColor.bind(this));
            nocolor.addEventListener('click', this.onHighLightColor.bind(this));
        };
        Text.prototype.createHightlighColorPickerDiv = function (backgroundColor, id) {
            var colorDiv = ej2_base_1.createElement('div', { className: 'e-de-ctnr-hglt-btn', id: id });
            colorDiv.style.backgroundColor = backgroundColor;
            this.highlightColorElement.appendChild(colorDiv);
            return colorDiv;
        };
        Text.prototype.onHighLightColor = function (event) {
            if (this.documentEditor.selectionModule) {
                this.applyHighlightColor(event.currentTarget.style.backgroundColor);
                this.highlightColor.toggle();
            }
        };
        Text.prototype.applyHighlightColorAsBackground = function (color) {
            this.removeSelectedColorDiv();
            Eif (color === 'NoColor') {
                this.highlightColorElement.querySelector('#noColorDiv').classList.add('e-color-selected');
            }
            else if (color === 'Yellow') {
                this.highlightColorElement.querySelector('#yellowDiv').classList.add('e-color-selected');
            }
            else if (color === 'BrightGreen') {
                this.highlightColorElement.querySelector('#brightGreenDiv').classList.add('e-color-selected');
            }
            else if (color === 'Turquoise') {
                this.highlightColorElement.querySelector('#turquoiseDiv').classList.add('e-color-selected');
            }
            else if (color === 'Pink') {
                this.highlightColorElement.querySelector('#hotPinkDiv').classList.add('e-color-selected');
            }
            else if (color === 'Red') {
                this.highlightColorElement.querySelector('#redDiv').classList.add('e-color-selected');
            }
            else if (color === 'DarkBlue') {
                this.highlightColorElement.querySelector('#darkBlueDiv').classList.add('e-color-selected');
            }
            else if (color === 'Teal') {
                this.highlightColorElement.querySelector('#tealDiv').classList.add('e-color-selected');
            }
            else if (color === 'Green') {
                this.highlightColorElement.querySelector('#greenDiv').classList.add('e-color-selected');
            }
            else if (color === 'Violet') {
                this.highlightColorElement.querySelector('#violetDiv').classList.add('e-color-selected');
            }
            else if (color === 'DarkRed') {
                this.highlightColorElement.querySelector('#darkRedDiv').classList.add('e-color-selected');
            }
            else if (color === 'DarkYellow') {
                this.highlightColorElement.querySelector('#darkYellowDiv').classList.add('e-color-selected');
            }
            else if (color === 'Gray50') {
                this.highlightColorElement.querySelector('#gray50Div').classList.add('e-color-selected');
            }
            else if (color === 'Gray25') {
                this.highlightColorElement.querySelector('#gray25Div').classList.add('e-color-selected');
            }
            else if (color === 'Black') {
                this.highlightColorElement.querySelector('#blackDiv').classList.add('e-color-selected');
            }
            else if (color === 'Blue') {
                this.highlightColorElement.querySelector('#blueDiv').classList.add('e-color-selected');
            }
        };
        Text.prototype.removeSelectedColorDiv = function () {
            this.highlightColorElement.querySelector('#noColorDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#yellowDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#brightGreenDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#turquoiseDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#hotPinkDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#redDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#darkBlueDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#tealDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#greenDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#violetDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#darkRedDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#darkYellowDiv').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#gray50Div').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#gray25Div').classList.remove('e-color-selected');
            this.highlightColorElement.querySelector('#blackDiv').classList.remove('e-color-selected');
        };
        Text.prototype.applyHighlightColor = function (color) {
            this.appliedHighlightColor = color;
            var hgltColor = this.getHighLightColor(color);
            if (hgltColor === 'NoColor') {
                this.documentEditor.selectionModule.characterFormat.highlightColor = null;
            }
            this.documentEditor.selectionModule.characterFormat.highlightColor = hgltColor;
            this.documentEditor.focusIn();
        };
        Text.prototype.getHighLightColor = function (color) {
            switch (color) {
                case 'rgb(255, 255, 0)':
                    return 'Yellow';
                case 'rgb(0, 255, 0)':
                    return 'BrightGreen';
                case 'rgb(0, 255, 255)':
                    return 'Turquoise';
                case 'rgb(255, 0, 255)':
                    return 'Pink';
                case 'rgb(0, 0, 255)':
                    return 'Blue';
                case 'rgb(255, 0, 0)':
                    return 'Red';
                case 'rgb(0, 0, 128)':
                    return 'DarkBlue';
                case 'rgb(0, 128, 128)':
                    return 'Teal';
                case 'rgb(0, 128, 0)':
                    return 'Green';
                case 'rgb(128, 0, 128)':
                    return 'Violet';
                case 'rgb(128, 0, 0)':
                    return 'DarkRed';
                case 'rgb(128, 128, 0)':
                    return 'DarkYellow';
                case 'rgb(128, 128, 128)':
                    return 'Gray50';
                case 'rgb(192, 192, 192)':
                    return 'Gray25';
                case 'rgb(0, 0, 0)':
                    return 'Black';
                default:
                    return 'NoColor';
            }
        };
        Text.prototype.createDiv = function (id, parentDiv, style) {
            var div;
            if (style) {
                div = ej2_base_1.createElement('div', { id: id, styles: style });
            }
            else {
                div = ej2_base_1.createElement('div', { id: id });
            }
            parentDiv.appendChild(div);
            return div;
        };
        Text.prototype.createButtonTemplate = function (id, iconcss, div, buttonClass, width, toolTipText) {
            var button = ej2_base_1.createElement('Button', { id: id, attrs: { type: 'button' } });
            div.appendChild(button);
            var btn = new ej2_buttons_1.Button({
                cssClass: buttonClass, iconCss: iconcss, enableRtl: this.isRtl
            });
            btn.appendTo(button);
            button.setAttribute('title', this.localObj.getConstant(toolTipText));
            button.setAttribute('aria-label', this.localObj.getConstant(toolTipText));
            button.setAttribute('aria-pressed', 'false');
            switch (toolTipText) {
                case 'Bold Tooltip':
                    this.boldBtn = btn;
                    break;
                case 'Italic Tooltip':
                    this.italicBtn = btn;
                    break;
                case 'Underline Tooltip':
                    this.underlineBtn = btn;
                    break;
                case 'Strikethrough':
                    this.strikethroughBtn = btn;
                    break;
                case 'Superscript Tooltip':
                    this.superscriptBtn = btn;
                    break;
                case 'Subscript Tooltip':
                    this.subscriptBtn = btn;
                    break;
                default:
                    this.clearFormatBtn = btn;
            }
            return button;
        };
        Text.prototype.createFontColorPicker = function (id, width, divElement, toolTipText) {
            var _a = this.documentEditor.documentEditorSettings.colorPickerSettings, columns = _a.columns, createPopupOnClick = _a.createPopupOnClick, cssClass = _a.cssClass, disabled = _a.disabled, enablePersistence = _a.enablePersistence, inline = _a.inline, mode = _a.mode, modeSwitcher = _a.modeSwitcher, noColor = _a.noColor, presetColors = _a.presetColors, showButtons = _a.showButtons;
            var inputElement = ej2_base_1.createElement('input', { id: id, attrs: { 'type': 'color' } });
            inputElement.style.width = width + 'px';
            divElement.appendChild(inputElement);
            this.fontColorInputElement = new ej2_inputs_1.ColorPicker({ value: '#000000', enableRtl: this.isRtl, locale: this.container.locale, enableOpacity: false, mode: mode, modeSwitcher: modeSwitcher, showButtons: showButtons, columns: columns, createPopupOnClick: createPopupOnClick, cssClass: cssClass, disabled: disabled, enablePersistence: enablePersistence, inline: inline, noColor: noColor, presetColors: presetColors }, inputElement);
            this.fontColorInputElement.element.parentElement.setAttribute('title', toolTipText);
            this.fontColorInputElement.element.parentElement.setAttribute('aria-label', toolTipText);
            this.documentEditor.documentHelper.fontColorInputElement = this.fontColorInputElement;
            return inputElement;
        };
        Text.prototype.createDropDownListForSize = function (fontSelectElement) {
            var _this = this;
            var fontSize = ['8', '9', '10', '11', '12', '14', '16', '18', '20', '22', '24', '26', '28', '36', '48', '72', '96'];
            this.fontSize = new ej2_dropdowns_1.ComboBox({
                dataSource: fontSize, popupHeight: '180px',
                popupWidth: '80px',
                cssClass: 'e-de-prop-dropdown',
                allowCustom: true,
                showClearButton: false,
                enableRtl: this.isRtl
            });
            this.fontSize.focus = function () {
                _this.isRetrieving = false;
                _this.fontSize.element.select();
            };
            var format = this.documentEditor.selectionModule.characterFormat;
            this.fontSize.value = (format.bidi || format.complexScript) ? format.fontSizeBidi.toString() : format.fontSize.toString();
            this.fontSize.appendTo(fontSelectElement);
            this.fontSize.element.parentElement.setAttribute('title', this.localObj.getConstant('Font Size'));
        };
        Text.prototype.createDropDownListForFamily = function (fontSelectElement) {
            var _this = this;
            var fontStyle;
            var isStringTemplate = false;
            var itemTemplate = '';
            Eif (!this.container.enableCsp) {
                itemTemplate = ej2_base_1.initializeCSPTemplate(function (data) { return "<span style=\"font-family: " + data.FontName + ";\">" + data.FontName + "</span>"; });
                isStringTemplate = true;
            }
            this.fontFamily = new ej2_dropdowns_1.ComboBox({
                dataSource: fontStyle,
                query: new ej2_data_1.Query().select(['FontName']),
                fields: { text: 'FontName', value: 'FontValue' },
                popupHeight: '150px',
                cssClass: 'e-de-prop-dropdown',
                allowCustom: true,
                showClearButton: false,
                enableRtl: this.isRtl,
                itemTemplate: itemTemplate
            });
            this.fontFamily.appendTo(fontSelectElement);
            this.fontFamily.isStringTemplate = isStringTemplate;
            var fontFamilyValue = this.container.documentEditorSettings.fontFamilies;
            for (var i = 0; i < fontFamilyValue.length; i++) {
                var fontValue = fontFamilyValue[i];
                var fontStyleValue = { 'FontName': fontValue, 'FontValue': fontValue };
                this.fontFamily.addItem(fontStyleValue, i);
            }
            this.fontFamily.focus = function () {
                _this.isRetrieving = false;
                _this.fontFamily.element.select();
            };
            this.fontFamily.element.parentElement.setAttribute('title', this.localObj.getConstant('Font'));
        };
        Text.prototype.wireEvent = function () {
            var _this = this;
            this.fontFamily.addEventListener('change', function () {
                _this.changeFontFamily();
            });
            this.fontSize.addEventListener('change', function () {
                _this.changeFontSize();
            });
            this.bold.addEventListener('click', function () {
                _this.isRetrieving = false;
                _this.boldAction();
            });
            this.italic.addEventListener('click', function () {
                _this.isRetrieving = false;
                _this.italicAction();
            });
            this.underline.addEventListener('click', function () {
                _this.isRetrieving = false;
                _this.underlineAction();
            });
            this.strikethrough.addEventListener('click', function () {
                _this.isRetrieving = false;
                _this.strikethroughAction();
            });
            this.superscript.addEventListener('click', function () {
                _this.isRetrieving = false;
                _this.superscriptAction();
            });
            this.subscript.addEventListener('click', function () {
                _this.isRetrieving = false;
                _this.subscriptAction();
            });
            this.fontColorInputElement.addEventListener('change', function (args) {
                _this.isRetrieving = false;
                _this.changeFontColor(args);
            });
            this.clearFormat.addEventListener('click', function () {
                _this.isRetrieving = false;
                _this.clearFormatAction();
            });
            this.changeCaseDropdown.addEventListener('select', function (args) {
                _this.isRetrieving = false;
                _this.changeCase(args);
            });
        };
        Text.prototype.unwireEvents = function () {
            this.fontFamily.change = undefined;
            this.fontSize.change = undefined;
            this.bold.click = undefined;
            this.italic.click = undefined;
            this.underline.click = undefined;
            this.strikethrough.click = undefined;
            this.superscript.click = undefined;
            this.subscript.click = undefined;
            this.fontColorInputElement.change = undefined;
            this.highlightColorElement.click = undefined;
            this.highlightColor.click = undefined;
            this.clearFormat.click = undefined;
            this.changeCaseDropdown.select = undefined;
        };
        Text.prototype.boldAction = function () {
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
                this.documentEditor.editorModule.toggleBold();
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.italicAction = function () {
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
                this.documentEditor.editorModule.toggleItalic();
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.underlineAction = function () {
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
                this.documentEditor.editorModule.toggleUnderline('Single');
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.strikethroughAction = function () {
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
                this.documentEditor.editorModule.toggleStrikethrough();
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.clearFormatAction = function () {
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
                this.documentEditor.editorModule.clearFormatting();
            }
        };
        Text.prototype.subscriptAction = function () {
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
                this.documentEditor.editorModule.toggleSubscript();
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.superscriptAction = function () {
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
                this.documentEditor.editorModule.toggleSuperscript();
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.changeFontColor = function (arg) {
            var _this = this;
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.selectionModule) {
                this.documentEditor.selectionModule.characterFormat.fontColor = arg.currentValue.hex;
                setTimeout(function () {
                    _this.documentEditor.focusIn();
                }, 30);
            }
        };
        Text.prototype.changeFontFamily = function () {
            var _this = this;
            Eif (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.selectionModule && this.fontFamily.value !== '') {
                setTimeout(function () {
                    _this.documentEditor.selectionModule.characterFormat.fontFamily =
                        ej2_base_2.SanitizeHtmlHelper.sanitize(_this.fontFamily.value);
                }, 10);
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.changeFontSize = function () {
            var _this = this;
            if (this.isRetrieving) {
                return;
            }
            if (!this.documentEditor.isReadOnly && this.documentEditor.selectionModule && this.fontSize.value !== '') {
                setTimeout(function () {
                    _this.documentEditor.selectionModule.characterFormat.fontSize = _this.fontSize.value;
                }, 10);
                this.documentEditor.focusIn();
            }
        };
        Text.prototype.onSelectionChange = function () {
            this.isRetrieving = true;
            Eif (this.documentEditor.selectionModule) {
                Eif (this.documentEditor.selectionModule.characterFormat.fontFamily) {
                    var fontFamily = void 0;
                    if (!ej2_base_1.isNullOrUndefined(this.documentEditor.selectionModule.characterFormat.renderedFontFamily)
                        && !ej2_base_1.isNullOrUndefined(this.documentEditor.selectionModule.characterFormat.fontFamily)) {
                        fontFamily = this.documentEditor.selectionModule.characterFormat.renderedFontFamily;
                    }
                    else {
                        fontFamily = this.documentEditor.selectionModule.characterFormat.fontFamily;
                    }
                    this.fontFamily.value = fontFamily;
                    this.fontFamily.dataBind();
                    if (ej2_base_1.isNullOrUndefined(this.fontFamily.getDataByValue(fontFamily))) {
                        var fontStyleValue = { 'FontName': fontFamily, 'FontValue': fontFamily };
                        this.fontFamily.addItem(fontStyleValue);
                    }
                }
                else {
                    this.fontFamily.value = '';
                }
                Eif (this.documentEditor.selectionModule.characterFormat.fontSize) {
                    var format = this.documentEditor.selectionModule.characterFormat;
                    this.fontSize.value = (format.bidi || format.complexScript) ? (!ej2_base_1.isNullOrUndefined(format.fontSizeBidi) ? format.fontSizeBidi.toString() : '') : format.fontSize.toString();
                    this.fontSize.dataBind();
                }
                else {
                    this.fontSize.value = '';
                }
                Iif (this.documentEditor.selectionModule.characterFormat.bold) {
                    if (!this.bold.classList.contains('e-btn-toggle')) {
                        this.bold.classList.add('e-btn-toggle');
                        this.bold.setAttribute('aria-pressed', 'true');
                    }
                }
                else {
                    Iif (this.bold.classList.contains('e-btn-toggle')) {
                        this.bold.classList.remove('e-btn-toggle');
                        this.bold.setAttribute('aria-pressed', 'false');
                    }
                }
                Iif (this.documentEditor.selectionModule.characterFormat.italic) {
                    if (!this.italic.classList.contains('e-btn-toggle')) {
                        this.italic.classList.add('e-btn-toggle');
                        this.italic.setAttribute('aria-pressed', 'true');
                    }
                }
                else {
                    Iif (this.italic.classList.contains('e-btn-toggle')) {
                        this.italic.classList.remove('e-btn-toggle');
                        this.italic.setAttribute('aria-pressed', 'false');
                    }
                }
                Iif (this.documentEditor.selectionModule.characterFormat.underline
                    && this.documentEditor.selectionModule.characterFormat.underline !== 'None') {
                    if (!this.underline.classList.contains('e-btn-toggle')) {
                        this.underline.classList.add('e-btn-toggle');
                        this.underline.setAttribute('aria-pressed', 'true');
                    }
                }
                else {
                    Iif (this.underline.classList.contains('e-btn-toggle')) {
                        this.underline.classList.remove('e-btn-toggle');
                        this.underline.setAttribute('aria-pressed', 'false');
                    }
                }
                Iif (this.documentEditor.selectionModule.characterFormat.strikethrough
                    && this.documentEditor.selectionModule.characterFormat.strikethrough !== 'None') {
                    if (!this.strikethrough.classList.contains('e-btn-toggle')) {
                        this.strikethrough.classList.add('e-btn-toggle');
                        this.strikethrough.setAttribute('aria-pressed', 'true');
                    }
                }
                else {
                    Iif (this.strikethrough.classList.contains('e-btn-toggle')) {
                        this.strikethrough.classList.remove('e-btn-toggle');
                        this.strikethrough.setAttribute('aria-pressed', 'false');
                    }
                }
                Iif (this.documentEditor.selectionModule.characterFormat.baselineAlignment
                    && this.documentEditor.selectionModule.characterFormat.baselineAlignment === 'Subscript') {
                    if (!this.subscript.classList.contains('e-btn-toggle')) {
                        this.subscript.classList.add('e-btn-toggle');
                        this.subscript.setAttribute('aria-pressed', 'true');
                    }
                }
                else {
                    Iif (this.subscript.classList.contains('e-btn-toggle')) {
                        this.subscript.classList.remove('e-btn-toggle');
                        this.subscript.setAttribute('aria-pressed', 'false');
                    }
                }
                Iif (this.documentEditor.selectionModule.characterFormat.baselineAlignment
                    && this.documentEditor.selectionModule.characterFormat.baselineAlignment === 'Superscript') {
                    if (!this.superscript.classList.contains('e-btn-toggle')) {
                        this.superscript.classList.add('e-btn-toggle');
                        this.superscript.setAttribute('aria-pressed', 'true');
                    }
                }
                else {
                    Iif (this.superscript.classList.contains('e-btn-toggle')) {
                        this.superscript.classList.remove('e-btn-toggle');
                        this.superscript.setAttribute('aria-pressed', 'false');
                    }
                }
                Eif (this.documentEditor.selectionModule.characterFormat.fontColor) {
                    var fontColor = this.documentEditor.selectionModule.characterFormat.fontColor;
                    if (fontColor === 'empty' || fontColor === '#00000000') {
                        fontColor = '#000000';
                    }
                    this.fontColorInputElement.value = fontColor;
                }
                Eif (this.documentEditor.selectionModule.characterFormat.highlightColor) {
                    this.highlightColorInputElement.style.backgroundColor = this.appliedHighlightColor;
                    this.applyHighlightColorAsBackground(this.documentEditor.selectionModule.characterFormat.highlightColor);
                }
            }
        };
        Text.prototype.removeHTMLElement = function () {
            var _this = this;
            this.bold.remove();
            this.bold = null;
            this.italic.remove();
            this.italic = null;
            this.underline.remove();
            this.underline = null;
            this.strikethrough.remove();
            this.strikethrough = null;
            this.subscript.remove();
            this.subscript = null;
            this.superscript.remove();
            this.superscript = null;
            this.clearFormat.remove();
            this.clearFormat = null;
            this.fontColor.remove();
            this.fontColor = null;
            this.highlightColorInputElement.childNodes.forEach(function (element) {
                _this.highlightColorInputElement.removeChild(element);
            });
            this.highlightColorInputElement.remove();
            this.highlightColorInputElement = null;
            this.highlightColorElement.childNodes.forEach(function (element) {
                _this.highlightColorElement.removeChild(element);
            });
            this.highlightColorElement.remove();
            this.highlightColorElement = null;
        };
        Text.prototype.destroy = function () {
            this.unwireEvents();
            this.removeHTMLElement();
            Eif (this.highlightColor) {
                this.highlightColor.destroy();
                this.highlightColor = undefined;
            }
            Eif (this.fontColorInputElement) {
                this.fontColorInputElement.destroy();
                this.fontColorInputElement.element.remove();
                this.fontColorInputElement.element = null;
                this.fontColorInputElement = undefined;
            }
            Eif (this.fontSize) {
                this.fontSize.destroy();
                Eif (this.fontSize.element) {
                    this.fontSize.element.remove();
                    this.fontSize.element = undefined;
                }
                this.fontSize = undefined;
            }
            Eif (this.fontFamily) {
                this.fontFamily.destroy();
                Eif (this.fontFamily.element) {
                    this.fontFamily.element.remove();
                    this.fontFamily.element = undefined;
                }
                this.fontFamily = undefined;
            }
            Eif (this.changeCaseDropdown) {
                this.changeCaseDropdown.destroy();
                this.changeCaseDropdown = undefined;
            }
            Eif (this.boldBtn) {
                this.boldBtn.destroy();
                this.boldBtn = undefined;
            }
            Eif (this.italicBtn) {
                this.italicBtn.destroy();
                this.italicBtn = undefined;
            }
            Eif (this.underlineBtn) {
                this.underlineBtn.destroy();
                this.underlineBtn = undefined;
            }
            Eif (this.strikethroughBtn) {
                this.strikethroughBtn.destroy();
                this.strikethroughBtn = undefined;
            }
            Eif (this.subscriptBtn) {
                this.subscriptBtn.destroy();
                this.subscriptBtn = undefined;
            }
            Eif (this.superscriptBtn) {
                this.superscriptBtn.destroy();
                this.superscriptBtn = undefined;
            }
            Eif (this.clearFormatBtn) {
                this.clearFormatBtn.destroy();
                this.clearFormatBtn = undefined;
            }
            this.container = undefined;
        };
        return Text;
    }());
    exports.Text = Text;
});