@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 11.5 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[5552],{49794:(e,t,n)=>{n.d(t,{o:()=>r});var a=n(32295),o=n(19990),r=a.React.memo((function(e){var t=e.font_size,n=e.actions;(0,a.useEffect)((function(){setTimeout((function(){return n.updateTableOfContents(!0)}))}),[]);var r=(0,a.useRedux)([n.name,"contents"]);return a.React.createElement(o.TableOfContents,{contents:r,style:{fontSize:"".concat(t-6,"px")},scrollTo:n.scrollToHeading.bind(n)})}))},85552:(e,t,n)=>{n.r(t),n.d(t,{Editor:()=>Y,pdfjs_buttons:()=>P});var a=n(24620),o=n(28459),r=n(47975),l=n(10552),i=n(33258),c=n(61375),u=n.n(c),s=n(32295),m=n(19990),d=n(50386),f=n(88570),p=n(13398),h=n(4668),b=n(57031),y=n(33667),g=n(84286),R=n(64174),_=n(84884),v=n(13435);function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a,o,r=[],l=!0,i=!1;try{for(n=n.call(e);!(l=(a=n.next()).done)&&(r.push(a.value),!t||r.length!==t);l=!0);}catch(e){i=!0,o=e}finally{try{l||null==n.return||n.return()}finally{if(i)throw o}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){var t;if(null==e)return"";if("string"==typeof e)t=e;else{var n=[];e.forEach((function(e){(0,a.split)(e).length>1&&(e=-1===e.indexOf("'")?"'".concat(e,"'"):'"'.concat(e,'"')),n.push(e)})),t=n.join(" ")}return t}var w=s.React.memo((function(e){var t,n=function(e){var t=(0,_.mT)(e,i,u,l.output_directory);l.set_build_command(t)},a=function(){l.init_build_directive(!0)},o=function(){if(O){var e=l.sanitize_build_cmd_str(O);l.set_build_command(e),I(e)}else n(_.xm[0]);j(!1),B(!1)},r=function(){return s.React.createElement(y.zx,{disabled:!X,bsSize:"xsmall",bsStyle:X?"success":void 0,title:"Saves the modified command (or just hit the 'Return' key)",onClick:function(){return o()}},s.React.createElement(R.Z,null))},l=e.actions,i=e.filename,c=e.build_command,u=e.knitr,x=e.font_size,w=e.build_command_hardcoded,C=void 0!==w&&w,z=E(s.React.useState(c),2),k=z[0],T=z[1],A=E(s.React.useState(S(c)),2),O=A[0],I=A[1],L=E(s.React.useState(!1),2),F=L[0],B=L[1],D=E(s.React.useState(!1),2),X=D[0],j=D[1],P=E(s.React.useState(!1),2),Z=P[0],Y=P[1];return F||k==c||(T(c),I(S(c))),null==O?s.React.createElement(m.Loading,null):s.React.createElement("div",{style:{paddingRight:"5px"}},C?s.React.createElement(s.React.Fragment,null,s.React.createElement(s.React.Fragment,null,s.React.createElement("h4",null,"Hardcoded build-command",s.React.createElement("a",{style:{float:"right"},onClick:function(){return Y(!Z)}},s.React.createElement(m.Icon,{name:"question-circle"})," ",Z?"Close Help":"Help"),s.React.createElement("a",{style:{float:"right",marginRight:"10px"},onClick:function(){return a()}},s.React.createElement(m.Icon,{name:"reload"})," Rescan")),s.React.createElement("pre",{style:{whiteSpace:"pre-line"}},O),Z&&s.React.createElement(d.Alert,{bsStyle:"warning"},s.React.createElement("div",{style:{color:v.COLORS.GRAY}},s.React.createElement("p",null,"There is a ",s.React.createElement("code",null,"% !TeX cocalc = ...")," directive in your document. This hardcodes the build command for this document. The command is sanitized to work well with this editor by e.g. always replacing the last token to the current file name. To disable any sanitization, add a semicolon at the end or use a semicolon to issue more than one command."),s.React.createElement("p",null,"After changing the build command directive, commenting it out via ",s.React.createElement("code",null,"%% ")," or removing it, make sure to"," ",s.React.createElement("a",{onClick:function(){return a()}},"rescan the document"),"."),s.React.createElement("p",null,"Example:"," ",s.React.createElement("code",null,"% !TeX cocalc = latexmk -pdf -f -g -bibtex -deps -synctex=1 -interaction=nonstopmode file.tex"),"."))))):s.React.createElement(s.React.Fragment,null,s.React.createElement(b.Z,{name:"command_line",layout:"inline"},s.React.createElement(b.Z.Item,{style:{flex:"1 1 auto",marginRight:"0"}},s.React.createElement(h.Z,{style:{fontFamily:"monospace",fontSize:x,textOverflow:"ellipsis"},value:O,disabled:C,onChange:function(e){return t=e.target.value,I(t),void j(!0);var t},onFocus:function(){return B(!0)},onKeyDown:function(e){(13==e.keyCode||(e.metaKey||e.ctrlKey)&&"s"==String.fromCharCode(e.which).toLowerCase())&&(o(),e.preventDefault())},onBlur:function(){o()}})),s.React.createElement(b.Z.Item,null,r()),s.React.createElement(b.Z.Item,{style:{marginRight:"5px"}},s.React.createElement(p.Z,{placement:"bottomRight",overlay:(t=_.xm.map((function(e){return s.React.createElement(f.Z.Item,{key:e},e)})),s.React.createElement(f.Z,{onClick:function(e){return n(e.key)}},t)),trigger:["hover","click"],disabled:C},s.React.createElement(y.zx,{bsSize:"xsmall"},"Engine ",s.React.createElement(g.Z,null))))),F?s.React.createElement(d.Alert,{bsStyle:"info"},s.React.createElement("div",{style:{color:v.COLORS.GRAY}},s.React.createElement("h4",null,"Build Command"),"Select a build engine from the menu at the right, or enter absolutely any custom build command line you want. Custom build commands are run using bash, so you can separate multiple commands with a semicolon. If there is no semicolon, then the command line must end with the filename (not including the directory).")):null))})),C=n(27517);function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a,o,r=[],l=!0,i=!1;try{for(n=n.call(e);!(l=(a=n.next()).done)&&(r.push(a.value),!t||r.length!==t);l=!0);}catch(e){i=!0,o=e}finally{try{l||null==n.return||n.return()}finally{if(i)throw o}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var T={build:{button:!0,label:"Build",icon:"retweet",tip:"Build the document, running LaTeX, BibTex, Sage, etc."},latex:{button:!1,label:"LaTeX",icon:"tex-file",tip:"Run the LaTeX build command (typically latexmk)"},bibtex:{button:!1,label:"BibTeX",icon:"file-code",tip:"Process bibliography using Bibtex"},sagetex:{button:!1,label:"SageTex",icon:"sagemath-bold",tip:"Run SageTex, if necessary"},pythontex:{button:!1,label:"PythonTeX",icon:"python",tip:"Run PythonTeX3, if necessary"},knitr:{button:!1,label:"Knitr",icon:"r",tip:"Run Knitr, if necessary"},clean:{button:!0,label:"Clean",icon:"trash",tip:"Delete all autogenerated auxiliary files"}},A=s.React.memo((function(e){var t,n=function(e,t,n,a){var o={fontFamily:"monospace",whiteSpace:"pre-line",color:v.COLORS.GRAY_D,background:v.COLORS.GRAY_LLL,display:_===e?"block":"none",width:"100%",padding:"5px",fontSize:"".concat(f,"px"),overflowY:"auto",margin:"0"},r=n?{background:v.COLORS.ATND_BG_RED_L}:void 0,l=s.React.createElement("div",{style:r},e);return s.React.createElement(y.OK,{key:e,eventKey:e,title:l,style:o},a&&"Build time: ".concat(a,"\n\n"),s.React.createElement(u(),null,t))},o=function(e){if(null!=p){var t=p.get(e);if(t){var a=t.get("stdout")+t.get("stderr");if(a){var o=t.get("time"),r=o?"(".concat((o/1e3).toFixed(1)," seconds)"):"",l=T[e].label,i=p.getIn([e,"parse","errors"]).size>0;return i&&(A=!1,null==S&&(x(l),z(l))),n(l,a,i,r)}}}},r=e.name,l=e.actions,i=e.path,c=e.font_size,d=e.status,f=.8*c,p=(0,C.h)(r),h=(0,s.useRedux)([r,"build_command"]),b=null!==(t=(0,s.useRedux)([r,"build_command_hardcoded"]))&&void 0!==t&&t,g=(0,s.useRedux)([r,"knitr"]),R=k(s.React.useState(T.latex.label),2),_=R[0],x=R[1],E=k(s.React.useState(null),2),S=E[0],z=E[1],A=!0,O=function(){if(!d)return s.React.createElement(y.mQ,{activeKey:_,onSelect:x,tabPosition:"left",size:"small",style:{height:"100%",overflowY:"auto"}},o("latex"),o("sagetex"),o("pythontex"),o("knitr"),o("bibtex"),function(){var e=null==p?void 0:p.getIn(["clean","output"]);if(e)return n("Clean Auxiliary Files",e)}())}();return A&&null!=S&&z(null),s.React.createElement("div",{className:"smc-vfill cocalc-latex-build-content",style:{overflow:"hidden",padding:"5px 0 0 5px",fontSize:"".concat(f,"px")}},s.React.createElement(w,{font_size:f,filename:(0,a.path_split)(i).tail,actions:l,build_command:h,knitr:g,build_command_hardcoded:b}),function(){if(d)return s.React.createElement("div",{style:{margin:"15px"}},s.React.createElement(m.Loading,{text:d,style:{fontSize:"10pt",textAlign:"center",marginTop:"15px",color:v.COLORS.GRAY}}))}(),O)})),O=n(24816),I=s.React.memo((function(e){var t,n=e.name,a=e.actions,o=e.font_size,r=null!==(t=(0,s.useRedux)([n,"word_count"]))&&void 0!==t?t:"";return s.React.useEffect((function(){a.word_count(0,!1)}),[]),s.React.createElement("div",{"cocalc-test":"word-count-output",className:"smc-vfill",style:{overflowY:"scroll",padding:"5px 15px",fontSize:"".concat(.8*o,"pt"),whiteSpace:"pre-wrap",fontFamily:"monospace"}},r)})),L=n(72113),F=n(96396),B=n(63697),D=n(89550),X=n(67941),j=n(49794),P=(0,a.set)(["print","download","decrease_font_size","increase_font_size","set_zoom","zoom_page_width","zoom_page_height","sync"]),Z={cm:{short:"Source",name:"LaTeX Source Code",icon:"code",component:i.w,buttons:(0,a.set)(["build","print","decrease_font_size","increase_font_size","save","time_travel","replace","find","goto_line","cut","paste","copy","undo","redo","sync","help","format","switch_to_file","show_table_of_contents"]),gutters:["Codemirror-latex-errors"]},pdfjs_canvas:{short:"PDF (preview)",name:"PDF - Preview",icon:"file-pdf",component:r.a,buttons:P,path:D.n,style:{background:"#525659"},renderer:"canvas"},error:{short:"Errors",name:"Errors and Warnings",icon:"bug",component:O.o,buttons:(0,a.set)(["build"])},build:{short:"Build",name:"Build Control and Log",icon:"terminal",component:A,buttons:(0,a.set)(["build","force_build","clean","decrease_font_size","increase_font_size","rescan_latex_directive"])},latex_table_of_contents:{short:"Contents",name:"Table of Contents",icon:"align-right",component:j.o,buttons:(0,a.set)(["decrease_font_size","increase_font_size"])},word_count:{short:"Word Count",name:"Word Count",icon:"file-alt",buttons:(0,a.set)(["word_count"]),component:I},terminal:F.terminal,settings:L.H,time_travel:B.Y};X.IS_IPAD||X.IS_IOS||(Z.pdf_embed={short:"PDF (native)",name:"PDF - Native",icon:"file-pdf",buttons:(0,a.set)(["print","save","download"]),component:l.X,path:D.n});var Y=(0,o.J)({format_bar:!0,format_bar_exclude:{strikethrough:!0,SpecialChar:!0,image:!0,unformat:!0,font_dropdowns:!0},editor_spec:Z,display_name:"LaTeXEditor"})}}]);