Code coverage report for src/js/base/module/Clipboard.js

# all files / src/js/base/module/ Clipboard.js

68.42% Statements 13/19
0% Branches 0/11
83.33% Functions 5/6
66.67% Lines 12/18

    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
    341×
    1×
    1×
    1×
    2×
    97×
    97×

    1×
    97×

    1×

    1×

    1×

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/src/js/base/module/Clipboard.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    var lists_1 = require("../core/lists");
    var Clipboard = /** @class */ (function () {
        function Clipboard(context) {
            this.context = context;
            this.$editable = context.layoutInfo.editable;
        }
        Clipboard.prototype.initialize = function () {
            this.$editable.on('paste', this.pasteByEvent.bind(this));
        };
        /**
         * paste by clipboard event
         *
         * @param {Event} event
         */
        Clipboard.prototype.pasteByEvent = function (event) {
            var clipboardData = event.originalEvent.clipboardData;
            if (clipboardData && clipboardData.items && clipboardData.items.length) {
                // paste img file
                var item = clipboardData.items.length > 1 ? clipboardData.items[1] : lists_1["default"].head(clipboardData.items);
                if (item.kind === 'file' && item.type.indexOf('image/') !== -1) {
                    this.context.invoke('editor.insertImagesOrCallback', [item.getAsFile()]);
                }
                this.context.invoke('editor.afterCommand');
            }
        };
        return Clipboard;
    }());
    exports["default"] = Clipboard;

    },'src/js/base/module/Clipboard.js',{"../core/lists":"/Users/lqez/Dev/summernote/src/js/base/core/lists.js"}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2xpcGJvYXJkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiQ2xpcGJvYXJkLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsdUNBQWtDO0FBRWxDO0lBQ0UsbUJBQVksT0FBTztRQUNqQixJQUFJL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