12 lines
14 KiB
JavaScript
12 lines
14 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/cu-editor/cu-editor"],{599:function(t,e,o){"use strict";o.r(e);var n=o(600),i=o(602);for(var r in i)["default"].indexOf(r)<0&&function(t){o.d(e,t,(function(){return i[t]}))}(r);o(605);var a,s=o(46),c=Object(s["default"])(i["default"],n["render"],n["staticRenderFns"],!1,null,"7b039d96",null,!1,n["components"],a);c.options.__file="components/cu-editor/cu-editor.vue",e["default"]=c.exports},600:function(t,e,o){"use strict";o.r(e);var n=o(601);o.d(e,"render",(function(){return n["render"]})),o.d(e,"staticRenderFns",(function(){return n["staticRenderFns"]})),o.d(e,"recyclableRender",(function(){return n["recyclableRender"]})),o.d(e,"components",(function(){return n["components"]}))},601:function(t,e,o){"use strict";var n;o.r(e),o.d(e,"render",(function(){return i})),o.d(e,"staticRenderFns",(function(){return a})),o.d(e,"recyclableRender",(function(){return r})),o.d(e,"components",(function(){return n}));var i=function(){var t=this,e=t.$createElement,o=(t._self._c,t.__map(t.formatArray,(function(e,o){var n=t.__get_orig(e),i=0===t.swiperCurrent||1!==t.swiperCurrent&&2!==t.swiperCurrent?null:t.__map(e.array,(function(e,o){var n=t.__get_orig(e),i=t.__map(e.items,(function(o,n){var i=t.__get_orig(o),r=t.isActive(o,e),a="color"!=e.name&&"icon"!=e.label?t.__get_style([{fontSize:"fontSize"==e.name?o.value:""},o.style]):null;return{$orig:i,m0:r,s0:a}}));return{$orig:n,l0:i}}));return{$orig:n,l1:i}})));t._isMounted||(t.e0=function(e,o){var n=arguments[arguments.length-1].currentTarget.dataset,i=n.eventParams||n["event-params"];o=i.index;return e.stopPropagation(),t.changeSwiper(o)}),t.$mp.data=Object.assign({},{$root:{l2:o}})},r=!1,a=[];i._withStripped=!0},602:function(t,e,o){"use strict";o.r(e);var n=o(603),i=o.n(n);for(var r in n)["default"].indexOf(r)<0&&function(t){o.d(e,t,(function(){return n[t]}))}(r);e["default"]=i.a},603:function(t,e,o){"use strict";(function(t,n){var i=o(4);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=i(o(11)),a=o(604);function s(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function c(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?s(Object(o),!0).forEach((function(e){(0,r.default)(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):s(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}var l={name:"cuEditor",props:{placeholder:{type:String,default:"请输入内容"},showImgSize:{type:Boolean,default:!1},showImgToolbar:{type:Boolean,default:!1},showImgResize:{type:Boolean,default:!1},content:{type:String,default:""},maxSize:{type:Number,default:5},count:{type:Number,default:5},sizeType:{type:Array,default:function(){return["original","compressed"]}},sourceType:{type:Array,default:function(){return["album","camera"]}},noAllowType:{type:Array,default:function(){return[]}},url:{type:String,default:""},header:{type:Object,default:function(){return{}}},formData:{type:Object,default:function(){return{}}},name:{type:String,default:"file"}},data:function(){return{isSelect:null,isFixed:!0,iphoneXBottomH:0,scrollHeightDefault:0,keyboardHeight:0,readOnly:!0,isDefaultFormat:!0,isIos:!1,inputFocus:!1,formats:{},formatArray:[{type:"feature",array:[{name:"chooseImage",icon:"image"},{name:"chooseImagebyCamera",icon:"photo"},{name:"chooseMusic",icon:"music",title:"音乐"},{name:"choosArticleTemplate",icon:"articleTemplate",title:"模板"}]},{type:"tool",array:[{name:"text",label:"icon",items:[{name:"bold",icon:"bold"},{name:"italic",icon:"italic"},{name:"underline",icon:"underline"},{name:"strike",icon:"strikethrough"},{name:"backgroundColor",value:"yellow",icon:"fontbgcolor"}]},{name:"defaultFormat",items:[{title:"标题",format:{fontSize:"18px",bold:"strong"},style:{fontSize:"18px",fontWeight:"bold"}},{title:"小标题",format:{fontSize:"16px",bold:"strong"},style:{fontSize:"16px",fontWeight:"bold"}},{title:"正文",format:{fontSize:"14px"},style:{fontSize:"14px"}},{title:"注释",format:{fontSize:"12px",color:"#888888"},style:{fontSize:"12px",color:"#888888"}}]},{name:"fontSize",items:[{title:"18",value:"18px"},{title:"16",value:"16px"},{title:"14",value:"14px"},{title:"12",value:"12px"},{title:"11",value:"11px"},{title:"10",value:"10px"}]},{name:"color",items:[{value:"#000000"},{value:"#888888"},{value:"#ffffff"},{value:"#f6de41"},{value:"#f68c41"},{value:"#fd3136"},{value:"#5ad8a6"}]}]},{type:"tool",array:[{name:"align",label:"icon",items:[{value:"left",icon:"align-left"},{value:"center",icon:"align-center"},{value:"right",icon:"align-right"}]},{name:"text",label:"icon",items:[{name:"list",value:"ordered",icon:"orderedlist"},{name:"list",value:"bullet",icon:"unorderedlist"},{name:"indent",icon:"outdent",value:"+1"},{name:"indent",icon:"indent",value:"-1"}]},{name:"lineHeight",items:[{value:1},{value:1.3},{value:1.5},{value:2},{value:3}]}]},{type:"articleTemplate",array:[]},{type:"music",array:[]}],curLength:0,swiperCurrent:0,toolbarShow:!0,toolBarContentShow:!1,fixedTopHeight:0,toolBarHeight:100,toolBarContentHeight:800,progress:!0,musicConfig:{poster:"https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/music-a.png",name:"音乐",author:"暂无",src:"",show:!1},currentTemplate:0,templateConfig:[{value:0,src:"https://env-00jxt5y29hrd.normal.cloudstatic.cn/static/temp.jpg?expire_at=1741101642&er_sign=9c89032edb940439a476e2ca0ff1e0ba",checked:!0}]}},computed:{fullToolBarHeight:function(){var e=0;return this.toolbarShow&&(e+=this.toolBarHeight),this.toolBarContentShow&&(e+=this.toolBarContentHeight),t.upx2px(e)},scrollHeight:function(){return this.scrollHeightDefault-this.fixedTopHeight-this.fullToolBarHeight},scrollViewHeight:function(){var t=this.scrollHeight-this.keyboardHeight;return this.keyboardHeight>0?t+this.iphoneXBottomH:t},fixedBottom:function(){return this.isIos||this.iphoneXBottomH>0?this.keyboardHeight>0?this.keyboardHeight:this.iphoneXBottomH:0}},watch:{keyboardHeight:function(t,e){t>0&&(this.toolBarContentShow=!1)},toolbarShow:function(t){t||(this.toolBarContentShow=t)}},created:function(){var t=this;this.index=0,this.createdAt=Date.now(),this.getUid=function(){return"wux-upload--".concat(t.createdAt,"-").concat(++t.index)},this.uploadTask={},this.tempFilePaths=[]},mounted:function(){var e=this,o=n.createSelectorQuery().in(this);o.select("#fixed-top").boundingClientRect((function(t){e.fixedTopHeight=t.height})).exec();t.getSystemInfo({success:function(t){e.isIos="ios"==t.platform;var o=("devtools"==t.platform||e.isIos)&&44==t.safeArea.top;e.iphoneXBottomH=o?34:0,e.scrollHeightDefault=t.windowHeight-34}});t.onKeyboardHeightChange((function(o){var n=e.keyboardHeight;if(o.height!==n){e.keyboardHeight=o.height;var i=o.height>0?1e3*o.duration:0;n=o.height,setTimeout((function(){t.pageScrollTo({scrollTop:0,success:function(){e.updatePosition(n),e.editorCtx.scrollIntoView()}})}),i)}}))},beforeDestroy:function(){console.log("editor beforeDestroy")},methods:{isActive:function(t,e){var o=t.name,n=t.value,i=t.format;if(!o&&(o=e.name),i){for(var r in i)if(this.formats[r]!==i[r])return!1;return!0}return n?this.formats[o]===n:this.formats[o]},hideKeyboard:function(){this.editorCtx.blur()},changeSwiper:function(t){console.log(t),this.toolBarContentShow=!0,this.swiperCurrent=t,this.hideKeyboard()},updatePosition:function(t){this.keyboardHeight=t},onEditorReady:function(){var e=this;t.createSelectorQuery().in(this).select("#editor").context((function(t){e.editorCtx=t.context,e.setValue(e.content),e.readOnly=!1})).exec()},onEditorInput:function(t){var e=t.detail,o=(e.html,e.text);this.curLength=o.length-1},onEditorFocus:function(t){this.toolbarShow=!0},onEditorBlur:function(){},changeKeyBoard:function(){this.toolBarContentShow=!1,this.hideKeyboard()},hideToolbar:function(){this.hideKeyboard(),this.toolbarShow=!1},formatDefault:function(t){for(var e in t)this.editorCtx.format(e,t[e]);t.bold?this.editorCtx.format("bold",!0):this.formats.bold&&this.editorCtx.format("bold",""),this.editorCtx.format("lineHeight","")},formatformat:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e.name=e.name||o.name||"";var n=e.name,i=e.value;switch(t){case"format":if(!n)return;"defaultFormat"==n?this.formatDefault(e.format):this.editorCtx.format(n,i);break;case"removeFormat":this.editorCtx.removeFormat();break;case"insertDate":var r=new Date,a="".concat(r.getFullYear()," 年").concat(r.getMonth()+1," 月").concat(r.getDate()," 日");this.editorCtx.insertText({text:a});break;case"check":this.editorCtx.format("list","check");break;case"undo":this.editorCtx.undo();break;case"redo":this.editorCtx.redo();break;case"insertDivider":this.editorCtx.insertDivider();break;case"clear":this.editorCtx.clear();break;case"chooseImage":this.chooseImage();break;case"chooseImagebyCamera":this.chooseImage(!0);break;case"chooseMusic":this.chooseMusic();break;case"choosArticleTemplate":this.choosArticleTemplate();break}},choosArticleTemplate:function(){this.changeSwiper(3)},chooseMusic:function(){this.changeSwiper(4)},onStatusChange:function(t){this.formats=t.detail,console.log(this.formats)},chooseImage:function(e){var o=this,n=function(t){o.tempFilePaths=t.tempFiles.map((function(t){return{url:t.path,size:t.size,type:t.path.substring(t.path.lastIndexOf(".")+1,t.path.length),uid:o.getUid()}})),o.tempFilePaths.forEach((function(t){o.insertImage(t.url,t)}))},i=this.count,r=this.sizeType;setTimeout((function(){t.chooseImage({count:i,sizeType:r,sourceType:e?["camera"]:o.sourceType,success:n})}),100)},insertImage:function(t,e){var o=this;o.editorCtx.insertImage({src:t,data:{id:e.uid},extClass:"editor--editor-img",success:function(t){}})},uploadFile:function(e,o){var n=this;if(this.tempFilePaths.length){var i=this.url,r=this.name,a=this.header,s=this.formData,c=this.progress,l=this.tempFilePaths.shift();l.index=o?o+1:1;var u=l.uid,h=l.url;i&&h&&(this.uploadTask[u]=t.uploadFile({url:i,filePath:h,name:r,header:a,formData:s,success:function(t){return n.onSuccess(l,t)},fail:function(t){return n.onFail(l,t)},complete:function(t){delete n.uploadTask[u],n.$emit("complete",t),n.tempFilePaths.length&&(n.verifyFile(),n.uploadFile(e,l.index))}}),c&&this.uploadTask[u].onProgressUpdate((function(t){return n.onProgress(l,t,e)})))}},verifyFile:function(){var e=this,o=this.tempFilePaths[0],n=o.size,i=o.type;this.noAllowType.map((function(o){i==o&&(t.showToast({title:"不支持上传".concat(o,"图片"),icon:"none"}),e.tempFilePaths.shift())})),n/1024>1024*this.maxSize&&(t.showToast({title:"上传图片不能大于"+this.bytesToSize(1024*this.maxSize*1024)+"!",icon:"none"}),this.tempFilePaths.shift())},onSuccess:function(e,o){var n=JSON.parse(o.data);0==n.code?this.insertImage(n.data.path,e):t.showToast({title:"图片上传失败",icon:"none"})},onFail:function(e,o){t.showToast({title:"图片上传失败!",icon:"none"})},onProgress:function(e,o,n){100!=o.progress&&t.showToast({title:"正在上传图片".concat(e.index,"/").concat(n),icon:"none"});var i=c(c({},e),{},{progress:o.progress,res:o}),r={file:i};this.$emit("progress",r)},bytesToSize:function(t){if(0===t)return"0 B";var e=1024,o=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=Math.floor(Math.log(t)/Math.log(e));return(t/Math.pow(e,n)).toPrecision(3)+" "+o[n]},setValue:function(t){var e=this;this.editorCtx&&this.editorCtx.setContents({html:t,success:function(){e.getContents((function(t){e.onEditorInput({detail:{html:t.html,text:t.text}}),e.$emit("update",t)}))}})},getContents:function(t){this.editorCtx.getContents({success:function(e){t(e)}})},chooseAudio:function(){var e=this;console.log(0),t.chooseMessageFile({count:1,type:"file",extension:[".mp3",".m4a",".wav"],success:function(t){console.log(t),e.musicConfig.src=t.tempFiles[0].path,e.musicConfig.name=t.tempFiles[0].name,e.musicConfig.show=!0}})},playAudioFile:function(e){var o=t.createInnerAudioContext();o.src=e,o.autoplay=!0,o.play()},templateChange:function(t){this.currentTemplate=t;for(var e=0;e<this.templateConfig.length;e++)this.templateConfig[e].value===t?this.templateConfig[e].checked=!0:this.templateConfig[e].checked=!1},toPreview:function(){var e=this;t.getFileSystemManager().saveFile({tempFilePath:this.musicConfig.src,success:function(o){var n=o.savedFilePath;t.setStorageSync("musicSrc",n),t.setStorageSync("templateSrc",e.templateConfig[e.currentTemplate].src),e.editorCtx.getContents({success:function(e){console.log(e),t.setStorageSync("html",(0,a.handleHtmlImage)(e.html,!0))},complete:function(e){t.navigateTo({url:"/pages/preview/preview"})}})},fail:function(t){console.log(t)}})},save:function(){var e=this;this.editorCtx.getContents({success:function(o){console.log(o),o.html=(0,a.handleHtmlImage)(o.html,!0),e.$emit("save",o),t.showToast({title:"保存成功",icon:"none"})},complete:function(t){console.log("getContents complete")}})}}};e.default=l}).call(this,o(2)["default"],o(1)["default"])},605:function(t,e,o){"use strict";o.r(e);var n=o(606),i=o.n(n);for(var r in n)["default"].indexOf(r)<0&&function(t){o.d(e,t,(function(){return n[t]}))}(r);e["default"]=i.a},606:function(t,e,o){}}]);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/cu-editor/cu-editor.js.map
|
|
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
|
|
'components/cu-editor/cu-editor-create-component',
|
|
{
|
|
'components/cu-editor/cu-editor-create-component':(function(module, exports, __webpack_require__){
|
|
__webpack_require__('2')['createComponent'](__webpack_require__(599))
|
|
})
|
|
},
|
|
[['components/cu-editor/cu-editor-create-component']]
|
|
]);
|