texlite 0.11.0 → 0.13.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 +64 -12
- package/dist/client/assets/AdminUsers-CfKlKMUu.js +1 -0
- package/dist/client/assets/{CitationLibraryDialog-tVD3i2gg.js → CitationLibraryDialog-BpnX28Le.js} +1 -1
- package/dist/client/assets/Dashboard-nbu54S0M.js +2 -0
- package/dist/client/assets/GitDialog-CrLMkNSh.js +3 -0
- package/dist/client/assets/GitHubAccountDialog-Bt0c8yBQ.js +1 -0
- package/dist/client/assets/HistoryDialog-CNEHivv5.js +7 -0
- package/dist/client/assets/LatexEditor-Dq9cqkpP.js +138 -0
- package/dist/client/assets/{PdfPreview-CMkO72I5.js → PdfPreview-xiB5Piyv.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-BSdiBwtv.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-isGMXCfG.js → ProjectNavigationDialogs-C7cD7PvT.js} +1 -1
- package/dist/client/assets/ProjectSettings-CRHG-jAZ.js +1 -0
- package/dist/client/assets/ProjectWorkspace-BdmKRaK2.js +32 -0
- package/dist/client/assets/{SelectionHistoryDialog-ZvAhIJMy.js → SelectionHistoryDialog-JL_2qLGf.js} +1 -1
- package/dist/client/assets/SystemMetricsDialog-BIWJwsxD.js +1 -0
- package/dist/client/assets/{TagManagementDialog-qhZfHgTr.js → TagManagementDialog-CJXWtqXN.js} +1 -1
- package/dist/client/assets/{WordCountDialog-tFhMCGyn.js → WordCountDialog-sr21g-ex.js} +1 -1
- package/dist/client/assets/check-CzfkSYah.js +1 -0
- package/dist/client/assets/{chktex-tM1XXPk2.js → chktex-BEVGf49u.js} +1 -1
- package/dist/client/assets/{editor-B9HNwtsd.js → editor-taw1iptB.js} +1 -1
- package/dist/client/assets/external-link-DuxFggPh.js +1 -0
- package/dist/client/assets/github-D805ABUR.js +1 -0
- package/dist/client/assets/{hard-drive-CkIPwUSV.js → hard-drive-De8wdQpw.js} +1 -1
- package/dist/client/assets/index-BYAZKPNO.js +10 -0
- package/dist/client/assets/{index-DTYEGzB7.js → index-CXWzCgcU.js} +1 -1
- package/dist/client/assets/index-Cc9-JFj7.css +1 -0
- package/dist/client/assets/{minimize-2-CLuDohEf.js → minimize-2-DP0ZJHGp.js} +1 -1
- package/dist/client/assets/{minus-BpuvzV2m.js → minus-BDK-NFbs.js} +1 -1
- package/dist/client/assets/{plus-BFr75l91.js → plus-GB_3iSP8.js} +1 -1
- package/dist/client/assets/{refresh-cw-DyA4NKh7.js → refresh-cw-DwUVAz9L.js} +1 -1
- package/dist/client/assets/{search-Nu4OcY_n.js → search-BJ0HR5pC.js} +1 -1
- package/dist/client/assets/{sigma-B-wjepsY.js → sigma-DOfd27T4.js} +1 -1
- package/dist/client/assets/{spellCheck-C-bNJsIU.js → spellCheck-CRN7y5Qf.js} +1 -1
- package/dist/client/assets/{tags-BSA08jK3.js → tags-BdjO5Lmr.js} +1 -1
- package/dist/client/assets/{type-BCdIbDmF.js → type-qV4gbXDh.js} +1 -1
- package/dist/client/assets/{user-plus-gFwY-NA3.js → user-plus-CPne6OnV.js} +1 -1
- package/dist/client/assets/x-DPtqmVM9.js +1 -0
- package/dist/client/index.html +3 -3
- package/dist/server/db.js +30 -1
- package/dist/server/git.js +64 -29
- package/dist/server/harper.js +14 -0
- package/dist/server/history.js +14 -5
- package/dist/server/i18n.js +2 -2
- package/dist/server/routes/projectGit.js +10 -11
- package/dist/server/routes/projectHistory.js +32 -5
- package/dist/server/routes/projectMembers.js +0 -5
- package/dist/server/routes/projects.js +10 -0
- package/dist/server/routes/users.js +0 -2
- package/dist/shared/historyFiles.js +6 -0
- package/package.json +3 -1
- package/dist/client/assets/AdminUsers-BExOMZsW.js +0 -1
- package/dist/client/assets/Dashboard-DRt4rjKP.js +0 -2
- package/dist/client/assets/GitDialog-CjDCi1uh.js +0 -3
- package/dist/client/assets/HistoryDialog-Pa9mK3Ky.js +0 -7
- package/dist/client/assets/LatexEditor-8r486VeG.js +0 -138
- package/dist/client/assets/ProjectIconPickerDialog-B52xbSyr.js +0 -1
- package/dist/client/assets/ProjectSettings-Br_kJ113.js +0 -1
- package/dist/client/assets/ProjectWorkspace-CcbrdCy8.js +0 -32
- package/dist/client/assets/SystemMetricsDialog-D4ouU4HI.js +0 -1
- package/dist/client/assets/check-DKIW1zpR.js +0 -1
- package/dist/client/assets/index-90X2GUd_.css +0 -1
- package/dist/client/assets/index-CqBmQAzW.js +0 -10
- package/dist/client/assets/key-round-BEnQo7IM.js +0 -1
- package/dist/client/assets/x-Cspw_pa4.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as Q,r as t,j as e}from"./react-BVUjbTTn.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-BpuvzV2m.js";import{P as xe}from"./plus-BFr75l91.js";import{d as G}from"./index-CqBmQAzW.js";import{R as J}from"./refresh-cw-DyA4NKh7.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-BVUjbTTn.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-BDK-NFbs.js";import{P as xe}from"./plus-GB_3iSP8.js";import{d as G}from"./index-BYAZKPNO.js";import{R as J}from"./refresh-cw-DwUVAz9L.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-BVUjbTTn.js";import{M as $,h as M}from"./index-BYAZKPNO.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-nbu54S0M.js";import{S as q}from"./search-BJ0HR5pC.js";import"./hard-drive-De8wdQpw.js";import"./x-DPtqmVM9.js";import"./github-D805ABUR.js";import"./sigma-DOfd27T4.js";import"./tags-BdjO5Lmr.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-
|
|
1
|
+
import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-BYAZKPNO.js";import{S as $}from"./search-BJ0HR5pC.js";import{F as J,e as K}from"./x-DPtqmVM9.js";import{C as G}from"./check-CzfkSYah.js";const T=U("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);function te({open:c,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(0),m=r.useRef(null),y=r.useRef(null),l=r.useMemo(()=>h.filter(s=>s.type==="file").map(s=>({entry:s,score:H(s.path,n)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,n]);r.useEffect(()=>{c&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[c]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{c&&y.current?.scrollIntoView({block:"nearest"})},[c,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:c,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:u,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:m,value:n,placeholder:a("navigation.filePlaceholder"),onChange:s=>{f(s.target.value),o(0)},onKeyDown:s=>{s.key==="ArrowDown"&&(s.preventDefault(),o(i=>Math.min(l.length-1,i+1))),s.key==="ArrowUp"&&(s.preventDefault(),o(i=>Math.max(0,i-1))),s.key==="Enter"&&l[d]&&(s.preventDefault(),S(l[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[l.map(({entry:s},i)=>e.jsxs("button",{ref:i===d?y:void 0,className:i===d?"active":"",onMouseEnter:()=>o(i),onClick:()=>S(s.path),children:[e.jsx(K,{size:14}),e.jsx("span",{children:s.path}),i===d&&e.jsx(G,{size:13})]},s.path)),l.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function se({open:c,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(""),[m,y]=r.useState(!1),[l,S]=r.useState(!1),[s,i]=r.useState([]),[g,C]=r.useState(0),[P,D]=r.useState(!1),[b,k]=r.useState(!1),[W,N]=r.useState(!1),[R,M]=r.useState(""),[z,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!c){v.current?.abort();return}if(M(""),w(""),!n.trim()){i([]),C(0),D(!1);return}const t=window.setTimeout(()=>{v.current?.abort();const x=new AbortController;v.current=x,k(!0);const E=new URLSearchParams({q:n});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),q(`/api/projects/${h.id}/search?${E}`,{signal:x.signal}).then(j=>{i(j.matches),C(j.total),D(j.truncated)}).catch(j=>{j instanceof DOMException&&j.name==="AbortError"||w(L(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[c,h.id,n,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await q(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:m,wholeWord:l})});M(a("navigation.replaced",{count:t.replacements,files:t.files.length})),i([]),C(0),Q(x=>x+1)}catch(t){w(L(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:c,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:u,footer:e.jsx("button",{onClick:()=>u(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[z&&e.jsx("p",{className:"error",children:z}),R&&e.jsx("p",{className:"success",children:R}),e.jsxs("div",{className:"project-search-form",children:[e.jsxs("label",{className:"project-search-query",children:[e.jsx($,{size:16}),e.jsx("input",{autoFocus:!0,value:n,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(T,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:t=>o(t.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:m,onChange:t=>y(t.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:l,onChange:t=>S(t.target.checked)}),a("editor.search.wholeWord")]}),h.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(T,{size:13}),a("navigation.replaceAll",{count:g})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:g})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:s.length})})]}),e.jsxs("div",{className:"project-search-results",children:[s.map((t,x)=>e.jsxs("button",{onClick:()=>{p(t.path,t.line,t.column),u(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[t.path,e.jsxs("small",{children:[":",t.line,":",t.column]})]}),e.jsxs("code",{children:[t.preview.slice(0,t.matchStart),e.jsx("mark",{children:t.preview.slice(t.matchStart,t.matchEnd)}),t.preview.slice(t.matchEnd)]})]})]},`${t.path}-${t.line}-${t.column}-${x}`)),!b&&n.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(B,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:g}),confirmLabel:a("navigation.replaceAll",{count:g}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{I()}})]})}function H(c,h){const u=c.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let n=0,f=0;for(const d of p){const o=u.indexOf(d,n);if(o<0)return-1;f+=o===n?5:1,n=o+1}return f-u.length/100}function L(c){return c instanceof Error?c.message:String(c)}export{se as ProjectSearchDialog,te as QuickOpenDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as ze,r as i,j as e}from"./react-BVUjbTTn.js";import{c as u,g as E,h as O,d as R}from"./index-BYAZKPNO.js";import{E as z,G as Te,S as V,I as he,J as Me,K as Le,B as je,L as Oe}from"./ProjectWorkspace-BdmKRaK2.js";import{X as xe,i as Re,C as $e,d as Ae,k as He}from"./x-DPtqmVM9.js";import{T as me}from"./type-qV4gbXDh.js";import{S as Pe}from"./sigma-DOfd27T4.js";import{R as J}from"./refresh-cw-DwUVAz9L.js";import"./check-CzfkSYah.js";import"./search-BJ0HR5pC.js";import"./user-plus-CPne6OnV.js";const De=u("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const We=u("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const ge=u("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 qe=u("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 Be=u("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=u("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 Ve=u("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=u("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(b,a){const o=b.filter(r=>r.type==="file"&&["latexmkrc",".latexmkrc"].includes(r.path.split("/").at(-1)??"")).map(r=>r.path);a&&b.some(r=>r.type==="file"&&r.path===a)&&!o.includes(a)&&o.push(a);const p=r=>r==="latexmkrc"?0:r===".latexmkrc"?1:r.includes("/")?3:2;return o.sort((r,k)=>p(r)-p(k)||r.localeCompare(k))}function Qe({name:b,state:a,label:o,reloadLabel:p,onReload:r,compact:k=!1}){const S=a.status==="loading"?e.jsx(R,{className:"spin",size:14}):a.status==="working"?e.jsx(je,{size:14}):e.jsx(ge,{size:14}),N=e.jsxs(e.Fragment,{children:[S,e.jsx("strong",{children:b}),e.jsx("span",{children:o}),a.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:p,"aria-label":p,onClick:r,children:[e.jsx(J,{size:12}),p]})]});return k?e.jsxs("span",{className:`browser-tool-status compact ${a.status}`,role:"status","aria-live":"polite","aria-label":`${b}: ${o}`,title:a.error||void 0,children:[S,e.jsx("span",{children:o}),a.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:p,"aria-label":p,onClick:r,children:e.jsx(J,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${a.status}`,title:a.error||void 0,children:N})}function it({onClose:b,project:a,projectId:o,site:p,files:r,dictionaryWords:k,onDictionaryChange:S,editorPreferences:N,onEditorPreferences:ue,spellCheckCount:m,spellCheckUniqueCount:be,spellCheckIndex:f,onSpellCheckNavigate:T,onProject:K}){const{t:s}=ze(),[$,Q]=i.useState(a.engine),[A,H]=i.useState(!!a.latexmkrc),[P,U]=i.useState(a.name),[v,X]=i.useState(a.mainFile),[D,G]=i.useState(a.chktexEnabled),[x,Z]=i.useState(!1),M=i.useRef(null),C=i.useRef(!0),Y=i.useRef({name:a.name,mainFile:a.mainFile,engine:a.engine,latexmkrc:a.latexmkrc,chktexEnabled:a.chktexEnabled}),[w,I]=i.useState(null),[ee,W]=i.useState(""),[q,te]=i.useState(""),[se,L]=i.useState(""),[y,B]=i.useState("checking"),[ke,fe]=i.useState(0),[d,ae]=i.useState("appearance"),[n,h]=i.useState(N),ie=i.useSyncExternalStore(z.subscribe,z.getSnapshot,z.getSnapshot),j=a.permission==="owner",ne=a.permission!=="read",re=a.permission!=="read";i.useEffect(()=>h(N),[N]),i.useEffect(()=>(C.current=!0,()=>{C.current=!1}),[]),i.useEffect(()=>{Te().catch(z.failed)},[o]),i.useEffect(()=>{const t=new AbortController;return B("checking"),E(`/api/projects/${o}/spellcheck/status`,{signal:t.signal}).then(c=>{t.signal.aborted||B(c.available?"available":"unavailable")}).catch(()=>{t.signal.aborted||B("error")}),()=>t.abort()},[o,ke]);const ve=()=>{Oe().catch(z.failed)},F=Ke(r,a.latexmkrc),ce=a.latexmkrc&&F.includes(a.latexmkrc)?a.latexmkrc:F[0]??"",le=r.length>0&&a.latexmkrc!==null&&!F.includes(a.latexmkrc);i.useEffect(()=>{le&&H(!1)},[le]),i.useEffect(()=>{if(d!=="compiler")return;const t=new AbortController;return I(null),E(`/api/projects/${o}/main-files`,{signal:t.signal}).then(c=>I(c.mainFiles)).catch(c=>{c instanceof Error&&c.name==="AbortError"||W(O(c))}),()=>t.abort()},[o,r,d]);const ye=w??[a.mainFile],Se=w!==null&&!w.includes(v),oe=async()=>{if(M.current)return;const t=r.length===0&&a.latexmkrc&&p.allowProjectLatexmkrc!==!1?a.latexmkrc:A&&p.allowProjectLatexmkrc!==!1&&ce||null,c=Y.current,g={};if(P!==c.name&&(g.name=P),v!==c.mainFile&&(g.mainFile=v),$!==c.engine&&(g.engine=$),t!==c.latexmkrc&&(g.latexmkrc=t),D!==c.chktexEnabled&&(g.chktexEnabled=D),Object.keys(g).length===0)return;const Ee=Object.fromEntries(Object.keys(g).map(l=>[l,c[l]])),_=new AbortController;M.current=_,Z(!0);try{W("");const l=await E(`/api/projects/${o}`,{method:"PATCH",signal:_.signal,body:JSON.stringify({...g,expectedSettings:Ee})});if(!C.current){K(l.project);return}Y.current={name:l.project.name,mainFile:l.project.mainFile,engine:l.project.engine,latexmkrc:l.project.latexmkrc,chktexEnabled:l.project.chktexEnabled},U(l.project.name),X(l.project.mainFile),Q(l.project.engine),G(l.project.chktexEnabled),H(!!l.project.latexmkrc),K(l.project)}catch(l){C.current&&W(O(l))}finally{M.current===_&&(M.current=null,C.current&&Z(!1))}},pe=()=>ue(n),Ne=()=>{if(d==="appearance")return pe();j&&oe()},Ce=s(d==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),we=d==="appearance"||j,de=async()=>{const t=q.trim();if(t)try{const c=await E(`/api/projects/${o}/dictionary`,{method:"POST",body:JSON.stringify({word:t})});S(c.words),te(""),L("")}catch(c){L(O(c))}},Fe=async t=>{try{const c=await E(`/api/projects/${o}/dictionary/${encodeURIComponent(t)}`,{method:"DELETE"});S(c.words),L("")}catch(c){L(O(c))}};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:[we&&e.jsxs("button",{type:"button",className:"drawer-settings-save",disabled:d==="compiler"&&x,"aria-busy":d==="compiler"&&x,onClick:Ne,children:[d==="compiler"&&x?e.jsx(R,{className:"spin",size:14}):e.jsx(V,{size:14}),e.jsx("span",{children:Ce})]}),e.jsx("button",{type:"button","aria-label":s("common.close"),onClick:b,children:e.jsx(xe,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[ee&&e.jsx("p",{className:"error",children:ee}),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":d==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${d==="appearance"?" active":""}`,onClick:()=>ae("appearance"),children:[e.jsx(me,{size:15}),s("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":d==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${d==="compiler"?" active":""}`,onClick:()=>ae("compiler"),children:[e.jsx(he,{size:15}),s("projectSettings.compilerTab")]})]}),d==="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(me,{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:n.font,onChange:t=>h({...n,font:t.target.value}),children:Me.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:n.fontSize,onChange:t=>h({...n,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:n.lineHeight,onChange:t=>h({...n,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:n.lineWrapping,onChange:t=>h({...n,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:n.showTooltips,onChange:t=>h({...n,showTooltips:t.target.checked})}),e.jsx(Be,{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:n.mathPreviewOnHover,onChange:t=>h({...n,mathPreviewOnHover:t.target.checked})}),e.jsx(Pe,{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:n.spellCheck,onChange:t=>h({...n,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"})]}),m!==null&&e.jsxs("div",{className:`spell-check-result${m?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(Ve,{size:14}),e.jsx("span",{children:m?s("projectSettings.writingIssues",{count:m,uniqueCount:be??0}):s("chktex.noIssues")}),m>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:s("projectSettings.spellCheckFirst"),"aria-label":s("projectSettings.spellCheckFirst"),disabled:f<=0,onClick:()=>T(0),children:e.jsx(De,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckPrevious"),"aria-label":s("projectSettings.spellCheckPrevious"),disabled:f<=0,onClick:()=>T(f-1),children:e.jsx(Re,{size:14})}),e.jsx("span",{className:"spell-check-position",children:s("projectSettings.spellCheckPosition",{current:Math.min(f+1,m),total:m})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckNext"),"aria-label":s("projectSettings.spellCheckNext"),disabled:f>=m-1,onClick:()=>T(f+1),children:e.jsx($e,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckLast"),"aria-label":s("projectSettings.spellCheckLast"),disabled:f>=m-1,onClick:()=>T(m-1),children:e.jsx(We,{size:14})})]})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.vimMode,onChange:t=>h({...n,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:n.openFilesInTabs,onChange:t=>h({...n,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:!ne,checked:n.formatOnCompile,onChange:t=>h({...n,formatOnCompile:t.target.checked})}),e.jsx(Le,{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")}),!ne&&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(Qe,{compact:!0,name:"tex-fmt",state:ie,label:s(`projectSettings.toolStatus.${ie.status}`),reloadLabel:s("projectSettings.reloadTool"),onReload:ve})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:n.texFmtConfig,placeholder:s("projectSettings.texFmtOptionsPlaceholder"),onChange:t=>h({...n,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(Ae,{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(R,{className:"spin",size:12,"aria-hidden":"true"}):y==="available"?e.jsx(je,{size:12,"aria-hidden":"true"}):e.jsx(ge,{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:()=>fe(t=>t+1),children:e.jsx(J,{size:12})})]})]}),e.jsx("p",{className:"settings-description",children:s("projectSettings.dictionaryDescription")}),se&&e.jsx("p",{className:"error dictionary-error",children:se}),re&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:q,placeholder:s("projectSettings.dictionaryPlaceholder"),onChange:t=>te(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),de())}}),e.jsx("button",{type:"button",disabled:!q.trim(),onClick:()=>{de()},children:s("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[k.map(t=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:t}),re&&e.jsx("button",{type:"button",title:s("common.delete"),"aria-label":`${s("common.delete")} ${t}`,onClick:()=>{Fe(t)},children:e.jsx(xe,{size:13})})]},t)),k.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(V,{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(he,{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:!j||x,value:P,onChange:t=>U(t.target.value)})]}),e.jsxs("label",{children:[s("projectSettings.mainFile"),e.jsxs("select",{disabled:!j||x||w===null||w.length===0,value:v,onChange:t=>X(t.target.value),children:[Se&&e.jsx("option",{value:v,disabled:!0,children:s("projectSettings.invalidMainFileOption",{path:v})}),ye.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{children:[s(A&&F.length>0&&p.allowProjectLatexmkrc!==!1?"projectSettings.defaultEngine":"projectSettings.engine"),e.jsx("select",{disabled:!j||x,value:$,onChange:t=>Q(t.target.value),children:(p.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:!j||x,checked:D,onChange:t=>G(t.target.checked)}),e.jsx(qe,{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:!j||x||p.allowProjectLatexmkrc===!1,checked:A&&p.allowProjectLatexmkrc!==!1,onChange:t=>H(t.target.checked)}),e.jsx("span",{children:s("projectSettings.enableLatexmkrc")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.latexmkrcSource",{path:ce})}),p.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:j&&e.jsxs("button",{className:"settings-save",disabled:x,"aria-busy":x,onClick:()=>{oe()},children:[x?e.jsx(R,{className:"spin",size:15}):e.jsx(V,{size:15}),s("projectSettings.saveCompiler")]})})]})]})]})}export{it as ProjectSettings};
|