You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
31 KiB
14 lines
31 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[194],{"7ahc":function(ee,P,e){"use strict";e.d(P,"a",function(){return ue});var B=e("k1fw"),Q=e("0Owb"),re=e("+L6B"),y=e("2/Rp"),j=e("y8nQ"),r=e("Vl3Y"),t=e("tJVT"),v=e("OaEy"),U=e("2fM7"),_=e("q1tI"),u=e.n(_),E=e("VrN/"),I=e.n(E),V=e("p77/"),ie=e.n(V),ve=e("c5Ni"),ce=e.n(ve),X=U.a.Option,i={labelCol:{span:4},wrapperCol:{span:20}},te={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};P.b=function($){var G=$.callback,oe=$.onCancel,de=Object(_.useState)("python"),z=Object(t.a)(de,2),be=z[0],b=z[1];function _e(f){b(te[f][1])}function Z(f){G(f)}return u.a.createElement(r.a,Object(Q.a)({},i,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:Z}),u.a.createElement(r.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},u.a.createElement(U.a,{onChange:_e},Object.keys(te).map(function(f){return u.a.createElement(X,{key:f,value:f},te[f][0])}))),u.a.createElement(r.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},u.a.createElement(ue,{mode:be})),u.a.createElement("div",{className:"flex-container flex-end"},u.a.createElement(y.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),u.a.createElement(y.a,{type:"ghost",onClick:oe},"\u53D6\u6D88")))};function ue($){var G=$.value,oe=$.onChange,de=$.mode,z=$.options,be=z===void 0?{}:z,b=Object(_.useRef)(),_e=Object(_.useState)(),Z=Object(t.a)(_e,2),f=Z[0],De=Z[1];return Object(_.useEffect)(function(){if(f){var Ce=function(c){var m=c.getValue();oe&&oe(m)};return f.on("change",Ce),function(){f.off("change",Ce)}}},[f,oe]),Object(_.useEffect)(function(){f&&f.setOption("mode",de)},[f,de]),Object(_.useEffect)(function(){f&&((G!==f.getValue()||G==="")&&setTimeout(function(){f.setValue(G||" ")},300))},[f,G]),Object(_.useEffect)(function(){if(b.current&&!f){var Ce=I.a.fromTextArea(b.current,Object(B.a)({mode:de,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},be));De(Ce)}},[b.current,f]),u.a.createElement("div",{className:"my-codemirror-container"},u.a.createElement("textarea",{ref:b}))}},"9Bee":function(ee,P,e){"use strict";var B=e("q1tI"),Q=e.n(B),re=e("vg9a"),y=e("tJVT"),j=e("DlQD"),r=e.n(j),t=e("rUJ1");function v(d,c){var m=d.match(/^(\s+)(?:```)/);if(m===null)return c;var p=m[1];return c.split(`
|
|
`).map(function(x){var H=x.match(/^\s+/);if(H===null)return x;var J=Object(y.a)(H,1),ae=J[0];return ae.length>=p.length?x.slice(p.length):x}).join(`
|
|
`)}var U=[],_=["<ul>"],u=new r.a.Renderer,E=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function I(){U.length=0,_=["<ul>"]}function V(d,c,m,p){if(c>=d.length||d[c].level<=m)return c;var x=d[c];p.push("<li><a href='#"+x.anchor+"'>"+x.text+"</a>"),c++;var H=[];return c=V(d,c,x.level,H),H.length>0&&(p.push("<ul>"),H.forEach(function(J){p.push(J)}),p.push("</ul>")),p.push("</li>"),c=V(d,c,m,p),c}function ie(){return V(U,0,0,_),_.push("</ul>"),_.join("")}var ve={heading:function(c){var m=E.exec(c);if(m)return{type:"heading",raw:m[0],depth:m[1].length,text:m[2]}},fences:function(c){var m=this.rules.block.fences.exec(c);if(m){var p=m[0],x=v(p,m[3]||""),H=m[2]?m[2].trim():m[2];if(["latex","katex","math"].indexOf(H)>=0){var J=i(),ae=x;x=J,te[J]={type:"block",expression:ae}}return{type:"code",raw:p,lang:H,text:x}}}},ce=/(?:\${2})([^\n`]+?)(?:\${2})/gi,X=0,i=function(){return"__special_katext_id_".concat(X++,"__")},te={};function ue(){return te}function $(){X=0,te={}}function G(d){return d=d.replace(ce,function(c,m){var p=i();return te[p]={type:"inline",expression:m},p}),d}var oe=u.listitem;u.listitem=function(d){return oe(G(d))};var de=u.paragraph;u.paragraph=function(d){return de(G(d))};var z=u.tablecell;u.tablecell=function(d,c){return z(G(d),c)},u.code=function(d,c,m){var p=(c||"").match(/\S*/)[0];return p?["latex","katex","math"].indexOf(p)>=0?"<p class='editormd-tex'>".concat(d,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(c,'">').concat(m?d:Object(t.escape)(d,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(m?d:Object(t.escape)(d,!0))+"</code></pre>"},u.heading=function(d,c,m){var p=this.options.headerPrefix+m.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return U.push({anchor:p,level:c,text:d}),"<h"+c+' id="'+p+'">'+d+"</h"+c+">"},r.a.setOptions({silent:!0,smartypants:!0,gfm:!0,pedantic:!1}),r.a.use({tokenizer:ve,renderer:u});var be=r.a,b=e("SJMd"),_e=e("m3rI"),Z=e("Oy/b"),f=/<pre[^>]*>/g;function De(d){var c=document.createElement("div");return c.innerHTML=d,c.childNodes.length===0?"":c.childNodes[0].nodeValue}var Ce=P.a=function(d){var c=d.value,m=c===void 0?"":c,p=d.className,x=d.style,H=x===void 0?{}:x,J=String(m),ae=Object(B.useMemo)(function(){try{var D=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,F=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Le=/\(\s+\/files\/uploads\/|\(\/files\/uploads\//g;J=J.replace(D,"("+_e.a.API_SERVER+"/api/attachments/").replace(F,'"'+_e.a.API_SERVER+"/api/attachments/").replace(Le,'"'+_e.a.API_SERVER+"/files/uploads/")}catch(Oe){}var N=be(J),Ve=ue();return J.match(/\[TOC\]/)&&(N=N.replace("<p>[TOC]</p>",ie()),I()),N=N.replace(/(__special_katext_id_\d+__)/g,function(Oe,Re){var le=Ve[Re],se=le.type,me=le.expression;return Object(Z.renderToString)(De(me)||"",{displayMode:se==="block",throwOnError:!1,output:"html"})}),N=N.replace(/▁/g,"\u2581\u2581\u2581"),$(),N},[J]),he=Object(B.useRef)();function ge(D){var F=D.target;if(F.tagName.toUpperCase()==="A"){var Le=F.getAttribute("href");if(Le.startsWith("#")){D.preventDefault();var N=document.getElementById(Le.replace("#",""));N&&N.scrollIntoView(!0)}}}return Object(B.useEffect)(function(){if(he.current&&ae&&(ae.match(f)&&window.PR.prettyPrint()),he.current)return he.current.addEventListener("click",ge),function(){he.current.removeEventListener("click",ge),$(),I()}},[ae,he.current,ge]),Q.a.createElement("div",{ref:he,style:H,className:"".concat(p||""," markdown-body"),dangerouslySetInnerHTML:{__html:ae}})}},"9VGf":function(ee,P,e){"use strict";e.d(P,"a",function(){return re});var B=e("q1tI"),Q=e.n(B);function re(y,j){var r=Object(B.useRef)();Object(B.useEffect)(function(){r.current=y}),Object(B.useEffect)(function(){function t(){r.current()}if(j!==null){var v=setInterval(t,j);return function(){return clearInterval(v)}}},[j])}},BjJ7:function(ee,P,e){"use strict";e.d(P,"d",function(){return Q}),e.d(P,"c",function(){return re}),e.d(P,"e",function(){return y}),e.d(P,"b",function(){return j}),e.d(P,"a",function(){return t});var B=e("m3rI");function Q(v){var U=!0;if(v.length>0){for(var _=0;_<v.length;_++)if(v[_].compile_success==0||!v[_].compile_success){U=!1;break}}else U=!1;return U}function re(v){for(var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",_=[],u=0;u<v.length;u++){var E=v[u],I=U?"".concat(U,"/").concat(E.name):"".concat(E.name);_.push({title:E.name,isLeaf:!(E.type==="tree"),key:I})}return _}function y(v,U,_){for(var u=0;u<v.length;u++){var E=v[u];if(E.key===U){E.children=_;break}E.children&&y(E.children,U,_)}return v}function j(v,U,_){var u;return function(){var E=this,I=arguments,V=function(){u=null,_||v.apply(E,I)},ie=_&&!u;clearTimeout(u),u=setTimeout(V,U),ie&&v.apply(E,I)}}var r=!0,t=B.a.API_SERVER},"C+DQ":function(ee,P,e){},HmJG:function(ee,P,e){},M8RZ:function(ee,P,e){"use strict";e.d(P,"a",function(){return U});var B=e("fWQN"),Q=e("mtLc"),re=e("yKVA"),y=e("879j"),j=e("q1tI"),r=e.n(j),t=e("i8i4"),v=e.n(t),U=function(_){Object(re.a)(E,_);var u=Object(y.a)(E);function E(I){var V;Object(B.a)(this,E),V=u.call(this,I);var ie=window.document;return V.node=ie.createElement("div"),ie.body.appendChild(V.node),V}return Object(Q.a)(E,[{key:"render",value:function(){var V=this.props.children;return Object(t.createPortal)(V,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),E}(r.a.Component)},Ot1p:function(ee,P,e){"use strict";var B=e("2qtc"),Q=e("kLXV"),re=e("rAM+"),y=e("tJVT"),j=e("jrin"),r=e("q1tI"),t=e.n(r),v=e("VrN/"),U=e.n(v),_=e("bdgK"),u=e("p77/"),E=e("Bd2K"),I=e("ELLl"),V=e("19Vz"),ie=e("lZu9"),ve=e("kSUc"),ce=e("9Bee"),X=e("0Owb"),i=e("dejd"),te=e("C+DQ"),ue=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function $(n){var K=n.onActionCallback,C=n.title,M=n.icon,W=n.actionName,ye=n.className,Ue=ye===void 0?"":ye,pe=n.children;function Se(){K(W)}return t.a.createElement("a",{title:C,className:Ue,onClick:Se},t.a.createElement("i",{className:"md-iconfont ".concat(M)}),pe)}var G=function(n){var K=n.watch,C=n.showNullButton,M=n.onActionCallback,W=n.fullScreen,ye=[].concat(ue,[{title:"".concat(K?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(K?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return t.a.createElement("ul",{className:"markdown-toolbar-container"},ye.map(function(Ue,pe){return t.a.createElement("li",{key:pe},Ue.actionName?t.a.createElement($,Object(X.a)({},Ue,{onActionCallback:M})):t.a.createElement("span",{className:"v-line"}))}),C?t.a.createElement("li",null,t.a.createElement($,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:M},t.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,t.a.createElement("li",{className:"btn-full-screen"},t.a.createElement($,{icon:"".concat(W?"icon-shrink":"icon-enlarge"),title:W?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:M})))},oe=e("M8RZ"),de=e("+L6B"),z=e("2/Rp"),be=e("y8nQ"),b=e("Vl3Y"),_e=e("5NDa"),Z=e("5rEg"),f={labelCol:{span:4},wrapperCol:{span:20}},De=function(n){var K=n.callback,C=n.onCancel;function M(W){K(W)}return t.a.createElement(b.a,Object(X.a)({},f,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:M}),t.a.createElement(b.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},t.a.createElement(Z.a,null)),t.a.createElement(b.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},t.a.createElement(Z.a,null)),t.a.createElement("div",{className:"flex-container flex-end"},t.a.createElement(z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),t.a.createElement(z.a,{type:"ghost",onClick:C},"\u53D6\u6D88")))},Ce=e("7ahc"),d=e("HmJG"),c=e("BjJ7"),m=b.a.useForm,p={width:280,marginRight:10},x={labelCol:{span:5},wrapperCol:{span:19}},H=function(n){var K=n.callback,C=n.onCancel,M=m(),W=Object(y.a)(M,1),ye=W[0];function Ue(Te){K(Te)}function pe(Te){ye.setFieldsValue({src:"/api/attachments/".concat(Te.id)})}function Se(Te){var Xe=Te.target.files[0];ae(Xe,pe)}return t.a.createElement(b.a,Object(X.a)({form:ye},x,{className:"upload-image-panel",onFinish:Ue}),t.a.createElement(b.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},t.a.createElement("div",{className:"flex-container"},t.a.createElement(b.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},t.a.createElement(Z.a,{style:p})),t.a.createElement(J,{onFileChange:Se}))),t.a.createElement(b.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u63CF\u8FF0"}]},t.a.createElement(Z.a,{style:{width:264}})),t.a.createElement(b.a.Item,{style:{textAlign:"right"}},t.a.createElement(z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),t.a.createElement(z.a,{type:"ghost",onClick:C},"\u53D6\u6D88")))};function J(n){var K=n.onFileChange;return t.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",t.a.createElement("input",{type:"file",accept:"image/*",onChange:K}))}function ae(n,K){if(!n)throw new String("\u6CA1\u6709\u6587\u4EF6");var C=new FormData;C.append("editormd-image-file",n),C.append("file_param_name","editormd-image-file"),C.append("byxhr","true");var M=new window.XMLHttpRequest;M.withCredentials=!0,M.addEventListener("load",function(W){K(JSON.parse(W.target.responseText))},!1),M.addEventListener("error",function(W){console.error(W)},!1),M.open("POST","".concat(c.a,"/api/attachments.json")),M.send(C)}var he=e("giR+"),ge=e("fyUT"),D=e("7Kak"),F=e("9yH6"),Le=F.a.Group,N={margin:"0 8px"},Ve=function(n){var K=n.callback,C=n.onCancel;function M(W){K(W)}return t.a.createElement(b.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:M},t.a.createElement("div",{className:"flex-container"},t.a.createElement("span",{style:N},"\u5355\u5143\u683C\u6570\uFF1A"),t.a.createElement("span",{style:N},"\u884C\u6570"),t.a.createElement(b.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},t.a.createElement(ge.a,null)),t.a.createElement("span",{style:N},"\u5217\u6570"),t.a.createElement(b.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},t.a.createElement(ge.a,null))),t.a.createElement("div",{className:"flex-container",style:{marginTop:12}},t.a.createElement("span",{style:N},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),t.a.createElement(b.a.Item,{name:"align"},t.a.createElement(Le,null,t.a.createElement(F.a,{value:"default"},t.a.createElement("i",{className:"fa fa-align-justify"})),t.a.createElement(F.a,{value:"left"},t.a.createElement("i",{className:"fa fa-align-left"})),t.a.createElement(F.a,{value:"center"},t.a.createElement("i",{className:"fa fa-align-center"})),t.a.createElement(F.a,{value:"right"},t.a.createElement("i",{className:"fa fa-align-right"}))))),t.a.createElement("div",{className:"flex-container flex-end"},t.a.createElement(z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),t.a.createElement(z.a,{type:"ghost",onClick:C},"\u53D6\u6D88")))},Oe="link",Re="upload-image",le="code-block",se="add-table",me="------------",Pe={default:me,left:":".concat(me),center:":".concat(me,":"),right:"".concat(me,":")},Ze=e("9VGf"),Ne,Ee;function T(){}var h=0,S=1e4,O="\u2581";function L(n){return/^\d+$/.test(n)?"".concat(n,"px"):n}var Me=navigator.platform.toUpperCase().indexOf("MAC")>=0,Ae=Me?"Cmd":"Ctrl",q=(Ne={},Object(j.a)(Ne,Ae+"-B","bold"),Object(j.a)(Ne,Ae+"-I","italic"),Ne),fe=(Ee={},Object(j.a)(Ee,Oe,"\u6DFB\u52A0\u94FE\u63A5"),Object(j.a)(Ee,le,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(j.a)(Ee,Re,"\u6DFB\u52A0\u56FE\u7247"),Object(j.a)(Ee,se,"\u6DFB\u52A0\u8868\u683C"),Ee),Fe=P.a=function(n){var K=n.defaultValue,C=K===void 0?"":K,M=n.onChange,W=n.width,ye=W===void 0?"100%":W,Ue=n.height,pe=Ue===void 0?400:Ue,Se=n.miniToolbar,Te=Se===void 0?!1:Se,Xe=n.isFocus,it=Xe===void 0?!1:Xe,qe=n.watch,ct=n.id,$e=ct===void 0?"markdown-editor-id":ct,ut=n.showResizeBar,xt=ut===void 0?!1:ut,dt=n.noStorage,Nt=dt===void 0?!1:dt,_t=n.showNullButton,St=_t===void 0?!1:_t,mt=n.fullScreen,ze=mt===void 0?!1:mt,et=n.onBlur,tt=n.onCMBeforeChange,Et=n.className,Bt=Et===void 0?"":Et,ft=n.placeholder,It=ft===void 0?"":ft,pt=n.values,at=pt===void 0?"":pt,Ft=Object(r.useState)(null),vt=Object(y.a)(Ft,2),a=vt[0],Kt=vt[1],Wt=Object(r.useState)(C),ht=Object(y.a)(Wt,2),nt=ht[0],He=ht[1],kt=Object(r.useState)(qe),gt=Object(y.a)(kt,2),je=gt[0],Ot=gt[1],wt=Object(r.useState)(ze),Rt=Object(y.a)(wt,2),xe=Rt[0],Pt=Rt[1],Vt=Object(r.useState)(""),yt=Object(y.a)(Vt,2),Be=yt[0],Ie=yt[1],Xt=Object(r.useState)(0),Ut=Object(y.a)(Xt,2),Ke=Ut[0],rt=Ut[1],$t=Object(r.useState)(pe),bt=Object(y.a)($t,2),ot=bt[0],Dt=bt[1],zt=Object(r.useState)(!1),Ct=Object(y.a)(zt,2),Qt=Ct[0],lt=Ct[1],We=Object(r.useRef)(),ke=Object(r.useRef)(),Je=Object(r.useRef)(),Ge=Object(r.useRef)();Object(r.useEffect)(function(){He(at),a==null||a.setValue(at)},[at]),Object(r.useEffect)(function(){if(We.current){var o=function(g,R){var A=R.clipboardData;if(A){var k=A.types.toString(),Y=A.items;if(k==="text/html,Files"||k==="Files"){var w=Y[1];k==="Files"&&(w=Y[0]),w.kind==="file"&&w.type.match(/^image\//i)&&ae(w.getAsFile(),function(ne){ne.id?l.replaceSelection("")):(ne==null?void 0:ne.status)===401&&(document.location.href="/user/login")})}else return!0}return!0},l=U.a.fromTextArea(We.current,{mode:"markdown",inputStyle:"contenteditable",lineNumbers:!Te,lineWrapping:!0,value:C,autoCloseTags:!0,autoCloseBrackets:!0});return l.on("paste",o),Kt(l),function(){l.off("paste",o)}}},[]);var Lt=Object(r.useCallback)(function(){if(ke.current)try{var o=ke.current.getElementsByClassName("markdown-toolbar-container")[0].offsetHeight,l=ke.current.getElementsByClassName("markdown-editor-body")[0];xe?l.style.height="calc(100vh - ".concat(o,"px)"):l.style.height="".concat(ot-o,"px")}catch(s){console.log(s,"---- to set md editor body height")}},[ot,ke,xe]);Object(r.useEffect)(function(){function o(){var s=new _.default(function(g){var R=Object(re.a)(g),A;try{for(R.s();!(A=R.n()).done;){var k=A.value;(k.target.offsetHeight>0||k.target.offsetWidth>0)&&(Lt(),a.setSize("100%","100%"),a.refresh())}}catch(Y){R.e(Y)}finally{R.f()}});return s.observe(We.current.parentElement),s}if(a){var l=o();return function(){l.unobserve(We.current.parentElement)}}},[a,Lt]),Object(r.useEffect)(function(){if(a){for(var o=[],l=function(){var k=g[s];R=Object(y.a)(k,2);var Y=R[0],w=R[1],ne=Object(j.a)({},Y,function(){Mt(w)});o.push(ne),a.addKeyMap(ne)},s=0,g=Object.entries(q);s<g.length;s++){var R;l()}return function(){var A=Object(re.a)(o),k;try{for(A.s();!(k=A.n()).done;){var Y=k.value;a.removeKeyMap(Y)}}catch(w){A.e(w)}finally{A.f()}}}},[a]),Object(r.useEffect)(function(){ze!==xe&&Pt(ze)},[ze]),Object(Ze.a)(function(){if(!Nt&&Ke>0){var o=new Date().getTime(),l=window.sessionStorage.getItem($e);o>=Ke+S&&(!l||l!==nt)&&(window.sessionStorage.setItem($e,nt),lt(!0))}},S),Object(r.useEffect)(function(){Ot(qe)},[a,qe]),Object(r.useEffect)(function(){a&&(it&&a.focus())},[a,it]),Object(r.useEffect)(function(){if(je&&a){var o=function(g){var R=g.target;if(Ge.current){var A=R.scrollTop/R.scrollHeight;Ge.current.scrollTop=Ge.current.scrollHeight*A}},l=a.getScrollerElement();return l.addEventListener("scroll",o),function(){l.removeEventListener("scroll",o)}}},[a,je]),Object(r.useEffect)(function(){if(a&&tt){var o=function(s,g){tt(s,g)};return a.on("beforeChange",o),function(){a.off("beforeChange",o)}}},[a,tt]),Object(r.useEffect)(function(){if(a&&et){var o=function(){et(a.getValue())};return a.on("blur",o),function(){a.off("blur",o)}}},[a,et]),Object(r.useEffect)(function(){if(a){var o=function(s){var g=s.getValue();He(g),rt(new Date().getTime()),s.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),M&&M(g)};return a.on("change",o),function(){a.off("change",o)}}},[a,M]),Object(r.useEffect)(function(){a&&(C==null?(a.setValue(""),He("")):C!==a.getValue()&&(a.setValue(C),He(C)))},[a,C]);var Mt=Object(r.useCallback)(function(o){var l=a.getCursor(),s=a.getSelection(),g=s.split(`
|
|
`);switch(o){case"bold":return a.replaceSelection("**"+s+"**"),s===""&&a.setCursor(l.line,l.ch+2),a.focus();case"italic":return a.replaceSelection("*"+s+"*"),s===""&&a.setCursor(l.line,l.ch+1),a.focus();case"code":return a.replaceSelection("`"+s+"`"),s===""&&a.setCursor(l.line,l.ch+1),a.focus();case"inline-latex":return a.replaceSelection("`$$"+s+"$$`"),s===""&&a.setCursor(l.line,l.ch+3),a.focus();case"latex":return a.replaceSelection("```latex\n"+s+"\n```"),a.setCursor(l.line+1,s.length+1),a.focus();case"line-break":return a.replaceSelection(`<br/>
|
|
`),a.focus();case"list-ul":return s===""?a.replaceSelection("- "+s):a.replaceSelection(g.map(function(R){return R===""?"":"- ".concat(R)}).join(`
|
|
`)),a.focus();case"list-ol":return s===""?a.replaceSelection("1. "+s):a.replaceSelection(g.map(function(R,A){return R===""?"":"".concat(A+1,". ").concat(R)}).join(`
|
|
`)),a.focus();case"add-null-ch":return s===""&&a.setCursor(l.line,l.ch+1),a.replaceSelection(O),a.focus();case"eraser":return a.setValue(""),a.focus();case"trigger-watch":return Ot(!je),a.focus();case"trigger-full-screen":return Pt(!xe),a.focus();case Oe:Ie(Oe);return;case le:Ie(le);return;case Re:Ie(Re);return;case se:Ie(se);return;default:throw new Error}},[a,je,xe]),Ye=Object(r.useCallback)(function(o){Ie("");switch(Be){case Oe:var l=o.title,s=o.link;return a.replaceSelection("[".concat(l,"](").concat(s,")")),a.focus();case le:var g=o.language,R=o.content;return a.replaceSelection(["```"+g,R,"```"].join(`
|
|
`)),a.focus();case Re:var A=o.src,k=o.alt;return a.replaceSelection(".concat(A,' "').concat(k,'" )')),a.focus();case se:for(var Y=o.row,w=o.col,ne=o.align,st=`
|
|
`,Qe=0;Qe<Y;Qe++){for(var At=[],Tt=[],jt=0;jt<w;jt++)Qe===1&&Tt.push(Pe[ne]),At.push(" ");Qe===1&&(st+="| ".concat(Tt.join(" | "),` |
|
|
`)),st+="| ".concat(At.join(w===1?"":" | "),` |
|
|
`)}return a.replaceSelection(st+`
|
|
`),a.focus();default:throw new Error}},[a,Be]),Ht=Object(r.useMemo)(function(){switch(Be){case Oe:return t.a.createElement(De,{callback:Ye,onCancel:we});case le:return t.a.createElement(Ce.b,{callback:Ye,onCancel:we});case Re:return t.a.createElement(H,{callback:Ye,onCancel:we});case se:return t.a.createElement(Ve,{callback:Ye,onCancel:we});default:return null}},[Be]);function we(){Ie("")}Object(r.useEffect)(function(){if(Je.current){var o=function(Y){R=!0,A=Y.pageY},l=function(){R=!1},s=function(Y){if(R){var w=Y.pageY-A;w<0&&(w=0),w>300&&(w=300);var ne=pe+w+"px";Dt(ne)}},g=Je.current,R=!1,A=0;return g.addEventListener("mousedown",o),document.addEventListener("mousemove",s),document.addEventListener("mouseup",l),function(){g.removeEventListener("mousedown",o),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l)}}},[a,Je]),Object(r.useEffect)(function(){Dt(pe)},[pe]);var Jt=L(ye),Gt=L(ot),Yt={width:Jt,height:Gt},Zt=Object(r.useMemo)(function(){if(Ke){var o=new Date(Ke),l=o.getHours(),s=o.getMinutes(),g=o.getSeconds();return l=l<10?"0"+l:l,s=s<10?"0"+s:s,g=g<10?"0"+g:g,"".concat(l,":").concat(s,":").concat(g)}return 0},[Ke]);function qt(){window.sessionStorage.removeItem($e),lt(!1),rt(0)}function ea(){lt(!1),rt(0),a.setValue(window.sessionStorage.getItem($e))}return t.a.createElement(r.Fragment,null,t.a.createElement("div",{className:"markdown-editor-wrapper",ref:ke},t.a.createElement("div",{className:"markdown-editor-container ".concat(Bt," ").concat(je?"on-preview":""," ").concat(Te?"mini":""," ").concat(xe?"full-screen":""),style:Yt},t.a.createElement(G,{watch:je,fullScreen:xe,showNullButton:St,onActionCallback:Mt}),t.a.createElement("div",{className:"markdown-editor-body"},t.a.createElement("div",{className:"codemirror-container"},t.a.createElement("textarea",{ref:We,placeholder:It})),je?t.a.createElement("div",{ref:Ge,className:"preview-container"},t.a.createElement(ce.a,{value:nt})):null))),xt?t.a.createElement("a",{ref:Je,className:"editor-resize"}):null,t.a.createElement(oe.a,null,fe[Be]?t.a.createElement(Q.a,{centered:!0,title:fe[Be],visible:!0,onCancel:we,footer:null},Ht):null))}},dejd:function(ee,P,e){},kSUc:function(ee,P,e){},lteO:function(ee,P,e){ee.exports={title:"title___jboTG"}},w6l6:function(ee,P,e){"use strict";e.r(P);var B=e("+L6B"),Q=e("2/Rp"),re=e("14J3"),y=e("BMrR"),j=e("DZo9"),r=e("8z0m"),t=e("miYZ"),v=e("tsqr"),U=e("jCWc"),_=e("kPKH"),u=e("WmNS"),E=e.n(u),I=e("oBTY"),V=e("5NDa"),ie=e("5rEg"),ve=e("9og8"),ce=e("tJVT"),X=e("q1tI"),i=e.n(X),te=e("m3rI"),ue=e("ErOA"),$=e("lteO"),G=e.n($),oe=e("Ot1p"),de=e("Ty5D"),z=e("55Ip"),be=e("9kvl"),b=e("xvlK"),_e=e("2BaD");function Z(f){var De=f.user,Ce=f.dispatch,d=Object(X.useState)(),c=Object(ce.a)(d,2),m=c[0],p=c[1],x=Object(X.useState)(),H=Object(ce.a)(x,2),J=H[0],ae=H[1],he=Object(X.useState)([]),ge=Object(ce.a)(he,2),D=ge[0],F=ge[1],Le=Object(X.useState)(),N=Object(ce.a)(Le,2),Ve=N[0],Oe=N[1],Re=Object(X.useState)(),le=Object(ce.a)(Re,2),se=le[0],me=le[1],Pe=Object(de.m)(),Ze=i.a.createElement("div",{style:{height:"128px",width:"128px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},i.a.createElement(b.a,null),i.a.createElement("div",{style:{marginTop:8}},"\u4E0A\u4F20\u56FE\u7247"));Object(X.useEffect)(function(){Ne()},[Pe]);function Ne(){return Ee.apply(this,arguments)}function Ee(){return Ee=Object(ve.a)(E.a.mark(function T(){var h,S,O,L,Me;return E.a.wrap(function(q){for(;;)switch(q.prev=q.next){case 0:return q.next=2,Object(ue.a)("/api/memos/".concat(Pe==null?void 0:Pe.id,".json"),{method:"GET",params:{forum:18}});case 2:L=q.sent,p(L==null||((h=L.memo)===null||h===void 0)?void 0:h.subject),me(L==null||((S=L.memo)===null||S===void 0)?void 0:S.content),Me=[],L==null||((O=L.attachments_list)===null||O===void 0)||O.map(function(fe,Fe){Me.push({response:{id:fe==null?void 0:fe.id}})}),F([].concat(Me));case 8:case"end":return q.stop()}},T)})),Ee.apply(this,arguments)}return i.a.createElement("div",{style:{marginBottom:"40px"}},i.a.createElement("div",{className:"edu-container",style:{marginTop:"10px"}},i.a.createElement(z.Link,{to:"/TeachingStyle",style:{color:"#333333"}},"\u6559\u5B66\u98CE\u91C7"),"/",i.a.createElement("span",null,"\u7F16\u8F91")),i.a.createElement("div",{className:"edu-container minH500",style:{width:"1200px",background:"#fff",marginTop:"20px",paddingBottom:"20px"}},i.a.createElement("div",{className:G.a.title},i.a.createElement("span",null,"\u7F16\u8F91\u6D3B\u52A8 ")),i.a.createElement("div",{style:{padding:"0px 45px"}},i.a.createElement("div",{style:{marginBottom:"20px"}},i.a.createElement("span",{style:{color:"#E02020"}},"*")," ",i.a.createElement("span",{style:{color:"#333333"}},"\u6807\u9898\uFF1A"),i.a.createElement("br",null),i.a.createElement(ie.a,{style:{marginTop:"21px",width:"600px",marginLeft:"10px"},value:m,onChange:function(h){return p(h.target.value)},maxLength:60,placeholder:"\u8BF7\u8F93\u5165\u6807\u9898"})),i.a.createElement("div",{style:{marginBottom:"20px"}},i.a.createElement("span",{style:{color:"#E02020"}},"*")," ",i.a.createElement("span",{style:{color:"#333333"}},"\u4E0A\u4F20\u5C01\u9762\u56FE\u7247\uFF1A",i.a.createElement("span",{style:{fontSize:"14px",color:"#888888",marginBottom:"21px"}},"\uFF08\u652F\u6301jpg\u3001gif\u3001png\u683C\u5F0F\u7684\u7167\u7247\uFF1B\u5EFA\u8BAE\u6587\u4EF6\u5C0F\u4E8E2M\uFF09")),i.a.createElement("br",null),i.a.createElement("div",{style:{marginTop:"21px",marginLeft:"10px"}},i.a.createElement(y.a,null,D==null?void 0:D.map(function(T,h){var S;return i.a.createElement(_.a,null,i.a.createElement("img",{onClick:function(L){},src:te.a.API_SERVER+"/api/attachments/"+(T==null||((S=T.response)===null||S===void 0)?void 0:S.id),alt:"avatar",style:{width:"128px",height:"128px",marginRight:"15px",marginBottom:"15px"}}),i.a.createElement(_e.a,{style:{position:"absolute",right:"7px",top:"-10px",color:"red",fontSize:"20px"},onClick:Object(ve.a)(E.a.mark(function O(){var L,Me;return E.a.wrap(function(q){for(;;)switch(q.prev=q.next){case 0:return F(Object(I.a)(D==null?void 0:D.filter(function(fe){var Fe,n;return(fe==null||((Fe=fe.response)===null||Fe===void 0)?void 0:Fe.id)!=(T==null||((n=T.response)===null||n===void 0)?void 0:n.id)}))),q.next=3,Object(ue.a)("/api/attachments/".concat(T==null||((L=T.response)===null||L===void 0)?void 0:L.id,".json "),{method:"Delete"});case 3:Me=q.sent;case 4:case"end":return q.stop()}},O)}))}))}),i.a.createElement(_.a,null,i.a.createElement(r.a,{name:"file",listType:"picture-card",accept:"image/png, image/jpeg",showUploadList:!1,action:te.a.API_SERVER+"/api/attachments.json",withCredentials:!0,fileList:D,onChange:function(h){var S,O=(h==null?void 0:h.file.size)/1024/1024<2;if(!((S=h.fileList)===null||S===void 0?void 0:S.length))return!1;F(O?h==null?void 0:h.fileList:Object(I.a)(D))},beforeUpload:function(h){var S=h.type==="image/jpeg"||h.type==="image/png";if(!S)return v.b.error("\u53EA\u80FD\u4E0A\u4F20jpg \u6216\u8005png\u56FE\u7247"),!1;var O=h.size/1024/1024<2;return O?S&&O:(v.b.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u5927\u4E8E2m"),!1)},onRemove:function(h){F([])}},(D==null?void 0:D.length)>8?null:Ze))))),i.a.createElement("div",{style:{marginBottom:"20px"}},i.a.createElement("span",{style:{color:"#333333"}},"\u5185\u5BB9\uFF1A"),i.a.createElement("br",null),i.a.createElement("div",{style:{marginTop:"21px",marginLeft:"10px"}},i.a.createElement(oe.a,{defaultValue:se,onChange:function(h){return me(h)},placeholder:"\u8BF7\u8F93\u5165\u7B80\u4ECB\uFF0C500\u5B57\u4EE5\u5185"}))),i.a.createElement("div",{style:{marginBottom:"20px"}},i.a.createElement(Q.a,{type:"primary",onClick:Object(ve.a)(E.a.mark(function T(){var h;return E.a.wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(m){O.next=3;break}return v.b.info("\u8BF7\u8F93\u5165\u6807\u9898"),O.abrupt("return");case 3:if(!((D==null?void 0:D.length)<=0)){O.next=6;break}return v.b.info("\u8BF7\u6DFB\u52A0\u5C01\u9762\u56FE"),O.abrupt("return");case 6:if(se){O.next=9;break}return v.b.info("\u8BF7\u8F93\u5165\u5185\u5BB9"),O.abrupt("return");case 9:return O.next=11,Object(ue.a)("/api/memos/".concat(Pe==null?void 0:Pe.id,".json"),{method:"put",body:{forum_id:18,subject:m,content:se,attachment_ids:D==null?void 0:D.map(function(L,Me){var Ae;return L==null||((Ae=L.response)===null||Ae===void 0)?void 0:Ae.id})}});case 11:h=O.sent,(h==null?void 0:h.status)===0&&(v.b.info("\u4FEE\u6539\u6210\u529F"),p(""),F([]),me(""),Oe(""),history.back());case 13:case"end":return O.stop()}},T)}))},"\u786E\u8BA4"),i.a.createElement(Q.a,{style:{marginLeft:"30px"},onClick:function(){history.back()}},"\u53D6\u6D88")))))}P.default=Object(be.a)(function(f){var De=f.user;return{user:De}})(Z)}}]);
|