all files / editor-manager/plugin/ clearformat-exec.js

100% Statements 28/28
100% Branches 5/5
100% Functions 8/8
100% Lines 28/28
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   1907× 1907×   1907× 1907× 1907×   1762× 1762× 1762×   457×       12× 11× 11×                   1762×        
define(["require", "exports", "./../base/constant", "./clearformat", "./../../common/constant"], function (require, exports, CONSTANT, clearformat_1, EVENTS) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ClearFormatExec = (function () {
        function ClearFormatExec(parent) {
            this.parent = parent;
            this.addEventListener();
        }
        ClearFormatExec.prototype.addEventListener = function () {
            this.parent.observer.on(CONSTANT.CLEAR_TYPE, this.applyClear, this);
            this.parent.observer.on(EVENTS.KEY_DOWN_HANDLER, this.onKeyDown, this);
            this.parent.observer.on(EVENTS.INTERNAL_DESTROY, this.destroy, this);
        };
        ClearFormatExec.prototype.removeEventListener = function () {
            this.parent.observer.off(CONSTANT.CLEAR_TYPE, this.applyClear);
            this.parent.observer.off(EVENTS.KEY_DOWN_HANDLER, this.onKeyDown);
            this.parent.observer.off(EVENTS.INTERNAL_DESTROY, this.destroy);
        };
        ClearFormatExec.prototype.onKeyDown = function (e) {
            switch (e.event.action) {
                case 'clear-format':
                    this.applyClear({ subCommand: 'ClearFormat', callBack: e.callBack, enterAction: e.enterAction });
                    e.event.preventDefault();
                    break;
            }
        };
        ClearFormatExec.prototype.applyClear = function (e) {
            if (e.subCommand === 'ClearFormat') {
                clearformat_1.ClearFormat.clear(this.parent.currentDocument, this.parent.editableElement, e.enterAction, e.selector, e.subCommand);
                if (e.callBack) {
                    e.callBack({
                        requestType: e.subCommand,
                        event: e.event,
                        editorMode: 'HTML',
                        range: this.parent.nodeSelection.getRange(this.parent.currentDocument),
                        elements: this.parent.nodeSelection.getSelectedNodes(this.parent.currentDocument)
                    });
                }
            }
        };
        ClearFormatExec.prototype.destroy = function () {
            this.removeEventListener();
        };
        return ClearFormatExec;
    }());
    exports.ClearFormatExec = ClearFormatExec;
});