mirror of
https://github.com/doocs/md.git
synced 2024-11-25 03:18:36 +08:00
3 lines
84 KiB
JavaScript
3 lines
84 KiB
JavaScript
|
(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("56d7")},"07db":function(e,t,o){},"0830":function(e,t,o){},"0d32":function(e,t,o){"use strict";o("2490")},"0f67":function(e,t,o){},1:function(e,t){},10:function(e,t){},11:function(e,t){},12:function(e,t){},13:function(e,t){},14:function(e,t){},15:function(e,t){},1663:function(e,t,o){"use strict";o("6af4")},2:function(e,t){},2490:function(e,t,o){},3:function(e,t){},"3f5e":function(module,__webpack_exports__,__webpack_require__){"use strict";var _fetch__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("e1d2"),_config__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("da71"),crypto_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("3452"),crypto_js__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(crypto_js__WEBPACK_IMPORTED_MODULE_2__),ali_oss__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("9b15"),ali_oss__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(ali_oss__WEBPACK_IMPORTED_MODULE_3__),minio__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("ad23"),minio__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(minio__WEBPACK_IMPORTED_MODULE_4__),cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("3438"),cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5__),buffer_from__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__("653c"),buffer_from__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(buffer_from__WEBPACK_IMPORTED_MODULE_6__),uuid__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__("ec26"),qiniu_js__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__("f744"),_assets_scripts_tokenTools__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__("4e00");function getConfig(e,t){if(e){const e="github"===t?_config__WEBPACK_IMPORTED_MODULE_1__["b"]:_config__WEBPACK_IMPORTED_MODULE_1__["a"],{username:o,repoList:i,branch:n,accessTokenList:s}=e,r=Math.floor(Math.random()*s.length),a=s[r].replace("doocsmd",""),l=Math.floor(Math.random()*i.length),c=i[l];return{username:o,repo:c,branch:n,accessToken:a}}const o=JSON.parse(localStorage.getItem(t+"Config")),i=o.repo.replace(`https://${t}.com/`,"").replace(`http://${t}.com/`,"").replace(t+".com/","").split("/");return{username:i[0],repo:i[1],branch:o.branch||"master",accessToken:o.accessToken}}function getDir(){const e=new Date,t=e.getFullYear(),o=(e.getMonth()+1).toString().padStart(2,"0"),i=e.getDate().toString().padStart(2,"0");return`${t}/${o}/${i}`}function getDateFilename(e){const t=(new Date).getTime(),o=e.split(".")[1];return`${t}-${Object(uuid__WEBPAC
|
|||
|
//!影响到右键菜单的点击事件,右键菜单的点击事件在组件内通过mousedown触发
|
|||
|
this.$store.commit("setRightClickMenuVisible",!1)}),this.editor.on("scroll",()=>{this.$store.commit("setRightClickMenuVisible",!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=>{We["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);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(){q(this.editor.getValue(0))},exportEditorContent(){this.$nextTick(()=>{B()})},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=L(t),t&&(localStorage.setItem("__editor_content",t),this.editor.setValue(t),this.$message.success("文档导入成功"))}},t.click(),e.removeChild(t)},formatContent(){const e=L(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.$store.commit("setRightClickMenuVisible",!0)},closeRightClickMenu(){this.$store.comm
|