# 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,