all files / rich-text-editor/actions/ clipboard-cleanup.js

100% Statements 40/40
91.67% Branches 11/12
100% Functions 10/10
100% Lines 40/40
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   2743× 2743× 2743×   2744× 2743× 2743× 2743×     5460× 2718×   2742× 2742×   2742× 2742× 2742×   2744×   2743×       212× 212× 212× 212× 212× 212× 212× 212× 212× 212× 212×       62201×        
define(["require", "exports", "../../editor-manager/plugin/clipboard-cleanup-action", "../base/constant", "@syncfusion/ej2-base", "../base/util"], function (require, exports, clipboard_cleanup_action_1, events, ej2_base_1, util_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ClipBoardCleanup = (function () {
        function ClipBoardCleanup(parent) {
            this.parent = parent;
            this.addEventListener();
            this.isDestroyed = false;
        }
        ClipBoardCleanup.prototype.addEventListener = function () {
            if (!this.parent.isDestroyed) {
                this.parent.on(events.clipBoardCleanup, this.clipBoardCleanup, this);
                this.parent.on(events.bindOnEnd, this.bindOnEnd, this);
                this.parent.on(events.destroy, this.destroy, this);
            }
        };
        ClipBoardCleanup.prototype.destroy = function () {
            if (this.isDestroyed) {
                return;
            }
            this.removeEventListener();
            this.isDestroyed = true;
        };
        ClipBoardCleanup.prototype.removeEventListener = function () {
            this.parent.off(events.clipBoardCleanup, this.clipBoardCleanup);
            this.parent.off(events.destroy, this.destroy);
            this.parent.off(events.bindOnEnd, this.bindOnEnd);
        };
        ClipBoardCleanup.prototype.bindOnEnd = function () {
            if (this.parent.editorMode === 'HTML' && this.parent.formatter && this.parent.formatter.editorManager
                && this.parent.contentModule) {
                this.clipBoardCleanupObj =
                    new clipboard_cleanup_action_1.ClipBoardCleanupAction(this.parent.formatter.editorManager);
            }
        };
        ClipBoardCleanup.prototype.clipBoardCleanup = function (e) {
            var _this = this;
            Eif (!ej2_base_1.isNullOrUndefined(e.args)) {
                var range = this.parent.getRange();
                var editableElement = this.parent.contentModule.getEditPanel();
                var operation = e.args.type;
                var clipboardDataArgs = this.clipBoardCleanupObj.handleClipboardProcessing(range, editableElement, operation);
                this.parent.trigger(events.beforeClipboardWrite, clipboardDataArgs, function (clipboardWriteArgs) {
                    var htmlText = util_1.sanitizeHelper(clipboardWriteArgs.htmlContent, _this.parent);
                    var plainText = util_1.sanitizeHelper(clipboardWriteArgs.plainTextContent, _this.parent);
                    e.args.clipboardData.setData('text/html', htmlText);
                    e.args.clipboardData.setData('text/plain', plainText);
                });
            }
        };
        ClipBoardCleanup.prototype.getModuleName = function () {
            return 'clipBoardCleanup';
        };
        return ClipBoardCleanup;
    }());
    exports.ClipBoardCleanup = ClipBoardCleanup;
});