md/js/app.a4bf757c.js

3 lines
84 KiB
JavaScript
Raw Normal View History

(function(e){function t(t){for(var i,r,a=t[0],l=t[1],c=t[2],u=0,m=[];u<a.length;u++)r=a[u],Object.prototype.hasOwnProperty.call(n,r)&&n[r]&&m.push(n[r][0]),n[r]=0;for(i in l)Object.prototype.hasOwnProperty.call(l,i)&&(e[i]=l[i]);d&&d(t);while(m.length)m.shift()();return s.push.apply(s,c||[]),o()}function o(){for(var e,t=0;t<s.length;t++){for(var o=s[t],i=!0,a=1;a<o.length;a++){var l=o[a];0!==n[l]&&(i=!1)}i&&(s.splice(t--,1),e=r(r.s=o[0]))}return e}var i={},n={app:0},s=[];function r(t){if(i[t])return i[t].exports;var o=i[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=i,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(o,i,function(t){return e[t]}.bind(null,i));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/md/";var a=window["webpackJsonp"]=window["webpackJsonp"]||[],l=a.push.bind(a);a.push=t,a=a.slice();for(var c=0;c<a.length;c++)t(a[c]);var d=l;s.push([0,"chunk-vendors"]),o()})({0:function(e,t,o){e.exports=o("3479")},1:function(e,t){},10:function(e,t){},"107b":function(e,t,o){},11:function(e,t){},12:function(e,t){},13:function(e,t){},14:function(e,t){},15:function(e,t){},"1cd3":function(e,t,o){"use strict";var i=o("9ad5"),n=o.n(i);const s=n.a.create({baseURL:"",timeout:3e4});s.interceptors.request.use(e=>(/^(post)|(put)|(delete)$/i.test(e.method)&&e.data&&e.data.upload&&(e.headers["Content-Type"]="multipart/form-data"),e),e=>{Promise.reject(e)}),s.interceptors.response.use(e=>e.data?e.data:Promise.reject(e),e=>Promise.reject(e)),t["a"]=s},2:function(e,t){},"202b":function(e,t,o){},"24f4":function(e,t,o){"use strict";o("2c25")},"2c25":function(e,t,o){},"2dab":function(e,t,o){},3:function(e,t){},3479:function(e,t,o){"use strict";o.r(t);var i=o("ff9b"),n=function(){var e=this,t=e._self._c;return t("div",{attrs:{id:"app"}},[t("router-view")],1)},s=[],r=(o("f961"),o("24f4"),o("2b5f")),a={},l=Object(r["a"])(a,n,s,!1,null,null,null),c=l.exports,d=o("358c"),u={builtinFonts:[{label:"无衬线",value:"-apple-system-font,BlinkMacSystemFont, Helvetica Neue, PingFang SC, Hiragino Sans GB , Microsoft YaHei UI , Microsoft YaHei ,Arial,sans-serif",desc:"Abc"},{label:"衬线",value:"Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif",desc:"Abc"}],sizeOption:[{label:"12px",value:"12px",desc:"更小"},{label:"13px",value:"13px",desc:"稍小"},{label:"14px",value:"14px",desc:"推荐"},{label:"15px",value:"15px",desc:"稍大"},{label:"16px",value:"16px",desc:"更大"}],colorOption:[{label:"经典蓝",value:"rgba(15, 76, 129, 1)",desc:"最新流行"},{label:"翡翠绿",value:"rgba(0, 152, 116, 1)",desc:"优雅清新"},{label:"活力橘",value:"rgba(250, 81, 81, 1)",desc:"热情活泼"}],codeThemeOption:[{label:"github",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/github.min.css",desc:"light"},{label:"solarized-light",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/solarized-light.min.css",desc:"light"},{label:"atom-one-dark",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/atom-one-dark.min.css",desc:"dark"},{label:"obsidian",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/obsidian.min.css",desc:"dark"},{label:"vs2015",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/vs2015.min.css",desc:"dark"}],form:{rows:1,cols:1}},m=(o("aa9c"),o("c6de")),p=o("
//!影响到右键菜单的点击事件右键菜单的点击事件在组件内通过mousedown触发
this.rightClickMenuVisible=!1}),this.editor.on("scroll",()=>{this.rightClickMenuVisible=!1})},initCssEditor(){this.initCssEditorEntity(),this.cssEditor.on("keyup",(e,t)=>{(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode)&&e.showHint(t)}),this.cssEditor.on("update",e=>{this.cssChanged(),j(this.cssEditor,"__css_content")})},cssChanged(){let e=K(this.cssEditor.getValue(0)),t=P(this.currentSize.replace("px",""));t=R(e,this.currentColor,t),this.setWxRendererOptions({theme:t}),this.onEditorRefresh()},codeThemeChanged(){let e=this.codeTheme,t=document.getElementById("hljs");if(void 0!=t)t.setAttribute("href",e);else{const t=document.createElement("link");t.setAttribute("type","text/css"),t.setAttribute("rel","stylesheet"),t.setAttribute("href",e),t.setAttribute("id","hljs"),document.head.appendChild(t)}},beforeUpload(e){const t=H(e);if(!t.ok)return this.$message.error(t.msg),!1;let o=localStorage.getItem("imgHost");o=o||"default",localStorage.setItem("imgHost",o);const i=localStorage.getItem(o+"Config"),n="default"==o||i;return!!n||(this.$message.error(`请先配置 ${o} 图床参数`),!1)},uploadImage(e,t){this.isImgLoading=!0,z(e).then(o=>{mt["a"].fileUpload(o,e).then(e=>{console.log(e),t?t(e):this.uploaded(e)}).catch(e=>{this.$message.error(e.message)})}).catch(e=>{this.$message.error(e.message)}),this.isImgLoading=!1},uploaded(e){if(console.log("图片上传之后: ",e),!e)return void this.$message.error("上传图片未知异常");this.dialogUploadImgVisible=!1;const t=this.editor.getCursor(),o=e,i=`![](${o})`;this.editor.replaceSelection(`\n${i}\n`,t),this.$message.success("图片上传成功"),this.onEditorRefresh()},leftAndRightScroll(){const e=e=>{let i,n;clearTimeout(this.timeout),"preview"===e?(i=this.$refs.preview.$el,n=document.getElementsByClassName("CodeMirror-scroll")[0],this.editor.off("scroll",t),this.timeout=setTimeout(()=>{this.editor.on("scroll",t)},300)):"editor"===e&&(i=document.getElementsByClassName("CodeMirror-scroll")[0],n=this.$refs.preview.$el,n.removeEventListener("scroll",o,!1),this.timeout=setTimeout(()=>{n.addEventListener("scroll",o,!1)},300));let s=i.scrollTop/(i.scrollHeight-i.offsetHeight),r=s*(n.scrollHeight-n.offsetHeight);n.scrollTo(0,r)},t=()=>{e("editor")},o=()=>{e("preview")};this.$refs.preview.$el.addEventListener("scroll",o,!1),this.editor.on("scroll",t)},onEditorRefresh(){this.codeThemeChanged(this.codeTheme),this.editorRefresh(),setTimeout(()=>window.PR.prettyPrint(),0)},endCopy(){this.backLight=!1,setTimeout(()=>{this.isCoping=!1},800)},addFormat(e,t=e){const{head:o,anchor:i}=this.editor.doc.sel.ranges[0];let n,s;o.line===i.line?o.ch<i.ch?(n=o,s=i):(n=i,s=o):o.line<i.line?(n=o,s=i):(n=i,s=o);const r=[];let a="";for(const c of this.editor.getValue())"\n"===c?(r.push(a),a=""):a+=c;r.push(a);let l="";for(let c=0;c<r.length;c++){const o=r[c];for(let i=0;i<o.length;i++)c===n.line&&i===n.ch&&(l+=e),c===s.line&&i===s.ch&&(l+=t),l+=o[i];c===s.line&&o.length===s.ch&&(l+=t),l+="\n"}this.editor.setValue(l)},importMD(e){this.editor.setValue(e),this.onEditorRefresh()},downloadEditorContent(){U(this.editor.getValue(0))},exportEditorContent(){this.$nextTick(()=>{q(),document.getElementById("output").innerHTML=this.output})},importMarkdownContent(){let e=document.getElementById("menu"),t=document.createElement("input");t.type="file",t.name="filename",t.accept=".txt,.md",e.appendChild(t),t.onchange=()=>{if(!t.files)return;const e=t.files[0];if(!/\.(txt|TXT|MD|md)$/.test(e.name))return void this.$message.error("不支持的文档格式");const o=new FileReader;o.readAsText(e),o.onload=e=>{let t=e.target.result;t=B(t),t&&(localStorage.setItem("__editor_content",t),this.editor.setValue(t),this.$message.success("文档导入成功"))}},t.click(),e.removeChild(t)},formatContent(){const e=B(this.editor.getValue(0));localStorage.setItem("__editor_content",e),this.editor.setValue(e)},openMenu(e){const t=105,o=this.$el.getBoundingClientRect().left,i=this.$el.offsetWidth,n=i-t,s=e.clientX-o;this.mouseLeft=Math.min(n,s),this.mouseTop=e.clientY+10,this.rightClickMenuVisible=!0},onMenuEvent(e){switch(e){case"re