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

100% Statements 26/26
100% Branches 4/4
100% Functions 7/7
100% Lines 26/26
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   1892× 1892×   1892× 1892×   1747× 1747×   217× 217× 185× 185× 185× 185× 185×               32×                   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 InsertHtmlExec = (function () {
        function InsertHtmlExec(parent) {
            this.parent = parent;
            this.addEventListener();
        }
        InsertHtmlExec.prototype.addEventListener = function () {
            this.parent.observer.on(CONSTANT.INSERTHTML_TYPE, this.applyHtml, this);
            this.parent.observer.on(EVENTS.INTERNAL_DESTROY, this.destroy, this);
        };
        InsertHtmlExec.prototype.removeEventListener = function () {
            this.parent.observer.off(CONSTANT.INSERTHTML_TYPE, this.applyHtml);
            this.parent.observer.off(EVENTS.INTERNAL_DESTROY, this.destroy);
        };
        InsertHtmlExec.prototype.applyHtml = function (e) {
            inserthtml_1.InsertHtml.Insert(this.parent.currentDocument, e.value, this.parent.editableElement, true, e.enterAction);
            if (e.subCommand === 'pasteCleanup') {
                var pastedElements = this.parent.editableElement.querySelectorAll('.pasteContent_RTE');
                var allPastedElements = [].slice.call(pastedElements);
                var imgElements = this.parent.editableElement.querySelectorAll('.pasteContent_Img');
                var allImgElm = [].slice.call(imgElements);
                e.callBack({
                    requestType: e.subCommand,
                    editorMode: 'HTML',
                    elements: allPastedElements,
                    imgElem: allImgElm
                });
            }
            else {
                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)
                    });
                }
            }
        };
        InsertHtmlExec.prototype.destroy = function () {
            this.removeEventListener();
        };
        return InsertHtmlExec;
    }());
    exports.InsertHtmlExec = InsertHtmlExec;
});