[
  {
    "path": ".gitignore",
    "content": "*~\n.DS_Store\n.idea\nnode_modules"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\n## v1.0.3 - March 29, 2017\n\n- Drop images at mouse coordinates instead of last caret position ([Issue #2](https://github.com/kensnyder/quill-image-drop-module/issues/2))\n\n## v1.0.2 - March 25, 2017\n\n- Add README link to plunker demo\n\n## v1.0.1 - March 25, 2017\n\n- Fix GitHub URL\n\n## v1.0.0 - March 18, 2017\n\n- Initial version"
  },
  {
    "path": "README.md",
    "content": "# Quill ImageDrop Module\n\nA module for Quill rich text editor to allow images to be pasted and drag/dropped into the editor.\n\n## Demo\n\n[Plunker](https://plnkr.co/edit/ubVmPkBjqQESsefM3JrT?p=preview)\n\n## Usage\n\n### Webpack/ES6\n\n```javascript\nimport Quill from 'quill';\nimport { ImageDrop } from 'quill-image-drop-module';\n\nQuill.register('modules/imageDrop', ImageDrop);\n\nconst quill = new Quill(editor, {\n    // ...\n    modules: {\n        // ...\n        imageDrop: true\n    }\n});\n```\n\n### Script Tag\n\nCopy image-drop.min.js into your web root or include from node_modules\n\n```html\n<script src=\"/node_modules/quill-image-drop-module/image-drop.min.js\"></script>\n```\n\n```javascript\nvar quill = new Quill(editor, {\n    // ...\n    modules: {\n        // ...\n        imageDrop: true\n    }\n});\n```"
  },
  {
    "path": "bin/release.sh",
    "content": "#!/usr/bin/env bash\n\ndir=\"$(dirname \"${BASH_SOURCE[0]}\")/..\"\n# Copy ES6 source file\ncp $dir/src/ImageDrop.js $dir/index.js\n# Copy the template\ncp $dir/src/es5-wrapper.js $dir/image-drop.min.js\n# Compile to ES5\njs=$(node $dir/node_modules/babel-cli/bin/babel.js $dir/src/ImageDrop.js --presets=es2015 | $dir/node_modules/uglify-js/bin/uglifyjs -m)\necho $js > tmp.js\n# Wrap\nsed -i '' -e '/MINIFIED_JS/r tmp.js' -e '/MINIFIED_JS/d' $dir/image-drop.min.js\nrm tmp.js"
  },
  {
    "path": "index.js",
    "content": "/**\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"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"quill-image-drop-module\",\n  \"version\": \"1.0.3\",\n  \"description\": \"A module for Quill rich text editor to allow images to be pasted and drag/dropped into the editor.\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n    \"release\": \"sh ./bin/release.sh\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/kensnyder/quill-image-drop-module.git\"\n  },\n  \"keywords\": [\n    \"quill\",\n    \"quilljs\",\n    \"image\",\n    \"drag\",\n    \"and\",\n    \"drop\",\n    \"drop\",\n    \"paste\"\n  ],\n  \"author\": \"@kensnyder\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/kensnyder/quill-image-drop-module/issues\"\n  },\n  \"homepage\": \"https://github.com/kensnyder/quill-image-drop-module#readme\",\n  \"devDependencies\": {\n    \"babel-cli\": \"^6.24.0\",\n    \"babel-preset-env\": \"^1.2.2\",\n    \"babel-preset-es2015\": \"^6.24.0\",\n    \"uglify-js\": \"^2.8.13\"\n  },\n  \"dependencies\": {\n    \"quill\": \"^1.2.2\"\n  }\n}\n"
  },
  {
    "path": "src/ImageDrop.js",
    "content": "/**\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"
  },
  {
    "path": "src/es5-wrapper.js",
    "content": "(function(){var exports={};\nMINIFIED_JS\nwindow.Quill.register('modules/imageDrop',exports.ImageDrop);})();"
  }
]