Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quill-image-uploader

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quill-image-uploader - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

dist/demo.min.js

@@ -1,1 +0,1 @@

!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=Quill},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,n,r)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(r):void 0},l=o.a.import("blots/block"),u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,l),i(t,[{key:"deleteAt",value:function(e,n){a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"deleteAt",this).call(this,e,2),this.cache={}}}],[{key:"create",value:function(e){var n=a(t.__proto__||Object.getPrototypeOf(t),"create",this).call(this,e);if(!0===e)return n;var r=document.createElement("img");return r.setAttribute("src",e),n.appendChild(r),n}},{key:"value",value:function(e){var t=e.dataset;return{src:t.src,custom:t.custom}}}]),t}();u.blotName="imageBlot",u.className="image-uploading",u.tagName="span",o.a.register({"formats/imageBlot":u}),n(3);var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.quill=t,this.options=n,this.range=null,this.options.upload,this.quill.getModule("toolbar").addHandler("image",this.selectLocalImage.bind(this))}return c(e,[{key:"selectLocalImage",value:function(){this.range=this.quill.getSelection(),this.fileHolder=document.createElement("input"),this.fileHolder.setAttribute("type","file"),this.fileHolder.setAttribute("accept","image/*"),this.fileHolder.onchange=this.fileChanged.bind(this),this.fileHolder.click()}},{key:"fileChanged",value:function(){var e=this,t=this.fileHolder.files[0],n=new FileReader;n.addEventListener("load",function(){var t=n.result;e.insertBase64Image(t)},!1),t&&n.readAsDataURL(t),this.options.upload(t).then(function(t){e.insertToEditor(t)},function(e){})}},{key:"insertBase64Image",value:function(e){var t=this.range;this.quill.insertEmbed(t.index,"imageBlot",""+e)}},{key:"insertToEditor",value:function(e){var t=this.range;this.quill.deleteText(t.index,2),this.quill.insertEmbed(t.index,"image",""+e),t.index++,this.quill.setSelection(t,"api")}}]),e}();t.default=s},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),i=n(1);o.a.register("modules/imageUploader",i.default),new o.a("#editor",{theme:"snow",modules:{toolbar:{container:[[{header:[1,2,3,!1]}],["bold","italic"],["clean"],["image"]]},imageUploader:{upload:function(e){return new Promise(function(e,t){setTimeout(function(){e("https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/JavaScript-logo.png/480px-JavaScript-logo.png")},3500)})}}}})},function(e,t){}]);
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=Quill},function(e,t,n){"use strict";n.r(t);var i=n(0),r=n.n(i),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=function e(t,n,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,i)}if("value"in r)return r.value;var a=r.get;return void 0!==a?a.call(i):void 0},l=r.a.import("blots/block"),u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,l),o(t,[{key:"deleteAt",value:function(e,n){a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"deleteAt",this).call(this,e,2),this.cache={}}}],[{key:"create",value:function(e){var n=a(t.__proto__||Object.getPrototypeOf(t),"create",this).call(this,e);if(!0===e)return n;var i=document.createElement("img");return i.setAttribute("src",e),n.appendChild(i),n}},{key:"value",value:function(e){var t=e.dataset;return{src:t.src,custom:t.custom}}}]),t}();u.blotName="imageBlot",u.className="image-uploading",u.tagName="span",r.a.register({"formats/imageBlot":u}),n(3);var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.quill=t,this.options=n,this.range=null,this.options.upload,this.quill.getModule("toolbar").addHandler("image",this.selectLocalImage.bind(this))}return c(e,[{key:"selectLocalImage",value:function(){var e=this;this.range=this.quill.getSelection(),this.fileHolder=document.createElement("input"),this.fileHolder.setAttribute("type","file"),this.fileHolder.setAttribute("accept","image/*"),this.fileHolder.setAttribute("style","visibility:hidden"),this.fileHolder.onchange=this.fileChanged.bind(this),document.body.appendChild(this.fileHolder),window.requestAnimationFrame(function(){e.fileHolder.click(),window.requestAnimationFrame(function(){document.body.removeChild(e.fileHolder)})})}},{key:"fileChanged",value:function(){var e=this,t=this.fileHolder.files[0],n=new FileReader;n.addEventListener("load",function(){var t=n.result;e.insertBase64Image(t)},!1),t&&n.readAsDataURL(t),this.options.upload(t).then(function(t){e.insertToEditor(t)},function(e){})}},{key:"insertBase64Image",value:function(e){var t=this.range;this.quill.insertEmbed(t.index,"imageBlot",""+e)}},{key:"insertToEditor",value:function(e){var t=this.range;this.quill.deleteText(t.index,2),this.quill.insertEmbed(t.index,"image",""+e),t.index++,this.quill.setSelection(t,"api")}}]),e}();t.default=s},function(e,t,n){"use strict";n.r(t);var i=n(0),r=n.n(i),o=n(1);r.a.register("modules/imageUploader",o.default),new r.a("#editor",{theme:"snow",modules:{toolbar:{container:[[{header:[1,2,3,!1]}],["bold","italic"],["clean"],["image"]]},imageUploader:{upload:function(e){return new Promise(function(e,t){setTimeout(function(){e("https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/JavaScript-logo.png/480px-JavaScript-logo.png")},3500)})}}}})},function(e,t){}]);

