diff --git a/dist/suneditor.min.js b/dist/suneditor.min.js index 830828622..3956c4fd0 100644 --- a/dist/suneditor.min.js +++ b/dist/suneditor.min.js @@ -1 +1 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s="XJR1")}({"0A7J":function(module,__webpack_exports__,__webpack_require__){"use strict";var _modules_colorPicker__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("EjF6");__webpack_exports__.a={name:"fontColor",add:function(core,targetElement){core.addModule([_modules_colorPicker__WEBPACK_IMPORTED_MODULE_0__.a]);const context=core.context;context.fontColor={previewEl:null,colorInput:null,colorList:null};let listDiv=eval(this.setSubmenu.call(core));context.fontColor.colorInput=listDiv.getElementsByClassName("sun-editor-id-submenu-color-input")[0],context.fontColor.colorInput.addEventListener("keyup",this.onChangeInput.bind(core)),listDiv.getElementsByClassName("sun-editor-id-submenu-color-submit")[0].addEventListener("click",this.submit.bind(core)),listDiv.getElementsByClassName("sun-editor-id-submenu-color-default")[0].addEventListener("click",this.remove.bind(core)),listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickup.bind(core)),context.fontColor.colorList=listDiv.getElementsByTagName("UL")[0].querySelectorAll("li button"),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(){const e=this.context.colorPicker.colorListHTML,t=this.util.createElement("DIV");return t.className="sun-editor-submenu layer_editor",t.style.display="none",t.innerHTML=e,t},on:function(){const e=this.context.colorPicker,t=this.context.fontColor;e._colorInput=t.colorInput,e._defaultColor="#333333",e._styleProperty="color",e._colorList=t.colorList,this.plugins.colorPicker.init.call(this,this.getSelectionNode(),null)},onChangeInput:function(e){const t=e.target.value.trim();this.plugins.colorPicker.setCurrentColor.call(this,t?"#"+t:"")},remove:function(){this.nodeChange(null,["color"]),this.submenuOff(),this.focus()},submit:function(){this.plugins.fontColor.applyColor.call(this,this.context.colorPicker._currentColor)},pickup:function(e){e.preventDefault(),e.stopPropagation(),this.plugins.fontColor.applyColor.call(this,e.target.getAttribute("data-value"))},applyColor:function(e){if(!e)return;const t=this.util.createElement("SPAN");t.style.color=e,this.nodeChange(t,["color"]),this.submenuOff(),this.focus()}}},"1kvd":function(e,t,i){"use strict";t.a={name:"dialog",add:function(e){const t=e.context;t.dialog={};let i=e.util.createElement("DIV");i.className="sun-editor-id-dialogBox sun-editor-common";let n=e.util.createElement("DIV");n.className="modal-dialog-background sun-editor-id-dialog-back",n.style.display="none";let o=e.util.createElement("DIV");o.className="modal-dialog sun-editor-id-dialog-modal",o.style.display="none",i.appendChild(n),i.appendChild(o),t.dialog.modalArea=i,t.dialog.back=n,t.dialog.modal=o,t.dialog.modal.addEventListener("click",this.onClick_dialog.bind(e)),t.element.relative.appendChild(i),i=null,n=null,o=null},onClick_dialog:function(e){e.stopPropagation(),(/modal-dialog/.test(e.target.className)||/close/.test(e.target.getAttribute("data-command")))&&this.plugins.dialog.close.call(this)},open:function(e,t){if(this.modalForm)return!1;this.context.dialog.updateModal=t,"full"===this.context.option.popupDisplay?this.context.dialog.modalArea.style.position="fixed":this.context.dialog.modalArea.style.position="absolute",this.context.dialog.kind=e,this.modalForm=this.context[e].modal;const i=this.context[e].focusElement;this.context.dialog.modalArea.style.display="block",this.context.dialog.back.style.display="block",this.context.dialog.modal.style.display="block",this.modalForm.style.display="block",i&&i.focus()},close:function(){this.modalForm.style.display="none",this.context.dialog.back.style.display="none",this.context.dialog.modalArea.style.display="none",this.modalForm=null,this.context.dialog.updateModal=!1,this.plugins[this.context.dialog.kind].init.call(this)}}},"3FqI":function(e,t,i){},"50IV":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"font",add:function(core,targetElement){const context=core.context;context.font={_fontList:[],currentFont:""};let listDiv=eval(this.setSubmenu.call(core));listDiv.getElementsByClassName("list_family")[0].addEventListener("click",this.pickup.bind(core)),context.font._fontList=listDiv.getElementsByTagName("UL")[0].querySelectorAll("li button"),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(){const e=this.context.option,t=this.lang,i=this.util.createElement("DIV");let n,o,l,s;i.className="layer_editor",i.style.display="none";let a=e.font?e.font:["Arial","Comic Sans MS","Courier New","Impact","Georgia","tahoma","Trebuchet MS","Verdana"],r='
",r+="
",i.innerHTML=r,i},on:function(){const e=this.context.font,t=e._fontList,i=this.commandMap.FONT.getAttribute("title")||"";if(i!==e.currentFont){for(let e=0,n=t.length;e '}return n+='
"},init:function(e,t){const i=this.plugins.colorPicker;let n=t||(i.getColorInNode.call(this,e)||this.context.colorPicker._defaultColor);n=i.isHexColor(n)?n:i.rgb2hex(n);const o=this.context.colorPicker._colorList;if(o)for(let e=0,t=o.length;e
",i.innerHTML=n,i},openTab:function(e){const t=this.context.image.modal,i="init"===e?t.getElementsByClassName("sun-editor-id-tab-link")[0]:e.target;if(!/^BUTTON$/i.test(i.tagName))return!1;const n=i.getAttribute("data-tab-link");let o,l,s;for(l=t.getElementsByClassName("sun-editor-id-tab-content"),o=0;o0){const t=this.context.option.imageUploadUrl,i=this.context.dialog.updateModal?1:e.length;if("string"==typeof t&&t.length>0){const n=new FormData;for(let t=0;t0?1:a.length;s0){const n=this.util.createElement("A");return n.href=/^https?:\/\//.test(t)?t:"http://"+t,n.target=i?"_blank":"",n.setAttribute("data-image-link","image"),e.setAttribute("data-image-link",t),n.appendChild(e),n}return e},setInputSize:function(e){this.context.dialog.updateModal&&this.context.image.proportion.checked&&("x"===e?this.context.image.imageY.value=Math.round(this.context.image._element_h/this.context.image._element_w*this.context.image.imageX.value):this.context.image.imageX.value=Math.round(this.context.image._element_w/this.context.image._element_h*this.context.image.imageY.value))},submit:function(e){this.showLoading(),e.preventDefault(),e.stopPropagation(),this.context.image._linkValue=this.context.image.imgLink.value,this.context.image._altText=this.context.image.altText.value,this.context.image._align=this.context.image.modal.querySelector('input[name="suneditor_image_radio"]:checked').value,this.context.image._captionChecked=this.context.image.captionCheckEl.checked,this.context.image._resizing&&(this.context.image._proportionChecked=this.context.image.proportion.checked);try{this.context.dialog.updateModal&&this.plugins.image.update_image.call(this),this.context.image.imgInputFile&&this.context.image.imgInputFile.files.length>0?this.plugins.image.onRender_imgInput.call(this):this.context.image.imgUrlFile&&this.context.image.imgUrlFile.value.trim().length>0?this.plugins.image.onRender_imgUrl.call(this):this.closeLoading()}catch(e){throw this.closeLoading(),_modules_notice__WEBPACK_IMPORTED_MODULE_2__.a.open.call(this,'[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"'),Error('[SUNEDITOR.image.submit.fail] cause : "'+e.message+'"')}finally{this.plugins.dialog.close.call(this)}return!1},_onload_image:function(e,t){if(e.setAttribute("origin-size",e.naturalWidth+","+e.naturalHeight),e.setAttribute("data-origin",e.offsetWidth+","+e.offsetHeight),!t)return;let i=e.getAttribute("data-index");i?(this._variable._imagesInfo[i].name=e.getAttribute("data-file-name"),this._variable._imagesInfo[i].size=1*e.getAttribute("data-file-size")):(i=this._variable._imageIndex,e.setAttribute("data-index",i),this._variable._imagesInfo[i]={src:e.src,index:i,name:t.name,size:t.size,select:function(){const t=this.plugins.resizing.call_controller_resize.call(this,e,"image");this.plugins.image.onModifyMode.call(this,e,t),e.scrollIntoView()}.bind(this),delete:this.plugins.image.destroy.bind(this,e)},this._variable._imageIndex++,e.setAttribute("data-file-name",t.name),e.setAttribute("data-file-size",t.size)),this._imageUpload(e,i,!1,this._variable._imagesInfo[i])},create_image:function(e,t,i,n,o,l,s,a){if(l)return void(s.src=e);const r=this.context.image;let c=this.util.createElement("IMG");c.addEventListener("load",this.plugins.image._onload_image.bind(this,c,a)),c.src=e,c.setAttribute("data-align",o),c.alt=r._altText,(c=this.plugins.image.onRender_link.call(this,c,t,i)).setAttribute("data-rotate","0"),r._resizing&&(/\d+/.test(n)&&(c.style.width=n),c.setAttribute("data-proportion",r._proportionChecked));const d=this.plugins.resizing.set_cover.call(this,c),u=this.plugins.resizing.set_container.call(this,d,"sun-editor-id-image-container");r._captionChecked&&(r._caption=this.plugins.resizing.create_caption.call(this),r._caption.setAttribute("contenteditable",!1),d.appendChild(r._caption)),d.style.margin="none"!==o?"auto":"0",this.util.removeClass(u,r._floatClassRegExp),this.util.addClass(u,"float-"+o),r._resizing&&/\d+/.test(n)||(this.context.resizing._resize_plugin="image",r._element=c,r._cover=d,r._container=u,this.plugins.image.setAutoSize.call(this)),this.insertNode(u,this.util.getFormatElement(this.getSelectionNode())),this.appendFormatTag(u)},update_image:function(e){const t=this.context.image,i=t._linkValue;let n=t._element,o=t._cover,l=t._container,s=!1;const a=1*t.imageX.value!==n.offsetWidth||1*t.imageY.value!==n.offsetHeight;if(null===o&&(s=!0,n=t._element.cloneNode(!0),o=this.plugins.resizing.set_cover.call(this,n)),null===l&&(o=o.cloneNode(!0),s=!0,l=this.plugins.resizing.set_container.call(this,o,"sun-editor-id-image-container")),s&&(l.innerHTML="",l.appendChild(o)),n.alt=t._altText,t._resizing&&(n.setAttribute("data-proportion",t._proportionChecked),a&&this.plugins.image.setSize.call(this,t.imageX.value,t.imageY.value)),t._captionChecked?t._caption||(t._caption=this.plugins.resizing.create_caption.call(this),o.appendChild(t._caption)):t._caption&&(this.util.removeItem(t._caption),t._caption=null),t._align&&"none"!==t._align?o.style.margin="auto":o.style.margin="0",this.util.removeClass(l,this.context.image._floatClassRegExp),this.util.addClass(l,"float-"+t._align),n.setAttribute("data-align",t._align),i.trim().length>0)if(null!==t._linkElement)t._linkElement.href=i,t._linkElement.target=t.imgLinkNewWindowCheck.checked?"_blank":"",n.setAttribute("data-image-link",i);else{let e=this.plugins.image.onRender_link.call(this,n,i,this.context.image.imgLinkNewWindowCheck.checked);o.insertBefore(e,t._caption)}else if(null!==t._linkElement){const e=n;e.setAttribute("data-image-link","");let i=e.cloneNode(!0);o.removeChild(t._linkElement),o.insertBefore(i,t._caption),n=i}if(s){const e=this.util.isRangeFormatElement(t._element.parentNode)||this.util.isWysiwygDiv(t._element.parentNode)?t._element:this.util.getFormatElement(t._element)||t._element;e.parentNode.insertBefore(l,e),this.util.removeItem(t._element)}!e&&(/\d+/.test(n.style.height)||t._resizing&&a||this.context.resizing._rotateVertical&&t._captionChecked)&&this.plugins.resizing.setTransformSize.call(this,n),this.history.push(),e&&this.plugins.image.init.call(this)},sizeRevert:function(){const e=this.context.image;e._origin_w&&(e.imageX.value=e._element_w=e._origin_w,e.imageY.value=e._element_h=e._origin_h)},onModifyMode:function(e,t){const i=this.context.image;i._linkElement=/^A$/i.test(e.parentNode.nodeName)?e.parentNode:null,i._element=e,i._cover=this.util.getParentElement(e,".sun-editor-figure-cover"),i._container=this.util.getParentElement(e,".sun-editor-id-image-container"),i._caption=this.util.getChildElement(i._cover,"FIGCAPTION"),i._align=e.getAttribute("data-align")||"none",i._element_w=t.w,i._element_h=t.h,i._element_t=t.t,i._element_l=t.l;let n=i._element.getAttribute("data-origin");n?(n=n.split(","),i._origin_w=1*n[0],i._origin_h=1*n[1]):(i._origin_w=t.w,i._origin_h=t.h,i._element.setAttribute("data-origin",t.w+","+t.h))},openModify:function(e){const t=this.context.image;t.imgUrlFile.value=t._element.src,t.altText.value=t._element.alt,t.imgLink.value=null===t._linkElement?"":t._linkElement.href,t.imgLinkNewWindowCheck.checked=t._linkElement&&"_blank"===t._linkElement.target,t.modal.querySelector('input[name="suneditor_image_radio"][value="'+t._align+'"]').checked=!0,t._captionChecked=t.captionCheckEl.checked=!!t._caption,t._resizing&&(t.proportion.checked=t._proportionChecked="true"===t._element.getAttribute("data-proportion"),t.imageX.value=t._element.offsetWidth,t.imageY.value=t._element.offsetHeight,t.imageX.disabled=!1,t.imageY.disabled=!1,t.proportion.disabled=!1),e||this.plugins.dialog.open.call(this,"image",!0)},setSize:function(e,t){const i=this.context.image;i._element.style.width=e+"px",i._element.style.height=t+"px"},setAutoSize:function(){const e=this.context.image;this.plugins.resizing.resetTransform.call(this,e._element),this.plugins.image.cancelPercentAttr.call(this),e._element.style.maxWidth="100%",e._element.style.width="100%",e._element.style.height="",e._cover.style.width="",e._cover.style.height=""},setPercentSize:function(e){const t=this.context.image;t._container.style.width=e,t._container.style.height="",t._cover.style.width="100%",t._cover.style.height="",t._element.style.width="100%",t._element.style.height="",/100/.test(e)&&(this.util.removeClass(t._container,this.context.image._floatClassRegExp),this.util.addClass(t._container,"float-center"))},cancelPercentAttr:function(){const e=this.context.image;e._element.style.maxWidth="none",e._cover.style.width="",e._cover.style.height="",e._container.style.width="",e._container.style.height="",this.util.removeClass(e._container,this.context.image._floatClassRegExp),this.util.addClass(e._container,"float-"+e._align)},resetAlign:function(){const e=this.context.image;e._element.setAttribute("data-align",""),e._align="none",e._cover.style.margin="0",this.util.removeClass(e._container,e._floatClassRegExp)},destroy:function(e){const t=e||this.context.image._element,i=this.util.getParentElement(t,".sun-editor-id-image-container")||t,n=t.getAttribute("data-index");this.util.removeItem(i),this.plugins.image.init.call(this),this.controllersOff(),n&&(delete this._variable._imagesInfo[n],this._imageUpload(t,n,!0))},init:function(){const e=this.context.image;if(e.imgInputFile&&(e.imgInputFile.value=""),e.imgUrlFile&&(e.imgUrlFile.value=""),e.altText.value="",e.imgLink.value="",e.imgLinkNewWindowCheck.checked=!1,e.modal.querySelector('input[name="suneditor_image_radio"][value="none"]').checked=!0,e.captionCheckEl.checked=!1,e._element=null,this.plugins.image.openTab.call(this,"init"),e._resizing){const t="auto"===this.context.option.imageWidth;e.proportion.checked=!1,e.imageX.value=t?"":this.context.option.imageWidth,e.imageY.value="",e.imageX.disabled=t,e.imageY.disabled=!0,e.proportion.disabled=!0}}}},MIhV:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a={name:"fontSize",add:function(core,targetElement){const context=core.context;context.fontSize={_sizeList:[],currentSize:""};let listDiv=eval(this.setSubmenu.call(core));listDiv.getElementsByTagName("UL")[0].addEventListener("click",this.pickup.bind(core)),context.fontSize._sizeList=listDiv.getElementsByTagName("UL")[0].querySelectorAll("li button"),targetElement.parentNode.appendChild(listDiv),listDiv=null},setSubmenu:function(){const e=this.context.option,t=this.lang,i=this.util.createElement("DIV");i.className="sun-editor-submenu layer_editor",i.style.display="none";const n=e.fontSize?e.fontSize:[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72];let o='
  • ";for(let e=0,t=n.length;e"}return o+="
",i.innerHTML=o,i},on:function(){const e=this.context.fontSize,t=e._sizeList,i=this.commandMap.SIZE.getAttribute("title")||"";if(i!==e.currentSize){for(let e=0,n=t.length;e