texlite 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +87 -5
- package/OPERATIONS.md +27 -0
- package/dist/client/assets/AdminUsers-5cAOkdRO.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-G2kKkA2f.js +1 -0
- package/dist/client/assets/Dashboard-BJDFbzQa.js +5 -0
- package/dist/client/assets/GitDialog-BEtLh2S_.js +3 -0
- package/dist/client/assets/GitHubAccountDialog-D2kdCzOs.js +1 -0
- package/dist/client/assets/{HistoryDialog-DWYErBwj.js → HistoryDialog-BwxDdj-j.js} +3 -3
- package/dist/client/assets/LatexEditor-sMjmvA6V.js +141 -0
- package/dist/client/assets/{PdfPreview-BjghzUb1.js → PdfPreview-z5KnowpL.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-DNV7M7vH.js +1 -0
- package/dist/client/assets/ProjectSettings-Mf8zDGRu.js +1 -0
- package/dist/client/assets/ProjectWorkspace-BJFxjMCn.js +32 -0
- package/dist/client/assets/QuickOpenDialog-C758pouQ.js +1 -0
- package/dist/client/assets/{SelectionHistoryDialog-CR5c3I8k.js → SelectionHistoryDialog-p8L2n4RS.js} +2 -2
- package/dist/client/assets/SystemMetricsDialog-DDiSuglF.js +1 -0
- package/dist/client/assets/TagManagementDialog-BTVERmQS.js +1 -0
- package/dist/client/assets/WordCountDialog-B6RvAI6V.js +1 -0
- package/dist/client/assets/check-Hlb-tLSh.js +1 -0
- package/dist/client/assets/chevron-up-D0psXvTv.js +1 -0
- package/dist/client/assets/chktex-ZnIx425m.js +3 -0
- package/dist/client/assets/clock-3-C71NmJZI.js +1 -0
- package/dist/client/assets/{editor-CLY5CgkY.js → editor-_i6aPXT4.js} +1 -1
- package/dist/client/assets/eye-swovgNYS.js +1 -0
- package/dist/client/assets/github-y6i0qxSV.js +1 -0
- package/dist/client/assets/{hard-drive-Ctj3K_zx.js → hard-drive-BqcHPdoY.js} +1 -1
- package/dist/client/assets/index-7WrjzKvC.js +5 -0
- package/dist/client/assets/index-C5T8_lAl.js +1 -0
- package/dist/client/assets/index-DF5cor0N.js +10 -0
- package/dist/client/assets/index-Do5FsFqg.js +1 -0
- package/dist/client/assets/index-Y-wXUwwe.css +1 -0
- package/dist/client/assets/{minimize-2-BiVyoWZA.js → minimize-2-CK7jUy7-.js} +1 -1
- package/dist/client/assets/{minus-Bl8l4LXq.js → minus-B2sswwWT.js} +1 -1
- package/dist/client/assets/{plus-CCxK-HNt.js → plus-Co7iyp5m.js} +1 -1
- package/dist/client/assets/{refresh-cw-BE8IbaHI.js → refresh-cw-BHVcjInn.js} +1 -1
- package/dist/client/assets/{search-CPbhRWQE.js → search-Tpi6WAga.js} +1 -1
- package/dist/client/assets/{sigma-LxGD9tK2.js → sigma-DoHJQYf7.js} +1 -1
- package/dist/client/assets/spellCheck-BSbFJY9f.js +1 -0
- package/dist/client/assets/{tags-DuN89PsZ.js → tags-BHDlIcSb.js} +1 -1
- package/dist/client/assets/{type-BiettCiY.js → type-C-6Jq_0r.js} +1 -1
- package/dist/client/index.html +15 -3
- package/dist/server/app.js +6 -1
- package/dist/server/cgroups.js +35 -0
- package/dist/server/compilerVersions.js +46 -0
- package/dist/server/config.js +8 -0
- package/dist/server/cpuMetrics.js +122 -0
- package/dist/server/db.js +13 -0
- package/dist/server/environment.js +11 -0
- package/dist/server/i18n.js +0 -2
- package/dist/server/resourceMetrics.js +214 -0
- package/dist/server/routes/projectFiles.js +1 -59
- package/dist/server/routes/system.js +32 -1
- package/dist/server/systemMemory.js +51 -0
- package/dist/server/updates.js +116 -0
- package/dist/shared/compilerVersions.js +11 -0
- package/dist/shared/resourceMetrics.js +1 -0
- package/dist/shared/updates.js +5 -0
- package/package.json +3 -1
- package/texlite.config.example.json +3 -0
- package/dist/client/assets/AdminUsers-Dyapv-3c.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-CU7Q7r0Z.js +0 -1
- package/dist/client/assets/Dashboard-DsdhFENx.js +0 -2
- package/dist/client/assets/GitDialog-CZpnKw-J.js +0 -3
- package/dist/client/assets/GitHubAccountDialog-CZ8O_PjD.js +0 -1
- package/dist/client/assets/LatexEditor-CssVgypt.js +0 -141
- package/dist/client/assets/ProjectIconPickerDialog-CqRmgFBM.js +0 -1
- package/dist/client/assets/ProjectNavigationDialogs-BZxI3PJO.js +0 -1
- package/dist/client/assets/ProjectSettings-CZE_xDKn.js +0 -1
- package/dist/client/assets/ProjectWorkspace-CAX3qEYr.js +0 -32
- package/dist/client/assets/SystemMetricsDialog-DDpFwgXh.js +0 -1
- package/dist/client/assets/TagManagementDialog-CXLA9h_j.js +0 -1
- package/dist/client/assets/WordCountDialog-DUyR24vv.js +0 -1
- package/dist/client/assets/check-CwBYzomT.js +0 -1
- package/dist/client/assets/chevron-up-D5lCNKlk.js +0 -1
- package/dist/client/assets/chktex-CRkLYKcV.js +0 -3
- package/dist/client/assets/external-link-C9Td1CCj.js +0 -1
- package/dist/client/assets/github-D-JDXb-w.js +0 -1
- package/dist/client/assets/index-9hnQ8Q9x.js +0 -5
- package/dist/client/assets/index-C0qg2Ylw.css +0 -1
- package/dist/client/assets/index-DkpU9Fgs.js +0 -10
- package/dist/client/assets/index-_eYe7K9T.js +0 -1
- package/dist/client/assets/spellCheck-hpm8qZTr.js +0 -1
- package/dist/client/assets/x-C_3swJOC.js +0 -1
- package/dist/server/projectSearch.js +0 -113
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as Q,r as t,j as e}from"./react-CltQJflK.js";import{P as de,g as fe,w as he,G as me}from"./pdf-DUYcbPMK.js";import{M as pe,a as ge}from"./minus-Bl8l4LXq.js";import{P as xe}from"./plus-CCxK-HNt.js";import{d as G}from"./index-DkpU9Fgs.js";import{R as J}from"./refresh-cw-BE8IbaHI.js";me.workerSrc=he;const se=new de,re=2,S=new Map;async function Ee(){await se.promise}function ie(i,r){const n=`${r}:${i}`,a=S.get(n);if(a)return a.lastUsed=Date.now(),a;const m=fe({url:i,worker:se,disableRange:r==="full"}),o={task:m,promise:m.promise,consumers:0,settled:!1,retired:!1,lastUsed:Date.now()};return S.set(n,o),o.promise.then(()=>{o.settled=!0,oe()},()=>{o.settled=!0,S.get(n)===o&&S.delete(n),o.retired||(o.retired=!0,o.consumers===0&&o.task.destroy())}),o}function we(i,r){const n=`${r}:${i}`,a=S.get(n);a&&(S.delete(n),a.retired=!0,a.consumers===0&&a.task.destroy())}function oe(){if(S.size<=re)return;const i=[...S.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,n)=>r[1].lastUsed-n[1].lastUsed);for(;S.size>re&&i.length;){const[r,n]=i.shift();S.get(r)===n&&(S.delete(r),n.retired=!0,n.task.destroy())}}function Se(i,r){if(!i)return;ie(i,r).promise.catch(()=>{})}function ye(i,r){const n=ie(i,r);n.consumers+=1,n.lastUsed=Date.now();let a=!1;return{promise:n.promise,release:()=>{a||(a=!0,n.consumers=Math.max(0,n.consumers-1),n.lastUsed=Date.now(),n.retired&&n.consumers===0&&n.task.destroy(),oe())}}}function Ce({url:i,loadingMode:r,target:n,compiling:a=!1,onViewportLocation:m,onDoubleClickLocation:o,onDisplayedUrlChange:U}){const{t:d}=Q(),v=t.useRef(null),[p,$]=t.useState(null),[f,R]=t.useState(""),[k,N]=t.useState(0),[M,C]=t.useState(100),[P,b]=t.useState(""),[y,z]=t.useState(0),j=t.useRef(new Map),D=t.useRef(null),A=t.useRef(null),E=t.useRef(null),L=t.useRef(m);L.current=m;const F=t.useRef(U);F.current=U;const T=t.useRef(0),B=()=>{we(i,r),F.current?.(""),b(""),z(s=>s+1)},W=t.useCallback((s,c)=>{c?j.current.set(s,c):j.current.delete(s)},[]),_=async s=>{if(!p||s==null)return;let c=s;if(typeof s=="string"&&(c=await p.getDestination(s).catch(()=>null)),!Array.isArray(c)||c.length===0)return;const u=c[0];let w=null;if(typeof u=="number"&&Number.isInteger(u))w=u;else if(u!=null)try{w=await p.getPageIndex(u)}catch{return}w==null||w<0||w>=p.numPages||j.current.get(w+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},l=t.useCallback(()=>{D.current=null;const s=v.current;if(!s)return;const c=s.getBoundingClientRect(),u=c.left+c.width/2,w=c.top+c.height/2,q=[...s.querySelectorAll(".pdf-page")],H=q.find(Y=>{const V=Y.getBoundingClientRect();return w>=V.top&&w<=V.bottom})??q.reduce((Y,V)=>{if(!Y)return V;const ae=Math.abs(V.getBoundingClientRect().top-w),ue=Math.abs(Y.getBoundingClientRect().top-w);return ae<ue?V:Y},null);if(!H)return;const K=H.getBoundingClientRect(),ee=Number(H.dataset.scale)||1,te=Number(H.dataset.page),ce=Math.max(0,Math.min(K.width,u-K.left))/ee,le=Math.max(0,Math.min(K.height,w-K.top))/ee;te&&L.current(te,ce,le)},[]),x=t.useCallback(()=>{D.current===null&&(D.current=window.requestAnimationFrame(l))},[l]);t.useEffect(()=>()=>{D.current!==null&&window.cancelAnimationFrame(D.current),D.current=null},[]),t.useEffect(()=>{const s=v.current;if(!s)return;const c=()=>N(s.clientWidth);c();const u=new ResizeObserver(c);return u.observe(s),()=>u.disconnect()},[]),t.useEffect(()=>{const s=A.current;if(s?.url===i&&s.loadingMode===r&&T.current===y){b("");return}let c=!1;b("");const u=ye(i,r);return E.current=u,u.promise.then(w=>{if(c)return;const q=A.current;A.current={...u,url:i,loadingMode:r},T.current=y,E.current===u&&(E.current=null),$(w),R(i),q?.release()}).catch(()=>{c||(E.current===u&&(E.current=null),u.release(),b(d("editor.pdfLoadFailed")))}),()=>{c=!0,E.current===u&&(E.current=null,u.release())}},[i,r,y,d]),t.useEffect(()=>()=>{F.current?.(""),E.current?.release(),E.current=null,A.current?.release(),A.current=null},[]),t.useEffect(()=>{M>100||!v.current||(v.current.scrollLeft=0)},[M,k,p]);const h=s=>C(c=>Math.min(200,Math.max(50,c+s))),g=()=>{v.current&&(v.current.scrollLeft=0),C(100)},O=s=>{!s.shiftKey||Math.abs(s.deltaX)>Math.abs(s.deltaY)||(s.preventDefault(),s.currentTarget.scrollLeft+=s.deltaY,x())},Z=!!(p&&f!==i&&!P),I=f===i?n:null,X=()=>{f===i&&F.current?.(i),x()};return e.jsxs("div",{className:"pdf-viewer",children:[e.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":d("editor.pdfZoomControls"),children:[e.jsx("button",{disabled:M<=50,title:d("editor.pdfZoomOut"),"aria-label":d("editor.pdfZoomOut"),onClick:()=>h(-10),children:e.jsx(pe,{size:14})}),e.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[M,"%"]}),e.jsx("button",{disabled:M>=200,title:d("editor.pdfZoomIn"),"aria-label":d("editor.pdfZoomIn"),onClick:()=>h(10),children:e.jsx(xe,{size:14})}),e.jsxs("button",{className:"pdf-fit-width",title:d("editor.pdfFitWidth"),onClick:g,children:[e.jsx(ge,{size:13}),d("editor.pdfFitWidth")]})]}),a&&e.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.compiling")})]}),Z&&!a&&e.jsxs("div",{className:"pdf-loading-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.loadingPdf")})]}),p&&P&&e.jsxs("div",{className:"pdf-load-error-overlay",role:"status","aria-live":"polite",children:[e.jsx("span",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:13}),d("common.retry")]})]}),e.jsx("div",{className:"pdf-document",ref:v,onScroll:x,onWheel:O,children:e.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,k-28)*Math.max(1,M/100)}px`},children:[!p&&!P&&e.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:24}),e.jsx("span",{children:d("editor.loadingPdf")})]}),P&&!p&&e.jsxs("div",{className:"preview-empty",children:[e.jsx("strong",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:14}),d("common.retry")]})]}),p&&k>0&&Array.from({length:p.numPages},(s,c)=>e.jsx(ve,{document:p,pageNumber:c+1,availableWidth:k-28,zoom:M/100,target:I?.page===c+1?I:null,onReady:X,onPageElement:W,onInternalLink:_,onDoubleClickLocation:f===i?o:void 0,onRetryDocument:B},`${f}:${c+1}`))]})})]})}function ve({document:i,pageNumber:r,availableWidth:n,zoom:a,target:m,onReady:o,onPageElement:U,onInternalLink:d,onDoubleClickLocation:v,onRetryDocument:p}){const{t:$}=Q(),f=t.useRef(null),R=t.useRef(null),k=t.useRef(null),[N,M]=t.useState(1),[C,P]=t.useState({width:0,height:0}),[b,y]=t.useState(r===1),[z,j]=t.useState(!1),[D,A]=t.useState(null),[E,L]=t.useState([]),[F,T]=t.useState(!1);t.useEffect(()=>{const l=f.current;if(!l||b)return;if(!("IntersectionObserver"in window)){y(!0);return}const x=new IntersectionObserver(h=>{h.some(g=>g.isIntersecting)&&(y(!0),x.disconnect())},{rootMargin:"900px 0px"});return x.observe(l),()=>x.disconnect()},[b]),t.useEffect(()=>{m&&y(!0)},[m?.nonce]),t.useEffect(()=>{if(!b)return;let l=!1,x=null,h=null;return j(!1),A(null),L([]),T(!1),i.getPage(r).then(g=>{if(l)return;const O=g.getViewport({scale:1}),Z=n/O.width,I=Math.min(3.3,Math.max(.175,Z*a)),X=g.getViewport({scale:I});if(M(I),P({width:X.width,height:X.height}),A(X),g.getAnnotations({intent:"display"}).then(u=>{l||L(u)}).catch(()=>{l||L([])}),!R.current)return;const s=Math.max(1,window.devicePixelRatio||1),c=g.getViewport({scale:I*s});return R.current.width=Math.floor(c.width),R.current.height=Math.floor(c.height),x=g.render({canvas:R.current,viewport:c}),x.promise.then(()=>{l||(j(!0),h=window.requestAnimationFrame(()=>{l||o()}))})}).catch(g=>{!l&&!(g instanceof Error&&g.name==="RenderingCancelledException")&&T(!0)}),()=>{l=!0,h!==null&&window.cancelAnimationFrame(h),x?.cancel()}},[i,r,n,a,b]),t.useEffect(()=>{!m||!k.current||k.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[m?.nonce,N]);const B=l=>{if(!v||!z||l.target instanceof HTMLElement&&l.target.closest("a"))return;const x=R.current;if(!x)return;const h=x.getBoundingClientRect();if(l.clientX<h.left||l.clientX>h.right||l.clientY<h.top||l.clientY>h.bottom)return;const g=N||1,O=Math.max(0,Math.min(h.width,l.clientX-h.left))/g,Z=Math.max(0,Math.min(h.height,l.clientY-h.top))/g;v(r,O,Z)},W=Math.max(1,n*a),_=W*(792/612);return e.jsxs("figure",{ref:l=>{f.current=l,U(r,l)},onDoubleClick:B,className:`pdf-page${z?" rendered":" loading"}`,"data-page":r,"data-scale":N,style:{width:`${C.width||W}px`,minHeight:`${C.height||_}px`},children:[e.jsx("canvas",{ref:R,style:{width:`${C.width||W}px`,height:`${C.height||_}px`}}),F&&e.jsxs("div",{className:"pdf-page-error",role:"alert",children:[e.jsx("span",{children:$("editor.pdfPageLoadFailed",{page:r})}),e.jsxs("button",{type:"button",onClick:p,children:[e.jsx(J,{size:14}),$("common.retry")]})]}),z&&D&&e.jsx(be,{annotations:E,viewport:D,onInternalLink:d}),m&&e.jsx("span",{ref:k,className:"pdf-sync-marker",style:{left:m.x*N,top:m.y*N}}),e.jsx("figcaption",{children:r})]})}function be({annotations:i,viewport:r,onInternalLink:n}){const{t:a}=Q(),m=a("editor.pdfLink");return e.jsx("div",{className:"pdf-annotation-layer","aria-label":a("editor.pdfLinks"),children:i.filter(o=>o.subtype==="Link"&&Array.isArray(o.rect)&&o.rect.length>=4).map((o,U)=>{const[d,v]=r.convertToViewportPoint(o.rect[0],o.rect[1]),[p,$]=r.convertToViewportPoint(o.rect[2],o.rect[3]),f=[d,v,p,$],R=Math.min(f[0],f[2]),k=Math.min(f[1],f[3]),N=Math.abs(f[2]-f[0]),M=Math.abs(f[3]-f[1]),C=typeof o.title=="string"?o.title.trim():"",P=typeof o.unsafeUrl=="string"?o.unsafeUrl.trim():"",b=typeof o.url=="string"?o.url.trim():"",y=ne(b)?b:ne(P)?P:"",z=o.dest;if(!y&&z==null)return null;const j=!!y;return e.jsx("a",{className:"pdf-annotation-link",href:y||"#",target:j?"_blank":void 0,rel:j?"noreferrer":void 0,title:C||(j?y:m),"aria-label":C||(j?y:m),style:{left:R,top:k,width:N,height:M},onClick:j?void 0:D=>{D.preventDefault(),n(z)}},`${U}-${R}-${k}`)})})}function ne(i){return/^(?:https?|mailto|ftp):/i.test(i)}export{Ce as PdfPreview,Se as preloadPdf,Ee as preloadPdfRuntime};
|
|
1
|
+
import{u as Q,r as t,j as e}from"./react-CltQJflK.js";import{P as de,g as fe,w as he,G as me}from"./pdf-DUYcbPMK.js";import{M as pe,a as ge}from"./minus-B2sswwWT.js";import{P as xe}from"./plus-Co7iyp5m.js";import{L as G}from"./index-DF5cor0N.js";import{R as J}from"./refresh-cw-BHVcjInn.js";me.workerSrc=he;const se=new de,re=2,S=new Map;async function Ee(){await se.promise}function ie(i,r){const n=`${r}:${i}`,a=S.get(n);if(a)return a.lastUsed=Date.now(),a;const m=fe({url:i,worker:se,disableRange:r==="full"}),o={task:m,promise:m.promise,consumers:0,settled:!1,retired:!1,lastUsed:Date.now()};return S.set(n,o),o.promise.then(()=>{o.settled=!0,oe()},()=>{o.settled=!0,S.get(n)===o&&S.delete(n),o.retired||(o.retired=!0,o.consumers===0&&o.task.destroy())}),o}function we(i,r){const n=`${r}:${i}`,a=S.get(n);a&&(S.delete(n),a.retired=!0,a.consumers===0&&a.task.destroy())}function oe(){if(S.size<=re)return;const i=[...S.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,n)=>r[1].lastUsed-n[1].lastUsed);for(;S.size>re&&i.length;){const[r,n]=i.shift();S.get(r)===n&&(S.delete(r),n.retired=!0,n.task.destroy())}}function Se(i,r){if(!i)return;ie(i,r).promise.catch(()=>{})}function ye(i,r){const n=ie(i,r);n.consumers+=1,n.lastUsed=Date.now();let a=!1;return{promise:n.promise,release:()=>{a||(a=!0,n.consumers=Math.max(0,n.consumers-1),n.lastUsed=Date.now(),n.retired&&n.consumers===0&&n.task.destroy(),oe())}}}function Ce({url:i,loadingMode:r,target:n,compiling:a=!1,onViewportLocation:m,onDoubleClickLocation:o,onDisplayedUrlChange:U}){const{t:d}=Q(),v=t.useRef(null),[p,$]=t.useState(null),[f,R]=t.useState(""),[k,N]=t.useState(0),[M,C]=t.useState(100),[P,b]=t.useState(""),[y,z]=t.useState(0),j=t.useRef(new Map),D=t.useRef(null),A=t.useRef(null),E=t.useRef(null),L=t.useRef(m);L.current=m;const F=t.useRef(U);F.current=U;const T=t.useRef(0),B=()=>{we(i,r),F.current?.(""),b(""),z(s=>s+1)},W=t.useCallback((s,c)=>{c?j.current.set(s,c):j.current.delete(s)},[]),_=async s=>{if(!p||s==null)return;let c=s;if(typeof s=="string"&&(c=await p.getDestination(s).catch(()=>null)),!Array.isArray(c)||c.length===0)return;const u=c[0];let w=null;if(typeof u=="number"&&Number.isInteger(u))w=u;else if(u!=null)try{w=await p.getPageIndex(u)}catch{return}w==null||w<0||w>=p.numPages||j.current.get(w+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},l=t.useCallback(()=>{D.current=null;const s=v.current;if(!s)return;const c=s.getBoundingClientRect(),u=c.left+c.width/2,w=c.top+c.height/2,q=[...s.querySelectorAll(".pdf-page")],H=q.find(Y=>{const V=Y.getBoundingClientRect();return w>=V.top&&w<=V.bottom})??q.reduce((Y,V)=>{if(!Y)return V;const ae=Math.abs(V.getBoundingClientRect().top-w),ue=Math.abs(Y.getBoundingClientRect().top-w);return ae<ue?V:Y},null);if(!H)return;const K=H.getBoundingClientRect(),ee=Number(H.dataset.scale)||1,te=Number(H.dataset.page),ce=Math.max(0,Math.min(K.width,u-K.left))/ee,le=Math.max(0,Math.min(K.height,w-K.top))/ee;te&&L.current(te,ce,le)},[]),x=t.useCallback(()=>{D.current===null&&(D.current=window.requestAnimationFrame(l))},[l]);t.useEffect(()=>()=>{D.current!==null&&window.cancelAnimationFrame(D.current),D.current=null},[]),t.useEffect(()=>{const s=v.current;if(!s)return;const c=()=>N(s.clientWidth);c();const u=new ResizeObserver(c);return u.observe(s),()=>u.disconnect()},[]),t.useEffect(()=>{const s=A.current;if(s?.url===i&&s.loadingMode===r&&T.current===y){b("");return}let c=!1;b("");const u=ye(i,r);return E.current=u,u.promise.then(w=>{if(c)return;const q=A.current;A.current={...u,url:i,loadingMode:r},T.current=y,E.current===u&&(E.current=null),$(w),R(i),q?.release()}).catch(()=>{c||(E.current===u&&(E.current=null),u.release(),b(d("editor.pdfLoadFailed")))}),()=>{c=!0,E.current===u&&(E.current=null,u.release())}},[i,r,y,d]),t.useEffect(()=>()=>{F.current?.(""),E.current?.release(),E.current=null,A.current?.release(),A.current=null},[]),t.useEffect(()=>{M>100||!v.current||(v.current.scrollLeft=0)},[M,k,p]);const h=s=>C(c=>Math.min(200,Math.max(50,c+s))),g=()=>{v.current&&(v.current.scrollLeft=0),C(100)},O=s=>{!s.shiftKey||Math.abs(s.deltaX)>Math.abs(s.deltaY)||(s.preventDefault(),s.currentTarget.scrollLeft+=s.deltaY,x())},Z=!!(p&&f!==i&&!P),I=f===i?n:null,X=()=>{f===i&&F.current?.(i),x()};return e.jsxs("div",{className:"pdf-viewer",children:[e.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":d("editor.pdfZoomControls"),children:[e.jsx("button",{disabled:M<=50,title:d("editor.pdfZoomOut"),"aria-label":d("editor.pdfZoomOut"),onClick:()=>h(-10),children:e.jsx(pe,{size:14})}),e.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[M,"%"]}),e.jsx("button",{disabled:M>=200,title:d("editor.pdfZoomIn"),"aria-label":d("editor.pdfZoomIn"),onClick:()=>h(10),children:e.jsx(xe,{size:14})}),e.jsxs("button",{className:"pdf-fit-width",title:d("editor.pdfFitWidth"),onClick:g,children:[e.jsx(ge,{size:13}),d("editor.pdfFitWidth")]})]}),a&&e.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.compiling")})]}),Z&&!a&&e.jsxs("div",{className:"pdf-loading-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.loadingPdf")})]}),p&&P&&e.jsxs("div",{className:"pdf-load-error-overlay",role:"status","aria-live":"polite",children:[e.jsx("span",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:13}),d("common.retry")]})]}),e.jsx("div",{className:"pdf-document",ref:v,onScroll:x,onWheel:O,children:e.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,k-28)*Math.max(1,M/100)}px`},children:[!p&&!P&&e.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:24}),e.jsx("span",{children:d("editor.loadingPdf")})]}),P&&!p&&e.jsxs("div",{className:"preview-empty",children:[e.jsx("strong",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:14}),d("common.retry")]})]}),p&&k>0&&Array.from({length:p.numPages},(s,c)=>e.jsx(ve,{document:p,pageNumber:c+1,availableWidth:k-28,zoom:M/100,target:I?.page===c+1?I:null,onReady:X,onPageElement:W,onInternalLink:_,onDoubleClickLocation:f===i?o:void 0,onRetryDocument:B},`${f}:${c+1}`))]})})]})}function ve({document:i,pageNumber:r,availableWidth:n,zoom:a,target:m,onReady:o,onPageElement:U,onInternalLink:d,onDoubleClickLocation:v,onRetryDocument:p}){const{t:$}=Q(),f=t.useRef(null),R=t.useRef(null),k=t.useRef(null),[N,M]=t.useState(1),[C,P]=t.useState({width:0,height:0}),[b,y]=t.useState(r===1),[z,j]=t.useState(!1),[D,A]=t.useState(null),[E,L]=t.useState([]),[F,T]=t.useState(!1);t.useEffect(()=>{const l=f.current;if(!l||b)return;if(!("IntersectionObserver"in window)){y(!0);return}const x=new IntersectionObserver(h=>{h.some(g=>g.isIntersecting)&&(y(!0),x.disconnect())},{rootMargin:"900px 0px"});return x.observe(l),()=>x.disconnect()},[b]),t.useEffect(()=>{m&&y(!0)},[m?.nonce]),t.useEffect(()=>{if(!b)return;let l=!1,x=null,h=null;return j(!1),A(null),L([]),T(!1),i.getPage(r).then(g=>{if(l)return;const O=g.getViewport({scale:1}),Z=n/O.width,I=Math.min(3.3,Math.max(.175,Z*a)),X=g.getViewport({scale:I});if(M(I),P({width:X.width,height:X.height}),A(X),g.getAnnotations({intent:"display"}).then(u=>{l||L(u)}).catch(()=>{l||L([])}),!R.current)return;const s=Math.max(1,window.devicePixelRatio||1),c=g.getViewport({scale:I*s});return R.current.width=Math.floor(c.width),R.current.height=Math.floor(c.height),x=g.render({canvas:R.current,viewport:c}),x.promise.then(()=>{l||(j(!0),h=window.requestAnimationFrame(()=>{l||o()}))})}).catch(g=>{!l&&!(g instanceof Error&&g.name==="RenderingCancelledException")&&T(!0)}),()=>{l=!0,h!==null&&window.cancelAnimationFrame(h),x?.cancel()}},[i,r,n,a,b]),t.useEffect(()=>{!m||!k.current||k.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[m?.nonce,N]);const B=l=>{if(!v||!z||l.target instanceof HTMLElement&&l.target.closest("a"))return;const x=R.current;if(!x)return;const h=x.getBoundingClientRect();if(l.clientX<h.left||l.clientX>h.right||l.clientY<h.top||l.clientY>h.bottom)return;const g=N||1,O=Math.max(0,Math.min(h.width,l.clientX-h.left))/g,Z=Math.max(0,Math.min(h.height,l.clientY-h.top))/g;v(r,O,Z)},W=Math.max(1,n*a),_=W*(792/612);return e.jsxs("figure",{ref:l=>{f.current=l,U(r,l)},onDoubleClick:B,className:`pdf-page${z?" rendered":" loading"}`,"data-page":r,"data-scale":N,style:{width:`${C.width||W}px`,minHeight:`${C.height||_}px`},children:[e.jsx("canvas",{ref:R,style:{width:`${C.width||W}px`,height:`${C.height||_}px`}}),F&&e.jsxs("div",{className:"pdf-page-error",role:"alert",children:[e.jsx("span",{children:$("editor.pdfPageLoadFailed",{page:r})}),e.jsxs("button",{type:"button",onClick:p,children:[e.jsx(J,{size:14}),$("common.retry")]})]}),z&&D&&e.jsx(be,{annotations:E,viewport:D,onInternalLink:d}),m&&e.jsx("span",{ref:k,className:"pdf-sync-marker",style:{left:m.x*N,top:m.y*N}}),e.jsx("figcaption",{children:r})]})}function be({annotations:i,viewport:r,onInternalLink:n}){const{t:a}=Q(),m=a("editor.pdfLink");return e.jsx("div",{className:"pdf-annotation-layer","aria-label":a("editor.pdfLinks"),children:i.filter(o=>o.subtype==="Link"&&Array.isArray(o.rect)&&o.rect.length>=4).map((o,U)=>{const[d,v]=r.convertToViewportPoint(o.rect[0],o.rect[1]),[p,$]=r.convertToViewportPoint(o.rect[2],o.rect[3]),f=[d,v,p,$],R=Math.min(f[0],f[2]),k=Math.min(f[1],f[3]),N=Math.abs(f[2]-f[0]),M=Math.abs(f[3]-f[1]),C=typeof o.title=="string"?o.title.trim():"",P=typeof o.unsafeUrl=="string"?o.unsafeUrl.trim():"",b=typeof o.url=="string"?o.url.trim():"",y=ne(b)?b:ne(P)?P:"",z=o.dest;if(!y&&z==null)return null;const j=!!y;return e.jsx("a",{className:"pdf-annotation-link",href:y||"#",target:j?"_blank":void 0,rel:j?"noreferrer":void 0,title:C||(j?y:m),"aria-label":C||(j?y:m),style:{left:R,top:k,width:N,height:M},onClick:j?void 0:D=>{D.preventDefault(),n(z)}},`${U}-${R}-${k}`)})})}function ne(i){return/^(?:https?|mailto|ftp):/i.test(i)}export{Ce as PdfPreview,Se as preloadPdf,Ee as preloadPdfRuntime};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as E,r as t,j as e}from"./react-CltQJflK.js";import{M as $,e as M}from"./index-DF5cor0N.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-BJDFbzQa.js";import{S as q}from"./search-Tpi6WAga.js";import"./index-C5T8_lAl.js";import"./github-y6i0qxSV.js";import"./hard-drive-BqcHPdoY.js";import"./sigma-DoHJQYf7.js";import"./tags-BHDlIcSb.js";function y(o){return o.trim().toLocaleLowerCase()}function J({project:o,open:l,onOpenChange:d,onSave:g}){const{t:s,i18n:k}=E(),[i,x]=t.useState(""),[n,p]=t.useState(null),[I,u]=t.useState(""),[r,j]=t.useState(!1),[f,m]=t.useState("");t.useEffect(()=>{l&&(x(""),p(o?.icon??null),u(o?.icon&&!z(o.icon)?o.icon:""),j(!1),m(""))},[l,o?.id,o?.icon]);const v=t.useMemo(()=>{const c=y(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>y(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await g(o.id,n),d(!1)}catch(c){m(M(c))}finally{j(!1)}}},S=n!==(o?.icon??null),N=c=>{p(c),u("")},w=c=>{u(c);const a=c.trim();p(a?F(a)??a:null)};return e.jsx($,{open:l,wide:!0,className:"project-icon-picker-modal",title:s("projectIcons.title"),description:o?s("projectIcons.description",{project:o.name}):void 0,onOpenChange:c=>{r||d(c)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>d(!1),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"primary",disabled:r||!S,"aria-busy":r,onClick:()=>{C()},children:s("projectIcons.save")})]}),children:e.jsxs("div",{className:"project-icon-picker",children:[f&&e.jsx("p",{className:"error dialog-error",role:"alert",children:f}),e.jsxs("label",{className:"project-icon-search",children:[e.jsx(q,{"aria-hidden":"true",size:16}),e.jsx("span",{className:"sr-only",children:s("projectIcons.search")}),e.jsx("input",{autoFocus:!0,value:i,placeholder:s("projectIcons.search"),onChange:c=>x(c.target.value)})]}),e.jsxs("div",{className:"project-icon-options","aria-label":s("projectIcons.title"),children:[e.jsxs("button",{type:"button","aria-pressed":n===null,className:`project-icon-option project-icon-reset${n===null?" selected":""}`,title:s("projectIcons.useInitial"),onClick:()=>N(null),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{fallback:L(o?.name??"")})}),e.jsx("span",{children:s("projectIcons.useInitial")})]}),v.map(({name:c})=>e.jsxs("button",{type:"button","aria-pressed":n===c,className:`project-icon-option${n===c?" selected":""}`,title:s(`projectIcons.icons.${c}.name`),onClick:()=>N(c),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{icon:c,fallback:"?"})}),e.jsx("span",{children:s(`projectIcons.icons.${c}.name`)})]},c))]}),v.length===0&&e.jsx("p",{className:"project-icon-picker-empty",children:s("projectIcons.noMatches",{query:i})}),e.jsxs("div",{className:"project-icon-advanced",children:[e.jsx("label",{htmlFor:"project-icon-advanced-name",children:s("projectIcons.advancedName")}),e.jsxs("div",{className:"project-icon-advanced-input",children:[e.jsx("input",{id:"project-icon-advanced-name",value:I,placeholder:s("projectIcons.advancedNamePlaceholder"),onChange:c=>w(c.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),I.trim()&&e.jsx("span",{className:"project-icon-advanced-preview","aria-label":s("projectIcons.advancedPreview"),children:e.jsx(h,{icon:n,fallback:"?"})})]}),e.jsxs("p",{children:[s("projectIcons.advancedNameDescription")," ",e.jsx("a",{href:"https://icon-sets.iconify.design/lucide/",target:"_blank",rel:"noreferrer",children:s("projectIcons.browse")})]})]})]})})}export{J as ProjectIconPickerDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as J,r as n,j as e}from"./react-CltQJflK.js";import{c as f,a as N,L as z,e as R}from"./index-DF5cor0N.js";import{E as T,G as ze,S as _,I as xe,J as Le,K as Me,C as ge,L as Oe}from"./ProjectWorkspace-BJFxjMCn.js";import{E as Re}from"./eye-swovgNYS.js";import{X as me,n as $e,m as Ae,g as Pe,p as He}from"./index-C5T8_lAl.js";import{T as je}from"./type-C-6Jq_0r.js";import{S as De}from"./sigma-DoHJQYf7.js";import{R as B}from"./refresh-cw-BHVcjInn.js";import"./check-Hlb-tLSh.js";import"./index-Do5FsFqg.js";import"./chevron-up-D0psXvTv.js";const Ve=f("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Xe=f("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const ue=f("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const We=f("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);const qe=f("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const _e=f("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);const Be=f("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);const Je=f("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);function Ke(h,i){const r=h.filter(a=>a.type==="file"&&["latexmkrc",".latexmkrc"].includes(a.path.split("/").at(-1)??"")).map(a=>a.path);i&&h.some(a=>a.type==="file"&&a.path===i)&&!r.includes(i)&&r.push(i);const o=a=>a==="latexmkrc"?0:a===".latexmkrc"?1:a.includes("/")?3:2;return r.sort((a,d)=>o(a)-o(d)||a.localeCompare(d))}const Ie=[{id:"texlive",name:"TeX Live"},{id:"pdflatex",name:"pdfLaTeX"},{id:"xelatex",name:"XeLaTeX"},{id:"lualatex",name:"LuaLaTeX"},{id:"latexmk",name:"latexmk"},{id:"bibtex",name:"BibTeX"},{id:"biber",name:"Biber"},{id:"texcount",name:"TeXcount"},{id:"chktex",name:"ChkTeX"}];function Qe(){const{t:h}=J(),[i,r]=n.useState(!1);return i?e.jsx(Ue,{}):e.jsx("div",{className:"compiler-versions",children:e.jsxs("button",{type:"button",className:"compiler-versions-toggle",onClick:()=>r(!0),children:[e.jsx(Re,{size:14,"aria-hidden":"true"}),h("projectSettings.showSoftwareVersions")]})})}function Ue(){const{t:h}=J(),i=n.useId(),[r,o]=n.useState(null);n.useEffect(()=>{const d=new AbortController;return N("/api/compiler/versions",{signal:d.signal}).then(u=>{d.signal.aborted||o(u)}).catch(()=>{d.signal.aborted||o({tools:[]})}),()=>d.abort()},[]);const a=new Map(r?.tools.map(d=>[d.id,d.version]));return e.jsxs("section",{className:"compiler-versions","aria-labelledby":i,"aria-busy":r===null,children:[e.jsxs("h3",{id:i,children:[h("projectSettings.softwareVersions"),r===null&&e.jsx(z,{size:13,className:"spin","aria-label":h("common.loading")})]}),e.jsx("dl",{children:Ie.map(({id:d,name:u})=>e.jsxs("div",{children:[e.jsx("dt",{children:u}),e.jsx("dd",{className:a.get(d)?"":"compiler-version-unknown",children:r===null?"—":a.get(d)??h("projectSettings.unknownVersion")})]},d))})]})}function Ge({name:h,state:i,label:r,reloadLabel:o,onReload:a,compact:d=!1}){const u=i.status==="loading"?e.jsx(z,{className:"spin",size:14}):i.status==="working"?e.jsx(ge,{size:14}):e.jsx(ue,{size:14}),C=e.jsxs(e.Fragment,{children:[u,e.jsx("strong",{children:h}),e.jsx("span",{children:r}),i.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:o,"aria-label":o,onClick:a,children:[e.jsx(B,{size:12}),o]})]});return d?e.jsxs("span",{className:`browser-tool-status compact ${i.status}`,role:"status","aria-live":"polite","aria-label":`${h}: ${r}`,title:i.error||void 0,children:[u,e.jsx("span",{children:r}),i.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:o,"aria-label":o,onClick:a,children:e.jsx(B,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${i.status}`,title:i.error||void 0,children:C})}function ot({onClose:h,project:i,projectId:r,site:o,files:a,dictionaryWords:d,onDictionaryChange:u,editorPreferences:C,onEditorPreferences:be,spellCheckCount:g,spellCheckUniqueCount:ke,spellCheckIndex:v,onSpellCheckNavigate:L,onProject:K}){const{t:s}=J(),[$,I]=n.useState(i.engine),[A,P]=n.useState(!!i.latexmkrc),[H,Q]=n.useState(i.name),[S,U]=n.useState(i.mainFile),[D,G]=n.useState(i.chktexEnabled),[j,Z]=n.useState(!1),M=n.useRef(null),w=n.useRef(!0),Y=n.useRef({name:i.name,mainFile:i.mainFile,engine:i.engine,latexmkrc:i.latexmkrc,chktexEnabled:i.chktexEnabled}),[E,ee]=n.useState(null),[te,V]=n.useState(""),[X,se]=n.useState(""),[ie,O]=n.useState(""),[y,W]=n.useState("checking"),[fe,ve]=n.useState(0),[x,ne]=n.useState("appearance"),[c,m]=n.useState(C),ae=n.useSyncExternalStore(T.subscribe,T.getSnapshot,T.getSnapshot),b=i.permission==="owner",re=i.permission!=="read",ce=i.permission!=="read";n.useEffect(()=>m(C),[C]),n.useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]),n.useEffect(()=>{ze().catch(T.failed)},[r]),n.useEffect(()=>{const t=new AbortController;return W("checking"),N(`/api/projects/${r}/spellcheck/status`,{signal:t.signal}).then(l=>{t.signal.aborted||W(l.available?"available":"unavailable")}).catch(()=>{t.signal.aborted||W("error")}),()=>t.abort()},[r,fe]);const Se=()=>{Oe().catch(T.failed)},F=Ke(a,i.latexmkrc),le=i.latexmkrc&&F.includes(i.latexmkrc)?i.latexmkrc:F[0]??"",oe=a.length>0&&i.latexmkrc!==null&&!F.includes(i.latexmkrc);n.useEffect(()=>{oe&&P(!1)},[oe]),n.useEffect(()=>{if(x!=="compiler")return;const t=new AbortController;return ee(null),N(`/api/projects/${r}/main-files`,{signal:t.signal}).then(l=>ee(l.mainFiles)).catch(l=>{l instanceof Error&&l.name==="AbortError"||V(R(l))}),()=>t.abort()},[r,a,x]);const ye=E??[i.mainFile],Ne=E!==null&&!E.includes(S),de=async()=>{if(M.current)return;const t=a.length===0&&i.latexmkrc&&o.allowProjectLatexmkrc!==!1?i.latexmkrc:A&&o.allowProjectLatexmkrc!==!1&&le||null,l=Y.current,k={};if(H!==l.name&&(k.name=H),S!==l.mainFile&&(k.mainFile=S),$!==l.engine&&(k.engine=$),t!==l.latexmkrc&&(k.latexmkrc=t),D!==l.chktexEnabled&&(k.chktexEnabled=D),Object.keys(k).length===0)return;const Te=Object.fromEntries(Object.keys(k).map(p=>[p,l[p]])),q=new AbortController;M.current=q,Z(!0);try{V("");const p=await N(`/api/projects/${r}`,{method:"PATCH",signal:q.signal,body:JSON.stringify({...k,expectedSettings:Te})});if(!w.current){K(p.project);return}Y.current={name:p.project.name,mainFile:p.project.mainFile,engine:p.project.engine,latexmkrc:p.project.latexmkrc,chktexEnabled:p.project.chktexEnabled},Q(p.project.name),U(p.project.mainFile),I(p.project.engine),G(p.project.chktexEnabled),P(!!p.project.latexmkrc),K(p.project)}catch(p){w.current&&V(R(p))}finally{M.current===q&&(M.current=null,w.current&&Z(!1))}},pe=()=>be(c),Ce=()=>{if(x==="appearance")return pe();b&&de()},we=s(x==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),Ee=x==="appearance"||b,he=async()=>{const t=X.trim();if(t)try{const l=await N(`/api/projects/${r}/dictionary`,{method:"POST",body:JSON.stringify({word:t})});u(l.words),se(""),O("")}catch(l){O(R(l))}},Fe=async t=>{try{const l=await N(`/api/projects/${r}/dictionary/${encodeURIComponent(t)}`,{method:"DELETE"});u(l.words),O("")}catch(l){O(R(l))}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"drawer-title settings-drawer-title",children:[e.jsx("strong",{children:s("editor.projectSettings")}),e.jsxs("div",{className:"drawer-title-actions",children:[Ee&&e.jsxs("button",{type:"button",className:"drawer-settings-save",disabled:x==="compiler"&&j,"aria-busy":x==="compiler"&&j,onClick:Ce,children:[x==="compiler"&&j?e.jsx(z,{className:"spin",size:14}):e.jsx(_,{size:14}),e.jsx("span",{children:we})]}),e.jsx("button",{type:"button","aria-label":s("common.close"),onClick:h,children:e.jsx(me,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[te&&e.jsx("p",{className:"error",children:te}),e.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":s("common.settings"),children:[e.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":x==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${x==="appearance"?" active":""}`,onClick:()=>ne("appearance"),children:[e.jsx(je,{size:15}),s("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":x==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${x==="compiler"?" active":""}`,onClick:()=>ne("compiler"),children:[e.jsx(xe,{size:15}),s("projectSettings.compilerTab")]})]}),x==="appearance"?e.jsxs("section",{id:"settings-panel-appearance",role:"tabpanel","aria-labelledby":"settings-tab-appearance",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(je,{size:15}),e.jsx("strong",{children:s("projectSettings.editorAppearance")})]}),e.jsx("p",{className:"settings-description appearance-description",children:s("projectSettings.editorAppearanceDescription")}),e.jsxs("label",{children:[s("projectSettings.fontFamily"),e.jsx("select",{value:c.font,onChange:t=>m({...c,font:t.target.value}),children:Le.map(t=>e.jsx("option",{value:t.id,children:s(t.labelKey)},t.id))})]}),e.jsxs("label",{children:[s("projectSettings.fontSize"),e.jsx("select",{value:c.fontSize,onChange:t=>m({...c,fontSize:Number(t.target.value)}),children:[12,13,14,15,16,18,20].map(t=>e.jsxs("option",{value:t,children:[t," px"]},t))})]}),e.jsxs("label",{children:[s("projectSettings.lineHeight"),e.jsxs("select",{value:c.lineHeight,onChange:t=>m({...c,lineHeight:Number(t.target.value)}),children:[e.jsx("option",{value:1.45,children:s("projectSettings.lineHeightCompact")}),e.jsx("option",{value:1.65,children:s("projectSettings.lineHeightNormal")}),e.jsx("option",{value:1.85,children:s("projectSettings.lineHeightRelaxed")})]})]}),e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.lineWrapping,onChange:t=>m({...c,lineWrapping:t.target.checked})}),e.jsx(Je,{size:15}),e.jsx("span",{children:s("projectSettings.lineWrapping")})]}),e.jsx("div",{className:"editor-preference",children:e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.showTooltips,onChange:t=>m({...c,showTooltips:t.target.checked})}),e.jsx(qe,{size:15}),e.jsx("span",{children:s("projectSettings.showTooltips")})]})}),e.jsx("div",{className:"editor-preference",children:e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.mathPreviewOnHover,onChange:t=>m({...c,mathPreviewOnHover:t.target.checked})}),e.jsx(De,{size:15}),e.jsx("span",{children:s("projectSettings.mathPreviewOnHover")})]})}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.spellCheck,onChange:t=>m({...c,spellCheck:t.target.checked})}),e.jsx("span",{children:s("projectSettings.spellCheck")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.writingCheckDescription")," ",e.jsx("a",{href:"https://writewithharper.com/docs/integrations/language-server",target:"_blank",rel:"noreferrer",children:"Harper"})]}),g!==null&&e.jsxs("div",{className:`spell-check-result${g?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(Be,{size:14}),e.jsx("span",{children:g?s("projectSettings.writingIssues",{count:g,uniqueCount:ke??0}):s("chktex.noIssues")}),g>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:s("projectSettings.spellCheckFirst"),"aria-label":s("projectSettings.spellCheckFirst"),disabled:v<=0,onClick:()=>L(0),children:e.jsx(Ve,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckPrevious"),"aria-label":s("projectSettings.spellCheckPrevious"),disabled:v<=0,onClick:()=>L(v-1),children:e.jsx($e,{size:14})}),e.jsx("span",{className:"spell-check-position",children:s("projectSettings.spellCheckPosition",{current:Math.min(v+1,g),total:g})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckNext"),"aria-label":s("projectSettings.spellCheckNext"),disabled:v>=g-1,onClick:()=>L(v+1),children:e.jsx(Ae,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckLast"),"aria-label":s("projectSettings.spellCheckLast"),disabled:v>=g-1,onClick:()=>L(g-1),children:e.jsx(Xe,{size:14})})]})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.vimMode,onChange:t=>m({...c,vimMode:t.target.checked})}),e.jsx("span",{children:s("projectSettings.vimMode")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.vimModeDescription")," ",e.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:s("projectSettings.vimHelp")})]})]}),e.jsx("div",{className:"editor-preference",children:e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.openFilesInTabs,onChange:t=>m({...c,openFilesInTabs:t.target.checked})}),e.jsx(_e,{size:15}),e.jsx("span",{children:s("projectSettings.openFilesInTabs")})]})}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!re,checked:c.formatOnCompile,onChange:t=>m({...c,formatOnCompile:t.target.checked})}),e.jsx(Me,{size:15}),e.jsx("span",{children:s("projectSettings.formatOnCompile")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.formatterDescription")," ",e.jsx("a",{href:"https://www.npmjs.com/package/tex-fmt",target:"_blank",rel:"noreferrer",children:s("projectSettings.formatterInstall")})," · ",e.jsx("a",{href:"https://github.com/FlamingTempura/bibtex-tidy",target:"_blank",rel:"noreferrer",children:s("projectSettings.bibtexTidyInstall")}),!re&&e.jsxs(e.Fragment,{children:[" ",s("projectSettings.formatRequiresWrite")]})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"tex-fmt-options-field",children:[e.jsxs("span",{className:"tex-fmt-options-heading",children:[e.jsx("span",{children:s("projectSettings.texFmtOptions")}),e.jsx(Ge,{compact:!0,name:"tex-fmt",state:ae,label:s(`projectSettings.toolStatus.${ae.status}`),reloadLabel:s("projectSettings.reloadTool"),onReload:Se})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:c.texFmtConfig,placeholder:s("projectSettings.texFmtOptionsPlaceholder"),onChange:t=>m({...c,texFmtConfig:t.target.value})})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.texFmtOptionsDescription")})]}),e.jsxs("div",{className:"settings-section-title dictionary-heading",children:[e.jsx(Pe,{size:15}),e.jsx("strong",{children:s("projectSettings.dictionary")}),e.jsxs("span",{className:`harper-cli-status ${y}`,role:"status","aria-live":"polite",children:[y==="checking"?e.jsx(z,{className:"spin",size:12,"aria-hidden":"true"}):y==="available"?e.jsx(ge,{size:12,"aria-hidden":"true"}):e.jsx(ue,{size:12,"aria-hidden":"true"}),e.jsxs("span",{children:["Harper CLI · ",s(`projectSettings.harperCliStatus.${y}`)]}),(y==="error"||y==="unavailable")&&e.jsx("button",{type:"button",title:s("projectSettings.harperCliRetry"),"aria-label":s("projectSettings.harperCliRetry"),onClick:()=>ve(t=>t+1),children:e.jsx(B,{size:12})})]})]}),e.jsx("p",{className:"settings-description",children:s("projectSettings.dictionaryDescription")}),ie&&e.jsx("p",{className:"error dictionary-error",children:ie}),ce&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:X,placeholder:s("projectSettings.dictionaryPlaceholder"),onChange:t=>se(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),he())}}),e.jsx("button",{type:"button",disabled:!X.trim(),onClick:()=>{he()},children:s("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[d.map(t=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:t}),ce&&e.jsx("button",{type:"button",title:s("common.delete"),"aria-label":`${s("common.delete")} ${t}`,onClick:()=>{Fe(t)},children:e.jsx(me,{size:13})})]},t)),d.length===0&&e.jsx("span",{className:"dictionary-empty",children:s("projectSettings.dictionaryEmpty")})]}),e.jsx("div",{className:"settings-actions",children:e.jsxs("button",{className:"settings-save",onClick:pe,children:[e.jsx(_,{size:15}),s("projectSettings.saveAppearance")]})})]}):e.jsxs("section",{id:"settings-panel-compiler",role:"tabpanel","aria-labelledby":"settings-tab-compiler",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(xe,{size:15}),e.jsx("strong",{children:s("projectSettings.compilerTab")})]}),e.jsx("p",{className:"settings-description compiler-description",children:s("projectSettings.compilerDescription")}),e.jsxs("label",{children:[s("projects.name"),e.jsx("input",{disabled:!b||j,value:H,onChange:t=>Q(t.target.value)})]}),e.jsxs("label",{children:[s("projectSettings.mainFile"),e.jsxs("select",{disabled:!b||j||E===null||E.length===0,value:S,onChange:t=>U(t.target.value),children:[Ne&&e.jsx("option",{value:S,disabled:!0,children:s("projectSettings.invalidMainFileOption",{path:S})}),ye.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{children:[s(A&&F.length>0&&o.allowProjectLatexmkrc!==!1?"projectSettings.defaultEngine":"projectSettings.engine"),e.jsx("select",{disabled:!b||j,value:$,onChange:t=>I(t.target.value),children:(o.allowedEngines??["pdflatex","xelatex","lualatex"]).map(t=>e.jsx("option",{children:t},t))})]}),e.jsxs("div",{className:"editor-preference compiler-check-option",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!b||j,checked:D,onChange:t=>G(t.target.checked)}),e.jsx(We,{size:15}),e.jsx("span",{children:s("chktex.enabled")})]}),e.jsxs("p",{className:"field-hint",children:[s("chktex.description")," ",e.jsx("a",{href:"https://www.nongnu.org/chktex/",target:"_blank",rel:"noreferrer",children:"ChkTeX"})]})]}),F.length>0&&e.jsxs("div",{className:"editor-preference latexmkrc-setting",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!b||j||o.allowProjectLatexmkrc===!1,checked:A&&o.allowProjectLatexmkrc!==!1,onChange:t=>P(t.target.checked)}),e.jsx("span",{children:s("projectSettings.enableLatexmkrc")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.latexmkrcSource",{path:le})}),o.allowProjectLatexmkrc===!1?e.jsx("p",{className:"field-hint",children:s("projectSettings.latexmkrcUnavailable")}):e.jsxs("p",{className:"field-hint latexmkrc-warning",children:[e.jsx(He,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:s("projectSettings.latexmkrcWarning")})]})]}),e.jsx("div",{className:"settings-actions",children:b&&e.jsxs("button",{className:"settings-save",disabled:j,"aria-busy":j,onClick:()=>{de()},children:[j?e.jsx(z,{className:"spin",size:15}):e.jsx(_,{size:15}),s("projectSettings.saveCompiler")]})}),e.jsx(Qe,{})]})]})]})}export{ot as ProjectSettings};
|