@@ -1,1 +0,1 @@

!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=Quill},function(e,t,n){"use strict";n.r(t);var r=n(0),i=n.n(r),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var l=i.get;return void 0!==l?l.call(r):void 0},a=i.a.import("blots/block"),u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a),o(t,[{key:"deleteAt",value:function(e,n){l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"deleteAt",this).call(this,e,2),this.cache={}}}],[{key:"create",value:function(e){var n=l(t.__proto__||Object.getPrototypeOf(t),"create",this).call(this,e);if(!0===e)return n;var r=document.createElement("img");return r.setAttribute("src",e),n.appendChild(r),n}},{key:"value",value:function(e){var t=e.dataset;return{src:t.src,custom:t.custom}}}]),t}();u.blotName="imageBlot",u.className="image-uploading",u.tagName="span",i.a.register({"formats/imageBlot":u}),n(3);var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.quill=t,this.options=n,this.range=null,this.options.upload,this.quill.getModule("toolbar").addHandler("image",this.selectLocalImage.bind(this))}return c(e,[{key:"selectLocalImage",value:function(){this.range=this.quill.getSelection(),this.fileHolder=document.createElement("input"),this.fileHolder.setAttribute("type","file"),this.fileHolder.setAttribute("accept","image/*"),this.fileHolder.onchange=this.fileChanged.bind(this),this.fileHolder.click()}},{key:"fileChanged",value:function(){var e=this,t=this.fileHolder.files[0],n=new FileReader;n.addEventListener("load",function(){var t=n.result;e.insertBase64Image(t)},!1),t&&n.readAsDataURL(t),this.options.upload(t).then(function(t){e.insertToEditor(t)},function(e){})}},{key:"insertBase64Image",value:function(e){var t=this.range;this.quill.insertEmbed(t.index,"imageBlot",""+e)}},{key:"insertToEditor",value:function(e){var t=this.range;this.quill.deleteText(t.index,2),this.quill.insertEmbed(t.index,"image",""+e),t.index++,this.quill.setSelection(t,"api")}}]),e}();t.default=s},,function(e,t){}]);
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=Quill},function(e,t,n){"use strict";n.r(t);var r=n(0),i=n.n(r),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var l=i.get;return void 0!==l?l.call(r):void 0},a=i.a.import("blots/block"),u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a),o(t,[{key:"deleteAt",value:function(e,n){l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"deleteAt",this).call(this,e,2),this.cache={}}}],[{key:"create",value:function(e){var n=l(t.__proto__||Object.getPrototypeOf(t),"create",this).call(this,e);if(!0===e)return n;var r=document.createElement("img");return r.setAttribute("src",e),n.appendChild(r),n}},{key:"value",value:function(e){var t=e.dataset;return{src:t.src,custom:t.custom}}}]),t}();u.blotName="imageBlot",u.className="image-uploading",u.tagName="span",i.a.register({"formats/imageBlot":u}),n(3);var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.quill=t,this.options=n,this.range=null,this.options.upload,this.quill.getModule("toolbar").addHandler("image",this.selectLocalImage.bind(this))}return c(e,[{key:"selectLocalImage",value:function(){var e=this;this.range=this.quill.getSelection(),this.fileHolder=document.createElement("input"),this.fileHolder.setAttribute("type","file"),this.fileHolder.setAttribute("accept","image/*"),this.fileHolder.setAttribute("style","visibility:hidden"),this.fileHolder.onchange=this.fileChanged.bind(this),document.body.appendChild(this.fileHolder),window.requestAnimationFrame(function(){e.fileHolder.click(),window.requestAnimationFrame(function(){document.body.removeChild(e.fileHolder)})})}},{key:"fileChanged",value:function(){var e=this,t=this.fileHolder.files[0],n=new FileReader;n.addEventListener("load",function(){var t=n.result;e.insertBase64Image(t)},!1),t&&n.readAsDataURL(t),this.options.upload(t).then(function(t){e.insertToEditor(t)},function(e){})}},{key:"insertBase64Image",value:function(e){var t=this.range;this.quill.insertEmbed(t.index,"imageBlot",""+e)}},{key:"insertToEditor",value:function(e){var t=this.range;this.quill.deleteText(t.index,2),this.quill.insertEmbed(t.index,"image",""+e),t.index++,this.quill.setSelection(t,"api")}}]),e}();t.default=s},,function(e,t){}]);
{
"name": "quill-image-uploader",
"version": "1.0.0",
"repository": "https://github.com/noeloconnell/quill-image-uploader.git",
"description": "A module for Quill rich text editor to allow images to be uploaded to a server instead of being base64 encoded",
"main": "src/quill.imageUploader.js",
"eslintConfig": {
"extends": "airbnb",
"env": {
"browser": true
}
},
"scripts": {
"watch": "webpack --watch --progress --mode production",
"start": "webpack-dev-server --hot --open",
"build": "webpack --mode production",
"publish": "npm publish"
},
"keywords": [
"quill",
"quilljs",
"image",
"upload"
],
"author": "",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.3",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-preset-env": "^1.6.1",
"css-loader": "^0.28.8",
"eslint": "^4.15.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"jshint": "^2.9.5",
"style-loader": "^0.19.1",
"uglifyjs-webpack-plugin": "^1.1.6",
"webpack": "^4.1.0",
"webpack-cli": "^2.0.10",
"webpack-dev-server": "^3.1.0"
},
"dependencies": {
"quill": "^1.3.6"
}
"name": "quill-image-uploader",
"version": "1.0.1",
"repository": "https://github.com/noeloconnell/quill-image-uploader.git",
"description": "A module for Quill rich text editor to allow images to be uploaded to a server instead of being base64 encoded",
"main": "src/quill.imageUploader.js",
"eslintConfig": {
"extends": "airbnb",
"env": {
"browser": true
}
},
"scripts": {
"watch": "webpack --watch --progress --mode production",
"start": "webpack-dev-server --hot --open",
"build": "webpack --mode production",
"publish": "npm publish"
},
"keywords": [
"quill",
"quilljs",
"image",
"upload"
],
"author": "",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.3",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-preset-env": "^1.6.1",
"css-loader": "^0.28.8",
"eslint": "^4.15.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"jshint": "^2.9.5",
"style-loader": "^0.19.1",
"uglifyjs-webpack-plugin": "^1.1.6",
"webpack": "^4.1.0",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.14"
},
"dependencies": {
"quill": "^1.3.6"
}
}

