{"version":3,"sources":["webpack://grapesjs-tui-image-editor/webpack/universalModuleDefinition","webpack://grapesjs-tui-image-editor/webpack/bootstrap","webpack://grapesjs-tui-image-editor/./node_modules/@babel/runtime/helpers/objectSpread.js","webpack://grapesjs-tui-image-editor/./node_modules/@babel/runtime/helpers/toConsumableArray.js","webpack://grapesjs-tui-image-editor/./src/index.js","webpack://grapesjs-tui-image-editor/./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","webpack://grapesjs-tui-image-editor/./node_modules/@babel/runtime/helpers/iterableToArray.js","webpack://grapesjs-tui-image-editor/./node_modules/@babel/runtime/helpers/nonIterableSpread.js","webpack://grapesjs-tui-image-editor/./node_modules/@babel/runtime/helpers/defineProperty.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","target","arguments","length","source","ownKeys","keys","getOwnPropertySymbols","concat","filter","sym","getOwnPropertyDescriptor","forEach","arrayWithoutHoles","iterableToArray","nonIterableSpread","arr","__webpack_exports__","editor","options","undefined","remoteIcons","opts","_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_1___default","config","constructor","labelImageEditor","labelApply","height","width","commandId","toolbarIcon","hideHeader","onApply","addToAssets","upload","onApplyButton","icons","menu.normalIcon.path","menu.activeIcon.path","menu.disabledIcon.path","menu.hoverIcon.path","submenu.normalIcon.path","submenu.activeIcon.path","script","style","getConstructor","tui","ImageEditor","constr","head","document","scripts","Array","isArray","_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default","appendStyle","styles","link","createElement","href","shift","rel","appendChild","appendScript","scr","src","onerror","onload","domc","DomComponents","typeImage","getType","model","addType","initToolbar","apply","this","tb","some","item","command","unshift","label","set","Commands","add","run","ed","_this","id","log","level","stopCommand","getSelected","content","createContent","title","btn","children","Modal","open","getModel","once","imageEditor","getEditorConfig","setEditing","onclick","applyChanges","stop","destroy","path","includeUI","theme","loadImage","uiSize","innerHTML","_this2","AssetManager","getDrawingMode","crop","getCropzoneRect","then","uploadImage","am","_this3","dataURL","toDataURL","file","dataUrlToBlob","FileUploader","uploadFile","dataTransfer","files","res","obj","data","applyToTarget","split","pop","result","close","byteStr","atob","type","ab","ArrayBuffer","ia","Uint8Array","charCodeAt","Blob","arr2","iter","iterator","toString","from","TypeError","configurable","writable"],"mappings":";CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,IACA,mBAAAG,eAAAC,IACAD,OAAA,GAAAH,GACA,iBAAAC,QACAA,QAAA,6BAAAD,IAEAD,EAAA,6BAAAC,IARA,CASCK,OAAA,WACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAP,QAGA,IAAAC,EAAAI,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAT,QAAA,IAUA,OANAU,EAAAH,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAQ,GAAA,EAGAR,EAAAD,QA0DA,OArDAM,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CV,EAAAgB,EAAA,SAAAtB,GACA,oBAAAuB,eAAAC,aACAN,OAAAC,eAAAnB,EAAAuB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAnB,EAAA,cAAiDyB,OAAA,KAQjDnB,EAAAoB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAAnB,EAAAmB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,iBAAAF,QAAA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AA+I,EACA5J,OAAAC,eAAA2J,EAAA/I,EAAA,CACAN,QACAL,YAAA,EACAgL,cAAA,EACAC,UAAA,IAGAvB,EAAA/I,GAAAN,EAGAqJ","file":"dist/grapesjs-tui-image-editor.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"grapesjs-tui-image-editor\"] = factory();\n\telse\n\t\troot[\"grapesjs-tui-image-editor\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","var defineProperty = require(\"./defineProperty\");\n\nfunction _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n var ownKeys = Object.keys(source);\n\n if (typeof Object.getOwnPropertySymbols === 'function') {\n ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {\n return Object.getOwnPropertyDescriptor(source, sym).enumerable;\n }));\n }\n\n ownKeys.forEach(function (key) {\n defineProperty(target, key, source[key]);\n });\n }\n\n return target;\n}\n\nmodule.exports = _objectSpread;","var arrayWithoutHoles = require(\"./arrayWithoutHoles\");\n\nvar iterableToArray = require(\"./iterableToArray\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;","export default (editor, options = {}) => {\n const remoteIcons = '../images/svg/svg/';\n const opts = { ...{\n // TOAST UI's configurations\n // http://nhnent.github.io/tui.image-editor/latest/ImageEditor.html\n config: {},\n\n // Pass the editor constructor. By default, the `tui.ImageEditor` will be called\n constructor: '',\n\n // Label for the image editor (used in the modal)\n labelImageEditor: 'Image Editor',\n\n // Label used on the apply button\n labelApply: 'Apply',\n\n // Default editor height\n height: '650px',\n\n // Default editor width\n width: '100%',\n\n // Id to use to create the image editor command\n commandId: 'tui-image-editor',\n\n // Icon used in the component toolbar\n toolbarIcon: ``,\n\n // Hide the default editor header\n hideHeader: 1,\n\n // By default, GrapesJS takes the modified image, adds it to the Asset Manager and update the target.\n // If you need some custom logic you can use this custom 'onApply' function\n // eg.\n // onApply: (imageEditor, imageModel) => {\n // const dataUrl = imageEditor.toDataURL();\n // editor.AssetManager.add({ src: dataUrl }); // Add it to Assets\n // imageModel.set('src', dataUrl); // Update the image component\n // }\n onApply: 0,\n\n // If no custom `onApply` is passed and this option is `true`, the result image will be added to assets\n addToAssets: 1,\n\n // If no custom `onApply` is passed, on confirm, the edited image, will be passed to the AssetManager's\n // uploader and the result (eg. instead of having the dataURL you'll have the URL) will be\n // passed to the default `onApply` process (update target, etc.)\n upload: 0,\n\n // The apply button (HTMLElement) will be passed as an argument to this function, once created.\n // This will allow you a higher customization.\n onApplyButton: () => {},\n\n // The TOAST UI editor isn't compiled with icons, so generally, you should download them and indicate\n // the local path in the `includeUI.theme` configurations.\n // Use this option to change them or set it to `false` to keep what is come in `includeUI.theme`\n // By default, the plugin will try to use the editor's remote icons (which involves a cross-origin async\n // request, indicated as unsafe by most of the browsers)\n icons: {\n 'menu.normalIcon.path': `${remoteIcons}icon-d.svg`,\n 'menu.activeIcon.path': `${remoteIcons}icon-b.svg`,\n 'menu.disabledIcon.path': `${remoteIcons}icon-a.svg`,\n 'menu.hoverIcon.path': `${remoteIcons}icon-c.svg`,\n 'submenu.normalIcon.path': `${remoteIcons}icon-d.svg`,\n 'submenu.activeIcon.path': `${remoteIcons}icon-c.svg`,\n },\n\n // Scripts to load dynamically in case no TOAST UI editor instance was found\n script: [\n 'https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.6.7/fabric.min.js',\n 'https://uicdn.toast.com/tui.code-snippet/v1.5.0/tui-code-snippet.min.js',\n 'https://uicdn.toast.com/tui-color-picker/v2.2.0/tui-color-picker.min.js',\n 'https://uicdn.toast.com/tui-image-editor/v3.4.0/tui-image-editor.min.js'\n ],\n\n // In case the script is loaded this style will be loaded too\n style: [\n 'https://uicdn.toast.com/tui-color-picker/v2.2.0/tui-color-picker.min.css',\n 'https://uicdn.toast.com/tui-image-editor/v3.4.0/tui-image-editor.min.css'\n ],\n }, ...options };\n\n const { script, style, height, width, hideHeader, icons, onApply, upload, addToAssets, commandId } = opts;\n const getConstructor = () => opts.constructor || (window.tui && window.tui.ImageEditor);\n let constr = getConstructor();\n\n // Dynamic loading of the image editor scripts and styles\n if (!constr && script) {\n const { head } = document;\n const scripts = Array.isArray(script) ? [...script] : [script];\n const styles = Array.isArray(style) ? [...style] : [style];\n const appendStyle = styles => {\n if (styles.length) {\n const link = document.createElement('link');\n link.href = styles.shift();\n link.rel = 'stylesheet';\n head.appendChild(link);\n appendStyle(styles);\n }\n }\n const appendScript = scripts => {\n if (scripts.length) {\n const scr = document.createElement('script');\n scr.src = scripts.shift();\n scr.onerror = scr.onload = appendScript.bind(null, scripts);\n head.appendChild(scr);\n } else {\n constr = getConstructor();\n }\n }\n appendStyle(styles);\n appendScript(scripts);\n }\n\n // Update image component toolbar\n const domc = editor.DomComponents;\n const typeImage = domc.getType('image').model;\n domc.addType('image', {\n model: {\n initToolbar() {\n typeImage.prototype.initToolbar.apply(this, arguments);\n const tb = this.get('toolbar');\n const tbExists = tb.some(item => item.command === commandId);\n\n if (!tbExists) {\n tb.unshift({\n command: commandId,\n label: opts.toolbarIcon,\n });\n this.set('toolbar', tb);\n }\n }\n }\n })\n\n // Add the image editor command\n editor.Commands.add(commandId, {\n run(ed, s, options = {}) {\n const { id } = this;\n\n if (!constr) {\n ed.log('TOAST UI Image editor not found', {\n level: 'error',\n ns: commandId,\n });\n return ed.stopCommand(id);\n }\n\n this.editor = ed;\n this.target = options.target || ed.getSelected();\n const content = this.createContent();\n const title = opts.labelImageEditor;\n const btn = content.children[1];\n ed.Modal.open({ title, content })\n .getModel().once('change:open', () => ed.stopCommand(id));\n this.imageEditor = new constr(content.children[0], this.getEditorConfig());\n ed.getModel().setEditing(1);\n btn.onclick = () => this.applyChanges();\n opts.onApplyButton(btn);\n },\n\n stop(ed) {\n const { imageEditor } = this;\n imageEditor && imageEditor.destroy();\n ed.getModel().setEditing(0);\n },\n\n getEditorConfig() {\n const config = { ...opts.config };\n const path = this.target.get('src');\n\n if (!config.includeUI) config.includeUI = {};\n config.includeUI = {\n theme: {},\n ...config.includeUI,\n loadImage: { path, name: 1 },\n uiSize: { height, width },\n };\n if (hideHeader) config.includeUI.theme['header.display'] = 'none';\n if (icons) config.includeUI.theme = {\n ...config.includeUI.theme,\n ...icons,\n }\n\n return config;\n },\n\n createContent() {\n const content = document.createElement('div');\n content.style = 'position: relative';\n content.innerHTML = `\n
\n