all files / rich-text-editor/actions/ toolbar-action.js

97.87% Statements 46/47
90.24% Branches 37/41
100% Functions 8/8
97.87% Lines 46/47
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   1827× 1827×   1827× 1827× 1827× 1827×   1200×   1195× 1194×   1194× 848×     1195× 33×     1195× 76×         1195× 1195×   279× 279×     223×   223× 27× 27×     196×     279×   30× 30× 30×   1808× 1808× 1808× 1808×        
define(["require", "exports", "@syncfusion/ej2-base", "../base/constant"], function (require, exports, ej2_base_1, events) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ToolbarAction = (function () {
        function ToolbarAction(parent) {
            this.parent = parent;
            this.addEventListener();
        }
        ToolbarAction.prototype.addEventListener = function () {
            this.parent.on(events.toolbarClick, this.toolbarClick, this);
            this.parent.on(events.dropDownSelect, this.dropDownSelect, this);
            this.parent.on(events.colorPickerChanged, this.renderSelection, this);
            this.parent.on(events.destroy, this.removeEventListener, this);
        };
        ToolbarAction.prototype.toolbarClick = function (args) {
            if (ej2_base_1.isNullOrUndefined(args.item)) {
                return;
            }
            if (!ej2_base_1.isNullOrUndefined(args.item.controlParent)) {
                var activeEle = args.item.controlParent
                    .activeEle;
                if (activeEle) {
                    activeEle.tabIndex = -1;
                }
            }
            if (args.item.command === 'NumberFormatList' || args.item.command === 'BulletFormatList') {
                if (args.originalEvent.target.classList.contains('e-order-list') || args.originalEvent.target.classList.contains('e-unorder-list')) {
                    args.item.command = 'Lists';
                    args.item.subCommand = args.item.subCommand === 'NumberFormatList' ? 'OL' : 'UL';
                }
            }
            if (args.item.command === 'Lists') {
                Iif (args.originalEvent.target.classList.contains('e-caret') &&
                    (args.originalEvent.target.parentElement.classList.contains('e-rte-bulletformatlist-dropdown') || args.originalEvent.target.parentElement.classList.contains('e-rte-numberformatlist-dropdown'))) {
                    return;
                }
            }
            this.parent.notify(events.htmlToolbarClick, args);
            this.parent.notify(events.markdownToolbarClick, args);
        };
        ToolbarAction.prototype.dropDownSelect = function (e) {
            this.parent.notify(events.selectionRestore, {});
            if (!(document.body.contains(document.body.querySelector('.e-rte-quick-toolbar'))
                && e.item && (e.item.command === 'Images' || e.item.command === 'Audios' || e.item.command === 'Videos' ||
                e.item.command === 'VideoLayoutOption' || e.item.command === 'Display' || e.item.command === 'Table'))) {
                var value = e.item.controlParent && this.parent.quickToolbarModule && this.parent.quickToolbarModule.tableQTBar
                    && this.parent.quickToolbarModule.tableQTBar.element.contains(e.item.controlParent.element) ? 'Table' : null;
                if (e.item.command === 'Lists') {
                    var listItem = { listStyle: e.item.value, listImage: e.item.listImage, type: e.item.subCommand };
                    this.parent.formatter.process(this.parent, e, e.originalEvent, listItem);
                }
                else {
                    this.parent.formatter.process(this.parent, e, e.originalEvent, value);
                }
            }
            this.parent.notify(events.selectionSave, {});
        };
        ToolbarAction.prototype.renderSelection = function (args) {
            this.parent.notify(events.selectionRestore, {});
            this.parent.formatter.process(this.parent, args, args.originalEvent, null);
            this.parent.notify(events.selectionSave, {});
        };
        ToolbarAction.prototype.removeEventListener = function () {
            this.parent.off(events.toolbarClick, this.toolbarClick);
            this.parent.off(events.dropDownSelect, this.dropDownSelect);
            this.parent.off(events.colorPickerChanged, this.renderSelection);
            this.parent.off(events.destroy, this.removeEventListener);
        };
        return ToolbarAction;
    }());
    exports.ToolbarAction = ToolbarAction;
});