all files / editor-manager/plugin/ insert-text.js

100% Statements 21/21
100% Branches 2/2
100% Functions 7/7
100% Lines 21/21
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   1892× 1892×   1892× 1892×   1747× 1747×                   1747×        
define(["require", "exports", "../base/constant", "./inserthtml", "./../../common/constant"], function (require, exports, CONSTANT, inserthtml_1, EVENTS) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var InsertTextExec = (function () {
        function InsertTextExec(parent) {
            this.parent = parent;
            this.addEventListener();
        }
        InsertTextExec.prototype.addEventListener = function () {
            this.parent.observer.on(CONSTANT.INSERT_TEXT_TYPE, this.insertText, this);
            this.parent.observer.on(EVENTS.INTERNAL_DESTROY, this.destroy, this);
        };
        InsertTextExec.prototype.removeEventListener = function () {
            this.parent.observer.off(CONSTANT.INSERT_TEXT_TYPE, this.insertText);
            this.parent.observer.off(EVENTS.INTERNAL_DESTROY, this.destroy);
        };
        InsertTextExec.prototype.insertText = function (e) {
            var node = document.createTextNode(e.value);
            inserthtml_1.InsertHtml.Insert(this.parent.currentDocument, node, this.parent.editableElement);
            if (e.callBack) {
                e.callBack({
                    requestType: e.subCommand,
                    editorMode: 'HTML',
                    event: e.event,
                    range: this.parent.nodeSelection.getRange(this.parent.currentDocument),
                    elements: this.parent.nodeSelection.getSelectedNodes(this.parent.currentDocument)
                });
            }
        };
        InsertTextExec.prototype.destroy = function () {
            this.removeEventListener();
        };
        return InsertTextExec;
    }());
    exports.InsertTextExec = InsertTextExec;
});