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.
1 line
52 KiB
1 line
52 KiB
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[123],{"7ahc":function(e,t,n){"use strict";n.d(t,"a",(function(){return v}));var r=n("k1fw"),a=n("0Owb"),o=(n("+L6B"),n("2/Rp")),i=(n("y8nQ"),n("Vl3Y")),c=n("tJVT"),l=(n("OaEy"),n("2fM7")),u=n("q1tI"),s=n.n(u),f=n("VrN/"),h=n.n(f),d=(n("p77/"),n("c5Ni"),l["a"].Option),p={labelCol:{span:4},wrapperCol:{span:20}},m={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"]};function v(e){var t=e.value,n=e.onChange,a=e.mode,o=e.options,i=void 0===o?{}:o,l=Object(u["useRef"])(),f=Object(u["useState"])(),d=Object(c["a"])(f,2),p=d[0],m=d[1];return Object(u["useEffect"])((function(){if(p){var e=function(e){var t=e.getValue();n&&n(t)};return p.on("change",e),function(){p.off("change",e)}}}),[p,n]),Object(u["useEffect"])((function(){p&&p.setOption("mode",a)}),[p,a]),Object(u["useEffect"])((function(){p&&(t===p.getValue()&&""!==t||setTimeout((function(){p.setValue(t||" ")}),300))}),[p,t]),Object(u["useEffect"])((function(){if(l.current&&!p){var e=h.a.fromTextArea(l.current,Object(r["a"])({mode:a,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},i));m(e)}}),[l.current,p]),s.a.createElement("div",{className:"my-codemirror-container"},s.a.createElement("textarea",{ref:l}))}t["b"]=function(e){var t=e.callback,n=e.onCancel,r=Object(u["useState"])("python"),f=Object(c["a"])(r,2),h=f[0],g=f[1];function y(e){g(m[e][1])}function b(e){t(e)}return s.a.createElement(i["a"],Object(a["a"])({},p,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:b}),s.a.createElement(i["a"].Item,{label:"\u4ee3\u7801\u8bed\u8a00",name:"language"},s.a.createElement(l["a"],{onChange:y},Object.keys(m).map((function(e){return s.a.createElement(d,{key:e,value:e},m[e][0])})))),s.a.createElement(i["a"].Item,{label:"\u4ee3\u7801\u5185\u5bb9",name:"content",rules:[{required:!0,message:"\u8bf7\u8f93\u5165\u4ee3\u7801\u5185\u5bb9"}]},s.a.createElement(v,{mode:h})),s.a.createElement("div",{className:"flex-container flex-end"},s.a.createElement(o["a"],{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786e\u5b9a"),s.a.createElement(o["a"],{type:"ghost",onClick:n},"\u53d6\u6d88")))}},"9Bee":function(e,t,n){"use strict";var r=n("q1tI"),a=n.n(r),o=(n("vg9a"),n("tJVT")),i=n("DlQD"),c=n.n(i),l=n("rUJ1");function u(e,t){var n=e.match(/^(\s+)(?:```)/);if(null===n)return t;var r=n[1];return t.split("\n").map((function(e){var t=e.match(/^\s+/);if(null===t)return e;var n=Object(o["a"])(t,1),a=n[0];return a.length>=r.length?e.slice(r.length):e})).join("\n")}var s=[],f=["<ul>"],h=new c.a.Renderer,d=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function p(){s.length=0,f=["<ul>"]}function m(e,t,n,r){if(t>=e.length||e[t].level<=n)return t;var a=e[t];r.push("<li><a href='#"+a.anchor+"'>"+a.text+"</a>"),t++;var o=[];return t=m(e,t,a.level,o),o.length>0&&(r.push("<ul>"),o.forEach((function(e){r.push(e)})),r.push("</ul>")),r.push("</li>"),t=m(e,t,n,r),t}function v(){return m(s,0,0,f),f.push("</ul>"),f.join("")}var g={heading:function(e){var t=d.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[1].length,text:t[2]}},fences:function(e){var t=this.rules.block.fences.exec(e);if(t){var n=t[0],r=u(n,t[3]||""),a=t[2]?t[2].trim():t[2];if(["latex","katex","math"].indexOf(a)>=0){var o=w(),i=r;r=o,E[o]={type:"block",expression:i}}return{type:"code",raw:n,lang:a,text:r}}}},y=/(?:\${2})([^\n`]+?)(?:\${2})/gi,b=0,w=function(){return"__special_katext_id_".concat(b++,"__")},E={};function j(){return E}function O(){b=0,E={}}function x(e){return e=e.replace(y,(function(e,t){var n=w();return E[n]={type:"inline",expression:t},n})),e}var k=h.listitem;h.listitem=function(e){return k(x(e))};var L=h.paragraph;h.paragraph=function(e){return L(x(e))};var S=h.tablecell;h.tablecell=function(e,t){return S(x(e),t)},h.code=function(e,t,n){var r=(t||"").match(/\S*/)[0];return r?["latex","katex","math"].indexOf(r)>=0?"<p class='editormd-tex'>".concat(e,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(t,'">').concat(n?e:Object(l["escape"])(e,!0),"</code></pre>\n"):'<pre class="prettyprint linenums"><code>'+(n?e:Object(l["escape"])(e,!0))+"</code></pre>"},h.heading=function(e,t,n){var r=this.options.headerPrefix+n.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return s.push({anchor:r,level:t,text:e}),"<h"+t+' id="'+r+'">'+e+"</h"+t+">"},c.a.setOptions({silent:!0,smartypants:!0,gfm:!0,pedantic:!1}),c.a.use({tokenizer:g,renderer:h});var N=c.a,_=(n("SJMd"),n("m3rI")),C=n("Oy/b"),I=n("Xjjk"),T=n.n(I),V=/<pre[^>]*>/g;function P(e){var t=document.createElement("div");return t.innerHTML=e,0===t.childNodes.length?"":t.childNodes[0].nodeValue}t["a"]=function(e){var t=e.value,n=void 0===t?"":t,o=e.className,i=e.style,c=void 0===i?{}:i,l=String(n),u=Object(r["useMemo"])((function(){try{var e=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,t=/\"\/api\/attachments\/|\"\/attachments\/download\//g,n=/\(\s+\/files\/uploads\/|\(\/files\/uploads\//g;l=l.replace(e,"("+_["a"].API_SERVER+"/api/attachments/").replace(t,'"'+_["a"].API_SERVER+"/api/attachments/").replace(n,'"'+_["a"].API_SERVER+"/files/uploads/")}catch(o){}l=T()(l);var r=N(l),a=j();return l.match(/\[TOC\]/)&&(r=r.replace("<p>[TOC]</p>",v()),p()),r=r.replace(/(__special_katext_id_\d+__)/g,(function(e,t){var n=a[t],r=n.type,o=n.expression;return Object(C["renderToString"])(P(o)||"",{displayMode:"block"===r,throwOnError:!1,output:"html"})})),r=r.replace(/\u2581/g,"\u2581\u2581\u2581"),O(),r}),[l]),s=Object(r["useRef"])();function f(e){var t=e.target;if("A"===t.tagName.toUpperCase()){var n=t.getAttribute("href");if(n.startsWith("#")){e.preventDefault();var r=document.getElementById(n.replace("#",""));r&&r.scrollIntoView(!0)}}}return Object(r["useEffect"])((function(){if(s.current&&u&&u.match(V)&&window.PR.prettyPrint(),s.current)return s.current.addEventListener("click",f),function(){s.current.removeEventListener("click",f),O(),p()}}),[u,s.current,f]),a.a.createElement("div",{ref:s,style:c,className:"".concat(o||""," markdown-body"),dangerouslySetInnerHTML:{__html:u}})}},"9VGf":function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n("q1tI");function a(e,t){var n=Object(r["useRef"])();Object(r["useEffect"])((function(){n.current=e})),Object(r["useEffect"])((function(){function e(){n.current()}if(null!==t){var r=setInterval(e,t);return function(){return clearInterval(r)}}}),[t])}},"9ivq":function(e,t,n){},BjJ7:function(e,t,n){"use strict";n.d(t,"d",(function(){return a})),n.d(t,"c",(function(){return o})),n.d(t,"e",(function(){return i})),n.d(t,"b",(function(){return c})),n.d(t,"a",(function(){return l}));var r=n("m3rI");function a(e){var t=!0;if(e.length>0){for(var n=0;n<e.length;n++)if(0==e[n].compile_success||!e[n].compile_success){t=!1;break}}else t=!1;return t}function o(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=[],r=0;r<e.length;r++){var a=e[r],o=t?"".concat(t,"/").concat(a.name):"".concat(a.name);n.push({title:a.name,isLeaf:"tree"!==a.type,key:o})}return n}function i(e,t,n){for(var r=0;r<e.length;r++){var a=e[r];if(a.key===t){a.children=n;break}a.children&&i(a.children,t,n)}return e}function c(e,t,n){var r;return function(){var a=this,o=arguments,i=function(){r=null,n||e.apply(a,o)},c=n&&!r;clearTimeout(r),r=setTimeout(i,t),c&&e.apply(a,o)}}var l=r["a"].API_SERVER},"C+DQ":function(e,t,n){},HmJG:function(e,t,n){},M8RZ:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n("fWQN"),a=n("mtLc"),o=n("yKVA"),i=n("879j"),c=n("q1tI"),l=n.n(c),u=n("i8i4"),s=function(e){Object(o["a"])(n,e);var t=Object(i["a"])(n);function n(e){var a;Object(r["a"])(this,n),a=t.call(this,e);var o=window.document;return a.node=o.createElement("div"),o.body.appendChild(a.node),a}return Object(a["a"])(n,[{key:"render",value:function(){var e=this.props.children;return Object(u["createPortal"])(e,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),n}(l.a.Component)},Ot1p:function(e,t,n){"use strict";n("2qtc");var r=n("kLXV"),a=n("rAM+"),o=n("tJVT"),i=n("jrin"),c=n("q1tI"),l=n.n(c),u=n("VrN/"),s=n.n(u),f=n("bdgK"),h=(n("p77/"),n("Bd2K"),n("ELLl"),n("19Vz"),n("lZu9"),n("kSUc"),n("9Bee")),d=n("0Owb"),p=(n("dejd"),n("C+DQ"),[{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 m(e){var t=e.onActionCallback,n=e.title,r=e.icon,a=e.actionName,o=e.className,i=void 0===o?"":o,c=e.children;function u(){t(a)}return l.a.createElement("a",{title:n,className:i,onClick:u},l.a.createElement("i",{className:"md-iconfont ".concat(r)}),c)}var v=function(e){var t=e.watch,n=e.showNullButton,r=e.onActionCallback,a=e.fullScreen,o=[].concat(p,[{title:"".concat(t?"\u5173\u95ed\u5b9e\u65f6\u9884\u89c8":"\u5f00\u542f\u5b9e\u65f6\u9884\u89c8"),icon:"".concat(t?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return l.a.createElement("ul",{className:"markdown-toolbar-container"},o.map((function(e,t){return l.a.createElement("li",{key:t},e.actionName?l.a.createElement(m,Object(d["a"])({},e,{onActionCallback:r})):l.a.createElement("span",{className:"v-line"}))})),n?l.a.createElement("li",null,l.a.createElement(m,{icon:"icon-edit",className:"btn-null",title:"\u589e\u52a0\u586b\u7a7a",actionName:"add-null-ch",onActionCallback:r},l.a.createElement("span",{className:"fill-tip"},"\u70b9\u51fb\u63d2\u5165\b\u586b\u7a7a\u9879"))):null,l.a.createElement("li",{className:"btn-full-screen"},l.a.createElement(m,{icon:"".concat(a?"icon-shrink":"icon-enlarge"),title:a?"\u5173\u95ed\u5168\u5c4f":"\u5f00\u542f\u5168\u5c4f",actionName:"trigger-full-screen",onActionCallback:r})))},g=n("M8RZ"),y=(n("+L6B"),n("2/Rp")),b=(n("y8nQ"),n("Vl3Y")),w=(n("5NDa"),n("5rEg")),E={labelCol:{span:4},wrapperCol:{span:20}},j=function(e){var t=e.callback,n=e.onCancel;function r(e){t(e)}return l.a.createElement(b["a"],Object(d["a"])({},E,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:r}),l.a.createElement(b["a"].Item,{label:"\u94fe\u63a5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8bf7\u8f93\u5165\u94fe\u63a5\u5730\u5740"}]},l.a.createElement(w["a"],null)),l.a.createElement(b["a"].Item,{label:"\u94fe\u63a5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8bf7\u8f93\u5165\u94fe\u63a5\u6807\u9898"}]},l.a.createElement(w["a"],null)),l.a.createElement("div",{className:"flex-container flex-end"},l.a.createElement(y["a"],{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786e\u5b9a"),l.a.createElement(y["a"],{type:"ghost",onClick:n},"\u53d6\u6d88")))},O=n("7ahc"),x=(n("HmJG"),n("BjJ7")),k=b["a"].useForm,L={width:280,marginRight:10},S={labelCol:{span:5},wrapperCol:{span:19}},N=function(e){var t=e.callback,n=e.onCancel,r=k(),a=Object(o["a"])(r,1),i=a[0];function c(e){t(e)}function u(e){i.setFieldsValue({src:"/api/attachments/".concat(e.id)})}function s(e){var t=e.target.files[0];C(t,u)}return l.a.createElement(b["a"],Object(d["a"])({form:i},S,{className:"upload-image-panel",onFinish:c}),l.a.createElement(b["a"].Item,{label:"\u56fe\u7247\u5730\u5740",required:!0},l.a.createElement("div",{className:"flex-container"},l.a.createElement(b["a"].Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8bf7\u8f93\u5165\u56fe\u7247\u5730\u5740"}]},l.a.createElement(w["a"],{style:L})),l.a.createElement(_,{onFileChange:s}))),l.a.createElement(b["a"].Item,{label:"\u56fe\u7247\u63cf\u8ff0",name:"alt",rules:[{required:!0,message:"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0"}]},l.a.createElement(w["a"],{style:{width:264}})),l.a.createElement(b["a"].Item,{style:{textAlign:"right"}},l.a.createElement(y["a"],{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786e\u5b9a"),l.a.createElement(y["a"],{type:"ghost",onClick:n},"\u53d6\u6d88")))};function _(e){var t=e.onFileChange;return l.a.createElement("a",{className:"upload-button"},"\u672c\u5730\u4e0a\u4f20",l.a.createElement("input",{type:"file",accept:"image/*",onChange:t}))}function C(e,t){if(!e)throw new String("\u6ca1\u6709\u6587\u4ef6");var n=new FormData;n.append("editormd-image-file",e),n.append("file_param_name","editormd-image-file"),n.append("byxhr","true");var r=new window.XMLHttpRequest;r.withCredentials=!0,r.addEventListener("load",(function(e){t(JSON.parse(e.target.responseText))}),!1),r.addEventListener("error",(function(e){console.error(e)}),!1),r.open("POST","".concat(x["a"],"/api/attachments.json")),r.send(n)}n("giR+");var I,T,V=n("fyUT"),P=(n("7Kak"),n("9yH6")),R=P["a"].Group,A={margin:"0 8px"},F=function(e){var t=e.callback,n=e.onCancel;function r(e){t(e)}return l.a.createElement(b["a"],{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:r},l.a.createElement("div",{className:"flex-container"},l.a.createElement("span",{style:A},"\u5355\u5143\u683c\u6570\uff1a"),l.a.createElement("span",{style:A},"\u884c\u6570"),l.a.createElement(b["a"].Item,{name:"row",rules:[{required:!0,message:"\u8bf7\u8f93\u5165\u884c\u6570"}]},l.a.createElement(V["a"],null)),l.a.createElement("span",{style:A},"\u5217\u6570"),l.a.createElement(b["a"].Item,{name:"col",rules:[{required:!0,message:"\u8bf7\u8f93\u5165\u5217\u6570"}]},l.a.createElement(V["a"],null))),l.a.createElement("div",{className:"flex-container",style:{marginTop:12}},l.a.createElement("span",{style:A},"\u5bf9\u9f50\u65b9\u5f0f\uff1a"),l.a.createElement(b["a"].Item,{name:"align"},l.a.createElement(R,null,l.a.createElement(P["a"],{value:"default"},l.a.createElement("i",{className:"fa fa-align-justify"})),l.a.createElement(P["a"],{value:"left"},l.a.createElement("i",{className:"fa fa-align-left"})),l.a.createElement(P["a"],{value:"center"},l.a.createElement("i",{className:"fa fa-align-center"})),l.a.createElement(P["a"],{value:"right"},l.a.createElement("i",{className:"fa fa-align-right"}))))),l.a.createElement("div",{className:"flex-container flex-end"},l.a.createElement(y["a"],{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786e\u5b9a"),l.a.createElement(y["a"],{type:"ghost",onClick:n},"\u53d6\u6d88")))},G="link",B="upload-image",M="code-block",q="add-table",D="------------",J={default:D,left:":".concat(D),center:":".concat(D,":"),right:"".concat(D,":")},H=n("9VGf");var U=1e4,Y="\u2581";function z(e){return/^\d+$/.test(e)?"".concat(e,"px"):e}var $=navigator.platform.toUpperCase().indexOf("MAC")>=0,Q=$?"Cmd":"Ctrl",Z=(I={},Object(i["a"])(I,Q+"-B","bold"),Object(i["a"])(I,Q+"-I","italic"),I),K=(T={},Object(i["a"])(T,G,"\u6dfb\u52a0\u94fe\u63a5"),Object(i["a"])(T,M,"\u6dfb\u52a0\u4ee3\u7801\u5757"),Object(i["a"])(T,B,"\u6dfb\u52a0\u56fe\u7247"),Object(i["a"])(T,q,"\u6dfb\u52a0\u8868\u683c"),T);t["a"]=function(e){var t=e.defaultValue,n=void 0===t?"":t,u=e.onChange,d=e.width,p=void 0===d?"100%":d,m=e.height,y=void 0===m?400:m,b=e.miniToolbar,w=void 0!==b&&b,E=e.isFocus,x=void 0!==E&&E,k=e.watch,L=e.id,S=void 0===L?"markdown-editor-id":L,_=e.showResizeBar,I=void 0!==_&&_,T=e.noStorage,V=void 0!==T&&T,P=e.showNullButton,R=void 0!==P&&P,A=e.fullScreen,D=void 0!==A&&A,$=e.onBlur,Q=e.onCMBeforeChange,W=e.className,X=void 0===W?"":W,ee=e.placeholder,te=void 0===ee?"":ee,ne=e.values,re=void 0===ne?"":ne,ae=Object(c["useState"])(null),oe=Object(o["a"])(ae,2),ie=oe[0],ce=oe[1],le=Object(c["useState"])(n),ue=Object(o["a"])(le,2),se=ue[0],fe=ue[1],he=Object(c["useState"])(k),de=Object(o["a"])(he,2),pe=de[0],me=de[1],ve=Object(c["useState"])(D),ge=Object(o["a"])(ve,2),ye=ge[0],be=ge[1],we=Object(c["useState"])(""),Ee=Object(o["a"])(we,2),je=Ee[0],Oe=Ee[1],xe=Object(c["useState"])(0),ke=Object(o["a"])(xe,2),Le=ke[0],Se=ke[1],Ne=Object(c["useState"])(y),_e=Object(o["a"])(Ne,2),Ce=_e[0],Ie=_e[1],Te=Object(c["useState"])(!1),Ve=Object(o["a"])(Te,2),Pe=(Ve[0],Ve[1]),Re=Object(c["useRef"])(),Ae=Object(c["useRef"])(),Fe=Object(c["useRef"])(),Ge=Object(c["useRef"])();Object(c["useEffect"])((function(){fe(re),null===ie||void 0===ie||ie.setValue(re)}),[re]),Object(c["useEffect"])((function(){if(Re.current){var e=function(e,n){var r=n.clipboardData;if(r){var a=r.types.toString(),o=r.items;if("text/html,Files"!==a&&"Files"!==a)return!0;var i=o[1];"Files"===a&&(i=o[0]),"file"===i.kind&&i.type.match(/^image\//i)&&C(i.getAsFile(),(function(e){e.id?t.replaceSelection("")):401===(null===e||void 0===e?void 0:e.status)&&(document.location.href="/user/login")}))}return!0},t=s.a.fromTextArea(Re.current,{mode:"markdown",inputStyle:"contenteditable",lineNumbers:!w,lineWrapping:!0,value:n,autoCloseTags:!0,autoCloseBrackets:!0});return t.on("paste",e),ce(t),function(){t.off("paste",e)}}}),[]);var Be=Object(c["useCallback"])((function(){if(Ae.current)try{var e=Ae.current.getElementsByClassName("markdown-toolbar-container")[0].offsetHeight,t=Ae.current.getElementsByClassName("markdown-editor-body")[0];t.style.height=ye?"calc(100vh - ".concat(e,"px)"):"".concat(Ce-e,"px")}catch(n){console.log(n,"---- to set md editor body height")}}),[Ce,Ae,ye]);Object(c["useEffect"])((function(){function e(){var e=new f["default"]((function(e){var t,n=Object(a["a"])(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;(r.target.offsetHeight>0||r.target.offsetWidth>0)&&(Be(),ie.setSize("100%","100%"),ie.refresh())}}catch(o){n.e(o)}finally{n.f()}}));return e.observe(Re.current.parentElement),e}if(ie){var t=e();return function(){t.unobserve(Re.current.parentElement)}}}),[ie,Be]),Object(c["useEffect"])((function(){if(ie){for(var e=[],t=function(){var t=r[n];a=Object(o["a"])(t,2);var c=a[0],l=a[1],u=Object(i["a"])({},c,(function(){Me(l)}));e.push(u),ie.addKeyMap(u)},n=0,r=Object.entries(Z);n<r.length;n++){var a;t()}return function(){for(var t=0,n=e;t<n.length;t++){var r=n[t];ie.removeKeyMap(r)}}}}),[ie]),Object(c["useEffect"])((function(){D!==ye&&be(D)}),[D]),Object(H["a"])((function(){if(!V&&Le>0){var e=(new Date).getTime(),t=window.sessionStorage.getItem(S);e>=Le+U&&(!t||t!==se)&&(window.sessionStorage.setItem(S,se),Pe(!0))}}),U),Object(c["useEffect"])((function(){me(k)}),[ie,k]),Object(c["useEffect"])((function(){ie&&x&&ie.focus()}),[ie,x]),Object(c["useEffect"])((function(){if(pe&&ie){var e=function(e){var t=e.target;if(Ge.current){var n=t.scrollTop/t.scrollHeight;Ge.current.scrollTop=Ge.current.scrollHeight*n}},t=ie.getScrollerElement();return t.addEventListener("scroll",e),function(){t.removeEventListener("scroll",e)}}}),[ie,pe]),Object(c["useEffect"])((function(){if(ie&&Q){var e=function(e,t){Q(e,t)};return ie.on("beforeChange",e),function(){ie.off("beforeChange",e)}}}),[ie,Q]),Object(c["useEffect"])((function(){if(ie&&$){var e=function(){$(ie.getValue())};return ie.on("blur",e),function(){ie.off("blur",e)}}}),[ie,$]),Object(c["useEffect"])((function(){if(ie){var e=function(e){var t=e.getValue();fe(t),Se((new Date).getTime()),e.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),u&&u(t)};return ie.on("change",e),function(){ie.off("change",e)}}}),[ie,u]),Object(c["useEffect"])((function(){ie&&(null===n||void 0===n?(ie.setValue(""),fe("")):n!==ie.getValue()&&(ie.setValue(n),fe(n)))}),[ie,n]);var Me=Object(c["useCallback"])((function(e){var t=ie.getCursor(),n=ie.getSelection(),r=n.split("\n");switch(e){case"bold":return ie.replaceSelection("**"+n+"**"),""===n&&ie.setCursor(t.line,t.ch+2),ie.focus();case"italic":return ie.replaceSelection("*"+n+"*"),""===n&&ie.setCursor(t.line,t.ch+1),ie.focus();case"code":return ie.replaceSelection("`"+n+"`"),""===n&&ie.setCursor(t.line,t.ch+1),ie.focus();case"inline-latex":return ie.replaceSelection("`$$"+n+"$$`"),""===n&&ie.setCursor(t.line,t.ch+3),ie.focus();case"latex":return ie.replaceSelection("```latex\n"+n+"\n```"),ie.setCursor(t.line+1,n.length+1),ie.focus();case"line-break":return ie.replaceSelection("<br/>\n"),ie.focus();case"list-ul":return""===n?ie.replaceSelection("- "+n):ie.replaceSelection(r.map((function(e){return""===e?"":"- ".concat(e)})).join("\n")),ie.focus();case"list-ol":return""===n?ie.replaceSelection("1. "+n):ie.replaceSelection(r.map((function(e,t){return""===e?"":"".concat(t+1,". ").concat(e)})).join("\n")),ie.focus();case"add-null-ch":return""===n&&ie.setCursor(t.line,t.ch+1),ie.replaceSelection(Y),ie.focus();case"eraser":return ie.setValue(""),ie.focus();case"trigger-watch":return me(!pe),ie.focus();case"trigger-full-screen":return be(!ye),ie.focus();case G:return void Oe(G);case M:return void Oe(M);case B:return void Oe(B);case q:return void Oe(q);default:throw new Error}}),[ie,pe,ye]),qe=Object(c["useCallback"])((function(e){switch(Oe(""),je){case G:var t=e.title,n=e.link;return ie.replaceSelection("[".concat(t,"](").concat(n,")")),ie.focus();case M:var r=e.language,a=e.content;return ie.replaceSelection(["```"+r,a,"```"].join("\n")),ie.focus();case B:var o=e.src,i=e.alt;return ie.replaceSelection(".concat(o,' "').concat(i,'" )')),ie.focus();case q:for(var c=e.row,l=e.col,u=e.align,s="\n",f=0;f<c;f++){for(var h=[],d=[],p=0;p<l;p++)1===f&&d.push(J[u]),h.push(" ");1===f&&(s+="| ".concat(d.join(" | ")," |\n")),s+="| ".concat(h.join(1===l?"":" | ")," |\n")}return ie.replaceSelection(s+"\n"),ie.focus();default:throw new Error}}),[ie,je]),De=Object(c["useMemo"])((function(){switch(je){case G:return l.a.createElement(j,{callback:qe,onCancel:Je});case M:return l.a.createElement(O["b"],{callback:qe,onCancel:Je});case B:return l.a.createElement(N,{callback:qe,onCancel:Je});case q:return l.a.createElement(F,{callback:qe,onCancel:Je});default:return null}}),[je]);function Je(){Oe("")}Object(c["useEffect"])((function(){if(Fe.current){var e=function(e){a=!0,o=e.pageY},t=function(){a=!1},n=function(e){if(a){var t=e.pageY-o;t<0&&(t=0),t>300&&(t=300);var n=y+t+"px";Ie(n)}},r=Fe.current,a=!1,o=0;return r.addEventListener("mousedown",e),document.addEventListener("mousemove",n),document.addEventListener("mouseup",t),function(){r.removeEventListener("mousedown",e),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",t)}}}),[ie,Fe]),Object(c["useEffect"])((function(){Ie(y)}),[y]);var He=z(p),Ue=z(Ce),Ye={width:He,height:Ue};Object(c["useMemo"])((function(){if(Le){var e=new Date(Le),t=e.getHours(),n=e.getMinutes(),r=e.getSeconds();return t=t<10?"0"+t:t,n=n<10?"0"+n:n,r=r<10?"0"+r:r,"".concat(t,":").concat(n,":").concat(r)}return 0}),[Le]);return l.a.createElement(c["Fragment"],null,l.a.createElement("div",{className:"markdown-editor-wrapper",ref:Ae},l.a.createElement("div",{className:"markdown-editor-container ".concat(X," ").concat(pe?"on-preview":""," ").concat(w?"mini":""," ").concat(ye?"full-screen":""),style:Ye},l.a.createElement(v,{watch:pe,fullScreen:ye,showNullButton:R,onActionCallback:Me}),l.a.createElement("div",{className:"markdown-editor-body"},l.a.createElement("div",{className:"codemirror-container"},l.a.createElement("textarea",{ref:Re,placeholder:te})),pe?l.a.createElement("div",{ref:Ge,className:"preview-container"},l.a.createElement(h["a"],{value:se})):null))),I?l.a.createElement("a",{ref:Fe,className:"editor-resize"}):null,l.a.createElement(g["a"],null,K[je]?l.a.createElement(r["a"],{centered:!0,title:K[je],visible:!0,onCancel:Je,footer:null},De):null))}},axZZ:function(e,t,n){"use strict";n.r(t);n("DZo9");var r=n("8z0m"),a=(n("+L6B"),n("2/Rp")),o=(n("miYZ"),n("tsqr")),i=n("9og8"),c=n("tJVT"),l=n("q1tI"),u=n.n(l),s=(n("5NDa"),n("5rEg")),f=n("Ot1p"),h=n("ErOA");function d(){d=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(_){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new L(a||[]);return r(i,"_invoke",{value:j(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(_){return{type:"throw",arg:_}}}e.wrap=u;var f={};function h(){}function p(){}function m(){}var v={};l(v,o,(function(){return this}));var g=Object.getPrototypeOf,y=g&&g(g(S([])));y&&y!==t&&n.call(y,o)&&(v=y);var b=m.prototype=h.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function j(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return N()}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=O(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function O(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:N}}function N(){return{value:void 0,done:!0}}return p.prototype=m,r(b,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:p,configurable:!0}),p.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},w(E.prototype),l(E.prototype,i,(function(){return this})),e.AsyncIterator=E,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new E(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},w(b),l(b,c,"Generator"),l(b,o,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function p(e){var t=e.setIscreate,n=e.init,r=e.UpdateItem,p=Object(l["useState"])(""),m=Object(c["a"])(p,2),v=m[0],g=m[1],y=Object(l["useState"])(""),b=Object(c["a"])(y,2),w=b[0],E=b[1];function j(){return O.apply(this,arguments)}function O(){return O=Object(i["a"])(d().mark((function e(){var a;return d().wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(v){e.next=3;break}return o["b"].info("\u6807\u9898\u4e0d\u80fd\u4e3a\u7a7a"),e.abrupt("return");case 3:if(w){e.next=6;break}return o["b"].info("\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a"),e.abrupt("return");case 6:if(!r){e.next=9;break}return x(),e.abrupt("return");case 9:return e.next=11,Object(h["a"])("/api/hpc_courses.json",{method:"post",body:{name:v,description:w,container_type:window.location.pathname.split("/")[1]}});case 11:a=e.sent,a&&(o["b"].info("\u521b\u5efa\u6210\u529f"),t(!1),n("add"));case 13:case"end":return e.stop()}}),e)}))),O.apply(this,arguments)}function x(){return k.apply(this,arguments)}function k(){return k=Object(i["a"])(d().mark((function e(){var a;return d().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(h["a"])("/api/hpc_courses/".concat(r.id,".json"),{method:"put",body:{name:v,description:w,container_type:window.location.pathname.split("/")[1]}});case 2:a=e.sent,a&&(o["b"].info("\u7f16\u8f91\u6210\u529f"),t(!1),n(""));case 4:case"end":return e.stop()}}),e)}))),k.apply(this,arguments)}return Object(l["useEffect"])((function(){r&&(g(r&&r.name),E(r&&r.description))}),[r]),u.a.createElement("div",null,u.a.createElement(s["a"],{style:{marginBottom:"20px"},placeholder:"\u8bf7\u8f93\u5165\u6807\u9898",value:v,maxLength:60,addonAfter:String(v.length)+"/60",onChange:function(e){return g(e.target.value)}}),u.a.createElement(f["a"],{id:"courseContentMD",defaultValue:w,onChange:function(e){return E(e)}}),u.a.createElement("div",{className:"clearfix mt30 mb30"},u.a.createElement(a["a"],{type:"primary",onClick:function(){return j()},className:"defalutSubmitbtn fl mr20"},"\u63d0\u4ea4"),u.a.createElement("a",{className:"defalutCancelbtn fl",onClick:function(){return t(!1)}},"\u53d6\u6d88")))}var m=p,v=n("9Bee");function g(){g=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(_){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new L(a||[]);return r(i,"_invoke",{value:j(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(_){return{type:"throw",arg:_}}}e.wrap=u;var f={};function h(){}function d(){}function p(){}var m={};l(m,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(S([])));y&&y!==t&&n.call(y,o)&&(m=y);var b=p.prototype=h.prototype=Object.create(m);function w(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function j(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return N()}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=O(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function O(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:N}}function N(){return{value:void 0,done:!0}}return d.prototype=p,r(b,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},w(E.prototype),l(E.prototype,i,(function(){return this})),e.AsyncIterator=E,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new E(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},w(b),l(b,c,"Generator"),l(b,o,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function y(e){var t=e.CourseItem,n=e.userId,r=e.init,c=e.ItemUpdate,l=e.setSee,s=e.UserInfo;function f(){return d.apply(this,arguments)}function d(){return d=Object(i["a"])(g().mark((function e(){var n;return g().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(h["a"])("/api/hpc_courses/".concat(t.id,".json"),{method:"delete"});case 2:n=e.sent,n&&(o["b"].info("\u5220\u9664\u6210\u529f"),r("delete"),l(!1));case 4:case"end":return e.stop()}}),e)}))),d.apply(this,arguments)}function p(){c(t)}return u.a.createElement("div",null,299635===n||301458===n||(null===s||void 0===s?void 0:s.admin)||(null===s||void 0===s?void 0:s.business)?u.a.createElement("div",{style:{textAlign:"right"}},u.a.createElement(a["a"],{onClick:function(){return p()}},"\u7f16\u8f91"),u.a.createElement(a["a"],{onClick:function(){return f()},style:{marginLeft:"30px"}},"\u5220\u9664")):null,u.a.createElement("h1",null,null===t||void 0===t?void 0:t.name),u.a.createElement(v["a"],{value:null===t||void 0===t?void 0:t.description}))}var b=y,w=(n("9ivq"),n("m3rI")),E=n("Ty5D"),j=n("9kvl");function O(){O=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(_){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),c=new L(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(_){return{type:"throw",arg:_}}}e.wrap=u;var f={};function h(){}function d(){}function p(){}var m={};l(m,o,(function(){return this}));var v=Object.getPrototypeOf,g=v&&v(v(S([])));g&&g!==t&&n.call(g,o)&&(m=g);var y=p.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return N()}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=j(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function j(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,j(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:N}}function N(){return{value:void 0,done:!0}}return d.prototype=p,r(y,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(y),l(y,c,"Generator"),l(y,o,(function(){return this})),l(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function x(e){var t,n,s,f,d,p,v,g,y,j=e.user,x=e.dispatch,k=Object(l["useState"])(1),L=Object(c["a"])(k,2),S=L[0],N=(L[1],Object(l["useState"])(100)),_=Object(c["a"])(N,2),C=_[0],I=(_[1],Object(l["useState"])([])),T=Object(c["a"])(I,2),V=T[0],P=T[1],R=Object(l["useState"])(!1),A=Object(c["a"])(R,2),F=A[0],G=A[1],B=Object(l["useState"])(!1),M=Object(c["a"])(B,2),q=M[0],D=M[1],J=Object(l["useState"])(""),H=Object(c["a"])(J,2),U=H[0],Y=H[1],z=Object(l["useState"])(""),$=Object(c["a"])(z,2),Q=$[0],Z=$[1],K=Object(l["useState"])(""),W=Object(c["a"])(K,2),X=W[0],ee=W[1],te=Object(E["m"])(),ne=te.itemname,re=Object(l["useState"])(""),ae=Object(c["a"])(re,2),oe=ae[0],ie=ae[1];function ce(e){return le.apply(this,arguments)}function le(){return le=Object(i["a"])(O().mark((function e(t){var n,r,a,o,i;return O().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(h["a"])("/api/hpc_courses.json",{method:"get",params:{page:S,per_page:C,container_type:window.location.pathname.split("/")[1]}});case 2:if(n=e.sent,!n){e.next=24;break}if(r=n.data.hpc_courses.length,P(n.data.hpc_courses),ee(n.data.file_url),Z(""),r){e.next=10;break}return e.abrupt("return");case 10:if(oe){e.next=14;break}ne?(i=0,null===n||void 0===n||null===(a=n.data)||void 0===a||null===(o=a.hpc_courses)||void 0===o||o.map((function(e,t){var n;(null===ne||void 0===ne?void 0:ne.toLocaleLowerCase())===(null===e||void 0===e||null===(n=e.name)||void 0===n?void 0:n.toLocaleLowerCase())&&(i=t)})),Y(n.data.hpc_courses[i]),D(!0),ie(n.data.hpc_courses[i].id),"resources"===(null===ne||void 0===ne?void 0:ne.toLocaleLowerCase())&&(Y(n.data.hpc_courses.filter((function(e){return 15===e.id}))[0]),D(!0),ie(15))):(Y(n.data.hpc_courses[0]),D(!0),ie(n.data.hpc_courses[0].id)),e.next=24;break;case 14:if("delete"!==t){e.next=23;break}if(0!==r){e.next=18;break}return D(!1),e.abrupt("return");case 18:Y(n.data.hpc_courses[0]),D(!0),ie(n.data.hpc_courses[0].id),e.next=24;break;case 23:"add"===t?(Y(n.data.hpc_courses[r-1]),D(!0),ie(n.data.hpc_courses[r-1].id)):(Y(n.data.hpc_courses.filter((function(e){return e.id===oe}))[0]),D(!0),ie(oe));case 24:case"end":return e.stop()}}),e)}))),le.apply(this,arguments)}function ue(e){G(!1),D(!0),Y(e),ie(e.id)}function se(e){Z(e),G(!0),D(!1)}function fe(){Z(""),G(!0),D(!1)}Object(l["useEffect"])((function(){x({type:"globalSetting/headerToggle",payload:!1}),S&&ce("")}),[S]);var he={name:"file",multiple:!0,action:"https://www.educoder.net/api/hpc_courses/upload_file.json",data:{container_type:window.location.pathname.split("/")[1]},onChange:function(e){var t=e.file.status;"done"===t?(o["b"].success("".concat(e.file.name," \u6587\u4ef6\u4e0a\u4f20\u6210\u529f")),ce("")):"error"===t&&o["b"].error("".concat(e.file.name," \u6587\u4ef6\u4e0a\u4f20\u5931\u8d25"))},beforeUpload:function(e){var t=e.size/1024/1024<150;return t||o["b"].info("\u6587\u4ef6\u5927\u5c0f\u5fc5\u987b\u5c0f\u4e8e150MB"),t}};return u.a.createElement("div",{style:{marginBottom:"40px"}},u.a.createElement("img",{style:{width:"100%"},src:w["a"].IMG_SERVER+"/".concat(X)}),u.a.createElement("div",{className:"edu-container minH500",style:{display:"flex",width:"1200px"}},u.a.createElement("div",{style:{flex:"1",marginTop:"17px"}},V&&V.map((function(e,t){return u.a.createElement("p",{key:t,onClick:function(){return ue(e)},className:oe===e.id?"menuitemselect":"menuitem task-hide"},e.name)})),299635===(null===j||void 0===j||null===(t=j.userInfo)||void 0===t?void 0:t.user_id)||301458===(null===j||void 0===j||null===(n=j.userInfo)||void 0===n?void 0:n.user_id)||(null===j||void 0===j||null===(s=j.userInfo)||void 0===s?void 0:s.admin)||(null===j||void 0===j||null===(f=j.userInfo)||void 0===f?void 0:f.business)?u.a.createElement("p",{onClick:function(){return fe()},className:"menuadd",style:{fontSize:"24px",paddingLeft:"10px"}},u.a.createElement("span",{style:{fontSize:"16px",marginLeft:"5px"}},"Last updated")):null),u.a.createElement("div",{className:"rightcount",style:{flex:"6",background:"#ffffff",padding:"20px",marginLeft:"30px",marginTop:"24px"}},F?u.a.createElement(m,{UpdateItem:Q,setIscreate:G,init:ce}):null,q?u.a.createElement(b,{UserInfo:null===j||void 0===j?void 0:j.userInfo,setSee:D,userId:null===j||void 0===j||null===(d=j.userInfo)||void 0===d?void 0:d.user_id,ItemUpdate:se,CourseItem:U,init:ce}):null)),299635===(null===j||void 0===j||null===(p=j.userInfo)||void 0===p?void 0:p.user_id)||301458===(null===j||void 0===j||null===(v=j.userInfo)||void 0===v?void 0:v.user_id)||(null===j||void 0===j||null===(g=j.userInfo)||void 0===g?void 0:g.admin)||(null===j||void 0===j||null===(y=j.userInfo)||void 0===y?void 0:y.business)?u.a.createElement(r["a"],he,u.a.createElement(a["a"],{className:"menuadd",style:{paddingLeft:"10px",marginLeft:"20px"}},"\u4e0a\u4f20\u9996\u9875\u56fe\u7247")):null)}t["default"]=Object(j["a"])((function(e){var t=e.user;return{user:t}}))(x)},dejd:function(e,t,n){},kSUc:function(e,t,n){}}]); |