@@ -0,0 +0,0 @@ # Quill ImageHandler Module

@@ -0,0 +0,0 @@ import Quill from "quill";

@@ -0,0 +0,0 @@ import Quill from "quill";

@@ -1,76 +0,85 @@

import "./blots/image";
import './blots/image';
import "./quill.imageUploader.css";
import './quill.imageUploader.css';
class ImageUploader {
constructor(quill, options) {
this.quill = quill;
this.options = options;
this.range = null;
constructor(quill, options) {
this.quill = quill;
this.options = options;
this.range = null;
if (typeof this.options.upload !== "function")
console.warn(
"[Missing config] upload function that returns a promise is required"
);
if (typeof this.options.upload !== 'function')
console.warn(
'[Missing config] upload function that returns a promise is required'
);
var toolbar = this.quill.getModule("toolbar");
toolbar.addHandler("image", this.selectLocalImage.bind(this));
}
var toolbar = this.quill.getModule('toolbar');
toolbar.addHandler('image', this.selectLocalImage.bind(this));
}
selectLocalImage() {
this.range = this.quill.getSelection();
this.fileHolder = document.createElement("input");
this.fileHolder.setAttribute("type", "file");
this.fileHolder.setAttribute("accept", "image/*");
selectLocalImage() {
this.range = this.quill.getSelection();
this.fileHolder = document.createElement('input');
this.fileHolder.setAttribute('type', 'file');
this.fileHolder.setAttribute('accept', 'image/*');
this.fileHolder.setAttribute('style', 'visibility:hidden');
this.fileHolder.onchange = this.fileChanged.bind(this);
this.fileHolder.onchange = this.fileChanged.bind(this);
this.fileHolder.click();
}
document.body.appendChild(this.fileHolder);
fileChanged() {
const file = this.fileHolder.files[0];
window.requestAnimationFrame(() => {
this.fileHolder.click();
const fileReader = new FileReader();
window.requestAnimationFrame(() => {
document.body.removeChild(this.fileHolder);
});
});
}
fileReader.addEventListener(
"load",
() => {
let base64ImageSrc = fileReader.result;
this.insertBase64Image(base64ImageSrc);
},
false
);
fileChanged() {
const file = this.fileHolder.files[0];
if (file) {
fileReader.readAsDataURL(file);
}
const fileReader = new FileReader();
this.options.upload(file).then(
imageUrl => {
this.insertToEditor(imageUrl);
},
error => {
console.warn(error.message);
}
);
}
fileReader.addEventListener(
'load',
() => {
let base64ImageSrc = fileReader.result;
this.insertBase64Image(base64ImageSrc);
},
false
);
insertBase64Image(url) {
const range = this.range;
this.quill.insertEmbed(range.index, "imageBlot", `${url}`);
}
if (file) {
fileReader.readAsDataURL(file);
}
insertToEditor(url) {
const range = this.range;
// Delete the placeholder image
this.quill.deleteText(range.index, 2);
// Insert the server saved image
this.quill.insertEmbed(range.index, "image", `${url}`);
this.options.upload(file).then(
imageUrl => {
this.insertToEditor(imageUrl);
},
error => {
console.warn(error.message);
}
);
}
range.index++;
this.quill.setSelection(range, "api");
}
insertBase64Image(url) {
const range = this.range;
this.quill.insertEmbed(range.index, 'imageBlot', `${url}`);
}
insertToEditor(url) {
const range = this.range;
// Delete the placeholder image
this.quill.deleteText(range.index, 2);
// Insert the server saved image
this.quill.insertEmbed(range.index, 'image', `${url}`);
range.index++;
this.quill.setSelection(range, 'api');
}
}
export default ImageUploader;

@@ -0,0 +0,0 @@ const path = require("path");

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc