mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
3 lines
99 KiB
JavaScript
3 lines
99 KiB
JavaScript
|
(function(e){function t(t){for(var o,a,s=t[0],c=t[1],l=t[2],_=0,d=[];_<s.length;_++)a=s[_],Object.prototype.hasOwnProperty.call(r,a)&&r[a]&&d.push(r[a][0]),r[a]=0;for(o in c)Object.prototype.hasOwnProperty.call(c,o)&&(e[o]=c[o]);u&&u(t);while(d.length)d.shift()();return i.push.apply(i,l||[]),n()}function n(){for(var e,t=0;t<i.length;t++){for(var n=i[t],o=!0,s=1;s<n.length;s++){var c=n[s];0!==r[c]&&(o=!1)}o&&(i.splice(t--,1),e=a(a.s=n[0]))}return e}var o={},r={app:0},i=[];function a(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=o,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)a.d(n,o,function(t){return e[t]}.bind(null,o));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="/md/";var s=window["webpackJsonp"]=window["webpackJsonp"]||[],c=s.push.bind(s);s.push=t,s=s.slice();for(var l=0;l<s.length;l++)t(s[l]);var u=c;i.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("56d7")},"04b8":function(e,t,n){"use strict";n("fa26")},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){},16:function(e,t){},17:function(e,t){},"1db6":function(e,t,n){"use strict";n("f9da")},2:function(e,t){},2395:function(e,t,n){},2631:function(e,t,n){"use strict";n("e141")},"2ac9":function(e,t,n){"use strict";n("3d2b")},"2d6b":function(e,t,n){},3:function(e,t){},"3a5e":function(e,t,n){"use strict";var o=n("5abf"),r=n("cb57"),i=(n("2ac9"),n("2877")),a=Object(i["a"])(r["default"],o["a"],o["b"],!1,null,"56759a2c",null);t["default"]=a.exports},"3d2b":function(e,t,n){},"3ea0":function(e,t,n){},"3f5e":function(module,__webpack_exports__,__webpack_require__){"use strict";var _home_runner_work_md_md_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("c7eb"),_home_runner_work_md_md_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("1da1"),core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("ac1f"),core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_2__),core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("5319"),core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_3__),core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("1276"),core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_4__),core_js_modules_es_date_to_string_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("0d03"),core_js_modules_es_date_to_string_js__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(core_js_modules_es_date_to_string_js__WEBPACK_IMPORTED_MODULE_5__),core_js_modules_es_string_pad_start_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__("4d90"),core_js_modules_es_string_pad_start_js__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(core_js_modules_es_string_pad_start_js__WEBPACK_IMPORTED_MODULE_6__),core_js_modules_es_error_to_string_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__("d401"),core_js_modules_es_error_to_string_js__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(core_js_modules_es
|
|||
|
//!影响到右键菜单的点击事件,右键菜单的点击事件在组件内通过mousedown触发
|
|||
|
e.$store.commit("setRightClickMenuVisible",!1)})),this.editor.on("scroll",(function(){e.$store.commit("setRightClickMenuVisible",!1)}))},initCssEditor:function(){var e=this;this.initCssEditorEntity(),this.cssEditor.on("keyup",(function(e,t){(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode)&&e.showHint(t)})),this.cssEditor.on("update",(function(t){e.cssChanged(),q(e.cssEditor,"__css_content")}))},cssChanged:function(){var e=$(this.cssEditor.getValue(0)),t=L(this.currentSize.replace("px",""));t=B(e,this.currentColor,t),this.setWxRendererOptions({theme:t}),this.onEditorRefresh()},codeThemeChanged:function(){var e=this.codeTheme,t=document.getElementById("hljs");if(void 0!=t)t.setAttribute("href",e);else{var n=document.createElement("link");n.setAttribute("type","text/css"),n.setAttribute("rel","stylesheet"),n.setAttribute("href",e),n.setAttribute("id","hljs"),document.head.appendChild(n)}},beforeUpload:function(e){var t=V(e);if(!t.ok)return this.$message.error(t.msg),!1;var n=localStorage.getItem("imgHost");n=n||"default",localStorage.setItem("imgHost",n);var o=localStorage.getItem("".concat(n,"Config")),r="default"==n||o;return!!r||(this.$message.error("请先配置 ".concat(n," 图床参数")),!1)},uploadImage:function(e,t){var n=this;this.isImgLoading=!0,N(e).then((function(o){Ze["a"].fileUpload(o,e).then((function(e){console.log(e),t?t(e):n.uploaded(e)}))["catch"]((function(e){n.$message.error(e.message)}))}))["catch"]((function(e){n.$message.error(e.message)})),this.isImgLoading=!1},uploaded:function(e){if(console.log("图片上传之后: ",e),e){this.dialogUploadImgVisible=!1;var t=this.editor.getCursor(),n=e,o="![](".concat(n,")");this.editor.replaceSelection("\n".concat(o,"\n"),t),this.$message.success("图片上传成功"),this.onEditorRefresh()}else this.$message.error("上传图片未知异常")},leftAndRightScroll:function(){var e=this,t=function(t){var r,i;clearTimeout(e.timeout),"preview"===t?(r=e.$refs.preview.$el,i=document.getElementsByClassName("CodeMirror-scroll")[0],e.editor.off("scroll",n),e.timeout=setTimeout((function(){e.editor.on("scroll",n)}),300)):"editor"===t&&(r=document.getElementsByClassName("CodeMirror-scroll")[0],i=e.$refs.preview.$el,i.removeEventListener("scroll",o,!1),e.timeout=setTimeout((function(){i.addEventListener("scroll",o,!1)}),300));var a=r.scrollTop/(r.scrollHeight-r.offsetHeight),s=a*(i.scrollHeight-i.offsetHeight);i.scrollTo(0,s)},n=function(){t("editor")},o=function(){t("preview")};this.$refs.preview.$el.addEventListener("scroll",o,!1),this.editor.on("scroll",n)},onEditorRefresh:function(){this.codeThemeChanged(this.codeTheme),this.editorRefresh(),setTimeout((function(){return window.PR.prettyPrint()}),0)},endCopy:function(){var e=this;this.backLight=!1,setTimeout((function(){e.isCoping=!1}),800)},addFormat:function(e){var t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=this.editor.doc.sel.ranges[0],i=r.head,a=r.anchor;i.line===a.line?i.ch<a.ch?(t=i,n=a):(t=a,n=i):(i.line,a.line,t=i,n=a);var s,c=[],l="",u=Object(le["a"])(this.editor.getValue());try{for(u.s();!(s=u.n()).done;){var _=s.value;"\n"===_?(c.push(l),l=""):l+=_}}catch(h){u.e(h)}finally{u.f()}c.push(l);for(var d="",m=0;m<c.length;m++){for(var f=c[m],p=0;p<f.length;p++)m===t.line&&p===t.ch&&(d+=e),m===n.line&&p===n.ch&&(d+=o),d+=f[p];m===n.line&&f.length===n.ch&&(d+=o),d+="\n"}this.editor.setValue(d)},importMD:function(e){this.editor.setValue(e),this.onEditorRefresh()},downloadEditorContent:function(){z(this.editor.getValue(0))},exportEditorContent:function(){this.$nextTick((function(){H()}))},importMarkdownContent:function(){var e=this,t=document.getElementById("menu"),n=document.createElement("input");n.type="file",n.name="filename",n.accept=".txt,.md",t.appendChild(n),n.onchange=function(){if(n.files){var t=n.files[0];if(/\.(txt|TXT|MD|md)$/.test(t.name)){var o=new FileReader;o.readAsText(t),o.onload=function(t){var n=t.target.result;n=W(n),n&&(localStorage.setItem("__editor_content",n),e.editor.setValue(n),e.$message.success("文档导入成功"))}}else e.$message.error("不支持的文档格式")}}
|