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
12 KiB
1 line
12 KiB
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[10267],{38278:function(e,t,n){n.d(t,{Z:function(){return _}});var a=n(82242),r=n.n(a),i=n(7557),c=n.n(i),l=n(41498),o=n.n(l),s=n(79800),u=n.n(s),d=n(59301),p={wrp:"wrp___dq7YK",bgBlack:"bgBlack___ARIUV",monaco:"monaco___VnZC3",darkBlue:"darkBlue___UprA9",close:"close___LKoWu",embed:"embed___hvpEJ"},f=n(3113),h=n(38827),v=n(65680),m=n(6848),g=n(23603),x=n(52113),y=n(88820),w=n(41681),b=n(37712),_=function(e){var t,n,a,i,l,s,_,k=e.editOffice,j=void 0===k?"view":k,E=e.data,S=(e.theme,e.type),C=e.filename,Z=e.monacoEditor,N=e.className,P=e.style,R=e.close,O=e.onClose,T=e.hasMask,L=e.disabledDownload,I=e.onImgDimensions,A=e.showNodata,M=(0,d.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),W=u()(M,2),F=(W[0],W[1],(0,d.useState)("")),H=u()(F,2),V=(H[0],H[1]),B=(0,d.useState)(),z=u()(B,2),D=z[0],U=z[1],$="build"===window.ENV?"/react/build":"",q=location.host.startsWith("localhost")?w.Z.PROXY_SERVER:w.Z.API_SERVER,J=(0,d.useRef)();null!==(t=E)&&void 0!==t&&t.startsWith("/api")&&"txt"!==S&&(E=w.Z.API_SERVER+E),C&&(Z.filename=C),(0,d.useEffect)((function(){var e,t=null===(e=document.cookie)||void 0===e||null===(e=e.replace(/\s/g,""))||void 0===e?void 0:e.split(";");null==t||t.map((function(e){var t=e.split("=");"_educoder_session"===t[0]&&V(t[1])}))}),[]),(0,d.useEffect)((function(){"office"===S&&X()}),[S,E]);var X=function(){var e=o()(c()().mark((function e(){var t,n,a;return c()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=E,E.startsWith("http")||(t=location.origin+t),n=new URL(t).pathname.split("/").pop(),e.next=5,(0,x.gJ)({attachment_id:n});case 5:a=e.sent,U(a);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),K=function(){E.startsWith("http")||E.startsWith("blob:")?Y():(0,g.Sv)(C||"educoder",E,C)},Y=function(){(0,g.Nd)(C||"educoder",decodeURIComponent(E))};return(0,b.jsxs)("div",{style:r()({},P||{}),className:"".concat(T&&p.bgBlack," ").concat(S?p.wrp:"hide"),children:[R&&(0,b.jsxs)("div",{className:p.close,ref:J,children:[!!I&&(0,b.jsx)(m.Z,{title:"点击对图片进行批注",getPopupContainer:function(){return J.current},children:(0,b.jsx)("span",{onClick:function(){O(),I()},children:(0,b.jsx)("i",{className:"icon-yulanpizhu"})})}),!L&&(0,b.jsx)(m.Z,{title:"点击下载此文件",getPopupContainer:function(){return J.current},children:(0,b.jsx)("span",{onClick:Y,children:(0,b.jsx)("i",{className:"icon-quxiaozhiding"})})}),(0,b.jsx)(m.Z,{title:"关闭",getPopupContainer:function(){return J.current},children:(0,b.jsx)("span",{className:"",onClick:O,children:(0,b.jsx)("i",{className:"icon-guanbi1"})})})]}),(0,b.jsx)("div",{className:"".concat(p[N]," ").concat(N," ").concat(p.monaco," ").concat("txt"===S?"show":"hide"),children:"txt"===S&&(0,b.jsx)(v.ZP,r()({},Z))}),"audio"===S&&(0,b.jsx)("audio",{src:(null===(n=E)||void 0===n?void 0:n.indexOf("http"))>-1||null!==(a=E)&&void 0!==a&&a.startsWith("/api")?E:"data:image/png;base64,".concat(E),autoPlay:!0}),"video"===S&&(0,b.jsx)(b.Fragment,{children:(null===(i=E)||void 0===i?void 0:i.indexOf("http"))>-1||null!==(l=E)&&void 0!==l&&l.startsWith("/api")?(0,b.jsx)("video",{controls:!0,src:"".concat(E),autoPlay:!0}):(0,b.jsx)("video",{controls:!0,src:"data:video/mp4;base64,".concat(E),autoPlay:!0})}),"office"===S&&D&&(0,b.jsx)("iframe",{src:"".concat($,"/office.html?key=").concat(D.key,"&url=").concat(q+D.url,"&callbackUrl=").concat(q+D.callbackUrl,"&fileType=").concat(D.fileType,"&title=").concat(D.title,"&model=").concat(j,"&officeServer=").concat(w.Z.ONLYOFFICE,"&disabledDownload=").concat(!!L)}),"html"===S&&(0,b.jsx)("iframe",{src:E+"&disposition=inline"}),"pdf"===S&&(0,b.jsx)("iframe",{src:"".concat($,"/js/pdfview/index.html?url=").concat(E,"&disabledDownload=").concat(!!L)}),"image"===S&&(0,b.jsx)("img",{src:(null===(s=E)||void 0===s?void 0:s.indexOf("http"))>-1||null!==(_=E)&&void 0!==_&&_.startsWith("/api")?E:"data:image/png;base64,".concat(E)}),("other"===S||"download"===S)&&(0,b.jsx)(b.Fragment,{children:A?(0,b.jsx)(y.Z,{customText:"当前文件不支持预览,可点击下载查看",ButtonTwo:(0,b.jsx)(f.ZP,{icon:(0,b.jsx)("i",{className:"iconfont icon-xiazai4 font14"}),type:"primary",size:"middle",onClick:K,children:"下载"})}):(0,b.jsxs)(f.ZP,{type:"primary",size:"middle",onClick:K,children:[(0,b.jsx)(h.Z,{}),"点击下载"]})})]})}},10267:function(e,t,n){n.d(t,{Z:function(){return z}});var a=n(82242),r=n.n(a),i=n(37205),c=n.n(i),l=n(91232),o=n.n(l),s=n(79800),u=n.n(s),d=n(59301),p=(n(46650),n(32834)),f=n.n(p),h=n(11690);var v=[],m=["<ul>"],g=new(f().Renderer),x=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function y(){v.length=0,m=["<ul>"]}var w={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function b(e,t,n,a){if(t>=e.length||e[t].level<=n)return t;var r=e[t];a.push("<li><a href='#"+r.anchor+"'>"+r.text+"</a>");var i=[];return t=b(e,++t,r.level,i),i.length>0&&(a.push("<ul>"),i.forEach((function(e){a.push(e)})),a.push("</ul>")),a.push("</li>"),t=b(e,t,n,a)}function _(){return b(v,0,0,m),m.push("</ul>"),m.join("")}var k={heading:function(e){var t=x.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],a=function(e,t){var n=e.match(/^(\s+)(?:```)/);if(null===n)return t;var a=n[1];return t.split("\n").map((function(e){var t=e.match(/^\s+/);return null===t?e:u()(t,1)[0].length>=a.length?e.slice(a.length):e})).join("\n")}(n,t[3]||""),r=t[2]?t[2].trim():t[2];if(["latex","katex","math"].indexOf(r)>=0){var i=S(),c=a;a=i,C[i]={type:"block",expression:c}}return{type:"code",raw:n,lang:r,text:a}}}},j=/(?:\${2})([^\n`]+?)(?:\${2})/gi,E=0,S=function(){return"__special_katext_id_".concat(E++,"__")},C={};function Z(){return C}function N(){E=0,C={}}function P(e){return e=e.replace(j,(function(e,t){var n=S();return C[n]={type:"inline",expression:t},n}))}var R=g.listitem;g.listitem=function(e){return R(P(e))};var O=g.paragraph;g.paragraph=function(e){return O(P(e))};var T=g.tablecell;g.tablecell=function(e,t){return T(P(e),t)},g.code=function(e,t,n){var a=(t||"").match(/\S*/)[0];return a?["latex","katex","math"].indexOf(a)>=0?"<p class='editormd-tex'>".concat(e,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(t,'">').concat(n?e:(0,h.escape)(e,!0),"</code></pre>\n"):'<pre class="prettyprint linenums"><code>'+(n?e:(0,h.escape)(e,!0))+"</code></pre>"},g.heading=function(e,t,n){var a=this.options.headerPrefix+n.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return v.push({anchor:a,level:t,text:e}),"<h"+t+' id="'+a+'">'+e+"</h"+t+">"},f().setOptions({silent:!0,gfm:!0,pedantic:!1}),f().use({tokenizer:k,renderer:g});var L=f(),I=(n(64018),n(45071)),A=n(41681),M=n(15342),W=n(1012),F=n(38278),H=n(37712),V="@▁@",B=/<pre[^>]*>/g;var z=function(e){var t=e.value,n=void 0===t?"":t,a=e.className,i=e.showTextOnly,l=e.showLines,s=e.style,p=void 0===s?{}:s,f=e.stylesPrev,h=void 0===f?{}:f,v=e.highlightKeywords,m=e.showProgramFill,g=(e.isProgramFill,e.disabledFill),x=void 0!==g&&g,b=e.programFillValue,k=e.onFillChange,j=void 0===k?function(e){}:k,E=e.onFillBlur,S=void 0===E?function(){}:E,C=String(n),P=(0,d.useState)(""),R=u()(P,2),O=R[0],T=R[1],z=(0,d.useState)("office"),D=u()(z,2),U=D[0],$=D[1],q=(0,d.useState)([]),J=u()(q,2),X=J[0],K=J[1],Y=(0,d.useRef)("a"+(0,W.Z)()),G={},Q=function(e){return e.replace(/<style.*?>([\s\S]+?)<\/style>/gim,(function(e,t){var n=t.replace(/(\n|\r)/g,"").split("}"),a=[];return n.map((function(e){""!=e&&a.push(".".concat(Y.current," ").concat(e))})),"<style>".concat(a.join("}"),"</style>")}))},ee=(0,d.useMemo)((function(){try{C=C.replace(/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,"("+A.Z.API_SERVER+"/api/attachments/").replace(/\"\/api\/attachments\/|\"\/attachments\/download\//g,'"'+A.Z.API_SERVER+"/api/attachments/").replace(/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g,'"'+A.Z.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,"\n")}catch(e){}if(m){var e=-1;return C=C.replaceAll("<","<").replaceAll(">",">").replace(/(@▁▁@|@▁@)/g,(function(t,n,a){return function(e,t){var n=document.createElement(e===V?"input":"textarea");n.style.width="100%",n.style.height=e===V?"40px":"151px",n.rows=5,n.spellcheck=!1,n.name="edu-program-fill",n.placeholder="请输入",n.dataset.id=t;var a=Object.keys(G).length;return G[a]=n,'<span class="edu-program-fill-wrap '.concat(e===V?"":"show",'" style="width:').concat(e===V?"200px":"100%",'"><span>').concat(n.outerHTML,'<span class="edu-program-fill-score"></span></span></span>')}(t,++e)})),'<pre style="background:#fff;padding:4px">'.concat(Q(C||""),"</pre>")}var t=L(C);t=Q(t);var n=Z();C.match(/\[TOC\]/)&&(t=t.replace("<p>[TOC]</p>",_()),y()),t=t.replace(/(__special_katext_id_\d+__)/g,(function(e,t){var a=n[t],r=a.type,i=a.expression;return(0,M.renderToString)(function(e){var t=document.createElement("div");return t.innerHTML=e,0===t.childNodes.length?"":t.childNodes[0].nodeValue}(i)||"",{displayMode:"block"===r,throwOnError:!1,output:"html"})})),t=t.replace(/▁/g,"▁▁▁"),N();var a=document.createElement("div");return a.innerHTML=t,v?(ae(a,v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),a.innerHTML):i?a.innerText:(setTimeout((function(){return ce()}),500),a.innerHTML)}),[C,v]);(0,d.useEffect)((function(){re.current&&re.current.querySelectorAll(["input","textarea"]).forEach((function(e){e.oninput=te,e.onblur=ne}))}),[X]),(0,d.useEffect)((function(){if(null!=b&&b.length){var e,t=re.current.querySelectorAll(".edu-program-fill-score"),n=re.current.querySelectorAll('[name="edu-program-fill"]'),a=o()(n.entries());try{for(a.s();!(e=a.n()).done;){var r,i=u()(e.value,2),c=i[0],l=i[1];l.value=null===(r=b[c])||void 0===r?void 0:r.value,"warning"===b[c].type?l.className="program-fill-warning":"success"===b[c].type?l.className="program-fill-success":l.className=""}}catch(e){a.e(e)}finally{a.f()}var s,d=o()(t.entries());try{for(d.s();!(s=d.n()).done;){var p,f,h=u()(s.value,2),v=h[0];h[1].innerHTML=null!==(p=b[v])&&void 0!==p&&p.score?"".concat(null===(f=b[v])||void 0===f?void 0:f.score,"分"):""}}catch(e){d.e(e)}finally{d.f()}K(b)}}),[b]);var te=function(e){X[e.target.dataset.id]=X[e.target.dataset.id]||{},X[e.target.dataset.id].value=e.target.value,K(c()(X)),j(X,e.target.dataset.id)},ne=function(e){X[e.target.dataset.id]=X[e.target.dataset.id]||{},X[e.target.dataset.id].value=e.target.value,K(c()(X)),S(X,e.target.dataset.id)};function ae(e,t){return e.childNodes.forEach((function(e){if(e.childNodes.length>0)ae(e,t);else if("IMG"!==e.nodeName)if(e.innerHTML){var n;e.innerHTML=null===(n=e.innerHTML)||void 0===n?void 0:n.replace(new RegExp(t,"gi"),'<span style="color:#0152d9;background-color:#1890ff33">$&</span>')}else{var a=document.createElement("span");a.innerHTML=e.textContent.replace(new RegExp(t,"gi"),'<span style="color:#0152d9;background-color:#1890ff33">$&</span>'),e.replaceWith(a)}}))}var re=(0,d.useRef)();function ie(e){var t=e.target;if("A"===t.tagName.toUpperCase()){var n=t.getAttribute("href");if(n.indexOf("office")>-1)e.preventDefault(),T(n),$("office");else if(n.indexOf("application/pdf")>-1)e.preventDefault(),T(n),$("pdf");else if(n.indexOf("text/html")>-1)e.preventDefault(),T(n),$("html");else if(n.startsWith("#")){e.preventDefault();var a=document.getElementById(n.replace("#",""));a&&a.scrollIntoView(!0)}}}w.WebkitLineClamp=l,l&&(p=r()(r()({},p),w));var ce=function(){var e,t=null===(e=re.current)||void 0===e?void 0:e.querySelectorAll("video");null==t||t.forEach((function(e){if(e.oncontextmenu=function(){return!1},e.src.indexOf(".m3u8")>-1)if(e.canPlayType("application/vnd.apple.mpegurl"));else if(I.ZP.isSupported()){var t=new I.ZP;t.loadSource(e.src),t.attachMedia(e)}}))};return(0,d.useEffect)((function(){if(re.current&&ee&&ee.match(B)&&window.PR.prettyPrint(),re.current)return re.current.addEventListener("click",ie),function(){var e;null===(e=re.current)||void 0===e||e.removeEventListener("click",ie),N(),y()}}),[ee,re.current,ie]),(0,H.jsxs)(H.Fragment,{children:[i&&(0,H.jsx)("div",{ref:re,children:ee}),!i&&(0,H.jsx)("div",{ref:re,style:r()({},p),className:"".concat(a||""," ").concat(x?"disabled-fill":""," markdown-body ").concat(Y.current),dangerouslySetInnerHTML:{__html:ee}}),(0,H.jsx)(F.Z,{close:!0,data:O,type:null!=O&&O.length?U:"",style:r()({},h),onClose:function(){return T("")}})]})}}}]); |