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C7C,aAAgB,MACnB,EAAO,cAAc,EACtB,GAEF","file":"/gh/kensnyder/quill-image-drop-module@1.0.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /gh/kensnyder/quill-image-drop-module@1.0.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Custom module for quilljs to allow user to drag images from their file system into the editor\n * and paste images from clipboard (Works on Chrome, Firefox, Edge, not on Safari)\n * @see https://quilljs.com/blog/building-a-custom-module/\n */\nexport class ImageDrop {\n\n\t/**\n\t * Instantiate the module given a quill instance and any options\n\t * @param {Quill} quill\n\t * @param {Object} options\n\t */\n\tconstructor(quill, options = {}) {\n\t\t// save the quill reference\n\t\tthis.quill = quill;\n\t\t// bind handlers to this instance\n\t\tthis.handleDrop = this.handleDrop.bind(this);\n\t\tthis.handlePaste = this.handlePaste.bind(this);\n\t\t// listen for drop and paste events\n\t\tthis.quill.root.addEventListener('drop', this.handleDrop, false);\n\t\tthis.quill.root.addEventListener('paste', this.handlePaste, false);\n\t}\n\n\t/**\n\t * Handler for drop event to read dropped files from evt.dataTransfer\n\t * @param {Event} evt\n\t */\n\thandleDrop(evt) {\n\t\tevt.preventDefault();\n\t\tif (evt.dataTransfer && evt.dataTransfer.files && evt.dataTransfer.files.length) {\n\t\t\tif (document.caretRangeFromPoint) {\n\t\t\t\tconst selection = document.getSelection();\n\t\t\t\tconst range = document.caretRangeFromPoint(evt.clientX, evt.clientY);\n\t\t\t\tif (selection && range) {\n\t\t\t\t\tselection.setBaseAndExtent(range.startContainer, range.startOffset, range.startContainer, range.startOffset);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.readFiles(evt.dataTransfer.files, this.insert.bind(this));\n\t\t}\n\t}\n\n\t/**\n\t * Handler for paste event to read pasted files from evt.clipboardData\n\t * @param {Event} evt\n\t */\n\thandlePaste(evt) {\n\t\tif (evt.clipboardData && evt.clipboardData.items && evt.clipboardData.items.length) {\n\t\t\tthis.readFiles(evt.clipboardData.items, dataUrl => {\n\t\t\t\tconst selection = this.quill.getSelection();\n\t\t\t\tif (selection) {\n\t\t\t\t\t// we must be in a browser that supports pasting (like Firefox)\n\t\t\t\t\t// so it has already been placed into the editor\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// otherwise we wait until after the paste when this.quill.getSelection()\n\t\t\t\t\t// will return a valid index\n\t\t\t\t\tsetTimeout(() => this.insert(dataUrl), 0);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Insert the image into the document at the current cursor position\n\t * @param {String} dataUrl  The base64-encoded image URI\n\t */\n\tinsert(dataUrl) {\n\t\tconst index = (this.quill.getSelection() || {}).index || this.quill.getLength();\n\t\tthis.quill.insertEmbed(index, 'image', dataUrl, 'user');\n\t}\n\n\t/**\n\t * Extract image URIs a list of files from evt.dataTransfer or evt.clipboardData\n\t * @param {File[]} files  One or more File objects\n\t * @param {Function} callback  A function to send each data URI to\n\t */\n\treadFiles(files, callback) {\n\t\t// check each file for an image\n\t\t[].forEach.call(files, file => {\n\t\t\tif (!file.type.match(/^image\\/(gif|jpe?g|a?png|svg|webp|bmp|vnd\\.microsoft\\.icon)/i)) {\n\t\t\t\t// file is not an image\n\t\t\t\t// Note that some file formats such as psd start with image/* but are not readable\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// set up file reader\n\t\t\tconst reader = new FileReader();\n\t\t\treader.onload = (evt) => {\n\t\t\t\tcallback(evt.target.result);\n\t\t\t};\n\t\t\t// read the clipboard item or file\n\t\t\tconst blob = file.getAsFile ? file.getAsFile() : file;\n\t\t\tif (blob instanceof Blob) {\n\t\t\t\treader.readAsDataURL(blob);\n\t\t\t}\n\t\t});\n\t}\n\n}\n"]}